clang 21.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 ResolvedUnexpandedPackExpr *>,
237 SourceLocation>
239
240/// Describes whether we've seen any nullability information for the given
241/// file.
243 /// The first pointer declarator (of any pointer kind) in the file that does
244 /// not have a corresponding nullability annotation.
246
247 /// The end location for the first pointer declarator in the file. Used for
248 /// placing fix-its.
250
251 /// Which kind of pointer declarator we saw.
252 uint8_t PointerKind;
253
254 /// Whether we saw any type nullability annotations in the given file.
255 bool SawTypeNullability = false;
256};
257
258/// A mapping from file IDs to a record of whether we've seen nullability
259/// information in that file.
261 /// A mapping from file IDs to the nullability information for each file ID.
262 llvm::DenseMap<FileID, FileNullability> Map;
263
264 /// A single-element cache based on the file ID.
265 struct {
268 } Cache;
269
270public:
272 // Check the single-element cache.
273 if (file == Cache.File)
274 return Cache.Nullability;
275
276 // It's not in the single-element cache; flush the cache if we have one.
277 if (!Cache.File.isInvalid()) {
278 Map[Cache.File] = Cache.Nullability;
279 }
280
281 // Pull this entry into the cache.
282 Cache.File = file;
283 Cache.Nullability = Map[file];
284 return Cache.Nullability;
285 }
286};
287
288/// Tracks expected type during expression parsing, for use in code completion.
289/// The type is tied to a particular token, all functions that update or consume
290/// the type take a start location of the token they are looking at as a
291/// parameter. This avoids updating the type on hot paths in the parser.
293public:
294 PreferredTypeBuilder(bool Enabled) : Enabled(Enabled) {}
295
296 void enterCondition(Sema &S, SourceLocation Tok);
297 void enterReturn(Sema &S, SourceLocation Tok);
299 /// Handles e.g. BaseType{ .D = Tok...
301 const Designation &D);
302 /// Computing a type for the function argument may require running
303 /// overloading, so we postpone its computation until it is actually needed.
304 ///
305 /// Clients should be very careful when using this function, as it stores a
306 /// function_ref, clients should make sure all calls to get() with the same
307 /// location happen while function_ref is alive.
308 ///
309 /// The callback should also emit signature help as a side-effect, but only
310 /// if the completion point has been reached.
312 llvm::function_ref<QualType()> ComputeType);
313
315 void enterUnary(Sema &S, SourceLocation Tok, tok::TokenKind OpKind,
316 SourceLocation OpLoc);
317 void enterBinary(Sema &S, SourceLocation Tok, Expr *LHS, tok::TokenKind Op);
319 void enterSubscript(Sema &S, SourceLocation Tok, Expr *LHS);
320 /// Handles all type casts, including C-style cast, C++ casts, etc.
322
323 /// Get the expected type associated with this location, if any.
324 ///
325 /// If the location is a function argument, determining the expected type
326 /// involves considering all function overloads and the arguments so far.
327 /// In this case, signature help for these function overloads will be reported
328 /// as a side-effect (only if the completion point has been reached).
330 if (!Enabled || Tok != ExpectedLoc)
331 return QualType();
332 if (!Type.isNull())
333 return Type;
334 if (ComputeType)
335 return ComputeType();
336 return QualType();
337 }
338
339private:
340 bool Enabled;
341 /// Start position of a token for which we store expected type.
342 SourceLocation ExpectedLoc;
343 /// Expected type for a token starting at ExpectedLoc.
345 /// A function to compute expected type at ExpectedLoc. It is only considered
346 /// if Type is null.
347 llvm::function_ref<QualType()> ComputeType;
348};
349
351 SkipBodyInfo() = default;
352 bool ShouldSkip = false;
354 NamedDecl *Previous = nullptr;
355 NamedDecl *New = nullptr;
356};
357
358/// Describes the result of template argument deduction.
359///
360/// The TemplateDeductionResult enumeration describes the result of
361/// template argument deduction, as returned from
362/// DeduceTemplateArguments(). The separate TemplateDeductionInfo
363/// structure provides additional information about the results of
364/// template argument deduction, e.g., the deduced template argument
365/// list (if successful) or the specific template parameters or
366/// deduced arguments that were involved in the failure.
368 /// Template argument deduction was successful.
369 Success = 0,
370 /// The declaration was invalid; do nothing.
371 Invalid,
372 /// Template argument deduction exceeded the maximum template
373 /// instantiation depth (which has already been diagnosed).
375 /// Template argument deduction did not deduce a value
376 /// for every template parameter.
378 /// Template argument deduction did not deduce a value for every
379 /// expansion of an expanded template parameter pack.
381 /// Template argument deduction produced inconsistent
382 /// deduced values for the given template parameter.
384 /// Template argument deduction failed due to inconsistent
385 /// cv-qualifiers on a template parameter type that would
386 /// otherwise be deduced, e.g., we tried to deduce T in "const T"
387 /// but were given a non-const "X".
389 /// Substitution of the deduced template argument values
390 /// resulted in an error.
392 /// After substituting deduced template arguments, a dependent
393 /// parameter type did not match the corresponding argument.
395 /// After substituting deduced template arguments, an element of
396 /// a dependent parameter type did not match the corresponding element
397 /// of the corresponding argument (when deducing from an initializer list).
399 /// A non-depnedent component of the parameter did not match the
400 /// corresponding component of the argument.
402 /// When performing template argument deduction for a function
403 /// template, there were too many call arguments.
405 /// When performing template argument deduction for a function
406 /// template, there were too few call arguments.
408 /// The explicitly-specified template arguments were not valid
409 /// template arguments for the given template.
411 /// Checking non-dependent argument conversions failed.
413 /// The deduced arguments did not satisfy the constraints associated
414 /// with the template.
416 /// Deduction failed; that's all we know.
418 /// CUDA Target attributes do not match.
420 /// Some error which was already diagnosed.
422};
423
424/// Kinds of C++ special members.
432 Invalid
433};
434
435/// The kind of conversion being performed.
437 /// An implicit conversion.
438 Implicit,
439 /// A C-style cast.
441 /// A functional-style cast.
443 /// A cast other than a C-style cast.
444 OtherCast,
445 /// A conversion for an operand of a builtin overloaded operator.
447};
448
449enum class TagUseKind {
450 Reference, // Reference to a tag: 'struct foo *X;'
451 Declaration, // Fwd decl of a tag: 'struct foo;'
452 Definition, // Definition of a tag: 'struct foo { int X; } Y;'
453 Friend // Friend declaration: 'friend struct foo;'
454};
455
456/// Used with attributes/effects with a boolean condition, e.g. `nonblocking`.
457enum class FunctionEffectMode : uint8_t {
458 None, // effect is not present.
459 False, // effect(false).
460 True, // effect(true).
461 Dependent // effect(expr) where expr is dependent.
462};
463
464/// Sema - This implements semantic analysis and AST building for C.
465/// \nosubgrouping
466class Sema final : public SemaBase {
467 // Table of Contents
468 // -----------------
469 // 1. Semantic Analysis (Sema.cpp)
470 // 2. API Notes (SemaAPINotes.cpp)
471 // 3. C++ Access Control (SemaAccess.cpp)
472 // 4. Attributes (SemaAttr.cpp)
473 // 5. Availability Attribute Handling (SemaAvailability.cpp)
474 // 6. Bounds Safety (SemaBoundsSafety.cpp)
475 // 7. Casts (SemaCast.cpp)
476 // 8. Extra Semantic Checking (SemaChecking.cpp)
477 // 9. C++ Coroutines (SemaCoroutine.cpp)
478 // 10. C++ Scope Specifiers (SemaCXXScopeSpec.cpp)
479 // 11. Declarations (SemaDecl.cpp)
480 // 12. Declaration Attribute Handling (SemaDeclAttr.cpp)
481 // 13. C++ Declarations (SemaDeclCXX.cpp)
482 // 14. C++ Exception Specifications (SemaExceptionSpec.cpp)
483 // 15. Expressions (SemaExpr.cpp)
484 // 16. C++ Expressions (SemaExprCXX.cpp)
485 // 17. Member Access Expressions (SemaExprMember.cpp)
486 // 18. Initializers (SemaInit.cpp)
487 // 19. C++ Lambda Expressions (SemaLambda.cpp)
488 // 20. Name Lookup (SemaLookup.cpp)
489 // 21. Modules (SemaModule.cpp)
490 // 22. C++ Overloading (SemaOverload.cpp)
491 // 23. Statements (SemaStmt.cpp)
492 // 24. `inline asm` Statement (SemaStmtAsm.cpp)
493 // 25. Statement Attribute Handling (SemaStmtAttr.cpp)
494 // 26. C++ Templates (SemaTemplate.cpp)
495 // 27. C++ Template Argument Deduction (SemaTemplateDeduction.cpp)
496 // 28. C++ Template Deduction Guide (SemaTemplateDeductionGuide.cpp)
497 // 29. C++ Template Instantiation (SemaTemplateInstantiate.cpp)
498 // 30. C++ Template Declaration Instantiation
499 // (SemaTemplateInstantiateDecl.cpp)
500 // 31. C++ Variadic Templates (SemaTemplateVariadic.cpp)
501 // 32. Constraints and Concepts (SemaConcept.cpp)
502 // 33. Types (SemaType.cpp)
503 // 34. FixIt Helpers (SemaFixItUtils.cpp)
504 // 35. Function Effects (SemaFunctionEffects.cpp)
505
506 /// \name Semantic Analysis
507 /// Implementations are in Sema.cpp
508 ///@{
509
510public:
511 Sema(Preprocessor &pp, ASTContext &ctxt, ASTConsumer &consumer,
513 CodeCompleteConsumer *CompletionConsumer = nullptr);
514 ~Sema();
515
516 /// Perform initialization that occurs after the parser has been
517 /// initialized but before it parses anything.
518 void Initialize();
519
520 /// This virtual key function only exists to limit the emission of debug info
521 /// describing the Sema class. GCC and Clang only emit debug info for a class
522 /// with a vtable when the vtable is emitted. Sema is final and not
523 /// polymorphic, but the debug info size savings are so significant that it is
524 /// worth adding a vtable just to take advantage of this optimization.
525 virtual void anchor();
526
527 const LangOptions &getLangOpts() const { return LangOpts; }
530
533 Preprocessor &getPreprocessor() const { return PP; }
534 ASTContext &getASTContext() const { return Context; }
538
540 StringRef Platform);
542
543 /// Registers an external source. If an external source already exists,
544 /// creates a multiplex external source and appends to it.
545 ///
546 ///\param[in] E - A non-null external sema source.
547 ///
549
550 /// Print out statistics about the semantic analysis.
551 void PrintStats() const;
552
553 /// Run some code with "sufficient" stack space. (Currently, at least 256K is
554 /// guaranteed). Produces a warning if we're low on stack space and allocates
555 /// more in that case. Use this in code that may recurse deeply (for example,
556 /// in template instantiation) to avoid stack overflow.
558 llvm::function_ref<void()> Fn);
559
560 /// Returns default addr space for method qualifiers.
562
563 /// Load weak undeclared identifiers from the external source.
565
566 /// Determine if VD, which must be a variable or function, is an external
567 /// symbol that nonetheless can't be referenced from outside this translation
568 /// unit because its type has no linkage and it's not extern "C".
569 bool isExternalWithNoLinkageType(const ValueDecl *VD) const;
570
571 /// Obtain a sorted list of functions that are undefined but ODR-used.
573 SmallVectorImpl<std::pair<NamedDecl *, SourceLocation>> &Undefined);
574
575 typedef std::pair<SourceLocation, bool> DeleteExprLoc;
577 /// Retrieves list of suspicious delete-expressions that will be checked at
578 /// the end of translation unit.
579 const llvm::MapVector<FieldDecl *, DeleteLocs> &
581
582 /// Cause the built diagnostic to be emitted on the DiagosticsEngine.
583 /// This is closely coupled to the SemaDiagnosticBuilder class and
584 /// should not be used elsewhere.
585 void EmitDiagnostic(unsigned DiagID, const DiagnosticBuilder &DB);
586
587 void addImplicitTypedef(StringRef Name, QualType T);
588
589 /// Whether uncompilable error has occurred. This includes error happens
590 /// in deferred diagnostics.
591 bool hasUncompilableErrorOccurred() const;
592
593 /// Looks through the macro-expansion chain for the given
594 /// location, looking for a macro expansion with the given name.
595 /// If one is found, returns true and sets the location to that
596 /// expansion loc.
597 bool findMacroSpelling(SourceLocation &loc, StringRef name);
598
599 /// Calls \c Lexer::getLocForEndOfToken()
601
602 /// Retrieve the module loader associated with the preprocessor.
604
605 /// Invent a new identifier for parameters of abbreviated templates.
608 unsigned Index);
609
611
612 // Emit all deferred diagnostics.
613 void emitDeferredDiags();
614
616 /// The global module fragment, between 'module;' and a module-declaration.
618 /// A normal translation unit fragment. For a non-module unit, this is the
619 /// entire translation unit. Otherwise, it runs from the module-declaration
620 /// to the private-module-fragment (if any) or the end of the TU (if not).
622 /// The private module fragment, between 'module :private;' and the end of
623 /// the translation unit.
624 Private
625 };
626
627 /// This is called before the very first declaration in the translation unit
628 /// is parsed. Note that the ASTContext may have already injected some
629 /// declarations.
631 /// ActOnEndOfTranslationUnit - This is called at the very end of the
632 /// translation unit when EOF is reached and all but the top-level scope is
633 /// popped.
636
637 /// Determines the active Scope associated with the given declaration
638 /// context.
639 ///
640 /// This routine maps a declaration context to the active Scope object that
641 /// represents that declaration context in the parser. It is typically used
642 /// from "scope-less" code (e.g., template instantiation, lazy creation of
643 /// declarations) that injects a name for name-lookup purposes and, therefore,
644 /// must update the Scope.
645 ///
646 /// \returns The scope corresponding to the given declaraion context, or NULL
647 /// if no such scope is open.
649
650 void PushFunctionScope();
651 void PushBlockScope(Scope *BlockScope, BlockDecl *Block);
653
654 /// This is used to inform Sema what the current TemplateParameterDepth
655 /// is during Parsing. Currently it is used to pass on the depth
656 /// when parsing generic lambda 'auto' parameters.
657 void RecordParsingTemplateParameterDepth(unsigned Depth);
658
659 void PushCapturedRegionScope(Scope *RegionScope, CapturedDecl *CD,
661 unsigned OpenMPCaptureLevel = 0);
662
663 /// Custom deleter to allow FunctionScopeInfos to be kept alive for a short
664 /// time after they've been popped.
666 Sema *Self;
667
668 public:
669 explicit PoppedFunctionScopeDeleter(Sema *Self) : Self(Self) {}
671 };
672
674 std::unique_ptr<sema::FunctionScopeInfo, PoppedFunctionScopeDeleter>;
675
676 /// Pop a function (or block or lambda or captured region) scope from the
677 /// stack.
678 ///
679 /// \param WP The warning policy to use for CFG-based warnings, or null if
680 /// such warnings should not be produced.
681 /// \param D The declaration corresponding to this function scope, if
682 /// producing CFG-based warnings.
683 /// \param BlockType The type of the block expression, if D is a BlockDecl.
686 const Decl *D = nullptr,
687 QualType BlockType = QualType());
688
690
695
696 void PushCompoundScope(bool IsStmtExpr);
697 void PopCompoundScope();
698
699 /// Determine whether any errors occurred within this function/method/
700 /// block.
702
703 /// Retrieve the current block, if any.
705
706 /// Get the innermost lambda or block enclosing the current location, if any.
707 /// This looks through intervening non-lambda, non-block scopes such as local
708 /// functions.
710
711 /// Retrieve the current lambda scope info, if any.
712 /// \param IgnoreNonLambdaCapturingScope true if should find the top-most
713 /// lambda scope info ignoring all inner capturing scopes that are not
714 /// lambda scopes.
716 getCurLambda(bool IgnoreNonLambdaCapturingScope = false);
717
718 /// Retrieve the current generic lambda info, if any.
720
721 /// Retrieve the current captured region, if any.
723
724 void ActOnComment(SourceRange Comment);
725
726 /// Retrieve the parser's current scope.
727 ///
728 /// This routine must only be used when it is certain that semantic analysis
729 /// and the parser are in precisely the same context, which is not the case
730 /// when, e.g., we are performing any kind of template instantiation.
731 /// Therefore, the only safe places to use this scope are in the parser
732 /// itself and in routines directly invoked from the parser and *never* from
733 /// template substitution or instantiation.
734 Scope *getCurScope() const { return CurScope; }
735
737
740 }
741
742 SemaDiagnosticBuilder targetDiag(SourceLocation Loc, unsigned DiagID,
743 const FunctionDecl *FD = nullptr);
745 const PartialDiagnostic &PD,
746 const FunctionDecl *FD = nullptr) {
747 return targetDiag(Loc, PD.getDiagID(), FD) << PD;
748 }
749
750 /// Check if the type is allowed to be used for the current target.
752 ValueDecl *D = nullptr);
753
754 // /// The kind of conversion being performed.
755 // enum CheckedConversionKind {
756 // /// An implicit conversion.
757 // CCK_ImplicitConversion,
758 // /// A C-style cast.
759 // CCK_CStyleCast,
760 // /// A functional-style cast.
761 // CCK_FunctionalCast,
762 // /// A cast other than a C-style cast.
763 // CCK_OtherCast,
764 // /// A conversion for an operand of a builtin overloaded operator.
765 // CCK_ForBuiltinOverloadedOp
766 // };
767
768 /// ImpCastExprToType - If Expr is not of type 'Type', insert an implicit
769 /// cast. If there is already an implicit cast, merge into the existing one.
770 /// If isLvalue, the result of the cast is an lvalue.
773 const CXXCastPath *BasePath = nullptr,
775
776 /// ScalarTypeToBooleanCastKind - Returns the cast kind corresponding
777 /// to the conversion from scalar type ScalarTy to the Boolean type.
779
780 /// If \p AllowLambda is true, treat lambda as function.
781 DeclContext *getFunctionLevelDeclContext(bool AllowLambda = false) const;
782
783 /// Returns a pointer to the innermost enclosing function, or nullptr if the
784 /// current context is not inside a function. If \p AllowLambda is true,
785 /// this can return the call operator of an enclosing lambda, otherwise
786 /// lambdas are skipped when looking for an enclosing function.
787 FunctionDecl *getCurFunctionDecl(bool AllowLambda = false) const;
788
789 /// getCurMethodDecl - If inside of a method body, this returns a pointer to
790 /// the method decl for the method being parsed. If we're currently
791 /// in a 'block', this returns the containing context.
793
794 /// getCurFunctionOrMethodDecl - Return the Decl for the current ObjC method
795 /// or C function we're in, otherwise return null. If we're currently
796 /// in a 'block', this returns the containing context.
798
799 /// Warn if we're implicitly casting from a _Nullable pointer type to a
800 /// _Nonnull one.
803
804 /// Warn when implicitly casting 0 to nullptr.
806
807 /// Warn when implicitly changing function effects.
810
811 /// makeUnavailableInSystemHeader - There is an error in the current
812 /// context. If we're still in a system header, and we can plausibly
813 /// make the relevant declaration unavailable instead of erroring, do
814 /// so and return true.
816 UnavailableAttr::ImplicitReason reason);
817
818 /// Retrieve a suitable printing policy for diagnostics.
821 }
822
823 /// Retrieve a suitable printing policy for diagnostics.
825 const Preprocessor &PP);
826
827 /// Scope actions.
829
830 /// Determine whether \param D is function like (function or function
831 /// template) for parsing.
833
834 /// The maximum alignment, same as in llvm::Value. We duplicate them here
835 /// because that allows us not to duplicate the constants in clang code,
836 /// which we must to since we can't directly use the llvm constants.
837 /// The value is verified against llvm here: lib/CodeGen/CGDecl.cpp
838 ///
839 /// This is the greatest alignment value supported by load, store, and alloca
840 /// instructions, and global values.
841 static const unsigned MaxAlignmentExponent = 32;
842 static const uint64_t MaximumAlignment = 1ull << MaxAlignmentExponent;
843
844 /// Flag indicating whether or not to collect detailed statistics.
846
847 std::unique_ptr<sema::FunctionScopeInfo> CachedFunctionScope;
848
849 /// Stack containing information about each of the nested
850 /// function, block, and method scopes that are currently active.
852
853 /// The index of the first FunctionScope that corresponds to the current
854 /// context.
856
857 /// Track the number of currently active capturing scopes.
859
860 llvm::BumpPtrAllocator BumpAlloc;
861
862 /// The kind of translation unit we are processing.
863 ///
864 /// When we're processing a complete translation unit, Sema will perform
865 /// end-of-translation-unit semantic tasks (such as creating
866 /// initializers for tentative definitions in C) once parsing has
867 /// completed. Modules and precompiled headers perform different kinds of
868 /// checks.
870
871 /// Translation Unit Scope - useful to Objective-C actions that need
872 /// to lookup file scope declarations in the "ordinary" C decl namespace.
873 /// For example, user-defined classes, built-in "id" type, etc.
875
877 return CurScope->incrementMSManglingNumber();
878 }
879
880 /// Try to recover by turning the given expression into a
881 /// call. Returns true if recovery was attempted or an error was
882 /// emitted; this may also leave the ExprResult invalid.
884 bool ForceComplain = false,
885 bool (*IsPlausibleResult)(QualType) = nullptr);
886
887 /// Figure out if an expression could be turned into a call.
888 ///
889 /// Use this when trying to recover from an error where the programmer may
890 /// have written just the name of a function instead of actually calling it.
891 ///
892 /// \param E - The expression to examine.
893 /// \param ZeroArgCallReturnTy - If the expression can be turned into a call
894 /// with no arguments, this parameter is set to the type returned by such a
895 /// call; otherwise, it is set to an empty QualType.
896 /// \param OverloadSet - If the expression is an overloaded function
897 /// name, this parameter is populated with the decls of the various
898 /// overloads.
899 bool tryExprAsCall(Expr &E, QualType &ZeroArgCallReturnTy,
900 UnresolvedSetImpl &NonTemplateOverloads);
901
905
908
916
917 /// A RAII object to enter scope of a compound statement.
919 public:
920 CompoundScopeRAII(Sema &S, bool IsStmtExpr = false) : S(S) {
921 S.ActOnStartOfCompoundStmt(IsStmtExpr);
922 }
923
925
926 private:
927 Sema &S;
928 };
929
930 /// An RAII helper that pops function a function scope on exit.
933 bool Active;
936 if (Active)
938 }
939 void disable() { Active = false; }
940 };
941
943 return FunctionScopes.empty() ? nullptr : FunctionScopes.back();
944 }
945
946 /// Worker object for performing CFG-based warnings.
949
950 /// Callback to the parser to parse templated functions when needed.
951 typedef void LateTemplateParserCB(void *P, LateParsedTemplate &LPT);
952 typedef void LateTemplateParserCleanupCB(void *P);
956
958 LateTemplateParserCleanupCB *LTPCleanup, void *P) {
959 LateTemplateParser = LTP;
960 LateTemplateParserCleanup = LTPCleanup;
961 OpaqueParser = P;
962 }
963
964 /// Callback to the parser to parse a type expressed as a string.
965 std::function<TypeResult(StringRef, StringRef, SourceLocation)>
967
968 /// VAListTagName - The declaration name corresponding to __va_list_tag.
969 /// This is used as part of a hack to omit that class from ADL results.
971
972 /// Is the last error level diagnostic immediate. This is used to determined
973 /// whether the next info diagnostic should be immediate.
975
976 class DelayedDiagnostics;
977
979 sema::DelayedDiagnosticPool *SavedPool = nullptr;
981 };
984
985 /// A class which encapsulates the logic for delaying diagnostics
986 /// during parsing and other processing.
988 /// The current pool of diagnostics into which delayed
989 /// diagnostics should go.
990 sema::DelayedDiagnosticPool *CurPool = nullptr;
991
992 public:
994
995 /// Adds a delayed diagnostic.
996 void add(const sema::DelayedDiagnostic &diag); // in DelayedDiagnostic.h
997
998 /// Determines whether diagnostics should be delayed.
999 bool shouldDelayDiagnostics() { return CurPool != nullptr; }
1000
1001 /// Returns the current delayed-diagnostics pool.
1002 sema::DelayedDiagnosticPool *getCurrentPool() const { return CurPool; }
1003
1004 /// Enter a new scope. Access and deprecation diagnostics will be
1005 /// collected in this pool.
1008 state.SavedPool = CurPool;
1009 CurPool = &pool;
1010 return state;
1011 }
1012
1013 /// Leave a delayed-diagnostic state that was previously pushed.
1014 /// Do not emit any of the diagnostics. This is performed as part
1015 /// of the bookkeeping of popping a pool "properly".
1017 CurPool = state.SavedPool;
1018 }
1019
1020 /// Enter a new scope where access and deprecation diagnostics are
1021 /// not delayed.
1024 state.SavedPool = CurPool;
1025 CurPool = nullptr;
1026 return state;
1027 }
1028
1029 /// Undo a previous pushUndelayed().
1031 assert(CurPool == nullptr);
1032 CurPool = state.SavedPool;
1033 }
1034 } DelayedDiagnostics;
1035
1037 return DelayedDiagnostics.push(pool);
1038 }
1039
1040 /// Diagnostics that are emitted only if we discover that the given function
1041 /// must be codegen'ed. Because handling these correctly adds overhead to
1042 /// compilation, this is currently only enabled for CUDA compilations.
1043 SemaDiagnosticBuilder::DeferredDiagnosticsType DeviceDeferredDiags;
1044
1045 /// CurContext - This is the current declaration context of parsing.
1047
1049 assert(AMDGPUPtr);
1050 return *AMDGPUPtr;
1051 }
1052
1054 assert(ARMPtr);
1055 return *ARMPtr;
1056 }
1057
1059 assert(AVRPtr);
1060 return *AVRPtr;
1061 }
1062
1064 assert(BPFPtr);
1065 return *BPFPtr;
1066 }
1067
1069 assert(CodeCompletionPtr);
1070 return *CodeCompletionPtr;
1071 }
1072
1074 assert(CUDAPtr);
1075 return *CUDAPtr;
1076 }
1077
1079 assert(HLSLPtr);
1080 return *HLSLPtr;
1081 }
1082
1084 assert(HexagonPtr);
1085 return *HexagonPtr;
1086 }
1087
1089 assert(LoongArchPtr);
1090 return *LoongArchPtr;
1091 }
1092
1094 assert(M68kPtr);
1095 return *M68kPtr;
1096 }
1097
1099 assert(MIPSPtr);
1100 return *MIPSPtr;
1101 }
1102
1104 assert(MSP430Ptr);
1105 return *MSP430Ptr;
1106 }
1107
1109 assert(NVPTXPtr);
1110 return *NVPTXPtr;
1111 }
1112
1114 assert(ObjCPtr);
1115 return *ObjCPtr;
1116 }
1117
1119 assert(OpenACCPtr);
1120 return *OpenACCPtr;
1121 }
1122
1124 assert(OpenCLPtr);
1125 return *OpenCLPtr;
1126 }
1127
1129 assert(OpenMPPtr && "SemaOpenMP is dead");
1130 return *OpenMPPtr;
1131 }
1132
1134 assert(PPCPtr);
1135 return *PPCPtr;
1136 }
1137
1139 assert(PseudoObjectPtr);
1140 return *PseudoObjectPtr;
1141 }
1142
1144 assert(RISCVPtr);
1145 return *RISCVPtr;
1146 }
1147
1149 assert(SPIRVPtr);
1150 return *SPIRVPtr;
1151 }
1152
1154 assert(SYCLPtr);
1155 return *SYCLPtr;
1156 }
1157
1159 assert(SwiftPtr);
1160 return *SwiftPtr;
1161 }
1162
1164 assert(SystemZPtr);
1165 return *SystemZPtr;
1166 }
1167
1169 assert(WasmPtr);
1170 return *WasmPtr;
1171 }
1172
1174 assert(X86Ptr);
1175 return *X86Ptr;
1176 }
1177
1178 /// Source of additional semantic information.
1180
1181protected:
1182 friend class Parser;
1184 friend class ASTReader;
1185 friend class ASTDeclReader;
1186 friend class ASTWriter;
1187
1188private:
1189 std::optional<std::unique_ptr<DarwinSDKInfo>> CachedDarwinSDKInfo;
1190 bool WarnedDarwinSDKInfoMissing = false;
1191
1192 StackExhaustionHandler StackHandler;
1193
1194 Sema(const Sema &) = delete;
1195 void operator=(const Sema &) = delete;
1196
1197 /// The handler for the FileChanged preprocessor events.
1198 ///
1199 /// Used for diagnostics that implement custom semantic analysis for #include
1200 /// directives, like -Wpragma-pack.
1201 sema::SemaPPCallbacks *SemaPPCallbackHandler;
1202
1203 /// The parser's current scope.
1204 ///
1205 /// The parser maintains this state here.
1206 Scope *CurScope;
1207
1208 mutable IdentifierInfo *Ident_super;
1209
1210 std::unique_ptr<SemaAMDGPU> AMDGPUPtr;
1211 std::unique_ptr<SemaARM> ARMPtr;
1212 std::unique_ptr<SemaAVR> AVRPtr;
1213 std::unique_ptr<SemaBPF> BPFPtr;
1214 std::unique_ptr<SemaCodeCompletion> CodeCompletionPtr;
1215 std::unique_ptr<SemaCUDA> CUDAPtr;
1216 std::unique_ptr<SemaHLSL> HLSLPtr;
1217 std::unique_ptr<SemaHexagon> HexagonPtr;
1218 std::unique_ptr<SemaLoongArch> LoongArchPtr;
1219 std::unique_ptr<SemaM68k> M68kPtr;
1220 std::unique_ptr<SemaMIPS> MIPSPtr;
1221 std::unique_ptr<SemaMSP430> MSP430Ptr;
1222 std::unique_ptr<SemaNVPTX> NVPTXPtr;
1223 std::unique_ptr<SemaObjC> ObjCPtr;
1224 std::unique_ptr<SemaOpenACC> OpenACCPtr;
1225 std::unique_ptr<SemaOpenCL> OpenCLPtr;
1226 std::unique_ptr<SemaOpenMP> OpenMPPtr;
1227 std::unique_ptr<SemaPPC> PPCPtr;
1228 std::unique_ptr<SemaPseudoObject> PseudoObjectPtr;
1229 std::unique_ptr<SemaRISCV> RISCVPtr;
1230 std::unique_ptr<SemaSPIRV> SPIRVPtr;
1231 std::unique_ptr<SemaSYCL> SYCLPtr;
1232 std::unique_ptr<SemaSwift> SwiftPtr;
1233 std::unique_ptr<SemaSystemZ> SystemZPtr;
1234 std::unique_ptr<SemaWasm> WasmPtr;
1235 std::unique_ptr<SemaX86> X86Ptr;
1236
1237 ///@}
1238
1239 //
1240 //
1241 // -------------------------------------------------------------------------
1242 //
1243 //
1244
1245 /// \name API Notes
1246 /// Implementations are in SemaAPINotes.cpp
1247 ///@{
1248
1249public:
1250 /// Map any API notes provided for this declaration to attributes on the
1251 /// declaration.
1252 ///
1253 /// Triggered by declaration-attribute processing.
1254 void ProcessAPINotes(Decl *D);
1255
1256 ///@}
1257
1258 //
1259 //
1260 // -------------------------------------------------------------------------
1261 //
1262 //
1263
1264 /// \name C++ Access Control
1265 /// Implementations are in SemaAccess.cpp
1266 ///@{
1267
1268public:
1275
1276 /// SetMemberAccessSpecifier - Set the access specifier of a member.
1277 /// Returns true on error (when the previous member decl access specifier
1278 /// is different from the new member decl access specifier).
1279 bool SetMemberAccessSpecifier(NamedDecl *MemberDecl,
1280 NamedDecl *PrevMemberDecl,
1281 AccessSpecifier LexicalAS);
1282
1283 /// Perform access-control checking on a previously-unresolved member
1284 /// access which has now been resolved to a member.
1286 DeclAccessPair FoundDecl);
1288 DeclAccessPair FoundDecl);
1289
1290 /// Checks access to an overloaded operator new or delete.
1292 SourceRange PlacementRange,
1293 CXXRecordDecl *NamingClass,
1294 DeclAccessPair FoundDecl,
1295 bool Diagnose = true);
1296
1297 /// Checks access to a constructor.
1299 DeclAccessPair FoundDecl,
1300 const InitializedEntity &Entity,
1301 bool IsCopyBindingRefToTemp = false);
1302
1303 /// Checks access to a constructor.
1305 DeclAccessPair FoundDecl,
1306 const InitializedEntity &Entity,
1307 const PartialDiagnostic &PDiag);
1309 CXXDestructorDecl *Dtor,
1310 const PartialDiagnostic &PDiag,
1311 QualType objectType = QualType());
1312
1313 /// Checks access to the target of a friend declaration.
1315
1316 /// Checks access to a member.
1318 CXXRecordDecl *NamingClass,
1320
1321 /// Checks implicit access to a member in a structured binding.
1324 CXXRecordDecl *DecomposedClass,
1325 DeclAccessPair Field);
1327 const SourceRange &,
1328 DeclAccessPair FoundDecl);
1329
1330 /// Checks access to an overloaded member operator, including
1331 /// conversion operators.
1333 Expr *ArgExpr,
1334 DeclAccessPair FoundDecl);
1336 ArrayRef<Expr *> ArgExprs,
1337 DeclAccessPair FoundDecl);
1339 DeclAccessPair FoundDecl);
1340
1341 /// Checks access for a hierarchy conversion.
1342 ///
1343 /// \param ForceCheck true if this check should be performed even if access
1344 /// control is disabled; some things rely on this for semantics
1345 /// \param ForceUnprivileged true if this check should proceed as if the
1346 /// context had no special privileges
1348 QualType Derived, const CXXBasePath &Path,
1349 unsigned DiagID, bool ForceCheck = false,
1350 bool ForceUnprivileged = false);
1351
1352 /// Checks access to all the declarations in the given result set.
1353 void CheckLookupAccess(const LookupResult &R);
1354
1355 /// Checks access to Target from the given class. The check will take access
1356 /// specifiers into account, but no member access expressions and such.
1357 ///
1358 /// \param Target the declaration to check if it can be accessed
1359 /// \param NamingClass the class in which the lookup was started.
1360 /// \param BaseType type of the left side of member access expression.
1361 /// \p BaseType and \p NamingClass are used for C++ access control.
1362 /// Depending on the lookup case, they should be set to the following:
1363 /// - lhs.target (member access without a qualifier):
1364 /// \p BaseType and \p NamingClass are both the type of 'lhs'.
1365 /// - lhs.X::target (member access with a qualifier):
1366 /// BaseType is the type of 'lhs', NamingClass is 'X'
1367 /// - X::target (qualified lookup without member access):
1368 /// BaseType is null, NamingClass is 'X'.
1369 /// - target (unqualified lookup).
1370 /// BaseType is null, NamingClass is the parent class of 'target'.
1371 /// \return true if the Target is accessible from the Class, false otherwise.
1372 bool IsSimplyAccessible(NamedDecl *Decl, CXXRecordDecl *NamingClass,
1373 QualType BaseType);
1374
1375 /// Is the given member accessible for the purposes of deciding whether to
1376 /// define a special member function as deleted?
1378 DeclAccessPair Found, QualType ObjectType,
1380 const PartialDiagnostic &Diag);
1383 QualType ObjectType) {
1384 return isMemberAccessibleForDeletion(NamingClass, Found, ObjectType,
1385 SourceLocation(), PDiag());
1386 }
1387
1389 const DependentDiagnostic &DD,
1390 const MultiLevelTemplateArgumentList &TemplateArgs);
1392
1393 ///@}
1394
1395 //
1396 //
1397 // -------------------------------------------------------------------------
1398 //
1399 //
1400
1401 /// \name Attributes
1402 /// Implementations are in SemaAttr.cpp
1403 ///@{
1404
1405public:
1406 /// Controls member pointer representation format under the MS ABI.
1409
1410 bool MSStructPragmaOn; // True when \#pragma ms_struct on
1411
1412 /// Source location for newly created implicit MSInheritanceAttrs
1414
1415 /// pragma clang section kind
1422 PCSK_Relro = 5
1424
1426
1428 std::string SectionName;
1429 bool Valid = false;
1431 };
1432
1438
1440 PSK_Reset = 0x0, // #pragma ()
1441 PSK_Set = 0x1, // #pragma (value)
1442 PSK_Push = 0x2, // #pragma (push[, id])
1443 PSK_Pop = 0x4, // #pragma (pop[, id])
1444 PSK_Show = 0x8, // #pragma (show) -- only for "pack"!
1445 PSK_Push_Set = PSK_Push | PSK_Set, // #pragma (push[, id], value)
1446 PSK_Pop_Set = PSK_Pop | PSK_Set, // #pragma (pop[, id], value)
1447 };
1448
1451 StringRef SlotLabel;
1453 };
1454
1455 // #pragma pack and align.
1457 public:
1458 // `Native` represents default align mode, which may vary based on the
1459 // platform.
1460 enum Mode : unsigned char { Native, Natural, Packed, Mac68k };
1461
1462 // #pragma pack info constructor
1463 AlignPackInfo(AlignPackInfo::Mode M, unsigned Num, bool IsXL)
1464 : PackAttr(true), AlignMode(M), PackNumber(Num), XLStack(IsXL) {
1465 assert(Num == PackNumber && "The pack number has been truncated.");
1466 }
1467
1468 // #pragma align info constructor
1470 : PackAttr(false), AlignMode(M),
1471 PackNumber(M == Packed ? 1 : UninitPackVal), XLStack(IsXL) {}
1472
1473 explicit AlignPackInfo(bool IsXL) : AlignPackInfo(Native, IsXL) {}
1474
1476
1477 // When a AlignPackInfo itself cannot be used, this returns an 32-bit
1478 // integer encoding for it. This should only be passed to
1479 // AlignPackInfo::getFromRawEncoding, it should not be inspected directly.
1480 static uint32_t getRawEncoding(const AlignPackInfo &Info) {
1481 std::uint32_t Encoding{};
1482 if (Info.IsXLStack())
1483 Encoding |= IsXLMask;
1484
1485 Encoding |= static_cast<uint32_t>(Info.getAlignMode()) << 1;
1486
1487 if (Info.IsPackAttr())
1488 Encoding |= PackAttrMask;
1489
1490 Encoding |= static_cast<uint32_t>(Info.getPackNumber()) << 4;
1491
1492 return Encoding;
1493 }
1494
1495 static AlignPackInfo getFromRawEncoding(unsigned Encoding) {
1496 bool IsXL = static_cast<bool>(Encoding & IsXLMask);
1498 static_cast<AlignPackInfo::Mode>((Encoding & AlignModeMask) >> 1);
1499 int PackNumber = (Encoding & PackNumMask) >> 4;
1500
1501 if (Encoding & PackAttrMask)
1502 return AlignPackInfo(M, PackNumber, IsXL);
1503
1504 return AlignPackInfo(M, IsXL);
1505 }
1506
1507 bool IsPackAttr() const { return PackAttr; }
1508
1509 bool IsAlignAttr() const { return !PackAttr; }
1510
1511 Mode getAlignMode() const { return AlignMode; }
1512
1513 unsigned getPackNumber() const { return PackNumber; }
1514
1515 bool IsPackSet() const {
1516 // #pragma align, #pragma pack(), and #pragma pack(0) do not set the pack
1517 // attriute on a decl.
1518 return PackNumber != UninitPackVal && PackNumber != 0;
1519 }
1520
1521 bool IsXLStack() const { return XLStack; }
1522
1523 bool operator==(const AlignPackInfo &Info) const {
1524 return std::tie(AlignMode, PackNumber, PackAttr, XLStack) ==
1525 std::tie(Info.AlignMode, Info.PackNumber, Info.PackAttr,
1526 Info.XLStack);
1527 }
1528
1529 bool operator!=(const AlignPackInfo &Info) const {
1530 return !(*this == Info);
1531 }
1532
1533 private:
1534 /// \brief True if this is a pragma pack attribute,
1535 /// not a pragma align attribute.
1536 bool PackAttr;
1537
1538 /// \brief The alignment mode that is in effect.
1539 Mode AlignMode;
1540
1541 /// \brief The pack number of the stack.
1542 unsigned char PackNumber;
1543
1544 /// \brief True if it is a XL #pragma align/pack stack.
1545 bool XLStack;
1546
1547 /// \brief Uninitialized pack value.
1548 static constexpr unsigned char UninitPackVal = -1;
1549
1550 // Masks to encode and decode an AlignPackInfo.
1551 static constexpr uint32_t IsXLMask{0x0000'0001};
1552 static constexpr uint32_t AlignModeMask{0x0000'0006};
1553 static constexpr uint32_t PackAttrMask{0x00000'0008};
1554 static constexpr uint32_t PackNumMask{0x0000'01F0};
1555 };
1556
1557 template <typename ValueType> struct PragmaStack {
1558 struct Slot {
1559 llvm::StringRef StackSlotLabel;
1560 ValueType Value;
1563 Slot(llvm::StringRef StackSlotLabel, ValueType Value,
1568 };
1569
1570 void Act(SourceLocation PragmaLocation, PragmaMsStackAction Action,
1571 llvm::StringRef StackSlotLabel, ValueType Value) {
1572 if (Action == PSK_Reset) {
1574 CurrentPragmaLocation = PragmaLocation;
1575 return;
1576 }
1577 if (Action & PSK_Push)
1578 Stack.emplace_back(StackSlotLabel, CurrentValue, CurrentPragmaLocation,
1579 PragmaLocation);
1580 else if (Action & PSK_Pop) {
1581 if (!StackSlotLabel.empty()) {
1582 // If we've got a label, try to find it and jump there.
1583 auto I = llvm::find_if(llvm::reverse(Stack), [&](const Slot &x) {
1584 return x.StackSlotLabel == StackSlotLabel;
1585 });
1586 // If we found the label so pop from there.
1587 if (I != Stack.rend()) {
1588 CurrentValue = I->Value;
1589 CurrentPragmaLocation = I->PragmaLocation;
1590 Stack.erase(std::prev(I.base()), Stack.end());
1591 }
1592 } else if (!Stack.empty()) {
1593 // We do not have a label, just pop the last entry.
1594 CurrentValue = Stack.back().Value;
1595 CurrentPragmaLocation = Stack.back().PragmaLocation;
1596 Stack.pop_back();
1597 }
1598 }
1599 if (Action & PSK_Set) {
1601 CurrentPragmaLocation = PragmaLocation;
1602 }
1603 }
1604
1605 // MSVC seems to add artificial slots to #pragma stacks on entering a C++
1606 // method body to restore the stacks on exit, so it works like this:
1607 //
1608 // struct S {
1609 // #pragma <name>(push, InternalPragmaSlot, <current_pragma_value>)
1610 // void Method {}
1611 // #pragma <name>(pop, InternalPragmaSlot)
1612 // };
1613 //
1614 // It works even with #pragma vtordisp, although MSVC doesn't support
1615 // #pragma vtordisp(push [, id], n)
1616 // syntax.
1617 //
1618 // Push / pop a named sentinel slot.
1619 void SentinelAction(PragmaMsStackAction Action, StringRef Label) {
1620 assert((Action == PSK_Push || Action == PSK_Pop) &&
1621 "Can only push / pop #pragma stack sentinels!");
1623 }
1624
1625 // Constructors.
1626 explicit PragmaStack(const ValueType &Default)
1628
1629 bool hasValue() const { return CurrentValue != DefaultValue; }
1630
1632 ValueType DefaultValue; // Value used for PSK_Reset action.
1633 ValueType CurrentValue;
1635 };
1636 // FIXME: We should serialize / deserialize these if they occur in a PCH (but
1637 // we shouldn't do so if they're in a module).
1638
1639 /// Whether to insert vtordisps prior to virtual bases in the Microsoft
1640 /// C++ ABI. Possible values are 0, 1, and 2, which mean:
1641 ///
1642 /// 0: Suppress all vtordisps
1643 /// 1: Insert vtordisps in the presence of vbase overrides and non-trivial
1644 /// structors
1645 /// 2: Always insert vtordisps to support RTTI on partially constructed
1646 /// objects
1649 // The current #pragma align/pack values and locations at each #include.
1654 };
1656 // Segment #pragmas.
1661
1662 // #pragma strict_gs_check.
1664
1665 // This stack tracks the current state of Sema.CurFPFeatures.
1668 FPOptionsOverride result;
1669 if (!FpPragmaStack.hasValue()) {
1670 result = FPOptionsOverride();
1671 } else {
1672 result = FpPragmaStack.CurrentValue;
1673 }
1674 return result;
1675 }
1676
1682 };
1683
1684 // RAII object to push / pop sentinel slots for all MS #pragma stacks.
1685 // Actions should be performed only if we enter / exit a C++ method body.
1687 public:
1688 PragmaStackSentinelRAII(Sema &S, StringRef SlotLabel, bool ShouldAct);
1690
1691 private:
1692 Sema &S;
1693 StringRef SlotLabel;
1694 bool ShouldAct;
1695 };
1696
1697 /// Last section used with #pragma init_seg.
1700
1701 /// Sections used with #pragma alloc_text.
1702 llvm::StringMap<std::tuple<StringRef, SourceLocation>> FunctionToSectionMap;
1703
1704 /// VisContext - Manages the stack for \#pragma GCC visibility.
1705 void *VisContext; // Really a "PragmaVisStack*"
1706
1707 /// This an attribute introduced by \#pragma clang attribute.
1713 };
1714
1715 /// A push'd group of PragmaAttributeEntries.
1717 /// The location of the push attribute.
1719 /// The namespace of this push group.
1722 };
1723
1725
1726 /// The declaration that is currently receiving an attribute from the
1727 /// #pragma attribute stack.
1729
1730 /// This represents the last location of a "#pragma clang optimize off"
1731 /// directive if such a directive has not been closed by an "on" yet. If
1732 /// optimizations are currently "on", this is set to an invalid location.
1734
1735 /// Get the location for the currently active "\#pragma clang optimize
1736 /// off". If this location is invalid, then the state of the pragma is "on".
1739 }
1740
1741 /// The "on" or "off" argument passed by \#pragma optimize, that denotes
1742 /// whether the optimizations in the list passed to the pragma should be
1743 /// turned off or on. This boolean is true by default because command line
1744 /// options are honored when `#pragma optimize("", on)`.
1745 /// (i.e. `ModifyFnAttributeMSPragmaOptimze()` does nothing)
1747
1748 /// Set of no-builtin functions listed by \#pragma function.
1750
1751 /// AddAlignmentAttributesForRecord - Adds any needed alignment attributes to
1752 /// a the record decl, to handle '\#pragma pack' and '\#pragma options align'.
1754
1755 /// AddMsStructLayoutForRecord - Adds ms_struct layout attribute to record.
1757
1758 /// Add gsl::Pointer attribute to std::container::iterator
1759 /// \param ND The declaration that introduces the name
1760 /// std::container::iterator. \param UnderlyingRecord The record named by ND.
1761 void inferGslPointerAttribute(NamedDecl *ND, CXXRecordDecl *UnderlyingRecord);
1762
1763 /// Add [[gsl::Owner]] and [[gsl::Pointer]] attributes for std:: types.
1765
1766 /// Add [[clang:::lifetimebound]] attr for std:: functions and methods.
1768
1769 /// Add [[clang:::lifetime_capture_by(this)]] to STL container methods.
1771
1772 /// Add [[gsl::Pointer]] attributes for std:: types.
1774
1775 LifetimeCaptureByAttr *ParseLifetimeCaptureByAttr(const ParsedAttr &AL,
1776 StringRef ParamName);
1777 // Processes the argument 'X' in [[clang::lifetime_capture_by(X)]]. Since 'X'
1778 // can be the name of a function parameter, we need to parse the function
1779 // declaration and rest of the parameters before processesing 'X'. Therefore
1780 // do this lazily instead of processing while parsing the annotation itself.
1782
1783 /// Add _Nullable attributes for std:: types.
1785
1787 POAK_Native, // #pragma options align=native
1788 POAK_Natural, // #pragma options align=natural
1789 POAK_Packed, // #pragma options align=packed
1790 POAK_Power, // #pragma options align=power
1791 POAK_Mac68k, // #pragma options align=mac68k
1792 POAK_Reset // #pragma options align=reset
1794
1795 /// ActOnPragmaClangSection - Called on well formed \#pragma clang section
1798 PragmaClangSectionKind SecKind,
1799 StringRef SecName);
1800
1801 /// ActOnPragmaOptionsAlign - Called on well formed \#pragma options align.
1803 SourceLocation PragmaLoc);
1804
1805 /// ActOnPragmaPack - Called on well formed \#pragma pack(...).
1806 void ActOnPragmaPack(SourceLocation PragmaLoc, PragmaMsStackAction Action,
1807 StringRef SlotLabel, Expr *Alignment);
1808
1809 /// ConstantFoldAttrArgs - Folds attribute arguments into ConstantExprs
1810 /// (unless they are value dependent or type dependent). Returns false
1811 /// and emits a diagnostic if one or more of the arguments could not be
1812 /// folded into a constant.
1815
1819 };
1820
1822 SourceLocation IncludeLoc);
1824
1825 /// ActOnPragmaMSStruct - Called on well formed \#pragma ms_struct [on|off].
1827
1828 /// ActOnPragmaMSComment - Called on well formed
1829 /// \#pragma comment(kind, "arg").
1831 StringRef Arg);
1832
1833 /// ActOnPragmaDetectMismatch - Call on well-formed \#pragma detect_mismatch
1834 void ActOnPragmaDetectMismatch(SourceLocation Loc, StringRef Name,
1835 StringRef Value);
1836
1837 /// Are precise floating point semantics currently enabled?
1839 return !CurFPFeatures.getAllowFPReassociate() &&
1840 !CurFPFeatures.getNoSignedZero() &&
1841 !CurFPFeatures.getAllowReciprocal() &&
1842 !CurFPFeatures.getAllowApproxFunc();
1843 }
1844
1847
1848 /// ActOnPragmaFloatControl - Call on well-formed \#pragma float_control
1851
1852 /// ActOnPragmaMSPointersToMembers - called on well formed \#pragma
1853 /// pointers_to_members(representation method[, general purpose
1854 /// representation]).
1857 SourceLocation PragmaLoc);
1858
1859 /// Called on well formed \#pragma vtordisp().
1862
1863 bool UnifySection(StringRef SectionName, int SectionFlags,
1864 NamedDecl *TheDecl);
1865 bool UnifySection(StringRef SectionName, int SectionFlags,
1866 SourceLocation PragmaSectionLocation);
1867
1868 /// Called on well formed \#pragma bss_seg/data_seg/const_seg/code_seg.
1869 void ActOnPragmaMSSeg(SourceLocation PragmaLocation,
1870 PragmaMsStackAction Action,
1871 llvm::StringRef StackSlotLabel,
1872 StringLiteral *SegmentName, llvm::StringRef PragmaName);
1873
1874 /// Called on well formed \#pragma section().
1875 void ActOnPragmaMSSection(SourceLocation PragmaLocation, int SectionFlags,
1876 StringLiteral *SegmentName);
1877
1878 /// Called on well-formed \#pragma init_seg().
1879 void ActOnPragmaMSInitSeg(SourceLocation PragmaLocation,
1880 StringLiteral *SegmentName);
1881
1882 /// Called on well-formed \#pragma alloc_text().
1884 SourceLocation PragmaLocation, StringRef Section,
1885 const SmallVector<std::tuple<IdentifierInfo *, SourceLocation>>
1886 &Functions);
1887
1888 /// ActOnPragmaMSStrictGuardStackCheck - Called on well formed \#pragma
1889 /// strict_gs_check.
1891 PragmaMsStackAction Action,
1892 bool Value);
1893
1894 /// ActOnPragmaUnused - Called on well-formed '\#pragma unused'.
1895 void ActOnPragmaUnused(const Token &Identifier, Scope *curScope,
1896 SourceLocation PragmaLoc);
1897
1899 SourceLocation PragmaLoc,
1902 const IdentifierInfo *Namespace);
1903
1904 /// Called on well-formed '\#pragma clang attribute pop'.
1906 const IdentifierInfo *Namespace);
1907
1908 /// Adds the attributes that have been specified using the
1909 /// '\#pragma clang attribute push' directives to the given declaration.
1910 void AddPragmaAttributes(Scope *S, Decl *D);
1911
1913
1915
1916 /// Called on well formed \#pragma clang optimize.
1917 void ActOnPragmaOptimize(bool On, SourceLocation PragmaLoc);
1918
1919 /// #pragma optimize("[optimization-list]", on | off).
1920 void ActOnPragmaMSOptimize(SourceLocation Loc, bool IsOn);
1921
1922 /// Call on well formed \#pragma function.
1923 void
1925 const llvm::SmallVectorImpl<StringRef> &NoBuiltins);
1926
1927 /// Only called on function definitions; if there is a pragma in scope
1928 /// with the effect of a range-based optnone, consider marking the function
1929 /// with attribute optnone.
1931
1932 /// Only called on function definitions; if there is a `#pragma alloc_text`
1933 /// that decides which code section the function should be in, add
1934 /// attribute section to the function.
1936
1937 /// Adds the 'optnone' attribute to the function declaration if there
1938 /// are no conflicts; Loc represents the location causing the 'optnone'
1939 /// attribute to be added (usually because of a pragma).
1941
1942 /// Only called on function definitions; if there is a MSVC #pragma optimize
1943 /// in scope, consider changing the function's attributes based on the
1944 /// optimization list passed to the pragma.
1946
1947 /// Only called on function definitions; if there is a pragma in scope
1948 /// with the effect of a range-based no_builtin, consider marking the function
1949 /// with attribute no_builtin.
1951
1952 /// AddPushedVisibilityAttribute - If '\#pragma GCC visibility' was used,
1953 /// add an appropriate visibility attribute.
1955
1956 /// FreeVisContext - Deallocate and null out VisContext.
1957 void FreeVisContext();
1958
1959 /// ActOnPragmaVisibility - Called on well formed \#pragma GCC visibility... .
1960 void ActOnPragmaVisibility(const IdentifierInfo *VisType,
1961 SourceLocation PragmaLoc);
1962
1963 /// ActOnPragmaFPContract - Called on well formed
1964 /// \#pragma {STDC,OPENCL} FP_CONTRACT and
1965 /// \#pragma clang fp contract
1967
1968 /// Called on well formed
1969 /// \#pragma clang fp reassociate
1970 /// or
1971 /// \#pragma clang fp reciprocal
1973 bool IsEnabled);
1974
1975 /// ActOnPragmaFenvAccess - Called on well formed
1976 /// \#pragma STDC FENV_ACCESS
1977 void ActOnPragmaFEnvAccess(SourceLocation Loc, bool IsEnabled);
1978
1979 /// ActOnPragmaCXLimitedRange - Called on well formed
1980 /// \#pragma STDC CX_LIMITED_RANGE
1983
1984 /// Called on well formed '\#pragma clang fp' that has option 'exceptions'.
1987
1988 /// Called to set constant rounding mode for floating point operations.
1989 void ActOnPragmaFEnvRound(SourceLocation Loc, llvm::RoundingMode);
1990
1991 /// Called to set exception behavior for floating point operations.
1993
1994 /// PushNamespaceVisibilityAttr - Note that we've entered a
1995 /// namespace with a visibility attribute.
1996 void PushNamespaceVisibilityAttr(const VisibilityAttr *Attr,
1998
1999 /// PopPragmaVisibility - Pop the top element of the visibility stack; used
2000 /// for '\#pragma GCC visibility' and visibility attributes on namespaces.
2001 void PopPragmaVisibility(bool IsNamespaceEnd, SourceLocation EndLoc);
2002
2003 /// Handles semantic checking for features that are common to all attributes,
2004 /// such as checking whether a parameter was properly specified, or the
2005 /// correct number of arguments were passed, etc. Returns true if the
2006 /// attribute has been diagnosed.
2007 bool checkCommonAttributeFeatures(const Decl *D, const ParsedAttr &A,
2008 bool SkipArgCountCheck = false);
2009 bool checkCommonAttributeFeatures(const Stmt *S, const ParsedAttr &A,
2010 bool SkipArgCountCheck = false);
2011
2012 ///@}
2013
2014 //
2015 //
2016 // -------------------------------------------------------------------------
2017 //
2018 //
2019
2020 /// \name Availability Attribute Handling
2021 /// Implementations are in SemaAvailability.cpp
2022 ///@{
2023
2024public:
2025 /// Issue any -Wunguarded-availability warnings in \c FD
2027
2029
2030 /// Retrieve the current function, if any, that should be analyzed for
2031 /// potential availability violations.
2033
2035 const ObjCInterfaceDecl *UnknownObjCClass,
2036 bool ObjCPropertyAccess,
2037 bool AvoidPartialAvailabilityChecks = false,
2038 ObjCInterfaceDecl *ClassReceiver = nullptr);
2039
2040 ///@}
2041
2042 //
2043 //
2044 // -------------------------------------------------------------------------
2045 //
2046 //
2047
2048 /// \name Bounds Safety
2049 /// Implementations are in SemaBoundsSafety.cpp
2050 ///@{
2051public:
2052 /// Check if applying the specified attribute variant from the "counted by"
2053 /// family of attributes to FieldDecl \p FD is semantically valid. If
2054 /// semantically invalid diagnostics will be emitted explaining the problems.
2055 ///
2056 /// \param FD The FieldDecl to apply the attribute to
2057 /// \param E The count expression on the attribute
2058 /// \param CountInBytes If true the attribute is from the "sized_by" family of
2059 /// attributes. If the false the attribute is from
2060 /// "counted_by" family of attributes.
2061 /// \param OrNull If true the attribute is from the "_or_null" suffixed family
2062 /// of attributes. If false the attribute does not have the
2063 /// suffix.
2064 ///
2065 /// Together \p CountInBytes and \p OrNull decide the attribute variant. E.g.
2066 /// \p CountInBytes and \p OrNull both being true indicates the
2067 /// `counted_by_or_null` attribute.
2068 ///
2069 /// \returns false iff semantically valid.
2070 bool CheckCountedByAttrOnField(FieldDecl *FD, Expr *E, bool CountInBytes,
2071 bool OrNull);
2072
2073 ///@}
2074
2075 //
2076 //
2077 // -------------------------------------------------------------------------
2078 //
2079 //
2080
2081 /// \name Casts
2082 /// Implementations are in SemaCast.cpp
2083 ///@{
2084
2085public:
2087 return CCK == CheckedConversionKind::CStyleCast ||
2090 }
2091
2092 /// ActOnCXXNamedCast - Parse
2093 /// {dynamic,static,reinterpret,const,addrspace}_cast's.
2095 SourceLocation LAngleBracketLoc, Declarator &D,
2096 SourceLocation RAngleBracketLoc,
2097 SourceLocation LParenLoc, Expr *E,
2098 SourceLocation RParenLoc);
2099
2101 TypeSourceInfo *Ty, Expr *E,
2102 SourceRange AngleBrackets, SourceRange Parens);
2103
2105 ExprResult Operand,
2106 SourceLocation RParenLoc);
2107
2109 Expr *Operand, SourceLocation RParenLoc);
2110
2111 // Checks that reinterpret casts don't have undefined behavior.
2112 void CheckCompatibleReinterpretCast(QualType SrcType, QualType DestType,
2113 bool IsDereference, SourceRange Range);
2114
2115 // Checks that the vector type should be initialized from a scalar
2116 // by splatting the value rather than populating a single element.
2117 // This is the case for AltiVecVector types as well as with
2118 // AltiVecPixel and AltiVecBool when -faltivec-src-compat=xl is specified.
2119 bool ShouldSplatAltivecScalarInCast(const VectorType *VecTy);
2120
2121 // Checks if the -faltivec-src-compat=gcc option is specified.
2122 // If so, AltiVecVector, AltiVecBool and AltiVecPixel types are
2123 // treated the same way as they are when trying to initialize
2124 // these vectors on gcc (an error is emitted).
2126 QualType SrcTy);
2127
2129 SourceLocation RParenLoc, Expr *Op);
2130
2132 SourceLocation LParenLoc,
2133 Expr *CastExpr,
2134 SourceLocation RParenLoc);
2135
2136 ///@}
2137
2138 //
2139 //
2140 // -------------------------------------------------------------------------
2141 //
2142 //
2143
2144 /// \name Extra Semantic Checking
2145 /// Implementations are in SemaChecking.cpp
2146 ///@{
2147
2148public:
2149 /// Used to change context to isConstantEvaluated without pushing a heavy
2150 /// ExpressionEvaluationContextRecord object.
2152
2156 }
2157
2159 unsigned ByteNo) const;
2160
2162 FAPK_Fixed, // values to format are fixed (no C-style variadic arguments)
2163 FAPK_Variadic, // values to format are passed as variadic arguments
2164 FAPK_VAList, // values to format are passed in a va_list
2165 };
2166
2167 // Used to grab the relevant information from a FormatAttr and a
2168 // FunctionDeclaration.
2170 unsigned FormatIdx;
2173 };
2174
2175 /// Given a FunctionDecl's FormatAttr, attempts to populate the
2176 /// FomatStringInfo parameter with the FormatAttr's correct format_idx and
2177 /// firstDataArg. Returns true when the format fits the function and the
2178 /// FormatStringInfo has been populated.
2179 static bool getFormatStringInfo(const FormatAttr *Format, bool IsCXXMember,
2180 bool IsVariadic, FormatStringInfo *FSI);
2181
2182 // Used by C++ template instantiation.
2184
2185 /// ConvertVectorExpr - Handle __builtin_convertvector
2187 SourceLocation BuiltinLoc,
2188 SourceLocation RParenLoc);
2189
2203 static FormatStringType GetFormatStringType(const FormatAttr *Format);
2204
2205 bool FormatStringHasSArg(const StringLiteral *FExpr);
2206
2207 /// Check for comparisons of floating-point values using == and !=. Issue a
2208 /// warning if the comparison is not likely to do what the programmer
2209 /// intended.
2211 BinaryOperatorKind Opcode);
2212
2213 /// Register a magic integral constant to be used as a type tag.
2214 void RegisterTypeTagForDatatype(const IdentifierInfo *ArgumentKind,
2215 uint64_t MagicValue, QualType Type,
2216 bool LayoutCompatible, bool MustBeNull);
2217
2220
2224
2226
2227 /// If true, \c Type should be compared with other expression's types for
2228 /// layout-compatibility.
2229 LLVM_PREFERRED_TYPE(bool)
2231 LLVM_PREFERRED_TYPE(bool)
2232 unsigned MustBeNull : 1;
2233 };
2234
2235 /// A pair of ArgumentKind identifier and magic value. This uniquely
2236 /// identifies the magic value.
2237 typedef std::pair<const IdentifierInfo *, uint64_t> TypeTagMagicValue;
2238
2239 /// Diagnoses the current set of gathered accesses. This typically
2240 /// happens at full expression level. The set is cleared after emitting the
2241 /// diagnostics.
2243
2244 /// This function checks if the expression is in the sef of potentially
2245 /// misaligned members and it is converted to some pointer type T with lower
2246 /// or equal alignment requirements. If so it removes it. This is used when
2247 /// we do not want to diagnose such misaligned access (e.g. in conversions to
2248 /// void*).
2250
2251 /// This function calls Action when it determines that E designates a
2252 /// misaligned member due to the packed attribute. This is used to emit
2253 /// local diagnostics like in reference binding.
2255 Expr *E,
2256 llvm::function_ref<void(Expr *, RecordDecl *, FieldDecl *, CharUnits)>
2257 Action);
2258
2259 enum class AtomicArgumentOrder { API, AST };
2261 BuildAtomicExpr(SourceRange CallRange, SourceRange ExprRange,
2262 SourceLocation RParenLoc, MultiExprArg Args,
2265
2266 /// Check to see if a given expression could have '.c_str()' called on it.
2267 bool hasCStrMethod(const Expr *E);
2268
2269 /// Diagnose pointers that are always non-null.
2270 /// \param E the expression containing the pointer
2271 /// \param NullKind NPCK_NotNull if E is a cast to bool, otherwise, E is
2272 /// compared to a null pointer
2273 /// \param IsEqual True when the comparison is equal to a null pointer
2274 /// \param Range Extra SourceRange to highlight in the diagnostic
2277 bool IsEqual, SourceRange Range);
2278
2279 /// CheckParmsForFunctionDef - Check that the parameters of the given
2280 /// function are appropriate for the definition of a function. This
2281 /// takes care of any checks that cannot be performed on the
2282 /// declaration itself, e.g., that the types of each of the function
2283 /// parameters are complete.
2285 bool CheckParameterNames);
2286
2287 /// CheckCastAlign - Implements -Wcast-align, which warns when a
2288 /// pointer cast increases the alignment requirements.
2289 void CheckCastAlign(Expr *Op, QualType T, SourceRange TRange);
2290
2291 /// checkUnsafeAssigns - Check whether +1 expr is being assigned
2292 /// to weak/__unsafe_unretained type.
2294
2295 /// checkUnsafeExprAssigns - Check whether +1 expr is being assigned
2296 /// to weak/__unsafe_unretained expression.
2298
2299 /// Emit \p DiagID if statement located on \p StmtLoc has a suspicious null
2300 /// statement as a \p Body, and it is located on the same line.
2301 ///
2302 /// This helps prevent bugs due to typos, such as:
2303 /// if (condition);
2304 /// do_stuff();
2305 void DiagnoseEmptyStmtBody(SourceLocation StmtLoc, const Stmt *Body,
2306 unsigned DiagID);
2307
2308 /// Warn if a for/while loop statement \p S, which is followed by
2309 /// \p PossibleBody, has a suspicious null statement as a body.
2310 void DiagnoseEmptyLoopBody(const Stmt *S, const Stmt *PossibleBody);
2311
2312 /// DiagnoseSelfMove - Emits a warning if a value is moved to itself.
2313 void DiagnoseSelfMove(const Expr *LHSExpr, const Expr *RHSExpr,
2314 SourceLocation OpLoc);
2315
2316 // Used for emitting the right warning by DefaultVariadicArgumentPromotion
2324
2325 bool IsLayoutCompatible(QualType T1, QualType T2) const;
2327 const TypeSourceInfo *Derived);
2328
2329 /// CheckFunctionCall - Check a direct function call for various correctness
2330 /// and safety properties not strictly enforced by the C type system.
2331 bool CheckFunctionCall(FunctionDecl *FDecl, CallExpr *TheCall,
2332 const FunctionProtoType *Proto);
2333
2334 /// \param FPOnly restricts the arguments to floating-point types.
2335 std::optional<QualType> BuiltinVectorMath(CallExpr *TheCall,
2336 bool FPOnly = false);
2337 bool BuiltinVectorToScalarMath(CallExpr *TheCall);
2338
2339 void checkLifetimeCaptureBy(FunctionDecl *FDecl, bool IsMemberFunction,
2340 const Expr *ThisArg, ArrayRef<const Expr *> Args);
2341
2342 /// Handles the checks for format strings, non-POD arguments to vararg
2343 /// functions, NULL arguments passed to non-NULL parameters, diagnose_if
2344 /// attributes and AArch64 SME attributes.
2345 void checkCall(NamedDecl *FDecl, const FunctionProtoType *Proto,
2346 const Expr *ThisArg, ArrayRef<const Expr *> Args,
2347 bool IsMemberFunction, SourceLocation Loc, SourceRange Range,
2348 VariadicCallType CallType);
2349
2350 /// \brief Enforce the bounds of a TCB
2351 /// CheckTCBEnforcement - Enforces that every function in a named TCB only
2352 /// directly calls other functions in the same TCB as marked by the
2353 /// enforce_tcb and enforce_tcb_leaf attributes.
2354 void CheckTCBEnforcement(const SourceLocation CallExprLoc,
2355 const NamedDecl *Callee);
2356
2357 void CheckConstrainedAuto(const AutoType *AutoT, SourceLocation Loc);
2358
2359 /// BuiltinConstantArg - Handle a check if argument ArgNum of CallExpr
2360 /// TheCall is a constant expression.
2361 bool BuiltinConstantArg(CallExpr *TheCall, int ArgNum, llvm::APSInt &Result);
2362
2363 /// BuiltinConstantArgRange - Handle a check if argument ArgNum of CallExpr
2364 /// TheCall is a constant expression in the range [Low, High].
2365 bool BuiltinConstantArgRange(CallExpr *TheCall, int ArgNum, int Low, int High,
2366 bool RangeIsError = true);
2367
2368 /// BuiltinConstantArgMultiple - Handle a check if argument ArgNum of CallExpr
2369 /// TheCall is a constant expression is a multiple of Num..
2370 bool BuiltinConstantArgMultiple(CallExpr *TheCall, int ArgNum,
2371 unsigned Multiple);
2372
2373 /// BuiltinConstantArgPower2 - Check if argument ArgNum of TheCall is a
2374 /// constant expression representing a power of 2.
2375 bool BuiltinConstantArgPower2(CallExpr *TheCall, int ArgNum);
2376
2377 /// BuiltinConstantArgShiftedByte - Check if argument ArgNum of TheCall is
2378 /// a constant expression representing an arbitrary byte value shifted left by
2379 /// a multiple of 8 bits.
2380 bool BuiltinConstantArgShiftedByte(CallExpr *TheCall, int ArgNum,
2381 unsigned ArgBits);
2382
2383 /// BuiltinConstantArgShiftedByteOr0xFF - Check if argument ArgNum of
2384 /// TheCall is a constant expression representing either a shifted byte value,
2385 /// or a value of the form 0x??FF (i.e. a member of the arithmetic progression
2386 /// 0x00FF, 0x01FF, ..., 0xFFFF). This strange range check is needed for some
2387 /// Arm MVE intrinsics.
2388 bool BuiltinConstantArgShiftedByteOrXXFF(CallExpr *TheCall, int ArgNum,
2389 unsigned ArgBits);
2390
2391 /// Checks that a call expression's argument count is at least the desired
2392 /// number. This is useful when doing custom type-checking on a variadic
2393 /// function. Returns true on error.
2394 bool checkArgCountAtLeast(CallExpr *Call, unsigned MinArgCount);
2395
2396 /// Checks that a call expression's argument count is at most the desired
2397 /// number. This is useful when doing custom type-checking on a variadic
2398 /// function. Returns true on error.
2399 bool checkArgCountAtMost(CallExpr *Call, unsigned MaxArgCount);
2400
2401 /// Checks that a call expression's argument count is in the desired range.
2402 /// This is useful when doing custom type-checking on a variadic function.
2403 /// Returns true on error.
2404 bool checkArgCountRange(CallExpr *Call, unsigned MinArgCount,
2405 unsigned MaxArgCount);
2406
2407 /// Checks that a call expression's argument count is the desired number.
2408 /// This is useful when doing custom type-checking. Returns true on error.
2409 bool checkArgCount(CallExpr *Call, unsigned DesiredArgCount);
2410
2411 /// Returns true if the argument consists of one contiguous run of 1s with any
2412 /// number of 0s on either side. The 1s are allowed to wrap from LSB to MSB,
2413 /// so 0x000FFF0, 0x0000FFFF, 0xFF0000FF, 0x0 are all runs. 0x0F0F0000 is not,
2414 /// since all 1s are not contiguous.
2415 bool ValueIsRunOfOnes(CallExpr *TheCall, unsigned ArgNum);
2416
2418 bool *ICContext = nullptr,
2419 bool IsListInit = false);
2420
2422 bool CheckForFloatArgs = true);
2424
2425private:
2426 void CheckArrayAccess(const Expr *BaseExpr, const Expr *IndexExpr,
2427 const ArraySubscriptExpr *ASE = nullptr,
2428 bool AllowOnePastEnd = true, bool IndexNegated = false);
2429 void CheckArrayAccess(const Expr *E);
2430
2431 bool CheckPointerCall(NamedDecl *NDecl, CallExpr *TheCall,
2432 const FunctionProtoType *Proto);
2433
2434 /// Checks function calls when a FunctionDecl or a NamedDecl is not available,
2435 /// such as function pointers returned from functions.
2436 bool CheckOtherCall(CallExpr *TheCall, const FunctionProtoType *Proto);
2437
2438 /// CheckConstructorCall - Check a constructor call for correctness and safety
2439 /// properties not enforced by the C type system.
2440 void CheckConstructorCall(FunctionDecl *FDecl, QualType ThisType,
2442 const FunctionProtoType *Proto, SourceLocation Loc);
2443
2444 /// Warn if a pointer or reference argument passed to a function points to an
2445 /// object that is less aligned than the parameter. This can happen when
2446 /// creating a typedef with a lower alignment than the original type and then
2447 /// calling functions defined in terms of the original type.
2448 void CheckArgAlignment(SourceLocation Loc, NamedDecl *FDecl,
2449 StringRef ParamName, QualType ArgTy, QualType ParamTy);
2450
2451 ExprResult CheckOSLogFormatStringArg(Expr *Arg);
2452
2453 ExprResult CheckBuiltinFunctionCall(FunctionDecl *FDecl, unsigned BuiltinID,
2454 CallExpr *TheCall);
2455
2456 bool CheckTSBuiltinFunctionCall(const TargetInfo &TI, unsigned BuiltinID,
2457 CallExpr *TheCall);
2458
2459 void checkFortifiedBuiltinMemoryFunction(FunctionDecl *FD, CallExpr *TheCall);
2460
2461 /// Check the arguments to '__builtin_va_start' or '__builtin_ms_va_start'
2462 /// for validity. Emit an error and return true on failure; return false
2463 /// on success.
2464 bool BuiltinVAStart(unsigned BuiltinID, CallExpr *TheCall);
2465 bool BuiltinVAStartARMMicrosoft(CallExpr *Call);
2466
2467 /// BuiltinUnorderedCompare - Handle functions like __builtin_isgreater and
2468 /// friends. This is declared to take (...), so we have to check everything.
2469 bool BuiltinUnorderedCompare(CallExpr *TheCall, unsigned BuiltinID);
2470
2471 /// BuiltinSemaBuiltinFPClassification - Handle functions like
2472 /// __builtin_isnan and friends. This is declared to take (...), so we have
2473 /// to check everything.
2474 bool BuiltinFPClassification(CallExpr *TheCall, unsigned NumArgs,
2475 unsigned BuiltinID);
2476
2477 /// Perform semantic analysis for a call to __builtin_complex.
2478 bool BuiltinComplex(CallExpr *TheCall);
2479 bool BuiltinOSLogFormat(CallExpr *TheCall);
2480
2481 /// BuiltinPrefetch - Handle __builtin_prefetch.
2482 /// This is declared to take (const void*, ...) and can take two
2483 /// optional constant int args.
2484 bool BuiltinPrefetch(CallExpr *TheCall);
2485
2486 /// Handle __builtin_alloca_with_align. This is declared
2487 /// as (size_t, size_t) where the second size_t must be a power of 2 greater
2488 /// than 8.
2489 bool BuiltinAllocaWithAlign(CallExpr *TheCall);
2490
2491 /// BuiltinArithmeticFence - Handle __arithmetic_fence.
2492 bool BuiltinArithmeticFence(CallExpr *TheCall);
2493
2494 /// BuiltinAssume - Handle __assume (MS Extension).
2495 /// __assume does not evaluate its arguments, and should warn if its argument
2496 /// has side effects.
2497 bool BuiltinAssume(CallExpr *TheCall);
2498
2499 /// Handle __builtin_assume_aligned. This is declared
2500 /// as (const void*, size_t, ...) and can take one optional constant int arg.
2501 bool BuiltinAssumeAligned(CallExpr *TheCall);
2502
2503 /// BuiltinLongjmp - Handle __builtin_longjmp(void *env[5], int val).
2504 /// This checks that the target supports __builtin_longjmp and
2505 /// that val is a constant 1.
2506 bool BuiltinLongjmp(CallExpr *TheCall);
2507
2508 /// BuiltinSetjmp - Handle __builtin_setjmp(void *env[5]).
2509 /// This checks that the target supports __builtin_setjmp.
2510 bool BuiltinSetjmp(CallExpr *TheCall);
2511
2512 /// We have a call to a function like __sync_fetch_and_add, which is an
2513 /// overloaded function based on the pointer type of its first argument.
2514 /// The main BuildCallExpr routines have already promoted the types of
2515 /// arguments because all of these calls are prototyped as void(...).
2516 ///
2517 /// This function goes through and does final semantic checking for these
2518 /// builtins, as well as generating any warnings.
2519 ExprResult BuiltinAtomicOverloaded(ExprResult TheCallResult);
2520
2521 /// BuiltinNontemporalOverloaded - We have a call to
2522 /// __builtin_nontemporal_store or __builtin_nontemporal_load, which is an
2523 /// overloaded function based on the pointer type of its last argument.
2524 ///
2525 /// This function goes through and does final semantic checking for these
2526 /// builtins.
2527 ExprResult BuiltinNontemporalOverloaded(ExprResult TheCallResult);
2528 ExprResult AtomicOpsOverloaded(ExprResult TheCallResult,
2530
2531 /// \param FPOnly restricts the arguments to floating-point types.
2532 bool BuiltinElementwiseMath(CallExpr *TheCall, bool FPOnly = false);
2533 bool PrepareBuiltinReduceMathOneArgCall(CallExpr *TheCall);
2534
2535 bool BuiltinNonDeterministicValue(CallExpr *TheCall);
2536
2537 enum BuiltinCountedByRefKind {
2538 AssignmentKind,
2539 InitializerKind,
2540 FunctionArgKind,
2541 ReturnArgKind,
2542 ArraySubscriptKind,
2543 BinaryExprKind,
2544 };
2545
2546 bool CheckInvalidBuiltinCountedByRef(const Expr *E,
2547 BuiltinCountedByRefKind K);
2548 bool BuiltinCountedByRef(CallExpr *TheCall);
2549
2550 // Matrix builtin handling.
2551 ExprResult BuiltinMatrixTranspose(CallExpr *TheCall, ExprResult CallResult);
2552 ExprResult BuiltinMatrixColumnMajorLoad(CallExpr *TheCall,
2553 ExprResult CallResult);
2554 ExprResult BuiltinMatrixColumnMajorStore(CallExpr *TheCall,
2555 ExprResult CallResult);
2556
2557 /// CheckFormatArguments - Check calls to printf and scanf (and similar
2558 /// functions) for correct use of format strings.
2559 /// Returns true if a format string has been fully checked.
2560 bool CheckFormatArguments(const FormatAttr *Format,
2561 ArrayRef<const Expr *> Args, bool IsCXXMember,
2562 VariadicCallType CallType, SourceLocation Loc,
2563 SourceRange Range,
2564 llvm::SmallBitVector &CheckedVarArgs);
2565 bool CheckFormatArguments(ArrayRef<const Expr *> Args,
2566 FormatArgumentPassingKind FAPK, unsigned format_idx,
2567 unsigned firstDataArg, FormatStringType Type,
2568 VariadicCallType CallType, SourceLocation Loc,
2569 SourceRange range,
2570 llvm::SmallBitVector &CheckedVarArgs);
2571
2572 void CheckInfNaNFunction(const CallExpr *Call, const FunctionDecl *FDecl);
2573
2574 /// Warn when using the wrong abs() function.
2575 void CheckAbsoluteValueFunction(const CallExpr *Call,
2576 const FunctionDecl *FDecl);
2577
2578 void CheckMaxUnsignedZero(const CallExpr *Call, const FunctionDecl *FDecl);
2579
2580 /// Check for dangerous or invalid arguments to memset().
2581 ///
2582 /// This issues warnings on known problematic, dangerous or unspecified
2583 /// arguments to the standard 'memset', 'memcpy', 'memmove', and 'memcmp'
2584 /// function calls.
2585 ///
2586 /// \param Call The call expression to diagnose.
2587 void CheckMemaccessArguments(const CallExpr *Call, unsigned BId,
2588 IdentifierInfo *FnName);
2589
2590 // Warn if the user has made the 'size' argument to strlcpy or strlcat
2591 // be the size of the source, instead of the destination.
2592 void CheckStrlcpycatArguments(const CallExpr *Call, IdentifierInfo *FnName);
2593
2594 // Warn on anti-patterns as the 'size' argument to strncat.
2595 // The correct size argument should look like following:
2596 // strncat(dst, src, sizeof(dst) - strlen(dest) - 1);
2597 void CheckStrncatArguments(const CallExpr *Call, IdentifierInfo *FnName);
2598
2599 /// Alerts the user that they are attempting to free a non-malloc'd object.
2600 void CheckFreeArguments(const CallExpr *E);
2601
2602 void CheckReturnValExpr(Expr *RetValExp, QualType lhsType,
2603 SourceLocation ReturnLoc, bool isObjCMethod = false,
2604 const AttrVec *Attrs = nullptr,
2605 const FunctionDecl *FD = nullptr);
2606
2607 /// Diagnoses "dangerous" implicit conversions within the given
2608 /// expression (which is a full expression). Implements -Wconversion
2609 /// and -Wsign-compare.
2610 ///
2611 /// \param CC the "context" location of the implicit conversion, i.e.
2612 /// the most location of the syntactic entity requiring the implicit
2613 /// conversion
2614 void CheckImplicitConversions(Expr *E, SourceLocation CC = SourceLocation());
2615
2616 /// CheckBoolLikeConversion - Check conversion of given expression to boolean.
2617 /// Input argument E is a logical expression.
2618 void CheckBoolLikeConversion(Expr *E, SourceLocation CC);
2619
2620 /// Diagnose when expression is an integer constant expression and its
2621 /// evaluation results in integer overflow
2622 void CheckForIntOverflow(const Expr *E);
2623 void CheckUnsequencedOperations(const Expr *E);
2624
2625 /// Perform semantic checks on a completed expression. This will either
2626 /// be a full-expression or a default argument expression.
2627 void CheckCompletedExpr(Expr *E, SourceLocation CheckLoc = SourceLocation(),
2628 bool IsConstexpr = false);
2629
2630 void CheckBitFieldInitialization(SourceLocation InitLoc, FieldDecl *Field,
2631 Expr *Init);
2632
2633 /// A map from magic value to type information.
2634 std::unique_ptr<llvm::DenseMap<TypeTagMagicValue, TypeTagData>>
2635 TypeTagForDatatypeMagicValues;
2636
2637 /// Peform checks on a call of a function with argument_with_type_tag
2638 /// or pointer_with_type_tag attributes.
2639 void CheckArgumentWithTypeTag(const ArgumentWithTypeTagAttr *Attr,
2640 const ArrayRef<const Expr *> ExprArgs,
2641 SourceLocation CallSiteLoc);
2642
2643 /// Check if we are taking the address of a packed field
2644 /// as this may be a problem if the pointer value is dereferenced.
2645 void CheckAddressOfPackedMember(Expr *rhs);
2646
2647 /// Helper class that collects misaligned member designations and
2648 /// their location info for delayed diagnostics.
2649 struct MisalignedMember {
2650 Expr *E;
2651 RecordDecl *RD;
2652 ValueDecl *MD;
2653 CharUnits Alignment;
2654
2655 MisalignedMember() : E(), RD(), MD() {}
2656 MisalignedMember(Expr *E, RecordDecl *RD, ValueDecl *MD,
2657 CharUnits Alignment)
2658 : E(E), RD(RD), MD(MD), Alignment(Alignment) {}
2659 explicit MisalignedMember(Expr *E)
2660 : MisalignedMember(E, nullptr, nullptr, CharUnits()) {}
2661
2662 bool operator==(const MisalignedMember &m) { return this->E == m.E; }
2663 };
2664 /// Small set of gathered accesses to potentially misaligned members
2665 /// due to the packed attribute.
2666 SmallVector<MisalignedMember, 4> MisalignedMembers;
2667
2668 /// Adds an expression to the set of gathered misaligned members.
2669 void AddPotentialMisalignedMembers(Expr *E, RecordDecl *RD, ValueDecl *MD,
2670 CharUnits Alignment);
2671 ///@}
2672
2673 //
2674 //
2675 // -------------------------------------------------------------------------
2676 //
2677 //
2678
2679 /// \name C++ Coroutines
2680 /// Implementations are in SemaCoroutine.cpp
2681 ///@{
2682
2683public:
2684 /// The C++ "std::coroutine_traits" template, which is defined in
2685 /// <coroutine_traits>
2687
2689 StringRef Keyword);
2693
2696 UnresolvedLookupExpr *Lookup);
2698 Expr *Awaiter, bool IsImplicit = false);
2700 UnresolvedLookupExpr *Lookup);
2703 bool IsImplicit = false);
2708
2709 // As a clang extension, enforces that a non-coroutine function must be marked
2710 // with [[clang::coro_wrapper]] if it returns a type marked with
2711 // [[clang::coro_return_type]].
2712 // Expects that FD is not a coroutine.
2714 /// Lookup 'coroutine_traits' in std namespace and std::experimental
2715 /// namespace. The namespace found is recorded in Namespace.
2717 SourceLocation FuncLoc);
2718 /// Check that the expression co_await promise.final_suspend() shall not be
2719 /// potentially-throwing.
2720 bool checkFinalSuspendNoThrow(const Stmt *FinalSuspend);
2721
2722 ///@}
2723
2724 //
2725 //
2726 // -------------------------------------------------------------------------
2727 //
2728 //
2729
2730 /// \name C++ Scope Specifiers
2731 /// Implementations are in SemaCXXScopeSpec.cpp
2732 ///@{
2733
2734public:
2735 // Marks SS invalid if it represents an incomplete type.
2737 // Complete an enum decl, maybe without a scope spec.
2739 CXXScopeSpec *SS = nullptr);
2740
2741 /// Compute the DeclContext that is associated with the given type.
2742 ///
2743 /// \param T the type for which we are attempting to find a DeclContext.
2744 ///
2745 /// \returns the declaration context represented by the type T,
2746 /// or NULL if the declaration context cannot be computed (e.g., because it is
2747 /// dependent and not the current instantiation).
2749
2750 /// Compute the DeclContext that is associated with the given
2751 /// scope specifier.
2752 ///
2753 /// \param SS the C++ scope specifier as it appears in the source
2754 ///
2755 /// \param EnteringContext when true, we will be entering the context of
2756 /// this scope specifier, so we can retrieve the declaration context of a
2757 /// class template or class template partial specialization even if it is
2758 /// not the current instantiation.
2759 ///
2760 /// \returns the declaration context represented by the scope specifier @p SS,
2761 /// or NULL if the declaration context cannot be computed (e.g., because it is
2762 /// dependent and not the current instantiation).
2764 bool EnteringContext = false);
2766
2767 /// If the given nested name specifier refers to the current
2768 /// instantiation, return the declaration that corresponds to that
2769 /// current instantiation (C++0x [temp.dep.type]p1).
2770 ///
2771 /// \param NNS a dependent nested name specifier.
2773
2774 /// The parser has parsed a global nested-name-specifier '::'.
2775 ///
2776 /// \param CCLoc The location of the '::'.
2777 ///
2778 /// \param SS The nested-name-specifier, which will be updated in-place
2779 /// to reflect the parsed nested-name-specifier.
2780 ///
2781 /// \returns true if an error occurred, false otherwise.
2783
2784 /// The parser has parsed a '__super' nested-name-specifier.
2785 ///
2786 /// \param SuperLoc The location of the '__super' keyword.
2787 ///
2788 /// \param ColonColonLoc The location of the '::'.
2789 ///
2790 /// \param SS The nested-name-specifier, which will be updated in-place
2791 /// to reflect the parsed nested-name-specifier.
2792 ///
2793 /// \returns true if an error occurred, false otherwise.
2795 SourceLocation ColonColonLoc, CXXScopeSpec &SS);
2796
2797 /// Determines whether the given declaration is an valid acceptable
2798 /// result for name lookup of a nested-name-specifier.
2799 /// \param SD Declaration checked for nested-name-specifier.
2800 /// \param IsExtension If not null and the declaration is accepted as an
2801 /// extension, the pointed variable is assigned true.
2803 bool *CanCorrect = nullptr);
2804
2805 /// If the given nested-name-specifier begins with a bare identifier
2806 /// (e.g., Base::), perform name lookup for that identifier as a
2807 /// nested-name-specifier within the given scope, and return the result of
2808 /// that name lookup.
2810
2811 /// Keeps information about an identifier in a nested-name-spec.
2812 ///
2814 /// The type of the object, if we're parsing nested-name-specifier in
2815 /// a member access expression.
2817
2818 /// The identifier preceding the '::'.
2820
2821 /// The location of the identifier.
2823
2824 /// The location of the '::'.
2826
2827 /// Creates info object for the most typical case.
2829 SourceLocation ColonColonLoc,
2830 ParsedType ObjectType = ParsedType())
2831 : ObjectType(ObjectType), Identifier(II), IdentifierLoc(IdLoc),
2832 CCLoc(ColonColonLoc) {}
2833
2835 SourceLocation ColonColonLoc, QualType ObjectType)
2836 : ObjectType(ParsedType::make(ObjectType)), Identifier(II),
2837 IdentifierLoc(IdLoc), CCLoc(ColonColonLoc) {}
2838 };
2839
2840 /// Build a new nested-name-specifier for "identifier::", as described
2841 /// by ActOnCXXNestedNameSpecifier.
2842 ///
2843 /// \param S Scope in which the nested-name-specifier occurs.
2844 /// \param IdInfo Parser information about an identifier in the
2845 /// nested-name-spec.
2846 /// \param EnteringContext If true, enter the context specified by the
2847 /// nested-name-specifier.
2848 /// \param SS Optional nested name specifier preceding the identifier.
2849 /// \param ScopeLookupResult Provides the result of name lookup within the
2850 /// scope of the nested-name-specifier that was computed at template
2851 /// definition time.
2852 /// \param ErrorRecoveryLookup Specifies if the method is called to improve
2853 /// error recovery and what kind of recovery is performed.
2854 /// \param IsCorrectedToColon If not null, suggestion of replace '::' -> ':'
2855 /// are allowed. The bool value pointed by this parameter is set to
2856 /// 'true' if the identifier is treated as if it was followed by ':',
2857 /// not '::'.
2858 /// \param OnlyNamespace If true, only considers namespaces in lookup.
2859 ///
2860 /// This routine differs only slightly from ActOnCXXNestedNameSpecifier, in
2861 /// that it contains an extra parameter \p ScopeLookupResult, which provides
2862 /// the result of name lookup within the scope of the nested-name-specifier
2863 /// that was computed at template definition time.
2864 ///
2865 /// If ErrorRecoveryLookup is true, then this call is used to improve error
2866 /// recovery. This means that it should not emit diagnostics, it should
2867 /// just return true on failure. It also means it should only return a valid
2868 /// scope if it *knows* that the result is correct. It should not return in a
2869 /// dependent context, for example. Nor will it extend \p SS with the scope
2870 /// specifier.
2871 bool BuildCXXNestedNameSpecifier(Scope *S, NestedNameSpecInfo &IdInfo,
2872 bool EnteringContext, CXXScopeSpec &SS,
2873 NamedDecl *ScopeLookupResult,
2874 bool ErrorRecoveryLookup,
2875 bool *IsCorrectedToColon = nullptr,
2876 bool OnlyNamespace = false);
2877
2878 /// The parser has parsed a nested-name-specifier 'identifier::'.
2879 ///
2880 /// \param S The scope in which this nested-name-specifier occurs.
2881 ///
2882 /// \param IdInfo Parser information about an identifier in the
2883 /// nested-name-spec.
2884 ///
2885 /// \param EnteringContext Whether we're entering the context nominated by
2886 /// this nested-name-specifier.
2887 ///
2888 /// \param SS The nested-name-specifier, which is both an input
2889 /// parameter (the nested-name-specifier before this type) and an
2890 /// output parameter (containing the full nested-name-specifier,
2891 /// including this new type).
2892 ///
2893 /// \param IsCorrectedToColon If not null, suggestions to replace '::' -> ':'
2894 /// are allowed. The bool value pointed by this parameter is set to 'true'
2895 /// if the identifier is treated as if it was followed by ':', not '::'.
2896 ///
2897 /// \param OnlyNamespace If true, only considers namespaces in lookup.
2898 ///
2899 /// \returns true if an error occurred, false otherwise.
2900 bool ActOnCXXNestedNameSpecifier(Scope *S, NestedNameSpecInfo &IdInfo,
2901 bool EnteringContext, CXXScopeSpec &SS,
2902 bool *IsCorrectedToColon = nullptr,
2903 bool OnlyNamespace = false);
2904
2905 /// The parser has parsed a nested-name-specifier
2906 /// 'template[opt] template-name < template-args >::'.
2907 ///
2908 /// \param S The scope in which this nested-name-specifier occurs.
2909 ///
2910 /// \param SS The nested-name-specifier, which is both an input
2911 /// parameter (the nested-name-specifier before this type) and an
2912 /// output parameter (containing the full nested-name-specifier,
2913 /// including this new type).
2914 ///
2915 /// \param TemplateKWLoc the location of the 'template' keyword, if any.
2916 /// \param TemplateName the template name.
2917 /// \param TemplateNameLoc The location of the template name.
2918 /// \param LAngleLoc The location of the opening angle bracket ('<').
2919 /// \param TemplateArgs The template arguments.
2920 /// \param RAngleLoc The location of the closing angle bracket ('>').
2921 /// \param CCLoc The location of the '::'.
2922 ///
2923 /// \param EnteringContext Whether we're entering the context of the
2924 /// nested-name-specifier.
2925 ///
2926 ///
2927 /// \returns true if an error occurred, false otherwise.
2929 Scope *S, CXXScopeSpec &SS, SourceLocation TemplateKWLoc,
2930 TemplateTy TemplateName, SourceLocation TemplateNameLoc,
2931 SourceLocation LAngleLoc, ASTTemplateArgsPtr TemplateArgs,
2932 SourceLocation RAngleLoc, SourceLocation CCLoc, bool EnteringContext);
2933
2935 SourceLocation ColonColonLoc);
2936
2938 const DeclSpec &DS,
2939 SourceLocation ColonColonLoc,
2940 QualType Type);
2941
2942 /// IsInvalidUnlessNestedName - This method is used for error recovery
2943 /// purposes to determine whether the specified identifier is only valid as
2944 /// a nested name specifier, for example a namespace name. It is
2945 /// conservatively correct to always return false from this method.
2946 ///
2947 /// The arguments are the same as those passed to ActOnCXXNestedNameSpecifier.
2949 NestedNameSpecInfo &IdInfo,
2950 bool EnteringContext);
2951
2952 /// Given a C++ nested-name-specifier, produce an annotation value
2953 /// that the parser can use later to reconstruct the given
2954 /// nested-name-specifier.
2955 ///
2956 /// \param SS A nested-name-specifier.
2957 ///
2958 /// \returns A pointer containing all of the information in the
2959 /// nested-name-specifier \p SS.
2961
2962 /// Given an annotation pointer for a nested-name-specifier, restore
2963 /// the nested-name-specifier structure.
2964 ///
2965 /// \param Annotation The annotation pointer, produced by
2966 /// \c SaveNestedNameSpecifierAnnotation().
2967 ///
2968 /// \param AnnotationRange The source range corresponding to the annotation.
2969 ///
2970 /// \param SS The nested-name-specifier that will be updated with the contents
2971 /// of the annotation pointer.
2972 void RestoreNestedNameSpecifierAnnotation(void *Annotation,
2973 SourceRange AnnotationRange,
2974 CXXScopeSpec &SS);
2975
2976 bool ShouldEnterDeclaratorScope(Scope *S, const CXXScopeSpec &SS);
2977
2978 /// ActOnCXXEnterDeclaratorScope - Called when a C++ scope specifier (global
2979 /// scope or nested-name-specifier) is parsed, part of a declarator-id.
2980 /// After this method is called, according to [C++ 3.4.3p3], names should be
2981 /// looked up in the declarator-id's scope, until the declarator is parsed and
2982 /// ActOnCXXExitDeclaratorScope is called.
2983 /// The 'SS' should be a non-empty valid CXXScopeSpec.
2985
2986 /// ActOnCXXExitDeclaratorScope - Called when a declarator that previously
2987 /// invoked ActOnCXXEnterDeclaratorScope(), is finished. 'SS' is the same
2988 /// CXXScopeSpec that was passed to ActOnCXXEnterDeclaratorScope as well.
2989 /// Used to indicate that names should revert to being looked up in the
2990 /// defining scope.
2992
2993 ///@}
2994
2995 //
2996 //
2997 // -------------------------------------------------------------------------
2998 //
2999 //
3000
3001 /// \name Declarations
3002 /// Implementations are in SemaDecl.cpp
3003 ///@{
3004
3005public:
3007
3008 /// The index of the first InventedParameterInfo that refers to the current
3009 /// context.
3011
3012 /// A RAII object to temporarily push a declaration context.
3014 private:
3015 Sema &S;
3016 DeclContext *SavedContext;
3017 ProcessingContextState SavedContextState;
3018 QualType SavedCXXThisTypeOverride;
3019 unsigned SavedFunctionScopesStart;
3020 unsigned SavedInventedParameterInfosStart;
3021
3022 public:
3023 ContextRAII(Sema &S, DeclContext *ContextToPush, bool NewThisContext = true)
3024 : S(S), SavedContext(S.CurContext),
3025 SavedContextState(S.DelayedDiagnostics.pushUndelayed()),
3026 SavedCXXThisTypeOverride(S.CXXThisTypeOverride),
3027 SavedFunctionScopesStart(S.FunctionScopesStart),
3028 SavedInventedParameterInfosStart(S.InventedParameterInfosStart) {
3029 assert(ContextToPush && "pushing null context");
3030 S.CurContext = ContextToPush;
3031 if (NewThisContext)
3032 S.CXXThisTypeOverride = QualType();
3033 // Any saved FunctionScopes do not refer to this context.
3034 S.FunctionScopesStart = S.FunctionScopes.size();
3035 S.InventedParameterInfosStart = S.InventedParameterInfos.size();
3036 }
3037
3038 void pop() {
3039 if (!SavedContext)
3040 return;
3041 S.CurContext = SavedContext;
3042 S.DelayedDiagnostics.popUndelayed(SavedContextState);
3043 S.CXXThisTypeOverride = SavedCXXThisTypeOverride;
3044 S.FunctionScopesStart = SavedFunctionScopesStart;
3045 S.InventedParameterInfosStart = SavedInventedParameterInfosStart;
3046 SavedContext = nullptr;
3047 }
3048
3049 ~ContextRAII() { pop(); }
3050 };
3051
3052 void DiagnoseInvalidJumps(Stmt *Body);
3053
3054 /// The function definitions which were renamed as part of typo-correction
3055 /// to match their respective declarations. We want to keep track of them
3056 /// to ensure that we don't emit a "redefinition" error if we encounter a
3057 /// correctly named definition after the renamed definition.
3059
3060 /// A cache of the flags available in enumerations with the flag_bits
3061 /// attribute.
3062 mutable llvm::DenseMap<const EnumDecl *, llvm::APInt> FlagBitsCache;
3063
3064 /// WeakUndeclaredIdentifiers - Identifiers contained in \#pragma weak before
3065 /// declared. Rare. May alias another identifier, declared or undeclared.
3066 ///
3067 /// For aliases, the target identifier is used as a key for eventual
3068 /// processing when the target is declared. For the single-identifier form,
3069 /// the sole identifier is used as the key. Each entry is a `SetVector`
3070 /// (ordered by parse order) of aliases (identified by the alias name) in case
3071 /// of multiple aliases to the same undeclared identifier.
3072 llvm::MapVector<
3074 llvm::SetVector<
3076 llvm::SmallDenseSet<WeakInfo, 2u, WeakInfo::DenseMapInfoByAliasOnly>>>
3078
3079 /// ExtnameUndeclaredIdentifiers - Identifiers contained in
3080 /// \#pragma redefine_extname before declared. Used in Solaris system headers
3081 /// to define functions that occur in multiple standards to call the version
3082 /// in the currently selected standard.
3083 llvm::DenseMap<IdentifierInfo *, AsmLabelAttr *> ExtnameUndeclaredIdentifiers;
3084
3085 /// Set containing all typedefs that are likely unused.
3088
3092
3093 /// The set of file scoped decls seen so far that have not been used
3094 /// and must warn if not used. Only contains the first declaration.
3096
3100
3101 /// All the tentative definitions encountered in the TU.
3103
3104 /// All the external declarations encoutered and used in the TU.
3106
3107 /// Generally null except when we temporarily switch decl contexts,
3108 /// like in \see SemaObjC::ActOnObjCTemporaryExitContainerContext.
3110
3111 /// Is the module scope we are in a C++ Header Unit?
3113 return ModuleScopes.empty() ? false
3114 : ModuleScopes.back().Module->isHeaderUnit();
3115 }
3116
3117 /// Get the module owning an entity.
3118 Module *getOwningModule(const Decl *Entity) {
3119 return Entity->getOwningModule();
3120 }
3121
3122 DeclGroupPtrTy ConvertDeclToDeclGroup(Decl *Ptr, Decl *OwnedType = nullptr);
3123
3124 /// If the identifier refers to a type name within this scope,
3125 /// return the declaration of that type.
3126 ///
3127 /// This routine performs ordinary name lookup of the identifier II
3128 /// within the given scope, with optional C++ scope specifier SS, to
3129 /// determine whether the name refers to a type. If so, returns an
3130 /// opaque pointer (actually a QualType) corresponding to that
3131 /// type. Otherwise, returns NULL.
3133 Scope *S, CXXScopeSpec *SS = nullptr,
3134 bool isClassName = false, bool HasTrailingDot = false,
3135 ParsedType ObjectType = nullptr,
3136 bool IsCtorOrDtorName = false,
3137 bool WantNontrivialTypeSourceInfo = false,
3138 bool IsClassTemplateDeductionContext = true,
3139 ImplicitTypenameContext AllowImplicitTypename =
3141 IdentifierInfo **CorrectedII = nullptr);
3142
3143 /// isTagName() - This method is called *for error recovery purposes only*
3144 /// to determine if the specified name is a valid tag name ("struct foo"). If
3145 /// so, this returns the TST for the tag corresponding to it (TST_enum,
3146 /// TST_union, TST_struct, TST_interface, TST_class). This is used to
3147 /// diagnose cases in C where the user forgot to specify the tag.
3149
3150 /// isMicrosoftMissingTypename - In Microsoft mode, within class scope,
3151 /// if a CXXScopeSpec's type is equal to the type of one of the base classes
3152 /// then downgrade the missing typename error to a warning.
3153 /// This is needed for MSVC compatibility; Example:
3154 /// @code
3155 /// template<class T> class A {
3156 /// public:
3157 /// typedef int TYPE;
3158 /// };
3159 /// template<class T> class B : public A<T> {
3160 /// public:
3161 /// A<T>::TYPE a; // no typename required because A<T> is a base class.
3162 /// };
3163 /// @endcode
3164 bool isMicrosoftMissingTypename(const CXXScopeSpec *SS, Scope *S);
3166 Scope *S, CXXScopeSpec *SS,
3167 ParsedType &SuggestedType,
3168 bool IsTemplateName = false);
3169
3170 /// Attempt to behave like MSVC in situations where lookup of an unqualified
3171 /// type name has failed in a dependent context. In these situations, we
3172 /// automatically form a DependentTypeName that will retry lookup in a related
3173 /// scope during instantiation.
3175 SourceLocation NameLoc,
3176 bool IsTemplateTypeArg);
3177
3178 /// Describes the result of the name lookup and resolution performed
3179 /// by \c ClassifyName().
3181 /// This name is not a type or template in this context, but might be
3182 /// something else.
3184 /// Classification failed; an error has been produced.
3186 /// The name has been typo-corrected to a keyword.
3188 /// The name was classified as a type.
3190 /// The name was classified as a specific non-type, non-template
3191 /// declaration. ActOnNameClassifiedAsNonType should be called to
3192 /// convert the declaration to an expression.
3194 /// The name was classified as an ADL-only function name.
3195 /// ActOnNameClassifiedAsUndeclaredNonType should be called to convert the
3196 /// result to an expression.
3198 /// The name denotes a member of a dependent type that could not be
3199 /// resolved. ActOnNameClassifiedAsDependentNonType should be called to
3200 /// convert the result to an expression.
3202 /// The name was classified as an overload set, and an expression
3203 /// representing that overload set has been formed.
3204 /// ActOnNameClassifiedAsOverloadSet should be called to form a suitable
3205 /// expression referencing the overload set.
3207 /// The name was classified as a template whose specializations are types.
3209 /// The name was classified as a variable template name.
3211 /// The name was classified as a function template name.
3213 /// The name was classified as an ADL-only function template name.
3215 /// The name was classified as a concept name.
3217 };
3218
3221 union {
3226 };
3227
3229
3230 public:
3232
3233 NameClassification(const IdentifierInfo *Keyword) : Kind(NC_Keyword) {}
3234
3235 static NameClassification Error() { return NameClassification(NC_Error); }
3236
3238 return NameClassification(NC_Unknown);
3239 }
3240
3242 NameClassification Result(NC_OverloadSet);
3243 Result.Expr = E;
3244 return Result;
3245 }
3246
3248 NameClassification Result(NC_NonType);
3249 Result.NonTypeDecl = D;
3250 return Result;
3251 }
3252
3254 return NameClassification(NC_UndeclaredNonType);
3255 }
3256
3258 return NameClassification(NC_DependentNonType);
3259 }
3260
3262 NameClassification Result(NC_TypeTemplate);
3263 Result.Template = Name;
3264 return Result;
3265 }
3266
3268 NameClassification Result(NC_VarTemplate);
3269 Result.Template = Name;
3270 return Result;
3271 }
3272
3274 NameClassification Result(NC_FunctionTemplate);
3275 Result.Template = Name;
3276 return Result;
3277 }
3278
3280 NameClassification Result(NC_Concept);
3281 Result.Template = Name;
3282 return Result;
3283 }
3284
3286 NameClassification Result(NC_UndeclaredTemplate);
3287 Result.Template = Name;
3288 return Result;
3289 }
3290
3292
3294 assert(Kind == NC_OverloadSet);
3295 return Expr;
3296 }
3297
3299 assert(Kind == NC_Type);
3300 return Type;
3301 }
3302
3304 assert(Kind == NC_NonType);
3305 return NonTypeDecl;
3306 }
3307
3309 assert(Kind == NC_TypeTemplate || Kind == NC_FunctionTemplate ||
3310 Kind == NC_VarTemplate || Kind == NC_Concept ||
3311 Kind == NC_UndeclaredTemplate);
3312 return Template;
3313 }
3314
3316 switch (Kind) {
3317 case NC_TypeTemplate:
3318 return TNK_Type_template;
3319 case NC_FunctionTemplate:
3320 return TNK_Function_template;
3321 case NC_VarTemplate:
3322 return TNK_Var_template;
3323 case NC_Concept:
3324 return TNK_Concept_template;
3325 case NC_UndeclaredTemplate:
3327 default:
3328 llvm_unreachable("unsupported name classification.");
3329 }
3330 }
3331 };
3332
3333 /// Perform name lookup on the given name, classifying it based on
3334 /// the results of name lookup and the following token.
3335 ///
3336 /// This routine is used by the parser to resolve identifiers and help direct
3337 /// parsing. When the identifier cannot be found, this routine will attempt
3338 /// to correct the typo and classify based on the resulting name.
3339 ///
3340 /// \param S The scope in which we're performing name lookup.
3341 ///
3342 /// \param SS The nested-name-specifier that precedes the name.
3343 ///
3344 /// \param Name The identifier. If typo correction finds an alternative name,
3345 /// this pointer parameter will be updated accordingly.
3346 ///
3347 /// \param NameLoc The location of the identifier.
3348 ///
3349 /// \param NextToken The token following the identifier. Used to help
3350 /// disambiguate the name.
3351 ///
3352 /// \param CCC The correction callback, if typo correction is desired.
3353 NameClassification ClassifyName(Scope *S, CXXScopeSpec &SS,
3354 IdentifierInfo *&Name, SourceLocation NameLoc,
3355 const Token &NextToken,
3356 CorrectionCandidateCallback *CCC = nullptr);
3357
3358 /// Act on the result of classifying a name as an undeclared (ADL-only)
3359 /// non-type declaration.
3361 SourceLocation NameLoc);
3362 /// Act on the result of classifying a name as an undeclared member of a
3363 /// dependent base class.
3365 IdentifierInfo *Name,
3366 SourceLocation NameLoc,
3367 bool IsAddressOfOperand);
3368 /// Act on the result of classifying a name as a specific non-type
3369 /// declaration.
3372 SourceLocation NameLoc,
3373 const Token &NextToken);
3374 /// Act on the result of classifying a name as an overload set.
3376
3377 /// Describes the detailed kind of a template name. Used in diagnostics.
3384 Concept,
3386 };
3389
3390 /// Determine whether it's plausible that E was intended to be a
3391 /// template-name.
3393 if (!getLangOpts().CPlusPlus || E.isInvalid())
3394 return false;
3395 Dependent = false;
3396 if (auto *DRE = dyn_cast<DeclRefExpr>(E.get()))
3397 return !DRE->hasExplicitTemplateArgs();
3398 if (auto *ME = dyn_cast<MemberExpr>(E.get()))
3399 return !ME->hasExplicitTemplateArgs();
3400 Dependent = true;
3401 if (auto *DSDRE = dyn_cast<DependentScopeDeclRefExpr>(E.get()))
3402 return !DSDRE->hasExplicitTemplateArgs();
3403 if (auto *DSME = dyn_cast<CXXDependentScopeMemberExpr>(E.get()))
3404 return !DSME->hasExplicitTemplateArgs();
3405 // Any additional cases recognized here should also be handled by
3406 // diagnoseExprIntendedAsTemplateName.
3407 return false;
3408 }
3409
3411
3413
3415 MultiTemplateParamsArg TemplateParameterLists);
3416
3417 /// Attempt to fold a variable-sized type to a constant-sized type, returning
3418 /// true if we were successful.
3421 unsigned FailedFoldDiagID);
3422
3423 /// Register the given locally-scoped extern "C" declaration so
3424 /// that it can be found later for redeclarations. We include any extern "C"
3425 /// declaration that is not visible in the translation unit here, not just
3426 /// function-scope declarations.
3428
3429 /// DiagnoseClassNameShadow - Implement C++ [class.mem]p13:
3430 /// If T is the name of a class, then each of the following shall have a
3431 /// name different from T:
3432 /// - every static data member of class T;
3433 /// - every member function of class T
3434 /// - every member of class T that is itself a type;
3435 /// \returns true if the declaration name violates these rules.
3437
3438 /// Diagnose a declaration whose declarator-id has the given
3439 /// nested-name-specifier.
3440 ///
3441 /// \param SS The nested-name-specifier of the declarator-id.
3442 ///
3443 /// \param DC The declaration context to which the nested-name-specifier
3444 /// resolves.
3445 ///
3446 /// \param Name The name of the entity being declared.
3447 ///
3448 /// \param Loc The location of the name of the entity being declared.
3449 ///
3450 /// \param IsMemberSpecialization Whether we are declaring a member
3451 /// specialization.
3452 ///
3453 /// \param TemplateId The template-id, if any.
3454 ///
3455 /// \returns true if we cannot safely recover from this error, false
3456 /// otherwise.
3459 TemplateIdAnnotation *TemplateId,
3460 bool IsMemberSpecialization);
3461
3463
3464 bool checkConstantPointerAuthKey(Expr *keyExpr, unsigned &key);
3465
3466 /// Diagnose function specifiers on a declaration of an identifier that
3467 /// does not identify a function.
3468 void DiagnoseFunctionSpecifiers(const DeclSpec &DS);
3469
3470 /// Return the declaration shadowed by the given typedef \p D, or null
3471 /// if it doesn't shadow any declaration or shadowing warnings are disabled.
3473 const LookupResult &R);
3474
3475 /// Return the declaration shadowed by the given variable \p D, or null
3476 /// if it doesn't shadow any declaration or shadowing warnings are disabled.
3478
3479 /// Return the declaration shadowed by the given variable \p D, or null
3480 /// if it doesn't shadow any declaration or shadowing warnings are disabled.
3482 const LookupResult &R);
3483 /// Diagnose variable or built-in function shadowing. Implements
3484 /// -Wshadow.
3485 ///
3486 /// This method is called whenever a VarDecl is added to a "useful"
3487 /// scope.
3488 ///
3489 /// \param ShadowedDecl the declaration that is shadowed by the given variable
3490 /// \param R the lookup of the name
3491 void CheckShadow(NamedDecl *D, NamedDecl *ShadowedDecl,
3492 const LookupResult &R);
3493
3494 /// Check -Wshadow without the advantage of a previous lookup.
3495 void CheckShadow(Scope *S, VarDecl *D);
3496
3497 /// Warn if 'E', which is an expression that is about to be modified, refers
3498 /// to a shadowing declaration.
3500
3501 /// Diagnose shadowing for variables shadowed in the lambda record \p LambdaRD
3502 /// when these variables are captured by the lambda.
3504
3505 void handleTagNumbering(const TagDecl *Tag, Scope *TagScope);
3506 void setTagNameForLinkagePurposes(TagDecl *TagFromDeclSpec,
3507 TypedefNameDecl *NewTD);
3510 TypeSourceInfo *TInfo,
3512
3513 /// ActOnTypedefNameDecl - Perform semantic checking for a declaration which
3514 /// declares a typedef-name, either using the 'typedef' type specifier or via
3515 /// a C++0x [dcl.typedef]p2 alias-declaration: 'using T = A;'.
3517 LookupResult &Previous, bool &Redeclaration);
3519 TypeSourceInfo *TInfo,
3521 MultiTemplateParamsArg TemplateParamLists,
3522 bool &AddToScope,
3524
3525 /// Perform semantic checking on a newly-created variable
3526 /// declaration.
3527 ///
3528 /// This routine performs all of the type-checking required for a
3529 /// variable declaration once it has been built. It is used both to
3530 /// check variables after they have been parsed and their declarators
3531 /// have been translated into a declaration, and to check variables
3532 /// that have been instantiated from a template.
3533 ///
3534 /// Sets NewVD->isInvalidDecl() if an error was encountered.
3535 ///
3536 /// Returns true if the variable declaration is a redeclaration.
3537 bool CheckVariableDeclaration(VarDecl *NewVD, LookupResult &Previous);
3538 void CheckVariableDeclarationType(VarDecl *NewVD);
3539 void CheckCompleteVariableDeclaration(VarDecl *VD);
3540
3541 NamedDecl *ActOnFunctionDeclarator(Scope *S, Declarator &D, DeclContext *DC,
3542 TypeSourceInfo *TInfo,
3543 LookupResult &Previous,
3544 MultiTemplateParamsArg TemplateParamLists,
3545 bool &AddToScope);
3546
3547 /// AddOverriddenMethods - See if a method overrides any in the base classes,
3548 /// and if so, check that it's a valid override and remember it.
3549 bool AddOverriddenMethods(CXXRecordDecl *DC, CXXMethodDecl *MD);
3550
3551 /// Perform semantic checking of a new function declaration.
3552 ///
3553 /// Performs semantic analysis of the new function declaration
3554 /// NewFD. This routine performs all semantic checking that does not
3555 /// require the actual declarator involved in the declaration, and is
3556 /// used both for the declaration of functions as they are parsed
3557 /// (called via ActOnDeclarator) and for the declaration of functions
3558 /// that have been instantiated via C++ template instantiation (called
3559 /// via InstantiateDecl).
3560 ///
3561 /// \param IsMemberSpecialization whether this new function declaration is
3562 /// a member specialization (that replaces any definition provided by the
3563 /// previous declaration).
3564 ///
3565 /// This sets NewFD->isInvalidDecl() to true if there was an error.
3566 ///
3567 /// \returns true if the function declaration is a redeclaration.
3568 bool CheckFunctionDeclaration(Scope *S, FunctionDecl *NewFD,
3569 LookupResult &Previous,
3570 bool IsMemberSpecialization, bool DeclIsDefn);
3571
3572 /// Checks if the new declaration declared in dependent context must be
3573 /// put in the same redeclaration chain as the specified declaration.
3574 ///
3575 /// \param D Declaration that is checked.
3576 /// \param PrevDecl Previous declaration found with proper lookup method for
3577 /// the same declaration name.
3578 /// \returns True if D must be added to the redeclaration chain which PrevDecl
3579 /// belongs to.
3580 bool shouldLinkDependentDeclWithPrevious(Decl *D, Decl *OldDecl);
3581
3582 /// Determines if we can perform a correct type check for \p D as a
3583 /// redeclaration of \p PrevDecl. If not, we can generally still perform a
3584 /// best-effort check.
3585 ///
3586 /// \param NewD The new declaration.
3587 /// \param OldD The old declaration.
3588 /// \param NewT The portion of the type of the new declaration to check.
3589 /// \param OldT The portion of the type of the old declaration to check.
3590 bool canFullyTypeCheckRedeclaration(ValueDecl *NewD, ValueDecl *OldD,
3591 QualType NewT, QualType OldT);
3592 void CheckMain(FunctionDecl *FD, const DeclSpec &D);
3593 void CheckMSVCRTEntryPoint(FunctionDecl *FD);
3594
3595 /// Returns an implicit CodeSegAttr if a __declspec(code_seg) is found on a
3596 /// containing class. Otherwise it will return implicit SectionAttr if the
3597 /// function is a definition and there is an active value on CodeSegStack
3598 /// (from the current #pragma code-seg value).
3599 ///
3600 /// \param FD Function being declared.
3601 /// \param IsDefinition Whether it is a definition or just a declaration.
3602 /// \returns A CodeSegAttr or SectionAttr to apply to the function or
3603 /// nullptr if no attribute should be added.
3604 Attr *getImplicitCodeSegOrSectionAttrForFunction(const FunctionDecl *FD,
3605 bool IsDefinition);
3606
3607 /// Common checks for a parameter-declaration that should apply to both
3608 /// function parameters and non-type template parameters.
3609 void CheckFunctionOrTemplateParamDeclarator(Scope *S, Declarator &D);
3610
3611 /// ActOnParamDeclarator - Called from Parser::ParseFunctionDeclarator()
3612 /// to introduce parameters into function prototype scope.
3613 Decl *ActOnParamDeclarator(Scope *S, Declarator &D,
3614 SourceLocation ExplicitThisLoc = {});
3615
3616 /// Synthesizes a variable for a parameter arising from a
3617 /// typedef.
3618 ParmVarDecl *BuildParmVarDeclForTypedef(DeclContext *DC, SourceLocation Loc,
3619 QualType T);
3620 ParmVarDecl *CheckParameter(DeclContext *DC, SourceLocation StartLoc,
3621 SourceLocation NameLoc,
3622 const IdentifierInfo *Name, QualType T,
3623 TypeSourceInfo *TSInfo, StorageClass SC);
3624
3625 // Contexts where using non-trivial C union types can be disallowed. This is
3626 // passed to err_non_trivial_c_union_in_invalid_context.
3628 // Function parameter.
3630 // Function return.
3632 // Default-initialized object.
3634 // Variable with automatic storage duration.
3636 // Initializer expression that might copy from another object.
3638 // Assignment.
3640 // Compound literal.
3642 // Block capture.
3644 // lvalue-to-rvalue conversion of volatile type.
3646 };
3647
3648 /// Emit diagnostics if the initializer or any of its explicit or
3649 /// implicitly-generated subexpressions require copying or
3650 /// default-initializing a type that is or contains a C union type that is
3651 /// non-trivial to copy or default-initialize.
3653
3654 // These flags are passed to checkNonTrivialCUnion.
3659 };
3660
3661 /// Emit diagnostics if a non-trivial C union type or a struct that contains
3662 /// a non-trivial C union is used in an invalid context.
3664 NonTrivialCUnionContext UseContext,
3665 unsigned NonTrivialKind);
3666
3667 /// AddInitializerToDecl - Adds the initializer Init to the
3668 /// declaration dcl. If DirectInit is true, this is C++ direct
3669 /// initialization rather than copy initialization.
3670 void AddInitializerToDecl(Decl *dcl, Expr *init, bool DirectInit);
3671 void ActOnUninitializedDecl(Decl *dcl);
3672
3673 /// ActOnInitializerError - Given that there was an error parsing an
3674 /// initializer for the given declaration, try to at least re-establish
3675 /// invariants such as whether a variable's type is either dependent or
3676 /// complete.
3677 void ActOnInitializerError(Decl *Dcl);
3678
3681 IdentifierInfo *Ident,
3682 ParsedAttributes &Attrs);
3683
3684 /// Check if VD needs to be dllexport/dllimport due to being in a
3685 /// dllexport/import function.
3688
3689 /// FinalizeDeclaration - called by ParseDeclarationAfterDeclarator to perform
3690 /// any semantic actions necessary after any initializer has been attached.
3691 void FinalizeDeclaration(Decl *D);
3693 ArrayRef<Decl *> Group);
3694
3695 /// BuildDeclaratorGroup - convert a list of declarations into a declaration
3696 /// group, performing any necessary semantic checking.
3698
3699 /// Should be called on all declarations that might have attached
3700 /// documentation comments.
3703
3704 enum class FnBodyKind {
3705 /// C++26 [dcl.fct.def.general]p1
3706 /// function-body:
3707 /// ctor-initializer[opt] compound-statement
3708 /// function-try-block
3709 Other,
3710 /// = default ;
3711 Default,
3712 /// deleted-function-body
3713 ///
3714 /// deleted-function-body:
3715 /// = delete ;
3716 /// = delete ( unevaluated-string ) ;
3717 Delete
3718 };
3719
3721 SourceLocation LocAfterDecls);
3723 FunctionDecl *FD, const FunctionDecl *EffectiveDefinition = nullptr,
3724 SkipBodyInfo *SkipBody = nullptr);
3726 MultiTemplateParamsArg TemplateParamLists,
3727 SkipBodyInfo *SkipBody = nullptr,
3728 FnBodyKind BodyKind = FnBodyKind::Other);
3730 SkipBodyInfo *SkipBody = nullptr,
3731 FnBodyKind BodyKind = FnBodyKind::Other);
3733
3734 /// Determine whether we can delay parsing the body of a function or
3735 /// function template until it is used, assuming we don't care about emitting
3736 /// code for that function.
3737 ///
3738 /// This will be \c false if we may need the body of the function in the
3739 /// middle of parsing an expression (where it's impractical to switch to
3740 /// parsing a different function), for instance, if it's constexpr in C++11
3741 /// or has an 'auto' return type in C++14. These cases are essentially bugs.
3742 bool canDelayFunctionBody(const Declarator &D);
3743
3744 /// Determine whether we can skip parsing the body of a function
3745 /// definition, assuming we don't care about analyzing its body or emitting
3746 /// code for that function.
3747 ///
3748 /// This will be \c false only if we may need the body of the function in
3749 /// order to parse the rest of the program (for instance, if it is
3750 /// \c constexpr in C++11 or has an 'auto' return type in C++14).
3751 bool canSkipFunctionBody(Decl *D);
3752
3753 /// Given the set of return statements within a function body,
3754 /// compute the variables that are subject to the named return value
3755 /// optimization.
3756 ///
3757 /// Each of the variables that is subject to the named return value
3758 /// optimization will be marked as NRVO variables in the AST, and any
3759 /// return statement that has a marked NRVO variable as its NRVO candidate can
3760 /// use the named return value optimization.
3761 ///
3762 /// This function applies a very simplistic algorithm for NRVO: if every
3763 /// return statement in the scope of a variable has the same NRVO candidate,
3764 /// that candidate is an NRVO variable.
3767 Decl *ActOnFinishFunctionBody(Decl *Decl, Stmt *Body, bool IsInstantiation);
3770
3771 /// ActOnFinishDelayedAttribute - Invoked when we have finished parsing an
3772 /// attribute for which parsing is delayed.
3774
3775 /// Diagnose any unused parameters in the given sequence of
3776 /// ParmVarDecl pointers.
3778
3779 /// Diagnose whether the size of parameters or return value of a
3780 /// function or obj-c method definition is pass-by-value and larger than a
3781 /// specified threshold.
3782 void
3784 QualType ReturnTy, NamedDecl *D);
3785
3787 SourceLocation RParenLoc);
3788
3791
3793
3794 /// ParsedFreeStandingDeclSpec - This method is invoked when a declspec with
3795 /// no declarator (e.g. "struct foo;") is parsed.
3797 const ParsedAttributesView &DeclAttrs,
3798 RecordDecl *&AnonRecord);
3799
3800 /// ParsedFreeStandingDeclSpec - This method is invoked when a declspec with
3801 /// no declarator (e.g. "struct foo;") is parsed. It also accepts template
3802 /// parameters to cope with template friend declarations.
3804 const ParsedAttributesView &DeclAttrs,
3805 MultiTemplateParamsArg TemplateParams,
3806 bool IsExplicitInstantiation,
3807 RecordDecl *&AnonRecord,
3808 SourceLocation EllipsisLoc = {});
3809
3810 /// BuildAnonymousStructOrUnion - Handle the declaration of an
3811 /// anonymous structure or union. Anonymous unions are a C++ feature
3812 /// (C++ [class.union]) and a C11 feature; anonymous structures
3813 /// are a C11 feature and GNU C++ extension.
3814 Decl *BuildAnonymousStructOrUnion(Scope *S, DeclSpec &DS, AccessSpecifier AS,
3815 RecordDecl *Record,
3816 const PrintingPolicy &Policy);
3817
3818 /// Called once it is known whether
3819 /// a tag declaration is an anonymous union or struct.
3821
3822 /// Emit diagnostic warnings for placeholder members.
3823 /// We can only do that after the class is fully constructed,
3824 /// as anonymous union/structs can insert placeholders
3825 /// in their parent scope (which might be a Record).
3827
3828 /// BuildMicrosoftCAnonymousStruct - Handle the declaration of an
3829 /// Microsoft C anonymous structure.
3830 /// Ref: http://msdn.microsoft.com/en-us/library/z2cx9y4f.aspx
3831 /// Example:
3832 ///
3833 /// struct A { int a; };
3834 /// struct B { struct A; int b; };
3835 ///
3836 /// void foo() {
3837 /// B var;
3838 /// var.a = 3;
3839 /// }
3840 Decl *BuildMicrosoftCAnonymousStruct(Scope *S, DeclSpec &DS,
3841 RecordDecl *Record);
3842
3843 /// Common ways to introduce type names without a tag for use in diagnostics.
3844 /// Keep in sync with err_tag_reference_non_tag.
3855 };
3856
3857 /// Given a non-tag type declaration, returns an enum useful for indicating
3858 /// what kind of non-tag type this is.
3860
3861 /// Determine whether a tag with a given kind is acceptable
3862 /// as a redeclaration of the given tag declaration.
3863 ///
3864 /// \returns true if the new tag kind is acceptable, false otherwise.
3866 bool isDefinition, SourceLocation NewTagLoc,
3867 const IdentifierInfo *Name);
3868
3870 // Not parsing a type within __builtin_offsetof.
3872 // Parsing a type within __builtin_offsetof.
3874 // Parsing a type within macro "offsetof", defined in __buitin_offsetof
3875 // To improve our diagnostic message.
3877 };
3878
3879 /// This is invoked when we see 'struct foo' or 'struct {'. In the
3880 /// former case, Name will be non-null. In the later case, Name will be null.
3881 /// TagSpec indicates what kind of tag this is. TUK indicates whether this is
3882 /// a reference/declaration/definition of a tag.
3883 ///
3884 /// \param IsTypeSpecifier \c true if this is a type-specifier (or
3885 /// trailing-type-specifier) other than one in an alias-declaration.
3886 ///
3887 /// \param SkipBody If non-null, will be set to indicate if the caller should
3888 /// skip the definition of this tag and treat it as if it were a declaration.
3889 DeclResult ActOnTag(Scope *S, unsigned TagSpec, TagUseKind TUK,
3890 SourceLocation KWLoc, CXXScopeSpec &SS,
3891 IdentifierInfo *Name, SourceLocation NameLoc,
3893 SourceLocation ModulePrivateLoc,
3894 MultiTemplateParamsArg TemplateParameterLists,
3895 bool &OwnedDecl, bool &IsDependent,
3896 SourceLocation ScopedEnumKWLoc,
3897 bool ScopedEnumUsesClassTag, TypeResult UnderlyingType,
3898 bool IsTypeSpecifier, bool IsTemplateParamOrArg,
3899 OffsetOfKind OOK, SkipBodyInfo *SkipBody = nullptr);
3900
3901 /// ActOnField - Each field of a C struct/union is passed into this in order
3902 /// to create a FieldDecl object for it.
3903 Decl *ActOnField(Scope *S, Decl *TagD, SourceLocation DeclStart,
3904 Declarator &D, Expr *BitfieldWidth);
3905
3906 /// HandleField - Analyze a field of a C struct or a C++ data member.
3907 FieldDecl *HandleField(Scope *S, RecordDecl *TagD, SourceLocation DeclStart,
3908 Declarator &D, Expr *BitfieldWidth,
3909 InClassInitStyle InitStyle, AccessSpecifier AS);
3910
3911 /// Build a new FieldDecl and check its well-formedness.
3912 ///
3913 /// This routine builds a new FieldDecl given the fields name, type,
3914 /// record, etc. \p PrevDecl should refer to any previous declaration
3915 /// with the same name and in the same scope as the field to be
3916 /// created.
3917 ///
3918 /// \returns a new FieldDecl.
3919 ///
3920 /// \todo The Declarator argument is a hack. It will be removed once
3923 SourceLocation Loc, bool Mutable,
3924 Expr *BitfieldWidth, InClassInitStyle InitStyle,
3926 NamedDecl *PrevDecl, Declarator *D = nullptr);
3927
3929
3930 /// ActOnLastBitfield - This routine handles synthesized bitfields rules for
3931 /// class and class extensions. For every class \@interface and class
3932 /// extension \@interface, if the last ivar is a bitfield of any type,
3933 /// then add an implicit `char :0` ivar to the end of that interface.
3934 void ActOnLastBitfield(SourceLocation DeclStart,
3935 SmallVectorImpl<Decl *> &AllIvarDecls);
3936
3937 // This is used for both record definitions and ObjC interface declarations.
3938 void ActOnFields(Scope *S, SourceLocation RecLoc, Decl *TagDecl,
3939 ArrayRef<Decl *> Fields, SourceLocation LBrac,
3940 SourceLocation RBrac, const ParsedAttributesView &AttrList);
3941
3942 /// ActOnTagStartDefinition - Invoked when we have entered the
3943 /// scope of a tag's definition (e.g., for an enumeration, class,
3944 /// struct, or union).
3946
3947 /// Perform ODR-like check for C/ObjC when merging tag types from modules.
3948 /// Differently from C++, actually parse the body and reject / error out
3949 /// in case of a structural mismatch.
3950 bool ActOnDuplicateDefinition(Decl *Prev, SkipBodyInfo &SkipBody);
3951
3953
3954 /// Invoked when we enter a tag definition that we're skipping.
3956
3957 /// ActOnStartCXXMemberDeclarations - Invoked when we have parsed a
3958 /// C++ record definition's base-specifiers clause and are starting its
3959 /// member declarations.
3961 SourceLocation FinalLoc,
3962 bool IsFinalSpelledSealed,
3963 bool IsAbstract,
3964 SourceLocation LBraceLoc);
3965
3966 /// ActOnTagFinishDefinition - Invoked once we have finished parsing
3967 /// the definition of a tag (enumeration, class, struct, or union).
3969 SourceRange BraceRange);
3970
3972
3973 /// ActOnTagDefinitionError - Invoked when there was an unrecoverable
3974 /// error parsing the definition of a tag.
3976
3978 EnumConstantDecl *LastEnumConst,
3980 Expr *val);
3981
3982 /// Check that this is a valid underlying type for an enum declaration.
3984
3985 /// Check whether this is a valid redeclaration of a previous enumeration.
3986 /// \return true if the redeclaration was invalid.
3987 bool CheckEnumRedeclaration(SourceLocation EnumLoc, bool IsScoped,
3988 QualType EnumUnderlyingTy, bool IsFixed,
3989 const EnumDecl *Prev);
3990
3991 /// Determine whether the body of an anonymous enumeration should be skipped.
3992 /// \param II The name of the first enumerator.
3994 SourceLocation IILoc);
3995
3996 Decl *ActOnEnumConstant(Scope *S, Decl *EnumDecl, Decl *LastEnumConstant,
3998 const ParsedAttributesView &Attrs,
3999 SourceLocation EqualLoc, Expr *Val);
4000 void ActOnEnumBody(SourceLocation EnumLoc, SourceRange BraceRange,
4001 Decl *EnumDecl, ArrayRef<Decl *> Elements, Scope *S,
4002 const ParsedAttributesView &Attr);
4003
4004 /// Set the current declaration context until it gets popped.
4005 void PushDeclContext(Scope *S, DeclContext *DC);
4006 void PopDeclContext();
4007
4008 /// EnterDeclaratorContext - Used when we must lookup names in the context
4009 /// of a declarator's nested name specifier.
4012
4013 /// Enter a template parameter scope, after it's been associated with a
4014 /// particular DeclContext. Causes lookup within the scope to chain through
4015 /// enclosing contexts in the correct order.
4017
4018 /// Push the parameters of D, which must be a function, into scope.
4021
4022 /// Add this decl to the scope shadowed decl chains.
4023 void PushOnScopeChains(NamedDecl *D, Scope *S, bool AddToContext = true);
4024
4025 /// isDeclInScope - If 'Ctx' is a function/method, isDeclInScope returns true
4026 /// if 'D' is in Scope 'S', otherwise 'S' is ignored and isDeclInScope returns
4027 /// true if 'D' belongs to the given declaration context.
4028 ///
4029 /// \param AllowInlineNamespace If \c true, allow the declaration to be in the
4030 /// enclosing namespace set of the context, rather than contained
4031 /// directly within it.
4032 bool isDeclInScope(NamedDecl *D, DeclContext *Ctx, Scope *S = nullptr,
4033 bool AllowInlineNamespace = false) const;
4034
4035 /// Finds the scope corresponding to the given decl context, if it
4036 /// happens to be an enclosing scope. Otherwise return NULL.
4038
4039 /// Subroutines of ActOnDeclarator().
4041 TypeSourceInfo *TInfo);
4042 bool isIncompatibleTypedef(const TypeDecl *Old, TypedefNameDecl *New);
4043
4044 /// Describes the kind of merge to perform for availability
4045 /// attributes (including "deprecated", "unavailable", and "availability").
4047 /// Don't merge availability attributes at all.
4049 /// Merge availability attributes for a redeclaration, which requires
4050 /// an exact match.
4052 /// Merge availability attributes for an override, which requires
4053 /// an exact match or a weakening of constraints.
4055 /// Merge availability attributes for an implementation of
4056 /// a protocol requirement.
4058 /// Merge availability attributes for an implementation of
4059 /// an optional protocol requirement.
4062
4063 /// mergeDeclAttributes - Copy attributes from the Old decl to the New one.
4064 void mergeDeclAttributes(NamedDecl *New, Decl *Old,
4066
4067 /// MergeTypedefNameDecl - We just parsed a typedef 'New' which has the
4068 /// same name and scope as a previous declaration 'Old'. Figure out
4069 /// how to resolve this situation, merging decls or emitting
4070 /// diagnostics as appropriate. If there was an error, set New to be invalid.
4072 LookupResult &OldDecls);
4073
4074 /// MergeFunctionDecl - We just parsed a function 'New' from
4075 /// declarator D which has the same name and scope as a previous
4076 /// declaration 'Old'. Figure out how to resolve this situation,
4077 /// merging decls or emitting diagnostics as appropriate.
4078 ///
4079 /// In C++, New and Old must be declarations that are not
4080 /// overloaded. Use IsOverload to determine whether New and Old are
4081 /// overloaded, and to select the Old declaration that New should be
4082 /// merged with.
4083 ///
4084 /// Returns true if there was an error, false otherwise.
4085 bool MergeFunctionDecl(FunctionDecl *New, NamedDecl *&Old, Scope *S,
4086 bool MergeTypeWithOld, bool NewDeclIsDefn);
4087
4088 /// Completes the merge of two function declarations that are
4089 /// known to be compatible.
4090 ///
4091 /// This routine handles the merging of attributes and other
4092 /// properties of function declarations from the old declaration to
4093 /// the new declaration, once we know that New is in fact a
4094 /// redeclaration of Old.
4095 ///
4096 /// \returns false
4098 Scope *S, bool MergeTypeWithOld);
4100
4101 /// MergeVarDecl - We just parsed a variable 'New' which has the same name
4102 /// and scope as a previous declaration 'Old'. Figure out how to resolve this
4103 /// situation, merging decls or emitting diagnostics as appropriate.
4104 ///
4105 /// Tentative definition rules (C99 6.9.2p2) are checked by
4106 /// FinalizeDeclaratorGroup. Unfortunately, we can't analyze tentative
4107 /// definitions here, since the initializer hasn't been attached.
4109
4110 /// MergeVarDeclTypes - We parsed a variable 'New' which has the same name and
4111 /// scope as a previous declaration 'Old'. Figure out how to merge their
4112 /// types, emitting diagnostics as appropriate.
4113 ///
4114 /// Declarations using the auto type specifier (C++ [decl.spec.auto]) call
4115 /// back to here in AddInitializerToDecl. We can't check them before the
4116 /// initializer is attached.
4117 void MergeVarDeclTypes(VarDecl *New, VarDecl *Old, bool MergeTypeWithOld);
4118
4119 /// We've just determined that \p Old and \p New both appear to be definitions
4120 /// of the same variable. Either diagnose or fix the problem.
4121 bool checkVarDeclRedefinition(VarDecl *OldDefn, VarDecl *NewDefn);
4122 void notePreviousDefinition(const NamedDecl *Old, SourceLocation New);
4123
4124 /// Filters out lookup results that don't fall within the given scope
4125 /// as determined by isDeclInScope.
4127 bool ConsiderLinkage, bool AllowInlineNamespace);
4128
4129 /// We've determined that \p New is a redeclaration of \p Old. Check that they
4130 /// have compatible owning modules.
4132
4133 /// [module.interface]p6:
4134 /// A redeclaration of an entity X is implicitly exported if X was introduced
4135 /// by an exported declaration; otherwise it shall not be exported.
4137
4138 /// A wrapper function for checking the semantic restrictions of
4139 /// a redeclaration within a module.
4141
4142 /// Check the redefinition in C++20 Modules.
4143 ///
4144 /// [basic.def.odr]p14:
4145 /// For any definable item D with definitions in multiple translation units,
4146 /// - if D is a non-inline non-templated function or variable, or
4147 /// - if the definitions in different translation units do not satisfy the
4148 /// following requirements,
4149 /// the program is ill-formed; a diagnostic is required only if the
4150 /// definable item is attached to a named module and a prior definition is
4151 /// reachable at the point where a later definition occurs.
4152 /// - Each such definition shall not be attached to a named module
4153 /// ([module.unit]).
4154 /// - Each such definition shall consist of the same sequence of tokens, ...
4155 /// ...
4156 ///
4157 /// Return true if the redefinition is not allowed. Return false otherwise.
4158 bool IsRedefinitionInModule(const NamedDecl *New, const NamedDecl *Old) const;
4159
4161
4162 /// If it's a file scoped decl that must warn if not used, keep track
4163 /// of it.
4165
4166 typedef llvm::function_ref<void(SourceLocation Loc, PartialDiagnostic PD)>
4168
4171 DiagReceiverTy DiagReceiver);
4172 void DiagnoseUnusedDecl(const NamedDecl *ND);
4173
4174 /// DiagnoseUnusedDecl - Emit warnings about declarations that are not used
4175 /// unless they are marked attr(unused).
4176 void DiagnoseUnusedDecl(const NamedDecl *ND, DiagReceiverTy DiagReceiver);
4177
4178 /// If VD is set but not otherwise used, diagnose, for a parameter or a
4179 /// variable.
4180 void DiagnoseUnusedButSetDecl(const VarDecl *VD, DiagReceiverTy DiagReceiver);
4181
4182 /// getNonFieldDeclScope - Retrieves the innermost scope, starting
4183 /// from S, where a non-field would be declared. This routine copes
4184 /// with the difference between C and C++ scoping rules in structs and
4185 /// unions. For example, the following code is well-formed in C but
4186 /// ill-formed in C++:
4187 /// @code
4188 /// struct S6 {
4189 /// enum { BAR } e;
4190 /// };
4191 ///
4192 /// void test_S6() {
4193 /// struct S6 a;
4194 /// a.e = BAR;
4195 /// }
4196 /// @endcode
4197 /// For the declaration of BAR, this routine will return a different
4198 /// scope. The scope S will be the scope of the unnamed enumeration
4199 /// within S6. In C++, this routine will return the scope associated
4200 /// with S6, because the enumeration's scope is a transparent
4201 /// context but structures can contain non-field names. In C, this
4202 /// routine will return the translation unit scope, since the
4203 /// enumeration's scope is a transparent context and structures cannot
4204 /// contain non-field names.
4206
4209
4210 /// LazilyCreateBuiltin - The specified Builtin-ID was first used at
4211 /// file scope. lazily create a decl for it. ForRedeclaration is true
4212 /// if we're creating this built-in in anticipation of redeclaring the
4213 /// built-in.
4215 bool ForRedeclaration, SourceLocation Loc);
4216
4217 /// Get the outermost AttributedType node that sets a calling convention.
4218 /// Valid types should not have multiple attributes with different CCs.
4220
4221 /// GetNameForDeclarator - Determine the full declaration name for the
4222 /// given Declarator.
4224
4225 /// Retrieves the declaration name from a parsed unqualified-id.
4227
4228 /// ParsingInitForAutoVars - a set of declarations with auto types for which
4229 /// we are currently parsing the initializer.
4231
4232 /// Look for a locally scoped extern "C" declaration by the given name.
4234
4236
4237 /// Adjust the \c DeclContext for a function or variable that might be a
4238 /// function-local external declaration.
4240
4242
4243 /// Checks if the variant/multiversion functions are compatible.
4245 const FunctionDecl *OldFD, const FunctionDecl *NewFD,
4246 const PartialDiagnostic &NoProtoDiagID,
4247 const PartialDiagnosticAt &NoteCausedDiagIDAt,
4248 const PartialDiagnosticAt &NoSupportDiagIDAt,
4249 const PartialDiagnosticAt &DiffDiagIDAt, bool TemplatesSupported,
4250 bool ConstexprSupported, bool CLinkageMayDiffer);
4251
4252 /// type checking declaration initializers (C99 6.7.8)
4254 Expr *Init, unsigned DiagID = diag::err_init_element_not_constant);
4255
4259 Expr *Init);
4260
4262 Expr *Init);
4263
4265
4266 // Heuristically tells if the function is `get_return_object` member of a
4267 // coroutine promise_type by matching the function name.
4268 static bool CanBeGetReturnObject(const FunctionDecl *FD);
4269 static bool CanBeGetReturnTypeOnAllocFailure(const FunctionDecl *FD);
4270
4271 /// ImplicitlyDefineFunction - An undeclared identifier was used in a function
4272 /// call, forming a call to an implicitly defined function (per C99 6.5.1p2).
4274 Scope *S);
4275
4276 /// If this function is a C++ replaceable global allocation function
4277 /// (C++2a [basic.stc.dynamic.allocation], C++2a [new.delete]),
4278 /// adds any function attributes that we know a priori based on the standard.
4279 ///
4280 /// We need to check for duplicate attributes both here and where user-written
4281 /// attributes are applied to declarations.
4283 FunctionDecl *FD);
4284
4285 /// Adds any function attributes that we know a priori based on
4286 /// the declaration of this function.
4287 ///
4288 /// These attributes can apply both to implicitly-declared builtins
4289 /// (like __builtin___printf_chk) or to library-declared functions
4290 /// like NSLog or printf.
4291 ///
4292 /// We need to check for duplicate attributes both here and where user-written
4293 /// attributes are applied to declarations.
4295
4296 /// VerifyBitField - verifies that a bit field expression is an ICE and has
4297 /// the correct width, and that the field type is valid.
4298 /// Returns false on success.
4300 const IdentifierInfo *FieldName, QualType FieldTy,
4301 bool IsMsStruct, Expr *BitWidth);
4302
4303 /// IsValueInFlagEnum - Determine if a value is allowed as part of a flag
4304 /// enum. If AllowMask is true, then we also allow the complement of a valid
4305 /// value, to be used as a mask.
4306 bool IsValueInFlagEnum(const EnumDecl *ED, const llvm::APInt &Val,
4307 bool AllowMask) const;
4308
4309 /// ActOnPragmaWeakID - Called on well formed \#pragma weak ident.
4310 void ActOnPragmaWeakID(IdentifierInfo *WeakName, SourceLocation PragmaLoc,
4311 SourceLocation WeakNameLoc);
4312
4313 /// ActOnPragmaRedefineExtname - Called on well formed
4314 /// \#pragma redefine_extname oldname newname.
4316 IdentifierInfo *AliasName,
4317 SourceLocation PragmaLoc,
4318 SourceLocation WeakNameLoc,
4319 SourceLocation AliasNameLoc);
4320
4321 /// ActOnPragmaWeakAlias - Called on well formed \#pragma weak ident = ident.
4322 void ActOnPragmaWeakAlias(IdentifierInfo *WeakName, IdentifierInfo *AliasName,
4323 SourceLocation PragmaLoc,
4324 SourceLocation WeakNameLoc,
4325 SourceLocation AliasNameLoc);
4326
4327 /// Status of the function emission on the CUDA/HIP/OpenMP host/device attrs.
4329 Emitted,
4330 CUDADiscarded, // Discarded due to CUDA/HIP hostness
4331 OMPDiscarded, // Discarded due to OpenMP hostness
4332 TemplateDiscarded, // Discarded due to uninstantiated templates
4333 Unknown,
4334 };
4335 FunctionEmissionStatus getEmissionStatus(const FunctionDecl *Decl,
4336 bool Final = false);
4337
4338 // Whether the callee should be ignored in CUDA/HIP/OpenMP host/device check.
4340
4341private:
4342 /// Function or variable declarations to be checked for whether the deferred
4343 /// diagnostics should be emitted.
4344 llvm::SmallSetVector<Decl *, 4> DeclsToCheckForDeferredDiags;
4345
4346 /// Map of current shadowing declarations to shadowed declarations. Warn if
4347 /// it looks like the user is trying to modify the shadowing declaration.
4348 llvm::DenseMap<const NamedDecl *, const NamedDecl *> ShadowingDecls;
4349
4350 // We need this to handle
4351 //
4352 // typedef struct {
4353 // void *foo() { return 0; }
4354 // } A;
4355 //
4356 // When we see foo we don't know if after the typedef we will get 'A' or '*A'
4357 // for example. If 'A', foo will have external linkage. If we have '*A',
4358 // foo will have no linkage. Since we can't know until we get to the end
4359 // of the typedef, this function finds out if D might have non-external
4360 // linkage. Callers should verify at the end of the TU if it D has external
4361 // linkage or not.
4362 static bool mightHaveNonExternalLinkage(const DeclaratorDecl *FD);
4363
4364 ///@}
4365
4366 //
4367 //
4368 // -------------------------------------------------------------------------
4369 //
4370 //
4371
4372 /// \name Declaration Attribute Handling
4373 /// Implementations are in SemaDeclAttr.cpp
4374 ///@{
4375
4376public:
4377 /// Describes the kind of priority given to an availability attribute.
4378 ///
4379 /// The sum of priorities deteremines the final priority of the attribute.
4380 /// The final priority determines how the attribute will be merged.
4381 /// An attribute with a lower priority will always remove higher priority
4382 /// attributes for the specified platform when it is being applied. An
4383 /// attribute with a higher priority will not be applied if the declaration
4384 /// already has an availability attribute with a lower priority for the
4385 /// specified platform. The final prirority values are not expected to match
4386 /// the values in this enumeration, but instead should be treated as a plain
4387 /// integer value. This enumeration just names the priority weights that are
4388 /// used to calculate that final vaue.
4390 /// The availability attribute was specified explicitly next to the
4391 /// declaration.
4393
4394 /// The availability attribute was applied using '#pragma clang attribute'.
4396
4397 /// The availability attribute for a specific platform was inferred from
4398 /// an availability attribute for another platform.
4401
4402 /// Describes the reason a calling convention specification was ignored, used
4403 /// for diagnostics.
4405 ForThisTarget = 0,
4409 };
4410
4411 /// A helper function to provide Attribute Location for the Attr types
4412 /// AND the ParsedAttr.
4413 template <typename AttrInfo>
4414 static std::enable_if_t<std::is_base_of_v<Attr, AttrInfo>, SourceLocation>
4415 getAttrLoc(const AttrInfo &AL) {
4416 return AL.getLocation();
4417 }
4419
4420 /// If Expr is a valid integer constant, get the value of the integer
4421 /// expression and return success or failure. May output an error.
4422 ///
4423 /// Negative argument is implicitly converted to unsigned, unless
4424 /// \p StrictlyUnsigned is true.
4425 template <typename AttrInfo>
4426 bool checkUInt32Argument(const AttrInfo &AI, const Expr *Expr, uint32_t &Val,
4427 unsigned Idx = UINT_MAX,
4428 bool StrictlyUnsigned = false) {
4429 std::optional<llvm::APSInt> I = llvm::APSInt(32);
4430 if (Expr->isTypeDependent() ||
4432 if (Idx != UINT_MAX)
4433 Diag(getAttrLoc(AI), diag::err_attribute_argument_n_type)
4434 << &AI << Idx << AANT_ArgumentIntegerConstant
4435 << Expr->getSourceRange();
4436 else
4437 Diag(getAttrLoc(AI), diag::err_attribute_argument_type)
4439 return false;
4440 }
4441
4442 if (!I->isIntN(32)) {
4443 Diag(Expr->getExprLoc(), diag::err_ice_too_large)
4444 << toString(*I, 10, false) << 32 << /* Unsigned */ 1;
4445 return false;
4446 }
4447
4448 if (StrictlyUnsigned && I->isSigned() && I->isNegative()) {
4449 Diag(getAttrLoc(AI), diag::err_attribute_requires_positive_integer)
4450 << &AI << /*non-negative*/ 1;
4451 return false;
4452 }
4453
4454 Val = (uint32_t)I->getZExtValue();
4455 return true;
4456 }
4457
4458 /// WeakTopLevelDecl - Translation-unit scoped declarations generated by
4459 /// \#pragma weak during processing of other Decls.
4460 /// I couldn't figure out a clean way to generate these in-line, so
4461 /// we store them here and handle separately -- which is a hack.
4462 /// It would be best to refactor this.
4464
4465 /// WeakTopLevelDeclDecls - access to \#pragma weak-generated Decls
4467
4471
4472 /// ExtVectorDecls - This is a list all the extended vector types. This allows
4473 /// us to associate a raw vector type with one of the ext_vector type names.
4474 /// This is only necessary for issuing pretty diagnostics.
4476
4477 /// Check if the argument \p E is a ASCII string literal. If not emit an error
4478 /// and return false, otherwise set \p Str to the value of the string literal
4479 /// and return true.
4481 const Expr *E, StringRef &Str,
4482 SourceLocation *ArgLocation = nullptr);
4483
4484 /// Check if the argument \p ArgNum of \p Attr is a ASCII string literal.
4485 /// If not emit an error and return false. If the argument is an identifier it
4486 /// will emit an error with a fixit hint and treat it as if it was a string
4487 /// literal.
4488 bool checkStringLiteralArgumentAttr(const ParsedAttr &Attr, unsigned ArgNum,
4489 StringRef &Str,
4490 SourceLocation *ArgLocation = nullptr);
4491
4492 /// Determine if type T is a valid subject for a nonnull and similar
4493 /// attributes. Dependent types are considered valid so they can be checked
4494 /// during instantiation time. By default, we look through references (the
4495 /// behavior used by nonnull), but if the second parameter is true, then we
4496 /// treat a reference type as valid.
4497 bool isValidPointerAttrType(QualType T, bool RefOkay = false);
4498
4499 /// AddAssumeAlignedAttr - Adds an assume_aligned attribute to a particular
4500 /// declaration.
4502 Expr *OE);
4503
4504 /// AddAllocAlignAttr - Adds an alloc_align attribute to a particular
4505 /// declaration.
4507 Expr *ParamExpr);
4508
4509 bool CheckAttrTarget(const ParsedAttr &CurrAttr);
4510 bool CheckAttrNoArgs(const ParsedAttr &CurrAttr);
4511
4512 AvailabilityAttr *mergeAvailabilityAttr(
4513 NamedDecl *D, const AttributeCommonInfo &CI, IdentifierInfo *Platform,
4514 bool Implicit, VersionTuple Introduced, VersionTuple Deprecated,
4515 VersionTuple Obsoleted, bool IsUnavailable, StringRef Message,
4516 bool IsStrict, StringRef Replacement, AvailabilityMergeKind AMK,
4517 int Priority, IdentifierInfo *IIEnvironment);
4518
4519 TypeVisibilityAttr *
4521 TypeVisibilityAttr::VisibilityType Vis);
4522 VisibilityAttr *mergeVisibilityAttr(Decl *D, const AttributeCommonInfo &CI,
4523 VisibilityAttr::VisibilityType Vis);
4524 SectionAttr *mergeSectionAttr(Decl *D, const AttributeCommonInfo &CI,
4525 StringRef Name);
4526
4527 /// Used to implement to perform semantic checking on
4528 /// attribute((section("foo"))) specifiers.
4529 ///
4530 /// In this case, "foo" is passed in to be checked. If the section
4531 /// specifier is invalid, return an Error that indicates the problem.
4532 ///
4533 /// This is a simple quality of implementation feature to catch errors
4534 /// and give good diagnostics in cases when the assembler or code generator
4535 /// would otherwise reject the section specifier.
4536 llvm::Error isValidSectionSpecifier(StringRef Str);
4537 bool checkSectionName(SourceLocation LiteralLoc, StringRef Str);
4538 CodeSegAttr *mergeCodeSegAttr(Decl *D, const AttributeCommonInfo &CI,
4539 StringRef Name);
4540
4541 // Check for things we'd like to warn about. Multiversioning issues are
4542 // handled later in the process, once we know how many exist.
4543 bool checkTargetAttr(SourceLocation LiteralLoc, StringRef Str);
4544
4545 /// Check Target Version attrs
4546 bool checkTargetVersionAttr(SourceLocation Loc, Decl *D, StringRef Str);
4548 SourceLocation LiteralLoc, StringRef Str, const StringLiteral *Literal,
4549 Decl *D, bool &HasDefault, bool &HasCommas, bool &HasNotDefault,
4550 SmallVectorImpl<SmallString<64>> &StringsBuffer);
4551
4552 ErrorAttr *mergeErrorAttr(Decl *D, const AttributeCommonInfo &CI,
4553 StringRef NewUserDiagnostic);
4554 FormatAttr *mergeFormatAttr(Decl *D, const AttributeCommonInfo &CI,
4555 IdentifierInfo *Format, int FormatIdx,
4556 int FirstArg);
4557
4558 /// AddAlignedAttr - Adds an aligned attribute to a particular declaration.
4559 void AddAlignedAttr(Decl *D, const AttributeCommonInfo &CI, Expr *E,
4560 bool IsPackExpansion);
4562 bool IsPackExpansion);
4563
4564 /// AddAlignValueAttr - Adds an align_value attribute to a particular
4565 /// declaration.
4566 void AddAlignValueAttr(Decl *D, const AttributeCommonInfo &CI, Expr *E);
4567
4568 /// CreateAnnotationAttr - Creates an annotation Annot with Args arguments.
4569 Attr *CreateAnnotationAttr(const AttributeCommonInfo &CI, StringRef Annot,
4572
4574 bool BestCase,
4575 MSInheritanceModel SemanticSpelling);
4576
4578
4579 /// AddModeAttr - Adds a mode attribute to a particular declaration.
4580 void AddModeAttr(Decl *D, const AttributeCommonInfo &CI, IdentifierInfo *Name,
4581 bool InInstantiation = false);
4582 AlwaysInlineAttr *mergeAlwaysInlineAttr(Decl *D,
4583 const AttributeCommonInfo &CI,
4584 const IdentifierInfo *Ident);
4585 MinSizeAttr *mergeMinSizeAttr(Decl *D, const AttributeCommonInfo &CI);
4586 OptimizeNoneAttr *mergeOptimizeNoneAttr(Decl *D,
4587 const AttributeCommonInfo &CI);
4588 InternalLinkageAttr *mergeInternalLinkageAttr(Decl *D, const ParsedAttr &AL);
4589 InternalLinkageAttr *mergeInternalLinkageAttr(Decl *D,
4590 const InternalLinkageAttr &AL);
4591
4592 /// Check validaty of calling convention attribute \p attr. If \p FD
4593 /// is not null pointer, use \p FD to determine the CUDA/HIP host/device
4594 /// target. Otherwise, it is specified by \p CFT.
4596 const ParsedAttr &attr, CallingConv &CC, const FunctionDecl *FD = nullptr,
4598
4599 /// Checks a regparm attribute, returning true if it is ill-formed and
4600 /// otherwise setting numParams to the appropriate value.
4601 bool CheckRegparmAttr(const ParsedAttr &attr, unsigned &value);
4602
4603 /// Create an CUDALaunchBoundsAttr attribute.
4604 CUDALaunchBoundsAttr *CreateLaunchBoundsAttr(const AttributeCommonInfo &CI,
4605 Expr *MaxThreads,
4606 Expr *MinBlocks,
4607 Expr *MaxBlocks);
4608
4609 /// AddLaunchBoundsAttr - Adds a launch_bounds attribute to a particular
4610 /// declaration.
4612 Expr *MaxThreads, Expr *MinBlocks, Expr *MaxBlocks);
4613
4614 enum class RetainOwnershipKind { NS, CF, OS };
4615
4616 UuidAttr *mergeUuidAttr(Decl *D, const AttributeCommonInfo &CI,
4617 StringRef UuidAsWritten, MSGuidDecl *GuidDecl);
4618
4619 BTFDeclTagAttr *mergeBTFDeclTagAttr(Decl *D, const BTFDeclTagAttr &AL);
4620
4621 DLLImportAttr *mergeDLLImportAttr(Decl *D, const AttributeCommonInfo &CI);
4622 DLLExportAttr *mergeDLLExportAttr(Decl *D, const AttributeCommonInfo &CI);
4623 MSInheritanceAttr *mergeMSInheritanceAttr(Decl *D,
4624 const AttributeCommonInfo &CI,
4625 bool BestCase,
4626 MSInheritanceModel Model);
4627
4628 EnforceTCBAttr *mergeEnforceTCBAttr(Decl *D, const EnforceTCBAttr &AL);
4629 EnforceTCBLeafAttr *mergeEnforceTCBLeafAttr(Decl *D,
4630 const EnforceTCBLeafAttr &AL);
4631
4632 /// Helper for delayed processing TransparentUnion or
4633 /// BPFPreserveAccessIndexAttr attribute.
4635 const ParsedAttributesView &AttrList);
4636
4637 // Options for ProcessDeclAttributeList().
4640 : IncludeCXX11Attributes(true), IgnoreTypeAttributes(false) {}
4641
4643 ProcessDeclAttributeOptions Result = *this;
4644 Result.IncludeCXX11Attributes = Val;
4645 return Result;
4646 }
4647
4649 ProcessDeclAttributeOptions Result = *this;
4650 Result.IgnoreTypeAttributes = Val;
4651 return Result;
4652 }
4653
4654 // Should C++11 attributes be processed?
4656
4657 // Should any type attributes encountered be ignored?
4658 // If this option is false, a diagnostic will be emitted for any type
4659 // attributes of a kind that does not "slide" from the declaration to
4660 // the decl-specifier-seq.
4662 };
4663
4664 /// ProcessDeclAttributeList - Apply all the decl attributes in the specified
4665 /// attribute list to the specified decl, ignoring any type attributes.
4667 const ParsedAttributesView &AttrList,
4668 const ProcessDeclAttributeOptions &Options =
4670
4671 /// Annotation attributes are the only attributes allowed after an access
4672 /// specifier.
4674 const ParsedAttributesView &AttrList);
4675
4676 /// checkUnusedDeclAttributes - Given a declarator which is not being
4677 /// used to build a declaration, complain about any decl attributes
4678 /// which might be lying around on it.
4680
4681 /// DeclClonePragmaWeak - clone existing decl (maybe definition),
4682 /// \#pragma weak needs a non-definition decl and source may not have one.
4685
4686 /// DeclApplyPragmaWeak - A declaration (maybe definition) needs \#pragma weak
4687 /// applied to it, possibly with an alias.
4688 void DeclApplyPragmaWeak(Scope *S, NamedDecl *ND, const WeakInfo &W);
4689
4690 void ProcessPragmaWeak(Scope *S, Decl *D);
4691 // Decl attributes - this routine is the top level dispatcher.
4692 void ProcessDeclAttributes(Scope *S, Decl *D, const Declarator &PD);
4693
4695
4696 /// Given a set of delayed diagnostics, re-emit them as if they had
4697 /// been delayed in the current context instead of in the given pool.
4698 /// Essentially, this just moves them to the current pool.
4700
4701 /// Check if IdxExpr is a valid parameter index for a function or
4702 /// instance method D. May output an error.
4703 ///
4704 /// \returns true if IdxExpr is a valid index.
4705 template <typename AttrInfo>
4706 bool checkFunctionOrMethodParameterIndex(const Decl *D, const AttrInfo &AI,
4707 unsigned AttrArgNum,
4708 const Expr *IdxExpr, ParamIdx &Idx,
4709 bool CanIndexImplicitThis = false) {
4711
4712 // In C++ the implicit 'this' function parameter also counts.
4713 // Parameters are counted from one.
4714 bool HP = hasFunctionProto(D);
4715 bool HasImplicitThisParam = isInstanceMethod(D);
4716 bool IV = HP && isFunctionOrMethodVariadic(D);
4717 unsigned NumParams =
4718 (HP ? getFunctionOrMethodNumParams(D) : 0) + HasImplicitThisParam;
4719
4720 std::optional<llvm::APSInt> IdxInt;
4721 if (IdxExpr->isTypeDependent() ||
4722 !(IdxInt = IdxExpr->getIntegerConstantExpr(Context))) {
4723 Diag(getAttrLoc(AI), diag::err_attribute_argument_n_type)
4724 << &AI << AttrArgNum << AANT_ArgumentIntegerConstant
4725 << IdxExpr->getSourceRange();
4726 return false;
4727 }
4728
4729 unsigned IdxSource = IdxInt->getLimitedValue(UINT_MAX);
4730 if (IdxSource < 1 || (!IV && IdxSource > NumParams)) {
4731 Diag(getAttrLoc(AI), diag::err_attribute_argument_out_of_bounds)
4732 << &AI << AttrArgNum << IdxExpr->getSourceRange();
4733 return false;
4734 }
4735 if (HasImplicitThisParam && !CanIndexImplicitThis) {
4736 if (IdxSource == 1) {
4737 Diag(getAttrLoc(AI), diag::err_attribute_invalid_implicit_this_argument)
4738 << &AI << IdxExpr->getSourceRange();
4739 return false;
4740 }
4741 }
4742
4743 Idx = ParamIdx(IdxSource, D);
4744 return true;
4745 }
4746
4747 ///@}
4748
4749 //
4750 //
4751 // -------------------------------------------------------------------------
4752 //
4753 //
4754
4755 /// \name C++ Declarations
4756 /// Implementations are in SemaDeclCXX.cpp
4757 ///@{
4758
4759public:
4761
4762 /// Called before parsing a function declarator belonging to a function
4763 /// declaration.
4765 unsigned TemplateParameterDepth);
4766
4767 /// Called after parsing a function declarator belonging to a function
4768 /// declaration.
4770
4771 // Act on C++ namespaces
4773 SourceLocation NamespaceLoc,
4774 SourceLocation IdentLoc, IdentifierInfo *Ident,
4775 SourceLocation LBrace,
4776 const ParsedAttributesView &AttrList,
4777 UsingDirectiveDecl *&UsingDecl, bool IsNested);
4778
4779 /// ActOnFinishNamespaceDef - This callback is called after a namespace is
4780 /// exited. Decl is the DeclTy returned by ActOnStartNamespaceDef.
4781 void ActOnFinishNamespaceDef(Decl *Dcl, SourceLocation RBrace);
4782
4784
4785 /// Retrieve the special "std" namespace, which may require us to
4786 /// implicitly define the namespace.
4788
4790 EnumDecl *getStdAlignValT() const;
4791
4793 const IdentifierInfo *MemberOrBase);
4794
4796 /// The '<=>' operator was used in an expression and a builtin operator
4797 /// was selected.
4799 /// A defaulted 'operator<=>' needed the comparison category. This
4800 /// typically only applies to 'std::strong_ordering', due to the implicit
4801 /// fallback return value.
4803 };
4804
4805 /// Lookup the specified comparison category types in the standard
4806 /// library, an check the VarDecls possibly returned by the operator<=>
4807 /// builtins for that type.
4808 ///
4809 /// \return The type of the comparison category type corresponding to the
4810 /// specified Kind, or a null type if an error occurs
4814
4815 /// Tests whether Ty is an instance of std::initializer_list and, if
4816 /// it is and Element is not NULL, assigns the element type to Element.
4817 bool isStdInitializerList(QualType Ty, QualType *Element);
4818
4819 /// Looks for the std::initializer_list template and instantiates it
4820 /// with Element, or emits an error if it's not found.
4821 ///
4822 /// \returns The instantiated template, or null on error.
4824
4825 /// Determine whether Ctor is an initializer-list constructor, as
4826 /// defined in [dcl.init.list]p2.
4827 bool isInitListConstructor(const FunctionDecl *Ctor);
4828
4829 Decl *ActOnUsingDirective(Scope *CurScope, SourceLocation UsingLoc,
4830 SourceLocation NamespcLoc, CXXScopeSpec &SS,
4831 SourceLocation IdentLoc,
4832 IdentifierInfo *NamespcName,
4833 const ParsedAttributesView &AttrList);
4834
4836
4837 Decl *ActOnNamespaceAliasDef(Scope *CurScope, SourceLocation NamespaceLoc,
4838 SourceLocation AliasLoc, IdentifierInfo *Alias,
4839 CXXScopeSpec &SS, SourceLocation IdentLoc,
4840 IdentifierInfo *Ident);
4841
4842 /// Remove decls we can't actually see from a lookup being used to declare
4843 /// shadow using decls.
4844 ///
4845 /// \param S - The scope of the potential shadow decl
4846 /// \param Previous - The lookup of a potential shadow decl's name.
4847 void FilterUsingLookup(Scope *S, LookupResult &lookup);
4848
4849 /// Hides a using shadow declaration. This is required by the current
4850 /// using-decl implementation when a resolvable using declaration in a
4851 /// class is followed by a declaration which would hide or override
4852 /// one or more of the using decl's targets; for example:
4853 ///
4854 /// struct Base { void foo(int); };
4855 /// struct Derived : Base {
4856 /// using Base::foo;
4857 /// void foo(int);
4858 /// };
4859 ///
4860 /// The governing language is C++03 [namespace.udecl]p12:
4861 ///
4862 /// When a using-declaration brings names from a base class into a
4863 /// derived class scope, member functions in the derived class
4864 /// override and/or hide member functions with the same name and
4865 /// parameter types in a base class (rather than conflicting).
4866 ///
4867 /// There are two ways to implement this:
4868 /// (1) optimistically create shadow decls when they're not hidden
4869 /// by existing declarations, or
4870 /// (2) don't create any shadow decls (or at least don't make them
4871 /// visible) until we've fully parsed/instantiated the class.
4872 /// The problem with (1) is that we might have to retroactively remove
4873 /// a shadow decl, which requires several O(n) operations because the
4874 /// decl structures are (very reasonably) not designed for removal.
4875 /// (2) avoids this but is very fiddly and phase-dependent.
4876 void HideUsingShadowDecl(Scope *S, UsingShadowDecl *Shadow);
4877
4878 /// Determines whether to create a using shadow decl for a particular
4879 /// decl, given the set of decls existing prior to this using lookup.
4881 const LookupResult &PreviousDecls,
4882 UsingShadowDecl *&PrevShadow);
4883
4884 /// Builds a shadow declaration corresponding to a 'using' declaration.
4887 UsingShadowDecl *PrevDecl);
4888
4889 /// Checks that the given using declaration is not an invalid
4890 /// redeclaration. Note that this is checking only for the using decl
4891 /// itself, not for any ill-formedness among the UsingShadowDecls.
4893 bool HasTypenameKeyword,
4894 const CXXScopeSpec &SS,
4895 SourceLocation NameLoc,
4896 const LookupResult &Previous);
4897
4898 /// Checks that the given nested-name qualifier used in a using decl
4899 /// in the current context is appropriately related to the current
4900 /// scope. If an error is found, diagnoses it and returns true.
4901 /// R is nullptr, if the caller has not (yet) done a lookup, otherwise it's
4902 /// the result of that lookup. UD is likewise nullptr, except when we have an
4903 /// already-populated UsingDecl whose shadow decls contain the same
4904 /// information (i.e. we're instantiating a UsingDecl with non-dependent
4905 /// scope).
4906 bool CheckUsingDeclQualifier(SourceLocation UsingLoc, bool HasTypename,
4907 const CXXScopeSpec &SS,
4908 const DeclarationNameInfo &NameInfo,
4909 SourceLocation NameLoc,
4910 const LookupResult *R = nullptr,
4911 const UsingDecl *UD = nullptr);
4912
4913 /// Builds a using declaration.
4914 ///
4915 /// \param IsInstantiation - Whether this call arises from an
4916 /// instantiation of an unresolved using declaration. We treat
4917 /// the lookup differently for these declarations.
4919 SourceLocation UsingLoc,
4920 bool HasTypenameKeyword,
4921 SourceLocation TypenameLoc, CXXScopeSpec &SS,
4922 DeclarationNameInfo NameInfo,
4923 SourceLocation EllipsisLoc,
4924 const ParsedAttributesView &AttrList,
4925 bool IsInstantiation, bool IsUsingIfExists);
4927 SourceLocation UsingLoc,
4928 SourceLocation EnumLoc,
4929 SourceLocation NameLoc,
4931 NamedDecl *BuildUsingPackDecl(NamedDecl *InstantiatedFrom,
4932 ArrayRef<NamedDecl *> Expansions);
4933
4934 /// Additional checks for a using declaration referring to a constructor name.
4936
4937 /// Given a derived-class using shadow declaration for a constructor and the
4938 /// correspnding base class constructor, find or create the implicit
4939 /// synthesized derived class constructor to use for this initialization.
4942 ConstructorUsingShadowDecl *DerivedShadow);
4943
4945 SourceLocation UsingLoc,
4946 SourceLocation TypenameLoc, CXXScopeSpec &SS,
4947 UnqualifiedId &Name, SourceLocation EllipsisLoc,
4948 const ParsedAttributesView &AttrList);
4950 SourceLocation UsingLoc,
4951 SourceLocation EnumLoc, SourceRange TyLoc,
4952 const IdentifierInfo &II, ParsedType Ty,
4953 CXXScopeSpec *SS = nullptr);
4955 MultiTemplateParamsArg TemplateParams,
4956 SourceLocation UsingLoc, UnqualifiedId &Name,
4957 const ParsedAttributesView &AttrList,
4958 TypeResult Type, Decl *DeclFromDeclSpec);
4959
4960 /// BuildCXXConstructExpr - Creates a complete call to a constructor,
4961 /// including handling of its default argument expressions.
4962 ///
4963 /// \param ConstructKind - a CXXConstructExpr::ConstructionKind
4965 SourceLocation ConstructLoc, QualType DeclInitType, NamedDecl *FoundDecl,
4966 CXXConstructorDecl *Constructor, MultiExprArg Exprs,
4967 bool HadMultipleCandidates, bool IsListInitialization,
4968 bool IsStdInitListInitialization, bool RequiresZeroInit,
4969 CXXConstructionKind ConstructKind, SourceRange ParenRange);
4970
4971 /// Build a CXXConstructExpr whose constructor has already been resolved if
4972 /// it denotes an inherited constructor.
4974 SourceLocation ConstructLoc, QualType DeclInitType,
4975 CXXConstructorDecl *Constructor, bool Elidable, MultiExprArg Exprs,
4976 bool HadMultipleCandidates, bool IsListInitialization,
4977 bool IsStdInitListInitialization, bool RequiresZeroInit,
4978 CXXConstructionKind ConstructKind, SourceRange ParenRange);
4979
4980 // FIXME: Can we remove this and have the above BuildCXXConstructExpr check if
4981 // the constructor can be elidable?
4983 SourceLocation ConstructLoc, QualType DeclInitType, NamedDecl *FoundDecl,
4984 CXXConstructorDecl *Constructor, bool Elidable, MultiExprArg Exprs,
4985 bool HadMultipleCandidates, bool IsListInitialization,
4986 bool IsStdInitListInitialization, bool RequiresZeroInit,
4987 CXXConstructionKind ConstructKind, SourceRange ParenRange);
4988
4990 SourceLocation InitLoc);
4991
4992 /// FinalizeVarWithDestructor - Prepare for calling destructor on the
4993 /// constructed variable.
4994 void FinalizeVarWithDestructor(VarDecl *VD, const RecordType *DeclInitType);
4995
4996 /// Helper class that collects exception specifications for
4997 /// implicitly-declared special member functions.
4999 // Pointer to allow copying
5000 Sema *Self;
5001 // We order exception specifications thus:
5002 // noexcept is the most restrictive, but is only used in C++11.
5003 // throw() comes next.
5004 // Then a throw(collected exceptions)
5005 // Finally no specification, which is expressed as noexcept(false).
5006 // throw(...) is used instead if any called function uses it.
5007 ExceptionSpecificationType ComputedEST;
5008 llvm::SmallPtrSet<CanQualType, 4> ExceptionsSeen;
5009 SmallVector<QualType, 4> Exceptions;
5010
5011 void ClearExceptions() {
5012 ExceptionsSeen.clear();
5013 Exceptions.clear();
5014 }
5015
5016 public:
5018 : Self(&Self), ComputedEST(EST_BasicNoexcept) {
5019 if (!Self.getLangOpts().CPlusPlus11)
5020 ComputedEST = EST_DynamicNone;
5021 }
5022
5023 /// Get the computed exception specification type.
5025 assert(!isComputedNoexcept(ComputedEST) &&
5026 "noexcept(expr) should not be a possible result");
5027 return ComputedEST;
5028 }
5029
5030 /// The number of exceptions in the exception specification.
5031 unsigned size() const { return Exceptions.size(); }
5032
5033 /// The set of exceptions in the exception specification.
5034 const QualType *data() const { return Exceptions.data(); }
5035
5036 /// Integrate another called method into the collected data.
5037 void CalledDecl(SourceLocation CallLoc, const CXXMethodDecl *Method);
5038
5039 /// Integrate an invoked expression into the collected data.
5040 void CalledExpr(Expr *E) { CalledStmt(E); }
5041
5042 /// Integrate an invoked statement into the collected data.
5043 void CalledStmt(Stmt *S);
5044
5045 /// Overwrite an EPI's exception specification with this
5046 /// computed exception specification.
5049 ESI.Type = getExceptionSpecType();
5050 if (ESI.Type == EST_Dynamic) {
5051 ESI.Exceptions = Exceptions;
5052 } else if (ESI.Type == EST_None) {
5053 /// C++11 [except.spec]p14:
5054 /// The exception-specification is noexcept(false) if the set of
5055 /// potential exceptions of the special member function contains "any"
5056 ESI.Type = EST_NoexceptFalse;
5057 ESI.NoexceptExpr =
5058 Self->ActOnCXXBoolLiteral(SourceLocation(), tok::kw_false).get();
5059 }
5060 return ESI;
5061 }
5062 };
5063
5064 /// Evaluate the implicit exception specification for a defaulted
5065 /// special member function.
5067
5068 /// Check the given exception-specification and update the
5069 /// exception specification information with the results.
5070 void checkExceptionSpecification(bool IsTopLevel,
5072 ArrayRef<ParsedType> DynamicExceptions,
5073 ArrayRef<SourceRange> DynamicExceptionRanges,
5074 Expr *NoexceptExpr,
5075 SmallVectorImpl<QualType> &Exceptions,
5077
5078 /// Add an exception-specification to the given member or friend function
5079 /// (or function template). The exception-specification was parsed
5080 /// after the function itself was declared.
5082 Decl *D, ExceptionSpecificationType EST, SourceRange SpecificationRange,
5083 ArrayRef<ParsedType> DynamicExceptions,
5084 ArrayRef<SourceRange> DynamicExceptionRanges, Expr *NoexceptExpr);
5085
5086 class InheritedConstructorInfo;
5087
5088 /// Determine if a special member function should have a deleted
5089 /// definition when it is defaulted.
5091 InheritedConstructorInfo *ICI = nullptr,
5092 bool Diagnose = false);
5093
5094 /// Produce notes explaining why a defaulted function was defined as deleted.
5096
5097 /// Declare the implicit default constructor for the given class.
5098 ///
5099 /// \param ClassDecl The class declaration into which the implicit
5100 /// default constructor will be added.
5101 ///
5102 /// \returns The implicitly-declared default constructor.
5105
5106 /// DefineImplicitDefaultConstructor - Checks for feasibility of
5107 /// defining this constructor as the default constructor.
5109 CXXConstructorDecl *Constructor);
5110
5111 /// Declare the implicit destructor for the given class.
5112 ///
5113 /// \param ClassDecl The class declaration into which the implicit
5114 /// destructor will be added.
5115 ///
5116 /// \returns The implicitly-declared destructor.
5118
5119 /// DefineImplicitDestructor - Checks for feasibility of
5120 /// defining this destructor as the default destructor.
5121 void DefineImplicitDestructor(SourceLocation CurrentLocation,
5123
5124 /// Build an exception spec for destructors that don't have one.
5125 ///
5126 /// C++11 says that user-defined destructors with no exception spec get one
5127 /// that looks as if the destructor was implicitly declared.
5129
5130 /// Define the specified inheriting constructor.
5132 CXXConstructorDecl *Constructor);
5133
5134 /// Declare the implicit copy constructor for the given class.
5135 ///
5136 /// \param ClassDecl The class declaration into which the implicit
5137 /// copy constructor will be added.
5138 ///
5139 /// \returns The implicitly-declared copy constructor.
5141
5142 /// DefineImplicitCopyConstructor - Checks for feasibility of
5143 /// defining this constructor as the copy constructor.
5144 void DefineImplicitCopyConstructor(SourceLocation CurrentLocation,
5145 CXXConstructorDecl *Constructor);
5146
5147 /// Declare the implicit move constructor for the given class.
5148 ///
5149 /// \param ClassDecl The Class declaration into which the implicit
5150 /// move constructor will be added.
5151 ///
5152 /// \returns The implicitly-declared move constructor, or NULL if it wasn't
5153 /// declared.
5155
5156 /// DefineImplicitMoveConstructor - Checks for feasibility of
5157 /// defining this constructor as the move constructor.
5158 void DefineImplicitMoveConstructor(SourceLocation CurrentLocation,
5159 CXXConstructorDecl *Constructor);
5160
5161 /// Declare the implicit copy assignment operator for the given class.
5162 ///
5163 /// \param ClassDecl The class declaration into which the implicit
5164 /// copy assignment operator will be added.
5165 ///
5166 /// \returns The implicitly-declared copy assignment operator.
5168
5169 /// Defines an implicitly-declared copy assignment operator.
5170 void DefineImplicitCopyAssignment(SourceLocation CurrentLocation,
5171 CXXMethodDecl *MethodDecl);
5172
5173 /// Declare the implicit move assignment operator for the given class.
5174 ///
5175 /// \param ClassDecl The Class declaration into which the implicit
5176 /// move assignment operator will be added.
5177 ///
5178 /// \returns The implicitly-declared move assignment operator, or NULL if it
5179 /// wasn't declared.
5181
5182 /// Defines an implicitly-declared move assignment operator.
5183 void DefineImplicitMoveAssignment(SourceLocation CurrentLocation,
5184 CXXMethodDecl *MethodDecl);
5185
5186 /// Check a completed declaration of an implicit special member.
5188
5189 /// Determine whether the given function is an implicitly-deleted
5190 /// special member function.
5192
5193 /// Check whether 'this' shows up in the type of a static member
5194 /// function after the (naturally empty) cv-qualifier-seq would be.
5195 ///
5196 /// \returns true if an error occurred.
5198
5199 /// Whether this' shows up in the exception specification of a static
5200 /// member function.
5202
5203 /// Check whether 'this' shows up in the attributes of the given
5204 /// static member function.
5205 ///
5206 /// \returns true if an error occurred.
5208
5210 FunctionDecl *FD, const sema::FunctionScopeInfo *FSI);
5211
5213
5214 /// Given a constructor and the set of arguments provided for the
5215 /// constructor, convert the arguments and add any required default arguments
5216 /// to form a proper call to this constructor.
5217 ///
5218 /// \returns true if an error occurred, false otherwise.
5220 QualType DeclInitType, MultiExprArg ArgsPtr,
5222 SmallVectorImpl<Expr *> &ConvertedArgs,
5223 bool AllowExplicit = false,
5224 bool IsListInitialization = false);
5225
5226 /// ActOnCXXEnterDeclInitializer - Invoked when we are about to parse an
5227 /// initializer for the declaration 'Dcl'.
5228 /// After this method is called, according to [C++ 3.4.1p13], if 'Dcl' is a
5229 /// static data member of class X, names should be looked up in the scope of
5230 /// class X.
5232
5233 /// ActOnCXXExitDeclInitializer - Invoked after we are finished parsing an
5234 /// initializer for the declaration 'Dcl'.
5235 void ActOnCXXExitDeclInitializer(Scope *S, Decl *Dcl);
5236
5237 /// Define the "body" of the conversion from a lambda object to a
5238 /// function pointer.
5239 ///
5240 /// This routine doesn't actually define a sensible body; rather, it fills
5241 /// in the initialization expression needed to copy the lambda object into
5242 /// the block, and IR generation actually generates the real body of the
5243 /// block pointer conversion.
5244 void
5246 CXXConversionDecl *Conv);
5247
5248 /// Define the "body" of the conversion from a lambda object to a
5249 /// block pointer.
5250 ///
5251 /// This routine doesn't actually define a sensible body; rather, it fills
5252 /// in the initialization expression needed to copy the lambda object into
5253 /// the block, and IR generation actually generates the real body of the
5254 /// block pointer conversion.
5256 CXXConversionDecl *Conv);
5257
5258 /// ActOnStartLinkageSpecification - Parsed the beginning of a C++
5259 /// linkage specification, including the language and (if present)
5260 /// the '{'. ExternLoc is the location of the 'extern', Lang is the
5261 /// language string literal. LBraceLoc, if valid, provides the location of
5262 /// the '{' brace. Otherwise, this linkage specification does not
5263 /// have any braces.
5265 Expr *LangStr, SourceLocation LBraceLoc);
5266
5267 /// ActOnFinishLinkageSpecification - Complete the definition of
5268 /// the C++ linkage specification LinkageSpec. If RBraceLoc is
5269 /// valid, it's the position of the closing '}' brace in a linkage
5270 /// specification that uses braces.
5272 SourceLocation RBraceLoc);
5273
5274 //===--------------------------------------------------------------------===//
5275 // C++ Classes
5276 //
5277
5278 /// Get the class that is directly named by the current context. This is the
5279 /// class for which an unqualified-id in this scope could name a constructor
5280 /// or destructor.
5281 ///
5282 /// If the scope specifier denotes a class, this will be that class.
5283 /// If the scope specifier is empty, this will be the class whose
5284 /// member-specification we are currently within. Otherwise, there
5285 /// is no such class.
5287
5288 /// isCurrentClassName - Determine whether the identifier II is the
5289 /// name of the class type currently being defined. In the case of
5290 /// nested classes, this will only return true if II is the name of
5291 /// the innermost class.
5292 bool isCurrentClassName(const IdentifierInfo &II, Scope *S,
5293 const CXXScopeSpec *SS = nullptr);
5294
5295 /// Determine whether the identifier II is a typo for the name of
5296 /// the class type currently being defined. If so, update it to the identifier
5297 /// that should have been used.
5299
5300 /// ActOnAccessSpecifier - Parsed an access specifier followed by a colon.
5302 SourceLocation ColonLoc,
5303 const ParsedAttributesView &Attrs);
5304
5305 /// ActOnCXXMemberDeclarator - This is invoked when a C++ class member
5306 /// declarator is parsed. 'AS' is the access specifier, 'BW' specifies the
5307 /// bitfield width if there is one, 'InitExpr' specifies the initializer if
5308 /// one has been parsed, and 'InitStyle' is set if an in-class initializer is
5309 /// present (but parsing it has been deferred).
5310 NamedDecl *
5312 MultiTemplateParamsArg TemplateParameterLists,
5313 Expr *BitfieldWidth, const VirtSpecifiers &VS,
5314 InClassInitStyle InitStyle);
5315
5316 /// Enter a new C++ default initializer scope. After calling this, the
5317 /// caller must call \ref ActOnFinishCXXInClassMemberInitializer, even if
5318 /// parsing or instantiating the initializer failed.
5320
5321 /// This is invoked after parsing an in-class initializer for a
5322 /// non-static C++ class member, and after instantiating an in-class
5323 /// initializer in a class template. Such actions are deferred until the class
5324 /// is complete.
5326 SourceLocation EqualLoc,
5328
5329 /// Handle a C++ member initializer using parentheses syntax.
5331 ActOnMemInitializer(Decl *ConstructorD, Scope *S, CXXScopeSpec &SS,
5332 IdentifierInfo *MemberOrBase, ParsedType TemplateTypeTy,
5333 const DeclSpec &DS, SourceLocation IdLoc,
5334 SourceLocation LParenLoc, ArrayRef<Expr *> Args,
5335 SourceLocation RParenLoc, SourceLocation EllipsisLoc);
5336
5337 /// Handle a C++ member initializer using braced-init-list syntax.
5338 MemInitResult ActOnMemInitializer(Decl *ConstructorD, Scope *S,
5339 CXXScopeSpec &SS,
5340 IdentifierInfo *MemberOrBase,
5341 ParsedType TemplateTypeTy,
5342 const DeclSpec &DS, SourceLocation IdLoc,
5343 Expr *InitList, SourceLocation EllipsisLoc);
5344
5345 /// Handle a C++ member initializer.
5346 MemInitResult BuildMemInitializer(Decl *ConstructorD, Scope *S,
5347 CXXScopeSpec &SS,
5348 IdentifierInfo *MemberOrBase,
5349 ParsedType TemplateTypeTy,
5350 const DeclSpec &DS, SourceLocation IdLoc,
5351 Expr *Init, SourceLocation EllipsisLoc);
5352
5354 SourceLocation IdLoc);
5355
5357 TypeSourceInfo *BaseTInfo, Expr *Init,
5358 CXXRecordDecl *ClassDecl,
5359 SourceLocation EllipsisLoc);
5360
5362 CXXRecordDecl *ClassDecl);
5363
5366
5367 bool SetCtorInitializers(CXXConstructorDecl *Constructor, bool AnyErrors,
5368 ArrayRef<CXXCtorInitializer *> Initializers = {});
5369
5370 /// MarkBaseAndMemberDestructorsReferenced - Given a record decl,
5371 /// mark all the non-trivial destructors of its members and bases as
5372 /// referenced.
5373 void MarkBaseAndMemberDestructorsReferenced(SourceLocation Loc,
5374 CXXRecordDecl *Record);
5375
5376 /// Mark destructors of virtual bases of this class referenced. In the Itanium
5377 /// C++ ABI, this is done when emitting a destructor for any non-abstract
5378 /// class. In the Microsoft C++ ABI, this is done any time a class's
5379 /// destructor is referenced.
5381 SourceLocation Location, CXXRecordDecl *ClassDecl,
5382 llvm::SmallPtrSetImpl<const RecordType *> *DirectVirtualBases = nullptr);
5383
5384 /// Do semantic checks to allow the complete destructor variant to be emitted
5385 /// when the destructor is defined in another translation unit. In the Itanium
5386 /// C++ ABI, destructor variants are emitted together. In the MS C++ ABI, they
5387 /// can be emitted in separate TUs. To emit the complete variant, run a subset
5388 /// of the checks performed when emitting a regular destructor.
5389 void CheckCompleteDestructorVariant(SourceLocation CurrentLocation,
5390 CXXDestructorDecl *Dtor);
5391
5392 /// The list of classes whose vtables have been used within
5393 /// this translation unit, and the source locations at which the
5394 /// first use occurred.
5395 typedef std::pair<CXXRecordDecl *, SourceLocation> VTableUse;
5396
5397 /// The list of vtables that are required but have not yet been
5398 /// materialized.
5400
5401 /// The set of classes whose vtables have been used within
5402 /// this translation unit, and a bit that will be true if the vtable is
5403 /// required to be emitted (otherwise, it should be emitted only if needed
5404 /// by code generation).
5405 llvm::DenseMap<CXXRecordDecl *, bool> VTablesUsed;
5406
5407 /// Load any externally-stored vtable uses.
5409
5410 /// Note that the vtable for the given class was used at the
5411 /// given location.
5413 bool DefinitionRequired = false);
5414
5415 /// Mark the exception specifications of all virtual member functions
5416 /// in the given class as needed.
5418 const CXXRecordDecl *RD);
5419
5420 /// MarkVirtualMembersReferenced - Will mark all members of the given
5421 /// CXXRecordDecl referenced.
5423 bool ConstexprOnly = false);
5424
5425 /// Define all of the vtables that have been used in this
5426 /// translation unit and reference any virtual members used by those
5427 /// vtables.
5428 ///
5429 /// \returns true if any work was done, false otherwise.
5430 bool DefineUsedVTables();
5431
5432 /// AddImplicitlyDeclaredMembersToClass - Adds any implicitly-declared
5433 /// special functions, such as the default constructor, copy
5434 /// constructor, or destructor, to the given C++ class (C++
5435 /// [special]p1). This routine can only be executed just before the
5436 /// definition of the class is complete.
5438
5439 /// ActOnMemInitializers - Handle the member initializers for a constructor.
5440 void ActOnMemInitializers(Decl *ConstructorDecl, SourceLocation ColonLoc,
5442 bool AnyErrors);
5443
5444 /// Check class-level dllimport/dllexport attribute. The caller must
5445 /// ensure that referenceDLLExportedClassMethods is called some point later
5446 /// when all outer classes of Class are complete.
5449
5451
5452 /// Perform propagation of DLL attributes from a derived class to a
5453 /// templated base class for MS compatibility.
5455 CXXRecordDecl *Class, Attr *ClassAttr,
5456 ClassTemplateSpecializationDecl *BaseTemplateSpec,
5457 SourceLocation BaseLoc);
5458
5459 /// Perform semantic checks on a class definition that has been
5460 /// completing, introducing implicitly-declared members, checking for
5461 /// abstract types, etc.
5462 ///
5463 /// \param S The scope in which the class was parsed. Null if we didn't just
5464 /// parse a class definition.
5465 /// \param Record The completed class.
5467
5468 /// Check that the C++ class annoated with "trivial_abi" satisfies all the
5469 /// conditions that are needed for the attribute to have an effect.
5471
5472 /// Check that VTable Pointer authentication is only being set on the first
5473 /// first instantiation of the vtable
5475
5477 Decl *TagDecl, SourceLocation LBrac,
5478 SourceLocation RBrac,
5479 const ParsedAttributesView &AttrList);
5480
5481 /// Perform any semantic analysis which needs to be delayed until all
5482 /// pending class member declarations have been parsed.
5485
5486 /// This is used to implement the constant expression evaluation part of the
5487 /// attribute enable_if extension. There is nothing in standard C++ which
5488 /// would require reentering parameters.
5490 unsigned ActOnReenterTemplateScope(Decl *Template,
5491 llvm::function_ref<Scope *()> EnterScope);
5493
5494 /// ActOnStartDelayedCXXMethodDeclaration - We have completed
5495 /// parsing a top-level (non-nested) C++ class, and we are now
5496 /// parsing those parts of the given Method declaration that could
5497 /// not be parsed earlier (C++ [class.mem]p2), such as default
5498 /// arguments. This action should enter the scope of the given
5499 /// Method declaration as if we had just parsed the qualified method
5500 /// name. However, it should not bring the parameters into scope;
5501 /// that will be performed by ActOnDelayedCXXMethodParameter.
5503 void ActOnDelayedCXXMethodParameter(Scope *S, Decl *Param);
5505
5506 /// ActOnFinishDelayedCXXMethodDeclaration - We have finished
5507 /// processing the delayed method declaration for Method. The method
5508 /// declaration is now considered finished. There may be a separate
5509 /// ActOnStartOfFunctionDef action later (not necessarily
5510 /// immediately!) for this method, if it was also defined inside the
5511 /// class body.
5514
5515 bool EvaluateStaticAssertMessageAsString(Expr *Message, std::string &Result,
5516 ASTContext &Ctx,
5517 bool ErrorOnInvalidMessage);
5519 Expr *AssertExpr, Expr *AssertMessageExpr,
5520 SourceLocation RParenLoc);
5522 Expr *AssertExpr, Expr *AssertMessageExpr,
5523 SourceLocation RParenLoc, bool Failed);
5524
5525 /// Try to print more useful information about a failed static_assert
5526 /// with expression \E
5527 void DiagnoseStaticAssertDetails(const Expr *E);
5528
5529 /// Handle a friend type declaration. This works in tandem with
5530 /// ActOnTag.
5531 ///
5532 /// Notes on friend class templates:
5533 ///
5534 /// We generally treat friend class declarations as if they were
5535 /// declaring a class. So, for example, the elaborated type specifier
5536 /// in a friend declaration is required to obey the restrictions of a
5537 /// class-head (i.e. no typedefs in the scope chain), template
5538 /// parameters are required to match up with simple template-ids, &c.
5539 /// However, unlike when declaring a template specialization, it's
5540 /// okay to refer to a template specialization without an empty
5541 /// template parameter declaration, e.g.
5542 /// friend class A<T>::B<unsigned>;
5543 /// We permit this as a special case; if there are any template
5544 /// parameters present at all, require proper matching, i.e.
5545 /// template <> template <class T> friend class A<int>::B;
5546 Decl *ActOnFriendTypeDecl(Scope *S, const DeclSpec &DS,
5547 MultiTemplateParamsArg TemplateParams,
5548 SourceLocation EllipsisLoc);
5550 MultiTemplateParamsArg TemplateParams);
5551
5552 /// CheckConstructorDeclarator - Called by ActOnDeclarator to check
5553 /// the well-formedness of the constructor declarator @p D with type @p
5554 /// R. If there are any errors in the declarator, this routine will
5555 /// emit diagnostics and set the invalid bit to true. In any case, the type
5556 /// will be updated to reflect a well-formed type for the constructor and
5557 /// returned.
5559 StorageClass &SC);
5560
5561 /// CheckConstructor - Checks a fully-formed constructor for
5562 /// well-formedness, issuing any diagnostics required. Returns true if
5563 /// the constructor declarator is invalid.
5564 void CheckConstructor(CXXConstructorDecl *Constructor);
5565
5566 /// CheckDestructorDeclarator - Called by ActOnDeclarator to check
5567 /// the well-formednes of the destructor declarator @p D with type @p
5568 /// R. If there are any errors in the declarator, this routine will
5569 /// emit diagnostics and set the declarator to invalid. Even if this happens,
5570 /// will be updated to reflect a well-formed type for the destructor and
5571 /// returned.
5573 StorageClass &SC);
5574
5575 /// CheckDestructor - Checks a fully-formed destructor definition for
5576 /// well-formedness, issuing any diagnostics required. Returns true
5577 /// on error.
5579
5580 /// CheckConversionDeclarator - Called by ActOnDeclarator to check the
5581 /// well-formednes of the conversion function declarator @p D with
5582 /// type @p R. If there are any errors in the declarator, this routine
5583 /// will emit diagnostics and return true. Otherwise, it will return
5584 /// false. Either way, the type @p R will be updated to reflect a
5585 /// well-formed type for the conversion operator.
5587
5588 /// ActOnConversionDeclarator - Called by ActOnDeclarator to complete
5589 /// the declaration of the given C++ conversion function. This routine
5590 /// is responsible for recording the conversion function in the C++
5591 /// class, if possible.
5593
5594 /// Check the validity of a declarator that we parsed for a deduction-guide.
5595 /// These aren't actually declarators in the grammar, so we need to check that
5596 /// the user didn't specify any pieces that are not part of the
5597 /// deduction-guide grammar. Return true on invalid deduction-guide.
5599 StorageClass &SC);
5600
5602
5605 SourceLocation DefaultLoc);
5607
5608 /// Kinds of defaulted comparison operator functions.
5609 enum class DefaultedComparisonKind : unsigned char {
5610 /// This is not a defaultable comparison operator.
5611 None,
5612 /// This is an operator== that should be implemented as a series of
5613 /// subobject comparisons.
5614 Equal,
5615 /// This is an operator<=> that should be implemented as a series of
5616 /// subobject comparisons.
5617 ThreeWay,
5618 /// This is an operator!= that should be implemented as a rewrite in terms
5619 /// of a == comparison.
5620 NotEqual,
5621 /// This is an <, <=, >, or >= that should be implemented as a rewrite in
5622 /// terms of a <=> comparison.
5623 Relational,
5624 };
5625
5629 FunctionDecl *Spaceship);
5632
5634 QualType R, bool IsLambda,
5635 DeclContext *DC = nullptr);
5637 DeclarationName Name, QualType R);
5639
5640 //===--------------------------------------------------------------------===//
5641 // C++ Derived Classes
5642 //
5643
5644 /// Check the validity of a C++ base class specifier.
5645 ///
5646 /// \returns a new CXXBaseSpecifier if well-formed, emits diagnostics
5647 /// and returns NULL otherwise.
5649 SourceRange SpecifierRange, bool Virtual,
5650 AccessSpecifier Access,
5651 TypeSourceInfo *TInfo,
5652 SourceLocation EllipsisLoc);
5653
5654 /// ActOnBaseSpecifier - Parsed a base specifier. A base specifier is
5655 /// one entry in the base class list of a class specifier, for
5656 /// example:
5657 /// class foo : public bar, virtual private baz {
5658 /// 'public bar' and 'virtual private baz' are each base-specifiers.
5659 BaseResult ActOnBaseSpecifier(Decl *classdecl, SourceRange SpecifierRange,
5660 const ParsedAttributesView &Attrs, bool Virtual,
5661 AccessSpecifier Access, ParsedType basetype,
5662 SourceLocation BaseLoc,
5663 SourceLocation EllipsisLoc);
5664
5665 /// Performs the actual work of attaching the given base class
5666 /// specifiers to a C++ class.
5669
5670 /// ActOnBaseSpecifiers - Attach the given base specifiers to the
5671 /// class, after checking whether there are any duplicate base
5672 /// classes.
5673 void ActOnBaseSpecifiers(Decl *ClassDecl,
5675
5676 /// Determine whether the type \p Derived is a C++ class that is
5677 /// derived from the type \p Base.
5679
5680 /// Determine whether the type \p Derived is a C++ class that is
5681 /// derived from the type \p Base.
5683 CXXBasePaths &Paths);
5684
5685 // FIXME: I don't like this name.
5686 void BuildBasePathArray(const CXXBasePaths &Paths, CXXCastPath &BasePath);
5687
5690 CXXCastPath *BasePath = nullptr,
5691 bool IgnoreAccess = false);
5692
5693 /// CheckDerivedToBaseConversion - Check whether the Derived-to-Base
5694 /// conversion (where Derived and Base are class types) is
5695 /// well-formed, meaning that the conversion is unambiguous (and
5696 /// that all of the base classes are accessible). Returns true
5697 /// and emits a diagnostic if the code is ill-formed, returns false
5698 /// otherwise. Loc is the location where this routine should point to
5699 /// if there is an error, and Range is the source range to highlight
5700 /// if there is an error.
5701 ///
5702 /// If either InaccessibleBaseID or AmbiguousBaseConvID are 0, then the
5703 /// diagnostic for the respective type of error will be suppressed, but the
5704 /// check for ill-formed code will still be performed.
5706 unsigned InaccessibleBaseID,
5707 unsigned AmbiguousBaseConvID,
5709 DeclarationName Name, CXXCastPath *BasePath,
5710 bool IgnoreAccess = false);
5711
5712 /// Builds a string representing ambiguous paths from a
5713 /// specific derived class to different subobjects of the same base
5714 /// class.
5715 ///
5716 /// This function builds a string that can be used in error messages
5717 /// to show the different paths that one can take through the
5718 /// inheritance hierarchy to go from the derived class to different
5719 /// subobjects of a base class. The result looks something like this:
5720 /// @code
5721 /// struct D -> struct B -> struct A
5722 /// struct D -> struct C -> struct A
5723 /// @endcode
5724 std::string getAmbiguousPathsDisplayString(CXXBasePaths &Paths);
5725
5727 const CXXMethodDecl *Old);
5728
5729 /// CheckOverridingFunctionReturnType - Checks whether the return types are
5730 /// covariant, according to C++ [class.virtual]p5.
5732 const CXXMethodDecl *Old);
5733
5734 // Check that the overriding method has no explicit object parameter.
5736 const CXXMethodDecl *Old);
5737
5738 /// Mark the given method pure.
5739 ///
5740 /// \param Method the method to be marked pure.
5741 ///
5742 /// \param InitRange the source range that covers the "0" initializer.
5743 bool CheckPureMethod(CXXMethodDecl *Method, SourceRange InitRange);
5744
5745 /// CheckOverrideControl - Check C++11 override control semantics.
5747
5748 /// DiagnoseAbsenceOfOverrideControl - Diagnose if 'override' keyword was
5749 /// not used in the declaration of an overriding method.
5751
5752 /// CheckIfOverriddenFunctionIsMarkedFinal - Checks whether a virtual member
5753 /// function overrides a virtual member function marked 'final', according to
5754 /// C++11 [class.virtual]p4.
5756 const CXXMethodDecl *Old);
5757
5768
5769 struct TypeDiagnoser;
5770
5773 TypeDiagnoser &Diagnoser);
5774 template <typename... Ts>
5776 const Ts &...Args) {
5777 BoundTypeDiagnoser<Ts...> Diagnoser(DiagID, Args...);
5778 return RequireNonAbstractType(Loc, T, Diagnoser);
5779 }
5780
5781 void DiagnoseAbstractType(const CXXRecordDecl *RD);
5782
5783 //===--------------------------------------------------------------------===//
5784 // C++ Overloaded Operators [C++ 13.5]
5785 //
5786
5787 /// CheckOverloadedOperatorDeclaration - Check whether the declaration
5788 /// of this overloaded operator is well-formed. If so, returns false;
5789 /// otherwise, emits appropriate diagnostics and returns true.
5791
5792 /// CheckLiteralOperatorDeclaration - Check whether the declaration
5793 /// of this literal operator function is well-formed. If so, returns
5794 /// false; otherwise, emits appropriate diagnostics and returns true.
5796
5797 /// ActOnExplicitBoolSpecifier - Build an ExplicitSpecifier from an expression
5798 /// found in an explicit(bool) specifier.
5800
5801 /// tryResolveExplicitSpecifier - Attempt to resolve the explict specifier.
5802 /// Returns true if the explicit specifier is now resolved.
5804
5805 /// ActOnCXXConditionDeclarationExpr - Parsed a condition declaration of a
5806 /// C++ if/switch/while/for statement.
5807 /// e.g: "if (int x = f()) {...}"
5809
5810 // Emitting members of dllexported classes is delayed until the class
5811 // (including field initializers) is fully parsed.
5814
5815 /// Merge the exception specifications of two variable declarations.
5816 ///
5817 /// This is called when there's a redeclaration of a VarDecl. The function
5818 /// checks if the redeclaration might have an exception specification and
5819 /// validates compatibility and merges the specs if necessary.
5821
5822 /// MergeCXXFunctionDecl - Merge two declarations of the same C++
5823 /// function, once we already know that they have the same
5824 /// type. Subroutine of MergeFunctionDecl. Returns true if there was an
5825 /// error, false otherwise.
5827
5828 /// Helpers for dealing with blocks and functions.
5830
5831 /// CheckExtraCXXDefaultArguments - Check for any extra default
5832 /// arguments in the declarator, which is not a function declaration
5833 /// or definition and therefore is not permitted to have default
5834 /// arguments. This routine should be invoked for every declarator
5835 /// that is not a function declaration or definition.
5837
5840 }
5841
5842 /// Perform semantic analysis for the variable declaration that
5843 /// occurs within a C++ catch clause, returning the newly-created
5844 /// variable.
5846 SourceLocation StartLoc,
5847 SourceLocation IdLoc,
5848 const IdentifierInfo *Id);
5849
5850 /// ActOnExceptionDeclarator - Parsed the exception-declarator in a C++ catch
5851 /// handler.
5853
5855
5856 /// Handle a friend tag declaration where the scope specifier was
5857 /// templated.
5859 unsigned TagSpec, SourceLocation TagLoc,
5860 CXXScopeSpec &SS, IdentifierInfo *Name,
5861 SourceLocation NameLoc,
5862 SourceLocation EllipsisLoc,
5864 MultiTemplateParamsArg TempParamLists);
5865
5867 SourceLocation DeclStart, Declarator &D,
5868 Expr *BitfieldWidth,
5869 InClassInitStyle InitStyle,
5870 AccessSpecifier AS,
5871 const ParsedAttr &MSPropertyAttr);
5872
5873 /// Diagnose why the specified class does not have a trivial special member of
5874 /// the given kind.
5877
5879 /// The triviality of a method unaffected by "trivial_abi".
5881
5882 /// The triviality of a method affected by "trivial_abi".
5885
5886 /// Determine whether a defaulted or deleted special member function is
5887 /// trivial, as specified in C++11 [class.ctor]p5, C++11 [class.copy]p12,
5888 /// C++11 [class.copy]p25, and C++11 [class.dtor]p5.
5891 bool Diagnose = false);
5892
5893 /// For a defaulted function, the kind of defaulted function that it is.
5895 LLVM_PREFERRED_TYPE(CXXSpecialMemberKind)
5896 unsigned SpecialMember : 8;
5897 unsigned Comparison : 8;
5898
5899 public:
5901 : SpecialMember(llvm::to_underlying(CXXSpecialMemberKind::Invalid)),
5902 Comparison(llvm::to_underlying(DefaultedComparisonKind::None)) {}
5904 : SpecialMember(llvm::to_underlying(CSM)),
5905 Comparison(llvm::to_underlying(DefaultedComparisonKind::None)) {}
5907 : SpecialMember(llvm::to_underlying(CXXSpecialMemberKind::Invalid)),
5908 Comparison(llvm::to_underlying(Comp)) {}
5909
5910 bool isSpecialMember() const {
5911 return static_cast<CXXSpecialMemberKind>(SpecialMember) !=
5912 CXXSpecialMemberKind::Invalid;
5913 }
5914 bool isComparison() const {
5915 return static_cast<DefaultedComparisonKind>(Comparison) !=
5916 DefaultedComparisonKind::None;
5917 }
5918
5919 explicit operator bool() const {
5920 return isSpecialMember() || isComparison();
5921 }
5922
5924 return static_cast<CXXSpecialMemberKind>(SpecialMember);
5925 }
5927 return static_cast<DefaultedComparisonKind>(Comparison);
5928 }
5929
5930 /// Get the index of this function kind for use in diagnostics.
5931 unsigned getDiagnosticIndex() const {
5932 static_assert(llvm::to_underlying(CXXSpecialMemberKind::Invalid) >
5933 llvm::to_underlying(CXXSpecialMemberKind::Destructor),
5934 "invalid should have highest index");
5935 static_assert((unsigned)DefaultedComparisonKind::None == 0,
5936 "none should be equal to zero");
5937 return SpecialMember + Comparison;
5938 }
5939 };
5940
5941 /// Determine the kind of defaulting that would be done for a given function.
5942 ///
5943 /// If the function is both a default constructor and a copy / move
5944 /// constructor (due to having a default argument for the first parameter),
5945 /// this picks CXXSpecialMemberKind::DefaultConstructor.
5946 ///
5947 /// FIXME: Check that case is properly handled by all callers.
5948 DefaultedFunctionKind getDefaultedFunctionKind(const FunctionDecl *FD);
5949
5950 /// Handle a C++11 empty-declaration and attribute-declaration.
5952 SourceLocation SemiLoc);
5953
5955 /// Diagnose issues that are non-constant or that are extensions.
5956 Diagnose,
5957 /// Identify whether this function satisfies the formal rules for constexpr
5958 /// functions in the current lanugage mode (with no extensions).
5960 };
5961
5962 // Check whether a function declaration satisfies the requirements of a
5963 // constexpr function definition or a constexpr constructor definition. If so,
5964 // return true. If not, produce appropriate diagnostics (unless asked not to
5965 // by Kind) and return false.
5966 //
5967 // This implements C++11 [dcl.constexpr]p3,4, as amended by DR1360.
5970
5971 /// Diagnose methods which overload virtual methods in a base class
5972 /// without overriding any.
5974
5975 /// Check if a method overloads virtual methods in a base class without
5976 /// overriding any.
5977 void
5979 SmallVectorImpl<CXXMethodDecl *> &OverloadedMethods);
5980 void
5982 SmallVectorImpl<CXXMethodDecl *> &OverloadedMethods);
5983
5984 /// ActOnParamDefaultArgument - Check whether the default argument
5985 /// provided for a function parameter is well-formed. If so, attach it
5986 /// to the parameter declaration.
5987 void ActOnParamDefaultArgument(Decl *param, SourceLocation EqualLoc,
5988 Expr *defarg);
5989
5990 /// ActOnParamUnparsedDefaultArgument - We've seen a default
5991 /// argument for a function parameter, but we can't parse it yet
5992 /// because we're inside a class definition. Note that this default
5993 /// argument will be parsed later.
5995 SourceLocation ArgLoc);
5996
5997 /// ActOnParamDefaultArgumentError - Parsing or semantic analysis of
5998 /// the default argument for the parameter param failed.
6000 Expr *DefaultArg);
6002 SourceLocation EqualLoc);
6003 void SetParamDefaultArgument(ParmVarDecl *Param, Expr *DefaultArg,
6004 SourceLocation EqualLoc);
6005
6006 void ActOnPureSpecifier(Decl *D, SourceLocation PureSpecLoc);
6007 void SetDeclDeleted(Decl *dcl, SourceLocation DelLoc,
6008 StringLiteral *Message = nullptr);
6009 void SetDeclDefaulted(Decl *dcl, SourceLocation DefaultLoc);
6010
6012 StringLiteral *DeletedMessage = nullptr);
6016
6017 NamedDecl *
6019 MultiTemplateParamsArg TemplateParamLists);
6022 RecordDecl *ClassDecl,
6023 const IdentifierInfo *Name);
6024
6027
6028 /// Stack containing information needed when in C++2a an 'auto' is encountered
6029 /// in a function declaration parameter type specifier in order to invent a
6030 /// corresponding template parameter in the enclosing abbreviated function
6031 /// template. This information is also present in LambdaScopeInfo, stored in
6032 /// the FunctionScopes stack.
6034
6035 /// FieldCollector - Collects CXXFieldDecls during parsing of C++ classes.
6036 std::unique_ptr<CXXFieldCollector> FieldCollector;
6037
6039 /// Set containing all declared private fields that are not used.
6041
6043
6044 /// PureVirtualClassDiagSet - a set of class declarations which we have
6045 /// emitted a list of pure virtual functions. Used to prevent emitting the
6046 /// same list more than once.
6047 std::unique_ptr<RecordDeclSetTy> PureVirtualClassDiagSet;
6048
6052
6053 /// All the delegating constructors seen so far in the file, used for
6054 /// cycle detection at the end of the TU.
6056
6057 /// The C++ "std" namespace, where the standard library resides.
6059
6060 /// The C++ "std::initializer_list" template, which is defined in
6061 /// <initializer_list>.
6063
6064 // Contains the locations of the beginning of unparsed default
6065 // argument locations.
6066 llvm::DenseMap<ParmVarDecl *, SourceLocation> UnparsedDefaultArgLocs;
6067
6068 /// UndefinedInternals - all the used, undefined objects which require a
6069 /// definition in this translation unit.
6070 llvm::MapVector<NamedDecl *, SourceLocation> UndefinedButUsed;
6071
6072 typedef llvm::PointerIntPair<CXXRecordDecl *, 3, CXXSpecialMemberKind>
6074
6075 /// The C++ special members which we are currently in the process of
6076 /// declaring. If this process recursively triggers the declaration of the
6077 /// same special member, we should act as if it is not yet declared.
6079
6081
6082 void ActOnDefaultCtorInitializers(Decl *CDtorDecl);
6083
6086 ParsingClassDepth++;
6088 }
6090 ParsingClassDepth--;
6092 }
6093
6095 CXXScopeSpec &SS,
6096 ParsedType TemplateTypeTy,
6097 IdentifierInfo *MemberOrBase);
6098
6099private:
6100 void setupImplicitSpecialMemberType(CXXMethodDecl *SpecialMem,
6101 QualType ResultTy,
6102 ArrayRef<QualType> Args);
6103
6104 // A cache representing if we've fully checked the various comparison category
6105 // types stored in ASTContext. The bit-index corresponds to the integer value
6106 // of a ComparisonCategoryType enumerator.
6107 llvm::SmallBitVector FullyCheckedComparisonCategories;
6108
6109 /// Check if there is a field shadowing.
6110 void CheckShadowInheritedFields(const SourceLocation &Loc,
6111 DeclarationName FieldName,
6112 const CXXRecordDecl *RD,
6113 bool DeclIsField = true);
6114
6115 ///@}
6116
6117 //
6118 //
6119 // -------------------------------------------------------------------------
6120 //
6121 //
6122
6123 /// \name C++ Exception Specifications
6124 /// Implementations are in SemaExceptionSpec.cpp
6125 ///@{
6126
6127public:
6128 /// All the overriding functions seen during a class definition
6129 /// that had their exception spec checks delayed, plus the overridden
6130 /// function.
6133
6134 /// All the function redeclarations seen during a class definition that had
6135 /// their exception spec checks delayed, plus the prior declaration they
6136 /// should be checked against. Except during error recovery, the new decl
6137 /// should always be a friend declaration, as that's the only valid way to
6138 /// redeclare a special member before its class is complete.
6141
6142 /// Determine if we're in a case where we need to (incorrectly) eagerly
6143 /// parse an exception specification to work around a libstdc++ bug.
6145
6146 /// Check the given noexcept-specifier, convert its expression, and compute
6147 /// the appropriate ExceptionSpecificationType.
6148 ExprResult ActOnNoexceptSpec(Expr *NoexceptExpr,
6150
6151 CanThrowResult canThrow(const Stmt *E);
6152 /// Determine whether the callee of a particular function call can throw.
6153 /// E, D and Loc are all optional.
6154 static CanThrowResult canCalleeThrow(Sema &S, const Expr *E, const Decl *D,
6157 const FunctionProtoType *FPT);
6160
6161 /// CheckSpecifiedExceptionType - Check if the given type is valid in an
6162 /// exception specification. Incomplete types, or pointers to incomplete types
6163 /// other than void are not allowed.
6164 ///
6165 /// \param[in,out] T The exception type. This will be decayed to a pointer
6166 /// type
6167 /// when the input is an array or a function type.
6169
6170 /// CheckDistantExceptionSpec - Check if the given type is a pointer or
6171 /// pointer to member to a function with an exception specification. This
6172 /// means that it is invalid to add another level of indirection.
6175
6176 /// CheckEquivalentExceptionSpec - Check if the two types have equivalent
6177 /// exception specifications. Exception specifications are equivalent if
6178 /// they allow exactly the same set of exception types. It does not matter how
6179 /// that is achieved. See C++ [except.spec]p2.
6181 SourceLocation OldLoc,
6182 const FunctionProtoType *New,
6183 SourceLocation NewLoc);
6185 const PartialDiagnostic &NoteID,
6186 const FunctionProtoType *Old,
6187 SourceLocation OldLoc,
6188 const FunctionProtoType *New,
6189 SourceLocation NewLoc);
6190 bool handlerCanCatch(QualType HandlerType, QualType ExceptionType);
6191
6192 /// CheckExceptionSpecSubset - Check whether the second function type's
6193 /// exception specification is a subset (or equivalent) of the first function
6194 /// type. This is used by override and pointer assignment checks.
6196 const PartialDiagnostic &DiagID, const PartialDiagnostic &NestedDiagID,
6197 const PartialDiagnostic &NoteID, const PartialDiagnostic &NoThrowDiagID,
6198 const FunctionProtoType *Superset, bool SkipSupersetFirstParameter,
6199 SourceLocation SuperLoc, const FunctionProtoType *Subset,
6200 bool SkipSubsetFirstParameter, SourceLocation SubLoc);
6201
6202 /// CheckParamExceptionSpec - Check if the parameter and return types of the
6203 /// two functions have equivalent exception specs. This is part of the
6204 /// assignment and override compatibility check. We do not check the
6205 /// parameters of parameter function pointers recursively, as no sane
6206 /// programmer would even be able to write such a function type.
6208 const PartialDiagnostic &NestedDiagID, const PartialDiagnostic &NoteID,
6209 const FunctionProtoType *Target, bool SkipTargetFirstParameter,
6210 SourceLocation TargetLoc, const FunctionProtoType *Source,
6211 bool SkipSourceFirstParameter, SourceLocation SourceLoc);
6212
6213 bool CheckExceptionSpecCompatibility(Expr *From, QualType ToType);
6214
6215 /// CheckOverridingFunctionExceptionSpec - Checks whether the exception
6216 /// spec is a subset of base spec.
6218 const CXXMethodDecl *Old);
6219
6220 ///@}
6221
6222 //
6223 //
6224 // -------------------------------------------------------------------------
6225 //
6226 //
6227
6228 /// \name Expressions
6229 /// Implementations are in SemaExpr.cpp
6230 ///@{
6231
6232public:
6233 /// Describes how the expressions currently being parsed are
6234 /// evaluated at run-time, if at all.
6236 /// The current expression and its subexpressions occur within an
6237 /// unevaluated operand (C++11 [expr]p7), such as the subexpression of
6238 /// \c sizeof, where the type of the expression may be significant but
6239 /// no code will be generated to evaluate the value of the expression at
6240 /// run time.
6242
6243 /// The current expression occurs within a braced-init-list within
6244 /// an unevaluated operand. This is mostly like a regular unevaluated
6245 /// context, except that we still instantiate constexpr functions that are
6246 /// referenced here so that we can perform narrowing checks correctly.
6248
6249 /// The current expression occurs within a discarded statement.
6250 /// This behaves largely similarly to an unevaluated operand in preventing
6251 /// definitions from being required, but not in other ways.
6253
6254 /// The current expression occurs within an unevaluated
6255 /// operand that unconditionally permits abstract references to
6256 /// fields, such as a SIZE operator in MS-style inline assembly.
6258
6259 /// The current context is "potentially evaluated" in C++11 terms,
6260 /// but the expression is evaluated at compile-time (like the values of
6261 /// cases in a switch statement).
6263
6264 /// In addition of being constant evaluated, the current expression
6265 /// occurs in an immediate function context - either a consteval function
6266 /// or a consteval if statement.
6268
6269 /// The current expression is potentially evaluated at run time,
6270 /// which means that code may be generated to evaluate the value of the
6271 /// expression at run time.
6273
6274 /// The current expression is potentially evaluated, but any
6275 /// declarations referenced inside that expression are only used if
6276 /// in fact the current expression is used.
6277 ///
6278 /// This value is used when parsing default function arguments, for which
6279 /// we would like to provide diagnostics (e.g., passing non-POD arguments
6280 /// through varargs) but do not want to mark declarations as "referenced"
6281 /// until the default argument is used.
6283 };
6284
6285 /// Store a set of either DeclRefExprs or MemberExprs that contain a reference
6286 /// to a variable (constant) that may or may not be odr-used in this Expr, and
6287 /// we won't know until all lvalue-to-rvalue and discarded value conversions
6288 /// have been applied to all subexpressions of the enclosing full expression.
6289 /// This is cleared at the end of each full expression.
6292
6293 using ImmediateInvocationCandidate = llvm::PointerIntPair<ConstantExpr *, 1>;
6294
6295 /// Data structure used to record current or nested
6296 /// expression evaluation contexts.
6298 /// The expression evaluation context.
6300
6301 /// Whether the enclosing context needed a cleanup.
6303
6304 /// The number of active cleanup objects when we entered
6305 /// this expression evaluation context.
6307
6308 /// The number of typos encountered during this expression evaluation
6309 /// context (i.e. the number of TypoExprs created).
6310 unsigned NumTypos;
6311
6313
6314 /// The lambdas that are present within this context, if it
6315 /// is indeed an unevaluated context.
6317
6318 /// The declaration that provides context for lambda expressions
6319 /// and block literals if the normal declaration context does not
6320 /// suffice, e.g., in a default function argument.
6322
6323 /// If we are processing a decltype type, a set of call expressions
6324 /// for which we have deferred checking the completeness of the return type.
6326
6327 /// If we are processing a decltype type, a set of temporary binding
6328 /// expressions for which we have deferred checking the destructor.
6330
6332
6333 /// Expressions appearing as the LHS of a volatile assignment in this
6334 /// context. We produce a warning for these when popping the context if
6335 /// they are not discarded-value expressions nor unevaluated operands.
6337
6338 /// Set of candidates for starting an immediate invocation.
6341
6342 /// Set of DeclRefExprs referencing a consteval function when used in a
6343 /// context not already known to be immediately invoked.
6345
6346 /// P2718R0 - Lifetime extension in range-based for loops.
6347 /// MaterializeTemporaryExprs in for-range-init expressions which need to
6348 /// extend lifetime. Add MaterializeTemporaryExpr* if the value of
6349 /// InLifetimeExtendingContext is true.
6351
6352 /// \brief Describes whether we are in an expression constext which we have
6353 /// to handle differently.
6358 EK_Other
6359 } ExprContext;
6360
6361 // A context can be nested in both a discarded statement context and
6362 // an immediate function context, so they need to be tracked independently.
6366
6367 bool IsCurrentlyCheckingDefaultArgumentOrInitializer = false;
6368
6369 // We are in a constant context, but we also allow
6370 // non constant expressions, for example for array bounds (which may be
6371 // VLAs).
6372 bool InConditionallyConstantEvaluateContext = false;
6373
6374 /// Whether we are currently in a context in which all temporaries must be
6375 /// lifetime-extended, even if they're not bound to a reference (for
6376 /// example, in a for-range initializer).
6377 bool InLifetimeExtendingContext = false;
6378
6379 /// Whether we should rebuild CXXDefaultArgExpr and CXXDefaultInitExpr.
6380 bool RebuildDefaultArgOrDefaultInit = false;
6381
6382 // When evaluating immediate functions in the initializer of a default
6383 // argument or default member initializer, this is the declaration whose
6384 // default initializer is being evaluated and the location of the call
6385 // or constructor definition.
6388 DeclContext *Context)
6389 : Loc(Loc), Decl(Decl), Context(Context) {
6390 assert(Decl && Context && "invalid initialization context");
6391 }
6392
6394 ValueDecl *Decl = nullptr;
6395 DeclContext *Context = nullptr;
6396 };
6397 std::optional<InitializationContext> DelayedDefaultInitializationContext;
6398
6400 unsigned NumCleanupObjects,
6401 CleanupInfo ParentCleanup,
6402 Decl *ManglingContextDecl,
6403 ExpressionKind ExprContext)
6404 : Context(Context), ParentCleanup(ParentCleanup),
6405 NumCleanupObjects(NumCleanupObjects), NumTypos(0),
6406 ManglingContextDecl(ManglingContextDecl), ExprContext(ExprContext),
6407 InDiscardedStatement(false), InImmediateFunctionContext(false),
6408 InImmediateEscalatingFunctionContext(false) {}
6409
6410 bool isUnevaluated() const {
6411 return Context == ExpressionEvaluationContext::Unevaluated ||
6412 Context == ExpressionEvaluationContext::UnevaluatedAbstract ||
6413 Context == ExpressionEvaluationContext::UnevaluatedList;
6414 }
6415
6417 return Context == ExpressionEvaluationContext::PotentiallyEvaluated ||
6418 Context ==
6419 ExpressionEvaluationContext::PotentiallyEvaluatedIfUsed ||
6420 Context == ExpressionEvaluationContext::ConstantEvaluated;
6421 }
6422
6423 bool isConstantEvaluated() const {
6424 return Context == ExpressionEvaluationContext::ConstantEvaluated ||
6425 Context == ExpressionEvaluationContext::ImmediateFunctionContext;
6426 }
6427
6429 return Context == ExpressionEvaluationContext::ImmediateFunctionContext ||
6430 (Context == ExpressionEvaluationContext::DiscardedStatement &&
6431 InImmediateFunctionContext) ||
6432 // C++23 [expr.const]p14:
6433 // An expression or conversion is in an immediate function
6434 // context if it is potentially evaluated and either:
6435 // * its innermost enclosing non-block scope is a function
6436 // parameter scope of an immediate function, or
6437 // * its enclosing statement is enclosed by the compound-
6438 // statement of a consteval if statement.
6439 (Context == ExpressionEvaluationContext::PotentiallyEvaluated &&
6440 InImmediateFunctionContext);
6441 }
6442
6444 return Context == ExpressionEvaluationContext::DiscardedStatement ||
6445 (Context ==
6446 ExpressionEvaluationContext::ImmediateFunctionContext &&
6447 InDiscardedStatement);
6448 }
6449 };
6450
6452 assert(!ExprEvalContexts.empty() &&
6453 "Must be in an expression evaluation context");
6454 return ExprEvalContexts.back();
6455 };
6456
6458 assert(!ExprEvalContexts.empty() &&
6459 "Must be in an expression evaluation context");
6460 return ExprEvalContexts.back();
6461 };
6462
6464 assert(ExprEvalContexts.size() >= 2 &&
6465 "Must be in an expression evaluation context");
6466 return ExprEvalContexts[ExprEvalContexts.size() - 2];
6467 };
6468
6470 return const_cast<Sema *>(this)->parentEvaluationContext();
6471 };
6472
6473 bool isAttrContext() const {
6474 return ExprEvalContexts.back().ExprContext ==
6476 }
6477
6478 /// Increment when we find a reference; decrement when we find an ignored
6479 /// assignment. Ultimately the value is 0 if every reference is an ignored
6480 /// assignment.
6481 llvm::DenseMap<const VarDecl *, int> RefsMinusAssignments;
6482
6483 /// Used to control the generation of ExprWithCleanups.
6485
6486 /// ExprCleanupObjects - This is the stack of objects requiring
6487 /// cleanup that are created by the current full expression.
6489
6490 /// Determine whether the use of this declaration is valid, without
6491 /// emitting diagnostics.
6492 bool CanUseDecl(NamedDecl *D, bool TreatUnavailableAsInvalid);
6493 // A version of DiagnoseUseOfDecl that should be used if overload resolution
6494 // has been used to find this declaration, which means we don't have to bother
6495 // checking the trailing requires clause.
6497 return DiagnoseUseOfDecl(
6498 D, Loc, /*UnknownObjCClass=*/nullptr, /*ObjCPropertyAccess=*/false,
6499 /*AvoidPartialAvailabilityChecks=*/false, /*ClassReceiver=*/nullptr,
6500 /*SkipTrailingRequiresClause=*/true);
6501 }
6502
6503 /// Determine whether the use of this declaration is valid, and
6504 /// emit any corresponding diagnostics.
6505 ///
6506 /// This routine diagnoses various problems with referencing
6507 /// declarations that can occur when using a declaration. For example,
6508 /// it might warn if a deprecated or unavailable declaration is being
6509 /// used, or produce an error (and return true) if a C++0x deleted
6510 /// function is being used.
6511 ///
6512 /// \returns true if there was an error (this declaration cannot be
6513 /// referenced), false otherwise.
6515 const ObjCInterfaceDecl *UnknownObjCClass = nullptr,
6516 bool ObjCPropertyAccess = false,
6517 bool AvoidPartialAvailabilityChecks = false,
6518 ObjCInterfaceDecl *ClassReciever = nullptr,
6519 bool SkipTrailingRequiresClause = false);
6520
6521 /// Emit a note explaining that this function is deleted.
6523
6524 /// DiagnoseSentinelCalls - This routine checks whether a call or
6525 /// message-send is to a declaration with the sentinel attribute, and
6526 /// if so, it checks that the requirements of the sentinel are
6527 /// satisfied.
6529 ArrayRef<Expr *> Args);
6530
6532 ExpressionEvaluationContext NewContext, Decl *LambdaContextDecl = nullptr,
6541
6543
6547
6548 /// Check whether E, which is either a discarded-value expression or an
6549 /// unevaluated operand, is a simple-assignment to a volatlie-qualified
6550 /// lvalue, and if so, remove it from the list of volatile-qualified
6551 /// assignments that we are going to warn are deprecated.
6553
6555
6556 // Functions for marking a declaration referenced. These functions also
6557 // contain the relevant logic for marking if a reference to a function or
6558 // variable is an odr-use (in the C++11 sense). There are separate variants
6559 // for expressions referring to a decl; these exist because odr-use marking
6560 // needs to be delayed for some constant variables when we build one of the
6561 // named expressions.
6562 //
6563 // MightBeOdrUse indicates whether the use could possibly be an odr-use, and
6564 // should usually be true. This only needs to be set to false if the lack of
6565 // odr-use cannot be determined from the current context (for instance,
6566 // because the name denotes a virtual function and was written without an
6567 // explicit nested-name-specifier).
6568 void MarkAnyDeclReferenced(SourceLocation Loc, Decl *D, bool MightBeOdrUse);
6569
6570 /// Mark a function referenced, and check whether it is odr-used
6571 /// (C++ [basic.def.odr]p2, C99 6.9p3)
6573 bool MightBeOdrUse = true);
6574
6575 /// Mark a variable referenced, and check whether it is odr-used
6576 /// (C++ [basic.def.odr]p2, C99 6.9p3). Note that this should not be
6577 /// used directly for normal expressions referring to VarDecl.
6579
6580 /// Perform reference-marking and odr-use handling for a DeclRefExpr.
6581 ///
6582 /// Note, this may change the dependence of the DeclRefExpr, and so needs to
6583 /// be handled with care if the DeclRefExpr is not newly-created.
6584 void MarkDeclRefReferenced(DeclRefExpr *E, const Expr *Base = nullptr);
6585
6586 /// Perform reference-marking and odr-use handling for a MemberExpr.
6588
6589 /// Perform reference-marking and odr-use handling for a FunctionParmPackExpr.
6592 unsigned CapturingScopeIndex);
6593
6595 void CleanupVarDeclMarking();
6596
6602
6603 /// Try to capture the given variable.
6604 ///
6605 /// \param Var The variable to capture.
6606 ///
6607 /// \param Loc The location at which the capture occurs.
6608 ///
6609 /// \param Kind The kind of capture, which may be implicit (for either a
6610 /// block or a lambda), or explicit by-value or by-reference (for a lambda).
6611 ///
6612 /// \param EllipsisLoc The location of the ellipsis, if one is provided in
6613 /// an explicit lambda capture.
6614 ///
6615 /// \param BuildAndDiagnose Whether we are actually supposed to add the
6616 /// captures or diagnose errors. If false, this routine merely check whether
6617 /// the capture can occur without performing the capture itself or complaining
6618 /// if the variable cannot be captured.
6619 ///
6620 /// \param CaptureType Will be set to the type of the field used to capture
6621 /// this variable in the innermost block or lambda. Only valid when the
6622 /// variable can be captured.
6623 ///
6624 /// \param DeclRefType Will be set to the type of a reference to the capture
6625 /// from within the current scope. Only valid when the variable can be
6626 /// captured.
6627 ///
6628 /// \param FunctionScopeIndexToStopAt If non-null, it points to the index
6629 /// of the FunctionScopeInfo stack beyond which we do not attempt to capture.
6630 /// This is useful when enclosing lambdas must speculatively capture
6631 /// variables that may or may not be used in certain specializations of
6632 /// a nested generic lambda.
6633 ///
6634 /// \returns true if an error occurred (i.e., the variable cannot be
6635 /// captured) and false if the capture succeeded.
6637 TryCaptureKind Kind, SourceLocation EllipsisLoc,
6638 bool BuildAndDiagnose, QualType &CaptureType,
6639 QualType &DeclRefType,
6640 const unsigned *const FunctionScopeIndexToStopAt);
6641
6642 /// Try to capture the given variable.
6645 SourceLocation EllipsisLoc = SourceLocation());
6646
6647 /// Checks if the variable must be captured.
6649
6650 /// Given a variable, determine the type that a reference to that
6651 /// variable will have in the given scope.
6653
6654 /// Mark all of the declarations referenced within a particular AST node as
6655 /// referenced. Used when template instantiation instantiates a non-dependent
6656 /// type -- entities referenced by the type are now referenced.
6658
6659 /// Mark any declarations that appear within this expression or any
6660 /// potentially-evaluated subexpressions as "referenced".
6661 ///
6662 /// \param SkipLocalVariables If true, don't mark local variables as
6663 /// 'referenced'.
6664 /// \param StopAt Subexpressions that we shouldn't recurse into.
6666 bool SkipLocalVariables = false,
6667 ArrayRef<const Expr *> StopAt = {});
6668
6669 /// Try to convert an expression \p E to type \p Ty. Returns the result of the
6670 /// conversion.
6671 ExprResult tryConvertExprToType(Expr *E, QualType Ty);
6672
6673 /// Conditionally issue a diagnostic based on the statements's reachability
6674 /// analysis.
6675 ///
6676 /// \param Stmts If Stmts is non-empty, delay reporting the diagnostic until
6677 /// the function body is parsed, and then do a basic reachability analysis to
6678 /// determine if the statement is reachable. If it is unreachable, the
6679 /// diagnostic will not be emitted.
6680 bool DiagIfReachable(SourceLocation Loc, ArrayRef<const Stmt *> Stmts,
6681 const PartialDiagnostic &PD);
6682
6683 /// Conditionally issue a diagnostic based on the current
6684 /// evaluation context.
6685 ///
6686 /// \param Statement If Statement is non-null, delay reporting the
6687 /// diagnostic until the function body is parsed, and then do a basic
6688 /// reachability analysis to determine if the statement is reachable.
6689 /// If it is unreachable, the diagnostic will not be emitted.
6690 bool DiagRuntimeBehavior(SourceLocation Loc, const Stmt *Statement,
6691 const PartialDiagnostic &PD);
6692 /// Similar, but diagnostic is only produced if all the specified statements
6693 /// are reachable.
6694 bool DiagRuntimeBehavior(SourceLocation Loc, ArrayRef<const Stmt *> Stmts,
6695 const PartialDiagnostic &PD);
6696
6697 // Primary Expressions.
6698 SourceRange getExprRange(Expr *E) const;
6699
6700 ExprResult ActOnIdExpression(Scope *S, CXXScopeSpec &SS,
6701 SourceLocation TemplateKWLoc, UnqualifiedId &Id,
6702 bool HasTrailingLParen, bool IsAddressOfOperand,
6703 CorrectionCandidateCallback *CCC = nullptr,
6704 bool IsInlineAsmIdentifier = false,
6705 Token *KeywordReplacement = nullptr);
6706
6707 /// Decomposes the given name into a DeclarationNameInfo, its location, and
6708 /// possibly a list of template arguments.
6709 ///
6710 /// If this produces template arguments, it is permitted to call
6711 /// DecomposeTemplateName.
6712 ///
6713 /// This actually loses a lot of source location information for
6714 /// non-standard name kinds; we should consider preserving that in
6715 /// some way.
6716 void DecomposeUnqualifiedId(const UnqualifiedId &Id,
6717 TemplateArgumentListInfo &Buffer,
6718 DeclarationNameInfo &NameInfo,
6719 const TemplateArgumentListInfo *&TemplateArgs);
6720
6721 /// Diagnose a lookup that found results in an enclosing class during error
6722 /// recovery. This usually indicates that the results were found in a
6723 /// dependent base class that could not be searched as part of a template
6724 /// definition. Always issues a diagnostic (though this may be only a warning
6725 /// in MS compatibility mode).
6726 ///
6727 /// Return \c true if the error is unrecoverable, or \c false if the caller
6728 /// should attempt to recover using these lookup results.
6729 bool DiagnoseDependentMemberLookup(const LookupResult &R);
6730
6731 /// Diagnose an empty lookup.
6732 ///
6733 /// \return false if new lookup candidates were found
6734 bool
6735 DiagnoseEmptyLookup(Scope *S, CXXScopeSpec &SS, LookupResult &R,
6736 CorrectionCandidateCallback &CCC,
6737 TemplateArgumentListInfo *ExplicitTemplateArgs = nullptr,
6738 ArrayRef<Expr *> Args = {},
6739 DeclContext *LookupCtx = nullptr,
6740 TypoExpr **Out = nullptr);
6741
6742 /// If \p D cannot be odr-used in the current expression evaluation context,
6743 /// return a reason explaining why. Otherwise, return NOUR_None.
6745
6746 DeclRefExpr *BuildDeclRefExpr(ValueDecl *D, QualType Ty, ExprValueKind VK,
6747 SourceLocation Loc,
6748 const CXXScopeSpec *SS = nullptr);
6749 DeclRefExpr *
6750 BuildDeclRefExpr(ValueDecl *D, QualType Ty, ExprValueKind VK,
6751 const DeclarationNameInfo &NameInfo,
6752 const CXXScopeSpec *SS = nullptr,
6753 NamedDecl *FoundD = nullptr,
6754 SourceLocation TemplateKWLoc = SourceLocation(),
6755 const TemplateArgumentListInfo *TemplateArgs = nullptr);
6756
6757 /// BuildDeclRefExpr - Build an expression that references a
6758 /// declaration that does not require a closure capture.
6759 DeclRefExpr *
6760 BuildDeclRefExpr(ValueDecl *D, QualType Ty, ExprValueKind VK,
6761 const DeclarationNameInfo &NameInfo,
6762 NestedNameSpecifierLoc NNS, NamedDecl *FoundD = nullptr,
6763 SourceLocation TemplateKWLoc = SourceLocation(),
6764 const TemplateArgumentListInfo *TemplateArgs = nullptr);
6765
6766 bool UseArgumentDependentLookup(const CXXScopeSpec &SS, const LookupResult &R,
6767 bool HasTrailingLParen);
6768
6769 /// BuildQualifiedDeclarationNameExpr - Build a C++ qualified
6770 /// declaration name, generally during template instantiation.
6771 /// There's a large number of things which don't need to be done along
6772 /// this path.
6774 CXXScopeSpec &SS, const DeclarationNameInfo &NameInfo,
6775 bool IsAddressOfOperand, TypeSourceInfo **RecoveryTSI = nullptr);
6776
6777 ExprResult BuildDeclarationNameExpr(const CXXScopeSpec &SS, LookupResult &R,
6778 bool NeedsADL,
6779 bool AcceptInvalidDecl = false);
6780
6781 /// Complete semantic analysis for a reference to the given declaration.
6783 const CXXScopeSpec &SS, const DeclarationNameInfo &NameInfo, NamedDecl *D,
6784 NamedDecl *FoundD = nullptr,
6785 const TemplateArgumentListInfo *TemplateArgs = nullptr,
6786 bool AcceptInvalidDecl = false);
6787
6788 // ExpandFunctionLocalPredefinedMacros - Returns a new vector of Tokens,
6789 // where Tokens representing function local predefined macros (such as
6790 // __FUNCTION__) are replaced (expanded) with string-literal Tokens.
6791 std::vector<Token> ExpandFunctionLocalPredefinedMacros(ArrayRef<Token> Toks);
6792
6795 ExprResult ActOnIntegerConstant(SourceLocation Loc, int64_t Val);
6796
6797 bool CheckLoopHintExpr(Expr *E, SourceLocation Loc, bool AllowZero);
6798
6799 ExprResult ActOnNumericConstant(const Token &Tok, Scope *UDLScope = nullptr);
6800 ExprResult ActOnCharacterConstant(const Token &Tok,
6801 Scope *UDLScope = nullptr);
6802 ExprResult ActOnParenExpr(SourceLocation L, SourceLocation R, Expr *E);
6803 ExprResult ActOnParenListExpr(SourceLocation L, SourceLocation R,
6804 MultiExprArg Val);
6805
6806 /// ActOnStringLiteral - The specified tokens were lexed as pasted string
6807 /// fragments (e.g. "foo" "bar" L"baz"). The result string has to handle
6808 /// string concatenation ([C99 5.1.1.2, translation phase #6]), so it may come
6809 /// from multiple tokens. However, the common case is that StringToks points
6810 /// to one string.
6811 ExprResult ActOnStringLiteral(ArrayRef<Token> StringToks,
6812 Scope *UDLScope = nullptr);
6813
6814 ExprResult ActOnUnevaluatedStringLiteral(ArrayRef<Token> StringToks);
6815
6816 /// ControllingExprOrType is either an opaque pointer coming out of a
6817 /// ParsedType or an Expr *. FIXME: it'd be better to split this interface
6818 /// into two so we don't take a void *, but that's awkward because one of
6819 /// the operands is either a ParsedType or an Expr *, which doesn't lend
6820 /// itself to generic code very well.
6821 ExprResult ActOnGenericSelectionExpr(SourceLocation KeyLoc,
6822 SourceLocation DefaultLoc,
6823 SourceLocation RParenLoc,
6824 bool PredicateIsExpr,
6825 void *ControllingExprOrType,
6826 ArrayRef<ParsedType> ArgTypes,
6827 ArrayRef<Expr *> ArgExprs);
6828 /// ControllingExprOrType is either a TypeSourceInfo * or an Expr *. FIXME:
6829 /// it'd be better to split this interface into two so we don't take a
6830 /// void *, but see the FIXME on ActOnGenericSelectionExpr as to why that
6831 /// isn't a trivial change.
6832 ExprResult CreateGenericSelectionExpr(SourceLocation KeyLoc,
6833 SourceLocation DefaultLoc,
6834 SourceLocation RParenLoc,
6835 bool PredicateIsExpr,
6836 void *ControllingExprOrType,
6837 ArrayRef<TypeSourceInfo *> Types,
6838 ArrayRef<Expr *> Exprs);
6839
6840 // Binary/Unary Operators. 'Tok' is the token for the operator.
6841 ExprResult CreateBuiltinUnaryOp(SourceLocation OpLoc, UnaryOperatorKind Opc,
6842 Expr *InputExpr, bool IsAfterAmp = false);
6843 ExprResult BuildUnaryOp(Scope *S, SourceLocation OpLoc, UnaryOperatorKind Opc,
6844 Expr *Input, bool IsAfterAmp = false);
6845
6846 /// Unary Operators. 'Tok' is the token for the operator.
6847 ExprResult ActOnUnaryOp(Scope *S, SourceLocation OpLoc, tok::TokenKind Op,
6848 Expr *Input, bool IsAfterAmp = false);
6849
6850 /// Determine whether the given expression is a qualified member
6851 /// access expression, of a form that could be turned into a pointer to member
6852 /// with the address-of operator.
6853 bool isQualifiedMemberAccess(Expr *E);
6854 bool CheckUseOfCXXMethodAsAddressOfOperand(SourceLocation OpLoc,
6855 const Expr *Op,
6856 const CXXMethodDecl *MD);
6857
6858 /// CheckAddressOfOperand - The operand of & must be either a function
6859 /// designator or an lvalue designating an object. If it is an lvalue, the
6860 /// object cannot be declared with storage class register or be a bit field.
6861 /// Note: The usual conversions are *not* applied to the operand of the &
6862 /// operator (C99 6.3.2.1p[2-4]), and its result is never an lvalue.
6863 /// In C++, the operand might be an overloaded function name, in which case
6864 /// we allow the '&' but retain the overloaded-function type.
6865 QualType CheckAddressOfOperand(ExprResult &Operand, SourceLocation OpLoc);
6866
6867 /// ActOnAlignasTypeArgument - Handle @c alignas(type-id) and @c
6868 /// _Alignas(type-name) .
6869 /// [dcl.align] An alignment-specifier of the form
6870 /// alignas(type-id) has the same effect as alignas(alignof(type-id)).
6871 ///
6872 /// [N1570 6.7.5] _Alignas(type-name) is equivalent to
6873 /// _Alignas(_Alignof(type-name)).
6874 bool ActOnAlignasTypeArgument(StringRef KWName, ParsedType Ty,
6875 SourceLocation OpLoc, SourceRange R);
6876 bool CheckAlignasTypeArgument(StringRef KWName, TypeSourceInfo *TInfo,
6877 SourceLocation OpLoc, SourceRange R);
6878
6879 /// Build a sizeof or alignof expression given a type operand.
6880 ExprResult CreateUnaryExprOrTypeTraitExpr(TypeSourceInfo *TInfo,
6881 SourceLocation OpLoc,
6882 UnaryExprOrTypeTrait ExprKind,
6883 SourceRange R);
6884
6885 /// Build a sizeof or alignof expression given an expression
6886 /// operand.
6887 ExprResult CreateUnaryExprOrTypeTraitExpr(Expr *E, SourceLocation OpLoc,
6888 UnaryExprOrTypeTrait ExprKind);
6889
6890 /// ActOnUnaryExprOrTypeTraitExpr - Handle @c sizeof(type) and @c sizeof @c
6891 /// expr and the same for @c alignof and @c __alignof
6892 /// Note that the ArgRange is invalid if isType is false.
6893 ExprResult ActOnUnaryExprOrTypeTraitExpr(SourceLocation OpLoc,
6894 UnaryExprOrTypeTrait ExprKind,
6895 bool IsType, void *TyOrEx,
6896 SourceRange ArgRange);
6897
6898 /// Check for operands with placeholder types and complain if found.
6899 /// Returns ExprError() if there was an error and no recovery was possible.
6901 bool CheckVecStepExpr(Expr *E);
6902
6903 /// Check the constraints on expression operands to unary type expression
6904 /// and type traits.
6905 ///
6906 /// Completes any types necessary and validates the constraints on the operand
6907 /// expression. The logic mostly mirrors the type-based overload, but may
6908 /// modify the expression as it completes the type for that expression through
6909 /// template instantiation, etc.
6911
6912 /// Check the constraints on operands to unary expression and type
6913 /// traits.
6914 ///
6915 /// This will complete any types necessary, and validate the various
6916 /// constraints on those operands.
6917 ///
6918 /// The UsualUnaryConversions() function is *not* called by this routine.
6919 /// C99 6.3.2.1p[2-4] all state:
6920 /// Except when it is the operand of the sizeof operator ...
6921 ///
6922 /// C++ [expr.sizeof]p4
6923 /// The lvalue-to-rvalue, array-to-pointer, and function-to-pointer
6924 /// standard conversions are not applied to the operand of sizeof.
6925 ///
6926 /// This policy is followed for all of the unary trait expressions.
6927 bool CheckUnaryExprOrTypeTraitOperand(QualType ExprType, SourceLocation OpLoc,
6928 SourceRange ExprRange,
6929 UnaryExprOrTypeTrait ExprKind,
6930 StringRef KWName);
6931
6932 ExprResult ActOnPostfixUnaryOp(Scope *S, SourceLocation OpLoc,
6933 tok::TokenKind Kind, Expr *Input);
6934
6935 ExprResult ActOnArraySubscriptExpr(Scope *S, Expr *Base, SourceLocation LLoc,
6936 MultiExprArg ArgExprs,
6937 SourceLocation RLoc);
6938 ExprResult CreateBuiltinArraySubscriptExpr(Expr *Base, SourceLocation LLoc,
6939 Expr *Idx, SourceLocation RLoc);
6940
6942 Expr *ColumnIdx,
6943 SourceLocation RBLoc);
6944
6945 /// ConvertArgumentsForCall - Converts the arguments specified in
6946 /// Args/NumArgs to the parameter types of the function FDecl with
6947 /// function prototype Proto. Call is the call expression itself, and
6948 /// Fn is the function expression. For a C++ member function, this
6949 /// routine does not attempt to convert the object argument. Returns
6950 /// true if the call is ill-formed.
6951 bool ConvertArgumentsForCall(CallExpr *Call, Expr *Fn, FunctionDecl *FDecl,
6952 const FunctionProtoType *Proto,
6953 ArrayRef<Expr *> Args, SourceLocation RParenLoc,
6954 bool ExecConfig = false);
6955
6956 /// CheckStaticArrayArgument - If the given argument corresponds to a static
6957 /// array parameter, check that it is non-null, and that if it is formed by
6958 /// array-to-pointer decay, the underlying array is sufficiently large.
6959 ///
6960 /// C99 6.7.5.3p7: If the keyword static also appears within the [ and ] of
6961 /// the array type derivation, then for each call to the function, the value
6962 /// of the corresponding actual argument shall provide access to the first
6963 /// element of an array with at least as many elements as specified by the
6964 /// size expression.
6965 void CheckStaticArrayArgument(SourceLocation CallLoc, ParmVarDecl *Param,
6966 const Expr *ArgExpr);
6967
6968 /// ActOnCallExpr - Handle a call to Fn with the specified array of arguments.
6969 /// This provides the location of the left/right parens and a list of comma
6970 /// locations.
6971 ExprResult ActOnCallExpr(Scope *S, Expr *Fn, SourceLocation LParenLoc,
6972 MultiExprArg ArgExprs, SourceLocation RParenLoc,
6973 Expr *ExecConfig = nullptr);
6974
6975 /// BuildCallExpr - Handle a call to Fn with the specified array of arguments.
6976 /// This provides the location of the left/right parens and a list of comma
6977 /// locations.
6978 ExprResult BuildCallExpr(Scope *S, Expr *Fn, SourceLocation LParenLoc,
6979 MultiExprArg ArgExprs, SourceLocation RParenLoc,
6980 Expr *ExecConfig = nullptr,
6981 bool IsExecConfig = false,
6982 bool AllowRecovery = false);
6983
6984 /// BuildBuiltinCallExpr - Create a call to a builtin function specified by Id
6985 // with the specified CallArgs
6986 Expr *BuildBuiltinCallExpr(SourceLocation Loc, Builtin::ID Id,
6987 MultiExprArg CallArgs);
6988
6990
6991 /// BuildResolvedCallExpr - Build a call to a resolved expression,
6992 /// i.e. an expression not of \p OverloadTy. The expression should
6993 /// unary-convert to an expression of function-pointer or
6994 /// block-pointer type.
6995 ///
6996 /// \param NDecl the declaration being called, if available
6998 BuildResolvedCallExpr(Expr *Fn, NamedDecl *NDecl, SourceLocation LParenLoc,
6999 ArrayRef<Expr *> Arg, SourceLocation RParenLoc,
7000 Expr *Config = nullptr, bool IsExecConfig = false,
7001 ADLCallKind UsesADL = ADLCallKind::NotADL);
7002
7004 ParsedType &Ty, SourceLocation RParenLoc,
7005 Expr *CastExpr);
7006
7007 /// Prepares for a scalar cast, performing all the necessary stages
7008 /// except the final cast and returning the kind required.
7010
7011 /// Build an altivec or OpenCL literal.
7013 SourceLocation RParenLoc, Expr *E,
7014 TypeSourceInfo *TInfo);
7015
7016 /// This is not an AltiVec-style cast or or C++ direct-initialization, so turn
7017 /// the ParenListExpr into a sequence of comma binary operators.
7019
7021 SourceLocation RParenLoc, Expr *InitExpr);
7022
7024 TypeSourceInfo *TInfo,
7025 SourceLocation RParenLoc,
7026 Expr *LiteralExpr);
7027
7028 ExprResult ActOnInitList(SourceLocation LBraceLoc, MultiExprArg InitArgList,
7029 SourceLocation RBraceLoc);
7030
7031 ExprResult BuildInitList(SourceLocation LBraceLoc, MultiExprArg InitArgList,
7032 SourceLocation RBraceLoc);
7033
7034 /// Binary Operators. 'Tok' is the token for the operator.
7036 Expr *LHSExpr, Expr *RHSExpr);
7038 Expr *LHSExpr, Expr *RHSExpr);
7039
7040 /// CreateBuiltinBinOp - Creates a new built-in binary operation with
7041 /// operator @p Opc at location @c TokLoc. This routine only supports
7042 /// built-in operations; ActOnBinOp handles overloaded operators.
7044 Expr *LHSExpr, Expr *RHSExpr);
7046 UnresolvedSetImpl &Functions);
7047
7048 /// Look for instances where it is likely the comma operator is confused with
7049 /// another operator. There is an explicit list of acceptable expressions for
7050 /// the left hand side of the comma operator, otherwise emit a warning.
7051 void DiagnoseCommaOperator(const Expr *LHS, SourceLocation Loc);
7052
7053 /// ActOnConditionalOp - Parse a ?: operation. Note that 'LHS' may be null
7054 /// in the case of a the GNU conditional expr extension.
7056 SourceLocation ColonLoc, Expr *CondExpr,
7057 Expr *LHSExpr, Expr *RHSExpr);
7058
7059 /// ActOnAddrLabel - Parse the GNU address of label extension: "&&foo".
7061 LabelDecl *TheDecl);
7062
7063 void ActOnStartStmtExpr();
7064 ExprResult ActOnStmtExpr(Scope *S, SourceLocation LPLoc, Stmt *SubStmt,
7065 SourceLocation RPLoc);
7067 SourceLocation RPLoc, unsigned TemplateDepth);
7068 // Handle the final expression in a statement expression.
7070 void ActOnStmtExprError();
7071
7072 // __builtin_offsetof(type, identifier(.identifier|[expr])*)
7075 bool isBrackets; // true if [expr], false if .ident
7076 union {
7079 } U;
7080 };
7081
7082 /// __builtin_offsetof(type, a.b[123][456].c)
7084 TypeSourceInfo *TInfo,
7085 ArrayRef<OffsetOfComponent> Components,
7086 SourceLocation RParenLoc);
7089 ParsedType ParsedArgTy,
7090 ArrayRef<OffsetOfComponent> Components,
7091 SourceLocation RParenLoc);
7092
7093 // __builtin_choose_expr(constExpr, expr1, expr2)
7094 ExprResult ActOnChooseExpr(SourceLocation BuiltinLoc, Expr *CondExpr,
7095 Expr *LHSExpr, Expr *RHSExpr,
7096 SourceLocation RPLoc);
7097
7098 // __builtin_va_arg(expr, type)
7100 SourceLocation RPLoc);
7102 TypeSourceInfo *TInfo, SourceLocation RPLoc);
7103
7104 // __builtin_LINE(), __builtin_FUNCTION(), __builtin_FUNCSIG(),
7105 // __builtin_FILE(), __builtin_COLUMN(), __builtin_source_location()
7107 SourceLocation BuiltinLoc,
7108 SourceLocation RPLoc);
7109
7110 // #embed
7112 StringLiteral *BinaryData);
7113
7114 // Build a potentially resolved SourceLocExpr.
7116 SourceLocation BuiltinLoc, SourceLocation RPLoc,
7117 DeclContext *ParentContext);
7118
7119 // __null
7121
7122 bool CheckCaseExpression(Expr *E);
7123
7124 //===------------------------- "Block" Extension ------------------------===//
7125
7126 /// ActOnBlockStart - This callback is invoked when a block literal is
7127 /// started.
7128 void ActOnBlockStart(SourceLocation CaretLoc, Scope *CurScope);
7129
7130 /// ActOnBlockArguments - This callback allows processing of block arguments.
7131 /// If there are no arguments, this is still invoked.
7132 void ActOnBlockArguments(SourceLocation CaretLoc, Declarator &ParamInfo,
7133 Scope *CurScope);
7134
7135 /// ActOnBlockError - If there is an error parsing a block, this callback
7136 /// is invoked to pop the information about the block from the action impl.
7137 void ActOnBlockError(SourceLocation CaretLoc, Scope *CurScope);
7138
7139 /// ActOnBlockStmtExpr - This is called when the body of a block statement
7140 /// literal was successfully completed. ^(int x){...}
7142 Scope *CurScope);
7143
7144 //===---------------------------- Clang Extensions ----------------------===//
7145
7146 /// ActOnConvertVectorExpr - create a new convert-vector expression from the
7147 /// provided arguments.
7148 ///
7149 /// __builtin_convertvector( value, dst type )
7150 ///
7152 SourceLocation BuiltinLoc,
7153 SourceLocation RParenLoc);
7154
7155 //===---------------------------- OpenCL Features -----------------------===//
7156
7157 /// Parse a __builtin_astype expression.
7158 ///
7159 /// __builtin_astype( value, dst type )
7160 ///
7162 SourceLocation BuiltinLoc,
7163 SourceLocation RParenLoc);
7164
7165 /// Create a new AsTypeExpr node (bitcast) from the arguments.
7167 SourceLocation BuiltinLoc,
7168 SourceLocation RParenLoc);
7169
7170 /// Attempts to produce a RecoveryExpr after some AST node cannot be created.
7172 ArrayRef<Expr *> SubExprs,
7173 QualType T = QualType());
7174
7175 /// Cast a base object to a member's actual type.
7176 ///
7177 /// There are two relevant checks:
7178 ///
7179 /// C++ [class.access.base]p7:
7180 ///
7181 /// If a class member access operator [...] is used to access a non-static
7182 /// data member or non-static member function, the reference is ill-formed
7183 /// if the left operand [...] cannot be implicitly converted to a pointer to
7184 /// the naming class of the right operand.
7185 ///
7186 /// C++ [expr.ref]p7:
7187 ///
7188 /// If E2 is a non-static data member or a non-static member function, the
7189 /// program is ill-formed if the class of which E2 is directly a member is
7190 /// an ambiguous base (11.8) of the naming class (11.9.3) of E2.
7191 ///
7192 /// Note that the latter check does not consider access; the access of the
7193 /// "real" base class is checked as appropriate when checking the access of
7194 /// the member name.
7196 NestedNameSpecifier *Qualifier,
7197 NamedDecl *FoundDecl,
7198 NamedDecl *Member);
7199
7200 /// CheckCallReturnType - Checks that a call expression's return type is
7201 /// complete. Returns true on failure. The location passed in is the location
7202 /// that best represents the call.
7204 CallExpr *CE, FunctionDecl *FD);
7205
7206 /// Emit a warning for all pending noderef expressions that we recorded.
7207 void WarnOnPendingNoDerefs(ExpressionEvaluationContextRecord &Rec);
7208
7210
7211 /// Instantiate or parse a C++ default argument expression as necessary.
7212 /// Return true on error.
7214 ParmVarDecl *Param, Expr *Init = nullptr,
7215 bool SkipImmediateInvocations = true);
7216
7217 /// BuildCXXDefaultArgExpr - Creates a CXXDefaultArgExpr, instantiating
7218 /// the default expr if needed.
7220 ParmVarDecl *Param, Expr *Init = nullptr);
7221
7222 /// Wrap the expression in a ConstantExpr if it is a potential immediate
7223 /// invocation.
7225
7227
7228 // Check that the SME attributes for PSTATE.ZA and PSTATE.SM are compatible.
7229 bool IsInvalidSMECallConversion(QualType FromType, QualType ToType);
7230
7231 /// Abstract base class used for diagnosing integer constant
7232 /// expression violations.
7234 public:
7236
7237 VerifyICEDiagnoser(bool Suppress = false) : Suppress(Suppress) {}
7238
7239 virtual SemaDiagnosticBuilder
7240 diagnoseNotICEType(Sema &S, SourceLocation Loc, QualType T);
7242 SourceLocation Loc) = 0;
7243 virtual SemaDiagnosticBuilder diagnoseFold(Sema &S, SourceLocation Loc);
7245 };
7246
7250 };
7251
7252 /// VerifyIntegerConstantExpression - Verifies that an expression is an ICE,
7253 /// and reports the appropriate diagnostics. Returns false on success.
7254 /// Can optionally return the value of the expression.
7256 VerifyICEDiagnoser &Diagnoser,
7257 AllowFoldKind CanFold = NoFold);
7259 unsigned DiagID,
7260 AllowFoldKind CanFold = NoFold);
7262 llvm::APSInt *Result = nullptr,
7263 AllowFoldKind CanFold = NoFold);
7265 AllowFoldKind CanFold = NoFold) {
7266 return VerifyIntegerConstantExpression(E, nullptr, CanFold);
7267 }
7268
7269 /// DiagnoseAssignmentAsCondition - Given that an expression is
7270 /// being used as a boolean condition, warn if it's an assignment.
7272
7273 /// Redundant parentheses over an equality comparison can indicate
7274 /// that the user intended an assignment used as condition.
7276
7278 public:
7279 FullExprArg() : E(nullptr) {}
7280 FullExprArg(Sema &actions) : E(nullptr) {}
7281
7282 ExprResult release() { return E; }
7283
7284 Expr *get() const { return E; }
7285
7286 Expr *operator->() { return E; }
7287
7288 private:
7289 // FIXME: No need to make the entire Sema class a friend when it's just
7290 // Sema::MakeFullExpr that needs access to the constructor below.
7291 friend class Sema;
7292
7293 explicit FullExprArg(Expr *expr) : E(expr) {}
7294
7295 Expr *E;
7296 };
7297
7299 return MakeFullExpr(Arg, Arg ? Arg->getExprLoc() : SourceLocation());
7300 }
7302 return FullExprArg(
7303 ActOnFinishFullExpr(Arg, CC, /*DiscardedValue*/ false).get());
7304 }
7306 ExprResult FE =
7307 ActOnFinishFullExpr(Arg, Arg ? Arg->getExprLoc() : SourceLocation(),
7308 /*DiscardedValue*/ true);
7309 return FullExprArg(FE.get());
7310 }
7311
7313 Decl *ConditionVar;
7315 bool Invalid;
7316 std::optional<bool> KnownValue;
7317
7318 friend class Sema;
7319 ConditionResult(Sema &S, Decl *ConditionVar, FullExprArg Condition,
7320 bool IsConstexpr)
7321 : ConditionVar(ConditionVar), Condition(Condition), Invalid(false) {
7322 if (IsConstexpr && Condition.get()) {
7323 if (std::optional<llvm::APSInt> Val =
7324 Condition.get()->getIntegerConstantExpr(S.Context)) {
7325 KnownValue = !!(*Val);
7326 }
7327 }
7328 }
7329 explicit ConditionResult(bool Invalid)
7330 : ConditionVar(nullptr), Condition(nullptr), Invalid(Invalid),
7331 KnownValue(std::nullopt) {}
7332
7333 public:
7335 bool isInvalid() const { return Invalid; }
7336 std::pair<VarDecl *, Expr *> get() const {
7337 return std::make_pair(cast_or_null<VarDecl>(ConditionVar),
7338 Condition.get());
7339 }
7340 std::optional<bool> getKnownValue() const { return KnownValue; }
7341 };
7343
7344 /// CheckBooleanCondition - Diagnose problems involving the use of
7345 /// the given expression as a boolean condition (e.g. in an if
7346 /// statement). Also performs the standard function and array
7347 /// decays, possibly changing the input variable.
7348 ///
7349 /// \param Loc - A location associated with the condition, e.g. the
7350 /// 'if' keyword.
7351 /// \return true iff there were any errors
7353 bool IsConstexpr = false);
7354
7355 enum class ConditionKind {
7356 Boolean, ///< A boolean condition, from 'if', 'while', 'for', or 'do'.
7357 ConstexprIf, ///< A constant boolean condition from 'if constexpr'.
7358 Switch ///< An integral condition for a 'switch' statement.
7359 };
7360
7361 ConditionResult ActOnCondition(Scope *S, SourceLocation Loc, Expr *SubExpr,
7362 ConditionKind CK, bool MissingOK = false);
7363
7364 QualType CheckConditionalOperands( // C99 6.5.15
7365 ExprResult &Cond, ExprResult &LHS, ExprResult &RHS, ExprValueKind &VK,
7366 ExprObjectKind &OK, SourceLocation QuestionLoc);
7367
7368 /// Emit a specialized diagnostic when one expression is a null pointer
7369 /// constant and the other is not a pointer. Returns true if a diagnostic is
7370 /// emitted.
7371 bool DiagnoseConditionalForNull(const Expr *LHSExpr, const Expr *RHSExpr,
7372 SourceLocation QuestionLoc);
7373
7374 /// type checking for vector binary operators.
7376 SourceLocation Loc, bool IsCompAssign,
7377 bool AllowBothBool, bool AllowBoolConversion,
7378 bool AllowBoolOperation, bool ReportInvalid);
7379
7380 /// Return a signed ext_vector_type that is of identical size and number of
7381 /// elements. For floating point vectors, return an integer type of identical
7382 /// size and number of elements. In the non ext_vector_type case, search from
7383 /// the largest type to the smallest type to avoid cases where long long ==
7384 /// long, where long gets picked over long long.
7387
7388 /// CheckVectorCompareOperands - vector comparisons are a clang extension that
7389 /// operates on extended vector types. Instead of producing an IntTy result,
7390 /// like a scalar comparison, a vector comparison produces a vector of integer
7391 /// types.
7394 BinaryOperatorKind Opc);
7397 BinaryOperatorKind Opc);
7400 BinaryOperatorKind Opc);
7401
7402 /// Context in which we're performing a usual arithmetic conversion.
7404 /// An arithmetic operation.
7406 /// A bitwise operation.
7408 /// A comparison.
7410 /// A conditional (?:) operator.
7412 /// A compound assignment expression.
7414 };
7415
7416 // type checking for sizeless vector binary operators.
7418 SourceLocation Loc, bool IsCompAssign,
7419 ArithConvKind OperationKind);
7420
7421 /// Type checking for matrix binary operators.
7424 bool IsCompAssign);
7426 SourceLocation Loc, bool IsCompAssign);
7427
7428 /// Are the two types SVE-bitcast-compatible types? I.e. is bitcasting from
7429 /// the first SVE type (e.g. an SVE VLAT) to the second type (e.g. an SVE
7430 /// VLST) allowed?
7431 ///
7432 /// This will also return false if the two given types do not make sense from
7433 /// the perspective of SVE bitcasts.
7434 bool isValidSveBitcast(QualType srcType, QualType destType);
7435
7436 /// Are the two types matrix types and do they have the same dimensions i.e.
7437 /// do they have the same number of rows and the same number of columns?
7439
7440 bool areVectorTypesSameSize(QualType srcType, QualType destType);
7441
7442 /// Are the two types lax-compatible vector types? That is, given
7443 /// that one of them is a vector, do they have equal storage sizes,
7444 /// where the storage size is the number of elements times the element
7445 /// size?
7446 ///
7447 /// This will also return false if either of the types is neither a
7448 /// vector nor a real type.
7449 bool areLaxCompatibleVectorTypes(QualType srcType, QualType destType);
7450
7451 /// Is this a legal conversion between two types, one of which is
7452 /// known to be a vector type?
7453 bool isLaxVectorConversion(QualType srcType, QualType destType);
7454
7455 // This returns true if at least one of the types is an altivec vector.
7456 bool anyAltivecTypes(QualType srcType, QualType destType);
7457
7458 // type checking C++ declaration initializers (C++ [dcl.init]).
7459
7460 /// Check a cast of an unknown-any type. We intentionally only
7461 /// trigger this for C-style casts.
7465
7466 /// Force an expression with unknown-type to an expression of the
7467 /// given type.
7469
7470 /// Type-check an expression that's being passed to an
7471 /// __unknown_anytype parameter.
7473 QualType &paramType);
7474
7475 // CheckMatrixCast - Check type constraints for matrix casts.
7476 // We allow casting between matrixes of the same dimensions i.e. when they
7477 // have the same number of rows and column. Returns true if the cast is
7478 // invalid.
7479 bool CheckMatrixCast(SourceRange R, QualType DestTy, QualType SrcTy,
7480 CastKind &Kind);
7481
7482 // CheckVectorCast - check type constraints for vectors.
7483 // Since vectors are an extension, there are no C standard reference for this.
7484 // We allow casting between vectors and integer datatypes of the same size.
7485 // returns true if the cast is invalid
7486 bool CheckVectorCast(SourceRange R, QualType VectorTy, QualType Ty,
7487 CastKind &Kind);
7488
7489 /// Prepare `SplattedExpr` for a vector splat operation, adding
7490 /// implicit casts if necessary.
7491 ExprResult prepareVectorSplat(QualType VectorTy, Expr *SplattedExpr);
7492
7493 // CheckExtVectorCast - check type constraints for extended vectors.
7494 // Since vectors are an extension, there are no C standard reference for this.
7495 // We allow casting between vectors and integer datatypes of the same size,
7496 // or vectors and the element type of that vector.
7497 // returns the cast expr
7499 CastKind &Kind);
7500
7503 }
7504
7505 // UsualUnaryConversions - promotes integers (C99 6.3.1.1p2), converts
7506 // functions and arrays to their respective pointers (C99 6.3.2.1), and
7507 // promotes floating-piont types according to the language semantics.
7509
7510 // UsualUnaryFPConversions - promotes floating-point types according to the
7511 // current language semantics.
7513
7514 /// CallExprUnaryConversions - a special case of an unary conversion
7515 /// performed on a function designator of a call expression.
7517
7518 // DefaultFunctionArrayConversion - converts functions and arrays
7519 // to their respective pointers (C99 6.3.2.1).
7521
7522 // DefaultFunctionArrayLvalueConversion - converts functions and
7523 // arrays to their respective pointers and performs the
7524 // lvalue-to-rvalue conversion.
7526 bool Diagnose = true);
7527
7528 // DefaultLvalueConversion - performs lvalue-to-rvalue conversion on
7529 // the operand. This function is a no-op if the operand has a function type
7530 // or an array type.
7532
7533 // DefaultArgumentPromotion (C99 6.5.2.2p6). Used for function calls that
7534 // do not have a prototype. Integer promotions are performed on each
7535 // argument, and arguments that have type float are promoted to double.
7537
7539 const FunctionProtoType *Proto,
7540 Expr *Fn);
7541
7542 // Used for determining in which context a type is allowed to be passed to a
7543 // vararg function.
7551
7552 /// Determine the degree of POD-ness for an expression.
7553 /// Incomplete types are considered POD, since this check can be performed
7554 /// when we're in an unevaluated context.
7556
7557 /// Check to see if the given expression is a valid argument to a variadic
7558 /// function, issuing a diagnostic if not.
7560
7561 /// GatherArgumentsForCall - Collector argument expressions for various
7562 /// form of call prototypes.
7564 const FunctionProtoType *Proto,
7565 unsigned FirstParam, ArrayRef<Expr *> Args,
7566 SmallVectorImpl<Expr *> &AllArgs,
7568 bool AllowExplicit = false,
7569 bool IsListInitialization = false);
7570
7571 // DefaultVariadicArgumentPromotion - Like DefaultArgumentPromotion, but
7572 // will create a runtime trap if the resulting type is not a POD type.
7574 FunctionDecl *FDecl);
7575
7576 // Check that the usual arithmetic conversions can be performed on this pair
7577 // of expressions that might be of enumeration type.
7580
7581 // UsualArithmeticConversions - performs the UsualUnaryConversions on it's
7582 // operands and then handles various conversions that are common to binary
7583 // operators (C99 6.3.1.8). If both operands aren't arithmetic, this
7584 // routine returns the first non-arithmetic type found. The client is
7585 // responsible for emitting appropriate error diagnostics.
7588
7589 /// AssignConvertType - All of the 'assignment' semantic checks return this
7590 /// enum to indicate whether the assignment was allowed. These checks are
7591 /// done for simple assignments, as well as initialization, return from
7592 /// function, argument passing, etc. The query is phrased in terms of a
7593 /// source and destination type.
7595 /// Compatible - the types are compatible according to the standard.
7597
7598 /// PointerToInt - The assignment converts a pointer to an int, which we
7599 /// accept as an extension.
7601
7602 /// IntToPointer - The assignment converts an int to a pointer, which we
7603 /// accept as an extension.
7605
7606 /// FunctionVoidPointer - The assignment is between a function pointer and
7607 /// void*, which the standard doesn't allow, but we accept as an extension.
7609
7610 /// IncompatiblePointer - The assignment is between two pointers types that
7611 /// are not compatible, but we accept them as an extension.
7613
7614 /// IncompatibleFunctionPointer - The assignment is between two function
7615 /// pointers types that are not compatible, but we accept them as an
7616 /// extension.
7618
7619 /// IncompatibleFunctionPointerStrict - The assignment is between two
7620 /// function pointer types that are not identical, but are compatible,
7621 /// unless compiled with -fsanitize=cfi, in which case the type mismatch
7622 /// may trip an indirect call runtime check.
7624
7625 /// IncompatiblePointerSign - The assignment is between two pointers types
7626 /// which point to integers which have a different sign, but are otherwise
7627 /// identical. This is a subset of the above, but broken out because it's by
7628 /// far the most common case of incompatible pointers.
7630
7631 /// CompatiblePointerDiscardsQualifiers - The assignment discards
7632 /// c/v/r qualifiers, which we accept as an extension.
7634
7635 /// IncompatiblePointerDiscardsQualifiers - The assignment
7636 /// discards qualifiers that we don't permit to be discarded,
7637 /// like address spaces.
7639
7640 /// IncompatibleNestedPointerAddressSpaceMismatch - The assignment
7641 /// changes address spaces in nested pointer types which is not allowed.
7642 /// For instance, converting __private int ** to __generic int ** is
7643 /// illegal even though __private could be converted to __generic.
7645
7646 /// IncompatibleNestedPointerQualifiers - The assignment is between two
7647 /// nested pointer types, and the qualifiers other than the first two
7648 /// levels differ e.g. char ** -> const char **, but we accept them as an
7649 /// extension.
7651
7652 /// IncompatibleVectors - The assignment is between two vector types that
7653 /// have the same size, which we accept as an extension.
7655
7656 /// IntToBlockPointer - The assignment converts an int to a block
7657 /// pointer. We disallow this.
7659
7660 /// IncompatibleBlockPointer - The assignment is between two block
7661 /// pointers types that are not compatible.
7663
7664 /// IncompatibleObjCQualifiedId - The assignment is between a qualified
7665 /// id type and something else (that is incompatible with it). For example,
7666 /// "id <XXX>" = "Foo *", where "Foo *" doesn't implement the XXX protocol.
7668
7669 /// IncompatibleObjCWeakRef - Assigning a weak-unavailable object to an
7670 /// object with __weak qualifier.
7672
7673 /// Incompatible - We reject this conversion outright, it is invalid to
7674 /// represent it in the AST.
7677
7678 /// DiagnoseAssignmentResult - Emit a diagnostic, if required, for the
7679 /// assignment conversion type specified by ConvTy. This returns true if the
7680 /// conversion was invalid or false if the conversion was accepted.
7682 QualType DstType, QualType SrcType,
7683 Expr *SrcExpr, AssignmentAction Action,
7684 bool *Complained = nullptr);
7685
7686 /// CheckAssignmentConstraints - Perform type checking for assignment,
7687 /// argument passing, variable initialization, and function return values.
7688 /// C99 6.5.16.
7690 QualType LHSType,
7691 QualType RHSType);
7692
7693 /// Check assignment constraints and optionally prepare for a conversion of
7694 /// the RHS to the LHS type. The conversion is prepared for if ConvertRHS
7695 /// is true.
7697 ExprResult &RHS, CastKind &Kind,
7698 bool ConvertRHS = true);
7699
7700 /// Check assignment constraints for an assignment of RHS to LHSType.
7701 ///
7702 /// \param LHSType The destination type for the assignment.
7703 /// \param RHS The source expression for the assignment.
7704 /// \param Diagnose If \c true, diagnostics may be produced when checking
7705 /// for assignability. If a diagnostic is produced, \p RHS will be
7706 /// set to ExprError(). Note that this function may still return
7707 /// without producing a diagnostic, even for an invalid assignment.
7708 /// \param DiagnoseCFAudited If \c true, the target is a function parameter
7709 /// in an audited Core Foundation API and does not need to be checked
7710 /// for ARC retain issues.
7711 /// \param ConvertRHS If \c true, \p RHS will be updated to model the
7712 /// conversions necessary to perform the assignment. If \c false,
7713 /// \p Diagnose must also be \c false.
7715 QualType LHSType, ExprResult &RHS, bool Diagnose = true,
7716 bool DiagnoseCFAudited = false, bool ConvertRHS = true);
7717
7718 // If the lhs type is a transparent union, check whether we
7719 // can initialize the transparent union with the given expression.
7721 ExprResult &RHS);
7722
7723 /// the following "Check" methods will return a valid/converted QualType
7724 /// or a null QualType (indicating an error diagnostic was issued).
7725
7726 /// type checking binary operators (subroutines of CreateBuiltinBinOp).
7728 ExprResult &RHS);
7729
7730 /// Diagnose cases where a scalar was implicitly converted to a vector and
7731 /// diagnose the underlying types. Otherwise, diagnose the error
7732 /// as invalid vector logical operands for non-C++ cases.
7734 ExprResult &RHS);
7735
7737 ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, bool IsCompAssign,
7738 bool IsDivide);
7739 QualType CheckRemainderOperands( // C99 6.5.5
7741 bool IsCompAssign = false);
7742 QualType CheckAdditionOperands( // C99 6.5.6
7744 BinaryOperatorKind Opc, QualType *CompLHSTy = nullptr);
7747 QualType *CompLHSTy = nullptr);
7748 QualType CheckShiftOperands( // C99 6.5.7
7750 BinaryOperatorKind Opc, bool IsCompAssign = false);
7752 QualType CheckCompareOperands( // C99 6.5.8/9
7754 BinaryOperatorKind Opc);
7755 QualType CheckBitwiseOperands( // C99 6.5.[10...12]
7757 BinaryOperatorKind Opc);
7758 QualType CheckLogicalOperands( // C99 6.5.[13,14]
7760 BinaryOperatorKind Opc);
7761 // CheckAssignmentOperands is used for both simple and compound assignment.
7762 // For simple assignment, pass both expressions and a null converted type.
7763 // For compound assignment, pass both expressions and the converted type.
7764 QualType CheckAssignmentOperands( // C99 6.5.16.[1,2]
7765 Expr *LHSExpr, ExprResult &RHS, SourceLocation Loc, QualType CompoundType,
7766 BinaryOperatorKind Opc);
7767
7768 /// To be used for checking whether the arguments being passed to
7769 /// function exceeds the number of parameters expected for it.
7770 static bool TooManyArguments(size_t NumParams, size_t NumArgs,
7771 bool PartialOverloading = false) {
7772 // We check whether we're just after a comma in code-completion.
7773 if (NumArgs > 0 && PartialOverloading)
7774 return NumArgs + 1 > NumParams; // If so, we view as an extra argument.
7775 return NumArgs > NumParams;
7776 }
7777
7778 /// Whether the AST is currently being rebuilt to correct immediate
7779 /// invocations. Immediate invocation candidates and references to consteval
7780 /// functions aren't tracked when this is set.
7782
7785 return (Ctx.isConstantEvaluated() || isConstantEvaluatedOverride) &&
7786 !Ctx.InConditionallyConstantEvaluateContext;
7787 }
7788
7789 /// Determines whether we are currently in a context that
7790 /// is not evaluated as per C++ [expr] p5.
7793 }
7794
7797 }
7798
7801 }
7802
7805 }
7806
7809 return (Ctx.Context ==
7811 Ctx.IsCurrentlyCheckingDefaultArgumentOrInitializer;
7812 }
7813
7814 std::optional<ExpressionEvaluationContextRecord::InitializationContext>
7816 assert(!ExprEvalContexts.empty() &&
7817 "Must be in an expression evaluation context");
7818 for (const auto &Ctx : llvm::reverse(ExprEvalContexts)) {
7820 Ctx.DelayedDefaultInitializationContext)
7821 return Ctx.DelayedDefaultInitializationContext;
7822 if (Ctx.isConstantEvaluated() || Ctx.isImmediateFunctionContext() ||
7823 Ctx.isUnevaluated())
7824 break;
7825 }
7826 return std::nullopt;
7827 }
7828
7829 std::optional<ExpressionEvaluationContextRecord::InitializationContext>
7831 assert(!ExprEvalContexts.empty() &&
7832 "Must be in an expression evaluation context");
7833 std::optional<ExpressionEvaluationContextRecord::InitializationContext> Res;
7834 for (auto &Ctx : llvm::reverse(ExprEvalContexts)) {
7836 !Ctx.DelayedDefaultInitializationContext && Res)
7837 break;
7838 if (Ctx.isConstantEvaluated() || Ctx.isImmediateFunctionContext() ||
7839 Ctx.isUnevaluated())
7840 break;
7841 Res = Ctx.DelayedDefaultInitializationContext;
7842 }
7843 return Res;
7844 }
7845
7848 }
7849
7850 /// Returns a field in a CXXRecordDecl that has the same name as the decl \p
7851 /// SelfAssigned when inside a CXXMethodDecl.
7852 const FieldDecl *
7854
7856
7857 template <typename... Ts>
7859 const Ts &...Args) {
7860 SizelessTypeDiagnoser<Ts...> Diagnoser(DiagID, Args...);
7862 }
7863
7864 template <typename... Ts>
7865 bool RequireCompleteSizedExprType(Expr *E, unsigned DiagID,
7866 const Ts &...Args) {
7867 SizelessTypeDiagnoser<Ts...> Diagnoser(DiagID, Args...);
7869 }
7870
7871 /// Abstract class used to diagnose incomplete types.
7874
7875 virtual void diagnose(Sema &S, SourceLocation Loc, QualType T) = 0;
7876 virtual ~TypeDiagnoser() {}
7877 };
7878
7879 template <typename... Ts> class BoundTypeDiagnoser : public TypeDiagnoser {
7880 protected:
7881 unsigned DiagID;
7882 std::tuple<const Ts &...> Args;
7883
7884 template <std::size_t... Is>
7886 std::index_sequence<Is...>) const {
7887 // Apply all tuple elements to the builder in order.
7888 bool Dummy[] = {false, (DB << getPrintable(std::get<Is>(Args)))...};
7889 (void)Dummy;
7890 }
7891
7892 public:
7893 BoundTypeDiagnoser(unsigned DiagID, const Ts &...Args)
7894 : TypeDiagnoser(), DiagID(DiagID), Args(Args...) {
7895 assert(DiagID != 0 && "no diagnostic for type diagnoser");
7896 }
7897
7898 void diagnose(Sema &S, SourceLocation Loc, QualType T) override {
7899 const SemaDiagnosticBuilder &DB = S.Diag(Loc, DiagID);
7900 emit(DB, std::index_sequence_for<Ts...>());
7901 DB << T;
7902 }
7903 };
7904
7905 /// A derivative of BoundTypeDiagnoser for which the diagnostic's type
7906 /// parameter is preceded by a 0/1 enum that is 1 if the type is sizeless.
7907 /// For example, a diagnostic with no other parameters would generally have
7908 /// the form "...%select{incomplete|sizeless}0 type %1...".
7909 template <typename... Ts>
7911 public:
7912 SizelessTypeDiagnoser(unsigned DiagID, const Ts &...Args)
7913 : BoundTypeDiagnoser<Ts...>(DiagID, Args...) {}
7914
7915 void diagnose(Sema &S, SourceLocation Loc, QualType T) override {
7916 const SemaDiagnosticBuilder &DB = S.Diag(Loc, this->DiagID);
7917 this->emit(DB, std::index_sequence_for<Ts...>());
7918 DB << T->isSizelessType() << T;
7919 }
7920 };
7921
7922 /// Check an argument list for placeholders that we won't try to
7923 /// handle later.
7925
7926 /// The C++ "std::source_location::__impl" struct, defined in
7927 /// <source_location>.
7929
7930 /// A stack of expression evaluation contexts.
7932
7933 // Set of failed immediate invocations to avoid double diagnosing.
7935
7936 /// List of SourceLocations where 'self' is implicitly retained inside a
7937 /// block.
7940
7941 /// Do an explicit extend of the given block pointer if we're in ARC.
7943
7944 std::vector<std::pair<QualType, unsigned>> ExcessPrecisionNotSatisfied;
7947
7948private:
7949 static BinaryOperatorKind ConvertTokenKindToBinaryOpcode(tok::TokenKind Kind);
7950
7951 /// Methods for marking which expressions involve dereferencing a pointer
7952 /// marked with the 'noderef' attribute. Expressions are checked bottom up as
7953 /// they are parsed, meaning that a noderef pointer may not be accessed. For
7954 /// example, in `&*p` where `p` is a noderef pointer, we will first parse the
7955 /// `*p`, but need to check that `address of` is called on it. This requires
7956 /// keeping a container of all pending expressions and checking if the address
7957 /// of them are eventually taken.
7958 void CheckSubscriptAccessOfNoDeref(const ArraySubscriptExpr *E);
7959 void CheckAddressOfNoDeref(const Expr *E);
7960
7961 ///@}
7962
7963 //
7964 //
7965 // -------------------------------------------------------------------------
7966 //
7967 //
7968
7969 /// \name C++ Expressions
7970 /// Implementations are in SemaExprCXX.cpp
7971 ///@{
7972
7973public:
7974 /// The C++ "std::bad_alloc" class, which is defined by the C++
7975 /// standard library.
7977
7978 /// The C++ "std::align_val_t" enum class, which is defined by the C++
7979 /// standard library.
7981
7982 /// The C++ "type_info" declaration, which is defined in <typeinfo>.
7984
7985 /// A flag to remember whether the implicit forms of operator new and delete
7986 /// have been declared.
7988
7989 /// Delete-expressions to be analyzed at the end of translation unit
7990 ///
7991 /// This list contains class members, and locations of delete-expressions
7992 /// that could not be proven as to whether they mismatch with new-expression
7993 /// used in initializer of the field.
7994 llvm::MapVector<FieldDecl *, DeleteLocs> DeleteExprs;
7995
7996 /// Handle the result of the special case name lookup for inheriting
7997 /// constructor declarations. 'NS::X::X' and 'NS::X<...>::X' are treated as
7998 /// constructor names in member using declarations, even if 'X' is not the
7999 /// name of the corresponding type.
8001 SourceLocation NameLoc,
8002 const IdentifierInfo &Name);
8003
8005 SourceLocation NameLoc, Scope *S,
8006 CXXScopeSpec &SS, bool EnteringContext);
8008 Scope *S, CXXScopeSpec &SS,
8009 ParsedType ObjectType, bool EnteringContext);
8010
8012 ParsedType ObjectType);
8013
8014 /// Build a C++ typeid expression with a type operand.
8015 ExprResult BuildCXXTypeId(QualType TypeInfoType, SourceLocation TypeidLoc,
8016 TypeSourceInfo *Operand, SourceLocation RParenLoc);
8017
8018 /// Build a C++ typeid expression with an expression operand.
8019 ExprResult BuildCXXTypeId(QualType TypeInfoType, SourceLocation TypeidLoc,
8020 Expr *Operand, SourceLocation RParenLoc);
8021
8022 /// ActOnCXXTypeid - Parse typeid( something ).
8024 bool isType, void *TyOrExpr,
8025 SourceLocation RParenLoc);
8026
8027 /// Build a Microsoft __uuidof expression with a type operand.
8028 ExprResult BuildCXXUuidof(QualType TypeInfoType, SourceLocation TypeidLoc,
8029 TypeSourceInfo *Operand, SourceLocation RParenLoc);
8030
8031 /// Build a Microsoft __uuidof expression with an expression operand.
8032 ExprResult BuildCXXUuidof(QualType TypeInfoType, SourceLocation TypeidLoc,
8033 Expr *Operand, SourceLocation RParenLoc);
8034
8035 /// ActOnCXXUuidof - Parse __uuidof( something ).
8037 bool isType, void *TyOrExpr,
8038 SourceLocation RParenLoc);
8039
8040 //// ActOnCXXThis - Parse 'this' pointer.
8042
8043 /// Check whether the type of 'this' is valid in the current context.
8045
8046 /// Build a CXXThisExpr and mark it referenced in the current context.
8048 void MarkThisReferenced(CXXThisExpr *This);
8049
8050 /// Try to retrieve the type of the 'this' pointer.
8051 ///
8052 /// \returns The type of 'this', if possible. Otherwise, returns a NULL type.
8054
8055 /// When non-NULL, the C++ 'this' expression is allowed despite the
8056 /// current context not being a non-static member function. In such cases,
8057 /// this provides the type used for 'this'.
8059
8060 /// RAII object used to temporarily allow the C++ 'this' expression
8061 /// to be used, with the given qualifiers on the current class type.
8063 Sema &S;
8064 QualType OldCXXThisTypeOverride;
8065 bool Enabled;
8066
8067 public:
8068 /// Introduce a new scope where 'this' may be allowed (when enabled),
8069 /// using the given declaration (which is either a class template or a
8070 /// class) along with the given qualifiers.
8071 /// along with the qualifiers placed on '*this'.
8072 CXXThisScopeRAII(Sema &S, Decl *ContextDecl, Qualifiers CXXThisTypeQuals,
8073 bool Enabled = true);
8074
8076 };
8077
8078 /// Make sure the value of 'this' is actually available in the current
8079 /// context, if it is a potentially evaluated context.
8080 ///
8081 /// \param Loc The location at which the capture of 'this' occurs.
8082 ///
8083 /// \param Explicit Whether 'this' is explicitly captured in a lambda
8084 /// capture list.
8085 ///
8086 /// \param FunctionScopeIndexToStopAt If non-null, it points to the index
8087 /// of the FunctionScopeInfo stack beyond which we do not attempt to capture.
8088 /// This is useful when enclosing lambdas must speculatively capture
8089 /// 'this' that may or may not be used in certain specializations of
8090 /// a nested generic lambda (depending on whether the name resolves to
8091 /// a non-static member function or a static function).
8092 /// \return returns 'true' if failed, 'false' if success.
8094 SourceLocation Loc, bool Explicit = false, bool BuildAndDiagnose = true,
8095 const unsigned *const FunctionScopeIndexToStopAt = nullptr,
8096 bool ByCopy = false);
8097
8098 /// Determine whether the given type is the type of *this that is used
8099 /// outside of the body of a member function for a type that is currently
8100 /// being defined.
8102
8103 /// ActOnCXXBoolLiteral - Parse {true,false} literals.
8105
8106 /// ActOnCXXNullPtrLiteral - Parse 'nullptr'.
8108
8109 //// ActOnCXXThrow - Parse throw expressions.
8112 bool IsThrownVarInScope);
8113
8114 /// CheckCXXThrowOperand - Validate the operand of a throw.
8115 bool CheckCXXThrowOperand(SourceLocation ThrowLoc, QualType ThrowTy, Expr *E);
8116
8117 /// ActOnCXXTypeConstructExpr - Parse construction of a specified type.
8118 /// Can be interpreted either as function-style casting ("int(x)")
8119 /// or class type construction ("ClassType(x,y,z)")
8120 /// or creation of a value-initialized type ("int()").
8122 SourceLocation LParenOrBraceLoc,
8123 MultiExprArg Exprs,
8124 SourceLocation RParenOrBraceLoc,
8125 bool ListInitialization);
8126
8128 SourceLocation LParenLoc,
8129 MultiExprArg Exprs,
8130 SourceLocation RParenLoc,
8131 bool ListInitialization);
8132
8133 /// Parsed a C++ 'new' expression (C++ 5.3.4).
8134 ///
8135 /// E.g.:
8136 /// @code new (memory) int[size][4] @endcode
8137 /// or
8138 /// @code ::new Foo(23, "hello") @endcode
8139 ///
8140 /// \param StartLoc The first location of the expression.
8141 /// \param UseGlobal True if 'new' was prefixed with '::'.
8142 /// \param PlacementLParen Opening paren of the placement arguments.
8143 /// \param PlacementArgs Placement new arguments.
8144 /// \param PlacementRParen Closing paren of the placement arguments.
8145 /// \param TypeIdParens If the type is in parens, the source range.
8146 /// \param D The type to be allocated, as well as array dimensions.
8147 /// \param Initializer The initializing expression or initializer-list, or
8148 /// null if there is none.
8149 ExprResult ActOnCXXNew(SourceLocation StartLoc, bool UseGlobal,
8150 SourceLocation PlacementLParen,
8151 MultiExprArg PlacementArgs,
8152 SourceLocation PlacementRParen,
8153 SourceRange TypeIdParens, Declarator &D,
8154 Expr *Initializer);
8156 BuildCXXNew(SourceRange Range, bool UseGlobal, SourceLocation PlacementLParen,
8157 MultiExprArg PlacementArgs, SourceLocation PlacementRParen,
8158 SourceRange TypeIdParens, QualType AllocType,
8159 TypeSourceInfo *AllocTypeInfo, std::optional<Expr *> ArraySize,
8160 SourceRange DirectInitRange, Expr *Initializer);
8161
8162 /// Determine whether \p FD is an aligned allocation or deallocation
8163 /// function that is unavailable.
8165
8166 /// Produce diagnostics if \p FD is an aligned allocation or deallocation
8167 /// function that is unavailable.
8170
8171 /// Checks that a type is suitable as the allocated type
8172 /// in a new-expression.
8174 SourceRange R);
8175
8176 /// The scope in which to find allocation functions.
8178 /// Only look for allocation functions in the global scope.
8180 /// Only look for allocation functions in the scope of the
8181 /// allocated class.
8183 /// Look for allocation functions in both the global scope
8184 /// and in the scope of the allocated class.
8185 AFS_Both
8187
8188 /// Finds the overloads of operator new and delete that are appropriate
8189 /// for the allocation.
8191 AllocationFunctionScope NewScope,
8192 AllocationFunctionScope DeleteScope,
8193 QualType AllocType, bool IsArray,
8194 bool &PassAlignment, MultiExprArg PlaceArgs,
8195 FunctionDecl *&OperatorNew,
8196 FunctionDecl *&OperatorDelete,
8197 bool Diagnose = true);
8198
8199 /// DeclareGlobalNewDelete - Declare the global forms of operator new and
8200 /// delete. These are:
8201 /// @code
8202 /// // C++03:
8203 /// void* operator new(std::size_t) throw(std::bad_alloc);
8204 /// void* operator new[](std::size_t) throw(std::bad_alloc);
8205 /// void operator delete(void *) throw();
8206 /// void operator delete[](void *) throw();
8207 /// // C++11:
8208 /// void* operator new(std::size_t);
8209 /// void* operator new[](std::size_t);
8210 /// void operator delete(void *) noexcept;
8211 /// void operator delete[](void *) noexcept;
8212 /// // C++1y:
8213 /// void* operator new(std::size_t);
8214 /// void* operator new[](std::size_t);
8215 /// void operator delete(void *) noexcept;
8216 /// void operator delete[](void *) noexcept;
8217 /// void operator delete(void *, std::size_t) noexcept;
8218 /// void operator delete[](void *, std::size_t) noexcept;
8219 /// @endcode
8220 /// Note that the placement and nothrow forms of new are *not* implicitly
8221 /// declared. Their use requires including <new>.
8224 ArrayRef<QualType> Params);
8225
8227 DeclarationName Name, FunctionDecl *&Operator,
8228 bool Diagnose = true, bool WantSize = false,
8229 bool WantAligned = false);
8231 bool CanProvideSize,
8232 bool Overaligned,
8233 DeclarationName Name);
8235 CXXRecordDecl *RD);
8236
8237 /// ActOnCXXDelete - Parsed a C++ 'delete' expression (C++ 5.3.5), as in:
8238 /// @code ::delete ptr; @endcode
8239 /// or
8240 /// @code delete [] ptr; @endcode
8241 ExprResult ActOnCXXDelete(SourceLocation StartLoc, bool UseGlobal,
8242 bool ArrayForm, Expr *Operand);
8244 bool IsDelete, bool CallCanBeVirtual,
8245 bool WarnOnNonAbstractTypes,
8246 SourceLocation DtorLoc);
8247
8249 Expr *Operand, SourceLocation RParen);
8251 SourceLocation RParen);
8252
8254 SourceLocation OpLoc,
8255 tok::TokenKind OpKind,
8256 ParsedType &ObjectType,
8257 bool &MayBePseudoDestructor);
8258
8260 Expr *Base, SourceLocation OpLoc, tok::TokenKind OpKind,
8261 const CXXScopeSpec &SS, TypeSourceInfo *ScopeType, SourceLocation CCLoc,
8262 SourceLocation TildeLoc, PseudoDestructorTypeStorage DestroyedType);
8263
8265 Scope *S, Expr *Base, SourceLocation OpLoc, tok::TokenKind OpKind,
8266 CXXScopeSpec &SS, UnqualifiedId &FirstTypeName, SourceLocation CCLoc,
8267 SourceLocation TildeLoc, UnqualifiedId &SecondTypeName);
8268
8270 SourceLocation OpLoc,
8271 tok::TokenKind OpKind,
8272 SourceLocation TildeLoc,
8273 const DeclSpec &DS);
8274
8275 /// MaybeCreateExprWithCleanups - If the current full-expression
8276 /// requires any cleanups, surround it with a ExprWithCleanups node.
8277 /// Otherwise, just returns the passed-in expression.
8281
8282 ExprResult ActOnFinishFullExpr(Expr *Expr, bool DiscardedValue) {
8283 return ActOnFinishFullExpr(
8284 Expr, Expr ? Expr->getExprLoc() : SourceLocation(), DiscardedValue);
8285 }
8287 bool DiscardedValue, bool IsConstexpr = false,
8288 bool IsTemplateArgument = false);
8290
8291 /// Process the expression contained within a decltype. For such expressions,
8292 /// certain semantic checks on temporaries are delayed until this point, and
8293 /// are omitted for the 'topmost' call in the decltype expression. If the
8294 /// topmost call bound a temporary, strip that temporary off the expression.
8296
8297 bool checkLiteralOperatorId(const CXXScopeSpec &SS, const UnqualifiedId &Id,
8298 bool IsUDSuffix);
8299
8301
8302 ConditionResult ActOnConditionVariable(Decl *ConditionVar,
8303 SourceLocation StmtLoc,
8304 ConditionKind CK);
8305
8306 /// Check the use of the given variable as a C++ condition in an if,
8307 /// while, do-while, or switch statement.
8309 SourceLocation StmtLoc, ConditionKind CK);
8310
8311 /// CheckCXXBooleanCondition - Returns true if conversion to bool is invalid.
8312 ExprResult CheckCXXBooleanCondition(Expr *CondExpr, bool IsConstexpr = false);
8313
8314 /// Helper function to determine whether this is the (deprecated) C++
8315 /// conversion from a string literal to a pointer to non-const char or
8316 /// non-const wchar_t (for narrow and wide string literals,
8317 /// respectively).
8319
8320 /// PerformImplicitConversion - Perform an implicit conversion of the
8321 /// expression From to the type ToType using the pre-computed implicit
8322 /// conversion sequence ICS. Returns the converted
8323 /// expression. Action is the kind of conversion we're performing,
8324 /// used in the error message.
8326 Expr *From, QualType ToType, const ImplicitConversionSequence &ICS,
8327 AssignmentAction Action,
8329
8330 /// PerformImplicitConversion - Perform an implicit conversion of the
8331 /// expression From to the type ToType by following the standard
8332 /// conversion sequence SCS. Returns the converted
8333 /// expression. Flavor is the context in which we're performing this
8334 /// conversion, for use in error messages.
8336 const StandardConversionSequence &SCS,
8337 AssignmentAction Action,
8339
8340 bool CheckTypeTraitArity(unsigned Arity, SourceLocation Loc, size_t N);
8341
8342 /// Parsed one of the type trait support pseudo-functions.
8345 SourceLocation RParenLoc);
8348 SourceLocation RParenLoc);
8349
8350 /// ActOnArrayTypeTrait - Parsed one of the binary type trait support
8351 /// pseudo-functions.
8353 ParsedType LhsTy, Expr *DimExpr,
8354 SourceLocation RParen);
8355
8357 TypeSourceInfo *TSInfo, Expr *DimExpr,
8358 SourceLocation RParen);
8359
8360 /// ActOnExpressionTrait - Parsed one of the unary type trait support
8361 /// pseudo-functions.
8363 Expr *Queried, SourceLocation RParen);
8364
8366 Expr *Queried, SourceLocation RParen);
8367
8369 ExprResult &LHS, ExprResult &RHS, ExprValueKind &VK, SourceLocation OpLoc,
8370 bool isIndirect);
8372 ExprResult &RHS,
8373 SourceLocation QuestionLoc);
8374
8376 ExprResult &LHS, ExprResult &RHS,
8377 SourceLocation QuestionLoc);
8378
8379 /// Check the operands of ?: under C++ semantics.
8380 ///
8381 /// See C++ [expr.cond]. Note that LHS is never null, even for the GNU x ?: y
8382 /// extension. In this case, LHS == Cond. (But they're not aliases.)
8383 ///
8384 /// This function also implements GCC's vector extension and the
8385 /// OpenCL/ext_vector_type extension for conditionals. The vector extensions
8386 /// permit the use of a?b:c where the type of a is that of a integer vector
8387 /// with the same number of elements and size as the vectors of b and c. If
8388 /// one of either b or c is a scalar it is implicitly converted to match the
8389 /// type of the vector. Otherwise the expression is ill-formed. If both b and
8390 /// c are scalars, then b and c are checked and converted to the type of a if
8391 /// possible.
8392 ///
8393 /// The expressions are evaluated differently for GCC's and OpenCL's
8394 /// extensions. For the GCC extension, the ?: operator is evaluated as
8395 /// (a[0] != 0 ? b[0] : c[0], .. , a[n] != 0 ? b[n] : c[n]).
8396 /// For the OpenCL extensions, the ?: operator is evaluated as
8397 /// (most-significant-bit-set(a[0]) ? b[0] : c[0], .. ,
8398 /// most-significant-bit-set(a[n]) ? b[n] : c[n]).
8400 ExprResult &cond, ExprResult &lhs, ExprResult &rhs, ExprValueKind &VK,
8401 ExprObjectKind &OK, SourceLocation questionLoc);
8402
8403 /// Find a merged pointer type and convert the two expressions to it.
8404 ///
8405 /// This finds the composite pointer type for \p E1 and \p E2 according to
8406 /// C++2a [expr.type]p3. It converts both expressions to this type and returns
8407 /// it. It does not emit diagnostics (FIXME: that's not true if \p
8408 /// ConvertArgs is \c true).
8409 ///
8410 /// \param Loc The location of the operator requiring these two expressions to
8411 /// be converted to the composite pointer type.
8412 ///
8413 /// \param ConvertArgs If \c false, do not convert E1 and E2 to the target
8414 /// type.
8416 bool ConvertArgs = true);
8418 ExprResult &E2, bool ConvertArgs = true) {
8419 Expr *E1Tmp = E1.get(), *E2Tmp = E2.get();
8420 QualType Composite =
8421 FindCompositePointerType(Loc, E1Tmp, E2Tmp, ConvertArgs);
8422 E1 = E1Tmp;
8423 E2 = E2Tmp;
8424 return Composite;
8425 }
8426
8427 /// MaybeBindToTemporary - If the passed in expression has a record type with
8428 /// a non-trivial destructor, this will return CXXBindTemporaryExpr. Otherwise
8429 /// it simply returns the passed in expression.
8431
8432 /// IgnoredValueConversions - Given that an expression's result is
8433 /// syntactically ignored, perform any conversions that are
8434 /// required.
8436
8438
8439 /// Process any TypoExprs in the given Expr and its children,
8440 /// generating diagnostics as appropriate and returning a new Expr if there
8441 /// were typos that were all successfully corrected and ExprError if one or
8442 /// more typos could not be corrected.
8443 ///
8444 /// \param E The Expr to check for TypoExprs.
8445 ///
8446 /// \param InitDecl A VarDecl to avoid because the Expr being corrected is its
8447 /// initializer.
8448 ///
8449 /// \param RecoverUncorrectedTypos If true, when typo correction fails, it
8450 /// will rebuild the given Expr with all TypoExprs degraded to RecoveryExprs.
8451 ///
8452 /// \param Filter A function applied to a newly rebuilt Expr to determine if
8453 /// it is an acceptable/usable result from a single combination of typo
8454 /// corrections. As long as the filter returns ExprError, different
8455 /// combinations of corrections will be tried until all are exhausted.
8457 Expr *E, VarDecl *InitDecl = nullptr,
8458 bool RecoverUncorrectedTypos = false,
8459 llvm::function_ref<ExprResult(Expr *)> Filter =
8460 [](Expr *E) -> ExprResult { return E; });
8461
8463 ExprResult ER, VarDecl *InitDecl = nullptr,
8464 bool RecoverUncorrectedTypos = false,
8465 llvm::function_ref<ExprResult(Expr *)> Filter =
8466 [](Expr *E) -> ExprResult { return E; }) {
8467 return ER.isInvalid()
8468 ? ER
8469 : CorrectDelayedTyposInExpr(ER.get(), InitDecl,
8470 RecoverUncorrectedTypos, Filter);
8471 }
8472
8473 /// Describes the result of an "if-exists" condition check.
8475 /// The symbol exists.
8477
8478 /// The symbol does not exist.
8480
8481 /// The name is a dependent name, so the results will differ
8482 /// from one instantiation to the next.
8484
8485 /// An error occurred.
8486 IER_Error
8488
8491 const DeclarationNameInfo &TargetNameInfo);
8492
8494 SourceLocation KeywordLoc,
8495 bool IsIfExists, CXXScopeSpec &SS,
8496 UnqualifiedId &Name);
8497
8500 ArrayRef<ParmVarDecl *> LocalParameters,
8501 Scope *BodyScope);
8505 CXXScopeSpec &SS,
8506 SourceLocation NameLoc,
8507 const IdentifierInfo *TypeName,
8508 TemplateIdAnnotation *TemplateId);
8510 SourceLocation NoexceptLoc);
8512 Expr *E, SourceLocation NoexceptLoc, CXXScopeSpec &SS,
8513 TemplateIdAnnotation *TypeConstraint, unsigned Depth);
8516 Expr *E, bool IsSatisfied, SourceLocation NoexceptLoc,
8520 bool IsSatisfied, SourceLocation NoexceptLoc,
8527 BuildNestedRequirement(StringRef InvalidConstraintEntity,
8528 const ASTConstraintSatisfaction &Satisfaction);
8531 SourceLocation LParenLoc,
8532 ArrayRef<ParmVarDecl *> LocalParameters,
8533 SourceLocation RParenLoc,
8535 SourceLocation ClosingBraceLoc);
8536
8537private:
8538 ExprResult BuiltinOperatorNewDeleteOverloaded(ExprResult TheCallResult,
8539 bool IsDelete);
8540
8541 void AnalyzeDeleteExprMismatch(const CXXDeleteExpr *DE);
8542 void AnalyzeDeleteExprMismatch(FieldDecl *Field, SourceLocation DeleteLoc,
8543 bool DeleteWasArrayForm);
8544
8545 ///@}
8546
8547 //
8548 //
8549 // -------------------------------------------------------------------------
8550 //
8551 //
8552
8553 /// \name Member Access Expressions
8554 /// Implementations are in SemaExprMember.cpp
8555 ///@{
8556
8557public:
8558 /// Check whether an expression might be an implicit class member access.
8560 bool IsAddressOfOperand);
8561
8562 /// Builds an expression which might be an implicit member expression.
8564 const CXXScopeSpec &SS, SourceLocation TemplateKWLoc, LookupResult &R,
8565 const TemplateArgumentListInfo *TemplateArgs, const Scope *S);
8566
8567 /// Builds an implicit member access expression. The current context
8568 /// is known to be an instance method, and the given unqualified lookup
8569 /// set is known to contain only instance members, at least one of which
8570 /// is from an appropriate type.
8572 BuildImplicitMemberExpr(const CXXScopeSpec &SS, SourceLocation TemplateKWLoc,
8573 LookupResult &R,
8574 const TemplateArgumentListInfo *TemplateArgs,
8575 bool IsDefiniteInstance, const Scope *S);
8576
8578 Expr *Base, QualType BaseType, bool IsArrow, SourceLocation OpLoc,
8579 const CXXScopeSpec &SS, SourceLocation TemplateKWLoc,
8580 NamedDecl *FirstQualifierInScope, const DeclarationNameInfo &NameInfo,
8581 const TemplateArgumentListInfo *TemplateArgs);
8582
8583 /// The main callback when the parser finds something like
8584 /// expression . [nested-name-specifier] identifier
8585 /// expression -> [nested-name-specifier] identifier
8586 /// where 'identifier' encompasses a fairly broad spectrum of
8587 /// possibilities, including destructor and operator references.
8588 ///
8589 /// \param OpKind either tok::arrow or tok::period
8590 /// \param ObjCImpDecl the current Objective-C \@implementation
8591 /// decl; this is an ugly hack around the fact that Objective-C
8592 /// \@implementations aren't properly put in the context chain
8594 tok::TokenKind OpKind, CXXScopeSpec &SS,
8595 SourceLocation TemplateKWLoc,
8596 UnqualifiedId &Member, Decl *ObjCImpDecl);
8597
8598 MemberExpr *
8599 BuildMemberExpr(Expr *Base, bool IsArrow, SourceLocation OpLoc,
8600 NestedNameSpecifierLoc NNS, SourceLocation TemplateKWLoc,
8601 ValueDecl *Member, DeclAccessPair FoundDecl,
8602 bool HadMultipleCandidates,
8603 const DeclarationNameInfo &MemberNameInfo, QualType Ty,
8605 const TemplateArgumentListInfo *TemplateArgs = nullptr);
8606
8607 // Check whether the declarations we found through a nested-name
8608 // specifier in a member expression are actually members of the base
8609 // type. The restriction here is:
8610 //
8611 // C++ [expr.ref]p2:
8612 // ... In these cases, the id-expression shall name a
8613 // member of the class or of one of its base classes.
8614 //
8615 // So it's perfectly legitimate for the nested-name specifier to name
8616 // an unrelated class, and for us to find an overload set including
8617 // decls from classes which are not superclasses, as long as the decl
8618 // we actually pick through overload resolution is from a superclass.
8619 bool CheckQualifiedMemberReference(Expr *BaseExpr, QualType BaseType,
8620 const CXXScopeSpec &SS,
8621 const LookupResult &R);
8622
8623 // This struct is for use by ActOnMemberAccess to allow
8624 // BuildMemberReferenceExpr to be able to reinvoke ActOnMemberAccess after
8625 // changing the access operator from a '.' to a '->' (to see if that is the
8626 // change needed to fix an error about an unknown member, e.g. when the class
8627 // defines a custom operator->).
8632 };
8633
8635 Expr *Base, QualType BaseType, SourceLocation OpLoc, bool IsArrow,
8636 CXXScopeSpec &SS, SourceLocation TemplateKWLoc,
8637 NamedDecl *FirstQualifierInScope, const DeclarationNameInfo &NameInfo,
8638 const TemplateArgumentListInfo *TemplateArgs, const Scope *S,
8639 ActOnMemberAccessExtraArgs *ExtraArgs = nullptr);
8640
8643 bool IsArrow, const CXXScopeSpec &SS,
8644 SourceLocation TemplateKWLoc,
8645 NamedDecl *FirstQualifierInScope, LookupResult &R,
8646 const TemplateArgumentListInfo *TemplateArgs,
8647 const Scope *S, bool SuppressQualifierCheck = false,
8648 ActOnMemberAccessExtraArgs *ExtraArgs = nullptr);
8649
8650 ExprResult BuildFieldReferenceExpr(Expr *BaseExpr, bool IsArrow,
8651 SourceLocation OpLoc,
8652 const CXXScopeSpec &SS, FieldDecl *Field,
8653 DeclAccessPair FoundDecl,
8654 const DeclarationNameInfo &MemberNameInfo);
8655
8656 /// Perform conversions on the LHS of a member access expression.
8658
8660 const CXXScopeSpec &SS, SourceLocation nameLoc,
8661 IndirectFieldDecl *indirectField,
8662 DeclAccessPair FoundDecl = DeclAccessPair::make(nullptr, AS_none),
8663 Expr *baseObjectExpr = nullptr, SourceLocation opLoc = SourceLocation());
8664
8665private:
8666 void CheckMemberAccessOfNoDeref(const MemberExpr *E);
8667
8668 ///@}
8669
8670 //
8671 //
8672 // -------------------------------------------------------------------------
8673 //
8674 //
8675
8676 /// \name Initializers
8677 /// Implementations are in SemaInit.cpp
8678 ///@{
8679
8680public:
8681 /// Stack of types that correspond to the parameter entities that are
8682 /// currently being copy-initialized. Can be empty.
8684
8685 llvm::DenseMap<unsigned, CXXDeductionGuideDecl *>
8687
8688 bool IsStringInit(Expr *Init, const ArrayType *AT);
8689
8690 /// Determine whether we can perform aggregate initialization for the purposes
8691 /// of overload resolution.
8693 const InitializedEntity &Entity, InitListExpr *From);
8694
8696 SourceLocation EqualOrColonLoc,
8697 bool GNUSyntax, ExprResult Init);
8698
8699 /// Check that the lifetime of the initializer (and its subobjects) is
8700 /// sufficient for initializing the entity, and perform lifetime extension
8701 /// (when permitted) if not.
8703
8706 bool BoundToLvalueReference);
8707
8708 /// If \p E is a prvalue denoting an unmaterialized temporary, materialize
8709 /// it as an xvalue. In C++98, the result will still be a prvalue, because
8710 /// we don't have xvalues there.
8712
8716
8720 SourceLocation EqualLoc, ExprResult Init,
8721 bool TopLevelOfInitList = false,
8722 bool AllowExplicit = false);
8723
8725 TypeSourceInfo *TInfo, const InitializedEntity &Entity,
8727
8728 ///@}
8729
8730 //
8731 //
8732 // -------------------------------------------------------------------------
8733 //
8734 //
8735
8736 /// \name C++ Lambda Expressions
8737 /// Implementations are in SemaLambda.cpp
8738 ///@{
8739
8740public:
8741 /// Create a new lambda closure type.
8743 TypeSourceInfo *Info,
8744 unsigned LambdaDependencyKind,
8745 LambdaCaptureDefault CaptureDefault);
8746
8747 /// Number lambda for linkage purposes if necessary.
8749 std::optional<CXXRecordDecl::LambdaNumbering>
8750 NumberingOverride = std::nullopt);
8751
8752 /// Endow the lambda scope info with the relevant properties.
8753 void buildLambdaScope(sema::LambdaScopeInfo *LSI, CXXMethodDecl *CallOperator,
8754 SourceRange IntroducerRange,
8755 LambdaCaptureDefault CaptureDefault,
8756 SourceLocation CaptureDefaultLoc, bool ExplicitParams,
8757 bool Mutable);
8758
8761
8763 CXXMethodDecl *CallOperator, CXXRecordDecl *Class,
8764 TemplateParameterList *TemplateParams);
8765
8767 CXXMethodDecl *Method, SourceLocation LambdaLoc,
8768 SourceLocation CallOperatorLoc, Expr *TrailingRequiresClause,
8769 TypeSourceInfo *MethodTyInfo, ConstexprSpecKind ConstexprKind,
8771 bool HasExplicitResultType);
8772
8773 /// Returns true if the explicit object parameter was invalid.
8775 SourceLocation CallLoc);
8776
8777 /// Perform initialization analysis of the init-capture and perform
8778 /// any implicit conversions such as an lvalue-to-rvalue conversion if
8779 /// not being used to initialize a reference.
8781 SourceLocation Loc, bool ByRef, SourceLocation EllipsisLoc,
8784 Loc, ByRef, EllipsisLoc, std::nullopt, Id,
8786 }
8788 SourceLocation Loc, bool ByRef, SourceLocation EllipsisLoc,
8789 std::optional<unsigned> NumExpansions, IdentifierInfo *Id,
8790 bool DirectInit, Expr *&Init);
8791
8792 /// Create a dummy variable within the declcontext of the lambda's
8793 /// call operator, for name lookup purposes for a lambda init capture.
8794 ///
8795 /// CodeGen handles emission of lambda captures, ignoring these dummy
8796 /// variables appropriately.
8798 SourceLocation Loc, QualType InitCaptureType, SourceLocation EllipsisLoc,
8799 IdentifierInfo *Id, unsigned InitStyle, Expr *Init, DeclContext *DeclCtx);
8800
8801 /// Add an init-capture to a lambda scope.
8802 void addInitCapture(sema::LambdaScopeInfo *LSI, VarDecl *Var, bool ByRef);
8803
8804 /// Note that we have finished the explicit captures for the
8805 /// given lambda.
8807
8808 /// Deduce a block or lambda's return type based on the return
8809 /// statements present in the body.
8811
8812 /// Once the Lambdas capture are known, we can start to create the closure,
8813 /// call operator method, and keep track of the captures.
8814 /// We do the capture lookup here, but they are not actually captured until
8815 /// after we know what the qualifiers of the call operator are.
8817 Scope *CurContext);
8818
8819 /// This is called after parsing the explicit template parameter list
8820 /// on a lambda (if it exists) in C++2a.
8822 SourceLocation LAngleLoc,
8823 ArrayRef<NamedDecl *> TParams,
8824 SourceLocation RAngleLoc,
8825 ExprResult RequiresClause);
8826
8828 SourceLocation MutableLoc);
8829
8831 Scope *LambdaScope,
8833
8834 /// ActOnStartOfLambdaDefinition - This is called just before we start
8835 /// parsing the body of a lambda; it analyzes the explicit captures and
8836 /// arguments, and sets up various data-structures for the body of the
8837 /// lambda.
8839 Declarator &ParamInfo, const DeclSpec &DS);
8840
8841 /// ActOnLambdaError - If there is an error parsing a lambda, this callback
8842 /// is invoked to pop the information about the lambda.
8843 void ActOnLambdaError(SourceLocation StartLoc, Scope *CurScope,
8844 bool IsInstantiation = false);
8845
8846 /// ActOnLambdaExpr - This is called when the body of a lambda expression
8847 /// was successfully completed.
8849
8850 /// Does copying/destroying the captured variable have side effects?
8851 bool CaptureHasSideEffects(const sema::Capture &From);
8852
8853 /// Diagnose if an explicit lambda capture is unused. Returns true if a
8854 /// diagnostic is emitted.
8855 bool DiagnoseUnusedLambdaCapture(SourceRange CaptureRange,
8856 const sema::Capture &From);
8857
8858 /// Build a FieldDecl suitable to hold the given capture.
8860
8861 /// Initialize the given capture with a suitable expression.
8863 SourceLocation ImplicitCaptureLoc,
8864 bool IsOpenMPMapping = false);
8865
8866 /// Complete a lambda-expression having processed and attached the
8867 /// lambda body.
8870
8871 /// Get the return type to use for a lambda's conversion function(s) to
8872 /// function pointer type, given the type of the call operator.
8873 QualType
8875 CallingConv CC);
8876
8878 SourceLocation ConvLocation,
8879 CXXConversionDecl *Conv, Expr *Src);
8880
8882 : private FunctionScopeRAII {
8883 public:
8885 Sema &SemasRef, FunctionDecl *FD, MultiLevelTemplateArgumentList MLTAL,
8887 bool ShouldAddDeclsFromParentScope = true);
8888 };
8889
8890 /// Compute the mangling number context for a lambda expression or
8891 /// block literal. Also return the extra mangling decl if any.
8892 ///
8893 /// \param DC - The DeclContext containing the lambda expression or
8894 /// block literal.
8895 std::tuple<MangleNumberingContext *, Decl *>
8897
8898 ///@}
8899
8900 //
8901 //
8902 // -------------------------------------------------------------------------
8903 //
8904 //
8905
8906 /// \name Name Lookup
8907 ///
8908 /// These routines provide name lookup that is used during semantic
8909 /// analysis to resolve the various kinds of names (identifiers,
8910 /// overloaded operator names, constructor names, etc.) into zero or
8911 /// more declarations within a particular scope. The major entry
8912 /// points are LookupName, which performs unqualified name lookup,
8913 /// and LookupQualifiedName, which performs qualified name lookup.
8914 ///
8915 /// All name lookup is performed based on some specific criteria,
8916 /// which specify what names will be visible to name lookup and how
8917 /// far name lookup should work. These criteria are important both
8918 /// for capturing language semantics (certain lookups will ignore
8919 /// certain names, for example) and for performance, since name
8920 /// lookup is often a bottleneck in the compilation of C++. Name
8921 /// lookup criteria is specified via the LookupCriteria enumeration.
8922 ///
8923 /// The results of name lookup can vary based on the kind of name
8924 /// lookup performed, the current language, and the translation
8925 /// unit. In C, for example, name lookup will either return nothing
8926 /// (no entity found) or a single declaration. In C++, name lookup
8927 /// can additionally refer to a set of overloaded functions or
8928 /// result in an ambiguity. All of the possible results of name
8929 /// lookup are captured by the LookupResult class, which provides
8930 /// the ability to distinguish among them.
8931 ///
8932 /// Implementations are in SemaLookup.cpp
8933 ///@{
8934
8935public:
8936 /// Tracks whether we are in a context where typo correction is
8937 /// disabled.
8939
8940 /// The number of typos corrected by CorrectTypo.
8942
8943 typedef llvm::SmallSet<SourceLocation, 2> SrcLocSet;
8944 typedef llvm::DenseMap<IdentifierInfo *, SrcLocSet> IdentifierSourceLocations;
8945
8946 /// A cache containing identifiers for which typo correction failed and
8947 /// their locations, so that repeated attempts to correct an identifier in a
8948 /// given location are ignored if typo correction already failed for it.
8950
8951 /// SpecialMemberOverloadResult - The overloading result for a special member
8952 /// function.
8953 ///
8954 /// This is basically a wrapper around PointerIntPair. The lowest bits of the
8955 /// integer are used to determine whether overload resolution succeeded.
8957 public:
8958 enum Kind { NoMemberOrDeleted, Ambiguous, Success };
8959
8960 private:
8961 llvm::PointerIntPair<CXXMethodDecl *, 2> Pair;
8962
8963 public:
8966 : Pair(MD, MD->isDeleted() ? NoMemberOrDeleted : Success) {}
8967
8968 CXXMethodDecl *getMethod() const { return Pair.getPointer(); }
8969 void setMethod(CXXMethodDecl *MD) { Pair.setPointer(MD); }
8970
8971 Kind getKind() const { return static_cast<Kind>(Pair.getInt()); }
8972 void setKind(Kind K) { Pair.setInt(K); }
8973 };
8974
8975 class SpecialMemberOverloadResultEntry : public llvm::FastFoldingSetNode,
8977 public:
8978 SpecialMemberOverloadResultEntry(const llvm::FoldingSetNodeID &ID)
8979 : FastFoldingSetNode(ID) {}
8980 };
8981
8982 /// A cache of special member function overload resolution results
8983 /// for C++ records.
8984 llvm::FoldingSet<SpecialMemberOverloadResultEntry> SpecialMemberCache;
8985
8986 /// Holds TypoExprs that are created from `createDelayedTypo`. This is used by
8987 /// `TransformTypos` in order to keep track of any TypoExprs that are created
8988 /// recursively during typo correction and wipe them away if the correction
8989 /// fails.
8991
8993
8994 // Members have to be NamespaceDecl* or TranslationUnitDecl*.
8995 // TODO: make this is a typesafe union.
8998
8999 /// Describes the kind of name lookup to perform.
9001 /// Ordinary name lookup, which finds ordinary names (functions,
9002 /// variables, typedefs, etc.) in C and most kinds of names
9003 /// (functions, variables, members, types, etc.) in C++.
9005 /// Tag name lookup, which finds the names of enums, classes,
9006 /// structs, and unions.
9008 /// Label name lookup.
9010 /// Member name lookup, which finds the names of
9011 /// class/struct/union members.
9013 /// Look up of an operator name (e.g., operator+) for use with
9014 /// operator overloading. This lookup is similar to ordinary name
9015 /// lookup, but will ignore any declarations that are class members.
9017 /// Look up a name following ~ in a destructor name. This is an ordinary
9018 /// lookup, but prefers tags to typedefs.
9020 /// Look up of a name that precedes the '::' scope resolution
9021 /// operator in C++. This lookup completely ignores operator, object,
9022 /// function, and enumerator names (C++ [basic.lookup.qual]p1).
9024 /// Look up a namespace name within a C++ using directive or
9025 /// namespace alias definition, ignoring non-namespace names (C++
9026 /// [basic.lookup.udir]p1).
9028 /// Look up all declarations in a scope with the given name,
9029 /// including resolved using declarations. This is appropriate
9030 /// for checking redeclarations for a using declaration.
9032 /// Look up an ordinary name that is going to be redeclared as a
9033 /// name with linkage. This lookup ignores any declarations that
9034 /// are outside of the current scope unless they have linkage. See
9035 /// C99 6.2.2p4-5 and C++ [basic.link]p6.
9037 /// Look up a friend of a local class. This lookup does not look
9038 /// outside the innermost non-class scope. See C++11 [class.friend]p11.
9040 /// Look up the name of an Objective-C protocol.
9042 /// Look up implicit 'self' parameter of an objective-c method.
9044 /// Look up the name of an OpenMP user-defined reduction operation.
9046 /// Look up the name of an OpenMP user-defined mapper.
9048 /// Look up any declaration with any name.
9051
9052 /// The possible outcomes of name lookup for a literal operator.
9054 /// The lookup resulted in an error.
9056 /// The lookup found no match but no diagnostic was issued.
9058 /// The lookup found a single 'cooked' literal operator, which
9059 /// expects a normal literal to be built and passed to it.
9061 /// The lookup found a single 'raw' literal operator, which expects
9062 /// a string literal containing the spelling of the literal token.
9064 /// The lookup found an overload set of literal operator templates,
9065 /// which expect the characters of the spelling of the literal token to be
9066 /// passed as a non-type template argument pack.
9068 /// The lookup found an overload set of literal operator templates,
9069 /// which expect the character type and characters of the spelling of the
9070 /// string literal token to be passed as template arguments.
9072 };
9073
9074 SpecialMemberOverloadResult
9076 bool VolatileArg, bool RValueThis, bool ConstThis,
9077 bool VolatileThis);
9078
9079 typedef std::function<void(const TypoCorrection &)> TypoDiagnosticGenerator;
9080 typedef std::function<ExprResult(Sema &, TypoExpr *, TypoCorrection)>
9082
9084
9085 /// Look up a name, looking for a single declaration. Return
9086 /// null if the results were absent, ambiguous, or overloaded.
9087 ///
9088 /// It is preferable to use the elaborated form and explicitly handle
9089 /// ambiguity and overloaded.
9092 LookupNameKind NameKind,
9093 RedeclarationKind Redecl = RedeclarationKind::NotForRedeclaration);
9094
9095 /// Lookup a builtin function, when name lookup would otherwise
9096 /// fail.
9097 bool LookupBuiltin(LookupResult &R);
9098 void LookupNecessaryTypesForBuiltin(Scope *S, unsigned ID);
9099
9100 /// Perform unqualified name lookup starting from a given
9101 /// scope.
9102 ///
9103 /// Unqualified name lookup (C++ [basic.lookup.unqual], C99 6.2.1) is
9104 /// used to find names within the current scope. For example, 'x' in
9105 /// @code
9106 /// int x;
9107 /// int f() {
9108 /// return x; // unqualified name look finds 'x' in the global scope
9109 /// }
9110 /// @endcode
9111 ///
9112 /// Different lookup criteria can find different names. For example, a
9113 /// particular scope can have both a struct and a function of the same
9114 /// name, and each can be found by certain lookup criteria. For more
9115 /// information about lookup criteria, see the documentation for the
9116 /// class LookupCriteria.
9117 ///
9118 /// @param S The scope from which unqualified name lookup will
9119 /// begin. If the lookup criteria permits, name lookup may also search
9120 /// in the parent scopes.
9121 ///
9122 /// @param [in,out] R Specifies the lookup to perform (e.g., the name to
9123 /// look up and the lookup kind), and is updated with the results of lookup
9124 /// including zero or more declarations and possibly additional information
9125 /// used to diagnose ambiguities.
9126 ///
9127 /// @returns \c true if lookup succeeded and false otherwise.
9128 bool LookupName(LookupResult &R, Scope *S, bool AllowBuiltinCreation = false,
9129 bool ForceNoCPlusPlus = false);
9130
9131 /// Perform qualified name lookup into a given context.
9132 ///
9133 /// Qualified name lookup (C++ [basic.lookup.qual]) is used to find
9134 /// names when the context of those names is explicit specified, e.g.,
9135 /// "std::vector" or "x->member", or as part of unqualified name lookup.
9136 ///
9137 /// Different lookup criteria can find different names. For example, a
9138 /// particular scope can have both a struct and a function of the same
9139 /// name, and each can be found by certain lookup criteria. For more
9140 /// information about lookup criteria, see the documentation for the
9141 /// class LookupCriteria.
9142 ///
9143 /// \param R captures both the lookup criteria and any lookup results found.
9144 ///
9145 /// \param LookupCtx The context in which qualified name lookup will
9146 /// search. If the lookup criteria permits, name lookup may also search
9147 /// in the parent contexts or (for C++ classes) base classes.
9148 ///
9149 /// \param InUnqualifiedLookup true if this is qualified name lookup that
9150 /// occurs as part of unqualified name lookup.
9151 ///
9152 /// \returns true if lookup succeeded, false if it failed.
9153 bool LookupQualifiedName(LookupResult &R, DeclContext *LookupCtx,
9154 bool InUnqualifiedLookup = false);
9155
9156 /// Performs qualified name lookup or special type of lookup for
9157 /// "__super::" scope specifier.
9158 ///
9159 /// This routine is a convenience overload meant to be called from contexts
9160 /// that need to perform a qualified name lookup with an optional C++ scope
9161 /// specifier that might require special kind of lookup.
9162 ///
9163 /// \param R captures both the lookup criteria and any lookup results found.
9164 ///
9165 /// \param LookupCtx The context in which qualified name lookup will
9166 /// search.
9167 ///
9168 /// \param SS An optional C++ scope-specifier.
9169 ///
9170 /// \returns true if lookup succeeded, false if it failed.
9171 bool LookupQualifiedName(LookupResult &R, DeclContext *LookupCtx,
9172 CXXScopeSpec &SS);
9173
9174 /// Performs name lookup for a name that was parsed in the
9175 /// source code, and may contain a C++ scope specifier.
9176 ///
9177 /// This routine is a convenience routine meant to be called from
9178 /// contexts that receive a name and an optional C++ scope specifier
9179 /// (e.g., "N::M::x"). It will then perform either qualified or
9180 /// unqualified name lookup (with LookupQualifiedName or LookupName,
9181 /// respectively) on the given name and return those results. It will
9182 /// perform a special type of lookup for "__super::" scope specifier.
9183 ///
9184 /// @param S The scope from which unqualified name lookup will
9185 /// begin.
9186 ///
9187 /// @param SS An optional C++ scope-specifier, e.g., "::N::M".
9188 ///
9189 /// @param EnteringContext Indicates whether we are going to enter the
9190 /// context of the scope-specifier SS (if present).
9191 ///
9192 /// @returns True if any decls were found (but possibly ambiguous)
9194 QualType ObjectType, bool AllowBuiltinCreation = false,
9195 bool EnteringContext = false);
9196
9197 /// Perform qualified name lookup into all base classes of the given
9198 /// class.
9199 ///
9200 /// \param R captures both the lookup criteria and any lookup results found.
9201 ///
9202 /// \param Class The context in which qualified name lookup will
9203 /// search. Name lookup will search in all base classes merging the results.
9204 ///
9205 /// @returns True if any decls were found (but possibly ambiguous)
9207
9209 UnresolvedSetImpl &Functions);
9210
9211 /// LookupOrCreateLabel - Do a name lookup of a label with the specified name.
9212 /// If GnuLabelLoc is a valid source location, then this is a definition
9213 /// of an __label__ label name, otherwise it is a normal label definition
9214 /// or use.
9216 SourceLocation GnuLabelLoc = SourceLocation());
9217
9218 /// Look up the constructors for the given class.
9220
9221 /// Look up the default constructor for the given class.
9223
9224 /// Look up the copying constructor for the given class.
9226 unsigned Quals);
9227
9228 /// Look up the copying assignment operator for the given class.
9230 bool RValueThis, unsigned ThisQuals);
9231
9232 /// Look up the moving constructor for the given class.
9234 unsigned Quals);
9235
9236 /// Look up the moving assignment operator for the given class.
9238 bool RValueThis, unsigned ThisQuals);
9239
9240 /// Look for the destructor of the given class.
9241 ///
9242 /// During semantic analysis, this routine should be used in lieu of
9243 /// CXXRecordDecl::getDestructor().
9244 ///
9245 /// \returns The destructor for this class.
9247
9248 /// Force the declaration of any implicitly-declared members of this
9249 /// class.
9251
9252 /// Make a merged definition of an existing hidden definition \p ND
9253 /// visible at the specified location.
9255
9256 /// Check ODR hashes for C/ObjC when merging types from modules.
9257 /// Differently from C++, actually parse the body and reject in case
9258 /// of a mismatch.
9259 template <typename T,
9260 typename = std::enable_if_t<std::is_base_of<NamedDecl, T>::value>>
9262 if (Duplicate->getODRHash() != Previous->getODRHash())
9263 return false;
9264
9265 // Make the previous decl visible.
9267 return true;
9268 }
9269
9270 /// Get the set of additional modules that should be checked during
9271 /// name lookup. A module and its imports become visible when instanting a
9272 /// template defined within it.
9273 llvm::DenseSet<Module *> &getLookupModules();
9274
9275 bool hasVisibleMergedDefinition(const NamedDecl *Def);
9277
9278 /// Determine if the template parameter \p D has a visible default argument.
9279 bool
9281 llvm::SmallVectorImpl<Module *> *Modules = nullptr);
9282 /// Determine if the template parameter \p D has a reachable default argument.
9284 const NamedDecl *D, llvm::SmallVectorImpl<Module *> *Modules = nullptr);
9285 /// Determine if the template parameter \p D has a reachable default argument.
9289
9290 /// Determine if there is a visible declaration of \p D that is an explicit
9291 /// specialization declaration for a specialization of a template. (For a
9292 /// member specialization, use hasVisibleMemberSpecialization.)
9294 const NamedDecl *D, llvm::SmallVectorImpl<Module *> *Modules = nullptr);
9295 /// Determine if there is a reachable declaration of \p D that is an explicit
9296 /// specialization declaration for a specialization of a template. (For a
9297 /// member specialization, use hasReachableMemberSpecialization.)
9299 const NamedDecl *D, llvm::SmallVectorImpl<Module *> *Modules = nullptr);
9300
9301 /// Determine if there is a visible declaration of \p D that is a member
9302 /// specialization declaration (as opposed to an instantiated declaration).
9304 const NamedDecl *D, llvm::SmallVectorImpl<Module *> *Modules = nullptr);
9305 /// Determine if there is a reachable declaration of \p D that is a member
9306 /// specialization declaration (as opposed to an instantiated declaration).
9308 const NamedDecl *D, llvm::SmallVectorImpl<Module *> *Modules = nullptr);
9309
9310 bool isModuleVisible(const Module *M, bool ModulePrivate = false);
9311
9312 /// Determine whether any declaration of an entity is visible.
9313 bool
9315 llvm::SmallVectorImpl<Module *> *Modules = nullptr) {
9316 return isVisible(D) || hasVisibleDeclarationSlow(D, Modules);
9317 }
9318
9321 /// Determine whether any declaration of an entity is reachable.
9322 bool
9324 llvm::SmallVectorImpl<Module *> *Modules = nullptr) {
9325 return isReachable(D) || hasReachableDeclarationSlow(D, Modules);
9326 }
9328 const NamedDecl *D, llvm::SmallVectorImpl<Module *> *Modules = nullptr);
9329
9330 void diagnoseTypo(const TypoCorrection &Correction,
9331 const PartialDiagnostic &TypoDiag,
9332 bool ErrorRecovery = true);
9333
9334 /// Diagnose a successfully-corrected typo. Separated from the correction
9335 /// itself to allow external validation of the result, etc.
9336 ///
9337 /// \param Correction The result of performing typo correction.
9338 /// \param TypoDiag The diagnostic to produce. This will have the corrected
9339 /// string added to it (and usually also a fixit).
9340 /// \param PrevNote A note to use when indicating the location of the entity
9341 /// to which we are correcting. Will have the correction string added
9342 /// to it.
9343 /// \param ErrorRecovery If \c true (the default), the caller is going to
9344 /// recover from the typo as if the corrected string had been typed.
9345 /// In this case, \c PDiag must be an error, and we will attach a fixit
9346 /// to it.
9347 void diagnoseTypo(const TypoCorrection &Correction,
9348 const PartialDiagnostic &TypoDiag,
9349 const PartialDiagnostic &PrevNote,
9350 bool ErrorRecovery = true);
9351
9352 /// Find the associated classes and namespaces for
9353 /// argument-dependent lookup for a call with the given set of
9354 /// arguments.
9355 ///
9356 /// This routine computes the sets of associated classes and associated
9357 /// namespaces searched by argument-dependent lookup
9358 /// (C++ [basic.lookup.argdep]) for a given set of arguments.
9360 SourceLocation InstantiationLoc, ArrayRef<Expr *> Args,
9361 AssociatedNamespaceSet &AssociatedNamespaces,
9362 AssociatedClassSet &AssociatedClasses);
9363
9364 /// Produce a diagnostic describing the ambiguity that resulted
9365 /// from name lookup.
9366 ///
9367 /// \param Result The result of the ambiguous lookup to be diagnosed.
9369
9370 /// LookupLiteralOperator - Determine which literal operator should be used
9371 /// for a user-defined literal, per C++11 [lex.ext].
9372 ///
9373 /// Normal overload resolution is not used to select which literal operator to
9374 /// call for a user-defined literal. Look up the provided literal operator
9375 /// name, and filter the results to the appropriate set for the given argument
9376 /// types.
9379 bool AllowRaw, bool AllowTemplate,
9380 bool AllowStringTemplate, bool DiagnoseMissing,
9381 StringLiteral *StringLit = nullptr);
9382
9384 ArrayRef<Expr *> Args, ADLResult &Functions);
9385
9388 bool IncludeGlobalScope = true,
9389 bool LoadExternal = true);
9392 bool IncludeGlobalScope = true,
9393 bool IncludeDependentBases = false,
9394 bool LoadExternal = true);
9395
9397 CTK_NonError, // CorrectTypo used in a non error recovery situation.
9398 CTK_ErrorRecovery // CorrectTypo used in normal error recovery.
9400
9401 /// Try to "correct" a typo in the source code by finding
9402 /// visible declarations whose names are similar to the name that was
9403 /// present in the source code.
9404 ///
9405 /// \param TypoName the \c DeclarationNameInfo structure that contains
9406 /// the name that was present in the source code along with its location.
9407 ///
9408 /// \param LookupKind the name-lookup criteria used to search for the name.
9409 ///
9410 /// \param S the scope in which name lookup occurs.
9411 ///
9412 /// \param SS the nested-name-specifier that precedes the name we're
9413 /// looking for, if present.
9414 ///
9415 /// \param CCC A CorrectionCandidateCallback object that provides further
9416 /// validation of typo correction candidates. It also provides flags for
9417 /// determining the set of keywords permitted.
9418 ///
9419 /// \param MemberContext if non-NULL, the context in which to look for
9420 /// a member access expression.
9421 ///
9422 /// \param EnteringContext whether we're entering the context described by
9423 /// the nested-name-specifier SS.
9424 ///
9425 /// \param OPT when non-NULL, the search for visible declarations will
9426 /// also walk the protocols in the qualified interfaces of \p OPT.
9427 ///
9428 /// \returns a \c TypoCorrection containing the corrected name if the typo
9429 /// along with information such as the \c NamedDecl where the corrected name
9430 /// was declared, and any additional \c NestedNameSpecifier needed to access
9431 /// it (C++ only). The \c TypoCorrection is empty if there is no correction.
9433 Sema::LookupNameKind LookupKind, Scope *S,
9435 CorrectTypoKind Mode,
9436 DeclContext *MemberContext = nullptr,
9437 bool EnteringContext = false,
9438 const ObjCObjectPointerType *OPT = nullptr,
9439 bool RecordFailure = true);
9440
9441 /// Try to "correct" a typo in the source code by finding
9442 /// visible declarations whose names are similar to the name that was
9443 /// present in the source code.
9444 ///
9445 /// \param TypoName the \c DeclarationNameInfo structure that contains
9446 /// the name that was present in the source code along with its location.
9447 ///
9448 /// \param LookupKind the name-lookup criteria used to search for the name.
9449 ///
9450 /// \param S the scope in which name lookup occurs.
9451 ///
9452 /// \param SS the nested-name-specifier that precedes the name we're
9453 /// looking for, if present.
9454 ///
9455 /// \param CCC A CorrectionCandidateCallback object that provides further
9456 /// validation of typo correction candidates. It also provides flags for
9457 /// determining the set of keywords permitted.
9458 ///
9459 /// \param TDG A TypoDiagnosticGenerator functor that will be used to print
9460 /// diagnostics when the actual typo correction is attempted.
9461 ///
9462 /// \param TRC A TypoRecoveryCallback functor that will be used to build an
9463 /// Expr from a typo correction candidate.
9464 ///
9465 /// \param MemberContext if non-NULL, the context in which to look for
9466 /// a member access expression.
9467 ///
9468 /// \param EnteringContext whether we're entering the context described by
9469 /// the nested-name-specifier SS.
9470 ///
9471 /// \param OPT when non-NULL, the search for visible declarations will
9472 /// also walk the protocols in the qualified interfaces of \p OPT.
9473 ///
9474 /// \returns a new \c TypoExpr that will later be replaced in the AST with an
9475 /// Expr representing the result of performing typo correction, or nullptr if
9476 /// typo correction is not possible. If nullptr is returned, no diagnostics
9477 /// will be emitted and it is the responsibility of the caller to emit any
9478 /// that are needed.
9480 const DeclarationNameInfo &Typo, Sema::LookupNameKind LookupKind,
9483 CorrectTypoKind Mode, DeclContext *MemberContext = nullptr,
9484 bool EnteringContext = false, const ObjCObjectPointerType *OPT = nullptr);
9485
9486 /// Kinds of missing import. Note, the values of these enumerators correspond
9487 /// to %select values in diagnostics.
9490 Definition,
9494 };
9495
9496 /// Diagnose that the specified declaration needs to be visible but
9497 /// isn't, and suggest a module import that would resolve the problem.
9499 MissingImportKind MIK, bool Recover = true);
9501 SourceLocation DeclLoc, ArrayRef<Module *> Modules,
9502 MissingImportKind MIK, bool Recover);
9503
9505 std::unique_ptr<TypoCorrectionConsumer> Consumer;
9508 TypoExprState();
9509 TypoExprState(TypoExprState &&other) noexcept;
9510 TypoExprState &operator=(TypoExprState &&other) noexcept;
9511 };
9512
9513 const TypoExprState &getTypoExprState(TypoExpr *TE) const;
9514
9515 /// Clears the state of the given TypoExpr.
9516 void clearDelayedTypo(TypoExpr *TE);
9517
9518 /// Called on #pragma clang __debug dump II
9520
9521 /// Called on #pragma clang __debug dump E
9522 void ActOnPragmaDump(Expr *E);
9523
9524private:
9525 // The set of known/encountered (unique, canonicalized) NamespaceDecls.
9526 //
9527 // The boolean value will be true to indicate that the namespace was loaded
9528 // from an AST/PCH file, or false otherwise.
9529 llvm::MapVector<NamespaceDecl *, bool> KnownNamespaces;
9530
9531 /// Whether we have already loaded known namespaces from an extenal
9532 /// source.
9533 bool LoadedExternalKnownNamespaces;
9534
9535 bool CppLookupName(LookupResult &R, Scope *S);
9536
9537 /// Determine if we could use all the declarations in the module.
9538 bool isUsableModule(const Module *M);
9539
9540 /// Helper for CorrectTypo and CorrectTypoDelayed used to create and
9541 /// populate a new TypoCorrectionConsumer. Returns nullptr if typo correction
9542 /// should be skipped entirely.
9543 std::unique_ptr<TypoCorrectionConsumer> makeTypoCorrectionConsumer(
9544 const DeclarationNameInfo &Typo, Sema::LookupNameKind LookupKind,
9546 DeclContext *MemberContext, bool EnteringContext,
9547 const ObjCObjectPointerType *OPT, bool ErrorRecovery);
9548
9549 /// The set of unhandled TypoExprs and their associated state.
9550 llvm::MapVector<TypoExpr *, TypoExprState> DelayedTypos;
9551
9552 /// Creates a new TypoExpr AST node.
9553 TypoExpr *createDelayedTypo(std::unique_ptr<TypoCorrectionConsumer> TCC,
9556
9557 /// Cache for module units which is usable for current module.
9558 llvm::DenseSet<const Module *> UsableModuleUnitsCache;
9559
9560 /// Record the typo correction failure and return an empty correction.
9561 TypoCorrection FailedCorrection(IdentifierInfo *Typo, SourceLocation TypoLoc,
9562 bool RecordFailure = true) {
9563 if (RecordFailure)
9564 TypoCorrectionFailures[Typo].insert(TypoLoc);
9565 return TypoCorrection();
9566 }
9567
9568 bool isAcceptableSlow(const NamedDecl *D, AcceptableKind Kind);
9569
9570 /// Determine whether two declarations should be linked together, given that
9571 /// the old declaration might not be visible and the new declaration might
9572 /// not have external linkage.
9573 bool shouldLinkPossiblyHiddenDecl(const NamedDecl *Old,
9574 const NamedDecl *New) {
9575 if (isVisible(Old))
9576 return true;
9577 // See comment in below overload for why it's safe to compute the linkage
9578 // of the new declaration here.
9579 if (New->isExternallyDeclarable()) {
9580 assert(Old->isExternallyDeclarable() &&
9581 "should not have found a non-externally-declarable previous decl");
9582 return true;
9583 }
9584 return false;
9585 }
9586 bool shouldLinkPossiblyHiddenDecl(LookupResult &Old, const NamedDecl *New);
9587
9588 ///@}
9589
9590 //
9591 //
9592 // -------------------------------------------------------------------------
9593 //
9594 //
9595
9596 /// \name Modules
9597 /// Implementations are in SemaModule.cpp
9598 ///@{
9599
9600public:
9601 /// Get the module unit whose scope we are currently within.
9603 return ModuleScopes.empty() ? nullptr : ModuleScopes.back().Module;
9604 }
9605
9606 /// Is the module scope we are an implementation unit?
9608 return ModuleScopes.empty()
9609 ? false
9610 : ModuleScopes.back().Module->isModuleImplementation();
9611 }
9612
9613 // When loading a non-modular PCH files, this is used to restore module
9614 // visibility.
9616 VisibleModules.setVisible(Mod, ImportLoc);
9617 }
9618
9619 enum class ModuleDeclKind {
9620 Interface, ///< 'export module X;'
9621 Implementation, ///< 'module X;'
9622 PartitionInterface, ///< 'export module X:Y;'
9623 PartitionImplementation, ///< 'module X:Y;'
9624 };
9625
9626 /// An enumeration to represent the transition of states in parsing module
9627 /// fragments and imports. If we are not parsing a C++20 TU, or we find
9628 /// an error in state transition, the state is set to NotACXX20Module.
9630 FirstDecl, ///< Parsing the first decl in a TU.
9631 GlobalFragment, ///< after 'module;' but before 'module X;'
9632 ImportAllowed, ///< after 'module X;' but before any non-import decl.
9633 ImportFinished, ///< after any non-import decl.
9634 PrivateFragmentImportAllowed, ///< after 'module :private;' but before any
9635 ///< non-import decl.
9636 PrivateFragmentImportFinished, ///< after 'module :private;' but a
9637 ///< non-import decl has already been seen.
9638 NotACXX20Module ///< Not a C++20 TU, or an invalid state was found.
9639 };
9640
9641 /// The parser has processed a module-declaration that begins the definition
9642 /// of a module interface or implementation.
9644 SourceLocation ModuleLoc, ModuleDeclKind MDK,
9645 ModuleIdPath Path, ModuleIdPath Partition,
9646 ModuleImportState &ImportState);
9647
9648 /// The parser has processed a global-module-fragment declaration that begins
9649 /// the definition of the global module fragment of the current module unit.
9650 /// \param ModuleLoc The location of the 'module' keyword.
9652
9653 /// The parser has processed a private-module-fragment declaration that begins
9654 /// the definition of the private module fragment of the current module unit.
9655 /// \param ModuleLoc The location of the 'module' keyword.
9656 /// \param PrivateLoc The location of the 'private' keyword.
9658 SourceLocation PrivateLoc);
9659
9660 /// The parser has processed a module import declaration.
9661 ///
9662 /// \param StartLoc The location of the first token in the declaration. This
9663 /// could be the location of an '@', 'export', or 'import'.
9664 /// \param ExportLoc The location of the 'export' keyword, if any.
9665 /// \param ImportLoc The location of the 'import' keyword.
9666 /// \param Path The module toplevel name as an access path.
9667 /// \param IsPartition If the name is for a partition.
9669 SourceLocation ExportLoc,
9670 SourceLocation ImportLoc, ModuleIdPath Path,
9671 bool IsPartition = false);
9673 SourceLocation ExportLoc,
9674 SourceLocation ImportLoc, Module *M,
9675 ModuleIdPath Path = {});
9676
9677 /// The parser has processed a module import translated from a
9678 /// #include or similar preprocessing directive.
9679 void ActOnAnnotModuleInclude(SourceLocation DirectiveLoc, Module *Mod);
9680 void BuildModuleInclude(SourceLocation DirectiveLoc, Module *Mod);
9681
9682 /// The parsed has entered a submodule.
9683 void ActOnAnnotModuleBegin(SourceLocation DirectiveLoc, Module *Mod);
9684 /// The parser has left a submodule.
9685 void ActOnAnnotModuleEnd(SourceLocation DirectiveLoc, Module *Mod);
9686
9687 /// Create an implicit import of the given module at the given
9688 /// source location, for error recovery, if possible.
9689 ///
9690 /// This routine is typically used when an entity found by name lookup
9691 /// is actually hidden within a module that we know about but the user
9692 /// has forgotten to import.
9694 Module *Mod);
9695
9696 /// We have parsed the start of an export declaration, including the '{'
9697 /// (if present).
9698 Decl *ActOnStartExportDecl(Scope *S, SourceLocation ExportLoc,
9699 SourceLocation LBraceLoc);
9700
9701 /// Complete the definition of an export declaration.
9702 Decl *ActOnFinishExportDecl(Scope *S, Decl *ExportDecl,
9703 SourceLocation RBraceLoc);
9704
9705private:
9706 /// The parser has begun a translation unit to be compiled as a C++20
9707 /// Header Unit, helper for ActOnStartOfTranslationUnit() only.
9708 void HandleStartOfHeaderUnit();
9709
9710 struct ModuleScope {
9711 SourceLocation BeginLoc;
9712 clang::Module *Module = nullptr;
9713 VisibleModuleSet OuterVisibleModules;
9714 };
9715 /// The modules we're currently parsing.
9717
9718 /// For an interface unit, this is the implicitly imported interface unit.
9719 clang::Module *ThePrimaryInterface = nullptr;
9720
9721 /// The explicit global module fragment of the current translation unit.
9722 /// The explicit Global Module Fragment, as specified in C++
9723 /// [module.global.frag].
9724 clang::Module *TheGlobalModuleFragment = nullptr;
9725
9726 /// The implicit global module fragments of the current translation unit.
9727 ///
9728 /// The contents in the implicit global module fragment can't be discarded.
9729 clang::Module *TheImplicitGlobalModuleFragment = nullptr;
9730
9731 /// Namespace definitions that we will export when they finish.
9732 llvm::SmallPtrSet<const NamespaceDecl *, 8> DeferredExportedNamespaces;
9733
9734 /// In a C++ standard module, inline declarations require a definition to be
9735 /// present at the end of a definition domain. This set holds the decls to
9736 /// be checked at the end of the TU.
9737 llvm::SmallPtrSet<const FunctionDecl *, 8> PendingInlineFuncDecls;
9738
9739 /// Helper function to judge if we are in module purview.
9740 /// Return false if we are not in a module.
9741 bool isCurrentModulePurview() const;
9742
9743 /// Enter the scope of the explicit global module fragment.
9744 Module *PushGlobalModuleFragment(SourceLocation BeginLoc);
9745 /// Leave the scope of the explicit global module fragment.
9746 void PopGlobalModuleFragment();
9747
9748 /// Enter the scope of an implicit global module fragment.
9749 Module *PushImplicitGlobalModuleFragment(SourceLocation BeginLoc);
9750 /// Leave the scope of an implicit global module fragment.
9751 void PopImplicitGlobalModuleFragment();
9752
9753 VisibleModuleSet VisibleModules;
9754
9755 ///@}
9756
9757 //
9758 //
9759 // -------------------------------------------------------------------------
9760 //
9761 //
9762
9763 /// \name C++ Overloading
9764 /// Implementations are in SemaOverload.cpp
9765 ///@{
9766
9767public:
9768 /// Whether deferrable diagnostics should be deferred.
9769 bool DeferDiags = false;
9770
9771 /// RAII class to control scope of DeferDiags.
9773 Sema &S;
9774 bool SavedDeferDiags = false;
9775
9776 public:
9777 DeferDiagsRAII(Sema &S, bool DeferDiags)
9778 : S(S), SavedDeferDiags(S.DeferDiags) {
9779 S.DeferDiags = DeferDiags;
9780 }
9781 ~DeferDiagsRAII() { S.DeferDiags = SavedDeferDiags; }
9782 };
9783
9784 /// Flag indicating if Sema is building a recovery call expression.
9785 ///
9786 /// This flag is used to avoid building recovery call expressions
9787 /// if Sema is already doing so, which would cause infinite recursions.
9789
9791 /// This is a legitimate overload: the existing declarations are
9792 /// functions or function templates with different signatures.
9794
9795 /// This is not an overload because the signature exactly matches
9796 /// an existing declaration.
9798
9799 /// This is not an overload because the lookup results contain a
9800 /// non-function.
9803
9804 /// Determine whether the given New declaration is an overload of the
9805 /// declarations in Old. This routine returns Ovl_Match or Ovl_NonFunction if
9806 /// New and Old cannot be overloaded, e.g., if New has the same signature as
9807 /// some function in Old (C++ 1.3.10) or if the Old declarations aren't
9808 /// functions (or function templates) at all. When it does return Ovl_Match or
9809 /// Ovl_NonFunction, MatchedDecl will point to the decl that New cannot be
9810 /// overloaded with. This decl may be a UsingShadowDecl on top of the
9811 /// underlying declaration.
9812 ///
9813 /// Example: Given the following input:
9814 ///
9815 /// void f(int, float); // #1
9816 /// void f(int, int); // #2
9817 /// int f(int, int); // #3
9818 ///
9819 /// When we process #1, there is no previous declaration of "f", so IsOverload
9820 /// will not be used.
9821 ///
9822 /// When we process #2, Old contains only the FunctionDecl for #1. By
9823 /// comparing the parameter types, we see that #1 and #2 are overloaded (since
9824 /// they have different signatures), so this routine returns Ovl_Overload;
9825 /// MatchedDecl is unchanged.
9826 ///
9827 /// When we process #3, Old is an overload set containing #1 and #2. We
9828 /// compare the signatures of #3 to #1 (they're overloaded, so we do nothing)
9829 /// and then #3 to #2. Since the signatures of #3 and #2 are identical (return
9830 /// types of functions are not part of the signature), IsOverload returns
9831 /// Ovl_Match and MatchedDecl will be set to point to the FunctionDecl for #2.
9832 ///
9833 /// 'NewIsUsingShadowDecl' indicates that 'New' is being introduced into a
9834 /// class by a using declaration. The rules for whether to hide shadow
9835 /// declarations ignore some properties which otherwise figure into a function
9836 /// template's signature.
9838 const LookupResult &OldDecls, NamedDecl *&OldDecl,
9839 bool UseMemberUsingDeclRules);
9840 bool IsOverload(FunctionDecl *New, FunctionDecl *Old,
9841 bool UseMemberUsingDeclRules, bool ConsiderCudaAttrs = true);
9842
9843 // Checks whether MD constitutes an override the base class method BaseMD.
9844 // When checking for overrides, the object object members are ignored.
9845 bool IsOverride(FunctionDecl *MD, FunctionDecl *BaseMD,
9846 bool UseMemberUsingDeclRules, bool ConsiderCudaAttrs = true);
9847
9848 enum class AllowedExplicit {
9849 /// Allow no explicit functions to be used.
9850 None,
9851 /// Allow explicit conversion functions but not explicit constructors.
9853 /// Allow both explicit conversion functions and explicit constructors.
9854 All
9855 };
9856
9858 Expr *From, QualType ToType, bool SuppressUserConversions,
9859 AllowedExplicit AllowExplicit, bool InOverloadResolution, bool CStyle,
9860 bool AllowObjCWritebackConversion);
9861
9862 /// PerformImplicitConversion - Perform an implicit conversion of the
9863 /// expression From to the type ToType. Returns the
9864 /// converted expression. Flavor is the kind of conversion we're
9865 /// performing, used in the error message. If @p AllowExplicit,
9866 /// explicit user-defined conversions are permitted.
9868 AssignmentAction Action,
9869 bool AllowExplicit = false);
9870
9871 /// IsIntegralPromotion - Determines whether the conversion from the
9872 /// expression From (whose potentially-adjusted type is FromType) to
9873 /// ToType is an integral promotion (C++ 4.5). If so, returns true and
9874 /// sets PromotedType to the promoted type.
9875 bool IsIntegralPromotion(Expr *From, QualType FromType, QualType ToType);
9876
9877 /// IsFloatingPointPromotion - Determines whether the conversion from
9878 /// FromType to ToType is a floating point promotion (C++ 4.6). If so,
9879 /// returns true and sets PromotedType to the promoted type.
9880 bool IsFloatingPointPromotion(QualType FromType, QualType ToType);
9881
9882 /// Determine if a conversion is a complex promotion.
9883 ///
9884 /// A complex promotion is defined as a complex -> complex conversion
9885 /// where the conversion between the underlying real types is a
9886 /// floating-point or integral promotion.
9887 bool IsComplexPromotion(QualType FromType, QualType ToType);
9888
9889 /// IsPointerConversion - Determines whether the conversion of the
9890 /// expression From, which has the (possibly adjusted) type FromType,
9891 /// can be converted to the type ToType via a pointer conversion (C++
9892 /// 4.10). If so, returns true and places the converted type (that
9893 /// might differ from ToType in its cv-qualifiers at some level) into
9894 /// ConvertedType.
9895 ///
9896 /// This routine also supports conversions to and from block pointers
9897 /// and conversions with Objective-C's 'id', 'id<protocols...>', and
9898 /// pointers to interfaces. FIXME: Once we've determined the
9899 /// appropriate overloading rules for Objective-C, we may want to
9900 /// split the Objective-C checks into a different routine; however,
9901 /// GCC seems to consider all of these conversions to be pointer
9902 /// conversions, so for now they live here. IncompatibleObjC will be
9903 /// set if the conversion is an allowed Objective-C conversion that
9904 /// should result in a warning.
9905 bool IsPointerConversion(Expr *From, QualType FromType, QualType ToType,
9906 bool InOverloadResolution, QualType &ConvertedType,
9907 bool &IncompatibleObjC);
9908
9909 /// isObjCPointerConversion - Determines whether this is an
9910 /// Objective-C pointer conversion. Subroutine of IsPointerConversion,
9911 /// with the same arguments and return values.
9912 bool isObjCPointerConversion(QualType FromType, QualType ToType,
9913 QualType &ConvertedType, bool &IncompatibleObjC);
9914 bool IsBlockPointerConversion(QualType FromType, QualType ToType,
9915 QualType &ConvertedType);
9916
9917 /// FunctionParamTypesAreEqual - This routine checks two function proto types
9918 /// for equality of their parameter types. Caller has already checked that
9919 /// they have same number of parameters. If the parameters are different,
9920 /// ArgPos will have the parameter index of the first different parameter.
9921 /// If `Reversed` is true, the parameters of `NewType` will be compared in
9922 /// reverse order. That's useful if one of the functions is being used as a
9923 /// C++20 synthesized operator overload with a reversed parameter order.
9926 unsigned *ArgPos = nullptr,
9927 bool Reversed = false);
9928
9930 const FunctionProtoType *NewType,
9931 unsigned *ArgPos = nullptr,
9932 bool Reversed = false);
9933
9934 bool FunctionNonObjectParamTypesAreEqual(const FunctionDecl *OldFunction,
9935 const FunctionDecl *NewFunction,
9936 unsigned *ArgPos = nullptr,
9937 bool Reversed = false);
9938
9939 /// HandleFunctionTypeMismatch - Gives diagnostic information for differeing
9940 /// function types. Catches different number of parameter, mismatch in
9941 /// parameter types, and different return types.
9943 QualType ToType);
9944
9945 /// CheckPointerConversion - Check the pointer conversion from the
9946 /// expression From to the type ToType. This routine checks for
9947 /// ambiguous or inaccessible derived-to-base pointer
9948 /// conversions for which IsPointerConversion has already returned
9949 /// true. It returns true and produces a diagnostic if there was an
9950 /// error, or returns false otherwise.
9951 bool CheckPointerConversion(Expr *From, QualType ToType, CastKind &Kind,
9952 CXXCastPath &BasePath, bool IgnoreBaseAccess,
9953 bool Diagnose = true);
9954
9955 /// IsMemberPointerConversion - Determines whether the conversion of the
9956 /// expression From, which has the (possibly adjusted) type FromType, can be
9957 /// converted to the type ToType via a member pointer conversion (C++ 4.11).
9958 /// If so, returns true and places the converted type (that might differ from
9959 /// ToType in its cv-qualifiers at some level) into ConvertedType.
9960 bool IsMemberPointerConversion(Expr *From, QualType FromType, QualType ToType,
9961 bool InOverloadResolution,
9962 QualType &ConvertedType);
9963
9964 /// CheckMemberPointerConversion - Check the member pointer conversion from
9965 /// the expression From to the type ToType. This routine checks for ambiguous
9966 /// or virtual or inaccessible base-to-derived member pointer conversions for
9967 /// which IsMemberPointerConversion has already returned true. It returns true
9968 /// and produces a diagnostic if there was an error, or returns false
9969 /// otherwise.
9971 CXXCastPath &BasePath,
9972 bool IgnoreBaseAccess);
9973
9974 /// IsQualificationConversion - Determines whether the conversion from
9975 /// an rvalue of type FromType to ToType is a qualification conversion
9976 /// (C++ 4.4).
9977 ///
9978 /// \param ObjCLifetimeConversion Output parameter that will be set to
9979 /// indicate when the qualification conversion involves a change in the
9980 /// Objective-C object lifetime.
9981 bool IsQualificationConversion(QualType FromType, QualType ToType,
9982 bool CStyle, bool &ObjCLifetimeConversion);
9983
9984 /// Determine whether the conversion from FromType to ToType is a valid
9985 /// conversion that strips "noexcept" or "noreturn" off the nested function
9986 /// type.
9987 bool IsFunctionConversion(QualType FromType, QualType ToType,
9988 QualType &ResultTy);
9991 DeclarationName Name,
9992 OverloadCandidateSet &CandidateSet,
9993 FunctionDecl *Fn, MultiExprArg Args,
9994 bool IsMember = false);
9995
9997 FunctionDecl *Fun);
9999 Expr *From, NestedNameSpecifier *Qualifier, NamedDecl *FoundDecl,
10000 CXXMethodDecl *Method);
10001
10002 /// PerformContextuallyConvertToBool - Perform a contextual conversion
10003 /// of the expression From to bool (C++0x [conv]p3).
10005
10006 /// PerformContextuallyConvertToObjCPointer - Perform a contextual
10007 /// conversion of the expression From to an Objective-C pointer type.
10008 /// Returns a valid but null ExprResult if no conversion sequence exists.
10010
10011 /// Contexts in which a converted constant expression is required.
10012 enum CCEKind {
10013 CCEK_CaseValue, ///< Expression in a case label.
10014 CCEK_Enumerator, ///< Enumerator value with fixed underlying type.
10015 CCEK_TemplateArg, ///< Value of a non-type template parameter.
10016 CCEK_InjectedTTP, ///< Injected parameter of a template template parameter.
10017 CCEK_ArrayBound, ///< Array bound in array declarator or new-expression.
10018 CCEK_ExplicitBool, ///< Condition in an explicit(bool) specifier.
10019 CCEK_Noexcept, ///< Condition in a noexcept(bool) specifier.
10020 CCEK_StaticAssertMessageSize, ///< Call to size() in a static assert
10021 ///< message.
10022 CCEK_StaticAssertMessageData, ///< Call to data() in a static assert
10023 ///< message.
10024 };
10025
10027 CCEKind CCE,
10028 NamedDecl *Dest = nullptr);
10029
10031 llvm::APSInt &Value, CCEKind CCE);
10033 APValue &Value, CCEKind CCE,
10034 NamedDecl *Dest = nullptr);
10035
10036 /// EvaluateConvertedConstantExpression - Evaluate an Expression
10037 /// That is a converted constant expression
10038 /// (which was built with BuildConvertedConstantExpression)
10041 CCEKind CCE, bool RequireInt,
10042 const APValue &PreNarrowingValue);
10043
10044 /// Abstract base class used to perform a contextual implicit
10045 /// conversion from an expression to any type passing a filter.
10047 public:
10050
10051 ContextualImplicitConverter(bool Suppress = false,
10052 bool SuppressConversion = false)
10053 : Suppress(Suppress), SuppressConversion(SuppressConversion) {}
10054
10055 /// Determine whether the specified type is a valid destination type
10056 /// for this conversion.
10057 virtual bool match(QualType T) = 0;
10058
10059 /// Emits a diagnostic complaining that the expression does not have
10060 /// integral or enumeration type.
10062 QualType T) = 0;
10063
10064 /// Emits a diagnostic when the expression has incomplete class type.
10065 virtual SemaDiagnosticBuilder
10067
10068 /// Emits a diagnostic when the only matching conversion function
10069 /// is explicit.
10072 QualType T,
10073 QualType ConvTy) = 0;
10074
10075 /// Emits a note for the explicit conversion function.
10076 virtual SemaDiagnosticBuilder
10078
10079 /// Emits a diagnostic when there are multiple possible conversion
10080 /// functions.
10082 QualType T) = 0;
10083
10084 /// Emits a note for one of the candidate conversions.
10085 virtual SemaDiagnosticBuilder
10087
10088 /// Emits a diagnostic when we picked a conversion function
10089 /// (for cases when we are not allowed to pick a conversion function).
10092 QualType T,
10093 QualType ConvTy) = 0;
10094
10096 };
10097
10099 bool AllowScopedEnumerations;
10100
10101 public:
10102 ICEConvertDiagnoser(bool AllowScopedEnumerations, bool Suppress,
10103 bool SuppressConversion)
10104 : ContextualImplicitConverter(Suppress, SuppressConversion),
10105 AllowScopedEnumerations(AllowScopedEnumerations) {}
10106
10107 /// Match an integral or (possibly scoped) enumeration type.
10108 bool match(QualType T) override;
10109
10111 QualType T) override {
10112 return diagnoseNotInt(S, Loc, T);
10113 }
10114
10115 /// Emits a diagnostic complaining that the expression does not have
10116 /// integral or enumeration type.
10118 QualType T) = 0;
10119 };
10120
10121 /// Perform a contextual implicit conversion.
10124 ContextualImplicitConverter &Converter);
10125
10126 /// ReferenceCompareResult - Expresses the result of comparing two
10127 /// types (cv1 T1 and cv2 T2) to determine their compatibility for the
10128 /// purposes of initialization by reference (C++ [dcl.init.ref]p4).
10130 /// Ref_Incompatible - The two types are incompatible, so direct
10131 /// reference binding is not possible.
10133 /// Ref_Related - The two types are reference-related, which means
10134 /// that their unqualified forms (T1 and T2) are either the same
10135 /// or T1 is a base class of T2.
10137 /// Ref_Compatible - The two types are reference-compatible.
10140
10141 // Fake up a scoped enumeration that still contextually converts to bool.
10143 /// The conversions that would be performed on an lvalue of type T2 when
10144 /// binding a reference of type T1 to it, as determined when evaluating
10145 /// whether T1 is reference-compatible with T2.
10147 Qualification = 0x1,
10148 NestedQualification = 0x2,
10150 DerivedToBase = 0x8,
10151 ObjC = 0x10,
10152 ObjCLifetime = 0x20,
10153
10154 LLVM_MARK_AS_BITMASK_ENUM(/*LargestValue=*/ObjCLifetime)
10155 };
10156 };
10158
10159 /// CompareReferenceRelationship - Compare the two types T1 and T2 to
10160 /// determine whether they are reference-compatible,
10161 /// reference-related, or incompatible, for use in C++ initialization by
10162 /// reference (C++ [dcl.ref.init]p4). Neither type can be a reference
10163 /// type, and the first type (T1) is the pointee type of the reference
10164 /// type being initialized.
10167 ReferenceConversions *Conv = nullptr);
10168
10169 /// AddOverloadCandidate - Adds the given function to the set of
10170 /// candidate functions, using the given function call arguments. If
10171 /// @p SuppressUserConversions, then don't allow user-defined
10172 /// conversions via constructors or conversion operators.
10173 ///
10174 /// \param PartialOverloading true if we are performing "partial" overloading
10175 /// based on an incomplete set of function arguments. This feature is used by
10176 /// code completion.
10178 ArrayRef<Expr *> Args,
10179 OverloadCandidateSet &CandidateSet,
10180 bool SuppressUserConversions = false,
10181 bool PartialOverloading = false,
10182 bool AllowExplicit = true,
10183 bool AllowExplicitConversion = false,
10184 ADLCallKind IsADLCandidate = ADLCallKind::NotADL,
10185 ConversionSequenceList EarlyConversions = {},
10187 bool AggregateCandidateDeduction = false,
10188 bool HasMatchedPackOnParmToNonPackOnArg = false);
10189
10190 /// Add all of the function declarations in the given function set to
10191 /// the overload candidate set.
10193 const UnresolvedSetImpl &Functions, ArrayRef<Expr *> Args,
10194 OverloadCandidateSet &CandidateSet,
10195 TemplateArgumentListInfo *ExplicitTemplateArgs = nullptr,
10196 bool SuppressUserConversions = false, bool PartialOverloading = false,
10197 bool FirstArgumentIsBase = false);
10198
10199 /// AddMethodCandidate - Adds a named decl (which is some kind of
10200 /// method) as a method candidate to the given overload set.
10201 void AddMethodCandidate(DeclAccessPair FoundDecl, QualType ObjectType,
10202 Expr::Classification ObjectClassification,
10203 ArrayRef<Expr *> Args,
10204 OverloadCandidateSet &CandidateSet,
10205 bool SuppressUserConversion = false,
10207
10208 /// AddMethodCandidate - Adds the given C++ member function to the set
10209 /// of candidate functions, using the given function call arguments
10210 /// and the object argument (@c Object). For example, in a call
10211 /// @c o.f(a1,a2), @c Object will contain @c o and @c Args will contain
10212 /// both @c a1 and @c a2. If @p SuppressUserConversions, then don't
10213 /// allow user-defined conversions via constructors or conversion
10214 /// operators.
10215 void AddMethodCandidate(CXXMethodDecl *Method, DeclAccessPair FoundDecl,
10216 CXXRecordDecl *ActingContext, QualType ObjectType,
10217 Expr::Classification ObjectClassification,
10218 ArrayRef<Expr *> Args,
10219 OverloadCandidateSet &CandidateSet,
10220 bool SuppressUserConversions = false,
10221 bool PartialOverloading = false,
10222 ConversionSequenceList EarlyConversions = {},
10224 bool HasMatchedPackOnParmToNonPackOnArg = false);
10225
10226 /// Add a C++ member function template as a candidate to the candidate
10227 /// set, using template argument deduction to produce an appropriate member
10228 /// function template specialization.
10230 FunctionTemplateDecl *MethodTmpl, DeclAccessPair FoundDecl,
10231 CXXRecordDecl *ActingContext,
10232 TemplateArgumentListInfo *ExplicitTemplateArgs, QualType ObjectType,
10233 Expr::Classification ObjectClassification, ArrayRef<Expr *> Args,
10234 OverloadCandidateSet &CandidateSet, bool SuppressUserConversions = false,
10235 bool PartialOverloading = false, OverloadCandidateParamOrder PO = {});
10236
10237 /// Add a C++ function template specialization as a candidate
10238 /// in the candidate set, using template argument deduction to produce
10239 /// an appropriate function template specialization.
10241 FunctionTemplateDecl *FunctionTemplate, DeclAccessPair FoundDecl,
10242 TemplateArgumentListInfo *ExplicitTemplateArgs, ArrayRef<Expr *> Args,
10243 OverloadCandidateSet &CandidateSet, bool SuppressUserConversions = false,
10244 bool PartialOverloading = false, bool AllowExplicit = true,
10245 ADLCallKind IsADLCandidate = ADLCallKind::NotADL,
10247 bool AggregateCandidateDeduction = false);
10248
10249 /// Check that implicit conversion sequences can be formed for each argument
10250 /// whose corresponding parameter has a non-dependent type, per DR1391's
10251 /// [temp.deduct.call]p10.
10253 FunctionTemplateDecl *FunctionTemplate, ArrayRef<QualType> ParamTypes,
10254 ArrayRef<Expr *> Args, OverloadCandidateSet &CandidateSet,
10255 ConversionSequenceList &Conversions, bool SuppressUserConversions,
10256 CXXRecordDecl *ActingContext = nullptr, QualType ObjectType = QualType(),
10257 Expr::Classification ObjectClassification = {},
10259
10260 /// AddConversionCandidate - Add a C++ conversion function as a
10261 /// candidate in the candidate set (C++ [over.match.conv],
10262 /// C++ [over.match.copy]). From is the expression we're converting from,
10263 /// and ToType is the type that we're eventually trying to convert to
10264 /// (which may or may not be the same type as the type that the
10265 /// conversion function produces).
10267 CXXConversionDecl *Conversion, DeclAccessPair FoundDecl,
10268 CXXRecordDecl *ActingContext, Expr *From, QualType ToType,
10269 OverloadCandidateSet &CandidateSet, bool AllowObjCConversionOnExplicit,
10270 bool AllowExplicit, bool AllowResultConversion = true,
10271 bool HasMatchedPackOnParmToNonPackOnArg = false);
10272
10273 /// Adds a conversion function template specialization
10274 /// candidate to the overload set, using template argument deduction
10275 /// to deduce the template arguments of the conversion function
10276 /// template from the type that we are converting to (C++
10277 /// [temp.deduct.conv]).
10279 FunctionTemplateDecl *FunctionTemplate, DeclAccessPair FoundDecl,
10280 CXXRecordDecl *ActingContext, Expr *From, QualType ToType,
10281 OverloadCandidateSet &CandidateSet, bool AllowObjCConversionOnExplicit,
10282 bool AllowExplicit, bool AllowResultConversion = true);
10283
10284 /// AddSurrogateCandidate - Adds a "surrogate" candidate function that
10285 /// converts the given @c Object to a function pointer via the
10286 /// conversion function @c Conversion, and then attempts to call it
10287 /// with the given arguments (C++ [over.call.object]p2-4). Proto is
10288 /// the type of function that we'll eventually be calling.
10289 void AddSurrogateCandidate(CXXConversionDecl *Conversion,
10290 DeclAccessPair FoundDecl,
10291 CXXRecordDecl *ActingContext,
10292 const FunctionProtoType *Proto, Expr *Object,
10293 ArrayRef<Expr *> Args,
10294 OverloadCandidateSet &CandidateSet);
10295
10296 /// Add all of the non-member operator function declarations in the given
10297 /// function set to the overload candidate set.
10299 const UnresolvedSetImpl &Functions, ArrayRef<Expr *> Args,
10300 OverloadCandidateSet &CandidateSet,
10301 TemplateArgumentListInfo *ExplicitTemplateArgs = nullptr);
10302
10303 /// Add overload candidates for overloaded operators that are
10304 /// member functions.
10305 ///
10306 /// Add the overloaded operator candidates that are member functions
10307 /// for the operator Op that was used in an operator expression such
10308 /// as "x Op y". , Args/NumArgs provides the operator arguments, and
10309 /// CandidateSet will store the added overload candidates. (C++
10310 /// [over.match.oper]).
10312 SourceLocation OpLoc, ArrayRef<Expr *> Args,
10313 OverloadCandidateSet &CandidateSet,
10315
10316 /// AddBuiltinCandidate - Add a candidate for a built-in
10317 /// operator. ResultTy and ParamTys are the result and parameter types
10318 /// of the built-in candidate, respectively. Args and NumArgs are the
10319 /// arguments being passed to the candidate. IsAssignmentOperator
10320 /// should be true when this built-in candidate is an assignment
10321 /// operator. NumContextualBoolArguments is the number of arguments
10322 /// (at the beginning of the argument list) that will be contextually
10323 /// converted to bool.
10324 void AddBuiltinCandidate(QualType *ParamTys, ArrayRef<Expr *> Args,
10325 OverloadCandidateSet &CandidateSet,
10326 bool IsAssignmentOperator = false,
10327 unsigned NumContextualBoolArguments = 0);
10328
10329 /// AddBuiltinOperatorCandidates - Add the appropriate built-in
10330 /// operator overloads to the candidate set (C++ [over.built]), based
10331 /// on the operator @p Op and the arguments given. For example, if the
10332 /// operator is a binary '+', this routine might add "int
10333 /// operator+(int, int)" to cover integer addition.
10335 SourceLocation OpLoc, ArrayRef<Expr *> Args,
10336 OverloadCandidateSet &CandidateSet);
10337
10338 /// Add function candidates found via argument-dependent lookup
10339 /// to the set of overloading candidates.
10340 ///
10341 /// This routine performs argument-dependent name lookup based on the
10342 /// given function name (which may also be an operator name) and adds
10343 /// all of the overload candidates found by ADL to the overload
10344 /// candidate set (C++ [basic.lookup.argdep]).
10346 DeclarationName Name, SourceLocation Loc, ArrayRef<Expr *> Args,
10347 TemplateArgumentListInfo *ExplicitTemplateArgs,
10348 OverloadCandidateSet &CandidateSet, bool PartialOverloading = false);
10349
10350 /// Check the enable_if expressions on the given function. Returns the first
10351 /// failing attribute, or NULL if they were all successful.
10352 EnableIfAttr *CheckEnableIf(FunctionDecl *Function, SourceLocation CallLoc,
10353 ArrayRef<Expr *> Args,
10354 bool MissingImplicitThis = false);
10355
10356 /// Emit diagnostics for the diagnose_if attributes on Function, ignoring any
10357 /// non-ArgDependent DiagnoseIfAttrs.
10358 ///
10359 /// Argument-dependent diagnose_if attributes should be checked each time a
10360 /// function is used as a direct callee of a function call.
10361 ///
10362 /// Returns true if any errors were emitted.
10363 bool diagnoseArgDependentDiagnoseIfAttrs(const FunctionDecl *Function,
10364 const Expr *ThisArg,
10365 ArrayRef<const Expr *> Args,
10366 SourceLocation Loc);
10367
10368 /// Emit diagnostics for the diagnose_if attributes on Function, ignoring any
10369 /// ArgDependent DiagnoseIfAttrs.
10370 ///
10371 /// Argument-independent diagnose_if attributes should be checked on every use
10372 /// of a function.
10373 ///
10374 /// Returns true if any errors were emitted.
10375 bool diagnoseArgIndependentDiagnoseIfAttrs(const NamedDecl *ND,
10376 SourceLocation Loc);
10377
10378 /// Determine if \p A and \p B are equivalent internal linkage declarations
10379 /// from different modules, and thus an ambiguity error can be downgraded to
10380 /// an extension warning.
10381 bool isEquivalentInternalLinkageDeclaration(const NamedDecl *A,
10382 const NamedDecl *B);
10384 SourceLocation Loc, const NamedDecl *D,
10385 ArrayRef<const NamedDecl *> Equiv);
10386
10387 // Emit as a 'note' the specific overload candidate
10389 const NamedDecl *Found, const FunctionDecl *Fn,
10391 QualType DestType = QualType(), bool TakingAddress = false);
10392
10393 // Emit as a series of 'note's all template and non-templates identified by
10394 // the expression Expr
10395 void NoteAllOverloadCandidates(Expr *E, QualType DestType = QualType(),
10396 bool TakingAddress = false);
10397
10398 /// Returns whether the given function's address can be taken or not,
10399 /// optionally emitting a diagnostic if the address can't be taken.
10400 ///
10401 /// Returns false if taking the address of the function is illegal.
10402 bool checkAddressOfFunctionIsAvailable(const FunctionDecl *Function,
10403 bool Complain = false,
10404 SourceLocation Loc = SourceLocation());
10405
10406 // [PossiblyAFunctionType] --> [Return]
10407 // NonFunctionType --> NonFunctionType
10408 // R (A) --> R(A)
10409 // R (*)(A) --> R (A)
10410 // R (&)(A) --> R (A)
10411 // R (S::*)(A) --> R (A)
10412 QualType ExtractUnqualifiedFunctionType(QualType PossiblyAFunctionType);
10413
10414 /// ResolveAddressOfOverloadedFunction - Try to resolve the address of
10415 /// an overloaded function (C++ [over.over]), where @p From is an
10416 /// expression with overloaded function type and @p ToType is the type
10417 /// we're trying to resolve to. For example:
10418 ///
10419 /// @code
10420 /// int f(double);
10421 /// int f(int);
10422 ///
10423 /// int (*pfd)(double) = f; // selects f(double)
10424 /// @endcode
10425 ///
10426 /// This routine returns the resulting FunctionDecl if it could be
10427 /// resolved, and NULL otherwise. When @p Complain is true, this
10428 /// routine will emit diagnostics if there is an error.
10429 FunctionDecl *
10430 ResolveAddressOfOverloadedFunction(Expr *AddressOfExpr, QualType TargetType,
10431 bool Complain, DeclAccessPair &Found,
10432 bool *pHadMultipleCandidates = nullptr);
10433
10434 /// Given an expression that refers to an overloaded function, try to
10435 /// resolve that function to a single function that can have its address
10436 /// taken. This will modify `Pair` iff it returns non-null.
10437 ///
10438 /// This routine can only succeed if from all of the candidates in the
10439 /// overload set for SrcExpr that can have their addresses taken, there is one
10440 /// candidate that is more constrained than the rest.
10441 FunctionDecl *
10442 resolveAddressOfSingleOverloadCandidate(Expr *E, DeclAccessPair &FoundResult);
10443
10444 /// Given an overloaded function, tries to turn it into a non-overloaded
10445 /// function reference using resolveAddressOfSingleOverloadCandidate. This
10446 /// will perform access checks, diagnose the use of the resultant decl, and,
10447 /// if requested, potentially perform a function-to-pointer decay.
10448 ///
10449 /// Returns false if resolveAddressOfSingleOverloadCandidate fails.
10450 /// Otherwise, returns true. This may emit diagnostics and return true.
10452 ExprResult &SrcExpr, bool DoFunctionPointerConversion = false);
10453
10454 /// Given an expression that refers to an overloaded function, try to
10455 /// resolve that overloaded function expression down to a single function.
10456 ///
10457 /// This routine can only resolve template-ids that refer to a single function
10458 /// template, where that template-id refers to a single template whose
10459 /// template arguments are either provided by the template-id or have
10460 /// defaults, as described in C++0x [temp.arg.explicit]p3.
10461 ///
10462 /// If no template-ids are found, no diagnostics are emitted and NULL is
10463 /// returned.
10465 OverloadExpr *ovl, bool Complain = false, DeclAccessPair *Found = nullptr,
10466 TemplateSpecCandidateSet *FailedTSC = nullptr);
10467
10468 // Resolve and fix an overloaded expression that can be resolved
10469 // because it identifies a single function template specialization.
10470 //
10471 // Last three arguments should only be supplied if Complain = true
10472 //
10473 // Return true if it was logically possible to so resolve the
10474 // expression, regardless of whether or not it succeeded. Always
10475 // returns true if 'complain' is set.
10477 ExprResult &SrcExpr, bool DoFunctionPointerConversion = false,
10478 bool Complain = false, SourceRange OpRangeForComplaining = SourceRange(),
10479 QualType DestTypeForComplaining = QualType(),
10480 unsigned DiagIDForComplaining = 0);
10481
10482 /// Add the overload candidates named by callee and/or found by argument
10483 /// dependent lookup to the given overload set.
10484 void AddOverloadedCallCandidates(UnresolvedLookupExpr *ULE,
10485 ArrayRef<Expr *> Args,
10486 OverloadCandidateSet &CandidateSet,
10487 bool PartialOverloading = false);
10488
10489 /// Add the call candidates from the given set of lookup results to the given
10490 /// overload set. Non-function lookup results are ignored.
10492 LookupResult &R, TemplateArgumentListInfo *ExplicitTemplateArgs,
10493 ArrayRef<Expr *> Args, OverloadCandidateSet &CandidateSet);
10494
10495 // An enum used to represent the different possible results of building a
10496 // range-based for loop.
10502
10503 /// Build a call to 'begin' or 'end' for a C++11 for-range statement. If the
10504 /// given LookupResult is non-empty, it is assumed to describe a member which
10505 /// will be invoked. Otherwise, the function will be found via argument
10506 /// dependent lookup.
10507 /// CallExpr is set to a valid expression and FRS_Success returned on success,
10508 /// otherwise CallExpr is set to ExprError() and some non-success value
10509 /// is returned.
10511 SourceLocation RangeLoc,
10512 const DeclarationNameInfo &NameInfo,
10513 LookupResult &MemberLookup,
10514 OverloadCandidateSet *CandidateSet,
10516
10517 /// BuildOverloadedCallExpr - Given the call expression that calls Fn
10518 /// (which eventually refers to the declaration Func) and the call
10519 /// arguments Args/NumArgs, attempt to resolve the function call down
10520 /// to a specific function. If overload resolution succeeds, returns
10521 /// the call expression produced by overload resolution.
10522 /// Otherwise, emits diagnostics and returns ExprError.
10524 Scope *S, Expr *Fn, UnresolvedLookupExpr *ULE, SourceLocation LParenLoc,
10525 MultiExprArg Args, SourceLocation RParenLoc, Expr *ExecConfig,
10526 bool AllowTypoCorrection = true, bool CalleesAddressIsTaken = false);
10527
10528 /// Constructs and populates an OverloadedCandidateSet from
10529 /// the given function.
10530 /// \returns true when an the ExprResult output parameter has been set.
10532 MultiExprArg Args, SourceLocation RParenLoc,
10533 OverloadCandidateSet *CandidateSet,
10535
10539 const UnresolvedSetImpl &Fns,
10540 bool PerformADL = true);
10541
10542 /// Create a unary operation that may resolve to an overloaded
10543 /// operator.
10544 ///
10545 /// \param OpLoc The location of the operator itself (e.g., '*').
10546 ///
10547 /// \param Opc The UnaryOperatorKind that describes this operator.
10548 ///
10549 /// \param Fns The set of non-member functions that will be
10550 /// considered by overload resolution. The caller needs to build this
10551 /// set based on the context using, e.g.,
10552 /// LookupOverloadedOperatorName() and ArgumentDependentLookup(). This
10553 /// set should not contain any member functions; those will be added
10554 /// by CreateOverloadedUnaryOp().
10555 ///
10556 /// \param Input The input argument.
10559 const UnresolvedSetImpl &Fns, Expr *input,
10560 bool RequiresADL = true);
10561
10562 /// Perform lookup for an overloaded binary operator.
10565 const UnresolvedSetImpl &Fns,
10566 ArrayRef<Expr *> Args, bool RequiresADL = true);
10567
10568 /// Create a binary operation that may resolve to an overloaded
10569 /// operator.
10570 ///
10571 /// \param OpLoc The location of the operator itself (e.g., '+').
10572 ///
10573 /// \param Opc The BinaryOperatorKind that describes this operator.
10574 ///
10575 /// \param Fns The set of non-member functions that will be
10576 /// considered by overload resolution. The caller needs to build this
10577 /// set based on the context using, e.g.,
10578 /// LookupOverloadedOperatorName() and ArgumentDependentLookup(). This
10579 /// set should not contain any member functions; those will be added
10580 /// by CreateOverloadedBinOp().
10581 ///
10582 /// \param LHS Left-hand argument.
10583 /// \param RHS Right-hand argument.
10584 /// \param PerformADL Whether to consider operator candidates found by ADL.
10585 /// \param AllowRewrittenCandidates Whether to consider candidates found by
10586 /// C++20 operator rewrites.
10587 /// \param DefaultedFn If we are synthesizing a defaulted operator function,
10588 /// the function in question. Such a function is never a candidate in
10589 /// our overload resolution. This also enables synthesizing a three-way
10590 /// comparison from < and == as described in C++20 [class.spaceship]p1.
10592 const UnresolvedSetImpl &Fns, Expr *LHS,
10593 Expr *RHS, bool RequiresADL = true,
10594 bool AllowRewrittenCandidates = true,
10595 FunctionDecl *DefaultedFn = nullptr);
10597 const UnresolvedSetImpl &Fns,
10598 Expr *LHS, Expr *RHS,
10599 FunctionDecl *DefaultedFn);
10600
10602 SourceLocation RLoc, Expr *Base,
10603 MultiExprArg Args);
10604
10605 /// BuildCallToMemberFunction - Build a call to a member
10606 /// function. MemExpr is the expression that refers to the member
10607 /// function (and includes the object parameter), Args/NumArgs are the
10608 /// arguments to the function call (not including the object
10609 /// parameter). The caller needs to validate that the member
10610 /// expression refers to a non-static member function or an overloaded
10611 /// member function.
10613 Scope *S, Expr *MemExpr, SourceLocation LParenLoc, MultiExprArg Args,
10614 SourceLocation RParenLoc, Expr *ExecConfig = nullptr,
10615 bool IsExecConfig = false, bool AllowRecovery = false);
10616
10617 /// BuildCallToObjectOfClassType - Build a call to an object of class
10618 /// type (C++ [over.call.object]), which can end up invoking an
10619 /// overloaded function call operator (@c operator()) or performing a
10620 /// user-defined conversion on the object argument.
10622 SourceLocation LParenLoc,
10623 MultiExprArg Args,
10624 SourceLocation RParenLoc);
10625
10626 /// BuildOverloadedArrowExpr - Build a call to an overloaded @c operator->
10627 /// (if one exists), where @c Base is an expression of class type and
10628 /// @c Member is the name of the member we're trying to find.
10630 SourceLocation OpLoc,
10631 bool *NoArrowOperatorFound = nullptr);
10632
10634 CXXConversionDecl *Method,
10635 bool HadMultipleCandidates);
10636
10637 /// BuildLiteralOperatorCall - Build a UserDefinedLiteral by creating a call
10638 /// to a literal operator described by the provided lookup results.
10641 SourceLocation LitEndLoc,
10642 TemplateArgumentListInfo *ExplicitTemplateArgs = nullptr);
10643
10644 /// FixOverloadedFunctionReference - E is an expression that refers to
10645 /// a C++ overloaded function (possibly with some parentheses and
10646 /// perhaps a '&' around it). We have resolved the overloaded function
10647 /// to the function declaration Fn, so patch up the expression E to
10648 /// refer (possibly indirectly) to Fn. Returns the new expr.
10650 FunctionDecl *Fn);
10652 DeclAccessPair FoundDecl,
10653 FunctionDecl *Fn);
10654
10655 /// - Returns a selector which best matches given argument list or
10656 /// nullptr if none could be found
10658 bool IsInstance,
10660
10661 ///@}
10662
10663 //
10664 //
10665 // -------------------------------------------------------------------------
10666 //
10667 //
10668
10669 /// \name Statements
10670 /// Implementations are in SemaStmt.cpp
10671 ///@{
10672
10673public:
10674 /// Stack of active SEH __finally scopes. Can be empty.
10676
10677 StmtResult ActOnExprStmt(ExprResult Arg, bool DiscardedValue = true);
10679
10681 bool HasLeadingEmptyMacro = false);
10682
10684 SourceLocation EndLoc);
10686
10687 /// DiagnoseDiscardedExprMarkedNodiscard - Given an expression that is
10688 /// semantically a discarded-value expression, diagnose if any [[nodiscard]]
10689 /// value has been discarded.
10691
10692 /// DiagnoseUnusedExprResult - If the statement passed in is an expression
10693 /// whose result is unused, warn.
10694 void DiagnoseUnusedExprResult(const Stmt *S, unsigned DiagID);
10695
10696 void ActOnStartOfCompoundStmt(bool IsStmtExpr);
10700 ArrayRef<Stmt *> Elts, bool isStmtExpr);
10701
10703
10706 SourceLocation DotDotDotLoc, ExprResult RHS,
10707 SourceLocation ColonLoc);
10708
10709 /// ActOnCaseStmtBody - This installs a statement as the body of a case.
10710 void ActOnCaseStmtBody(Stmt *CaseStmt, Stmt *SubStmt);
10711
10713 SourceLocation ColonLoc, Stmt *SubStmt,
10714 Scope *CurScope);
10716 SourceLocation ColonLoc, Stmt *SubStmt);
10717
10719 ArrayRef<const Attr *> Attrs, Stmt *SubStmt);
10721 Stmt *SubStmt);
10722
10723 /// Check whether the given statement can have musttail applied to it,
10724 /// issuing a diagnostic and returning false if not. In the success case,
10725 /// the statement is rewritten to remove implicit nodes from the return
10726 /// value.
10727 bool checkAndRewriteMustTailAttr(Stmt *St, const Attr &MTA);
10728
10730 SourceLocation LParenLoc, Stmt *InitStmt,
10731 ConditionResult Cond, SourceLocation RParenLoc,
10732 Stmt *ThenVal, SourceLocation ElseLoc, Stmt *ElseVal);
10734 SourceLocation LParenLoc, Stmt *InitStmt,
10735 ConditionResult Cond, SourceLocation RParenLoc,
10736 Stmt *ThenVal, SourceLocation ElseLoc, Stmt *ElseVal);
10737
10739
10741 SourceLocation LParenLoc, Stmt *InitStmt,
10742 ConditionResult Cond,
10743 SourceLocation RParenLoc);
10745 Stmt *Body);
10746
10747 /// DiagnoseAssignmentEnum - Warn if assignment to enum is a constant
10748 /// integer not in the range of enum values.
10749 void DiagnoseAssignmentEnum(QualType DstType, QualType SrcType,
10750 Expr *SrcExpr);
10751
10753 ConditionResult Cond, SourceLocation RParenLoc,
10754 Stmt *Body);
10756 SourceLocation WhileLoc, SourceLocation CondLParen,
10757 Expr *Cond, SourceLocation CondRParen);
10758
10760 Stmt *First, ConditionResult Second,
10761 FullExprArg Third, SourceLocation RParenLoc,
10762 Stmt *Body);
10763
10764 /// In an Objective C collection iteration statement:
10765 /// for (x in y)
10766 /// x can be an arbitrary l-value expression. Bind it up as a
10767 /// full-expression.
10769
10771 /// Initial building of a for-range statement.
10773 /// Instantiation or recovery rebuild of a for-range statement. Don't
10774 /// attempt any typo-correction.
10776 /// Determining whether a for-range statement could be built. Avoid any
10777 /// unnecessary or irreversible actions.
10780
10781 /// ActOnCXXForRangeStmt - Check and build a C++11 for-range statement.
10782 ///
10783 /// C++11 [stmt.ranged]:
10784 /// A range-based for statement is equivalent to
10785 ///
10786 /// {
10787 /// auto && __range = range-init;
10788 /// for ( auto __begin = begin-expr,
10789 /// __end = end-expr;
10790 /// __begin != __end;
10791 /// ++__begin ) {
10792 /// for-range-declaration = *__begin;
10793 /// statement
10794 /// }
10795 /// }
10796 ///
10797 /// The body of the loop is not available yet, since it cannot be analysed
10798 /// until we have determined the type of the for-range-declaration.
10800 Scope *S, SourceLocation ForLoc, SourceLocation CoawaitLoc,
10801 Stmt *InitStmt, Stmt *LoopVar, SourceLocation ColonLoc, Expr *Collection,
10803 ArrayRef<MaterializeTemporaryExpr *> LifetimeExtendTemps = {});
10804
10805 /// BuildCXXForRangeStmt - Build or instantiate a C++11 for-range statement.
10807 SourceLocation ForLoc, SourceLocation CoawaitLoc, Stmt *InitStmt,
10808 SourceLocation ColonLoc, Stmt *RangeDecl, Stmt *Begin, Stmt *End,
10809 Expr *Cond, Expr *Inc, Stmt *LoopVarDecl, SourceLocation RParenLoc,
10811 ArrayRef<MaterializeTemporaryExpr *> LifetimeExtendTemps = {});
10812
10813 /// FinishCXXForRangeStmt - Attach the body to a C++0x for-range statement.
10814 /// This is a separate step from ActOnCXXForRangeStmt because analysis of the
10815 /// body cannot be performed until after the type of the range variable is
10816 /// determined.
10817 StmtResult FinishCXXForRangeStmt(Stmt *ForRange, Stmt *Body);
10818
10819 StmtResult ActOnGotoStmt(SourceLocation GotoLoc, SourceLocation LabelLoc,
10820 LabelDecl *TheDecl);
10821 StmtResult ActOnIndirectGotoStmt(SourceLocation GotoLoc,
10822 SourceLocation StarLoc, Expr *DestExp);
10823 StmtResult ActOnContinueStmt(SourceLocation ContinueLoc, Scope *CurScope);
10824 StmtResult ActOnBreakStmt(SourceLocation BreakLoc, Scope *CurScope);
10825
10828
10829 enum Status : uint8_t { None, MoveEligible, MoveEligibleAndCopyElidable };
10831
10832 bool isMoveEligible() const { return S != None; };
10833 bool isCopyElidable() const { return S == MoveEligibleAndCopyElidable; }
10834 };
10836
10837 /// Determine whether the given expression might be move-eligible or
10838 /// copy-elidable in either a (co_)return statement or throw expression,
10839 /// without considering function return type, if applicable.
10840 ///
10841 /// \param E The expression being returned from the function or block,
10842 /// being thrown, or being co_returned from a coroutine. This expression
10843 /// might be modified by the implementation.
10844 ///
10845 /// \param Mode Overrides detection of current language mode
10846 /// and uses the rules for C++23.
10847 ///
10848 /// \returns An aggregate which contains the Candidate and isMoveEligible
10849 /// and isCopyElidable methods. If Candidate is non-null, it means
10850 /// isMoveEligible() would be true under the most permissive language
10851 /// standard.
10852 NamedReturnInfo getNamedReturnInfo(
10854
10855 /// Determine whether the given NRVO candidate variable is move-eligible or
10856 /// copy-elidable, without considering function return type.
10857 ///
10858 /// \param VD The NRVO candidate variable.
10859 ///
10860 /// \returns An aggregate which contains the Candidate and isMoveEligible
10861 /// and isCopyElidable methods. If Candidate is non-null, it means
10862 /// isMoveEligible() would be true under the most permissive language
10863 /// standard.
10864 NamedReturnInfo getNamedReturnInfo(const VarDecl *VD);
10865
10866 /// Updates given NamedReturnInfo's move-eligible and
10867 /// copy-elidable statuses, considering the function
10868 /// return type criteria as applicable to return statements.
10869 ///
10870 /// \param Info The NamedReturnInfo object to update.
10871 ///
10872 /// \param ReturnType This is the return type of the function.
10873 /// \returns The copy elision candidate, in case the initial return expression
10874 /// was copy elidable, or nullptr otherwise.
10875 const VarDecl *getCopyElisionCandidate(NamedReturnInfo &Info,
10876 QualType ReturnType);
10877
10878 /// Perform the initialization of a potentially-movable value, which
10879 /// is the result of return value.
10880 ///
10881 /// This routine implements C++20 [class.copy.elision]p3, which attempts to
10882 /// treat returned lvalues as rvalues in certain cases (to prefer move
10883 /// construction), then falls back to treating them as lvalues if that failed.
10886 const NamedReturnInfo &NRInfo, Expr *Value,
10887 bool SupressSimplerImplicitMoves = false);
10888
10890
10891 /// Deduce the return type for a function from a returned expression, per
10892 /// C++1y [dcl.spec.auto]p6.
10894 SourceLocation ReturnLoc, Expr *RetExpr,
10895 const AutoType *AT);
10896
10897 StmtResult ActOnReturnStmt(SourceLocation ReturnLoc, Expr *RetValExp,
10898 Scope *CurScope);
10899 StmtResult BuildReturnStmt(SourceLocation ReturnLoc, Expr *RetValExp,
10900 bool AllowRecovery = false);
10901
10902 /// ActOnCapScopeReturnStmt - Utility routine to type-check return statements
10903 /// for capturing scopes.
10905 NamedReturnInfo &NRInfo,
10906 bool SupressSimplerImplicitMoves);
10907
10908 /// ActOnCXXCatchBlock - Takes an exception declaration and a handler block
10909 /// and creates a proper catch handler from them.
10911 Stmt *HandlerBlock);
10912
10913 /// ActOnCXXTryBlock - Takes a try compound-statement and a number of
10914 /// handlers and creates a try statement from them.
10916 ArrayRef<Stmt *> Handlers);
10917
10918 StmtResult ActOnSEHTryBlock(bool IsCXXTry, // try (true) or __try (false) ?
10919 SourceLocation TryLoc, Stmt *TryBlock,
10920 Stmt *Handler);
10922 Stmt *Block);
10927
10929 bool IsIfExists,
10930 NestedNameSpecifierLoc QualifierLoc,
10931 DeclarationNameInfo NameInfo,
10932 Stmt *Nested);
10934 bool IsIfExists, CXXScopeSpec &SS,
10935 UnqualifiedId &Name, Stmt *Nested);
10936
10938 CapturedRegionKind Kind, unsigned NumParams);
10939 typedef std::pair<StringRef, QualType> CapturedParamNameType;
10943 unsigned OpenMPCaptureLevel = 0);
10948 unsigned NumParams);
10949
10950private:
10951 /// Check whether the given statement can have musttail applied to it,
10952 /// issuing a diagnostic and returning false if not.
10953 bool checkMustTailAttr(const Stmt *St, const Attr &MTA);
10954
10955 /// Check if the given expression contains 'break' or 'continue'
10956 /// statement that produces control flow different from GCC.
10957 void CheckBreakContinueBinding(Expr *E);
10958
10959 ///@}
10960
10961 //
10962 //
10963 // -------------------------------------------------------------------------
10964 //
10965 //
10966
10967 /// \name `inline asm` Statement
10968 /// Implementations are in SemaStmtAsm.cpp
10969 ///@{
10970
10971public:
10972 StmtResult ActOnGCCAsmStmt(SourceLocation AsmLoc, bool IsSimple,
10973 bool IsVolatile, unsigned NumOutputs,
10974 unsigned NumInputs, IdentifierInfo **Names,
10975 MultiExprArg Constraints, MultiExprArg Exprs,
10976 Expr *AsmString, MultiExprArg Clobbers,
10977 unsigned NumLabels, SourceLocation RParenLoc);
10978
10980 llvm::InlineAsmIdentifierInfo &Info);
10982 SourceLocation TemplateKWLoc,
10984 bool IsUnevaluatedContext);
10985 bool LookupInlineAsmField(StringRef Base, StringRef Member, unsigned &Offset,
10986 SourceLocation AsmLoc);
10988 SourceLocation AsmLoc);
10990 ArrayRef<Token> AsmToks, StringRef AsmString,
10991 unsigned NumOutputs, unsigned NumInputs,
10992 ArrayRef<StringRef> Constraints,
10993 ArrayRef<StringRef> Clobbers,
10994 ArrayRef<Expr *> Exprs, SourceLocation EndLoc);
10995 LabelDecl *GetOrCreateMSAsmLabel(StringRef ExternalLabelName,
10996 SourceLocation Location, bool AlwaysCreate);
10997
10998 ///@}
10999
11000 //
11001 //
11002 // -------------------------------------------------------------------------
11003 //
11004 //
11005
11006 /// \name Statement Attribute Handling
11007 /// Implementations are in SemaStmtAttr.cpp
11008 ///@{
11009
11010public:
11011 bool CheckNoInlineAttr(const Stmt *OrigSt, const Stmt *CurSt,
11012 const AttributeCommonInfo &A);
11013 bool CheckAlwaysInlineAttr(const Stmt *OrigSt, const Stmt *CurSt,
11014 const AttributeCommonInfo &A);
11015
11016 CodeAlignAttr *BuildCodeAlignAttr(const AttributeCommonInfo &CI, Expr *E);
11018
11019 /// Process the attributes before creating an attributed statement. Returns
11020 /// the semantic attributes that have been processed.
11021 void ProcessStmtAttributes(Stmt *Stmt, const ParsedAttributes &InAttrs,
11023
11027 const IdentifierInfo *AttrName,
11029
11030 ///@}
11031
11032 //
11033 //
11034 // -------------------------------------------------------------------------
11035 //
11036 //
11037
11038 /// \name C++ Templates
11039 /// Implementations are in SemaTemplate.cpp
11040 ///@{
11041
11042public:
11043 // Saves the current floating-point pragma stack and clear it in this Sema.
11045 public:
11047 : S(S), SavedStack(std::move(S.FpPragmaStack)) {
11048 S.FpPragmaStack.Stack.clear();
11049 }
11050 ~FpPragmaStackSaveRAII() { S.FpPragmaStack = std::move(SavedStack); }
11051
11052 private:
11053 Sema &S;
11055 };
11056
11058 CurFPFeatures = FPO;
11059 FpPragmaStack.CurrentValue = FPO.getChangesFrom(FPOptions(LangOpts));
11060 }
11061
11063 return llvm::ArrayRef(InventedParameterInfos.begin() +
11066 }
11067
11068 /// The number of SFINAE diagnostics that have been trapped.
11070
11073 FunctionScopes.end());
11074 }
11075
11076 typedef llvm::MapVector<const FunctionDecl *,
11077 std::unique_ptr<LateParsedTemplate>>
11080
11081 /// Determine the number of levels of enclosing template parameters. This is
11082 /// only usable while parsing. Note that this does not include dependent
11083 /// contexts in which no template parameters have yet been declared, such as
11084 /// in a terse function template or generic lambda before the first 'auto' is
11085 /// encountered.
11086 unsigned getTemplateDepth(Scope *S) const;
11087
11089 bool AllowFunctionTemplates = true,
11090 bool AllowDependent = true);
11092 bool AllowFunctionTemplates = true,
11093 bool AllowDependent = true,
11094 bool AllowNonTemplateFunctions = false);
11095 /// Try to interpret the lookup result D as a template-name.
11096 ///
11097 /// \param D A declaration found by name lookup.
11098 /// \param AllowFunctionTemplates Whether function templates should be
11099 /// considered valid results.
11100 /// \param AllowDependent Whether unresolved using declarations (that might
11101 /// name templates) should be considered valid results.
11103 bool AllowFunctionTemplates = true,
11104 bool AllowDependent = true);
11105
11107 /// Whether and why a template name is required in this lookup.
11109 public:
11110 /// Template name is required if TemplateKWLoc is valid.
11112 : TemplateKW(TemplateKWLoc) {}
11113 /// Template name is unconditionally required.
11115
11117 return TemplateKW.value_or(SourceLocation());
11118 }
11119 bool hasTemplateKeyword() const {
11120 return getTemplateKeywordLoc().isValid();
11121 }
11122 bool isRequired() const { return TemplateKW != SourceLocation(); }
11123 explicit operator bool() const { return isRequired(); }
11124
11125 private:
11126 std::optional<SourceLocation> TemplateKW;
11127 };
11128
11130 /// This is not assumed to be a template name.
11131 None,
11132 /// This is assumed to be a template name because lookup found nothing.
11134 /// This is assumed to be a template name because lookup found one or more
11135 /// functions (but no function templates).
11137 };
11138
11139 bool
11141 QualType ObjectType, bool EnteringContext,
11142 RequiredTemplateKind RequiredTemplate = SourceLocation(),
11143 AssumedTemplateKind *ATK = nullptr,
11144 bool AllowTypoCorrection = true);
11145
11147 bool hasTemplateKeyword,
11148 const UnqualifiedId &Name,
11149 ParsedType ObjectType, bool EnteringContext,
11150 TemplateTy &Template,
11151 bool &MemberOfUnknownSpecialization,
11152 bool Disambiguation = false);
11153
11154 /// Try to resolve an undeclared template name as a type template.
11155 ///
11156 /// Sets II to the identifier corresponding to the template name, and updates
11157 /// Name to a corresponding (typo-corrected) type template name and TNK to
11158 /// the corresponding kind, if possible.
11160 TemplateNameKind &TNK,
11161 SourceLocation NameLoc,
11162 IdentifierInfo *&II);
11163
11165 SourceLocation NameLoc,
11166 bool Diagnose = true);
11167
11168 /// Determine whether a particular identifier might be the name in a C++1z
11169 /// deduction-guide declaration.
11170 bool isDeductionGuideName(Scope *S, const IdentifierInfo &Name,
11171 SourceLocation NameLoc, CXXScopeSpec &SS,
11172 ParsedTemplateTy *Template = nullptr);
11173
11175 SourceLocation IILoc, Scope *S,
11176 const CXXScopeSpec *SS,
11177 TemplateTy &SuggestedTemplate,
11178 TemplateNameKind &SuggestedKind);
11179
11180 /// Determine whether we would be unable to instantiate this template (because
11181 /// it either has no definition, or is in the process of being instantiated).
11182 bool DiagnoseUninstantiableTemplate(SourceLocation PointOfInstantiation,
11183 NamedDecl *Instantiation,
11184 bool InstantiatedFromMember,
11185 const NamedDecl *Pattern,
11186 const NamedDecl *PatternDef,
11188 bool Complain = true);
11189
11190 /// DiagnoseTemplateParameterShadow - Produce a diagnostic complaining
11191 /// that the template parameter 'PrevDecl' is being shadowed by a new
11192 /// declaration at location Loc. Returns true to indicate that this is
11193 /// an error, and false otherwise.
11194 ///
11195 /// \param Loc The location of the declaration that shadows a template
11196 /// parameter.
11197 ///
11198 /// \param PrevDecl The template parameter that the declaration shadows.
11199 ///
11200 /// \param SupportedForCompatibility Whether to issue the diagnostic as
11201 /// a warning for compatibility with older versions of clang.
11202 /// Ignored when MSVC compatibility is enabled.
11204 bool SupportedForCompatibility = false);
11205
11206 /// AdjustDeclIfTemplate - If the given decl happens to be a template, reset
11207 /// the parameter D to reference the templated declaration and return a
11208 /// pointer to the template declaration. Otherwise, do nothing to D and return
11209 /// null.
11211
11212 /// ActOnTypeParameter - Called when a C++ template type parameter
11213 /// (e.g., "typename T") has been parsed. Typename specifies whether
11214 /// the keyword "typename" was used to declare the type parameter
11215 /// (otherwise, "class" was used), and KeyLoc is the location of the
11216 /// "class" or "typename" keyword. ParamName is the name of the
11217 /// parameter (NULL indicates an unnamed template parameter) and
11218 /// ParamNameLoc is the location of the parameter name (if any).
11219 /// If the type parameter has a default argument, it will be added
11220 /// later via ActOnTypeParameterDefault.
11222 SourceLocation EllipsisLoc,
11223 SourceLocation KeyLoc,
11224 IdentifierInfo *ParamName,
11225 SourceLocation ParamNameLoc, unsigned Depth,
11226 unsigned Position, SourceLocation EqualLoc,
11227 ParsedType DefaultArg, bool HasTypeConstraint);
11228
11230
11231 bool ActOnTypeConstraint(const CXXScopeSpec &SS,
11233 TemplateTypeParmDecl *ConstrainedParameter,
11234 SourceLocation EllipsisLoc);
11235 bool BuildTypeConstraint(const CXXScopeSpec &SS,
11237 TemplateTypeParmDecl *ConstrainedParameter,
11238 SourceLocation EllipsisLoc,
11239 bool AllowUnexpandedPack);
11240
11241 /// Attach a type-constraint to a template parameter.
11242 /// \returns true if an error occurred. This can happen if the
11243 /// immediately-declared constraint could not be formed (e.g. incorrect number
11244 /// of arguments for the named concept).
11246 DeclarationNameInfo NameInfo,
11247 ConceptDecl *NamedConcept, NamedDecl *FoundDecl,
11248 const TemplateArgumentListInfo *TemplateArgs,
11249 TemplateTypeParmDecl *ConstrainedParameter,
11250 QualType ConstrainedType,
11251 SourceLocation EllipsisLoc);
11252
11254 NonTypeTemplateParmDecl *NewConstrainedParm,
11255 NonTypeTemplateParmDecl *OrigConstrainedParm,
11256 SourceLocation EllipsisLoc);
11257
11258 /// Require the given type to be a structural type, and diagnose if it is not.
11259 ///
11260 /// \return \c true if an error was produced.
11262
11263 /// Check that the type of a non-type template parameter is
11264 /// well-formed.
11265 ///
11266 /// \returns the (possibly-promoted) parameter type if valid;
11267 /// otherwise, produces a diagnostic and returns a NULL type.
11271
11273 unsigned Depth, unsigned Position,
11274 SourceLocation EqualLoc,
11275 Expr *DefaultArg);
11276
11277 /// ActOnTemplateTemplateParameter - Called when a C++ template template
11278 /// parameter (e.g. T in template <template <typename> class T> class array)
11279 /// has been parsed. S is the current scope.
11281 Scope *S, SourceLocation TmpLoc, TemplateParameterList *Params,
11282 bool Typename, SourceLocation EllipsisLoc, IdentifierInfo *ParamName,
11283 SourceLocation ParamNameLoc, unsigned Depth, unsigned Position,
11284 SourceLocation EqualLoc, ParsedTemplateArgument DefaultArg);
11285
11286 /// ActOnTemplateParameterList - Builds a TemplateParameterList, optionally
11287 /// constrained by RequiresClause, that contains the template parameters in
11288 /// Params.
11290 unsigned Depth, SourceLocation ExportLoc, SourceLocation TemplateLoc,
11291 SourceLocation LAngleLoc, ArrayRef<NamedDecl *> Params,
11292 SourceLocation RAngleLoc, Expr *RequiresClause);
11293
11294 /// The context in which we are checking a template parameter list.
11305
11306 /// Checks the validity of a template parameter list, possibly
11307 /// considering the template parameter list from a previous
11308 /// declaration.
11309 ///
11310 /// If an "old" template parameter list is provided, it must be
11311 /// equivalent (per TemplateParameterListsAreEqual) to the "new"
11312 /// template parameter list.
11313 ///
11314 /// \param NewParams Template parameter list for a new template
11315 /// declaration. This template parameter list will be updated with any
11316 /// default arguments that are carried through from the previous
11317 /// template parameter list.
11318 ///
11319 /// \param OldParams If provided, template parameter list from a
11320 /// previous declaration of the same template. Default template
11321 /// arguments will be merged from the old template parameter list to
11322 /// the new template parameter list.
11323 ///
11324 /// \param TPC Describes the context in which we are checking the given
11325 /// template parameter list.
11326 ///
11327 /// \param SkipBody If we might have already made a prior merged definition
11328 /// of this template visible, the corresponding body-skipping information.
11329 /// Default argument redefinition is not an error when skipping such a body,
11330 /// because (under the ODR) we can assume the default arguments are the same
11331 /// as the prior merged definition.
11332 ///
11333 /// \returns true if an error occurred, false otherwise.
11335 TemplateParameterList *OldParams,
11337 SkipBodyInfo *SkipBody = nullptr);
11338
11339 /// Match the given template parameter lists to the given scope
11340 /// specifier, returning the template parameter list that applies to the
11341 /// name.
11342 ///
11343 /// \param DeclStartLoc the start of the declaration that has a scope
11344 /// specifier or a template parameter list.
11345 ///
11346 /// \param DeclLoc The location of the declaration itself.
11347 ///
11348 /// \param SS the scope specifier that will be matched to the given template
11349 /// parameter lists. This scope specifier precedes a qualified name that is
11350 /// being declared.
11351 ///
11352 /// \param TemplateId The template-id following the scope specifier, if there
11353 /// is one. Used to check for a missing 'template<>'.
11354 ///
11355 /// \param ParamLists the template parameter lists, from the outermost to the
11356 /// innermost template parameter lists.
11357 ///
11358 /// \param IsFriend Whether to apply the slightly different rules for
11359 /// matching template parameters to scope specifiers in friend
11360 /// declarations.
11361 ///
11362 /// \param IsMemberSpecialization will be set true if the scope specifier
11363 /// denotes a fully-specialized type, and therefore this is a declaration of
11364 /// a member specialization.
11365 ///
11366 /// \returns the template parameter list, if any, that corresponds to the
11367 /// name that is preceded by the scope specifier @p SS. This template
11368 /// parameter list may have template parameters (if we're declaring a
11369 /// template) or may have no template parameters (if we're declaring a
11370 /// template specialization), or may be NULL (if what we're declaring isn't
11371 /// itself a template).
11373 SourceLocation DeclStartLoc, SourceLocation DeclLoc,
11374 const CXXScopeSpec &SS, TemplateIdAnnotation *TemplateId,
11375 ArrayRef<TemplateParameterList *> ParamLists, bool IsFriend,
11376 bool &IsMemberSpecialization, bool &Invalid,
11377 bool SuppressDiagnostic = false);
11378
11379 /// Returns the template parameter list with all default template argument
11380 /// information.
11382
11384 Scope *S, unsigned TagSpec, TagUseKind TUK, SourceLocation KWLoc,
11385 CXXScopeSpec &SS, IdentifierInfo *Name, SourceLocation NameLoc,
11386 const ParsedAttributesView &Attr, TemplateParameterList *TemplateParams,
11387 AccessSpecifier AS, SourceLocation ModulePrivateLoc,
11388 SourceLocation FriendLoc, unsigned NumOuterTemplateParamLists,
11389 TemplateParameterList **OuterTemplateParamLists,
11390 SkipBodyInfo *SkipBody = nullptr);
11391
11392 /// Translates template arguments as provided by the parser
11393 /// into template arguments used by semantic analysis.
11396
11397 /// Convert a parsed type into a parsed template argument. This is mostly
11398 /// trivial, except that we may have parsed a C++17 deduced class template
11399 /// specialization type, in which case we should form a template template
11400 /// argument instead of a type template argument.
11402
11404
11406 SourceLocation TemplateLoc,
11407 TemplateArgumentListInfo &TemplateArgs);
11408
11411 TemplateTy Template, const IdentifierInfo *TemplateII,
11412 SourceLocation TemplateIILoc, SourceLocation LAngleLoc,
11413 ASTTemplateArgsPtr TemplateArgs, SourceLocation RAngleLoc,
11414 bool IsCtorOrDtorName = false, bool IsClassName = false,
11415 ImplicitTypenameContext AllowImplicitTypename =
11417
11418 /// Parsed an elaborated-type-specifier that refers to a template-id,
11419 /// such as \c class T::template apply<U>.
11421 TagUseKind TUK, TypeSpecifierType TagSpec, SourceLocation TagLoc,
11422 CXXScopeSpec &SS, SourceLocation TemplateKWLoc, TemplateTy TemplateD,
11423 SourceLocation TemplateLoc, SourceLocation LAngleLoc,
11424 ASTTemplateArgsPtr TemplateArgsIn, SourceLocation RAngleLoc);
11425
11428 SourceLocation TemplateKWLoc, TemplateParameterList *TemplateParams,
11430
11431 /// Get the specialization of the given variable template corresponding to
11432 /// the specified argument list, or a null-but-valid result if the arguments
11433 /// are dependent.
11435 SourceLocation TemplateLoc,
11436 SourceLocation TemplateNameLoc,
11437 const TemplateArgumentListInfo &TemplateArgs);
11438
11439 /// Form a reference to the specialization of the given variable template
11440 /// corresponding to the specified argument list, or a null-but-valid result
11441 /// if the arguments are dependent.
11443 const DeclarationNameInfo &NameInfo,
11444 VarTemplateDecl *Template, NamedDecl *FoundD,
11445 SourceLocation TemplateLoc,
11446 const TemplateArgumentListInfo *TemplateArgs);
11447
11449 CheckConceptTemplateId(const CXXScopeSpec &SS, SourceLocation TemplateKWLoc,
11450 const DeclarationNameInfo &ConceptNameInfo,
11451 NamedDecl *FoundDecl, ConceptDecl *NamedConcept,
11452 const TemplateArgumentListInfo *TemplateArgs);
11453
11456 bool TemplateKeyword, TemplateDecl *TD,
11458
11460 SourceLocation TemplateKWLoc, LookupResult &R,
11461 bool RequiresADL,
11462 const TemplateArgumentListInfo *TemplateArgs);
11463
11464 // We actually only call this from template instantiation.
11467 const DeclarationNameInfo &NameInfo,
11468 const TemplateArgumentListInfo *TemplateArgs,
11469 bool IsAddressOfOperand);
11470
11471 /// Form a template name from a name that is syntactically required to name a
11472 /// template, either due to use of the 'template' keyword or because a name in
11473 /// this syntactic context is assumed to name a template (C++
11474 /// [temp.names]p2-4).
11475 ///
11476 /// This action forms a template name given the name of the template and its
11477 /// optional scope specifier. This is used when the 'template' keyword is used
11478 /// or when the parsing context unambiguously treats a following '<' as
11479 /// introducing a template argument list. Note that this may produce a
11480 /// non-dependent template name if we can perform the lookup now and identify
11481 /// the named template.
11482 ///
11483 /// For example, given "x.MetaFun::template apply", the scope specifier
11484 /// \p SS will be "MetaFun::", \p TemplateKWLoc contains the location
11485 /// of the "template" keyword, and "apply" is the \p Name.
11487 SourceLocation TemplateKWLoc,
11488 const UnqualifiedId &Name,
11489 ParsedType ObjectType,
11490 bool EnteringContext, TemplateTy &Template,
11491 bool AllowInjectedClassName = false);
11492
11494 Scope *S, unsigned TagSpec, TagUseKind TUK, SourceLocation KWLoc,
11495 SourceLocation ModulePrivateLoc, CXXScopeSpec &SS,
11497 MultiTemplateParamsArg TemplateParameterLists,
11498 SkipBodyInfo *SkipBody = nullptr);
11499
11500 /// Check the non-type template arguments of a class template
11501 /// partial specialization according to C++ [temp.class.spec]p9.
11502 ///
11503 /// \param TemplateNameLoc the location of the template name.
11504 /// \param PrimaryTemplate the template parameters of the primary class
11505 /// template.
11506 /// \param NumExplicit the number of explicitly-specified template arguments.
11507 /// \param TemplateArgs the template arguments of the class template
11508 /// partial specialization.
11509 ///
11510 /// \returns \c true if there was an error, \c false otherwise.
11512 TemplateDecl *PrimaryTemplate,
11513 unsigned NumExplicitArgs,
11519
11521 MultiTemplateParamsArg TemplateParameterLists,
11522 Declarator &D);
11523
11524 /// Diagnose cases where we have an explicit template specialization
11525 /// before/after an explicit template instantiation, producing diagnostics
11526 /// for those cases where they are required and determining whether the
11527 /// new specialization/instantiation will have any effect.
11528 ///
11529 /// \param NewLoc the location of the new explicit specialization or
11530 /// instantiation.
11531 ///
11532 /// \param NewTSK the kind of the new explicit specialization or
11533 /// instantiation.
11534 ///
11535 /// \param PrevDecl the previous declaration of the entity.
11536 ///
11537 /// \param PrevTSK the kind of the old explicit specialization or
11538 /// instantiatin.
11539 ///
11540 /// \param PrevPointOfInstantiation if valid, indicates where the previous
11541 /// declaration was instantiated (either implicitly or explicitly).
11542 ///
11543 /// \param HasNoEffect will be set to true to indicate that the new
11544 /// specialization or instantiation has no effect and should be ignored.
11545 ///
11546 /// \returns true if there was an error that should prevent the introduction
11547 /// of the new declaration into the AST, false otherwise.
11549 SourceLocation NewLoc,
11550 TemplateSpecializationKind ActOnExplicitInstantiationNewTSK,
11551 NamedDecl *PrevDecl, TemplateSpecializationKind PrevTSK,
11552 SourceLocation PrevPtOfInstantiation, bool &SuppressNew);
11553
11554 /// Perform semantic analysis for the given dependent function
11555 /// template specialization.
11556 ///
11557 /// The only possible way to get a dependent function template specialization
11558 /// is with a friend declaration, like so:
11559 ///
11560 /// \code
11561 /// template <class T> void foo(T);
11562 /// template <class T> class A {
11563 /// friend void foo<>(T);
11564 /// };
11565 /// \endcode
11566 ///
11567 /// There really isn't any useful analysis we can do here, so we
11568 /// just store the information.
11570 FunctionDecl *FD, const TemplateArgumentListInfo *ExplicitTemplateArgs,
11572
11573 /// Perform semantic analysis for the given function template
11574 /// specialization.
11575 ///
11576 /// This routine performs all of the semantic analysis required for an
11577 /// explicit function template specialization. On successful completion,
11578 /// the function declaration \p FD will become a function template
11579 /// specialization.
11580 ///
11581 /// \param FD the function declaration, which will be updated to become a
11582 /// function template specialization.
11583 ///
11584 /// \param ExplicitTemplateArgs the explicitly-provided template arguments,
11585 /// if any. Note that this may be valid info even when 0 arguments are
11586 /// explicitly provided as in, e.g., \c void sort<>(char*, char*);
11587 /// as it anyway contains info on the angle brackets locations.
11588 ///
11589 /// \param Previous the set of declarations that may be specialized by
11590 /// this function specialization.
11591 ///
11592 /// \param QualifiedFriend whether this is a lookup for a qualified friend
11593 /// declaration with no explicit template argument list that might be
11594 /// befriending a function template specialization.
11596 FunctionDecl *FD, TemplateArgumentListInfo *ExplicitTemplateArgs,
11597 LookupResult &Previous, bool QualifiedFriend = false);
11598
11599 /// Perform semantic analysis for the given non-template member
11600 /// specialization.
11601 ///
11602 /// This routine performs all of the semantic analysis required for an
11603 /// explicit member function specialization. On successful completion,
11604 /// the function declaration \p FD will become a member function
11605 /// specialization.
11606 ///
11607 /// \param Member the member declaration, which will be updated to become a
11608 /// specialization.
11609 ///
11610 /// \param Previous the set of declarations, one of which may be specialized
11611 /// by this function specialization; the set will be modified to contain the
11612 /// redeclared member.
11615
11616 // Explicit instantiation of a class template specialization
11618 Scope *S, SourceLocation ExternLoc, SourceLocation TemplateLoc,
11619 unsigned TagSpec, SourceLocation KWLoc, const CXXScopeSpec &SS,
11620 TemplateTy Template, SourceLocation TemplateNameLoc,
11621 SourceLocation LAngleLoc, ASTTemplateArgsPtr TemplateArgs,
11622 SourceLocation RAngleLoc, const ParsedAttributesView &Attr);
11623
11624 // Explicit instantiation of a member class of a class template.
11626 SourceLocation TemplateLoc,
11627 unsigned TagSpec, SourceLocation KWLoc,
11628 CXXScopeSpec &SS, IdentifierInfo *Name,
11629 SourceLocation NameLoc,
11630 const ParsedAttributesView &Attr);
11631
11633 SourceLocation TemplateLoc,
11634 Declarator &D);
11635
11636 /// If the given template parameter has a default template
11637 /// argument, substitute into that default template argument and
11638 /// return the corresponding template argument.
11640 TemplateDecl *Template, SourceLocation TemplateLoc,
11641 SourceLocation RAngleLoc, Decl *Param,
11642 ArrayRef<TemplateArgument> SugaredConverted,
11643 ArrayRef<TemplateArgument> CanonicalConverted, bool &HasDefaultArg);
11644
11645 /// Returns the top most location responsible for the definition of \p N.
11646 /// If \p N is a a template specialization, this is the location
11647 /// of the top of the instantiation stack.
11648 /// Otherwise, the location of \p N is returned.
11650
11651 /// Specifies the context in which a particular template
11652 /// argument is being checked.
11654 /// The template argument was specified in the code or was
11655 /// instantiated with some deduced template arguments.
11657
11658 /// The template argument was deduced via template argument
11659 /// deduction.
11661
11662 /// The template argument was deduced from an array bound
11663 /// via template argument deduction.
11666
11668 explicit CheckTemplateArgumentInfo(bool PartialOrdering = false,
11669 bool MatchingTTP = false)
11670 : PartialOrdering(PartialOrdering), MatchingTTP(MatchingTTP) {}
11674
11675 /// The checked, converted argument will be added to the
11676 /// end of these vectors.
11678
11679 /// The check is being performed in the context of partial ordering.
11681
11682 /// If true, assume these template arguments are
11683 /// the injected template arguments for a template template parameter.
11684 /// This will relax the requirement that all its possible uses are valid:
11685 /// TTP checking is loose, and assumes that invalid uses will be diagnosed
11686 /// during instantiation.
11688
11689 /// Is set to true when, in the context of TTP matching, a pack parameter
11690 /// matches non-pack arguments.
11691 bool MatchedPackOnParmToNonPackOnArg = false;
11692 };
11693
11694 /// Check that the given template argument corresponds to the given
11695 /// template parameter.
11696 ///
11697 /// \param Param The template parameter against which the argument will be
11698 /// checked.
11699 ///
11700 /// \param Arg The template argument, which may be updated due to conversions.
11701 ///
11702 /// \param Template The template in which the template argument resides.
11703 ///
11704 /// \param TemplateLoc The location of the template name for the template
11705 /// whose argument list we're matching.
11706 ///
11707 /// \param RAngleLoc The location of the right angle bracket ('>') that closes
11708 /// the template argument list.
11709 ///
11710 /// \param ArgumentPackIndex The index into the argument pack where this
11711 /// argument will be placed. Only valid if the parameter is a parameter pack.
11712 ///
11713 /// \param CTAK Describes how we arrived at this particular template argument:
11714 /// explicitly written, deduced, etc.
11715 ///
11716 /// \returns true on error, false otherwise.
11718 NamedDecl *Template, SourceLocation TemplateLoc,
11719 SourceLocation RAngleLoc,
11720 unsigned ArgumentPackIndex,
11723
11724 /// Check that the given template arguments can be provided to
11725 /// the given template, converting the arguments along the way.
11726 ///
11727 /// \param Template The template to which the template arguments are being
11728 /// provided.
11729 ///
11730 /// \param TemplateLoc The location of the template name in the source.
11731 ///
11732 /// \param TemplateArgs The list of template arguments. If the template is
11733 /// a template template parameter, this function may extend the set of
11734 /// template arguments to also include substituted, defaulted template
11735 /// arguments.
11736 ///
11737 /// \param PartialTemplateArgs True if the list of template arguments is
11738 /// intentionally partial, e.g., because we're checking just the initial
11739 /// set of template arguments.
11740 ///
11741 /// \param Converted Will receive the converted, canonicalized template
11742 /// arguments.
11743 ///
11744 /// \param UpdateArgsWithConversions If \c true, update \p TemplateArgs to
11745 /// contain the converted forms of the template arguments as written.
11746 /// Otherwise, \p TemplateArgs will not be modified.
11747 ///
11748 /// \param ConstraintsNotSatisfied If provided, and an error occurred, will
11749 /// receive true if the cause for the error is the associated constraints of
11750 /// the template not being satisfied by the template arguments.
11751 ///
11752 /// \param DefaultArgs any default arguments from template specialization
11753 /// deduction.
11754 ///
11755 /// \returns true if an error occurred, false otherwise.
11757 SourceLocation TemplateLoc,
11758 TemplateArgumentListInfo &TemplateArgs,
11759 const DefaultArguments &DefaultArgs,
11760 bool PartialTemplateArgs,
11762 bool UpdateArgsWithConversions = true,
11763 bool *ConstraintsNotSatisfied = nullptr);
11764
11767 SmallVectorImpl<TemplateArgument> &SugaredConverted,
11768 SmallVectorImpl<TemplateArgument> &CanonicalConverted);
11769
11770 /// Check a template argument against its corresponding
11771 /// template type parameter.
11772 ///
11773 /// This routine implements the semantics of C++ [temp.arg.type]. It
11774 /// returns true if an error occurred, and false otherwise.
11776
11777 /// Check a template argument against its corresponding
11778 /// non-type template parameter.
11779 ///
11780 /// This routine implements the semantics of C++ [temp.arg.nontype].
11781 /// If an error occurred, it returns ExprError(); otherwise, it
11782 /// returns the converted template argument. \p ParamType is the
11783 /// type of the non-type template parameter after it has been instantiated.
11785 QualType InstantiatedParamType, Expr *Arg,
11786 TemplateArgument &SugaredConverted,
11787 TemplateArgument &CanonicalConverted,
11788 bool MatchingTTP,
11790
11791 /// Check a template argument against its corresponding
11792 /// template template parameter.
11793 ///
11794 /// This routine implements the semantics of C++ [temp.arg.template].
11795 /// It returns true if an error occurred, and false otherwise.
11797 TemplateParameterList *Params,
11799 bool PartialOrdering,
11800 bool *MatchedPackOnParmToNonPackOnArg);
11801
11803 std::optional<SourceRange> ParamRange = {});
11805
11806 /// Given a non-type template argument that refers to a
11807 /// declaration and the type of its corresponding non-type template
11808 /// parameter, produce an expression that properly refers to that
11809 /// declaration.
11810 /// FIXME: This is used in some contexts where the resulting expression
11811 /// doesn't need to live too long. It would be useful if this function
11812 /// could return a temporary expression.
11814 const TemplateArgument &Arg, QualType ParamType, SourceLocation Loc,
11815 NamedDecl *TemplateParam = nullptr);
11819
11820 /// Enumeration describing how template parameter lists are compared
11821 /// for equality.
11823 /// We are matching the template parameter lists of two templates
11824 /// that might be redeclarations.
11825 ///
11826 /// \code
11827 /// template<typename T> struct X;
11828 /// template<typename T> struct X;
11829 /// \endcode
11831
11832 /// We are matching the template parameter lists of two template
11833 /// template parameters as part of matching the template parameter lists
11834 /// of two templates that might be redeclarations.
11835 ///
11836 /// \code
11837 /// template<template<int I> class TT> struct X;
11838 /// template<template<int Value> class Other> struct X;
11839 /// \endcode
11841
11842 /// We are determining whether the template-parameters are equivalent
11843 /// according to C++ [temp.over.link]/6. This comparison does not consider
11844 /// constraints.
11845 ///
11846 /// \code
11847 /// template<C1 T> void f(T);
11848 /// template<C2 T> void f(T);
11849 /// \endcode
11851 };
11852
11853 // A struct to represent the 'new' declaration, which is either itself just
11854 // the named decl, or the important information we need about it in order to
11855 // do constraint comparisons.
11857 const NamedDecl *ND = nullptr;
11858 const DeclContext *DC = nullptr;
11859 const DeclContext *LexicalDC = nullptr;
11861
11862 public:
11865 const DeclContext *LexicalDeclCtx,
11867
11868 : DC(DeclCtx), LexicalDC(LexicalDeclCtx), Loc(Loc) {
11869 assert(DC && LexicalDC &&
11870 "Constructor only for cases where we have the information to put "
11871 "in here");
11872 }
11873
11874 // If this was constructed with no information, we cannot do substitution
11875 // for constraint comparison, so make sure we can check that.
11876 bool isInvalid() const { return !ND && !DC; }
11877
11878 const NamedDecl *getDecl() const { return ND; }
11879
11880 bool ContainsDecl(const NamedDecl *ND) const { return this->ND == ND; }
11881
11883 return ND ? ND->getLexicalDeclContext() : LexicalDC;
11884 }
11885
11887 return ND ? ND->getDeclContext() : DC;
11888 }
11889
11890 SourceLocation getLocation() const { return ND ? ND->getLocation() : Loc; }
11891 };
11892
11893 /// Determine whether the given template parameter lists are
11894 /// equivalent.
11895 ///
11896 /// \param New The new template parameter list, typically written in the
11897 /// source code as part of a new template declaration.
11898 ///
11899 /// \param Old The old template parameter list, typically found via
11900 /// name lookup of the template declared with this template parameter
11901 /// list.
11902 ///
11903 /// \param Complain If true, this routine will produce a diagnostic if
11904 /// the template parameter lists are not equivalent.
11905 ///
11906 /// \param Kind describes how we are to match the template parameter lists.
11907 ///
11908 /// \param TemplateArgLoc If this source location is valid, then we
11909 /// are actually checking the template parameter list of a template
11910 /// argument (New) against the template parameter list of its
11911 /// corresponding template template parameter (Old). We produce
11912 /// slightly different diagnostics in this scenario.
11913 ///
11914 /// \returns True if the template parameter lists are equal, false
11915 /// otherwise.
11917 const TemplateCompareNewDeclInfo &NewInstFrom, TemplateParameterList *New,
11918 const NamedDecl *OldInstFrom, TemplateParameterList *Old, bool Complain,
11920 SourceLocation TemplateArgLoc = SourceLocation());
11921
11923 TemplateParameterList *New, TemplateParameterList *Old, bool Complain,
11925 SourceLocation TemplateArgLoc = SourceLocation()) {
11926 return TemplateParameterListsAreEqual(nullptr, New, nullptr, Old, Complain,
11927 Kind, TemplateArgLoc);
11928 }
11929
11930 /// Check whether a template can be declared within this scope.
11931 ///
11932 /// If the template declaration is valid in this scope, returns
11933 /// false. Otherwise, issues a diagnostic and returns true.
11934 bool CheckTemplateDeclScope(Scope *S, TemplateParameterList *TemplateParams);
11935
11936 /// Called when the parser has parsed a C++ typename
11937 /// specifier, e.g., "typename T::type".
11938 ///
11939 /// \param S The scope in which this typename type occurs.
11940 /// \param TypenameLoc the location of the 'typename' keyword
11941 /// \param SS the nested-name-specifier following the typename (e.g., 'T::').
11942 /// \param II the identifier we're retrieving (e.g., 'type' in the example).
11943 /// \param IdLoc the location of the identifier.
11944 /// \param IsImplicitTypename context where T::type refers to a type.
11946 Scope *S, SourceLocation TypenameLoc, const CXXScopeSpec &SS,
11947 const IdentifierInfo &II, SourceLocation IdLoc,
11949
11950 /// Called when the parser has parsed a C++ typename
11951 /// specifier that ends in a template-id, e.g.,
11952 /// "typename MetaFun::template apply<T1, T2>".
11953 ///
11954 /// \param S The scope in which this typename type occurs.
11955 /// \param TypenameLoc the location of the 'typename' keyword
11956 /// \param SS the nested-name-specifier following the typename (e.g., 'T::').
11957 /// \param TemplateLoc the location of the 'template' keyword, if any.
11958 /// \param TemplateName The template name.
11959 /// \param TemplateII The identifier used to name the template.
11960 /// \param TemplateIILoc The location of the template name.
11961 /// \param LAngleLoc The location of the opening angle bracket ('<').
11962 /// \param TemplateArgs The template arguments.
11963 /// \param RAngleLoc The location of the closing angle bracket ('>').
11965 ActOnTypenameType(Scope *S, SourceLocation TypenameLoc,
11966 const CXXScopeSpec &SS, SourceLocation TemplateLoc,
11967 TemplateTy TemplateName, const IdentifierInfo *TemplateII,
11968 SourceLocation TemplateIILoc, SourceLocation LAngleLoc,
11969 ASTTemplateArgsPtr TemplateArgs, SourceLocation RAngleLoc);
11970
11972 SourceLocation KeywordLoc,
11973 NestedNameSpecifierLoc QualifierLoc,
11974 const IdentifierInfo &II, SourceLocation IILoc,
11975 TypeSourceInfo **TSI, bool DeducedTSTContext);
11976
11978 SourceLocation KeywordLoc,
11979 NestedNameSpecifierLoc QualifierLoc,
11980 const IdentifierInfo &II, SourceLocation IILoc,
11981 bool DeducedTSTContext = true);
11982
11983 /// Rebuilds a type within the context of the current instantiation.
11984 ///
11985 /// The type \p T is part of the type of an out-of-line member definition of
11986 /// a class template (or class template partial specialization) that was
11987 /// parsed and constructed before we entered the scope of the class template
11988 /// (or partial specialization thereof). This routine will rebuild that type
11989 /// now that we have entered the declarator's scope, which may produce
11990 /// different canonical types, e.g.,
11991 ///
11992 /// \code
11993 /// template<typename T>
11994 /// struct X {
11995 /// typedef T* pointer;
11996 /// pointer data();
11997 /// };
11998 ///
11999 /// template<typename T>
12000 /// typename X<T>::pointer X<T>::data() { ... }
12001 /// \endcode
12002 ///
12003 /// Here, the type "typename X<T>::pointer" will be created as a
12004 /// DependentNameType, since we do not know that we can look into X<T> when we
12005 /// parsed the type. This function will rebuild the type, performing the
12006 /// lookup of "pointer" in X<T> and returning an ElaboratedType whose
12007 /// canonical type is the same as the canonical type of T*, allowing the
12008 /// return types of the out-of-line definition and the declaration to match.
12011 DeclarationName Name);
12013
12015
12016 /// Rebuild the template parameters now that we know we're in a current
12017 /// instantiation.
12018 bool
12020
12021 /// Produces a formatted string that describes the binding of
12022 /// template parameters to template arguments.
12023 std::string
12025 const TemplateArgumentList &Args);
12026
12027 std::string
12029 const TemplateArgument *Args,
12030 unsigned NumArgs);
12031
12035
12036 /// ActOnDependentIdExpression - Handle a dependent id-expression that
12037 /// was just parsed. This is only possible with an explicit scope
12038 /// specifier naming a dependent type.
12040 const CXXScopeSpec &SS, SourceLocation TemplateKWLoc,
12041 const DeclarationNameInfo &NameInfo, bool isAddressOfOperand,
12042 const TemplateArgumentListInfo *TemplateArgs);
12043
12046 SourceLocation TemplateKWLoc,
12047 const DeclarationNameInfo &NameInfo,
12048 const TemplateArgumentListInfo *TemplateArgs);
12049
12050 // Calculates whether the expression Constraint depends on an enclosing
12051 // template, for the purposes of [temp.friend] p9.
12052 // TemplateDepth is the 'depth' of the friend function, which is used to
12053 // compare whether a declaration reference is referring to a containing
12054 // template, or just the current friend function. A 'lower' TemplateDepth in
12055 // the AST refers to a 'containing' template. As the constraint is
12056 // uninstantiated, this is relative to the 'top' of the TU.
12057 bool
12059 unsigned TemplateDepth,
12060 const Expr *Constraint);
12061
12062 /// Find the failed Boolean condition within a given Boolean
12063 /// constant expression, and describe it with a string.
12064 std::pair<Expr *, std::string> findFailedBooleanCondition(Expr *Cond);
12065
12067
12069 Scope *S, MultiTemplateParamsArg TemplateParameterLists,
12070 const IdentifierInfo *Name, SourceLocation NameLoc);
12071
12073 Expr *ConstraintExpr,
12074 const ParsedAttributesView &Attrs);
12075
12077 bool &AddToScope);
12079
12080 TypeResult ActOnDependentTag(Scope *S, unsigned TagSpec, TagUseKind TUK,
12081 const CXXScopeSpec &SS,
12082 const IdentifierInfo *Name,
12083 SourceLocation TagLoc, SourceLocation NameLoc);
12084
12086 CachedTokens &Toks);
12089
12090 /// We've found a use of a templated declaration that would trigger an
12091 /// implicit instantiation. Check that any relevant explicit specializations
12092 /// and partial specializations are visible/reachable, and diagnose if not.
12095
12096 ///@}
12097
12098 //
12099 //
12100 // -------------------------------------------------------------------------
12101 //
12102 //
12103
12104 /// \name C++ Template Argument Deduction
12105 /// Implementations are in SemaTemplateDeduction.cpp
12106 ///@{
12107
12108public:
12109 /// When true, access checking violations are treated as SFINAE
12110 /// failures rather than hard errors.
12112
12113 /// RAII class used to determine whether SFINAE has
12114 /// trapped any errors that occur during template argument
12115 /// deduction.
12117 Sema &SemaRef;
12118 unsigned PrevSFINAEErrors;
12119 bool PrevInNonInstantiationSFINAEContext;
12120 bool PrevAccessCheckingSFINAE;
12121 bool PrevLastDiagnosticIgnored;
12122
12123 public:
12124 explicit SFINAETrap(Sema &SemaRef, bool AccessCheckingSFINAE = false)
12125 : SemaRef(SemaRef), PrevSFINAEErrors(SemaRef.NumSFINAEErrors),
12126 PrevInNonInstantiationSFINAEContext(
12127 SemaRef.InNonInstantiationSFINAEContext),
12128 PrevAccessCheckingSFINAE(SemaRef.AccessCheckingSFINAE),
12129 PrevLastDiagnosticIgnored(
12130 SemaRef.getDiagnostics().isLastDiagnosticIgnored()) {
12131 if (!SemaRef.isSFINAEContext())
12132 SemaRef.InNonInstantiationSFINAEContext = true;
12133 SemaRef.AccessCheckingSFINAE = AccessCheckingSFINAE;
12134 }
12135
12137 SemaRef.NumSFINAEErrors = PrevSFINAEErrors;
12139 PrevInNonInstantiationSFINAEContext;
12140 SemaRef.AccessCheckingSFINAE = PrevAccessCheckingSFINAE;
12142 PrevLastDiagnosticIgnored);
12143 }
12144
12145 /// Determine whether any SFINAE errors have been trapped.
12146 bool hasErrorOccurred() const {
12147 return SemaRef.NumSFINAEErrors > PrevSFINAEErrors;
12148 }
12149 };
12150
12151 /// RAII class used to indicate that we are performing provisional
12152 /// semantic analysis to determine the validity of a construct, so
12153 /// typo-correction and diagnostics in the immediate context (not within
12154 /// implicitly-instantiated templates) should be suppressed.
12156 Sema &SemaRef;
12157 // FIXME: Using a SFINAETrap for this is a hack.
12158 SFINAETrap Trap;
12159 bool PrevDisableTypoCorrection;
12160
12161 public:
12162 explicit TentativeAnalysisScope(Sema &SemaRef)
12163 : SemaRef(SemaRef), Trap(SemaRef, true),
12164 PrevDisableTypoCorrection(SemaRef.DisableTypoCorrection) {
12165 SemaRef.DisableTypoCorrection = true;
12166 }
12168 SemaRef.DisableTypoCorrection = PrevDisableTypoCorrection;
12169 }
12170 };
12171
12172 /// For each declaration that involved template argument deduction, the
12173 /// set of diagnostics that were suppressed during that template argument
12174 /// deduction.
12175 ///
12176 /// FIXME: Serialize this structure to the AST file.
12177 typedef llvm::DenseMap<Decl *, SmallVector<PartialDiagnosticAt, 1>>
12180
12181 /// Compare types for equality with respect to possibly compatible
12182 /// function types (noreturn adjustment, implicit calling conventions). If any
12183 /// of parameter and argument is not a function, just perform type comparison.
12184 ///
12185 /// \param P the template parameter type.
12186 ///
12187 /// \param A the argument type.
12189
12190 /// Allocate a TemplateArgumentLoc where all locations have
12191 /// been initialized to the given location.
12192 ///
12193 /// \param Arg The template argument we are producing template argument
12194 /// location information for.
12195 ///
12196 /// \param NTTPType For a declaration template argument, the type of
12197 /// the non-type template parameter that corresponds to this template
12198 /// argument. Can be null if no type sugar is available to add to the
12199 /// type from the template argument.
12200 ///
12201 /// \param Loc The source location to use for the resulting template
12202 /// argument.
12206 NamedDecl *TemplateParam = nullptr);
12207
12208 /// Get a template argument mapping the given template parameter to itself,
12209 /// e.g. for X in \c template<int X>, this would return an expression template
12210 /// argument referencing X.
12212 SourceLocation Location);
12213
12214 /// Adjust the type \p ArgFunctionType to match the calling convention,
12215 /// noreturn, and optionally the exception specification of \p FunctionType.
12216 /// Deduction often wants to ignore these properties when matching function
12217 /// types.
12219 bool AdjustExceptionSpec = false);
12220
12223 ArrayRef<TemplateArgument> TemplateArgs,
12225
12228 ArrayRef<TemplateArgument> TemplateArgs,
12230
12231 /// Deduce the template arguments of the given template from \p FromType.
12232 /// Used to implement the IsDeducible constraint for alias CTAD per C++
12233 /// [over.match.class.deduct]p4.
12234 ///
12235 /// It only supports class or type alias templates.
12239
12244 bool NumberOfArgumentsMustMatch);
12245
12246 /// Substitute the explicitly-provided template arguments into the
12247 /// given function template according to C++ [temp.arg.explicit].
12248 ///
12249 /// \param FunctionTemplate the function template into which the explicit
12250 /// template arguments will be substituted.
12251 ///
12252 /// \param ExplicitTemplateArgs the explicitly-specified template
12253 /// arguments.
12254 ///
12255 /// \param Deduced the deduced template arguments, which will be populated
12256 /// with the converted and checked explicit template arguments.
12257 ///
12258 /// \param ParamTypes will be populated with the instantiated function
12259 /// parameters.
12260 ///
12261 /// \param FunctionType if non-NULL, the result type of the function template
12262 /// will also be instantiated and the pointed-to value will be updated with
12263 /// the instantiated function type.
12264 ///
12265 /// \param Info if substitution fails for any reason, this object will be
12266 /// populated with more information about the failure.
12267 ///
12268 /// \returns TemplateDeductionResult::Success if substitution was successful,
12269 /// or some failure condition.
12272 TemplateArgumentListInfo &ExplicitTemplateArgs,
12276
12277 /// brief A function argument from which we performed template argument
12278 // deduction for a call.
12280 OriginalCallArg(QualType OriginalParamType, bool DecomposedParam,
12281 unsigned ArgIdx, QualType OriginalArgType)
12282 : OriginalParamType(OriginalParamType),
12283 DecomposedParam(DecomposedParam), ArgIdx(ArgIdx),
12284 OriginalArgType(OriginalArgType) {}
12285
12288 unsigned ArgIdx;
12290 };
12291
12292 /// Finish template argument deduction for a function template,
12293 /// checking the deduced template arguments for completeness and forming
12294 /// the function template specialization.
12295 ///
12296 /// \param OriginalCallArgs If non-NULL, the original call arguments against
12297 /// which the deduced argument types should be compared.
12301 unsigned NumExplicitlySpecified, FunctionDecl *&Specialization,
12303 SmallVectorImpl<OriginalCallArg> const *OriginalCallArgs,
12304 bool PartialOverloading, bool PartialOrdering,
12305 llvm::function_ref<bool()> CheckNonDependent = [] { return false; });
12306
12307 /// Perform template argument deduction from a function call
12308 /// (C++ [temp.deduct.call]).
12309 ///
12310 /// \param FunctionTemplate the function template for which we are performing
12311 /// template argument deduction.
12312 ///
12313 /// \param ExplicitTemplateArgs the explicit template arguments provided
12314 /// for this call.
12315 ///
12316 /// \param Args the function call arguments
12317 ///
12318 /// \param Specialization if template argument deduction was successful,
12319 /// this will be set to the function template specialization produced by
12320 /// template argument deduction.
12321 ///
12322 /// \param Info the argument will be updated to provide additional information
12323 /// about template argument deduction.
12324 ///
12325 /// \param CheckNonDependent A callback to invoke to check conversions for
12326 /// non-dependent parameters, between deduction and substitution, per DR1391.
12327 /// If this returns true, substitution will be skipped and we return
12328 /// TemplateDeductionResult::NonDependentConversionFailure. The callback is
12329 /// passed the parameter types (after substituting explicit template
12330 /// arguments).
12331 ///
12332 /// \returns the result of template argument deduction.
12335 TemplateArgumentListInfo *ExplicitTemplateArgs, ArrayRef<Expr *> Args,
12337 bool PartialOverloading, bool AggregateDeductionCandidate,
12338 bool PartialOrdering, QualType ObjectType,
12339 Expr::Classification ObjectClassification,
12340 llvm::function_ref<bool(ArrayRef<QualType>)> CheckNonDependent);
12341
12342 /// Deduce template arguments when taking the address of a function
12343 /// template (C++ [temp.deduct.funcaddr]) or matching a specialization to
12344 /// a template.
12345 ///
12346 /// \param FunctionTemplate the function template for which we are performing
12347 /// template argument deduction.
12348 ///
12349 /// \param ExplicitTemplateArgs the explicitly-specified template
12350 /// arguments.
12351 ///
12352 /// \param ArgFunctionType the function type that will be used as the
12353 /// "argument" type (A) when performing template argument deduction from the
12354 /// function template's function type. This type may be NULL, if there is no
12355 /// argument type to compare against, in C++0x [temp.arg.explicit]p3.
12356 ///
12357 /// \param Specialization if template argument deduction was successful,
12358 /// this will be set to the function template specialization produced by
12359 /// template argument deduction.
12360 ///
12361 /// \param Info the argument will be updated to provide additional information
12362 /// about template argument deduction.
12363 ///
12364 /// \param IsAddressOfFunction If \c true, we are deducing as part of taking
12365 /// the address of a function template per [temp.deduct.funcaddr] and
12366 /// [over.over]. If \c false, we are looking up a function template
12367 /// specialization based on its signature, per [temp.deduct.decl].
12368 ///
12369 /// \returns the result of template argument deduction.
12372 TemplateArgumentListInfo *ExplicitTemplateArgs, QualType ArgFunctionType,
12374 bool IsAddressOfFunction = false);
12375
12376 /// Deduce template arguments for a templated conversion
12377 /// function (C++ [temp.deduct.conv]) and, if successful, produce a
12378 /// conversion function template specialization.
12381 Expr::Classification ObjectClassification, QualType ToType,
12383
12384 /// Deduce template arguments for a function template when there is
12385 /// nothing to deduce against (C++0x [temp.arg.explicit]p3).
12386 ///
12387 /// \param FunctionTemplate the function template for which we are performing
12388 /// template argument deduction.
12389 ///
12390 /// \param ExplicitTemplateArgs the explicitly-specified template
12391 /// arguments.
12392 ///
12393 /// \param Specialization if template argument deduction was successful,
12394 /// this will be set to the function template specialization produced by
12395 /// template argument deduction.
12396 ///
12397 /// \param Info the argument will be updated to provide additional information
12398 /// about template argument deduction.
12399 ///
12400 /// \param IsAddressOfFunction If \c true, we are deducing as part of taking
12401 /// the address of a function template in a context where we do not have a
12402 /// target type, per [over.over]. If \c false, we are looking up a function
12403 /// template specialization based on its signature, which only happens when
12404 /// deducing a function parameter type from an argument that is a template-id
12405 /// naming a function template specialization.
12406 ///
12407 /// \returns the result of template argument deduction.
12410 TemplateArgumentListInfo *ExplicitTemplateArgs,
12413 bool IsAddressOfFunction = false);
12414
12415 /// Substitute Replacement for \p auto in \p TypeWithAuto
12416 QualType SubstAutoType(QualType TypeWithAuto, QualType Replacement);
12417 /// Substitute Replacement for auto in TypeWithAuto
12419 QualType Replacement);
12420
12421 // Substitute auto in TypeWithAuto for a Dependent auto type
12423
12424 // Substitute auto in TypeWithAuto for a Dependent auto type
12427
12428 /// Completely replace the \c auto in \p TypeWithAuto by
12429 /// \p Replacement. This does not retain any \c auto type sugar.
12430 QualType ReplaceAutoType(QualType TypeWithAuto, QualType Replacement);
12432 QualType Replacement);
12433
12434 /// Deduce the type for an auto type-specifier (C++11 [dcl.spec.auto]p6)
12435 ///
12436 /// Note that this is done even if the initializer is dependent. (This is
12437 /// necessary to support partial ordering of templates using 'auto'.)
12438 /// A dependent type will be produced when deducing from a dependent type.
12439 ///
12440 /// \param Type the type pattern using the auto type-specifier.
12441 /// \param Init the initializer for the variable whose type is to be deduced.
12442 /// \param Result if type deduction was successful, this will be set to the
12443 /// deduced type.
12444 /// \param Info the argument will be updated to provide additional information
12445 /// about template argument deduction.
12446 /// \param DependentDeduction Set if we should permit deduction in
12447 /// dependent cases. This is necessary for template partial ordering
12448 /// with 'auto' template parameters. The template parameter depth to be
12449 /// used should be specified in the 'Info' parameter.
12450 /// \param IgnoreConstraints Set if we should not fail if the deduced type
12451 /// does not satisfy the type-constraint in the auto
12452 /// type.
12456 bool DependentDeduction = false,
12457 bool IgnoreConstraints = false,
12458 TemplateSpecCandidateSet *FailedTSC = nullptr);
12459 void DiagnoseAutoDeductionFailure(const VarDecl *VDecl, const Expr *Init);
12461 bool Diagnose = true);
12462
12465
12466 /// Returns the more specialized class template partial specialization
12467 /// according to the rules of partial ordering of class template partial
12468 /// specializations (C++ [temp.class.order]).
12469 ///
12470 /// \param PS1 the first class template partial specialization
12471 ///
12472 /// \param PS2 the second class template partial specialization
12473 ///
12474 /// \returns the more specialized class template partial specialization. If
12475 /// neither partial specialization is more specialized, returns NULL.
12480
12483
12487
12490
12492 TemplateParameterList *PParam, TemplateDecl *PArg, TemplateDecl *AArg,
12493 const DefaultArguments &DefaultArgs, SourceLocation ArgLoc,
12494 bool PartialOrdering, bool *MatchedPackOnParmToNonPackOnArg);
12495
12496 /// Mark which template parameters are used in a given expression.
12497 ///
12498 /// \param E the expression from which template parameters will be deduced.
12499 ///
12500 /// \param Used a bit vector whose elements will be set to \c true
12501 /// to indicate when the corresponding template parameter will be
12502 /// deduced.
12503 void MarkUsedTemplateParameters(const Expr *E, bool OnlyDeduced,
12504 unsigned Depth, llvm::SmallBitVector &Used);
12505
12506 /// Mark which template parameters can be deduced from a given
12507 /// template argument list.
12508 ///
12509 /// \param TemplateArgs the template argument list from which template
12510 /// parameters will be deduced.
12511 ///
12512 /// \param Used a bit vector whose elements will be set to \c true
12513 /// to indicate when the corresponding template parameter will be
12514 /// deduced.
12515 void MarkUsedTemplateParameters(const TemplateArgumentList &TemplateArgs,
12516 bool OnlyDeduced, unsigned Depth,
12517 llvm::SmallBitVector &Used);
12518 void
12520 llvm::SmallBitVector &Deduced) {
12522 }
12523
12524 /// Marks all of the template parameters that will be deduced by a
12525 /// call to the given function template.
12526 static void
12529 llvm::SmallBitVector &Deduced);
12530
12531 /// Returns the more specialized function template according
12532 /// to the rules of function template partial ordering (C++
12533 /// [temp.func.order]).
12534 ///
12535 /// \param FT1 the first function template
12536 ///
12537 /// \param FT2 the second function template
12538 ///
12539 /// \param TPOC the context in which we are performing partial ordering of
12540 /// function templates.
12541 ///
12542 /// \param NumCallArguments1 The number of arguments in the call to FT1, used
12543 /// only when \c TPOC is \c TPOC_Call. Does not include the object argument
12544 /// when calling a member function.
12545 ///
12546 /// \param RawObj1Ty The type of the object parameter of FT1 if a member
12547 /// function only used if \c TPOC is \c TPOC_Call and FT1 is a Function
12548 /// template from a member function
12549 ///
12550 /// \param RawObj2Ty The type of the object parameter of FT2 if a member
12551 /// function only used if \c TPOC is \c TPOC_Call and FT2 is a Function
12552 /// template from a member function
12553 ///
12554 /// \param Reversed If \c true, exactly one of FT1 and FT2 is an overload
12555 /// candidate with a reversed parameter order. In this case, the corresponding
12556 /// P/A pairs between FT1 and FT2 are reversed.
12557 ///
12558 /// \returns the more specialized function template. If neither
12559 /// template is more specialized, returns NULL.
12562 TemplatePartialOrderingContext TPOC, unsigned NumCallArguments1,
12563 QualType RawObj1Ty = {}, QualType RawObj2Ty = {}, bool Reversed = false);
12564
12565 /// Retrieve the most specialized of the given function template
12566 /// specializations.
12567 ///
12568 /// \param SpecBegin the start iterator of the function template
12569 /// specializations that we will be comparing.
12570 ///
12571 /// \param SpecEnd the end iterator of the function template
12572 /// specializations, paired with \p SpecBegin.
12573 ///
12574 /// \param Loc the location where the ambiguity or no-specializations
12575 /// diagnostic should occur.
12576 ///
12577 /// \param NoneDiag partial diagnostic used to diagnose cases where there are
12578 /// no matching candidates.
12579 ///
12580 /// \param AmbigDiag partial diagnostic used to diagnose an ambiguity, if one
12581 /// occurs.
12582 ///
12583 /// \param CandidateDiag partial diagnostic used for each function template
12584 /// specialization that is a candidate in the ambiguous ordering. One
12585 /// parameter in this diagnostic should be unbound, which will correspond to
12586 /// the string describing the template arguments for the function template
12587 /// specialization.
12588 ///
12589 /// \returns the most specialized function template specialization, if
12590 /// found. Otherwise, returns SpecEnd.
12591 UnresolvedSetIterator
12592 getMostSpecialized(UnresolvedSetIterator SBegin, UnresolvedSetIterator SEnd,
12593 TemplateSpecCandidateSet &FailedCandidates,
12594 SourceLocation Loc, const PartialDiagnostic &NoneDiag,
12595 const PartialDiagnostic &AmbigDiag,
12596 const PartialDiagnostic &CandidateDiag,
12597 bool Complain = true, QualType TargetType = QualType());
12598
12599 /// Returns the more constrained function according to the rules of
12600 /// partial ordering by constraints (C++ [temp.constr.order]).
12601 ///
12602 /// \param FD1 the first function
12603 ///
12604 /// \param FD2 the second function
12605 ///
12606 /// \returns the more constrained function. If neither function is
12607 /// more constrained, returns NULL.
12608 FunctionDecl *getMoreConstrainedFunction(FunctionDecl *FD1,
12609 FunctionDecl *FD2);
12610
12611 ///@}
12612
12613 //
12614 //
12615 // -------------------------------------------------------------------------
12616 //
12617 //
12618
12619 /// \name C++ Template Deduction Guide
12620 /// Implementations are in SemaTemplateDeductionGuide.cpp
12621 ///@{
12622
12623 /// Declare implicit deduction guides for a class template if we've
12624 /// not already done so.
12625 void DeclareImplicitDeductionGuides(TemplateDecl *Template,
12626 SourceLocation Loc);
12627
12628 FunctionTemplateDecl *DeclareAggregateDeductionGuideFromInitList(
12629 TemplateDecl *Template, MutableArrayRef<QualType> ParamTypes,
12630 SourceLocation Loc);
12631
12632 ///@}
12633
12634 //
12635 //
12636 // -------------------------------------------------------------------------
12637 //
12638 //
12639
12640 /// \name C++ Template Instantiation
12641 /// Implementations are in SemaTemplateInstantiate.cpp
12642 ///@{
12643
12644public:
12645 /// A helper class for building up ExtParameterInfos.
12648 bool HasInteresting = false;
12649
12650 public:
12651 /// Set the ExtParameterInfo for the parameter at the given index,
12652 ///
12653 void set(unsigned index, FunctionProtoType::ExtParameterInfo info) {
12654 assert(Infos.size() <= index);
12655 Infos.resize(index);
12656 Infos.push_back(info);
12657
12658 if (!HasInteresting)
12659 HasInteresting = (info != FunctionProtoType::ExtParameterInfo());
12660 }
12661
12662 /// Return a pointer (suitable for setting in an ExtProtoInfo) to the
12663 /// ExtParameterInfo array we've built up.
12665 getPointerOrNull(unsigned numParams) {
12666 if (!HasInteresting)
12667 return nullptr;
12668 Infos.resize(numParams);
12669 return Infos.data();
12670 }
12671 };
12672
12673 /// The current instantiation scope used to store local
12674 /// variables.
12676
12677 typedef llvm::DenseMap<ParmVarDecl *, llvm::TinyPtrVector<ParmVarDecl *>>
12679
12680 /// A mapping from parameters with unparsed default arguments to the
12681 /// set of instantiations of each parameter.
12682 ///
12683 /// This mapping is a temporary data structure used when parsing
12684 /// nested class templates or nested classes of class templates,
12685 /// where we might end up instantiating an inner class before the
12686 /// default arguments of its methods have been parsed.
12688
12689 /// A context in which code is being synthesized (where a source location
12690 /// alone is not sufficient to identify the context). This covers template
12691 /// instantiation and various forms of implicitly-generated functions.
12693 /// The kind of template instantiation we are performing
12695 /// We are instantiating a template declaration. The entity is
12696 /// the declaration we're instantiating (e.g., a CXXRecordDecl).
12698
12699 /// We are instantiating a default argument for a template
12700 /// parameter. The Entity is the template parameter whose argument is
12701 /// being instantiated, the Template is the template, and the
12702 /// TemplateArgs/NumTemplateArguments provide the template arguments as
12703 /// specified.
12705
12706 /// We are instantiating a default argument for a function.
12707 /// The Entity is the ParmVarDecl, and TemplateArgs/NumTemplateArgs
12708 /// provides the template arguments as specified.
12710
12711 /// We are substituting explicit template arguments provided for
12712 /// a function template. The entity is a FunctionTemplateDecl.
12714
12715 /// We are substituting template argument determined as part of
12716 /// template argument deduction for either a class template
12717 /// partial specialization or a function template. The
12718 /// Entity is either a {Class|Var}TemplatePartialSpecializationDecl or
12719 /// a TemplateDecl.
12721
12722 /// We are substituting into a lambda expression.
12724
12725 /// We are substituting prior template arguments into a new
12726 /// template parameter. The template parameter itself is either a
12727 /// NonTypeTemplateParmDecl or a TemplateTemplateParmDecl.
12729
12730 /// We are checking the validity of a default template argument that
12731 /// has been used when naming a template-id.
12733
12734 /// We are computing the exception specification for a defaulted special
12735 /// member function.
12737
12738 /// We are instantiating the exception specification for a function
12739 /// template which was deferred until it was needed.
12741
12742 /// We are instantiating a requirement of a requires expression.
12744
12745 /// We are checking the satisfaction of a nested requirement of a requires
12746 /// expression.
12748
12749 /// We are declaring an implicit special member function.
12751
12752 /// We are declaring an implicit 'operator==' for a defaulted
12753 /// 'operator<=>'.
12755
12756 /// We are defining a synthesized function (such as a defaulted special
12757 /// member).
12759
12760 // We are checking the constraints associated with a constrained entity or
12761 // the constraint expression of a concept. This includes the checks that
12762 // atomic constraints have the type 'bool' and that they can be constant
12763 // evaluated.
12765
12766 // We are substituting template arguments into a constraint expression.
12768
12769 // We are normalizing a constraint expression.
12771
12772 // Instantiating a Requires Expression parameter clause.
12774
12775 // We are substituting into the parameter mapping of an atomic constraint
12776 // during normalization.
12778
12779 /// We are rewriting a comparison operator in terms of an operator<=>.
12781
12782 /// We are initializing a structured binding.
12784
12785 /// We are marking a class as __dllexport.
12787
12788 /// We are building an implied call from __builtin_dump_struct. The
12789 /// arguments are in CallArgs.
12791
12792 /// Added for Template instantiation observation.
12793 /// Memoization means we are _not_ instantiating a template because
12794 /// it is already instantiated (but we entered a context where we
12795 /// would have had to if it was not already instantiated).
12797
12798 /// We are building deduction guides for a class.
12800
12801 /// We are instantiating a type alias template declaration.
12803
12804 /// We are performing partial ordering for template template parameters.
12807
12808 /// Was the enclosing context a non-instantiation SFINAE context?
12810
12811 /// The point of instantiation or synthesis within the source code.
12813
12814 /// The entity that is being synthesized.
12816
12817 /// The template (or partial specialization) in which we are
12818 /// performing the instantiation, for substitutions of prior template
12819 /// arguments.
12821
12822 union {
12823 /// The list of template arguments we are substituting, if they
12824 /// are not part of the entity.
12826
12827 /// The list of argument expressions in a synthesized call.
12828 const Expr *const *CallArgs;
12829 };
12830
12831 // FIXME: Wrap this union around more members, or perhaps store the
12832 // kind-specific members in the RAII object owning the context.
12833 union {
12834 /// The number of template arguments in TemplateArgs.
12836
12837 /// The number of expressions in CallArgs.
12838 unsigned NumCallArgs;
12839
12840 /// The special member being declared or defined.
12842 };
12843
12845 assert(Kind != DeclaringSpecialMember);
12846 return {TemplateArgs, NumTemplateArgs};
12847 }
12848
12849 /// The template deduction info object associated with the
12850 /// substitution or checking of explicit or deduced template arguments.
12852
12853 /// The source range that covers the construct that cause
12854 /// the instantiation, e.g., the template-id that causes a class
12855 /// template instantiation.
12857
12859 : Kind(TemplateInstantiation),
12860 SavedInNonInstantiationSFINAEContext(false), Entity(nullptr),
12861 Template(nullptr), TemplateArgs(nullptr), NumTemplateArgs(0),
12862 DeductionInfo(nullptr) {}
12863
12864 /// Determines whether this template is an actual instantiation
12865 /// that should be counted toward the maximum instantiation depth.
12866 bool isInstantiationRecord() const;
12867 };
12868
12869 /// A stack object to be created when performing template
12870 /// instantiation.
12871 ///
12872 /// Construction of an object of type \c InstantiatingTemplate
12873 /// pushes the current instantiation onto the stack of active
12874 /// instantiations. If the size of this stack exceeds the maximum
12875 /// number of recursive template instantiations, construction
12876 /// produces an error and evaluates true.
12877 ///
12878 /// Destruction of this object will pop the named instantiation off
12879 /// the stack.
12881 /// Note that we are instantiating a class template,
12882 /// function template, variable template, alias template,
12883 /// or a member thereof.
12884 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
12885 Decl *Entity,
12886 SourceRange InstantiationRange = SourceRange());
12887
12889 /// Note that we are instantiating an exception specification
12890 /// of a function template.
12891 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
12893 SourceRange InstantiationRange = SourceRange());
12894
12895 /// Note that we are instantiating a type alias template declaration.
12896 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
12897 TypeAliasTemplateDecl *Entity,
12898 ArrayRef<TemplateArgument> TemplateArgs,
12899 SourceRange InstantiationRange = SourceRange());
12900
12901 /// Note that we are instantiating a default argument in a
12902 /// template-id.
12903 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
12904 TemplateParameter Param, TemplateDecl *Template,
12905 ArrayRef<TemplateArgument> TemplateArgs,
12906 SourceRange InstantiationRange = SourceRange());
12907
12908 /// Note that we are substituting either explicitly-specified or
12909 /// deduced template arguments during function template argument deduction.
12910 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
12911 FunctionTemplateDecl *FunctionTemplate,
12912 ArrayRef<TemplateArgument> TemplateArgs,
12914 sema::TemplateDeductionInfo &DeductionInfo,
12915 SourceRange InstantiationRange = SourceRange());
12916
12917 /// Note that we are instantiating as part of template
12918 /// argument deduction for a class template declaration.
12919 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
12920 TemplateDecl *Template,
12921 ArrayRef<TemplateArgument> TemplateArgs,
12922 sema::TemplateDeductionInfo &DeductionInfo,
12923 SourceRange InstantiationRange = SourceRange());
12924
12925 /// Note that we are instantiating as part of template
12926 /// argument deduction for a class template partial
12927 /// specialization.
12928 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
12930 ArrayRef<TemplateArgument> TemplateArgs,
12931 sema::TemplateDeductionInfo &DeductionInfo,
12932 SourceRange InstantiationRange = SourceRange());
12933
12934 /// Note that we are instantiating as part of template
12935 /// argument deduction for a variable template partial
12936 /// specialization.
12937 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
12939 ArrayRef<TemplateArgument> TemplateArgs,
12940 sema::TemplateDeductionInfo &DeductionInfo,
12941 SourceRange InstantiationRange = SourceRange());
12942
12943 /// Note that we are instantiating a default argument for a function
12944 /// parameter.
12945 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
12946 ParmVarDecl *Param,
12947 ArrayRef<TemplateArgument> TemplateArgs,
12948 SourceRange InstantiationRange = SourceRange());
12949
12950 /// Note that we are substituting prior template arguments into a
12951 /// non-type parameter.
12952 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
12953 NamedDecl *Template, NonTypeTemplateParmDecl *Param,
12954 ArrayRef<TemplateArgument> TemplateArgs,
12955 SourceRange InstantiationRange);
12956
12957 /// Note that we are substituting prior template arguments into a
12958 /// template template parameter.
12959 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
12960 NamedDecl *Template, TemplateTemplateParmDecl *Param,
12961 ArrayRef<TemplateArgument> TemplateArgs,
12962 SourceRange InstantiationRange);
12963
12964 /// Note that we are checking the default template argument
12965 /// against the template parameter for a given template-id.
12966 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
12967 TemplateDecl *Template, NamedDecl *Param,
12968 ArrayRef<TemplateArgument> TemplateArgs,
12969 SourceRange InstantiationRange);
12970
12972 /// \brief Note that we are checking the constraints associated with some
12973 /// constrained entity (a concept declaration or a template with associated
12974 /// constraints).
12975 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
12976 ConstraintsCheck, NamedDecl *Template,
12977 ArrayRef<TemplateArgument> TemplateArgs,
12978 SourceRange InstantiationRange);
12979
12981 /// \brief Note that we are checking a constraint expression associated
12982 /// with a template declaration or as part of the satisfaction check of a
12983 /// concept.
12984 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
12986 sema::TemplateDeductionInfo &DeductionInfo,
12987 SourceRange InstantiationRange);
12988
12990 /// \brief Note that we are normalizing a constraint expression.
12991 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
12993 SourceRange InstantiationRange);
12994
12996 /// \brief Note that we are subtituting into the parameter mapping of an
12997 /// atomic constraint during constraint normalization.
12998 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
13000 SourceRange InstantiationRange);
13001
13002 /// \brief Note that we are substituting template arguments into a part of
13003 /// a requirement of a requires expression.
13004 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
13006 sema::TemplateDeductionInfo &DeductionInfo,
13007 SourceRange InstantiationRange = SourceRange());
13008
13009 /// \brief Note that we are checking the satisfaction of the constraint
13010 /// expression inside of a nested requirement.
13011 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
13013 SourceRange InstantiationRange = SourceRange());
13014
13015 /// \brief Note that we are checking a requires clause.
13016 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
13017 const RequiresExpr *E,
13018 sema::TemplateDeductionInfo &DeductionInfo,
13019 SourceRange InstantiationRange);
13020
13022 /// \brief Note that we are building deduction guides.
13023 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
13025 SourceRange InstantiationRange = SourceRange());
13026
13028 /// \brief Note that we are partial ordering template template parameters.
13029 InstantiatingTemplate(Sema &SemaRef, SourceLocation ArgLoc,
13031 SourceRange InstantiationRange = SourceRange());
13032
13033 /// Note that we have finished instantiating this template.
13034 void Clear();
13035
13037
13038 /// Determines whether we have exceeded the maximum
13039 /// recursive template instantiations.
13040 bool isInvalid() const { return Invalid; }
13041
13042 /// Determine whether we are already instantiating this
13043 /// specialization in some surrounding active instantiation.
13044 bool isAlreadyInstantiating() const { return AlreadyInstantiating; }
13045
13046 private:
13047 Sema &SemaRef;
13048 bool Invalid;
13049 bool AlreadyInstantiating;
13050 bool CheckInstantiationDepth(SourceLocation PointOfInstantiation,
13051 SourceRange InstantiationRange);
13052
13053 InstantiatingTemplate(Sema &SemaRef,
13055 SourceLocation PointOfInstantiation,
13056 SourceRange InstantiationRange, Decl *Entity,
13057 NamedDecl *Template = nullptr,
13058 ArrayRef<TemplateArgument> TemplateArgs = {},
13059 sema::TemplateDeductionInfo *DeductionInfo = nullptr);
13060
13061 InstantiatingTemplate(const InstantiatingTemplate &) = delete;
13062
13063 InstantiatingTemplate &operator=(const InstantiatingTemplate &) = delete;
13064 };
13065
13066 bool SubstTemplateArgument(const TemplateArgumentLoc &Input,
13067 const MultiLevelTemplateArgumentList &TemplateArgs,
13068 TemplateArgumentLoc &Output,
13069 SourceLocation Loc = {},
13070 const DeclarationName &Entity = {});
13071 bool
13072 SubstTemplateArguments(ArrayRef<TemplateArgumentLoc> Args,
13073 const MultiLevelTemplateArgumentList &TemplateArgs,
13074 TemplateArgumentListInfo &Outputs);
13075
13076 /// Retrieve the template argument list(s) that should be used to
13077 /// instantiate the definition of the given declaration.
13078 ///
13079 /// \param ND the declaration for which we are computing template
13080 /// instantiation arguments.
13081 ///
13082 /// \param DC In the event we don't HAVE a declaration yet, we instead provide
13083 /// the decl context where it will be created. In this case, the `Innermost`
13084 /// should likely be provided. If ND is non-null, this is ignored.
13085 ///
13086 /// \param Innermost if non-NULL, specifies a template argument list for the
13087 /// template declaration passed as ND.
13088 ///
13089 /// \param RelativeToPrimary true if we should get the template
13090 /// arguments relative to the primary template, even when we're
13091 /// dealing with a specialization. This is only relevant for function
13092 /// template specializations.
13093 ///
13094 /// \param Pattern If non-NULL, indicates the pattern from which we will be
13095 /// instantiating the definition of the given declaration, \p ND. This is
13096 /// used to determine the proper set of template instantiation arguments for
13097 /// friend function template specializations.
13098 ///
13099 /// \param ForConstraintInstantiation when collecting arguments,
13100 /// ForConstraintInstantiation indicates we should continue looking when
13101 /// encountering a lambda generic call operator, and continue looking for
13102 /// arguments on an enclosing class template.
13103 ///
13104 /// \param SkipForSpecialization when specified, any template specializations
13105 /// in a traversal would be ignored.
13106 /// \param ForDefaultArgumentSubstitution indicates we should continue looking
13107 /// when encountering a specialized member function template, rather than
13108 /// returning immediately.
13109 MultiLevelTemplateArgumentList getTemplateInstantiationArgs(
13110 const NamedDecl *D, const DeclContext *DC = nullptr, bool Final = false,
13111 std::optional<ArrayRef<TemplateArgument>> Innermost = std::nullopt,
13112 bool RelativeToPrimary = false, const FunctionDecl *Pattern = nullptr,
13113 bool ForConstraintInstantiation = false,
13114 bool SkipForSpecialization = false,
13115 bool ForDefaultArgumentSubstitution = false);
13116
13117 /// RAII object to handle the state changes required to synthesize
13118 /// a function body.
13120 Sema &S;
13121 Sema::ContextRAII SavedContext;
13122 bool PushedCodeSynthesisContext = false;
13123
13124 public:
13126 : S(S), SavedContext(S, DC) {
13127 auto *FD = dyn_cast<FunctionDecl>(DC);
13128 S.PushFunctionScope();
13129 S.PushExpressionEvaluationContext(
13130 (FD && FD->isImmediateFunction())
13131 ? ExpressionEvaluationContext::ImmediateFunctionContext
13132 : ExpressionEvaluationContext::PotentiallyEvaluated);
13133 if (FD) {
13134 auto &Current = S.currentEvaluationContext();
13135 const auto &Parent = S.parentEvaluationContext();
13136
13137 FD->setWillHaveBody(true);
13138 Current.InImmediateFunctionContext =
13139 FD->isImmediateFunction() ||
13140 (isLambdaMethod(FD) && (Parent.isConstantEvaluated() ||
13141 Parent.isImmediateFunctionContext()));
13142
13143 Current.InImmediateEscalatingFunctionContext =
13144 S.getLangOpts().CPlusPlus20 && FD->isImmediateEscalating();
13145 } else
13146 assert(isa<ObjCMethodDecl>(DC));
13147 }
13148
13150 assert(!PushedCodeSynthesisContext);
13151
13153 Ctx.Kind = Sema::CodeSynthesisContext::DefiningSynthesizedFunction;
13154 Ctx.PointOfInstantiation = UseLoc;
13155 Ctx.Entity = cast<Decl>(S.CurContext);
13156 S.pushCodeSynthesisContext(Ctx);
13157
13158 PushedCodeSynthesisContext = true;
13159 }
13160
13162 if (PushedCodeSynthesisContext)
13163 S.popCodeSynthesisContext();
13164 if (auto *FD = dyn_cast<FunctionDecl>(S.CurContext)) {
13165 FD->setWillHaveBody(false);
13166 S.CheckImmediateEscalatingFunctionDefinition(FD, S.getCurFunction());
13167 }
13168 S.PopExpressionEvaluationContext();
13169 S.PopFunctionScopeInfo();
13170 }
13171 };
13172
13173 /// List of active code synthesis contexts.
13174 ///
13175 /// This vector is treated as a stack. As synthesis of one entity requires
13176 /// synthesis of another, additional contexts are pushed onto the stack.
13178
13179 /// Specializations whose definitions are currently being instantiated.
13180 llvm::DenseSet<std::pair<Decl *, unsigned>> InstantiatingSpecializations;
13181
13182 /// Non-dependent types used in templates that have already been instantiated
13183 /// by some template instantiation.
13184 llvm::DenseSet<QualType> InstantiatedNonDependentTypes;
13185
13186 /// Extra modules inspected when performing a lookup during a template
13187 /// instantiation. Computed lazily.
13189
13190 /// Cache of additional modules that should be used for name lookup
13191 /// within the current template instantiation. Computed lazily; use
13192 /// getLookupModules() to get a complete set.
13193 llvm::DenseSet<Module *> LookupModulesCache;
13194
13195 /// Map from the most recent declaration of a namespace to the most
13196 /// recent visible declaration of that namespace.
13197 llvm::DenseMap<NamedDecl *, NamedDecl *> VisibleNamespaceCache;
13198
13199 /// Whether we are in a SFINAE context that is not associated with
13200 /// template instantiation.
13201 ///
13202 /// This is used when setting up a SFINAE trap (\c see SFINAETrap) outside
13203 /// of a template instantiation or template argument deduction.
13205
13206 /// The number of \p CodeSynthesisContexts that are not template
13207 /// instantiations and, therefore, should not be counted as part of the
13208 /// instantiation depth.
13209 ///
13210 /// When the instantiation depth reaches the user-configurable limit
13211 /// \p LangOptions::InstantiationDepth we will abort instantiation.
13212 // FIXME: Should we have a similar limit for other forms of synthesis?
13214
13215 /// The depth of the context stack at the point when the most recent
13216 /// error or warning was produced.
13217 ///
13218 /// This value is used to suppress printing of redundant context stacks
13219 /// when there are multiple errors or warnings in the same instantiation.
13220 // FIXME: Does this belong in Sema? It's tough to implement it anywhere else.
13222
13223 /// The template instantiation callbacks to trace or track
13224 /// instantiations (objects can be chained).
13225 ///
13226 /// This callbacks is used to print, trace or track template
13227 /// instantiations as they are being constructed.
13228 std::vector<std::unique_ptr<TemplateInstantiationCallback>>
13230
13231 /// The current index into pack expansion arguments that will be
13232 /// used for substitution of parameter packs.
13233 ///
13234 /// The pack expansion index will be -1 to indicate that parameter packs
13235 /// should be instantiated as themselves. Otherwise, the index specifies
13236 /// which argument within the parameter pack will be used for substitution.
13238
13239 /// RAII object used to change the argument pack substitution index
13240 /// within a \c Sema object.
13241 ///
13242 /// See \c ArgumentPackSubstitutionIndex for more information.
13244 Sema &Self;
13245 int OldSubstitutionIndex;
13246
13247 public:
13248 ArgumentPackSubstitutionIndexRAII(Sema &Self, int NewSubstitutionIndex)
13249 : Self(Self), OldSubstitutionIndex(Self.ArgumentPackSubstitutionIndex) {
13250 Self.ArgumentPackSubstitutionIndex = NewSubstitutionIndex;
13251 }
13252
13254 Self.ArgumentPackSubstitutionIndex = OldSubstitutionIndex;
13255 }
13256 };
13257
13259
13262
13264 if (!CodeSynthesisContexts.empty() &&
13268 }
13271 }
13272 /// Prints the current instantiation stack through a series of
13273 /// notes.
13275
13276 /// Determines whether we are currently in a context where
13277 /// template argument substitution failures are not considered
13278 /// errors.
13279 ///
13280 /// \returns An empty \c Optional if we're not in a SFINAE context.
13281 /// Otherwise, contains a pointer that, if non-NULL, contains the nearest
13282 /// template-deduction context object, which can be used to capture
13283 /// diagnostics that will be suppressed.
13284 std::optional<sema::TemplateDeductionInfo *> isSFINAEContext() const;
13285
13286 /// Perform substitution on the type T with a given set of template
13287 /// arguments.
13288 ///
13289 /// This routine substitutes the given template arguments into the
13290 /// type T and produces the instantiated type.
13291 ///
13292 /// \param T the type into which the template arguments will be
13293 /// substituted. If this type is not dependent, it will be returned
13294 /// immediately.
13295 ///
13296 /// \param Args the template arguments that will be
13297 /// substituted for the top-level template parameters within T.
13298 ///
13299 /// \param Loc the location in the source code where this substitution
13300 /// is being performed. It will typically be the location of the
13301 /// declarator (if we're instantiating the type of some declaration)
13302 /// or the location of the type in the source code (if, e.g., we're
13303 /// instantiating the type of a cast expression).
13304 ///
13305 /// \param Entity the name of the entity associated with a declaration
13306 /// being instantiated (if any). May be empty to indicate that there
13307 /// is no such entity (if, e.g., this is a type that occurs as part of
13308 /// a cast expression) or that the entity has no name (e.g., an
13309 /// unnamed function parameter).
13310 ///
13311 /// \param AllowDeducedTST Whether a DeducedTemplateSpecializationType is
13312 /// acceptable as the top level type of the result.
13313 ///
13314 /// \param IsIncompleteSubstitution If provided, the pointee will be set
13315 /// whenever substitution would perform a replacement with a null or
13316 /// non-existent template argument.
13317 ///
13318 /// \returns If the instantiation succeeds, the instantiated
13319 /// type. Otherwise, produces diagnostics and returns a NULL type.
13321 const MultiLevelTemplateArgumentList &TemplateArgs,
13323 bool AllowDeducedTST = false);
13324
13326 const MultiLevelTemplateArgumentList &TemplateArgs,
13328 bool *IsIncompleteSubstitution = nullptr);
13329
13331 const MultiLevelTemplateArgumentList &TemplateArgs,
13333
13334 /// A form of SubstType intended specifically for instantiating the
13335 /// type of a FunctionDecl. Its purpose is solely to force the
13336 /// instantiation of default-argument expressions and to avoid
13337 /// instantiating an exception-specification.
13339 TypeSourceInfo *T, const MultiLevelTemplateArgumentList &TemplateArgs,
13340 SourceLocation Loc, DeclarationName Entity, CXXRecordDecl *ThisContext,
13341 Qualifiers ThisTypeQuals, bool EvaluateConstraints = true);
13342 void SubstExceptionSpec(FunctionDecl *New, const FunctionProtoType *Proto,
13343 const MultiLevelTemplateArgumentList &Args);
13346 SmallVectorImpl<QualType> &ExceptionStorage,
13347 const MultiLevelTemplateArgumentList &Args);
13348 ParmVarDecl *
13350 const MultiLevelTemplateArgumentList &TemplateArgs,
13351 int indexAdjustment, std::optional<unsigned> NumExpansions,
13352 bool ExpectParameterPack, bool EvaluateConstraints = true);
13353
13354 /// Substitute the given template arguments into the given set of
13355 /// parameters, producing the set of parameter types that would be generated
13356 /// from such a substitution.
13358 const FunctionProtoType::ExtParameterInfo *ExtParamInfos,
13359 const MultiLevelTemplateArgumentList &TemplateArgs,
13360 SmallVectorImpl<QualType> &ParamTypes,
13362 ExtParameterInfoBuilder &ParamInfos);
13363
13364 /// Substitute the given template arguments into the default argument.
13366 const MultiLevelTemplateArgumentList &TemplateArgs,
13367 bool ForCallExpr = false);
13369 const MultiLevelTemplateArgumentList &TemplateArgs);
13370
13371 // A RAII type used by the TemplateDeclInstantiator and TemplateInstantiator
13372 // to disable constraint evaluation, then restore the state.
13373 template <typename InstTy> struct ConstraintEvalRAII {
13374 InstTy &TI;
13376
13378 : TI(TI), OldValue(TI.getEvaluateConstraints()) {
13379 TI.setEvaluateConstraints(false);
13380 }
13381 ~ConstraintEvalRAII() { TI.setEvaluateConstraints(OldValue); }
13382 };
13383
13384 // Must be used instead of SubstExpr at 'constraint checking' time.
13387 const MultiLevelTemplateArgumentList &TemplateArgs);
13388 // Unlike the above, this does not evaluates constraints.
13390 Expr *E, const MultiLevelTemplateArgumentList &TemplateArgs);
13391
13392 /// Substitute the given template arguments into a list of
13393 /// expressions, expanding pack expansions if required.
13394 ///
13395 /// \param Exprs The list of expressions to substitute into.
13396 ///
13397 /// \param IsCall Whether this is some form of call, in which case
13398 /// default arguments will be dropped.
13399 ///
13400 /// \param TemplateArgs The set of template arguments to substitute.
13401 ///
13402 /// \param Outputs Will receive all of the substituted arguments.
13403 ///
13404 /// \returns true if an error occurred, false otherwise.
13405 bool SubstExprs(ArrayRef<Expr *> Exprs, bool IsCall,
13406 const MultiLevelTemplateArgumentList &TemplateArgs,
13407 SmallVectorImpl<Expr *> &Outputs);
13408
13410 const MultiLevelTemplateArgumentList &TemplateArgs);
13411
13414 bool CXXDirectInit);
13415
13416 /// Perform substitution on the base class specifiers of the
13417 /// given class template specialization.
13418 ///
13419 /// Produces a diagnostic and returns true on error, returns false and
13420 /// attaches the instantiated base classes to the class template
13421 /// specialization if successful.
13422 bool SubstBaseSpecifiers(CXXRecordDecl *Instantiation, CXXRecordDecl *Pattern,
13423 const MultiLevelTemplateArgumentList &TemplateArgs);
13424
13425 /// Instantiate the definition of a class from a given pattern.
13426 ///
13427 /// \param PointOfInstantiation The point of instantiation within the
13428 /// source code.
13429 ///
13430 /// \param Instantiation is the declaration whose definition is being
13431 /// instantiated. This will be either a class template specialization
13432 /// or a member class of a class template specialization.
13433 ///
13434 /// \param Pattern is the pattern from which the instantiation
13435 /// occurs. This will be either the declaration of a class template or
13436 /// the declaration of a member class of a class template.
13437 ///
13438 /// \param TemplateArgs The template arguments to be substituted into
13439 /// the pattern.
13440 ///
13441 /// \param TSK the kind of implicit or explicit instantiation to perform.
13442 ///
13443 /// \param Complain whether to complain if the class cannot be instantiated
13444 /// due to the lack of a definition.
13445 ///
13446 /// \returns true if an error occurred, false otherwise.
13447 bool InstantiateClass(SourceLocation PointOfInstantiation,
13448 CXXRecordDecl *Instantiation, CXXRecordDecl *Pattern,
13449 const MultiLevelTemplateArgumentList &TemplateArgs,
13450 TemplateSpecializationKind TSK, bool Complain = true);
13451
13452 /// Instantiate the definition of an enum from a given pattern.
13453 ///
13454 /// \param PointOfInstantiation The point of instantiation within the
13455 /// source code.
13456 /// \param Instantiation is the declaration whose definition is being
13457 /// instantiated. This will be a member enumeration of a class
13458 /// temploid specialization, or a local enumeration within a
13459 /// function temploid specialization.
13460 /// \param Pattern The templated declaration from which the instantiation
13461 /// occurs.
13462 /// \param TemplateArgs The template arguments to be substituted into
13463 /// the pattern.
13464 /// \param TSK The kind of implicit or explicit instantiation to perform.
13465 ///
13466 /// \return \c true if an error occurred, \c false otherwise.
13467 bool InstantiateEnum(SourceLocation PointOfInstantiation,
13468 EnumDecl *Instantiation, EnumDecl *Pattern,
13469 const MultiLevelTemplateArgumentList &TemplateArgs,
13471
13472 /// Instantiate the definition of a field from the given pattern.
13473 ///
13474 /// \param PointOfInstantiation The point of instantiation within the
13475 /// source code.
13476 /// \param Instantiation is the declaration whose definition is being
13477 /// instantiated. This will be a class of a class temploid
13478 /// specialization, or a local enumeration within a function temploid
13479 /// specialization.
13480 /// \param Pattern The templated declaration from which the instantiation
13481 /// occurs.
13482 /// \param TemplateArgs The template arguments to be substituted into
13483 /// the pattern.
13484 ///
13485 /// \return \c true if an error occurred, \c false otherwise.
13487 SourceLocation PointOfInstantiation, FieldDecl *Instantiation,
13488 FieldDecl *Pattern, const MultiLevelTemplateArgumentList &TemplateArgs);
13489
13492
13494 SourceLocation PointOfInstantiation,
13495 ClassTemplateSpecializationDecl *ClassTemplateSpec,
13496 TemplateSpecializationKind TSK, bool Complain = true,
13497 bool PrimaryHasMatchedPackOnParmToNonPackOnArg = false);
13498
13499 /// Instantiates the definitions of all of the member
13500 /// of the given class, which is an instantiation of a class template
13501 /// or a member class of a template.
13502 void
13503 InstantiateClassMembers(SourceLocation PointOfInstantiation,
13504 CXXRecordDecl *Instantiation,
13505 const MultiLevelTemplateArgumentList &TemplateArgs,
13507
13508 /// Instantiate the definitions of all of the members of the
13509 /// given class template specialization, which was named as part of an
13510 /// explicit instantiation.
13512 SourceLocation PointOfInstantiation,
13513 ClassTemplateSpecializationDecl *ClassTemplateSpec,
13515
13518 const MultiLevelTemplateArgumentList &TemplateArgs);
13519
13520 /// Do template substitution on declaration name info.
13523 const MultiLevelTemplateArgumentList &TemplateArgs);
13527 const MultiLevelTemplateArgumentList &TemplateArgs);
13528
13530 const MultiLevelTemplateArgumentList &TemplateArgs,
13531 bool EvaluateConstraint);
13532
13533 /// Determine whether we are currently performing template instantiation.
13536 }
13537
13538 using EntityPrinter = llvm::function_ref<void(llvm::raw_ostream &)>;
13539
13540 /// \brief create a Requirement::SubstitutionDiagnostic with only a
13541 /// SubstitutedEntity and DiagLoc using ASTContext's allocator.
13544
13545 ///@}
13546
13547 //
13548 //
13549 // -------------------------------------------------------------------------
13550 //
13551 //
13552
13553 /// \name C++ Template Declaration Instantiation
13554 /// Implementations are in SemaTemplateInstantiateDecl.cpp
13555 ///@{
13556
13557public:
13558 /// An entity for which implicit template instantiation is required.
13559 ///
13560 /// The source location associated with the declaration is the first place in
13561 /// the source code where the declaration was "used". It is not necessarily
13562 /// the point of instantiation (which will be either before or after the
13563 /// namespace-scope declaration that triggered this implicit instantiation),
13564 /// However, it is the location that diagnostics should generally refer to,
13565 /// because users will need to know what code triggered the instantiation.
13566 typedef std::pair<ValueDecl *, SourceLocation> PendingImplicitInstantiation;
13567
13568 /// The queue of implicit template instantiations that are required
13569 /// but have not yet been performed.
13570 std::deque<PendingImplicitInstantiation> PendingInstantiations;
13571
13572 /// Queue of implicit template instantiations that cannot be performed
13573 /// eagerly.
13575
13579
13580 /// The queue of implicit template instantiations that are required
13581 /// and must be performed within the current local scope.
13582 ///
13583 /// This queue is only used for member functions of local classes in
13584 /// templates, which must be instantiated in the same scope as their
13585 /// enclosing function, so that they can reference function-local
13586 /// types, static variables, enumerators, etc.
13587 std::deque<PendingImplicitInstantiation> PendingLocalImplicitInstantiations;
13588
13590 public:
13592 SavedPendingLocalImplicitInstantiations.swap(
13593 S.PendingLocalImplicitInstantiations);
13594 }
13595
13596 void perform() { S.PerformPendingInstantiations(/*LocalOnly=*/true); }
13597
13599 assert(S.PendingLocalImplicitInstantiations.empty() &&
13600 "there shouldn't be any pending local implicit instantiations");
13601 SavedPendingLocalImplicitInstantiations.swap(
13602 S.PendingLocalImplicitInstantiations);
13603 }
13604
13605 private:
13606 Sema &S;
13607 std::deque<PendingImplicitInstantiation>
13608 SavedPendingLocalImplicitInstantiations;
13609 };
13610
13611 /// Records and restores the CurFPFeatures state on entry/exit of compound
13612 /// statements.
13614 public:
13617 FPOptionsOverride getOverrides() { return OldOverrides; }
13618
13619 private:
13620 Sema &S;
13621 FPOptions OldFPFeaturesState;
13622 FPOptionsOverride OldOverrides;
13623 LangOptions::FPEvalMethodKind OldEvalMethod;
13624 SourceLocation OldFPPragmaLocation;
13625 };
13626
13628 public:
13630 : S(S), Enabled(Enabled) {
13631 if (!Enabled)
13632 return;
13633
13634 S.SavedPendingInstantiations.emplace_back();
13635 S.SavedPendingInstantiations.back().swap(S.PendingInstantiations);
13636
13637 S.SavedVTableUses.emplace_back();
13638 S.SavedVTableUses.back().swap(S.VTableUses);
13639 }
13640
13641 void perform() {
13642 if (Enabled) {
13643 S.DefineUsedVTables();
13644 S.PerformPendingInstantiations();
13645 }
13646 }
13647
13649 if (!Enabled)
13650 return;
13651
13652 // Restore the set of pending vtables.
13653 assert(S.VTableUses.empty() &&
13654 "VTableUses should be empty before it is discarded.");
13655 S.VTableUses.swap(S.SavedVTableUses.back());
13656 S.SavedVTableUses.pop_back();
13657
13658 // Restore the set of pending implicit instantiations.
13659 if (S.TUKind != TU_Prefix || !S.LangOpts.PCHInstantiateTemplates) {
13660 assert(S.PendingInstantiations.empty() &&
13661 "PendingInstantiations should be empty before it is discarded.");
13662 S.PendingInstantiations.swap(S.SavedPendingInstantiations.back());
13663 S.SavedPendingInstantiations.pop_back();
13664 } else {
13665 // Template instantiations in the PCH may be delayed until the TU.
13666 S.PendingInstantiations.swap(S.SavedPendingInstantiations.back());
13667 S.PendingInstantiations.insert(
13668 S.PendingInstantiations.end(),
13669 S.SavedPendingInstantiations.back().begin(),
13670 S.SavedPendingInstantiations.back().end());
13671 S.SavedPendingInstantiations.pop_back();
13672 }
13673 }
13674
13675 private:
13676 Sema &S;
13677 bool Enabled;
13678 };
13679
13681 const MultiLevelTemplateArgumentList &TemplateArgs, ExplicitSpecifier ES);
13682
13687
13689 Decl *D)
13690 : TmplAttr(A), Scope(S), NewDecl(D) {}
13691 };
13693
13694 void InstantiateAttrs(const MultiLevelTemplateArgumentList &TemplateArgs,
13695 const Decl *Pattern, Decl *Inst,
13696 LateInstantiatedAttrVec *LateAttrs = nullptr,
13697 LocalInstantiationScope *OuterMostScope = nullptr);
13698
13699 /// Update instantiation attributes after template was late parsed.
13700 ///
13701 /// Some attributes are evaluated based on the body of template. If it is
13702 /// late parsed, such attributes cannot be evaluated when declaration is
13703 /// instantiated. This function is used to update instantiation attributes
13704 /// when template definition is ready.
13705 void updateAttrsForLateParsedTemplate(const Decl *Pattern, Decl *Inst);
13706
13707 void
13709 const Decl *Pattern, Decl *Inst,
13710 LateInstantiatedAttrVec *LateAttrs = nullptr,
13711 LocalInstantiationScope *OuterMostScope = nullptr);
13712
13713 /// In the MS ABI, we need to instantiate default arguments of dllexported
13714 /// default constructors along with the constructor definition. This allows IR
13715 /// gen to emit a constructor closure which calls the default constructor with
13716 /// its default arguments.
13718
13720 ParmVarDecl *Param);
13721 void InstantiateExceptionSpec(SourceLocation PointOfInstantiation,
13723
13724 /// Instantiate (or find existing instantiation of) a function template with a
13725 /// given set of template arguments.
13726 ///
13727 /// Usually this should not be used, and template argument deduction should be
13728 /// used in its place.
13734
13735 /// Instantiate the definition of the given function from its
13736 /// template.
13737 ///
13738 /// \param PointOfInstantiation the point at which the instantiation was
13739 /// required. Note that this is not precisely a "point of instantiation"
13740 /// for the function, but it's close.
13741 ///
13742 /// \param Function the already-instantiated declaration of a
13743 /// function template specialization or member function of a class template
13744 /// specialization.
13745 ///
13746 /// \param Recursive if true, recursively instantiates any functions that
13747 /// are required by this instantiation.
13748 ///
13749 /// \param DefinitionRequired if true, then we are performing an explicit
13750 /// instantiation where the body of the function is required. Complain if
13751 /// there is no such body.
13752 void InstantiateFunctionDefinition(SourceLocation PointOfInstantiation,
13754 bool Recursive = false,
13755 bool DefinitionRequired = false,
13756 bool AtEndOfTU = false);
13759 const TemplateArgumentList *PartialSpecArgs,
13760 const TemplateArgumentListInfo &TemplateArgsInfo,
13762 SourceLocation PointOfInstantiation,
13763 LateInstantiatedAttrVec *LateAttrs = nullptr,
13764 LocalInstantiationScope *StartingScope = nullptr);
13765
13766 /// Instantiates a variable template specialization by completing it
13767 /// with appropriate type information and initializer.
13769 VarTemplateSpecializationDecl *VarSpec, VarDecl *PatternDecl,
13770 const MultiLevelTemplateArgumentList &TemplateArgs);
13771
13772 /// BuildVariableInstantiation - Used after a new variable has been created.
13773 /// Sets basic variable data and decides whether to postpone the
13774 /// variable instantiation.
13775 void
13777 const MultiLevelTemplateArgumentList &TemplateArgs,
13778 LateInstantiatedAttrVec *LateAttrs,
13779 DeclContext *Owner,
13780 LocalInstantiationScope *StartingScope,
13781 bool InstantiatingVarTemplate = false,
13782 VarTemplateSpecializationDecl *PrevVTSD = nullptr);
13783
13784 /// Instantiate the initializer of a variable.
13786 VarDecl *Var, VarDecl *OldVar,
13787 const MultiLevelTemplateArgumentList &TemplateArgs);
13788
13789 /// Instantiate the definition of the given variable from its
13790 /// template.
13791 ///
13792 /// \param PointOfInstantiation the point at which the instantiation was
13793 /// required. Note that this is not precisely a "point of instantiation"
13794 /// for the variable, but it's close.
13795 ///
13796 /// \param Var the already-instantiated declaration of a templated variable.
13797 ///
13798 /// \param Recursive if true, recursively instantiates any functions that
13799 /// are required by this instantiation.
13800 ///
13801 /// \param DefinitionRequired if true, then we are performing an explicit
13802 /// instantiation where a definition of the variable is required. Complain
13803 /// if there is no such definition.
13804 void InstantiateVariableDefinition(SourceLocation PointOfInstantiation,
13805 VarDecl *Var, bool Recursive = false,
13806 bool DefinitionRequired = false,
13807 bool AtEndOfTU = false);
13808
13810 CXXConstructorDecl *New, const CXXConstructorDecl *Tmpl,
13811 const MultiLevelTemplateArgumentList &TemplateArgs);
13812
13813 /// Find the instantiation of the given declaration within the
13814 /// current instantiation.
13815 ///
13816 /// This routine is intended to be used when \p D is a declaration
13817 /// referenced from within a template, that needs to mapped into the
13818 /// corresponding declaration within an instantiation. For example,
13819 /// given:
13820 ///
13821 /// \code
13822 /// template<typename T>
13823 /// struct X {
13824 /// enum Kind {
13825 /// KnownValue = sizeof(T)
13826 /// };
13827 ///
13828 /// bool getKind() const { return KnownValue; }
13829 /// };
13830 ///
13831 /// template struct X<int>;
13832 /// \endcode
13833 ///
13834 /// In the instantiation of X<int>::getKind(), we need to map the \p
13835 /// EnumConstantDecl for \p KnownValue (which refers to
13836 /// X<T>::<Kind>::KnownValue) to its instantiation
13837 /// (X<int>::<Kind>::KnownValue).
13838 /// \p FindInstantiatedDecl performs this mapping from within the
13839 /// instantiation of X<int>.
13840 NamedDecl *
13842 const MultiLevelTemplateArgumentList &TemplateArgs,
13843 bool FindingInstantiatedContext = false);
13844
13845 /// Finds the instantiation of the given declaration context
13846 /// within the current instantiation.
13847 ///
13848 /// \returns NULL if there was an error
13849 DeclContext *
13851 const MultiLevelTemplateArgumentList &TemplateArgs);
13852
13853 Decl *SubstDecl(Decl *D, DeclContext *Owner,
13854 const MultiLevelTemplateArgumentList &TemplateArgs);
13855
13856 /// Substitute the name and return type of a defaulted 'operator<=>' to form
13857 /// an implicit 'operator=='.
13859 FunctionDecl *Spaceship);
13860
13861 /// Performs template instantiation for all implicit template
13862 /// instantiations we have seen until this point.
13863 void PerformPendingInstantiations(bool LocalOnly = false);
13864
13867 const MultiLevelTemplateArgumentList &TemplateArgs,
13868 bool EvaluateConstraints = true);
13869
13871 const DeclContext *Pattern,
13872 const MultiLevelTemplateArgumentList &TemplateArgs);
13873
13874private:
13875 /// Introduce the instantiated local variables into the local
13876 /// instantiation scope.
13877 void addInstantiatedLocalVarsToScope(FunctionDecl *Function,
13878 const FunctionDecl *PatternDecl,
13880 /// Introduce the instantiated function parameters into the local
13881 /// instantiation scope, and set the parameter names to those used
13882 /// in the template.
13883 bool addInstantiatedParametersToScope(
13884 FunctionDecl *Function, const FunctionDecl *PatternDecl,
13886 const MultiLevelTemplateArgumentList &TemplateArgs);
13887
13888 /// Introduce the instantiated captures of the lambda into the local
13889 /// instantiation scope.
13890 bool addInstantiatedCapturesToScope(
13891 FunctionDecl *Function, const FunctionDecl *PatternDecl,
13893 const MultiLevelTemplateArgumentList &TemplateArgs);
13894
13895 int ParsingClassDepth = 0;
13896
13897 class SavePendingParsedClassStateRAII {
13898 public:
13899 SavePendingParsedClassStateRAII(Sema &S) : S(S) { swapSavedState(); }
13900
13901 ~SavePendingParsedClassStateRAII() {
13902 assert(S.DelayedOverridingExceptionSpecChecks.empty() &&
13903 "there shouldn't be any pending delayed exception spec checks");
13904 assert(S.DelayedEquivalentExceptionSpecChecks.empty() &&
13905 "there shouldn't be any pending delayed exception spec checks");
13906 swapSavedState();
13907 }
13908
13909 private:
13910 Sema &S;
13911 decltype(DelayedOverridingExceptionSpecChecks)
13912 SavedOverridingExceptionSpecChecks;
13913 decltype(DelayedEquivalentExceptionSpecChecks)
13914 SavedEquivalentExceptionSpecChecks;
13915
13916 void swapSavedState() {
13917 SavedOverridingExceptionSpecChecks.swap(
13918 S.DelayedOverridingExceptionSpecChecks);
13919 SavedEquivalentExceptionSpecChecks.swap(
13920 S.DelayedEquivalentExceptionSpecChecks);
13921 }
13922 };
13923
13924 ///@}
13925
13926 //
13927 //
13928 // -------------------------------------------------------------------------
13929 //
13930 //
13931
13932 /// \name C++ Variadic Templates
13933 /// Implementations are in SemaTemplateVariadic.cpp
13934 ///@{
13935
13936public:
13937 /// Determine whether an unexpanded parameter pack might be permitted in this
13938 /// location. Useful for error recovery.
13940
13941 /// The context in which an unexpanded parameter pack is
13942 /// being diagnosed.
13943 ///
13944 /// Note that the values of this enumeration line up with the first
13945 /// argument to the \c err_unexpanded_parameter_pack diagnostic.
13947 /// An arbitrary expression.
13949
13950 /// The base type of a class type.
13952
13953 /// The type of an arbitrary declaration.
13955
13956 /// The type of a data member.
13958
13959 /// The size of a bit-field.
13961
13962 /// The expression in a static assertion.
13964
13965 /// The fixed underlying type of an enumeration.
13967
13968 /// The enumerator value.
13970
13971 /// A using declaration.
13973
13974 /// A friend declaration.
13976
13977 /// A declaration qualifier.
13979
13980 /// An initializer.
13982
13983 /// A default argument.
13985
13986 /// The type of a non-type template parameter.
13988
13989 /// The type of an exception.
13991
13992 /// Explicit specialization.
13994
13995 /// Partial specialization.
13997
13998 /// Microsoft __if_exists.
14000
14001 /// Microsoft __if_not_exists.
14003
14004 /// Lambda expression.
14006
14007 /// Block expression.
14009
14010 /// A type constraint.
14012
14013 // A requirement in a requires-expression.
14015
14016 // A requires-clause.
14018 };
14019
14020 /// Diagnose unexpanded parameter packs.
14021 ///
14022 /// \param Loc The location at which we should emit the diagnostic.
14023 ///
14024 /// \param UPPC The context in which we are diagnosing unexpanded
14025 /// parameter packs.
14026 ///
14027 /// \param Unexpanded the set of unexpanded parameter packs.
14028 ///
14029 /// \returns true if an error occurred, false otherwise.
14033
14034 /// If the given type contains an unexpanded parameter pack,
14035 /// diagnose the error.
14036 ///
14037 /// \param Loc The source location where a diagnostc should be emitted.
14038 ///
14039 /// \param T The type that is being checked for unexpanded parameter
14040 /// packs.
14041 ///
14042 /// \returns true if an error occurred, false otherwise.
14045
14046 /// If the given expression contains an unexpanded parameter
14047 /// pack, diagnose the error.
14048 ///
14049 /// \param E The expression that is being checked for unexpanded
14050 /// parameter packs.
14051 ///
14052 /// \returns true if an error occurred, false otherwise.
14055
14056 /// If the given requirees-expression contains an unexpanded reference to one
14057 /// of its own parameter packs, diagnose the error.
14058 ///
14059 /// \param RE The requiress-expression that is being checked for unexpanded
14060 /// parameter packs.
14061 ///
14062 /// \returns true if an error occurred, false otherwise.
14064
14065 /// If the given nested-name-specifier contains an unexpanded
14066 /// parameter pack, diagnose the error.
14067 ///
14068 /// \param SS The nested-name-specifier that is being checked for
14069 /// unexpanded parameter packs.
14070 ///
14071 /// \returns true if an error occurred, false otherwise.
14074
14075 /// If the given name contains an unexpanded parameter pack,
14076 /// diagnose the error.
14077 ///
14078 /// \param NameInfo The name (with source location information) that
14079 /// is being checked for unexpanded parameter packs.
14080 ///
14081 /// \returns true if an error occurred, false otherwise.
14084
14085 /// If the given template name contains an unexpanded parameter pack,
14086 /// diagnose the error.
14087 ///
14088 /// \param Loc The location of the template name.
14089 ///
14090 /// \param Template The template name that is being checked for unexpanded
14091 /// parameter packs.
14092 ///
14093 /// \returns true if an error occurred, false otherwise.
14095 TemplateName Template,
14097
14098 /// If the given template argument contains an unexpanded parameter
14099 /// pack, diagnose the error.
14100 ///
14101 /// \param Arg The template argument that is being checked for unexpanded
14102 /// parameter packs.
14103 ///
14104 /// \returns true if an error occurred, false otherwise.
14107
14108 /// Collect the set of unexpanded parameter packs within the given
14109 /// template argument.
14110 ///
14111 /// \param Arg The template argument that will be traversed to find
14112 /// unexpanded parameter packs.
14114 TemplateArgument Arg,
14116
14117 /// Collect the set of unexpanded parameter packs within the given
14118 /// template argument.
14119 ///
14120 /// \param Arg The template argument that will be traversed to find
14121 /// unexpanded parameter packs.
14125
14126 /// Collect the set of unexpanded parameter packs within the given
14127 /// type.
14128 ///
14129 /// \param T The type that will be traversed to find
14130 /// unexpanded parameter packs.
14133
14134 /// Collect the set of unexpanded parameter packs within the given
14135 /// type.
14136 ///
14137 /// \param TL The type that will be traversed to find
14138 /// unexpanded parameter packs.
14141
14142 /// Collect the set of unexpanded parameter packs within the given
14143 /// nested-name-specifier.
14144 ///
14145 /// \param NNS The nested-name-specifier that will be traversed to find
14146 /// unexpanded parameter packs.
14150
14151 /// Collect the set of unexpanded parameter packs within the given
14152 /// name.
14153 ///
14154 /// \param NameInfo The name that will be traversed to find
14155 /// unexpanded parameter packs.
14157 const DeclarationNameInfo &NameInfo,
14159
14160 /// Collect the set of unexpanded parameter packs within the given
14161 /// expression.
14164
14165 /// Invoked when parsing a template argument followed by an
14166 /// ellipsis, which creates a pack expansion.
14167 ///
14168 /// \param Arg The template argument preceding the ellipsis, which
14169 /// may already be invalid.
14170 ///
14171 /// \param EllipsisLoc The location of the ellipsis.
14173 SourceLocation EllipsisLoc);
14174
14175 /// Invoked when parsing a type followed by an ellipsis, which
14176 /// creates a pack expansion.
14177 ///
14178 /// \param Type The type preceding the ellipsis, which will become
14179 /// the pattern of the pack expansion.
14180 ///
14181 /// \param EllipsisLoc The location of the ellipsis.
14183
14184 /// Construct a pack expansion type from the pattern of the pack
14185 /// expansion.
14187 SourceLocation EllipsisLoc,
14188 std::optional<unsigned> NumExpansions);
14189
14190 /// Construct a pack expansion type from the pattern of the pack
14191 /// expansion.
14192 QualType CheckPackExpansion(QualType Pattern, SourceRange PatternRange,
14193 SourceLocation EllipsisLoc,
14194 std::optional<unsigned> NumExpansions);
14195
14196 /// Invoked when parsing an expression followed by an ellipsis, which
14197 /// creates a pack expansion.
14198 ///
14199 /// \param Pattern The expression preceding the ellipsis, which will become
14200 /// the pattern of the pack expansion.
14201 ///
14202 /// \param EllipsisLoc The location of the ellipsis.
14203 ExprResult ActOnPackExpansion(Expr *Pattern, SourceLocation EllipsisLoc);
14204
14205 /// Invoked when parsing an expression followed by an ellipsis, which
14206 /// creates a pack expansion.
14207 ///
14208 /// \param Pattern The expression preceding the ellipsis, which will become
14209 /// the pattern of the pack expansion.
14210 ///
14211 /// \param EllipsisLoc The location of the ellipsis.
14212 ExprResult CheckPackExpansion(Expr *Pattern, SourceLocation EllipsisLoc,
14213 std::optional<unsigned> NumExpansions);
14214
14215 /// Determine whether we could expand a pack expansion with the
14216 /// given set of parameter packs into separate arguments by repeatedly
14217 /// transforming the pattern.
14218 ///
14219 /// \param EllipsisLoc The location of the ellipsis that identifies the
14220 /// pack expansion.
14221 ///
14222 /// \param PatternRange The source range that covers the entire pattern of
14223 /// the pack expansion.
14224 ///
14225 /// \param Unexpanded The set of unexpanded parameter packs within the
14226 /// pattern.
14227 ///
14228 /// \param ShouldExpand Will be set to \c true if the transformer should
14229 /// expand the corresponding pack expansions into separate arguments. When
14230 /// set, \c NumExpansions must also be set.
14231 ///
14232 /// \param RetainExpansion Whether the caller should add an unexpanded
14233 /// pack expansion after all of the expanded arguments. This is used
14234 /// when extending explicitly-specified template argument packs per
14235 /// C++0x [temp.arg.explicit]p9.
14236 ///
14237 /// \param NumExpansions The number of separate arguments that will be in
14238 /// the expanded form of the corresponding pack expansion. This is both an
14239 /// input and an output parameter, which can be set by the caller if the
14240 /// number of expansions is known a priori (e.g., due to a prior substitution)
14241 /// and will be set by the callee when the number of expansions is known.
14242 /// The callee must set this value when \c ShouldExpand is \c true; it may
14243 /// set this value in other cases.
14244 ///
14245 /// \returns true if an error occurred (e.g., because the parameter packs
14246 /// are to be instantiated with arguments of different lengths), false
14247 /// otherwise. If false, \c ShouldExpand (and possibly \c NumExpansions)
14248 /// must be set.
14250 SourceLocation EllipsisLoc, SourceRange PatternRange,
14252 const MultiLevelTemplateArgumentList &TemplateArgs, bool &ShouldExpand,
14253 bool &RetainExpansion, std::optional<unsigned> &NumExpansions);
14254
14255 /// Determine the number of arguments in the given pack expansion
14256 /// type.
14257 ///
14258 /// This routine assumes that the number of arguments in the expansion is
14259 /// consistent across all of the unexpanded parameter packs in its pattern.
14260 ///
14261 /// Returns an empty Optional if the type can't be expanded.
14262 std::optional<unsigned> getNumArgumentsInExpansion(
14263 QualType T, const MultiLevelTemplateArgumentList &TemplateArgs);
14264
14265 std::optional<unsigned> getNumArgumentsInExpansionFromUnexpanded(
14267 const MultiLevelTemplateArgumentList &TemplateArgs);
14268
14269 /// Determine whether the given declarator contains any unexpanded
14270 /// parameter packs.
14271 ///
14272 /// This routine is used by the parser to disambiguate function declarators
14273 /// with an ellipsis prior to the ')', e.g.,
14274 ///
14275 /// \code
14276 /// void f(T...);
14277 /// \endcode
14278 ///
14279 /// To determine whether we have an (unnamed) function parameter pack or
14280 /// a variadic function.
14281 ///
14282 /// \returns true if the declarator contains any unexpanded parameter packs,
14283 /// false otherwise.
14285
14286 /// Returns the pattern of the pack expansion for a template argument.
14287 ///
14288 /// \param OrigLoc The template argument to expand.
14289 ///
14290 /// \param Ellipsis Will be set to the location of the ellipsis.
14291 ///
14292 /// \param NumExpansions Will be set to the number of expansions that will
14293 /// be generated from this pack expansion, if known a priori.
14295 TemplateArgumentLoc OrigLoc, SourceLocation &Ellipsis,
14296 std::optional<unsigned> &NumExpansions) const;
14297
14298 /// Given a template argument that contains an unexpanded parameter pack, but
14299 /// which has already been substituted, attempt to determine the number of
14300 /// elements that will be produced once this argument is fully-expanded.
14301 ///
14302 /// This is intended for use when transforming 'sizeof...(Arg)' in order to
14303 /// avoid actually expanding the pack where possible.
14304 std::optional<unsigned> getFullyPackExpandedSize(TemplateArgument Arg);
14305
14306 /// Called when an expression computing the size of a parameter pack
14307 /// is parsed.
14308 ///
14309 /// \code
14310 /// template<typename ...Types> struct count {
14311 /// static const unsigned value = sizeof...(Types);
14312 /// };
14313 /// \endcode
14314 ///
14315 //
14316 /// \param OpLoc The location of the "sizeof" keyword.
14317 /// \param Name The name of the parameter pack whose size will be determined.
14318 /// \param NameLoc The source location of the name of the parameter pack.
14319 /// \param RParenLoc The location of the closing parentheses.
14321 IdentifierInfo &Name,
14322 SourceLocation NameLoc,
14323 SourceLocation RParenLoc);
14324
14325 ExprResult ActOnPackIndexingExpr(Scope *S, Expr *PackExpression,
14326 SourceLocation EllipsisLoc,
14327 SourceLocation LSquareLoc, Expr *IndexExpr,
14328 SourceLocation RSquareLoc);
14329
14330 ExprResult BuildPackIndexingExpr(Expr *PackExpression,
14331 SourceLocation EllipsisLoc, Expr *IndexExpr,
14332 SourceLocation RSquareLoc,
14333 ArrayRef<Expr *> ExpandedExprs = {},
14334 bool FullySubstituted = false);
14335
14336 /// Handle a C++1z fold-expression: ( expr op ... op expr ).
14337 ExprResult ActOnCXXFoldExpr(Scope *S, SourceLocation LParenLoc, Expr *LHS,
14338 tok::TokenKind Operator,
14339 SourceLocation EllipsisLoc, Expr *RHS,
14340 SourceLocation RParenLoc);
14341 ExprResult BuildCXXFoldExpr(UnresolvedLookupExpr *Callee,
14342 SourceLocation LParenLoc, Expr *LHS,
14343 BinaryOperatorKind Operator,
14344 SourceLocation EllipsisLoc, Expr *RHS,
14345 SourceLocation RParenLoc,
14346 std::optional<unsigned> NumExpansions);
14347 ExprResult BuildEmptyCXXFoldExpr(SourceLocation EllipsisLoc,
14348 BinaryOperatorKind Operator);
14349
14350 ///@}
14351
14352 //
14353 //
14354 // -------------------------------------------------------------------------
14355 //
14356 //
14357
14358 /// \name Constraints and Concepts
14359 /// Implementations are in SemaConcept.cpp
14360 ///@{
14361
14362public:
14364 const llvm::FoldingSetNodeID &ID) {
14365 const NamedDecl *Can = cast<NamedDecl>(D->getCanonicalDecl());
14366 SatisfactionStack.emplace_back(Can, ID);
14367 }
14368
14369 void PopSatisfactionStackEntry() { SatisfactionStack.pop_back(); }
14370
14372 const llvm::FoldingSetNodeID &ID) const {
14373 const NamedDecl *Can = cast<NamedDecl>(D->getCanonicalDecl());
14374 return llvm::find(SatisfactionStack, SatisfactionStackEntryTy{Can, ID}) !=
14375 SatisfactionStack.end();
14376 }
14377
14379 std::pair<const NamedDecl *, llvm::FoldingSetNodeID>;
14380
14381 // Resets the current SatisfactionStack for cases where we are instantiating
14382 // constraints as a 'side effect' of normal instantiation in a way that is not
14383 // indicative of recursive definition.
14386 Sema &SemaRef;
14387
14388 public:
14390 SemaRef.SwapSatisfactionStack(BackupSatisfactionStack);
14391 }
14392
14394 SemaRef.SwapSatisfactionStack(BackupSatisfactionStack);
14395 }
14396 };
14397
14400 SatisfactionStack.swap(NewSS);
14401 }
14402
14403 /// Check whether the given expression is a valid constraint expression.
14404 /// A diagnostic is emitted if it is not, false is returned, and
14405 /// PossibleNonPrimary will be set to true if the failure might be due to a
14406 /// non-primary expression being used as an atomic constraint.
14407 bool CheckConstraintExpression(const Expr *CE, Token NextToken = Token(),
14408 bool *PossibleNonPrimary = nullptr,
14409 bool IsTrailingRequiresClause = false);
14410
14411 /// \brief Check whether the given list of constraint expressions are
14412 /// satisfied (as if in a 'conjunction') given template arguments.
14413 /// \param Template the template-like entity that triggered the constraints
14414 /// check (either a concept or a constrained entity).
14415 /// \param ConstraintExprs a list of constraint expressions, treated as if
14416 /// they were 'AND'ed together.
14417 /// \param TemplateArgLists the list of template arguments to substitute into
14418 /// the constraint expression.
14419 /// \param TemplateIDRange The source range of the template id that
14420 /// caused the constraints check.
14421 /// \param Satisfaction if true is returned, will contain details of the
14422 /// satisfaction, with enough information to diagnose an unsatisfied
14423 /// expression.
14424 /// \returns true if an error occurred and satisfaction could not be checked,
14425 /// false otherwise.
14427 const NamedDecl *Template, ArrayRef<const Expr *> ConstraintExprs,
14428 const MultiLevelTemplateArgumentList &TemplateArgLists,
14429 SourceRange TemplateIDRange, ConstraintSatisfaction &Satisfaction) {
14431 return CheckConstraintSatisfaction(Template, ConstraintExprs, Converted,
14432 TemplateArgLists, TemplateIDRange,
14433 Satisfaction);
14434 }
14435
14436 /// \brief Check whether the given list of constraint expressions are
14437 /// satisfied (as if in a 'conjunction') given template arguments.
14438 /// Additionally, takes an empty list of Expressions which is populated with
14439 /// the instantiated versions of the ConstraintExprs.
14440 /// \param Template the template-like entity that triggered the constraints
14441 /// check (either a concept or a constrained entity).
14442 /// \param ConstraintExprs a list of constraint expressions, treated as if
14443 /// they were 'AND'ed together.
14444 /// \param ConvertedConstraints a out parameter that will get populated with
14445 /// the instantiated version of the ConstraintExprs if we successfully checked
14446 /// satisfaction.
14447 /// \param TemplateArgList the multi-level list of template arguments to
14448 /// substitute into the constraint expression. This should be relative to the
14449 /// top-level (hence multi-level), since we need to instantiate fully at the
14450 /// time of checking.
14451 /// \param TemplateIDRange The source range of the template id that
14452 /// caused the constraints check.
14453 /// \param Satisfaction if true is returned, will contain details of the
14454 /// satisfaction, with enough information to diagnose an unsatisfied
14455 /// expression.
14456 /// \returns true if an error occurred and satisfaction could not be checked,
14457 /// false otherwise.
14459 const NamedDecl *Template, ArrayRef<const Expr *> ConstraintExprs,
14460 llvm::SmallVectorImpl<Expr *> &ConvertedConstraints,
14461 const MultiLevelTemplateArgumentList &TemplateArgList,
14462 SourceRange TemplateIDRange, ConstraintSatisfaction &Satisfaction);
14463
14464 /// \brief Check whether the given non-dependent constraint expression is
14465 /// satisfied. Returns false and updates Satisfaction with the satisfaction
14466 /// verdict if successful, emits a diagnostic and returns true if an error
14467 /// occurred and satisfaction could not be determined.
14468 ///
14469 /// \returns true if an error occurred, false otherwise.
14470 bool CheckConstraintSatisfaction(const Expr *ConstraintExpr,
14471 ConstraintSatisfaction &Satisfaction);
14472
14473 /// Check whether the given function decl's trailing requires clause is
14474 /// satisfied, if any. Returns false and updates Satisfaction with the
14475 /// satisfaction verdict if successful, emits a diagnostic and returns true if
14476 /// an error occurred and satisfaction could not be determined.
14477 ///
14478 /// \returns true if an error occurred, false otherwise.
14480 ConstraintSatisfaction &Satisfaction,
14481 SourceLocation UsageLoc = SourceLocation(),
14482 bool ForOverloadResolution = false);
14483
14484 // Calculates whether two constraint expressions are equal irrespective of a
14485 // difference in 'depth'. This takes a pair of optional 'NamedDecl's 'Old' and
14486 // 'New', which are the "source" of the constraint, since this is necessary
14487 // for figuring out the relative 'depth' of the constraint. The depth of the
14488 // 'primary template' and the 'instantiated from' templates aren't necessarily
14489 // the same, such as a case when one is a 'friend' defined in a class.
14491 const Expr *OldConstr,
14492 const TemplateCompareNewDeclInfo &New,
14493 const Expr *NewConstr);
14494
14495 // Calculates whether the friend function depends on an enclosing template for
14496 // the purposes of [temp.friend] p9.
14498
14499 /// \brief Ensure that the given template arguments satisfy the constraints
14500 /// associated with the given template, emitting a diagnostic if they do not.
14501 ///
14502 /// \param Template The template to which the template arguments are being
14503 /// provided.
14504 ///
14505 /// \param TemplateArgs The converted, canonicalized template arguments.
14506 ///
14507 /// \param TemplateIDRange The source range of the template id that
14508 /// caused the constraints check.
14509 ///
14510 /// \returns true if the constrains are not satisfied or could not be checked
14511 /// for satisfaction, false if the constraints are satisfied.
14513 TemplateDecl *Template,
14514 const MultiLevelTemplateArgumentList &TemplateArgs,
14515 SourceRange TemplateIDRange);
14516
14518 SourceLocation PointOfInstantiation, FunctionDecl *Decl,
14519 ArrayRef<TemplateArgument> TemplateArgs,
14520 ConstraintSatisfaction &Satisfaction);
14521
14522 /// \brief Emit diagnostics explaining why a constraint expression was deemed
14523 /// unsatisfied.
14524 /// \param First whether this is the first time an unsatisfied constraint is
14525 /// diagnosed for this error.
14527 bool First = true);
14528
14529 /// \brief Emit diagnostics explaining why a constraint expression was deemed
14530 /// unsatisfied.
14531 void
14533 bool First = true);
14534
14536 NamedDecl *ConstrainedDecl, ArrayRef<const Expr *> AssociatedConstraints);
14537
14538 /// \brief Check whether the given declaration's associated constraints are
14539 /// at least as constrained than another declaration's according to the
14540 /// partial ordering of constraints.
14541 ///
14542 /// \param Result If no error occurred, receives the result of true if D1 is
14543 /// at least constrained than D2, and false otherwise.
14544 ///
14545 /// \returns true if an error occurred, false otherwise.
14548 bool &Result);
14549
14550 /// If D1 was not at least as constrained as D2, but would've been if a pair
14551 /// of atomic constraints involved had been declared in a concept and not
14552 /// repeated in two separate places in code.
14553 /// \returns true if such a diagnostic was emitted, false otherwise.
14557
14558private:
14559 /// Caches pairs of template-like decls whose associated constraints were
14560 /// checked for subsumption and whether or not the first's constraints did in
14561 /// fact subsume the second's.
14562 llvm::DenseMap<std::pair<NamedDecl *, NamedDecl *>, bool> SubsumptionCache;
14563 /// Caches the normalized associated constraints of declarations (concepts or
14564 /// constrained declarations). If an error occurred while normalizing the
14565 /// associated constraints of the template or concept, nullptr will be cached
14566 /// here.
14567 llvm::DenseMap<NamedDecl *, NormalizedConstraint *> NormalizationCache;
14568
14569 llvm::ContextualFoldingSet<ConstraintSatisfaction, const ASTContext &>
14570 SatisfactionCache;
14571
14572 // The current stack of constraint satisfactions, so we can exit-early.
14574
14575 /// Used by SetupConstraintCheckingTemplateArgumentsAndScope to set up the
14576 /// LocalInstantiationScope of the current non-lambda function. For lambdas,
14577 /// use LambdaScopeForCallOperatorInstantiationRAII.
14578 bool
14579 SetupConstraintScope(FunctionDecl *FD,
14580 std::optional<ArrayRef<TemplateArgument>> TemplateArgs,
14581 const MultiLevelTemplateArgumentList &MLTAL,
14583
14584 /// Used during constraint checking, sets up the constraint template argument
14585 /// lists, and calls SetupConstraintScope to set up the
14586 /// LocalInstantiationScope to have the proper set of ParVarDecls configured.
14587 std::optional<MultiLevelTemplateArgumentList>
14588 SetupConstraintCheckingTemplateArgumentsAndScope(
14589 FunctionDecl *FD, std::optional<ArrayRef<TemplateArgument>> TemplateArgs,
14591
14592 ///@}
14593
14594 //
14595 //
14596 // -------------------------------------------------------------------------
14597 //
14598 //
14599
14600 /// \name Types
14601 /// Implementations are in SemaType.cpp
14602 ///@{
14603
14604public:
14605 /// A mapping that describes the nullability we've seen in each header file.
14607
14608 static int getPrintable(int I) { return I; }
14609 static unsigned getPrintable(unsigned I) { return I; }
14610 static bool getPrintable(bool B) { return B; }
14611 static const char *getPrintable(const char *S) { return S; }
14612 static StringRef getPrintable(StringRef S) { return S; }
14613 static const std::string &getPrintable(const std::string &S) { return S; }
14614 static const IdentifierInfo *getPrintable(const IdentifierInfo *II) {
14615 return II;
14616 }
14618 static QualType getPrintable(QualType T) { return T; }
14619 static SourceRange getPrintable(SourceRange R) { return R; }
14621 static SourceRange getPrintable(const Expr *E) { return E->getSourceRange(); }
14623
14624 enum class CompleteTypeKind {
14625 /// Apply the normal rules for complete types. In particular,
14626 /// treat all sizeless types as incomplete.
14627 Normal,
14628
14629 /// Relax the normal rules for complete types so that they include
14630 /// sizeless built-in types.
14632
14633 // FIXME: Eventually we should flip the default to Normal and opt in
14634 // to AcceptSizeless rather than opt out of it.
14636 };
14637
14639 const DeclSpec *DS = nullptr);
14641 const DeclSpec *DS = nullptr);
14642
14643 /// Build a pointer type.
14644 ///
14645 /// \param T The type to which we'll be building a pointer.
14646 ///
14647 /// \param Loc The location of the entity whose type involves this
14648 /// pointer type or, if there is no such entity, the location of the
14649 /// type that will have pointer type.
14650 ///
14651 /// \param Entity The name of the entity that involves the pointer
14652 /// type, if known.
14653 ///
14654 /// \returns A suitable pointer type, if there are no
14655 /// errors. Otherwise, returns a NULL type.
14657 DeclarationName Entity);
14658
14659 /// Build a reference type.
14660 ///
14661 /// \param T The type to which we'll be building a reference.
14662 ///
14663 /// \param Loc The location of the entity whose type involves this
14664 /// reference type or, if there is no such entity, the location of the
14665 /// type that will have reference type.
14666 ///
14667 /// \param Entity The name of the entity that involves the reference
14668 /// type, if known.
14669 ///
14670 /// \returns A suitable reference type, if there are no
14671 /// errors. Otherwise, returns a NULL type.
14673 DeclarationName Entity);
14674
14675 /// Build an array type.
14676 ///
14677 /// \param T The type of each element in the array.
14678 ///
14679 /// \param ASM C99 array size modifier (e.g., '*', 'static').
14680 ///
14681 /// \param ArraySize Expression describing the size of the array.
14682 ///
14683 /// \param Brackets The range from the opening '[' to the closing ']'.
14684 ///
14685 /// \param Entity The name of the entity that involves the array
14686 /// type, if known.
14687 ///
14688 /// \returns A suitable array type, if there are no errors. Otherwise,
14689 /// returns a NULL type.
14691 unsigned Quals, SourceRange Brackets,
14692 DeclarationName Entity);
14694
14695 /// Build an ext-vector type.
14696 ///
14697 /// Run the required checks for the extended vector type.
14699 SourceLocation AttrLoc);
14700 QualType BuildMatrixType(QualType T, Expr *NumRows, Expr *NumColumns,
14701 SourceLocation AttrLoc);
14702
14704 Expr *CountExpr,
14705 bool CountInBytes,
14706 bool OrNull);
14707
14708 /// BuildAddressSpaceAttr - Builds a DependentAddressSpaceType if an
14709 /// expression is uninstantiated. If instantiated it will apply the
14710 /// appropriate address space to the type. This function allows dependent
14711 /// template variables to be used in conjunction with the address_space
14712 /// attribute
14713 QualType BuildAddressSpaceAttr(QualType &T, LangAS ASIdx, Expr *AddrSpace,
14714 SourceLocation AttrLoc);
14715
14716 /// Same as above, but constructs the AddressSpace index if not provided.
14718 SourceLocation AttrLoc);
14719
14721
14723
14724 /// Build a function type.
14725 ///
14726 /// This routine checks the function type according to C++ rules and
14727 /// under the assumption that the result type and parameter types have
14728 /// just been instantiated from a template. It therefore duplicates
14729 /// some of the behavior of GetTypeForDeclarator, but in a much
14730 /// simpler form that is only suitable for this narrow use case.
14731 ///
14732 /// \param T The return type of the function.
14733 ///
14734 /// \param ParamTypes The parameter types of the function. This array
14735 /// will be modified to account for adjustments to the types of the
14736 /// function parameters.
14737 ///
14738 /// \param Loc The location of the entity whose type involves this
14739 /// function type or, if there is no such entity, the location of the
14740 /// type that will have function type.
14741 ///
14742 /// \param Entity The name of the entity that involves the function
14743 /// type, if known.
14744 ///
14745 /// \param EPI Extra information about the function type. Usually this will
14746 /// be taken from an existing function with the same prototype.
14747 ///
14748 /// \returns A suitable function type, if there are no errors. The
14749 /// unqualified type will always be a FunctionProtoType.
14750 /// Otherwise, returns a NULL type.
14754
14755 /// Build a member pointer type \c T Class::*.
14756 ///
14757 /// \param T the type to which the member pointer refers.
14758 /// \param Class the class type into which the member pointer points.
14759 /// \param Loc the location where this type begins
14760 /// \param Entity the name of the entity that will have this member pointer
14761 /// type
14762 ///
14763 /// \returns a member pointer type, if successful, or a NULL type if there was
14764 /// an error.
14767
14768 /// Build a block pointer type.
14769 ///
14770 /// \param T The type to which we'll be building a block pointer.
14771 ///
14772 /// \param Loc The source location, used for diagnostics.
14773 ///
14774 /// \param Entity The name of the entity that involves the block pointer
14775 /// type, if known.
14776 ///
14777 /// \returns A suitable block pointer type, if there are no
14778 /// errors. Otherwise, returns a NULL type.
14780 DeclarationName Entity);
14781
14782 /// Build a paren type including \p T.
14785
14786 /// Build a Read-only Pipe type.
14787 ///
14788 /// \param T The type to which we'll be building a Pipe.
14789 ///
14790 /// \param Loc We do not use it for now.
14791 ///
14792 /// \returns A suitable pipe type, if there are no errors. Otherwise, returns
14793 /// a NULL type.
14795
14796 /// Build a Write-only Pipe type.
14797 ///
14798 /// \param T The type to which we'll be building a Pipe.
14799 ///
14800 /// \param Loc We do not use it for now.
14801 ///
14802 /// \returns A suitable pipe type, if there are no errors. Otherwise, returns
14803 /// a NULL type.
14805
14806 /// Build a bit-precise integer type.
14807 ///
14808 /// \param IsUnsigned Boolean representing the signedness of the type.
14809 ///
14810 /// \param BitWidth Size of this int type in bits, or an expression
14811 /// representing that.
14812 ///
14813 /// \param Loc Location of the keyword.
14814 QualType BuildBitIntType(bool IsUnsigned, Expr *BitWidth, SourceLocation Loc);
14815
14816 /// GetTypeForDeclarator - Convert the type for the specified
14817 /// declarator to Type instances.
14818 ///
14819 /// The result of this call will never be null, but the associated
14820 /// type may be a null type if there's an unrecoverable error.
14823
14824 /// Package the given type and TSI into a ParsedType.
14827 TypeSourceInfo **TInfo = nullptr);
14828
14830
14831 // Check whether the size of array element of type \p EltTy is a multiple of
14832 // its alignment and return false if it isn't.
14834
14835 void
14836 diagnoseIgnoredQualifiers(unsigned DiagID, unsigned Quals,
14837 SourceLocation FallbackLoc,
14838 SourceLocation ConstQualLoc = SourceLocation(),
14839 SourceLocation VolatileQualLoc = SourceLocation(),
14840 SourceLocation RestrictQualLoc = SourceLocation(),
14841 SourceLocation AtomicQualLoc = SourceLocation(),
14842 SourceLocation UnalignedQualLoc = SourceLocation());
14843
14844 /// Retrieve the keyword associated
14846
14847 /// Adjust the calling convention of a method to be the ABI default if it
14848 /// wasn't specified explicitly. This handles method types formed from
14849 /// function type typedefs and typename template arguments.
14850 void adjustMemberFunctionCC(QualType &T, bool HasThisPointer,
14851 bool IsCtorOrDtor, SourceLocation Loc);
14852
14853 // Check if there is an explicit attribute, but only look through parens.
14854 // The intent is to look for an attribute on the current declarator, but not
14855 // one that came from a typedef.
14857
14858 /// Check whether a nullability type specifier can be added to the given
14859 /// type through some means not written in source (e.g. API notes).
14860 ///
14861 /// \param Type The type to which the nullability specifier will be
14862 /// added. On success, this type will be updated appropriately.
14863 ///
14864 /// \param Nullability The nullability specifier to add.
14865 ///
14866 /// \param DiagLoc The location to use for diagnostics.
14867 ///
14868 /// \param AllowArrayTypes Whether to accept nullability specifiers on an
14869 /// array type (e.g., because it will decay to a pointer).
14870 ///
14871 /// \param OverrideExisting Whether to override an existing, locally-specified
14872 /// nullability specifier rather than complaining about the conflict.
14873 ///
14874 /// \returns true if nullability cannot be applied, false otherwise.
14876 NullabilityKind Nullability,
14877 SourceLocation DiagLoc,
14878 bool AllowArrayTypes,
14879 bool OverrideExisting);
14880
14881 /// Get the type of expression E, triggering instantiation to complete the
14882 /// type if necessary -- that is, if the expression refers to a templated
14883 /// static data member of incomplete array type.
14884 ///
14885 /// May still return an incomplete type if instantiation was not possible or
14886 /// if the type is incomplete for a different reason. Use
14887 /// RequireCompleteExprType instead if a diagnostic is expected for an
14888 /// incomplete expression type.
14890
14892
14893 /// Ensure that the type of the given expression is complete.
14894 ///
14895 /// This routine checks whether the expression \p E has a complete type. If
14896 /// the expression refers to an instantiable construct, that instantiation is
14897 /// performed as needed to complete its type. Furthermore
14898 /// Sema::RequireCompleteType is called for the expression's type (or in the
14899 /// case of a reference type, the referred-to type).
14900 ///
14901 /// \param E The expression whose type is required to be complete.
14902 /// \param Kind Selects which completeness rules should be applied.
14903 /// \param Diagnoser The object that will emit a diagnostic if the type is
14904 /// incomplete.
14905 ///
14906 /// \returns \c true if the type of \p E is incomplete and diagnosed, \c false
14907 /// otherwise.
14909 TypeDiagnoser &Diagnoser);
14910 bool RequireCompleteExprType(Expr *E, unsigned DiagID);
14911
14912 template <typename... Ts>
14913 bool RequireCompleteExprType(Expr *E, unsigned DiagID, const Ts &...Args) {
14914 BoundTypeDiagnoser<Ts...> Diagnoser(DiagID, Args...);
14916 }
14917
14918 /// Retrieve a version of the type 'T' that is elaborated by Keyword,
14919 /// qualified by the nested-name-specifier contained in SS, and that is
14920 /// (re)declared by OwnedTagDecl, which is nullptr if this is not a
14921 /// (re)declaration.
14923 const CXXScopeSpec &SS, QualType T,
14924 TagDecl *OwnedTagDecl = nullptr);
14925
14926 // Returns the underlying type of a decltype with the given expression.
14928
14930 /// If AsUnevaluated is false, E is treated as though it were an evaluated
14931 /// context, such as when building a type for decltype(auto).
14932 QualType BuildDecltypeType(Expr *E, bool AsUnevaluated = true);
14933
14934 QualType ActOnPackIndexingType(QualType Pattern, Expr *IndexExpr,
14936 SourceLocation EllipsisLoc);
14937 QualType BuildPackIndexingType(QualType Pattern, Expr *IndexExpr,
14938 SourceLocation Loc, SourceLocation EllipsisLoc,
14939 bool FullySubstituted = false,
14940 ArrayRef<QualType> Expansions = {});
14941
14959
14960 /// Ensure that the type T is a literal type.
14961 ///
14962 /// This routine checks whether the type @p T is a literal type. If @p T is an
14963 /// incomplete type, an attempt is made to complete it. If @p T is a literal
14964 /// type, or @p AllowIncompleteType is true and @p T is an incomplete type,
14965 /// returns false. Otherwise, this routine issues the diagnostic @p PD (giving
14966 /// it the type @p T), along with notes explaining why the type is not a
14967 /// literal type, and returns true.
14968 ///
14969 /// @param Loc The location in the source that the non-literal type
14970 /// diagnostic should refer to.
14971 ///
14972 /// @param T The type that this routine is examining for literalness.
14973 ///
14974 /// @param Diagnoser Emits a diagnostic if T is not a literal type.
14975 ///
14976 /// @returns @c true if @p T is not a literal type and a diagnostic was
14977 /// emitted, @c false otherwise.
14979 TypeDiagnoser &Diagnoser);
14980 bool RequireLiteralType(SourceLocation Loc, QualType T, unsigned DiagID);
14981
14982 template <typename... Ts>
14984 const Ts &...Args) {
14985 BoundTypeDiagnoser<Ts...> Diagnoser(DiagID, Args...);
14986 return RequireLiteralType(Loc, T, Diagnoser);
14987 }
14988
14991 return !RequireCompleteTypeImpl(Loc, T, Kind, nullptr);
14992 }
14993
14994 /// Ensure that the type T is a complete type.
14995 ///
14996 /// This routine checks whether the type @p T is complete in any
14997 /// context where a complete type is required. If @p T is a complete
14998 /// type, returns false. If @p T is a class template specialization,
14999 /// this routine then attempts to perform class template
15000 /// instantiation. If instantiation fails, or if @p T is incomplete
15001 /// and cannot be completed, issues the diagnostic @p diag (giving it
15002 /// the type @p T) and returns true.
15003 ///
15004 /// @param Loc The location in the source that the incomplete type
15005 /// diagnostic should refer to.
15006 ///
15007 /// @param T The type that this routine is examining for completeness.
15008 ///
15009 /// @param Kind Selects which completeness rules should be applied.
15010 ///
15011 /// @returns @c true if @p T is incomplete and a diagnostic was emitted,
15012 /// @c false otherwise.
15014 CompleteTypeKind Kind, TypeDiagnoser &Diagnoser);
15016 CompleteTypeKind Kind, unsigned DiagID);
15017
15019 TypeDiagnoser &Diagnoser) {
15021 }
15024 }
15025
15026 template <typename... Ts>
15028 const Ts &...Args) {
15029 BoundTypeDiagnoser<Ts...> Diagnoser(DiagID, Args...);
15030 return RequireCompleteType(Loc, T, Diagnoser);
15031 }
15032
15033 /// Determine whether a declaration is visible to name lookup.
15034 bool isVisible(const NamedDecl *D) {
15035 return D->isUnconditionallyVisible() ||
15036 isAcceptableSlow(D, AcceptableKind::Visible);
15037 }
15038
15039 /// Determine whether a declaration is reachable.
15040 bool isReachable(const NamedDecl *D) {
15041 // All visible declarations are reachable.
15042 return D->isUnconditionallyVisible() ||
15043 isAcceptableSlow(D, AcceptableKind::Reachable);
15044 }
15045
15046 /// Determine whether a declaration is acceptable (visible/reachable).
15049 }
15050
15051 /// Determine if \p D and \p Suggested have a structurally compatible
15052 /// layout as described in C11 6.2.7/1.
15053 bool hasStructuralCompatLayout(Decl *D, Decl *Suggested);
15054
15055 /// Determine if \p D has a visible definition. If not, suggest a declaration
15056 /// that should be made visible to expose the definition.
15057 bool hasVisibleDefinition(NamedDecl *D, NamedDecl **Suggested,
15058 bool OnlyNeedComplete = false);
15060 NamedDecl *Hidden;
15061 return hasVisibleDefinition(const_cast<NamedDecl *>(D), &Hidden);
15062 }
15063
15064 /// Determine if \p D has a reachable definition. If not, suggest a
15065 /// declaration that should be made reachable to expose the definition.
15066 bool hasReachableDefinition(NamedDecl *D, NamedDecl **Suggested,
15067 bool OnlyNeedComplete = false);
15069 NamedDecl *Hidden;
15070 return hasReachableDefinition(D, &Hidden);
15071 }
15072
15073 bool hasAcceptableDefinition(NamedDecl *D, NamedDecl **Suggested,
15075 bool OnlyNeedComplete = false);
15077 NamedDecl *Hidden;
15078 return hasAcceptableDefinition(D, &Hidden, Kind);
15079 }
15080
15081 /// Try to parse the conditional expression attached to an effect attribute
15082 /// (e.g. 'nonblocking'). (c.f. Sema::ActOnNoexceptSpec). Return an empty
15083 /// optional on error.
15084 std::optional<FunctionEffectMode>
15085 ActOnEffectExpression(Expr *CondExpr, StringRef AttributeName);
15086
15087private:
15088 /// The implementation of RequireCompleteType
15089 bool RequireCompleteTypeImpl(SourceLocation Loc, QualType T,
15090 CompleteTypeKind Kind, TypeDiagnoser *Diagnoser);
15091
15092 /// Nullability type specifiers.
15093 IdentifierInfo *Ident__Nonnull = nullptr;
15094 IdentifierInfo *Ident__Nullable = nullptr;
15095 IdentifierInfo *Ident__Nullable_result = nullptr;
15096 IdentifierInfo *Ident__Null_unspecified = nullptr;
15097
15098 ///@}
15099
15100 //
15101 //
15102 // -------------------------------------------------------------------------
15103 //
15104 //
15105
15106 /// \name FixIt Helpers
15107 /// Implementations are in SemaFixItUtils.cpp
15108 ///@{
15109
15110public:
15111 /// Get a string to suggest for zero-initialization of a type.
15113 SourceLocation Loc) const;
15115
15116 ///@}
15117
15118 //
15119 //
15120 // -------------------------------------------------------------------------
15121 //
15122 //
15123
15124 /// \name Function Effects
15125 /// Implementations are in SemaFunctionEffects.cpp
15126 ///@{
15127public:
15129 enum class Kind { Added, Removed, ConditionMismatch };
15130
15133 std::optional<FunctionEffectWithCondition>
15134 Old; // Invalid when 'Kind' is 'Added'.
15135 std::optional<FunctionEffectWithCondition>
15136 New; // Invalid when 'Kind' is 'Removed'.
15137
15138 StringRef effectName() const {
15139 if (Old)
15140 return Old.value().Effect.name();
15141 return New.value().Effect.name();
15142 }
15143
15144 /// Describes the result of effects differing between a base class's virtual
15145 /// method and an overriding method in a subclass.
15146 enum class OverrideResult {
15147 NoAction,
15148 Warn,
15149 Merge // Merge missing effect from base to derived.
15150 };
15151
15152 /// Return true if adding or removing the effect as part of a type
15153 /// conversion should generate a diagnostic.
15154 bool shouldDiagnoseConversion(QualType SrcType,
15155 const FunctionEffectsRef &SrcFX,
15156 QualType DstType,
15157 const FunctionEffectsRef &DstFX) const;
15158
15159 /// Return true if adding or removing the effect in a redeclaration should
15160 /// generate a diagnostic.
15161 bool shouldDiagnoseRedeclaration(const FunctionDecl &OldFunction,
15162 const FunctionEffectsRef &OldFX,
15163 const FunctionDecl &NewFunction,
15164 const FunctionEffectsRef &NewFX) const;
15165
15166 /// Return true if adding or removing the effect in a C++ virtual method
15167 /// override should generate a diagnostic.
15168 OverrideResult shouldDiagnoseMethodOverride(
15169 const CXXMethodDecl &OldMethod, const FunctionEffectsRef &OldFX,
15170 const CXXMethodDecl &NewMethod, const FunctionEffectsRef &NewFX) const;
15171 };
15172
15173 struct FunctionEffectDiffVector : public SmallVector<FunctionEffectDiff> {
15174 /// Caller should short-circuit by checking for equality first.
15176 const FunctionEffectsRef &New);
15177 };
15178
15179 /// All functions/lambdas/blocks which have bodies and which have a non-empty
15180 /// FunctionEffectsRef to be verified.
15182
15183 /// The union of all effects present on DeclsWithEffectsToVerify. Conditions
15184 /// are all null.
15186
15187public:
15188 /// Warn and return true if adding a function effect to a set would create a
15189 /// conflict.
15192 SourceLocation NewAttrLoc);
15193
15194 // Report a failure to merge function effects between declarations due to a
15195 // conflict.
15196 void
15198 SourceLocation NewLoc,
15199 SourceLocation OldLoc);
15200
15201 /// Inline checks from the start of maybeAddDeclWithEffects, to
15202 /// minimize performance impact on code not using effects.
15203 template <class FuncOrBlockDecl>
15204 void maybeAddDeclWithEffects(FuncOrBlockDecl *D) {
15206 if (FunctionEffectsRef FX = D->getFunctionEffects(); !FX.empty())
15208 }
15209
15210 /// Potentially add a FunctionDecl or BlockDecl to DeclsWithEffectsToVerify.
15211 void maybeAddDeclWithEffects(const Decl *D, const FunctionEffectsRef &FX);
15212
15213 /// Unconditionally add a Decl to DeclsWithEfffectsToVerify.
15214 void addDeclWithEffects(const Decl *D, const FunctionEffectsRef &FX);
15215
15217
15218 ///@}
15219};
15220
15221DeductionFailureInfo
15223 sema::TemplateDeductionInfo &Info);
15224
15225/// Contains a late templated function.
15226/// Will be parsed at the end of the translation unit, used by Sema & Parser.
15229 /// The template function declaration to be late parsed.
15231 /// Floating-point options in the point of definition.
15233};
15234
15235template <>
15237 PragmaMsStackAction Action,
15238 llvm::StringRef StackSlotLabel,
15240} // end namespace clang
15241
15242#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:1122
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:4503
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:4779
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:739
Information about one declarator, including the parsed type information and the identifier.
Definition: DeclSpec.h:1904
A decomposition declaration.
Definition: DeclCXX.h:4233
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:1224
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:786
An instance of this object exists for each enum constant that is defined.
Definition: Decl.h:3298
Represents an enum.
Definition: Decl.h:3868
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:3040
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:260
FileNullability & operator[](FileID file)
Definition: Sema.h:271
FileNullability Nullability
Definition: Sema.h:267
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:3342
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:4389
An instance of this class represents the declaration of a property member.
Definition: DeclCXX.h:4335
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:292
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:294
void enterVariableInit(SourceLocation Tok, Decl *D)
QualType get(SourceLocation Tok) const
Get the expected type associated with this location, if any.
Definition: Sema.h:329
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:4169
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:1463
bool operator==(const AlignPackInfo &Info) const
Definition: Sema.h:1523
static AlignPackInfo getFromRawEncoding(unsigned Encoding)
Definition: Sema.h:1495
unsigned getPackNumber() const
Definition: Sema.h:1513
bool IsXLStack() const
Definition: Sema.h:1521
bool IsPackSet() const
Definition: Sema.h:1515
AlignPackInfo(AlignPackInfo::Mode M, bool IsXL)
Definition: Sema.h:1469
bool IsAlignAttr() const
Definition: Sema.h:1509
bool IsPackAttr() const
Definition: Sema.h:1507
bool operator!=(const AlignPackInfo &Info) const
Definition: Sema.h:1529
AlignPackInfo(bool IsXL)
Definition: Sema.h:1473
static uint32_t getRawEncoding(const AlignPackInfo &Info)
Definition: Sema.h:1480
Mode getAlignMode() const
Definition: Sema.h:1511
RAII object used to change the argument pack substitution index within a Sema object.
Definition: Sema.h:13243
ArgumentPackSubstitutionIndexRAII(Sema &Self, int NewSubstitutionIndex)
Definition: Sema.h:13248
BoundTypeDiagnoser(unsigned DiagID, const Ts &...Args)
Definition: Sema.h:7893
void diagnose(Sema &S, SourceLocation Loc, QualType T) override
Definition: Sema.h:7898
void emit(const SemaDiagnosticBuilder &DB, std::index_sequence< Is... >) const
Definition: Sema.h:7885
std::tuple< const Ts &... > Args
Definition: Sema.h:7882
RAII object used to temporarily allow the C++ 'this' expression to be used, with the given qualifiers...
Definition: Sema.h:8062
A RAII object to enter scope of a compound statement.
Definition: Sema.h:918
CompoundScopeRAII(Sema &S, bool IsStmtExpr=false)
Definition: Sema.h:920
std::pair< VarDecl *, Expr * > get() const
Definition: Sema.h:7336
bool isInvalid() const
Definition: Sema.h:7335
std::optional< bool > getKnownValue() const
Definition: Sema.h:7340
A RAII object to temporarily push a declaration context.
Definition: Sema.h:3013
ContextRAII(Sema &S, DeclContext *ContextToPush, bool NewThisContext=true)
Definition: Sema.h:3023
Abstract base class used to perform a contextual implicit conversion from an expression to any type p...
Definition: Sema.h:10046
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:10051
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:5894
DefaultedComparisonKind asComparison() const
Definition: Sema.h:5926
DefaultedFunctionKind(CXXSpecialMemberKind CSM)
Definition: Sema.h:5903
unsigned getDiagnosticIndex() const
Get the index of this function kind for use in diagnostics.
Definition: Sema.h:5931
DefaultedFunctionKind(DefaultedComparisonKind Comp)
Definition: Sema.h:5906
CXXSpecialMemberKind asSpecialMember() const
Definition: Sema.h:5923
RAII class to control scope of DeferDiags.
Definition: Sema.h:9772
DeferDiagsRAII(Sema &S, bool DeferDiags)
Definition: Sema.h:9777
A class which encapsulates the logic for delaying diagnostics during parsing and other processing.
Definition: Sema.h:987
DelayedDiagnosticsState push(sema::DelayedDiagnosticPool &pool)
Enter a new scope.
Definition: Sema.h:1006
void popUndelayed(DelayedDiagnosticsState state)
Undo a previous pushUndelayed().
Definition: Sema.h:1030
bool shouldDelayDiagnostics()
Determines whether diagnostics should be delayed.
Definition: Sema.h:999
sema::DelayedDiagnosticPool * getCurrentPool() const
Returns the current delayed-diagnostics pool.
Definition: Sema.h:1002
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:1016
DelayedDiagnosticsState pushUndelayed()
Enter a new scope where access and deprecation diagnostics are not delayed.
Definition: Sema.h:1022
A helper class for building up ExtParameterInfos.
Definition: Sema.h:12646
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:12665
void set(unsigned index, FunctionProtoType::ExtParameterInfo info)
Set the ExtParameterInfo for the parameter at the given index,.
Definition: Sema.h:12653
Records and restores the CurFPFeatures state on entry/exit of compound statements.
Definition: Sema.h:13613
FPOptionsOverride getOverrides()
Definition: Sema.h:13617
FullExprArg(Sema &actions)
Definition: Sema.h:7280
ExprResult release()
Definition: Sema.h:7282
Expr * get() const
Definition: Sema.h:7284
GlobalEagerInstantiationScope(Sema &S, bool Enabled)
Definition: Sema.h:13629
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:10110
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:10102
Helper class that collects exception specifications for implicitly-declared special member functions.
Definition: Sema.h:4998
unsigned size() const
The number of exceptions in the exception specification.
Definition: Sema.h:5031
ExceptionSpecificationType getExceptionSpecType() const
Get the computed exception specification type.
Definition: Sema.h:5024
const QualType * data() const
The set of exceptions in the exception specification.
Definition: Sema.h:5034
void CalledExpr(Expr *E)
Integrate an invoked expression into the collected data.
Definition: Sema.h:5040
FunctionProtoType::ExceptionSpecInfo getExceptionSpec() const
Overwrite an EPI's exception specification with this computed exception specification.
Definition: Sema.h:5047
static NameClassification DependentNonType()
Definition: Sema.h:3257
static NameClassification VarTemplate(TemplateName Name)
Definition: Sema.h:3267
ExprResult getExpression() const
Definition: Sema.h:3293
NameClassification(const IdentifierInfo *Keyword)
Definition: Sema.h:3233
static NameClassification Unknown()
Definition: Sema.h:3237
static NameClassification OverloadSet(ExprResult E)
Definition: Sema.h:3241
NameClassificationKind getKind() const
Definition: Sema.h:3291
static NameClassification UndeclaredTemplate(TemplateName Name)
Definition: Sema.h:3285
static NameClassification FunctionTemplate(TemplateName Name)
Definition: Sema.h:3273
NamedDecl * getNonTypeDecl() const
Definition: Sema.h:3303
NameClassification(ParsedType Type)
Definition: Sema.h:3231
TemplateName getTemplateName() const
Definition: Sema.h:3308
ParsedType getType() const
Definition: Sema.h:3298
TemplateNameKind getTemplateNameKind() const
Definition: Sema.h:3315
static NameClassification NonType(NamedDecl *D)
Definition: Sema.h:3247
static NameClassification Concept(TemplateName Name)
Definition: Sema.h:3279
static NameClassification UndeclaredNonType()
Definition: Sema.h:3253
static NameClassification TypeTemplate(TemplateName Name)
Definition: Sema.h:3261
static NameClassification Error()
Definition: Sema.h:3235
Custom deleter to allow FunctionScopeInfos to be kept alive for a short time after they've been poppe...
Definition: Sema.h:665
void operator()(sema::FunctionScopeInfo *Scope) const
Definition: Sema.cpp:2316
Whether and why a template name is required in this lookup.
Definition: Sema.h:11108
RequiredTemplateKind(TemplateNameIsRequiredTag)
Template name is unconditionally required.
Definition: Sema.h:11114
SourceLocation getTemplateKeywordLoc() const
Definition: Sema.h:11116
RequiredTemplateKind(SourceLocation TemplateKWLoc=SourceLocation())
Template name is required if TemplateKWLoc is valid.
Definition: Sema.h:11111
RAII class used to determine whether SFINAE has trapped any errors that occur during template argumen...
Definition: Sema.h:12116
bool hasErrorOccurred() const
Determine whether any SFINAE errors have been trapped.
Definition: Sema.h:12146
SFINAETrap(Sema &SemaRef, bool AccessCheckingSFINAE=false)
Definition: Sema.h:12124
A derivative of BoundTypeDiagnoser for which the diagnostic's type parameter is preceded by a 0/1 enu...
Definition: Sema.h:7910
void diagnose(Sema &S, SourceLocation Loc, QualType T) override
Definition: Sema.h:7915
SizelessTypeDiagnoser(unsigned DiagID, const Ts &...Args)
Definition: Sema.h:7912
SpecialMemberOverloadResultEntry(const llvm::FoldingSetNodeID &ID)
Definition: Sema.h:8978
SpecialMemberOverloadResult - The overloading result for a special member function.
Definition: Sema.h:8956
SpecialMemberOverloadResult(CXXMethodDecl *MD)
Definition: Sema.h:8965
CXXMethodDecl * getMethod() const
Definition: Sema.h:8968
void setMethod(CXXMethodDecl *MD)
Definition: Sema.h:8969
RAII object to handle the state changes required to synthesize a function body.
Definition: Sema.h:13119
void addContextNote(SourceLocation UseLoc)
Definition: Sema.h:13149
SynthesizedFunctionScope(Sema &S, DeclContext *DC)
Definition: Sema.h:13125
SourceLocation getLocation() const
Definition: Sema.h:11890
bool ContainsDecl(const NamedDecl *ND) const
Definition: Sema.h:11880
const DeclContext * getDeclContext() const
Definition: Sema.h:11886
TemplateCompareNewDeclInfo(const DeclContext *DeclCtx, const DeclContext *LexicalDeclCtx, SourceLocation Loc)
Definition: Sema.h:11864
const NamedDecl * getDecl() const
Definition: Sema.h:11878
TemplateCompareNewDeclInfo(const NamedDecl *ND)
Definition: Sema.h:11863
const DeclContext * getLexicalDeclContext() const
Definition: Sema.h:11882
RAII class used to indicate that we are performing provisional semantic analysis to determine the val...
Definition: Sema.h:12155
TentativeAnalysisScope(Sema &SemaRef)
Definition: Sema.h:12162
Abstract base class used for diagnosing integer constant expression violations.
Definition: Sema.h:7233
virtual SemaDiagnosticBuilder diagnoseNotICE(Sema &S, SourceLocation Loc)=0
VerifyICEDiagnoser(bool Suppress=false)
Definition: Sema.h:7237
Sema - This implements semantic analysis and AST building for C.
Definition: Sema.h:466
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:14579
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:1048
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:3105
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:13193
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:7815
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:13177
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:10675
LocalInstantiationScope * CurrentInstantiationScope
The current instantiation scope used to store local variables.
Definition: Sema.h:12675
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:2389
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:734
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:13576
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:6089
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:9788
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:6078
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:15845
bool RequireCompleteSizedExprType(Expr *E, unsigned DiagID, const Ts &...Args)
Definition: Sema.h:7865
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:15522
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:7783
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:6473
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:4481
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:7858
bool tryExprAsCall(Expr &E, QualType &ZeroArgCallReturnTy, UnresolvedSetImpl &NonTemplateOverloads)
Figure out if an expression could be turned into a call.
Definition: Sema.cpp:2489
CXXSpecialMemberKind getSpecialMember(const CXXMethodDecl *MD)
Definition: Sema.h:5838
LookupNameKind
Describes the kind of name lookup to perform.
Definition: Sema.h:9000
@ LookupLabel
Label name lookup.
Definition: Sema.h:9009
@ LookupOrdinaryName
Ordinary name lookup, which finds ordinary names (functions, variables, typedefs, etc....
Definition: Sema.h:9004
@ LookupUsingDeclName
Look up all declarations in a scope with the given name, including resolved using declarations.
Definition: Sema.h:9031
@ LookupNestedNameSpecifierName
Look up of a name that precedes the '::' scope resolution operator in C++.
Definition: Sema.h:9023
@ LookupOMPReductionName
Look up the name of an OpenMP user-defined reduction operation.
Definition: Sema.h:9045
@ LookupLocalFriendName
Look up a friend of a local class.
Definition: Sema.h:9039
@ LookupObjCProtocolName
Look up the name of an Objective-C protocol.
Definition: Sema.h:9041
@ LookupRedeclarationWithLinkage
Look up an ordinary name that is going to be redeclared as a name with linkage.
Definition: Sema.h:9036
@ LookupOperatorName
Look up of an operator name (e.g., operator+) for use with operator overloading.
Definition: Sema.h:9016
@ LookupObjCImplicitSelfParam
Look up implicit 'self' parameter of an objective-c method.
Definition: Sema.h:9043
@ LookupNamespaceName
Look up a namespace name within a C++ using directive or namespace alias definition,...
Definition: Sema.h:9027
@ LookupMemberName
Member name lookup, which finds the names of class/struct/union members.
Definition: Sema.h:9012
@ LookupDestructorName
Look up a name following ~ in a destructor name.
Definition: Sema.h:9019
@ LookupTagName
Tag name lookup, which finds the names of enums, classes, structs, and unions.
Definition: Sema.h:9007
@ LookupOMPMapperName
Look up the name of an OpenMP user-defined mapper.
Definition: Sema.h:9047
@ LookupAnyName
Look up any declaration with any name.
Definition: Sema.h:9049
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:8944
LazyVector< TypedefNameDecl *, ExternalSemaSource, &ExternalSemaSource::ReadExtVectorDecls, 2, 2 > ExtVectorDeclsType
Definition: Sema.h:4470
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:19678
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:13182
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:5775
Decl * ActOnUsingEnumDeclaration(Scope *CurScope, AccessSpecifier AS, SourceLocation UsingLoc, SourceLocation EnumLoc, SourceRange TyLoc, const IdentifierInfo &II, ParsedType Ty, CXXScopeSpec *SS=nullptr)
VariadicCallType
Definition: Sema.h:2317
@ VariadicDoesNotApply
Definition: Sema.h:2322
@ VariadicFunction
Definition: Sema.h:2318
@ VariadicMethod
Definition: Sema.h:2320
@ VariadicConstructor
Definition: Sema.h:2321
@ VariadicBlock
Definition: Sema.h:2319
SemaM68k & M68k()
Definition: Sema.h:1093
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)
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:2465
ExprResult ActOnCompoundLiteral(SourceLocation LParenLoc, ParsedType Ty, SourceLocation RParenLoc, Expr *InitExpr)
Definition: SemaExpr.cpp:7054
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:982
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:3627
@ NTCUC_CopyInit
Definition: Sema.h:3637
@ NTCUC_AutoVar
Definition: Sema.h:3635
@ NTCUC_CompoundLiteral
Definition: Sema.h:3641
@ NTCUC_DefaultInitializedObject
Definition: Sema.h:3633
@ NTCUC_Assignment
Definition: Sema.h:3639
@ NTCUC_BlockCapture
Definition: Sema.h:3643
@ NTCUC_FunctionReturn
Definition: Sema.h:3631
@ NTCUC_LValueToRValueVolatile
Definition: Sema.h:3645
@ NTCUC_FunctionParam
Definition: Sema.h:3629
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:1728
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:9488
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:7558
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:4415
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:4614
OpaquePtr< QualType > TypeTy
Definition: Sema.h:904
void ActOnTagDefinitionError(Scope *S, Decl *TagDecl)
ActOnTagDefinitionError - Invoked when there was an unrecoverable error parsing the definition of a t...
Definition: SemaDecl.cpp:18305
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:13263
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:2351
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:1128
IfExistsResult
Describes the result of an "if-exists" condition check.
Definition: Sema.h:8474
@ IER_DoesNotExist
The symbol does not exist.
Definition: Sema.h:8479
@ IER_Dependent
The name is a dependent name, so the results will differ from one instantiation to the next.
Definition: Sema.h:8483
@ IER_Error
An error occurred.
Definition: Sema.h:8486
@ IER_Exists
The symbol exists.
Definition: Sema.h:8476
void CheckDelegatingCtorCycles()
llvm::SmallSet< SourceLocation, 2 > SrcLocSet
Definition: Sema.h:8943
void ActOnStartStmtExpr()
Definition: SemaExpr.cpp:15864
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:5813
bool hasVisibleDeclaration(const NamedDecl *D, llvm::SmallVectorImpl< Module * > *Modules=nullptr)
Determine whether any declaration of an entity is visible.
Definition: Sema.h:9314
bool FormatStringHasSArg(const StringLiteral *FExpr)
void WarnOnPendingNoDerefs(ExpressionEvaluationContextRecord &Rec)
Emit a warning for all pending noderef expressions that we recorded.
Definition: SemaExpr.cpp:17483
TypeVisibilityAttr * mergeTypeVisibilityAttr(Decl *D, const AttributeCommonInfo &CI, TypeVisibilityAttr::VisibilityType Vis)
void ActOnStmtExprError()
Definition: SemaExpr.cpp:15870
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:20195
bool IsLastErrorImmediate
Is the last error level diagnostic immediate.
Definition: Sema.h:974
StmtResult ActOnSEHLeaveStmt(SourceLocation Loc, Scope *CurScope)
Definition: SemaStmt.cpp:4470
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:1570
static const IdentifierInfo * getPrintable(const IdentifierInfo *II)
Definition: Sema.h:14614
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:869
void ActOnTagFinishDefinition(Scope *S, Decl *TagDecl, SourceRange BraceRange)
ActOnTagFinishDefinition - Invoked once we have finished parsing the definition of a tag (enumeration...
Definition: SemaDecl.cpp:18237
FunctionEmissionStatus
Status of the function emission on the CUDA/HIP/OpenMP host/device attrs.
Definition: Sema.h:4328
llvm::SmallSetVector< const TypedefNameDecl *, 4 > UnusedLocalTypedefNameCandidates
Set containing all typedefs that are likely unused.
Definition: Sema.h:3087
PragmaClangSection PragmaClangRodataSection
Definition: Sema.h:1435
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:12191
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:15059
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:6055
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:16443
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:6036
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:858
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:1073
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:17418
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:1425
@ PCSA_Set
Definition: Sema.h:1425
@ PCSA_Clear
Definition: Sema.h:1425
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:20411
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:7355
@ 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:951
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:15018
bool RequireCompleteDeclContext(CXXScopeSpec &SS, DeclContext *DC)
Require that the context specified by SS be complete.
static SourceRange getPrintable(SourceLocation L)
Definition: Sema.h:14620
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:2689
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:7803
void CheckOverrideControl(NamedDecl *D)
CheckOverrideControl - Check C++11 override control semantics.
ModuleDeclKind
Definition: Sema.h:9619
@ PartitionImplementation
'module X:Y;'
@ Interface
'export module X;'
@ PartitionInterface
'export module X:Y;'
SourceLocation LocationOfExcessPrecisionNotSatisfied
Definition: Sema.h:7945
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:851
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:9261
ReferenceCompareResult
ReferenceCompareResult - Expresses the result of comparing two types (cv1 T1 and cv2 T2) to determine...
Definition: Sema.h:10129
@ Ref_Incompatible
Ref_Incompatible - The two types are incompatible, so direct reference binding is not possible.
Definition: Sema.h:10132
@ Ref_Compatible
Ref_Compatible - The two types are reference-compatible.
Definition: Sema.h:10138
@ Ref_Related
Ref_Related - The two types are reference-related, which means that their unqualified forms (T1 and T...
Definition: Sema.h:10136
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:1381
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:1269
@ AR_dependent
Definition: Sema.h:1272
@ AR_accessible
Definition: Sema.h:1270
@ AR_inaccessible
Definition: Sema.h:1271
@ AR_delayed
Definition: Sema.h:1273
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:2293
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:14624
@ 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:533
const ExpressionEvaluationContextRecord & currentEvaluationContext() const
Definition: Sema.h:6451
Scope * getScopeForContext(DeclContext *Ctx)
Determines the active Scope associated with the given declaration context.
Definition: Sema.cpp:2162
QualType GetSignedSizelessVectorType(QualType V)
Definition: SemaExpr.cpp:12750
llvm::DenseSet< std::pair< Decl *, unsigned > > InstantiatingSpecializations
Specializations whose definitions are currently being instantiated.
Definition: Sema.h:13180
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:7934
void deduceOpenCLAddressSpace(ValueDecl *decl)
Definition: SemaDecl.cpp:6867
ExprResult ActOnCharacterConstant(const Token &Tok, Scope *UDLScope=nullptr)
Definition: SemaExpr.cpp:3551
StmtResult ActOnGotoStmt(SourceLocation GotoLoc, SourceLocation LabelLoc, LabelDecl *TheDecl)
Definition: SemaStmt.cpp:3219
PragmaStack< FPOptionsOverride > FpPragmaStack
Definition: Sema.h:1666
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:7846
void SetFunctionBodyKind(Decl *D, SourceLocation Loc, FnBodyKind BodyKind, StringLiteral *DeletedMessage=nullptr)
static SourceRange getPrintable(const Expr *E)
Definition: Sema.h:14621
PragmaStack< StringLiteral * > CodeSegStack
Definition: Sema.h:1660
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:3830
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:18461
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:15185
void setFunctionHasBranchIntoScope()
Definition: Sema.cpp:2342
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:4475
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:1737
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:17176
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:1655
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:10835
Expr * BuildBuiltinCallExpr(SourceLocation Loc, Builtin::ID Id, MultiExprArg CallArgs)
BuildBuiltinCallExpr - Create a call to a builtin function specified by Id.
Definition: SemaExpr.cpp:6696
void AddAlignmentAttributesForRecord(RecordDecl *RD)
AddAlignmentAttributesForRecord - Adds any needed alignment attributes to a the record decl,...
Definition: SemaAttr.cpp:53
void PopParsingDeclaration(ParsingDeclState state, Decl *decl)
ErrorAttr * mergeErrorAttr(Decl *D, const AttributeCommonInfo &CI, StringRef NewUserDiagnostic)
Decl * ActOnConversionDeclarator(CXXConversionDecl *Conversion)
ActOnConversionDeclarator - Called by ActOnDeclarator to complete the declaration of the given C++ co...
void CheckMain(FunctionDecl *FD, const DeclSpec &D)
Definition: SemaDecl.cpp:12339
void AddKnownFunctionAttributes(FunctionDecl *FD)
Adds any function attributes that we know a priori based on the declaration of this function.
Definition: SemaDecl.cpp:16644
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:10162
void ActOnComment(SourceRange Comment)
Definition: Sema.cpp:2441
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:18324
concepts::Requirement * ActOnSimpleRequirement(Expr *E)
llvm::function_ref< void(llvm::raw_ostream &)> EntityPrinter
Definition: Sema.h:13538
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:18422
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:1667
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:1083
bool isValidSveBitcast(QualType srcType, QualType destType)
Are the two types SVE-bitcast-compatible types? I.e.
Definition: SemaExpr.cpp:7532
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:15883
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:1153
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:16526
IdentifierInfo * getSuperIdentifier() const
Definition: Sema.cpp:2716
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:6463
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:831
bool checkPointerAuthEnabled(SourceLocation Loc, SourceRange Range)
LateParsedTemplateMapT LateParsedTemplateMap
Definition: Sema.h:11079
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:11653
@ CTAK_DeducedFromArrayBound
The template argument was deduced from an array bound via template argument deduction.
Definition: Sema.h:11664
@ CTAK_Specified
The template argument was specified in the code or was instantiated with some deduced template argume...
Definition: Sema.h:11656
@ CTAK_Deduced
The template argument was deduced via template argument deduction.
Definition: Sema.h:11660
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:8938
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:1173
ExprResult DefaultVariadicArgumentPromotion(Expr *E, VariadicCallType CT, FunctionDecl *FDecl)
Definition: SemaExpr.cpp:1056
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:13903
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:13197
ExprResult tryConvertExprToType(Expr *E, QualType Ty)
Try to convert an expression E to type Ty.
Definition: SemaExpr.cpp:5012
Decl * ActOnFileScopeAsmDecl(Expr *expr, SourceLocation AsmLoc, SourceLocation RParenLoc)
Definition: SemaDecl.cpp:20227
bool hasMergedDefinitionInCurrentModule(const NamedDecl *Def)
bool DeduceReturnType(FunctionDecl *FD, SourceLocation Loc, bool Diagnose=true)
std::vector< Token > ExpandFunctionLocalPredefinedMacros(ArrayRef< Token > Toks)
Definition: SemaExpr.cpp:2012
StmtResult SubstStmt(Stmt *S, const MultiLevelTemplateArgumentList &TemplateArgs)
bool CheckMatrixCast(SourceRange R, QualType DestTy, QualType SrcTy, CastKind &Kind)
Definition: SemaExpr.cpp:7642
QualType CheckAddressOfOperand(ExprResult &Operand, SourceLocation OpLoc)
CheckAddressOfOperand - The operand of & must be either a function designator or an lvalue designatin...
Definition: SemaExpr.cpp:14183
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:911
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:7770
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:12986
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:9852
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:20206
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:4683
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:8949
FullExprArg MakeFullExpr(Expr *Arg, SourceLocation CC)
Definition: Sema.h:7301
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:11528
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:13204
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:531
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:7907
concepts::TypeRequirement * BuildTypeRequirement(TypeSourceInfo *Type)
void ActOnFinishTopLevelStmtDecl(TopLevelStmtDecl *D, Stmt *Statement)
Definition: SemaDecl.cpp:20248
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:3952
ExprResult BuildExpressionFromNonTypeTemplateArgument(const TemplateArgument &Arg, SourceLocation Loc)
bool RequireLiteralType(SourceLocation Loc, QualType T, unsigned DiagID, const Ts &...Args)
Definition: Sema.h:14983
AccessResult CheckDestructorAccess(SourceLocation Loc, CXXDestructorDecl *Dtor, const PartialDiagnostic &PDiag, QualType objectType=QualType())
bool CheckCaseExpression(Expr *E)
Definition: SemaExpr.cpp:21184
void resetFPOptions(FPOptions FPO)
Definition: Sema.h:11057
bool hasAcceptableDefinition(NamedDecl *D, AcceptableKind Kind)
Definition: Sema.h:15076
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:9607
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:14610
bool LookupBuiltin(LookupResult &R)
Lookup a builtin function, when name lookup would otherwise fail.
Definition: SemaLookup.cpp:916
SemaObjC & ObjC()
Definition: Sema.h:1113
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:13021
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:2671
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:1043
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:7247
@ AllowFold
Definition: Sema.h:7249
@ NoFold
Definition: Sema.h:7248
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:2686
PragmaStack< bool > StrictGuardStackCheckStack
Definition: Sema.h:1663
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:3095
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:19691
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:7795
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:534
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:7264
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:6062
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:15801
void CheckExplicitlyDefaultedFunction(Scope *S, FunctionDecl *MD)
ParsingDeclState PushParsingDeclaration(sema::DelayedDiagnosticPool &pool)
Definition: Sema.h:1036
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:18961
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:19939
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:6140
void LookupBinOp(Scope *S, SourceLocation OpLoc, BinaryOperatorKind Opc, UnresolvedSetImpl &Functions)
Definition: SemaExpr.cpp:15319
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:3180
@ NC_Unknown
This name is not a type or template in this context, but might be something else.
Definition: Sema.h:3183
@ NC_VarTemplate
The name was classified as a variable template name.
Definition: Sema.h:3210
@ NC_NonType
The name was classified as a specific non-type, non-template declaration.
Definition: Sema.h:3193
@ NC_TypeTemplate
The name was classified as a template whose specializations are types.
Definition: Sema.h:3208
@ NC_Error
Classification failed; an error has been produced.
Definition: Sema.h:3185
@ NC_FunctionTemplate
The name was classified as a function template name.
Definition: Sema.h:3212
@ NC_DependentNonType
The name denotes a member of a dependent type that could not be resolved.
Definition: Sema.h:3201
@ NC_UndeclaredNonType
The name was classified as an ADL-only function name.
Definition: Sema.h:3197
@ NC_UndeclaredTemplate
The name was classified as an ADL-only function template name.
Definition: Sema.h:3214
@ NC_Keyword
The name has been typo-corrected to a keyword.
Definition: Sema.h:3187
@ NC_Type
The name was classified as a type.
Definition: Sema.h:3189
@ NC_OverloadSet
The name was classified as an overload set, and an expression representing that overload set has been...
Definition: Sema.h:3206
@ NC_Concept
The name was classified as a concept name.
Definition: Sema.h:3216
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:17851
AssignConvertType CheckTransparentUnionArgumentConstraints(QualType ArgType, ExprResult &RHS)
Definition: SemaExpr.cpp:9595
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:1659
StmtResult ActOnSEHTryBlock(bool IsCXXTry, SourceLocation TryLoc, Stmt *TryBlock, Stmt *Handler)
Definition: SemaStmt.cpp:4405
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:881
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:3499
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:2151
ParsingClassState PushParsingClass()
Definition: Sema.h:6085
ForRangeStatus
Definition: Sema.h:10497
@ FRS_Success
Definition: Sema.h:10498
@ FRS_DiagnosticIssued
Definition: Sema.h:10500
@ FRS_NoViableFunction
Definition: Sema.h:10499
bool CheckArgsForPlaceholders(MultiExprArg args)
Check an argument list for placeholders that we won't try to handle later.
Definition: SemaExpr.cpp:6213
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:3114
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:7068
ExprResult ActOnAddrLabel(SourceLocation OpLoc, SourceLocation LabLoc, LabelDecl *TheDecl)
ActOnAddrLabel - Parse the GNU address of label extension: "&&foo".
Definition: SemaExpr.cpp:15851
void MarkAsLateParsedTemplate(FunctionDecl *FD, Decl *FnD, CachedTokens &Toks)
llvm::SmallVector< DeleteExprLoc, 4 > DeleteLocs
Definition: Sema.h:576
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:8997
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:8941
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:5609
@ 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:7923
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:8683
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:15181
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:9848
@ 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:841
llvm::PointerIntPair< CXXRecordDecl *, 3, CXXSpecialMemberKind > SpecialMemberDecl
Definition: Sema.h:6073
QualType CheckMatrixMultiplyOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, bool IsCompAssign)
Definition: SemaExpr.cpp:13067
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:20394
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:819
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:3118
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:16979
ExprResult ActOnCXXThrow(Scope *S, SourceLocation OpLoc, Expr *expr)
sema::LambdaScopeInfo * getCurGenericLambda()
Retrieve the current generic lambda info, if any.
Definition: Sema.cpp:2432
unsigned InventedParameterInfosStart
The index of the first InventedParameterInfo that refers to the current context.
Definition: Sema.h:3010
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:2217
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:11069
void setFunctionHasIndirectGoto()
Definition: Sema.cpp:2352
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:11822
@ TPL_TemplateTemplateParmMatch
We are matching the template parameter lists of two template template parameters as part of matching ...
Definition: Sema.h:11840
@ TPL_TemplateMatch
We are matching the template parameter lists of two templates that might be redeclarations.
Definition: Sema.h:11830
@ TPL_TemplateParamsEquivalent
We are determining whether the template-parameters are equivalent according to C++ [temp....
Definition: Sema.h:11850
ExprResult ActOnChooseExpr(SourceLocation BuiltinLoc, Expr *CondExpr, Expr *LHSExpr, Expr *RHSExpr, SourceLocation RPLoc)
Definition: SemaExpr.cpp:16139
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:4466
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:1684
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:7976
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:11129
@ 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
bool CheckTemplateArgument(NamedDecl *Param, TemplateArgumentLoc &Arg, NamedDecl *Template, SourceLocation TemplateLoc, SourceLocation RAngleLoc, unsigned ArgumentPackIndex, CheckTemplateArgumentInfo &CTAI, CheckTemplateArgumentKind CTAK)
Check that the given template argument corresponds to the given template parameter.
void MergeVarDeclTypes(VarDecl *New, VarDecl *Old, bool MergeTypeWithOld)
MergeVarDeclTypes - We parsed a variable 'New' which has the same name and scope as a previous declar...
Definition: SemaDecl.cpp:4391
ExprResult ActOnUnevaluatedStringLiteral(ArrayRef< Token > StringToks)
Definition: SemaExpr.cpp:1982
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:2259
void PushFunctionScope()
Enter a new function scope.
Definition: Sema.cpp:2181
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:3331
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:11062
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:674
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:3091
std::optional< ExpressionEvaluationContextRecord::InitializationContext > OutermostDeclarationWithDelayedImmediateInvocations() const
Definition: Sema.h:7830
static DeclarationName getPrintable(DeclarationName N)
Definition: Sema.h:14617
llvm::function_ref< void(SourceLocation Loc, PartialDiagnostic PD)> DiagReceiverTy
Definition: Sema.h:4167
bool CheckEnumUnderlyingType(TypeSourceInfo *TI)
Check that this is a valid underlying type for an enum declaration.
Definition: SemaDecl.cpp:16878
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:529
RecordDecl * StdSourceLocationImplDecl
The C++ "std::source_location::__impl" struct, defined in <source_location>.
Definition: Sema.h:7928
void SetLateTemplateParser(LateTemplateParserCB *LTP, LateTemplateParserCleanupCB *LTPCleanup, void *P)
Definition: Sema.h:957
ConditionResult ActOnCondition(Scope *S, SourceLocation Loc, Expr *SubExpr, ConditionKind CK, bool MissingOK=false)
Definition: SemaExpr.cpp:20442
SourceLocation getLocForEndOfToken(SourceLocation Loc, unsigned Offset=0)
Calls Lexer::getLocForEndOfToken()
Definition: Sema.cpp:82
sema::LambdaScopeInfo * PushLambdaScope()
Definition: Sema.cpp:2199
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:2331
bool RequireCompleteType(SourceLocation Loc, QualType T, unsigned DiagID, const Ts &...Args)
Definition: Sema.h:15027
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:19763
UnexpandedParameterPackContext
The context in which an unexpanded parameter pack is being diagnosed.
Definition: Sema.h:13946
@ UPPC_FixedUnderlyingType
The fixed underlying type of an enumeration.
Definition: Sema.h:13966
@ UPPC_RequiresClause
Definition: Sema.h:14017
@ UPPC_UsingDeclaration
A using declaration.
Definition: Sema.h:13972
@ UPPC_IfExists
Microsoft __if_exists.
Definition: Sema.h:13999
@ UPPC_Requirement
Definition: Sema.h:14014
@ UPPC_ExceptionType
The type of an exception.
Definition: Sema.h:13990
@ UPPC_EnumeratorValue
The enumerator value.
Definition: Sema.h:13969
@ UPPC_Lambda
Lambda expression.
Definition: Sema.h:14005
@ UPPC_IfNotExists
Microsoft __if_not_exists.
Definition: Sema.h:14002
@ UPPC_PartialSpecialization
Partial specialization.
Definition: Sema.h:13996
@ UPPC_Initializer
An initializer.
Definition: Sema.h:13981
@ UPPC_BaseType
The base type of a class type.
Definition: Sema.h:13951
@ UPPC_FriendDeclaration
A friend declaration.
Definition: Sema.h:13975
@ UPPC_DefaultArgument
A default argument.
Definition: Sema.h:13984
@ UPPC_DeclarationType
The type of an arbitrary declaration.
Definition: Sema.h:13954
@ UPPC_Expression
An arbitrary expression.
Definition: Sema.h:13948
@ UPPC_ExplicitSpecialization
Explicit specialization.
Definition: Sema.h:13993
@ UPPC_DeclarationQualifier
A declaration qualifier.
Definition: Sema.h:13978
@ UPPC_DataMemberType
The type of a data member.
Definition: Sema.h:13957
@ UPPC_StaticAssertExpression
The expression in a static assertion.
Definition: Sema.h:13963
@ UPPC_Block
Block expression.
Definition: Sema.h:14008
@ UPPC_BitFieldWidth
The size of a bit-field.
Definition: Sema.h:13960
@ UPPC_NonTypeTemplateParameterType
The type of a non-type template parameter.
Definition: Sema.h:13987
@ UPPC_TypeConstraint
A type constraint.
Definition: Sema.h:14011
api_notes::APINotesManager APINotes
Definition: Sema.h:915
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:12178
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:527
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:5399
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:12218
SourceLocation CurInitSegLoc
Definition: Sema.h:1699
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:7306
void ActOnPragmaMSVtorDisp(PragmaMsStackAction Action, SourceLocation PragmaLoc, MSVtorDispMode Value)
Called on well formed #pragma vtordisp().
Definition: SemaAttr.cpp:721
SemaCodeCompletion & CodeCompletion()
Definition: Sema.h:1068
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:3112
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:1118
void SwapSatisfactionStack(llvm::SmallVectorImpl< SatisfactionStackEntryTy > &NewSS)
Definition: Sema.h:14398
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:6535
@ ReuseLambdaContextDecl
Definition: Sema.h:6535
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:17514
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:535
NonOdrUseReason getNonOdrUseReasonInCurrentContext(ValueDecl *D)
If D cannot be odr-used in the current expression evaluation context, return a reason explaining why.
Definition: SemaExpr.cpp:2265
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:1063
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:20080
void * OpaqueParser
Definition: Sema.h:955
Preprocessor & PP
Definition: Sema.h:910
QualType CheckAdditionOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, BinaryOperatorKind Opc, QualType *CompLHSTy=nullptr)
Definition: SemaExpr.cpp:10963
VariadicCallType getVariadicCallType(FunctionDecl *FDecl, const FunctionProtoType *Proto, Expr *Fn)
Definition: SemaExpr.cpp:5724
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:6489
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:14155
bool MSPragmaOptimizeIsOn
The "on" or "off" argument passed by #pragma optimize, that denotes whether the optimizations in the ...
Definition: Sema.h:1746
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:16807
bool ActOnAlignasTypeArgument(StringRef KWName, ParsedType Ty, SourceLocation OpLoc, SourceRange R)
ActOnAlignasTypeArgument - Handle alignas(type-id) and _Alignas(type-name) .
Definition: SemaExpr.cpp:4725
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:948
SmallVector< PragmaAttributeGroup, 2 > PragmaAttributeStack
Definition: Sema.h:1724
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:1981
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:7547
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:3099
llvm::SmallSetVector< const NamedDecl *, 16 > NamedDeclSetType
Definition: Sema.h:6038
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:1103
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:14426
const LangOptions & LangOpts
Definition: Sema.h:909
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:15953
std::unique_ptr< sema::FunctionScopeInfo > CachedFunctionScope
Definition: Sema.h:847
ExprResult CorrectDelayedTyposInExpr(ExprResult ER, VarDecl *InitDecl=nullptr, bool RecoverUncorrectedTypos=false, llvm::function_ref< ExprResult(Expr *)> Filter=[](Expr *E) -> ExprResult { return E;})
Definition: Sema.h:8462
sema::LambdaScopeInfo * getCurLambda(bool IgnoreNonLambdaCapturingScope=false)
Retrieve the current lambda scope info, if any.
Definition: Sema.cpp:2407
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:6746
static const uint64_t MaximumAlignment
Definition: Sema.h:842
ExprResult BuildCXXMemberCallExpr(Expr *Exp, NamedDecl *FoundDecl, CXXConversionDecl *Method, bool HadMultipleCandidates)
llvm::DenseMap< unsigned, CXXDeductionGuideDecl * > AggregateDeductionCandidates
Definition: Sema.h:8686
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:17535
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:15040
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:6040
SemaHLSL & HLSL()
Definition: Sema.h:1078
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:11078
bool CollectStats
Flag indicating whether or not to collect detailed statistics.
Definition: Sema.h:845
llvm::SmallSetVector< DeclContext *, 16 > AssociatedNamespaceSet
Definition: Sema.h:8996
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:18517
ExpressionEvaluationContextRecord & currentEvaluationContext()
Definition: Sema.h:6457
void CheckUnusedVolatileAssignment(Expr *E)
Check whether E, which is either a discarded-value expression or an unevaluated operand,...
Definition: SemaExpr.cpp:17499
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:1436
void NoteHiddenVirtualMethods(CXXMethodDecl *MD, SmallVectorImpl< CXXMethodDecl * > &OverloadedMethods)
SemaMIPS & MIPS()
Definition: Sema.h:1098
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:1143
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:15204
bool checkConstantPointerAuthKey(Expr *keyExpr, unsigned &key)
SourceLocation ImplicitMSInheritanceAttrLoc
Source location for newly created implicit MSInheritanceAttrs.
Definition: Sema.h:1413
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:5405
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:3719
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:4795
@ 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:13574
SmallVector< InventedTemplateParameterInfo, 4 > InventedParameterInfos
Stack containing information needed when in C++2a an 'auto' is encountered in a function declaration ...
Definition: Sema.h:6033
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:20090
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:9876
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:14612
SemaSwift & Swift()
Definition: Sema.h:1158
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:3712
PragmaStack< AlignPackInfo > AlignPackStack
Definition: Sema.h:1648
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:6132
CleanupInfo Cleanup
Used to control the generation of ExprWithCleanups.
Definition: Sema.h:6484
std::vector< std::unique_ptr< TemplateInstantiationCallback > > TemplateInstCallbacks
The template instantiation callbacks to trace or track instantiations (objects can be chained).
Definition: Sema.h:13229
llvm::DenseMap< ParmVarDecl *, SourceLocation > UnparsedDefaultArgLocs
Definition: Sema.h:6066
StmtResult ActOnExprStmtError()
Definition: SemaStmt.cpp:66
AcceptableKind
Definition: Sema.h:8992
PragmaStack< StringLiteral * > BSSSegStack
Definition: Sema.h:1658
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:3409
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:738
std::function< TypeResult(StringRef, StringRef, SourceLocation)> ParseTypeFromStringCallback
Callback to the parser to parse a type expressed as a string.
Definition: Sema.h:966
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:1702
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 checkEnumArithmeticConversions(Expr *LHS, Expr *RHS, SourceLocation Loc, Sema::ArithConvKind ACK)
Check that the usual arithmetic conversions can be performed on this pair of expressions that might b...
Definition: SemaExpr.cpp:1506
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:906
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:13578
VarArgKind isValidVarArgType(const QualType &Ty)
Determine the degree of POD-ness for an expression.
Definition: SemaExpr.cpp:950
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:16954
llvm::SmallSetVector< StringRef, 4 > MSFunctionNoBuiltins
Set of no-builtin functions listed by #pragma function.
Definition: Sema.h:1749
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:15764
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:4505
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:4588
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:14606
ProcessingContextState ParsingClassState
Definition: Sema.h:6084
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:19789
sema::FunctionScopeInfo * getCurFunction() const
Definition: Sema.h:942
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:2326
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:2760
bool CheckLoopHintExpr(Expr *E, SourceLocation Loc, bool AllowZero)
Definition: SemaExpr.cpp:3651
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:3392
std::pair< const IdentifierInfo *, uint64_t > TypeTagMagicValue
A pair of ArgumentKind identifier and magic value.
Definition: Sema.h:2237
void ActOnPragmaWeakID(IdentifierInfo *WeakName, SourceLocation PragmaLoc, SourceLocation WeakNameLoc)
ActOnPragmaWeakID - Called on well formed #pragma weak ident.
Definition: SemaDecl.cpp:20282
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:10430
bool CheckNontrivialField(FieldDecl *FD)
Definition: SemaDecl.cpp:18715
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:9647
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:6481
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:18195
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:2145
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:12687
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:4426
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:952
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:5395
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:13237
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:3202
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:15034
bool CheckDerivedToBaseConversion(QualType Derived, QualType Base, SourceLocation Loc, SourceRange Range, CXXCastPath *BasePath=nullptr, bool IgnoreAccess=false)
bool isInLifetimeExtendingContext() const
Definition: Sema.h:7799
StringLiteral * CurInitSeg
Last section used with #pragma init_seg.
Definition: Sema.h:1698
FunctionEmissionStatus getEmissionStatus(const FunctionDecl *Decl, bool Final=false)
Definition: SemaDecl.cpp:20312
Module * getCurrentModule() const
Get the module unit whose scope we are currently within.
Definition: Sema.h:9602
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:7293
static bool isCast(CheckedConversionKind CCK)
Definition: Sema.h:2086
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:1652
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:16315
ExprResult prepareVectorSplat(QualType VectorTy, Expr *SplattedExpr)
Prepare SplattedExpr for a vector splat operation, adding implicit casts if necessary.
Definition: SemaExpr.cpp:7683
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:2362
bool DiagnoseMultipleUserDefinedConversion(Expr *From, QualType ToType)
bool DiagnoseUseOfOverloadedDecl(NamedDecl *D, SourceLocation Loc)
Definition: Sema.h:6496
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:6047
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:18186
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:1046
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:9079
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:20905
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:12179
@ VAK_Invalid
Definition: Sema.h:7549
@ VAK_Valid
Definition: Sema.h:7545
@ VAK_ValidInCXX11
Definition: Sema.h:7546
@ VAK_MSVCUndefined
Definition: Sema.h:7548
@ VAK_Undefined
Definition: Sema.h:7547
SemaOpenCL & OpenCL()
Definition: Sema.h:1123
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:13587
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:16689
void CompleteMemberSpecialization(NamedDecl *Member, LookupResult &Previous)
bool isPreciseFPEnabled()
Are precise floating point semantics currently enabled?
Definition: Sema.h:1838
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:14622
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:7929
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:5878
@ TAH_IgnoreTrivialABI
The triviality of a method unaffected by "trivial_abi".
Definition: Sema.h:5880
@ TAH_ConsiderTrivialABI
The triviality of a method affected by "trivial_abi".
Definition: Sema.h:5883
FormatArgumentPassingKind
Definition: Sema.h:2161
@ FAPK_Fixed
Definition: Sema.h:2162
@ FAPK_Variadic
Definition: Sema.h:2163
@ FAPK_VAList
Definition: Sema.h:2164
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:20141
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:7791
ObjCMethodDecl * SelectBestMethod(Selector Sel, MultiExprArg Args, bool IsInstance, SmallVectorImpl< ObjCMethodDecl * > &Methods)
llvm::DenseMap< ParmVarDecl *, llvm::TinyPtrVector< ParmVarDecl * > > UnparsedDefaultArgInstantiationsMap
Definition: Sema.h:12678
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:3506
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:8990
AssignConvertType
AssignConvertType - All of the 'assignment' semantic checks return this enum to indicate whether the ...
Definition: Sema.h:7594
@ IncompatiblePointerDiscardsQualifiers
IncompatiblePointerDiscardsQualifiers - The assignment discards qualifiers that we don't permit to be...
Definition: Sema.h:7638
@ IntToPointer
IntToPointer - The assignment converts an int to a pointer, which we accept as an extension.
Definition: Sema.h:7604
@ IncompatibleBlockPointer
IncompatibleBlockPointer - The assignment is between two block pointers types that are not compatible...
Definition: Sema.h:7662
@ IncompatibleObjCQualifiedId
IncompatibleObjCQualifiedId - The assignment is between a qualified id type and something else (that ...
Definition: Sema.h:7667
@ IncompatibleVectors
IncompatibleVectors - The assignment is between two vector types that have the same size,...
Definition: Sema.h:7654
@ CompatiblePointerDiscardsQualifiers
CompatiblePointerDiscardsQualifiers - The assignment discards c/v/r qualifiers, which we accept as an...
Definition: Sema.h:7633
@ IncompatiblePointer
IncompatiblePointer - The assignment is between two pointers types that are not compatible,...
Definition: Sema.h:7612
@ IncompatibleObjCWeakRef
IncompatibleObjCWeakRef - Assigning a weak-unavailable object to an object with __weak qualifier.
Definition: Sema.h:7671
@ Compatible
Compatible - the types are compatible according to the standard.
Definition: Sema.h:7596
@ IncompatibleFunctionPointerStrict
IncompatibleFunctionPointerStrict - The assignment is between two function pointer types that are not...
Definition: Sema.h:7623
@ Incompatible
Incompatible - We reject this conversion outright, it is invalid to represent it in the AST.
Definition: Sema.h:7675
@ FunctionVoidPointer
FunctionVoidPointer - The assignment is between a function pointer and void*, which the standard does...
Definition: Sema.h:7608
@ IncompatibleFunctionPointer
IncompatibleFunctionPointer - The assignment is between two function pointers types that are not comp...
Definition: Sema.h:7617
@ IncompatiblePointerSign
IncompatiblePointerSign - The assignment is between two pointers types which point to integers which ...
Definition: Sema.h:7629
@ IncompatibleNestedPointerQualifiers
IncompatibleNestedPointerQualifiers - The assignment is between two nested pointer types,...
Definition: Sema.h:7650
@ IncompatibleNestedPointerAddressSpaceMismatch
IncompatibleNestedPointerAddressSpaceMismatch - The assignment changes address spaces in nested point...
Definition: Sema.h:7644
@ PointerToInt
PointerToInt - The assignment converts a pointer to an int, which we accept as an extension.
Definition: Sema.h:7600
@ IntToBlockPointer
IntToBlockPointer - The assignment converts an int to a block pointer.
Definition: Sema.h:7658
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:4698
ArithConvKind
Context in which we're performing a usual arithmetic conversion.
Definition: Sema.h:7403
@ ACK_Arithmetic
An arithmetic operation.
Definition: Sema.h:7405
@ ACK_CompAssign
A compound assignment expression.
Definition: Sema.h:7413
@ ACK_BitwiseOp
A bitwise operation.
Definition: Sema.h:7407
@ ACK_Conditional
A conditional (?:) operator.
Definition: Sema.h:7411
@ ACK_Comparison
A comparison.
Definition: Sema.h:7409
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:20039
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:15047
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:2909
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:3234
bool GlobalNewDeleteDeclared
A flag to remember whether the implicit forms of operator new and delete have been declared.
Definition: Sema.h:7987
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:4122
ExprResult ActOnSourceLocExpr(SourceLocIdentKind Kind, SourceLocation BuiltinLoc, SourceLocation RPLoc)
Definition: SemaExpr.cpp:16774
DeclContext * OriginalLexicalContext
Generally null except when we temporarily switch decl contexts, like in.
Definition: Sema.h:3109
llvm::PointerIntPair< ConstantExpr *, 1 > ImmediateInvocationCandidate
Definition: Sema.h:6293
bool MSStructPragmaOn
Definition: Sema.h:1410
ExprResult CheckPlaceholderExpr(Expr *E)
Check for operands with placeholder types and complain if found.
Definition: SemaExpr.cpp:20995
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:17398
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:13213
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:13534
NonTagKind
Common ways to introduce type names without a tag for use in diagnostics.
Definition: Sema.h:3845
@ NTK_Typedef
Definition: Sema.h:3850
@ NTK_NonUnion
Definition: Sema.h:3848
@ NTK_TypeAlias
Definition: Sema.h:3851
@ NTK_NonClass
Definition: Sema.h:3847
@ NTK_NonEnum
Definition: Sema.h:3849
@ NTK_NonStruct
Definition: Sema.h:3846
@ NTK_TemplateTemplateArgument
Definition: Sema.h:3854
@ NTK_TypeAliasTemplate
Definition: Sema.h:3853
@ NTK_Template
Definition: Sema.h:3852
bool RequireCompleteType(SourceLocation Loc, QualType T, unsigned DiagID)
Definition: Sema.h:15022
SourceManager & getSourceManager() const
Definition: Sema.h:532
void BuildModuleInclude(SourceLocation DirectiveLoc, Module *Mod)
Definition: SemaModule.cpp:734
TryCaptureKind
Definition: Sema.h:6597
@ TryCapture_Implicit
Definition: Sema.h:6598
@ TryCapture_ExplicitByVal
Definition: Sema.h:6599
@ TryCapture_ExplicitByRef
Definition: Sema.h:6600
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:8058
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:4404
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:6724
bool CheckVecStepExpr(Expr *E)
Definition: SemaExpr.cpp:4403
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:3062
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:20044
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:11922
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:3466
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:8795
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:12762
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:10605
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:8984
ExprResult CheckLValueToRValueConversionOperand(Expr *E)
Definition: SemaExpr.cpp:19655
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:13742
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:18172
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:12111
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:1437
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:6989
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:3655
@ NTCUK_Destruct
Definition: Sema.h:3657
@ NTCUK_Init
Definition: Sema.h:3656
@ NTCUK_Copy
Definition: Sema.h:3658
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:983
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:7944
QualType CheckTemplateIdType(TemplateName Template, SourceLocation TemplateLoc, TemplateArgumentListInfo &TemplateArgs)
PragmaClangSection PragmaClangDataSection
Definition: Sema.h:1434
bool DiagRuntimeBehavior(SourceLocation Loc, const Stmt *Statement, const PartialDiagnostic &PD)
Conditionally issue a diagnostic based on the current evaluation context.
Definition: SemaExpr.cpp:20276
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:5501
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:8780
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:7577
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:7614
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:2193
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:20255
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:1647
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:6291
void ActOnLambdaClosureQualifiers(LambdaIntroducer &Intro, SourceLocation MutableLoc)
ExternalSemaSource * getExternalSource() const
Definition: Sema.h:537
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:855
void * VisContext
VisContext - Manages the stack for #pragma GCC visibility.
Definition: Sema.h:1705
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:8417
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:14619
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:20239
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:2061
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:14363
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:3885
bool isCompleteType(SourceLocation Loc, QualType T, CompleteTypeKind Kind=CompleteTypeKind::Default)
Definition: Sema.h:14989
SemaDiagnosticBuilder targetDiag(SourceLocation Loc, const PartialDiagnostic &PD, const FunctionDecl *FD=nullptr)
Definition: Sema.h:744
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:15295
void PushCapturedRegionScope(Scope *RegionScope, CapturedDecl *CD, RecordDecl *RD, CapturedRegionKind K, unsigned OpenMPCaptureLevel=0)
Definition: Sema.cpp:2722
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:1877
void setFunctionHasMustTail()
Definition: Sema.cpp:2357
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:7716
RecordDecl * CXXTypeInfoDecl
The C++ "type_info" declaration, which is defined in <typeinfo>.
Definition: Sema.h:7983
void InstantiateDefaultCtorDefaultArgs(CXXConstructorDecl *Ctor)
In the MS ABI, we need to instantiate default arguments of dllexported default constructors along wit...
CorrectTypoKind
Definition: Sema.h:9396
@ CTK_NonError
Definition: Sema.h:9397
@ CTK_ErrorRecovery
Definition: Sema.h:9398
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:615
@ Global
The global module fragment, between 'module;' and a module-declaration.
Definition: Sema.h:617
@ Private
The private module fragment, between 'module :private;' and the end of the translation unit.
Definition: Sema.h:624
@ Normal
A normal translation unit fragment.
Definition: Sema.h:621
bool IsOverride(FunctionDecl *MD, FunctionDecl *BaseMD, bool UseMemberUsingDeclRules, bool ConsiderCudaAttrs=true)
void PopSatisfactionStackEntry()
Definition: Sema.h:14369
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:2347
RedeclarationKind forRedeclarationInCurContext() const
bool hasReachableDefinition(NamedDecl *D)
Definition: Sema.h:15068
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:2153
bool CheckAttrTarget(const ParsedAttr &CurrAttr)
LazyDeclPtr StdNamespace
The C++ "std" namespace, where the standard library resides.
Definition: Sema.h:6058
StmtResult ActOnFinishSEHFinallyBlock(SourceLocation Loc, Stmt *Block)
Definition: SemaStmt.cpp:4463
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:14379
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:3275
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:10012
@ CCEK_StaticAssertMessageSize
Call to size() in a static assert message.
Definition: Sema.h:10020
@ CCEK_ExplicitBool
Condition in an explicit(bool) specifier.
Definition: Sema.h:10018
@ CCEK_InjectedTTP
Injected parameter of a template template parameter.
Definition: Sema.h:10016
@ CCEK_Noexcept
Condition in a noexcept(bool) specifier.
Definition: Sema.h:10019
@ CCEK_ArrayBound
Array bound in array declarator or new-expression.
Definition: Sema.h:10017
@ CCEK_CaseValue
Expression in a case label.
Definition: Sema.h:10013
@ CCEK_TemplateArg
Value of a non-type template parameter.
Definition: Sema.h:10015
@ CCEK_StaticAssertMessageData
Call to data() in a static assert message.
Definition: Sema.h:10022
@ CCEK_Enumerator
Enumerator value with fixed underlying type.
Definition: Sema.h:10014
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:18778
void InstantiateAttrsForDecl(const MultiLevelTemplateArgumentList &TemplateArgs, const Decl *Pattern, Decl *Inst, LateInstantiatedAttrVec *LateAttrs=nullptr, LocalInstantiationScope *OuterMostScope=nullptr)
std::pair< StringRef, QualType > CapturedParamNameType
Definition: Sema.h:10939
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:3083
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:19575
IntrusiveRefCntPtr< ExternalSemaSource > ExternalSource
Source of additional semantic information.
Definition: Sema.h:1179
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:912
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:4230
bool checkArgCount(CallExpr *Call, unsigned DesiredArgCount)
Checks that a call expression's argument count is the desired number.
OverloadKind
Definition: Sema.h:9790
@ Ovl_NonFunction
This is not an overload because the lookup results contain a non-function.
Definition: Sema.h:9801
@ Ovl_Overload
This is a legitimate overload: the existing declarations are functions or function templates with dif...
Definition: Sema.h:9793
@ Ovl_Match
This is not an overload because the signature exactly matches an existing declaration.
Definition: Sema.h:9797
PragmaAlignPackDiagnoseKind
Definition: Sema.h:1816
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:6488
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:947
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:13570
ExprResult CreateBuiltinArraySubscriptExpr(Expr *Base, SourceLocation LLoc, Expr *Idx, SourceLocation RLoc)
Definition: SemaExpr.cpp:5134
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:9629
@ 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:14618
ExprResult ActOnPredefinedExpr(SourceLocation Loc, tok::TokenKind Kind)
Definition: SemaExpr.cpp:3547
ExprResult ActOnEmbedExpr(SourceLocation EmbedKeywordLoc, StringLiteral *BinaryData)
Definition: SemaExpr.cpp:16815
QualType GetSignedVectorType(QualType V)
Return a signed ext_vector_type that is of identical size and number of elements.
Definition: SemaExpr.cpp:12707
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:4493
AccessResult CheckUnresolvedLookupAccess(UnresolvedLookupExpr *E, DeclAccessPair FoundDecl)
void incrementMSManglingNumber() const
Definition: Sema.h:876
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:8422
void AddKnownFunctionAttributesForReplaceableGlobalAllocationFunction(FunctionDecl *FD)
If this function is a C++ replaceable global allocation function (C++2a [basic.stc....
Definition: SemaDecl.cpp:16575
ExpressionEvaluationContext
Describes how the expressions currently being parsed are evaluated at run-time, if at all.
Definition: Sema.h:6235
@ 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:13221
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:4389
@ AP_PragmaClangAttribute
The availability attribute was applied using '#pragma clang attribute'.
Definition: Sema.h:4395
@ AP_InferredFromOtherPlatform
The availability attribute for a specific platform was inferred from an availability attribute for an...
Definition: Sema.h:4399
@ AP_Explicit
The availability attribute was specified explicitly next to the declaration.
Definition: Sema.h:4392
AvailabilityMergeKind
Describes the kind of merge to perform for availability attributes (including "deprecated",...
Definition: Sema.h:4046
@ AMK_None
Don't merge availability attributes at all.
Definition: Sema.h:4048
@ AMK_Override
Merge availability attributes for an override, which requires an exact match or a weakening of constr...
Definition: Sema.h:4054
@ AMK_ProtocolImplementation
Merge availability attributes for an implementation of a protocol requirement.
Definition: Sema.h:4057
@ AMK_OptionalProtocolImplementation
Merge availability attributes for an implementation of an optional protocol requirement.
Definition: Sema.h:4060
@ AMK_Redeclaration
Merge availability attributes for a redeclaration, which requires an exact match.
Definition: Sema.h:4051
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:6717
StmtResult ActOnSEHExceptBlock(SourceLocation Loc, Expr *FilterExpr, Stmt *Block)
Definition: SemaStmt.cpp:4443
ExprResult CreateUnaryExprOrTypeTraitExpr(TypeSourceInfo *TInfo, SourceLocation OpLoc, UnaryExprOrTypeTrait ExprKind, SourceRange R)
Build a sizeof or alignof expression given a type operand.
Definition: SemaExpr.cpp:4630
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:575
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:20283
bool CheckUnaryExprOrTypeTraitOperand(Expr *E, UnaryExprOrTypeTrait ExprKind)
Check the constraints on expression operands to unary type expression and type traits.
Definition: SemaExpr.cpp:4240
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:17163
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:1133
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:2206
ExprResult ActOnVAArg(SourceLocation BuiltinLoc, Expr *E, ParsedType Ty, SourceLocation RPLoc)
Definition: SemaExpr.cpp:16519
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:4463
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:874
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:14371
ExprResult forceUnknownAnyToType(Expr *E, QualType ToType)
Force an expression with unknown-type to an expression of the given type.
Definition: SemaExpr.cpp:20925
LateTemplateParserCB * LateTemplateParser
Definition: Sema.h:953
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:19023
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:19287
ExprResult ActOnCastExpr(Scope *S, SourceLocation LParenLoc, Declarator &D, ParsedType &Ty, SourceLocation RParenLoc, Expr *CastExpr)
Definition: SemaExpr.cpp:7751
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:7994
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:3102
Expr * MaybeCreateExprWithCleanups(Expr *SubExpr)
MaybeCreateExprWithCleanups - If the current full-expression requires any cleanups,...
bool DeferDiags
Whether deferrable diagnostics should be deferred.
Definition: Sema.h:9769
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:7781
SemaSystemZ & SystemZ()
Definition: Sema.h:1163
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:2744
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:17928
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:19279
SmallVector< ExpressionEvaluationContextRecord, 8 > ExprEvalContexts
A stack of expression evaluation contexts.
Definition: Sema.h:7931
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:7663
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:9615
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:914
TemplateNameIsRequiredTag
Definition: Sema.h:11106
@ TemplateNameIsRequired
Definition: Sema.h:11106
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:4717
ExprResult BuildVectorLiteral(SourceLocation LParenLoc, SourceLocation RParenLoc, Expr *E, TypeSourceInfo *TInfo)
Build an altivec or OpenCL literal.
Definition: SemaExpr.cpp:7824
NamedDecl * BuildUsingPackDecl(NamedDecl *InstantiatedFrom, ArrayRef< NamedDecl * > Expansions)
MemInitResult ActOnMemInitializer(Decl *ConstructorD, Scope *S, CXXScopeSpec &SS, IdentifierInfo *MemberOrBase, ParsedType TemplateTypeTy, const DeclSpec &DS, SourceLocation IdLoc, SourceLocation LParenLoc, ArrayRef< Expr * > Args, SourceLocation RParenLoc, SourceLocation EllipsisLoc)
Handle a C++ member initializer using parentheses syntax.
void SetDeclDeleted(Decl *dcl, SourceLocation DelLoc, StringLiteral *Message=nullptr)
ExprResult ActOnSizeofParameterPackExpr(Scope *S, SourceLocation OpLoc, IdentifierInfo &Name, SourceLocation NameLoc, SourceLocation RParenLoc)
Called when an expression computing the size of a parameter pack is parsed.
ExprResult UsualUnaryFPConversions(Expr *E)
UsualUnaryFPConversions - Promotes floating-point types according to the current language semantics.
Definition: SemaExpr.cpp:781
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:6051
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:2406
std::function< ExprResult(Sema &, TypoExpr *, TypoCorrection)> TypoRecoveryCallback
Definition: Sema.h:9081
DiagnosticsEngine & Diags
Definition: Sema.h:913
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:3302
FullExprArg MakeFullDiscardedValueExpr(Expr *Arg)
Definition: Sema.h:7305
OpenCLOptions & getOpenCLOptions()
Definition: Sema.h:528
FPOptions CurFPFeatures
Definition: Sema.h:907
void ActOnStartSEHFinallyBlock()
Definition: SemaStmt.cpp:4455
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:6042
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:1657
std::optional< QualType > BuiltinVectorMath(CallExpr *TheCall, bool FPOnly=false)
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:954
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:7600
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:2783
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:11295
@ TPC_ClassTemplate
Definition: Sema.h:11296
@ TPC_FriendFunctionTemplate
Definition: Sema.h:11301
@ TPC_ClassTemplateMember
Definition: Sema.h:11299
@ TPC_FunctionTemplate
Definition: Sema.h:11298
@ TPC_FriendClassTemplate
Definition: Sema.h:11300
@ TPC_FriendFunctionTemplateDefinition
Definition: Sema.h:11302
@ TPC_TypeAliasTemplate
Definition: Sema.h:11303
@ TPC_VarTemplate
Definition: Sema.h:11297
void ActOnPragmaVisibility(const IdentifierInfo *VisType, SourceLocation PragmaLoc)
ActOnPragmaVisibility - Called on well formed #pragma GCC visibility... .
Definition: SemaAttr.cpp:1357
void ActOnAbortSEHFinallyBlock()
Definition: SemaStmt.cpp:4459
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:16430
bool CheckQualifiedFunctionForTypeId(QualType T, SourceLocation Loc)
Definition: SemaType.cpp:1784
ExprResult ActOnIntegerConstant(SourceLocation Loc, int64_t Val)
Definition: SemaExpr.cpp:3611
SemaAVR & AVR()
Definition: Sema.h:1058
SmallVector< LateInstantiatedAttribute, 16 > LateInstantiatedAttrVec
Definition: Sema.h:13692
ExprResult BuildCXXDefaultInitExpr(SourceLocation Loc, FieldDecl *Field)
Definition: SemaExpr.cpp:5595
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:20326
SourceLocation OptimizeOffPragmaLocation
This represents the last location of a "#pragma clang optimize off" directive if such a directive has...
Definition: Sema.h:1733
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:13258
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:13118
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:6070
SmallVector< Module *, 16 > CodeSynthesisContextLookupModules
Extra modules inspected when performing a lookup during a template instantiation.
Definition: Sema.h:13188
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:15878
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:14609
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:1011
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:6088
FormatStringType
Definition: Sema.h:2190
@ FST_NSString
Definition: Sema.h:2193
@ FST_Syslog
Definition: Sema.h:2200
@ FST_Unknown
Definition: Sema.h:2201
@ FST_Strftime
Definition: Sema.h:2194
@ FST_Printf
Definition: Sema.h:2192
@ FST_FreeBSDKPrintf
Definition: Sema.h:2197
@ FST_Scanf
Definition: Sema.h:2191
@ FST_Strfmon
Definition: Sema.h:2195
@ FST_OSLog
Definition: Sema.h:2199
@ FST_Kprintf
Definition: Sema.h:2196
@ FST_OSTrace
Definition: Sema.h:2198
LangOptions::PragmaMSPointersToMembersKind MSPointerToMemberRepresentationMethod
Controls member pointer representation format under the MS ABI.
Definition: Sema.h:1408
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:12823
FunctionDecl * FindDeallocationFunctionForDestructor(SourceLocation StartLoc, CXXRecordDecl *RD)
llvm::BumpPtrAllocator BumpAlloc
Definition: Sema.h:860
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:10770
@ BFRK_Check
Determining whether a for-range statement could be built.
Definition: Sema.h:10778
@ BFRK_Build
Initial building of a for-range statement.
Definition: Sema.h:10772
@ BFRK_Rebuild
Instantiation or recovery rebuild of a for-range statement.
Definition: Sema.h:10775
bool IsInvalidSMECallConversion(QualType FromType, QualType ToType)
Definition: SemaExpr.cpp:8898
SemaNVPTX & NVPTX()
Definition: Sema.h:1108
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:4172
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:16822
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:16325
OffsetOfKind
Definition: Sema.h:3869
@ OOK_Outside
Definition: Sema.h:3871
@ OOK_Macro
Definition: Sema.h:3876
@ OOK_Builtin
Definition: Sema.h:3873
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:1677
@ PSK_ConstSeg
Definition: Sema.h:1680
@ PSK_DataSeg
Definition: Sema.h:1678
@ PSK_CodeSeg
Definition: Sema.h:1681
@ PSK_BSSSeg
Definition: Sema.h:1679
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:20061
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:16843
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:5812
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:18414
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:18109
CodeAlignAttr * BuildCodeAlignAttr(const AttributeCommonInfo &CI, Expr *E)
ExprResult ActOnStmtExprResult(ExprResult E)
Definition: SemaExpr.cpp:15922
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:4770
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:5967
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:20382
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:3077
SemaDiagnosticBuilder targetDiag(SourceLocation Loc, unsigned DiagID, const FunctionDecl *FD=nullptr)
Definition: Sema.cpp:1964
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:21192
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:4706
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:15369
PragmaClangSection PragmaClangBSSSection
Definition: Sema.h:1433
Decl * ActOnDeclarator(Scope *S, Declarator &D)
Definition: SemaDecl.cpp:6088
ExprResult ActOnNumericConstant(const Token &Tok, Scope *UDLScope=nullptr)
Definition: SemaExpr.cpp:3685
DeclarationName VAListTagName
VAListTagName - The declaration name corresponding to __va_list_tag.
Definition: Sema.h:970
AbstractDiagSelID
Definition: Sema.h:5758
@ AbstractSynthesizedIvarType
Definition: Sema.h:5765
@ AbstractVariableType
Definition: Sema.h:5762
@ AbstractReturnType
Definition: Sema.h:5760
@ AbstractNone
Definition: Sema.h:5759
@ AbstractFieldType
Definition: Sema.h:5763
@ AbstractArrayType
Definition: Sema.h:5766
@ AbstractParamType
Definition: Sema.h:5761
@ AbstractIvarType
Definition: Sema.h:5764
ExprResult PerformObjectMemberConversion(Expr *From, NestedNameSpecifier *Qualifier, NamedDecl *FoundDecl, NamedDecl *Member)
Cast a base object to a member's actual type.
Definition: SemaExpr.cpp:2982
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:7268
PragmaOptionsAlignKind
Definition: Sema.h:1786
@ POAK_Power
Definition: Sema.h:1790
@ POAK_Reset
Definition: Sema.h:1792
@ POAK_Packed
Definition: Sema.h:1789
@ POAK_Mac68k
Definition: Sema.h:1791
@ POAK_Natural
Definition: Sema.h:1788
@ POAK_Native
Definition: Sema.h:1787
void ActOnBlockStart(SourceLocation CaretLoc, Scope *CurScope)
ActOnBlockStart - This callback is invoked when a block literal is started.
Definition: SemaExpr.cpp:16177
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:1148
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:4843
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:7980
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:14792
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
bool CheckTemplateArgumentList(TemplateDecl *Template, SourceLocation TemplateLoc, TemplateArgumentListInfo &TemplateArgs, const DefaultArguments &DefaultArgs, bool PartialTemplateArgs, CheckTemplateArgumentInfo &CTAI, bool UpdateArgsWithConversions=true, bool *ConstraintsNotSatisfied=nullptr)
Check that the given template arguments can be provided to the given template, converting the argumen...
QualType BuiltinChangeSignedness(QualType BaseType, UTTKind UKind, SourceLocation Loc)
Definition: SemaType.cpp:9938
AssignConvertType CheckAssignmentConstraints(SourceLocation Loc, QualType LHSType, QualType RHSType)
CheckAssignmentConstraints - Perform type checking for assignment, argument passing,...
Definition: SemaExpr.cpp:9173
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:6451
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:4700
QualType PreferredConditionType(ConditionKind K) const
Definition: Sema.h:7501
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:9053
@ LOLR_ErrorNoDiagnostic
The lookup found no match but no diagnostic was issued.
Definition: Sema.h:9057
@ LOLR_Raw
The lookup found a single 'raw' literal operator, which expects a string literal containing the spell...
Definition: Sema.h:9063
@ LOLR_Error
The lookup resulted in an error.
Definition: Sema.h:9055
@ LOLR_Cooked
The lookup found a single 'cooked' literal operator, which expects a normal literal to be built and p...
Definition: Sema.h:9060
@ LOLR_StringTemplatePack
The lookup found an overload set of literal operator templates, which expect the character type and c...
Definition: Sema.h:9071
@ LOLR_Template
The lookup found an overload set of literal operator templates, which expect the characters of the sp...
Definition: Sema.h:9067
void ActOnPragmaWeakAlias(IdentifierInfo *WeakName, IdentifierInfo *AliasName, SourceLocation PragmaLoc, SourceLocation WeakNameLoc, SourceLocation AliasNameLoc)
ActOnPragmaWeakAlias - Called on well formed #pragma weak ident = ident.
Definition: SemaDecl.cpp:20294
sema::FunctionScopeInfo * getEnclosingFunction() const
Definition: Sema.cpp:2377
const ExpressionEvaluationContextRecord & parentEvaluationContext() const
Definition: Sema.h:6469
SemaLoongArch & LoongArch()
Definition: Sema.h:1088
void ActOnBlockArguments(SourceLocation CaretLoc, Declarator &ParamInfo, Scope *CurScope)
ActOnBlockArguments - This callback allows processing of block arguments.
Definition: SemaExpr.cpp:16206
QualType CheckRemainderOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, bool IsCompAssign=false)
Definition: SemaExpr.cpp:10644
CheckConstexprKind
Definition: Sema.h:5954
@ 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:13566
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:2736
OpaquePtr< TemplateName > TemplateTy
Definition: Sema.h:903
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)
unsigned GetDecompositionElementCount(QualType DecompType)
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:3058
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:14913
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:11086
static ConditionResult ConditionError()
Definition: Sema.h:7342
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:1168
ExprResult ActOnConvertVectorExpr(Expr *E, ParsedType ParsedDestTy, SourceLocation BuiltinLoc, SourceLocation RParenLoc)
ActOnConvertVectorExpr - create a new convert-vector expression from the provided arguments.
Definition: SemaExpr.cpp:6738
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:3006
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:13184
ExprResult checkUnknownAnyArg(SourceLocation callLoc, Expr *result, QualType &paramType)
Type-check an expression that's being passed to an __unknown_anytype parameter.
Definition: SemaExpr.cpp:20929
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:20015
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:5827
ExprResult ActOnBuiltinOffsetOf(Scope *S, SourceLocation BuiltinLoc, SourceLocation TypeLoc, ParsedType ParsedArgTy, ArrayRef< OffsetOfComponent > Components, SourceLocation RParenLoc)
Definition: SemaExpr.cpp:16120
SemaPseudoObject & PseudoObject()
Definition: Sema.h:1138
bool hasAnyUnrecoverableErrorsInThisFunction() const
Determine whether any errors occurred within this function/method/ block.
Definition: Sema.cpp:2338
StmtResult ActOnLabelStmt(SourceLocation IdentLoc, LabelDecl *TheDecl, SourceLocation ColonLoc, Stmt *SubStmt)
Definition: SemaStmt.cpp:608
ArrayRef< sema::FunctionScopeInfo * > getFunctionScopes() const
Definition: Sema.h:11071
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:4292
FullExprArg MakeFullExpr(Expr *Arg)
Definition: Sema.h:7298
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:7939
OpaquePtr< DeclGroupRef > DeclGroupPtrTy
Definition: Sema.h:902
static int getPrintable(int I)
Definition: Sema.h:14608
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:9323
bool checkMSInheritanceAttrOnDefinition(CXXRecordDecl *RD, SourceRange Range, bool BestCase, MSInheritanceModel SemanticSpelling)
void MarkDeducedTemplateParameters(const FunctionTemplateDecl *FunctionTemplate, llvm::SmallBitVector &Deduced)
Definition: Sema.h:12519
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:3378
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:17936
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:14613
PragmaClangSectionKind
pragma clang section kind
Definition: Sema.h:1416
@ PCSK_Invalid
Definition: Sema.h:1417
@ PCSK_BSS
Definition: Sema.h:1418
@ PCSK_Data
Definition: Sema.h:1419
@ PCSK_Text
Definition: Sema.h:1421
@ PCSK_Relro
Definition: Sema.h:1422
@ PCSK_Rodata
Definition: Sema.h:1420
ExprResult ActOnInitList(SourceLocation LBraceLoc, MultiExprArg InitArgList, SourceLocation RBraceLoc)
Definition: SemaExpr.cpp:7200
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:7807
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:16895
SemaARM & ARM()
Definition: Sema.h:1053
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:14611
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:8177
@ AFS_Both
Look for allocation functions in both the global scope and in the scope of the allocated class.
Definition: Sema.h:8185
@ AFS_Class
Only look for allocation functions in the scope of the allocated class.
Definition: Sema.h:8182
@ AFS_Global
Only look for allocation functions in the global scope.
Definition: Sema.h:8179
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:5346
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:1439
@ PSK_Push_Set
Definition: Sema.h:1445
@ PSK_Reset
Definition: Sema.h:1440
@ PSK_Pop_Set
Definition: Sema.h:1446
@ PSK_Show
Definition: Sema.h:1444
@ PSK_Pop
Definition: Sema.h:1443
@ PSK_Set
Definition: Sema.h:1441
@ PSK_Push
Definition: Sema.h:1442
StmtResult FinishCXXForRangeStmt(Stmt *ForRange, Stmt *Body)
FinishCXXForRangeStmt - Attach the body to a C++0x for-range statement.
Definition: SemaStmt.cpp:3201
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:8282
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:5020
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:1106
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:3585
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:4466
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:3391
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:3535
Base class for declarations which introduce a typedef-name.
Definition: Decl.h:3434
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:886
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:2784
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:1887
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:457
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:2828
@ CopyInit
[a = b], [a = {b}]
std::pair< llvm::PointerUnion< const TemplateTypeParmType *, NamedDecl *, ResolvedUnexpandedPackExpr * >, SourceLocation > UnexpandedParameterPack
Definition: Sema.h:238
@ 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:449
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:425
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< 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:367
@ 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:436
@ 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:242
SourceLocation PointerEndLoc
The end location for the first pointer declarator in the file.
Definition: Sema.h:249
SourceLocation PointerLoc
The first pointer declarator (of any pointer kind) in the file that does not have a corresponding nul...
Definition: Sema.h:245
bool SawTypeNullability
Whether we saw any type nullability annotations in the given file.
Definition: Sema.h:255
uint8_t PointerKind
Which kind of pointer declarator we saw.
Definition: Sema.h:252
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:2836
Contains a late templated function.
Definition: Sema.h:15227
CachedTokens Toks
Definition: Sema.h:15228
FPOptions FPO
Floating-point options in the point of definition.
Definition: Sema.h:15232
Decl * D
The template function declaration to be late parsed.
Definition: Sema.h:15230
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:1652
bool MatchingTTP
If true, assume these template arguments are the injected template arguments for a template template ...
Definition: Sema.h:11687
CheckTemplateArgumentInfo(const CheckTemplateArgumentInfo &)=delete
CheckTemplateArgumentInfo(bool PartialOrdering=false, bool MatchingTTP=false)
Definition: Sema.h:11668
bool PartialOrdering
The check is being performed in the context of partial ordering.
Definition: Sema.h:11680
SmallVector< TemplateArgument, 4 > CanonicalConverted
Definition: Sema.h:11677
CheckTemplateArgumentInfo & operator=(const CheckTemplateArgumentInfo &)=delete
A context in which code is being synthesized (where a source location alone is not sufficient to iden...
Definition: Sema.h:12692
SourceRange InstantiationRange
The source range that covers the construct that cause the instantiation, e.g., the template-id that c...
Definition: Sema.h:12856
bool SavedInNonInstantiationSFINAEContext
Was the enclosing context a non-instantiation SFINAE context?
Definition: Sema.h:12809
const TemplateArgument * TemplateArgs
The list of template arguments we are substituting, if they are not part of the entity.
Definition: Sema.h:12825
sema::TemplateDeductionInfo * DeductionInfo
The template deduction info object associated with the substitution or checking of explicit or deduce...
Definition: Sema.h:12851
ArrayRef< TemplateArgument > template_arguments() const
Definition: Sema.h:12844
NamedDecl * Template
The template (or partial specialization) in which we are performing the instantiation,...
Definition: Sema.h:12820
SourceLocation PointOfInstantiation
The point of instantiation or synthesis within the source code.
Definition: Sema.h:12812
unsigned NumCallArgs
The number of expressions in CallArgs.
Definition: Sema.h:12838
const Expr *const * CallArgs
The list of argument expressions in a synthesized call.
Definition: Sema.h:12828
unsigned NumTemplateArgs
The number of template arguments in TemplateArgs.
Definition: Sema.h:12835
SynthesisKind
The kind of template instantiation we are performing.
Definition: Sema.h:12694
@ MarkingClassDllexported
We are marking a class as __dllexport.
Definition: Sema.h:12786
@ DefaultTemplateArgumentInstantiation
We are instantiating a default argument for a template parameter.
Definition: Sema.h:12704
@ ExplicitTemplateArgumentSubstitution
We are substituting explicit template arguments provided for a function template.
Definition: Sema.h:12713
@ DefaultTemplateArgumentChecking
We are checking the validity of a default template argument that has been used when naming a template...
Definition: Sema.h:12732
@ InitializingStructuredBinding
We are initializing a structured binding.
Definition: Sema.h:12783
@ ExceptionSpecInstantiation
We are instantiating the exception specification for a function template which was deferred until it ...
Definition: Sema.h:12740
@ NestedRequirementConstraintsCheck
We are checking the satisfaction of a nested requirement of a requires expression.
Definition: Sema.h:12747
@ BuildingBuiltinDumpStructCall
We are building an implied call from __builtin_dump_struct.
Definition: Sema.h:12790
@ DefiningSynthesizedFunction
We are defining a synthesized function (such as a defaulted special member).
Definition: Sema.h:12758
@ Memoization
Added for Template instantiation observation.
Definition: Sema.h:12796
@ LambdaExpressionSubstitution
We are substituting into a lambda expression.
Definition: Sema.h:12723
@ TypeAliasTemplateInstantiation
We are instantiating a type alias template declaration.
Definition: Sema.h:12802
@ BuildingDeductionGuides
We are building deduction guides for a class.
Definition: Sema.h:12799
@ PartialOrderingTTP
We are performing partial ordering for template template parameters.
Definition: Sema.h:12805
@ DeducedTemplateArgumentSubstitution
We are substituting template argument determined as part of template argument deduction for either a ...
Definition: Sema.h:12720
@ PriorTemplateArgumentSubstitution
We are substituting prior template arguments into a new template parameter.
Definition: Sema.h:12728
@ ExceptionSpecEvaluation
We are computing the exception specification for a defaulted special member function.
Definition: Sema.h:12736
@ TemplateInstantiation
We are instantiating a template declaration.
Definition: Sema.h:12697
@ DeclaringSpecialMember
We are declaring an implicit special member function.
Definition: Sema.h:12750
@ DeclaringImplicitEqualityComparison
We are declaring an implicit 'operator==' for a defaulted 'operator<=>'.
Definition: Sema.h:12754
@ DefaultFunctionArgumentInstantiation
We are instantiating a default argument for a function.
Definition: Sema.h:12709
@ RewritingOperatorAsSpaceship
We are rewriting a comparison operator in terms of an operator<=>.
Definition: Sema.h:12780
@ RequirementInstantiation
We are instantiating a requirement of a requires expression.
Definition: Sema.h:12743
Decl * Entity
The entity that is being synthesized.
Definition: Sema.h:12815
CXXSpecialMemberKind SpecialMember
The special member being declared or defined.
Definition: Sema.h:12841
ConstraintEvalRAII(InstTy &TI)
Definition: Sema.h:13377
InitializationContext(SourceLocation Loc, ValueDecl *Decl, DeclContext *Context)
Definition: Sema.h:6387
Data structure used to record current or nested expression evaluation contexts.
Definition: Sema.h:6297
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:6329
llvm::SmallPtrSet< const Expr *, 8 > PossibleDerefs
Definition: Sema.h:6331
bool InLifetimeExtendingContext
Whether we are currently in a context in which all temporaries must be lifetime-extended,...
Definition: Sema.h:6377
Decl * ManglingContextDecl
The declaration that provides context for lambda expressions and block literals if the normal declara...
Definition: Sema.h:6321
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:6325
SmallVector< Expr *, 2 > VolatileAssignmentLHSs
Expressions appearing as the LHS of a volatile assignment in this context.
Definition: Sema.h:6336
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:6344
llvm::SmallVector< ImmediateInvocationCandidate, 4 > ImmediateInvocationCandidates
Set of candidates for starting an immediate invocation.
Definition: Sema.h:6340
SmallVector< MaterializeTemporaryExpr *, 8 > ForRangeLifetimeExtendTemps
P2718R0 - Lifetime extension in range-based for loops.
Definition: Sema.h:6350
SmallVector< LambdaExpr *, 2 > Lambdas
The lambdas that are present within this context, if it is indeed an unevaluated context.
Definition: Sema.h:6316
ExpressionKind
Describes whether we are in an expression constext which we have to handle differently.
Definition: Sema.h:6354
bool RebuildDefaultArgOrDefaultInit
Whether we should rebuild CXXDefaultArgExpr and CXXDefaultInitExpr.
Definition: Sema.h:6380
CleanupInfo ParentCleanup
Whether the enclosing context needed a cleanup.
Definition: Sema.h:6302
unsigned NumTypos
The number of typos encountered during this expression evaluation context (i.e.
Definition: Sema.h:6310
std::optional< InitializationContext > DelayedDefaultInitializationContext
Definition: Sema.h:6397
ExpressionEvaluationContextRecord(ExpressionEvaluationContext Context, unsigned NumCleanupObjects, CleanupInfo ParentCleanup, Decl *ManglingContextDecl, ExpressionKind ExprContext)
Definition: Sema.h:6399
ExpressionEvaluationContext Context
The expression evaluation context.
Definition: Sema.h:6299
unsigned NumCleanupObjects
The number of active cleanup objects when we entered this expression evaluation context.
Definition: Sema.h:6306
FormatArgumentPassingKind ArgPassingKind
Definition: Sema.h:2172
std::optional< FunctionEffectWithCondition > Old
Definition: Sema.h:15134
StringRef effectName() const
Definition: Sema.h:15138
OverrideResult
Describes the result of effects differing between a base class's virtual method and an overriding met...
Definition: Sema.h:15146
std::optional< FunctionEffectWithCondition > New
Definition: Sema.h:15136
FunctionEffect::Kind EffectKind
Definition: Sema.h:15131
An RAII helper that pops function a function scope on exit.
Definition: Sema.h:931
A stack object to be created when performing template instantiation.
Definition: Sema.h:12880
bool isInvalid() const
Determines whether we have exceeded the maximum recursive template instantiations.
Definition: Sema.h:13040
bool isAlreadyInstantiating() const
Determine whether we are already instantiating this specialization in some surrounding active instant...
Definition: Sema.h:13044
LocalInstantiationScope * Scope
Definition: Sema.h:13685
LateInstantiatedAttribute(const Attr *A, LocalInstantiationScope *S, Decl *D)
Definition: Sema.h:13688
bool isMoveEligible() const
Definition: Sema.h:10832
bool isCopyElidable() const
Definition: Sema.h:10833
const VarDecl * Candidate
Definition: Sema.h:10827
Keeps information about an identifier in a nested-name-spec.
Definition: Sema.h:2813
IdentifierInfo * Identifier
The identifier preceding the '::'.
Definition: Sema.h:2819
NestedNameSpecInfo(IdentifierInfo *II, SourceLocation IdLoc, SourceLocation ColonColonLoc, ParsedType ObjectType=ParsedType())
Creates info object for the most typical case.
Definition: Sema.h:2828
SourceLocation IdentifierLoc
The location of the identifier.
Definition: Sema.h:2822
SourceLocation CCLoc
The location of the '::'.
Definition: Sema.h:2825
ParsedType ObjectType
The type of the object, if we're parsing nested-name-specifier in a member access expression.
Definition: Sema.h:2816
NestedNameSpecInfo(IdentifierInfo *II, SourceLocation IdLoc, SourceLocation ColonColonLoc, QualType ObjectType)
Definition: Sema.h:2834
SourceLocation LocEnd
Definition: Sema.h:7074
IdentifierInfo * IdentInfo
Definition: Sema.h:7077
brief A function argument from which we performed template argument
Definition: Sema.h:12279
OriginalCallArg(QualType OriginalParamType, bool DecomposedParam, unsigned ArgIdx, QualType OriginalArgType)
Definition: Sema.h:12280
This an attribute introduced by #pragma clang attribute.
Definition: Sema.h:1708
SmallVector< attr::SubjectMatchRule, 4 > MatchRules
Definition: Sema.h:1711
A push'd group of PragmaAttributeEntries.
Definition: Sema.h:1716
SourceLocation Loc
The location of the push attribute.
Definition: Sema.h:1718
SmallVector< PragmaAttributeEntry, 2 > Entries
Definition: Sema.h:1721
const IdentifierInfo * Namespace
The namespace of this push group.
Definition: Sema.h:1720
SourceLocation PragmaLocation
Definition: Sema.h:1430
PragmaMsStackAction Action
Definition: Sema.h:1450
Slot(llvm::StringRef StackSlotLabel, ValueType Value, SourceLocation PragmaLocation, SourceLocation PragmaPushLocation)
Definition: Sema.h:1563
llvm::StringRef StackSlotLabel
Definition: Sema.h:1559
SourceLocation PragmaLocation
Definition: Sema.h:1561
SourceLocation PragmaPushLocation
Definition: Sema.h:1562
ValueType CurrentValue
Definition: Sema.h:1633
void SentinelAction(PragmaMsStackAction Action, StringRef Label)
Definition: Sema.h:1619
bool hasValue() const
Definition: Sema.h:1629
SmallVector< Slot, 2 > Stack
Definition: Sema.h:1631
ValueType DefaultValue
Definition: Sema.h:1632
SourceLocation CurrentPragmaLocation
Definition: Sema.h:1634
PragmaStack(const ValueType &Default)
Definition: Sema.h:1626
void Act(SourceLocation PragmaLocation, PragmaMsStackAction Action, llvm::StringRef StackSlotLabel, ValueType Value)
Definition: Sema.h:1570
ProcessDeclAttributeOptions WithIgnoreTypeAttributes(bool Val)
Definition: Sema.h:4648
ProcessDeclAttributeOptions WithIncludeCXX11Attributes(bool Val)
Definition: Sema.h:4642
ReferenceConversions
The conversions that would be performed on an lvalue of type T2 when binding a reference of type T1 t...
Definition: Sema.h:10146
Abstract class used to diagnose incomplete types.
Definition: Sema.h:7872
virtual void diagnose(Sema &S, SourceLocation Loc, QualType T)=0
virtual ~TypeDiagnoser()
Definition: Sema.h:7876
TypeTagData(QualType Type, bool LayoutCompatible, bool MustBeNull)
Definition: Sema.h:2221
unsigned LayoutCompatible
If true, Type should be compared with other expression's types for layout-compatibility.
Definition: Sema.h:2230
std::unique_ptr< TypoCorrectionConsumer > Consumer
Definition: Sema.h:9505
TypoDiagnosticGenerator DiagHandler
Definition: Sema.h:9506
TypoRecoveryCallback RecoveryHandler
Definition: Sema.h:9507
bool CheckSameAsPrevious
Definition: Sema.h:353
NamedDecl * Previous
Definition: Sema.h:354
SkipBodyInfo()=default
NamedDecl * New
Definition: Sema.h:355
Information about a template-id annotation token.