clang  9.0.0
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 
17 #include "clang/AST/Attr.h"
18 #include "clang/AST/Availability.h"
20 #include "clang/AST/DeclTemplate.h"
22 #include "clang/AST/Expr.h"
23 #include "clang/AST/ExprCXX.h"
24 #include "clang/AST/ExprObjC.h"
26 #include "clang/AST/LocInfoType.h"
28 #include "clang/AST/NSAPI.h"
30 #include "clang/AST/StmtCXX.h"
31 #include "clang/AST/TypeLoc.h"
32 #include "clang/AST/TypeOrdering.h"
34 #include "clang/Basic/Module.h"
37 #include "clang/Basic/Specifiers.h"
39 #include "clang/Basic/TypeTraits.h"
41 #include "clang/Sema/CleanupInfo.h"
42 #include "clang/Sema/DeclSpec.h"
46 #include "clang/Sema/Ownership.h"
47 #include "clang/Sema/Scope.h"
49 #include "clang/Sema/Weak.h"
50 #include "llvm/ADT/ArrayRef.h"
51 #include "llvm/ADT/Optional.h"
52 #include "llvm/ADT/SetVector.h"
53 #include "llvm/ADT/SmallBitVector.h"
54 #include "llvm/ADT/SmallPtrSet.h"
55 #include "llvm/ADT/SmallVector.h"
56 #include "llvm/ADT/TinyPtrVector.h"
57 #include <deque>
58 #include <memory>
59 #include <string>
60 #include <vector>
61 
62 namespace llvm {
63  class APSInt;
64  template <typename ValueT> struct DenseMapInfo;
65  template <typename ValueT, typename ValueInfoT> class DenseSet;
66  class SmallBitVector;
67  struct InlineAsmIdentifierInfo;
68 }
69 
70 namespace clang {
71  class ADLResult;
72  class ASTConsumer;
73  class ASTContext;
74  class ASTMutationListener;
75  class ASTReader;
76  class ASTWriter;
77  class ArrayType;
78  class ParsedAttr;
79  class BindingDecl;
80  class BlockDecl;
81  class CapturedDecl;
82  class CXXBasePath;
83  class CXXBasePaths;
84  class CXXBindTemporaryExpr;
86  class CXXConstructorDecl;
87  class CXXConversionDecl;
88  class CXXDeleteExpr;
89  class CXXDestructorDecl;
90  class CXXFieldCollector;
91  class CXXMemberCallExpr;
92  class CXXMethodDecl;
93  class CXXScopeSpec;
94  class CXXTemporary;
95  class CXXTryStmt;
96  class CallExpr;
97  class ClassTemplateDecl;
98  class ClassTemplatePartialSpecializationDecl;
99  class ClassTemplateSpecializationDecl;
100  class VarTemplatePartialSpecializationDecl;
101  class CodeCompleteConsumer;
102  class CodeCompletionAllocator;
103  class CodeCompletionTUInfo;
104  class CodeCompletionResult;
105  class CoroutineBodyStmt;
106  class Decl;
107  class DeclAccessPair;
108  class DeclContext;
109  class DeclRefExpr;
110  class DeclaratorDecl;
111  class DeducedTemplateArgument;
112  class DependentDiagnostic;
113  class DesignatedInitExpr;
114  class Designation;
115  class EnableIfAttr;
116  class EnumConstantDecl;
117  class Expr;
118  class ExtVectorType;
119  class FormatAttr;
120  class FriendDecl;
121  class FunctionDecl;
122  class FunctionProtoType;
123  class FunctionTemplateDecl;
124  class ImplicitConversionSequence;
126  class InitListExpr;
127  class InitializationKind;
128  class InitializationSequence;
129  class InitializedEntity;
130  class IntegerLiteral;
131  class LabelStmt;
132  class LambdaExpr;
133  class LangOptions;
134  class LocalInstantiationScope;
135  class LookupResult;
136  class MacroInfo;
138  class ModuleLoader;
139  class MultiLevelTemplateArgumentList;
140  class NamedDecl;
141  class ObjCCategoryDecl;
142  class ObjCCategoryImplDecl;
143  class ObjCCompatibleAliasDecl;
144  class ObjCContainerDecl;
145  class ObjCImplDecl;
146  class ObjCImplementationDecl;
147  class ObjCInterfaceDecl;
148  class ObjCIvarDecl;
149  template <class T> class ObjCList;
150  class ObjCMessageExpr;
151  class ObjCMethodDecl;
152  class ObjCPropertyDecl;
153  class ObjCProtocolDecl;
154  class OMPThreadPrivateDecl;
155  class OMPRequiresDecl;
156  class OMPDeclareReductionDecl;
157  class OMPDeclareSimdDecl;
158  class OMPClause;
159  struct OMPVarListLocTy;
160  struct OverloadCandidate;
161  class OverloadCandidateSet;
162  class OverloadExpr;
163  class ParenListExpr;
164  class ParmVarDecl;
165  class Preprocessor;
166  class PseudoDestructorTypeStorage;
167  class PseudoObjectExpr;
168  class QualType;
169  class StandardConversionSequence;
170  class Stmt;
171  class StringLiteral;
172  class SwitchStmt;
173  class TemplateArgument;
174  class TemplateArgumentList;
175  class TemplateArgumentLoc;
176  class TemplateDecl;
177  class TemplateInstantiationCallback;
178  class TemplateParameterList;
179  class TemplatePartialOrderingContext;
180  class TemplateTemplateParmDecl;
181  class Token;
182  class TypeAliasDecl;
183  class TypedefDecl;
184  class TypedefNameDecl;
185  class TypeLoc;
186  class TypoCorrectionConsumer;
187  class UnqualifiedId;
188  class UnresolvedLookupExpr;
189  class UnresolvedMemberExpr;
190  class UnresolvedSetImpl;
191  class UnresolvedSetIterator;
192  class UsingDecl;
193  class UsingShadowDecl;
194  class ValueDecl;
195  class VarDecl;
196  class VarTemplateSpecializationDecl;
197  class VisibilityAttr;
198  class VisibleDeclConsumer;
199  class IndirectFieldDecl;
200  struct DeductionFailureInfo;
201  class TemplateSpecCandidateSet;
202 
203 namespace sema {
204  class AccessedEntity;
205  class BlockScopeInfo;
206  class Capture;
207  class CapturedRegionScopeInfo;
208  class CapturingScopeInfo;
209  class CompoundScopeInfo;
210  class DelayedDiagnostic;
211  class DelayedDiagnosticPool;
212  class FunctionScopeInfo;
213  class LambdaScopeInfo;
214  class PossiblyUnreachableDiag;
215  class SemaPPCallbacks;
216  class TemplateDeductionInfo;
217 }
218 
219 namespace threadSafety {
220  class BeforeSet;
221  void threadSafetyCleanup(BeforeSet* Cache);
222 }
223 
224 // FIXME: No way to easily map from TemplateTypeParmTypes to
225 // TemplateTypeParmDecls, so we have this horrible PointerUnion.
226 typedef std::pair<llvm::PointerUnion<const TemplateTypeParmType*, NamedDecl*>,
228 
229 /// Describes whether we've seen any nullability information for the given
230 /// file.
232  /// The first pointer declarator (of any pointer kind) in the file that does
233  /// not have a corresponding nullability annotation.
235 
236  /// The end location for the first pointer declarator in the file. Used for
237  /// placing fix-its.
239 
240  /// Which kind of pointer declarator we saw.
241  uint8_t PointerKind;
242 
243  /// Whether we saw any type nullability annotations in the given file.
244  bool SawTypeNullability = false;
245 };
246 
247 /// A mapping from file IDs to a record of whether we've seen nullability
248 /// information in that file.
250  /// A mapping from file IDs to the nullability information for each file ID.
251  llvm::DenseMap<FileID, FileNullability> Map;
252 
253  /// A single-element cache based on the file ID.
254  struct {
257  } Cache;
258 
259 public:
261  // Check the single-element cache.
262  if (file == Cache.File)
263  return Cache.Nullability;
264 
265  // It's not in the single-element cache; flush the cache if we have one.
266  if (!Cache.File.isInvalid()) {
267  Map[Cache.File] = Cache.Nullability;
268  }
269 
270  // Pull this entry into the cache.
271  Cache.File = file;
272  Cache.Nullability = Map[file];
273  return Cache.Nullability;
274  }
275 };
276 
277 /// Keeps track of expected type during expression parsing. The type is tied to
278 /// a particular token, all functions that update or consume the type take a
279 /// start location of the token they are looking at as a parameter. This allows
280 /// to avoid updating the type on hot paths in the parser.
282 public:
283  PreferredTypeBuilder() = default;
284  explicit PreferredTypeBuilder(QualType Type) : Type(Type) {}
285 
286  void enterCondition(Sema &S, SourceLocation Tok);
287  void enterReturn(Sema &S, SourceLocation Tok);
288  void enterVariableInit(SourceLocation Tok, Decl *D);
289  /// Computing a type for the function argument may require running
290  /// overloading, so we postpone its computation until it is actually needed.
291  ///
292  /// Clients should be very careful when using this funciton, as it stores a
293  /// function_ref, clients should make sure all calls to get() with the same
294  /// location happen while function_ref is alive.
295  void enterFunctionArgument(SourceLocation Tok,
296  llvm::function_ref<QualType()> ComputeType);
297 
298  void enterParenExpr(SourceLocation Tok, SourceLocation LParLoc);
299  void enterUnary(Sema &S, SourceLocation Tok, tok::TokenKind OpKind,
300  SourceLocation OpLoc);
301  void enterBinary(Sema &S, SourceLocation Tok, Expr *LHS, tok::TokenKind Op);
302  void enterMemAccess(Sema &S, SourceLocation Tok, Expr *Base);
303  void enterSubscript(Sema &S, SourceLocation Tok, Expr *LHS);
304  /// Handles all type casts, including C-style cast, C++ casts, etc.
305  void enterTypeCast(SourceLocation Tok, QualType CastType);
306 
308  if (Tok != ExpectedLoc)
309  return QualType();
310  if (!Type.isNull())
311  return Type;
312  if (ComputeType)
313  return ComputeType();
314  return QualType();
315  }
316 
317 private:
318  /// Start position of a token for which we store expected type.
319  SourceLocation ExpectedLoc;
320  /// Expected type for a token starting at ExpectedLoc.
321  QualType Type;
322  /// A function to compute expected type at ExpectedLoc. It is only considered
323  /// if Type is null.
324  llvm::function_ref<QualType()> ComputeType;
325 };
326 
327 /// Sema - This implements semantic analysis and AST building for C.
328 class Sema {
329  Sema(const Sema &) = delete;
330  void operator=(const Sema &) = delete;
331 
332  ///Source of additional semantic information.
333  ExternalSemaSource *ExternalSource;
334 
335  ///Whether Sema has generated a multiplexer and has to delete it.
336  bool isMultiplexExternalSource;
337 
338  static bool mightHaveNonExternalLinkage(const DeclaratorDecl *FD);
339 
340  bool isVisibleSlow(const NamedDecl *D);
341 
342  /// Determine whether two declarations should be linked together, given that
343  /// the old declaration might not be visible and the new declaration might
344  /// not have external linkage.
345  bool shouldLinkPossiblyHiddenDecl(const NamedDecl *Old,
346  const NamedDecl *New) {
347  if (isVisible(Old))
348  return true;
349  // See comment in below overload for why it's safe to compute the linkage
350  // of the new declaration here.
351  if (New->isExternallyDeclarable()) {
352  assert(Old->isExternallyDeclarable() &&
353  "should not have found a non-externally-declarable previous decl");
354  return true;
355  }
356  return false;
357  }
358  bool shouldLinkPossiblyHiddenDecl(LookupResult &Old, const NamedDecl *New);
359 
360  void setupImplicitSpecialMemberType(CXXMethodDecl *SpecialMem,
361  QualType ResultTy,
362  ArrayRef<QualType> Args);
363 
364 public:
368 
371 
378 
379  /// Flag indicating whether or not to collect detailed statistics.
381 
382  /// Code-completion consumer.
384 
385  /// CurContext - This is the current declaration context of parsing.
387 
388  /// Generally null except when we temporarily switch decl contexts,
389  /// like in \see ActOnObjCTemporaryExitContainerContext.
391 
392  /// VAListTagName - The declaration name corresponding to __va_list_tag.
393  /// This is used as part of a hack to omit that class from ADL results.
395 
396  bool MSStructPragmaOn; // True when \#pragma ms_struct on
397 
398  /// Controls member pointer representation format under the MS ABI.
401 
402  /// Stack of active SEH __finally scopes. Can be empty.
404 
405  /// Source location for newly created implicit MSInheritanceAttrs
407 
408  /// pragma clang section kind
410  PCSK_Invalid = 0,
411  PCSK_BSS = 1,
412  PCSK_Data = 2,
413  PCSK_Rodata = 3,
414  PCSK_Text = 4
415  };
416 
418  PCSA_Set = 0,
419  PCSA_Clear = 1
420  };
421 
423  std::string SectionName;
424  bool Valid = false;
426 
427  void Act(SourceLocation PragmaLocation,
429  StringLiteral* Name);
430  };
431 
436 
438  PSK_Reset = 0x0, // #pragma ()
439  PSK_Set = 0x1, // #pragma (value)
440  PSK_Push = 0x2, // #pragma (push[, id])
441  PSK_Pop = 0x4, // #pragma (pop[, id])
442  PSK_Show = 0x8, // #pragma (show) -- only for "pack"!
443  PSK_Push_Set = PSK_Push | PSK_Set, // #pragma (push[, id], value)
444  PSK_Pop_Set = PSK_Pop | PSK_Set, // #pragma (pop[, id], value)
445  };
446 
447  template<typename ValueType>
448  struct PragmaStack {
449  struct Slot {
450  llvm::StringRef StackSlotLabel;
451  ValueType Value;
454  Slot(llvm::StringRef StackSlotLabel, ValueType Value,
455  SourceLocation PragmaLocation, SourceLocation PragmaPushLocation)
456  : StackSlotLabel(StackSlotLabel), Value(Value),
457  PragmaLocation(PragmaLocation),
458  PragmaPushLocation(PragmaPushLocation) {}
459  };
460  void Act(SourceLocation PragmaLocation,
461  PragmaMsStackAction Action,
462  llvm::StringRef StackSlotLabel,
463  ValueType Value);
464 
465  // MSVC seems to add artificial slots to #pragma stacks on entering a C++
466  // method body to restore the stacks on exit, so it works like this:
467  //
468  // struct S {
469  // #pragma <name>(push, InternalPragmaSlot, <current_pragma_value>)
470  // void Method {}
471  // #pragma <name>(pop, InternalPragmaSlot)
472  // };
473  //
474  // It works even with #pragma vtordisp, although MSVC doesn't support
475  // #pragma vtordisp(push [, id], n)
476  // syntax.
477  //
478  // Push / pop a named sentinel slot.
479  void SentinelAction(PragmaMsStackAction Action, StringRef Label) {
480  assert((Action == PSK_Push || Action == PSK_Pop) &&
481  "Can only push / pop #pragma stack sentinels!");
482  Act(CurrentPragmaLocation, Action, Label, CurrentValue);
483  }
484 
485  // Constructors.
486  explicit PragmaStack(const ValueType &Default)
487  : DefaultValue(Default), CurrentValue(Default) {}
488 
489  bool hasValue() const { return CurrentValue != DefaultValue; }
490 
492  ValueType DefaultValue; // Value used for PSK_Reset action.
493  ValueType CurrentValue;
495  };
496  // FIXME: We should serialize / deserialize these if they occur in a PCH (but
497  // we shouldn't do so if they're in a module).
498 
499  /// Whether to insert vtordisps prior to virtual bases in the Microsoft
500  /// C++ ABI. Possible values are 0, 1, and 2, which mean:
501  ///
502  /// 0: Suppress all vtordisps
503  /// 1: Insert vtordisps in the presence of vbase overrides and non-trivial
504  /// structors
505  /// 2: Always insert vtordisps to support RTTI on partially constructed
506  /// objects
508  // #pragma pack.
509  // Sentinel to represent when the stack is set to mac68k alignment.
510  static const unsigned kMac68kAlignmentSentinel = ~0U;
512  // The current #pragma pack values and locations at each #include.
514  unsigned CurrentValue;
516  bool HasNonDefaultValue, ShouldWarnOnInclude;
517  };
519  // Segment #pragmas.
524 
525  // RAII object to push / pop sentinel slots for all MS #pragma stacks.
526  // Actions should be performed only if we enter / exit a C++ method body.
528  public:
529  PragmaStackSentinelRAII(Sema &S, StringRef SlotLabel, bool ShouldAct);
531 
532  private:
533  Sema &S;
534  StringRef SlotLabel;
535  bool ShouldAct;
536  };
537 
538  /// A mapping that describes the nullability we've seen in each header file.
540 
541  /// Last section used with #pragma init_seg.
544 
545  /// VisContext - Manages the stack for \#pragma GCC visibility.
546  void *VisContext; // Really a "PragmaVisStack*"
547 
548  /// This an attribute introduced by \#pragma clang attribute.
553  bool IsUsed;
554  };
555 
556  /// A push'd group of PragmaAttributeEntries.
558  /// The location of the push attribute.
560  /// The namespace of this push group.
563  };
564 
566 
567  /// The declaration that is currently receiving an attribute from the
568  /// #pragma attribute stack.
570 
571  /// This represents the last location of a "#pragma clang optimize off"
572  /// directive if such a directive has not been closed by an "on" yet. If
573  /// optimizations are currently "on", this is set to an invalid location.
575 
576  /// Flag indicating if Sema is building a recovery call expression.
577  ///
578  /// This flag is used to avoid building recovery call expressions
579  /// if Sema is already doing so, which would cause infinite recursions.
581 
582  /// Used to control the generation of ExprWithCleanups.
584 
585  /// ExprCleanupObjects - This is the stack of objects requiring
586  /// cleanup that are created by the current full expression. The
587  /// element type here is ExprWithCleanups::Object.
589 
590  /// Store a set of either DeclRefExprs or MemberExprs that contain a reference
591  /// to a variable (constant) that may or may not be odr-used in this Expr, and
592  /// we won't know until all lvalue-to-rvalue and discarded value conversions
593  /// have been applied to all subexpressions of the enclosing full expression.
594  /// This is cleared at the end of each full expression.
595  using MaybeODRUseExprSet = llvm::SmallPtrSet<Expr *, 2>;
597 
598  std::unique_ptr<sema::FunctionScopeInfo> CachedFunctionScope;
599 
600  /// Stack containing information about each of the nested
601  /// function, block, and method scopes that are currently active.
603 
605  &ExternalSemaSource::ReadExtVectorDecls, 2, 2>
607 
608  /// ExtVectorDecls - This is a list all the extended vector types. This allows
609  /// us to associate a raw vector type with one of the ext_vector type names.
610  /// This is only necessary for issuing pretty diagnostics.
612 
613  /// FieldCollector - Collects CXXFieldDecls during parsing of C++ classes.
614  std::unique_ptr<CXXFieldCollector> FieldCollector;
615 
617 
618  /// Set containing all declared private fields that are not used.
619  NamedDeclSetType UnusedPrivateFields;
620 
621  /// Set containing all typedefs that are likely unused.
624 
625  /// Delete-expressions to be analyzed at the end of translation unit
626  ///
627  /// This list contains class members, and locations of delete-expressions
628  /// that could not be proven as to whether they mismatch with new-expression
629  /// used in initializer of the field.
630  typedef std::pair<SourceLocation, bool> DeleteExprLoc;
632  llvm::MapVector<FieldDecl *, DeleteLocs> DeleteExprs;
633 
634  typedef llvm::SmallPtrSet<const CXXRecordDecl*, 8> RecordDeclSetTy;
635 
636  /// PureVirtualClassDiagSet - a set of class declarations which we have
637  /// emitted a list of pure virtual functions. Used to prevent emitting the
638  /// same list more than once.
639  std::unique_ptr<RecordDeclSetTy> PureVirtualClassDiagSet;
640 
641  /// ParsingInitForAutoVars - a set of declarations with auto types for which
642  /// we are currently parsing the initializer.
643  llvm::SmallPtrSet<const Decl*, 4> ParsingInitForAutoVars;
644 
645  /// Look for a locally scoped extern "C" declaration by the given name.
646  NamedDecl *findLocallyScopedExternCDecl(DeclarationName Name);
647 
648  typedef LazyVector<VarDecl *, ExternalSemaSource,
649  &ExternalSemaSource::ReadTentativeDefinitions, 2, 2>
651 
652  /// All the tentative definitions encountered in the TU.
654 
655  typedef LazyVector<const DeclaratorDecl *, ExternalSemaSource,
656  &ExternalSemaSource::ReadUnusedFileScopedDecls, 2, 2>
658 
659  /// The set of file scoped decls seen so far that have not been used
660  /// and must warn if not used. Only contains the first declaration.
662 
663  typedef LazyVector<CXXConstructorDecl *, ExternalSemaSource,
664  &ExternalSemaSource::ReadDelegatingConstructors, 2, 2>
666 
667  /// All the delegating constructors seen so far in the file, used for
668  /// cycle detection at the end of the TU.
670 
671  /// All the overriding functions seen during a class definition
672  /// that had their exception spec checks delayed, plus the overridden
673  /// function.
676 
677  /// All the function redeclarations seen during a class definition that had
678  /// their exception spec checks delayed, plus the prior declaration they
679  /// should be checked against. Except during error recovery, the new decl
680  /// should always be a friend declaration, as that's the only valid way to
681  /// redeclare a special member before its class is complete.
684 
685  typedef llvm::MapVector<const FunctionDecl *,
686  std::unique_ptr<LateParsedTemplate>>
689 
690  /// Callback to the parser to parse templated functions when needed.
691  typedef void LateTemplateParserCB(void *P, LateParsedTemplate &LPT);
692  typedef void LateTemplateParserCleanupCB(void *P);
693  LateTemplateParserCB *LateTemplateParser;
694  LateTemplateParserCleanupCB *LateTemplateParserCleanup;
696 
697  void SetLateTemplateParser(LateTemplateParserCB *LTP,
698  LateTemplateParserCleanupCB *LTPCleanup,
699  void *P) {
700  LateTemplateParser = LTP;
701  LateTemplateParserCleanup = LTPCleanup;
702  OpaqueParser = P;
703  }
704 
705  class DelayedDiagnostics;
706 
708  sema::DelayedDiagnosticPool *SavedPool;
710  };
713 
714  /// A class which encapsulates the logic for delaying diagnostics
715  /// during parsing and other processing.
717  /// The current pool of diagnostics into which delayed
718  /// diagnostics should go.
720 
721  public:
722  DelayedDiagnostics() : CurPool(nullptr) {}
723 
724  /// Adds a delayed diagnostic.
725  void add(const sema::DelayedDiagnostic &diag); // in DelayedDiagnostic.h
726 
727  /// Determines whether diagnostics should be delayed.
728  bool shouldDelayDiagnostics() { return CurPool != nullptr; }
729 
730  /// Returns the current delayed-diagnostics pool.
732  return CurPool;
733  }
734 
735  /// Enter a new scope. Access and deprecation diagnostics will be
736  /// collected in this pool.
739  state.SavedPool = CurPool;
740  CurPool = &pool;
741  return state;
742  }
743 
744  /// Leave a delayed-diagnostic state that was previously pushed.
745  /// Do not emit any of the diagnostics. This is performed as part
746  /// of the bookkeeping of popping a pool "properly".
748  CurPool = state.SavedPool;
749  }
750 
751  /// Enter a new scope where access and deprecation diagnostics are
752  /// not delayed.
755  state.SavedPool = CurPool;
756  CurPool = nullptr;
757  return state;
758  }
759 
760  /// Undo a previous pushUndelayed().
762  assert(CurPool == nullptr);
763  CurPool = state.SavedPool;
764  }
766 
767  /// A RAII object to temporarily push a declaration context.
768  class ContextRAII {
769  private:
770  Sema &S;
771  DeclContext *SavedContext;
772  ProcessingContextState SavedContextState;
773  QualType SavedCXXThisTypeOverride;
774 
775  public:
776  ContextRAII(Sema &S, DeclContext *ContextToPush, bool NewThisContext = true)
777  : S(S), SavedContext(S.CurContext),
778  SavedContextState(S.DelayedDiagnostics.pushUndelayed()),
779  SavedCXXThisTypeOverride(S.CXXThisTypeOverride)
780  {
781  assert(ContextToPush && "pushing null context");
782  S.CurContext = ContextToPush;
783  if (NewThisContext)
785  }
786 
787  void pop() {
788  if (!SavedContext) return;
789  S.CurContext = SavedContext;
790  S.DelayedDiagnostics.popUndelayed(SavedContextState);
791  S.CXXThisTypeOverride = SavedCXXThisTypeOverride;
792  SavedContext = nullptr;
793  }
794 
796  pop();
797  }
798  };
799 
800  /// Used to change context to isConstantEvaluated without pushing a heavy
801  /// ExpressionEvaluationContextRecord object.
803 
805  return ExprEvalContexts.back().isConstantEvaluated() ||
806  isConstantEvaluatedOverride;
807  }
808 
809  /// RAII object to handle the state changes required to synthesize
810  /// a function body.
812  Sema &S;
813  Sema::ContextRAII SavedContext;
814  bool PushedCodeSynthesisContext = false;
815 
816  public:
818  : S(S), SavedContext(S, DC) {
819  S.PushFunctionScope();
821  Sema::ExpressionEvaluationContext::PotentiallyEvaluated);
822  if (auto *FD = dyn_cast<FunctionDecl>(DC))
823  FD->setWillHaveBody(true);
824  else
825  assert(isa<ObjCMethodDecl>(DC));
826  }
827 
829  assert(!PushedCodeSynthesisContext);
830 
832  Ctx.Kind = Sema::CodeSynthesisContext::DefiningSynthesizedFunction;
833  Ctx.PointOfInstantiation = UseLoc;
834  Ctx.Entity = cast<Decl>(S.CurContext);
836 
837  PushedCodeSynthesisContext = true;
838  }
839 
841  if (PushedCodeSynthesisContext)
843  if (auto *FD = dyn_cast<FunctionDecl>(S.CurContext))
844  FD->setWillHaveBody(false);
847  }
848  };
849 
850  /// WeakUndeclaredIdentifiers - Identifiers contained in
851  /// \#pragma weak before declared. rare. may alias another
852  /// identifier, declared or undeclared
853  llvm::MapVector<IdentifierInfo *, WeakInfo> WeakUndeclaredIdentifiers;
854 
855  /// ExtnameUndeclaredIdentifiers - Identifiers contained in
856  /// \#pragma redefine_extname before declared. Used in Solaris system headers
857  /// to define functions that occur in multiple standards to call the version
858  /// in the currently selected standard.
859  llvm::DenseMap<IdentifierInfo*,AsmLabelAttr*> ExtnameUndeclaredIdentifiers;
860 
861 
862  /// Load weak undeclared identifiers from the external source.
863  void LoadExternalWeakUndeclaredIdentifiers();
864 
865  /// WeakTopLevelDecl - Translation-unit scoped declarations generated by
866  /// \#pragma weak during processing of other Decls.
867  /// I couldn't figure out a clean way to generate these in-line, so
868  /// we store them here and handle separately -- which is a hack.
869  /// It would be best to refactor this.
871 
873 
874  /// Translation Unit Scope - useful to Objective-C actions that need
875  /// to lookup file scope declarations in the "ordinary" C decl namespace.
876  /// For example, user-defined classes, built-in "id" type, etc.
878 
879  /// The C++ "std" namespace, where the standard library resides.
881 
882  /// The C++ "std::bad_alloc" class, which is defined by the C++
883  /// standard library.
885 
886  /// The C++ "std::align_val_t" enum class, which is defined by the C++
887  /// standard library.
889 
890  /// The C++ "std::experimental" namespace, where the experimental parts
891  /// of the standard library resides.
893 
894  /// The C++ "std::initializer_list" template, which is defined in
895  /// <initializer_list>.
897 
898  /// The C++ "std::coroutine_traits" template, which is defined in
899  /// <coroutine_traits>
901 
902  /// The C++ "type_info" declaration, which is defined in <typeinfo>.
904 
905  /// The MSVC "_GUID" struct, which is defined in MSVC header files.
907 
908  /// Caches identifiers/selectors for NSFoundation APIs.
909  std::unique_ptr<NSAPI> NSAPIObj;
910 
911  /// The declaration of the Objective-C NSNumber class.
913 
914  /// The declaration of the Objective-C NSValue class.
916 
917  /// Pointer to NSNumber type (NSNumber *).
919 
920  /// Pointer to NSValue type (NSValue *).
922 
923  /// The Objective-C NSNumber methods used to create NSNumber literals.
924  ObjCMethodDecl *NSNumberLiteralMethods[NSAPI::NumNSNumberLiteralMethods];
925 
926  /// The declaration of the Objective-C NSString class.
928 
929  /// Pointer to NSString type (NSString *).
931 
932  /// The declaration of the stringWithUTF8String: method.
934 
935  /// The declaration of the valueWithBytes:objCType: method.
937 
938  /// The declaration of the Objective-C NSArray class.
940 
941  /// The declaration of the arrayWithObjects:count: method.
943 
944  /// The declaration of the Objective-C NSDictionary class.
946 
947  /// The declaration of the dictionaryWithObjects:forKeys:count: method.
949 
950  /// id<NSCopying> type.
952 
953  /// will hold 'respondsToSelector:'
955 
956  /// A flag to remember whether the implicit forms of operator new and delete
957  /// have been declared.
959 
960  /// A flag to indicate that we're in a context that permits abstract
961  /// references to fields. This is really a
963 
964  /// Describes how the expressions currently being parsed are
965  /// evaluated at run-time, if at all.
967  /// The current expression and its subexpressions occur within an
968  /// unevaluated operand (C++11 [expr]p7), such as the subexpression of
969  /// \c sizeof, where the type of the expression may be significant but
970  /// no code will be generated to evaluate the value of the expression at
971  /// run time.
972  Unevaluated,
973 
974  /// The current expression occurs within a braced-init-list within
975  /// an unevaluated operand. This is mostly like a regular unevaluated
976  /// context, except that we still instantiate constexpr functions that are
977  /// referenced here so that we can perform narrowing checks correctly.
978  UnevaluatedList,
979 
980  /// The current expression occurs within a discarded statement.
981  /// This behaves largely similarly to an unevaluated operand in preventing
982  /// definitions from being required, but not in other ways.
983  DiscardedStatement,
984 
985  /// The current expression occurs within an unevaluated
986  /// operand that unconditionally permits abstract references to
987  /// fields, such as a SIZE operator in MS-style inline assembly.
988  UnevaluatedAbstract,
989 
990  /// The current context is "potentially evaluated" in C++11 terms,
991  /// but the expression is evaluated at compile-time (like the values of
992  /// cases in a switch statement).
993  ConstantEvaluated,
994 
995  /// The current expression is potentially evaluated at run time,
996  /// which means that code may be generated to evaluate the value of the
997  /// expression at run time.
998  PotentiallyEvaluated,
999 
1000  /// The current expression is potentially evaluated, but any
1001  /// declarations referenced inside that expression are only used if
1002  /// in fact the current expression is used.
1003  ///
1004  /// This value is used when parsing default function arguments, for which
1005  /// we would like to provide diagnostics (e.g., passing non-POD arguments
1006  /// through varargs) but do not want to mark declarations as "referenced"
1007  /// until the default argument is used.
1008  PotentiallyEvaluatedIfUsed
1009  };
1010 
1011  /// Data structure used to record current or nested
1012  /// expression evaluation contexts.
1014  /// The expression evaluation context.
1016 
1017  /// Whether the enclosing context needed a cleanup.
1019 
1020  /// Whether we are in a decltype expression.
1022 
1023  /// The number of active cleanup objects when we entered
1024  /// this expression evaluation context.
1026 
1027  /// The number of typos encountered during this expression evaluation
1028  /// context (i.e. the number of TypoExprs created).
1029  unsigned NumTypos;
1030 
1032 
1033  /// The lambdas that are present within this context, if it
1034  /// is indeed an unevaluated context.
1036 
1037  /// The declaration that provides context for lambda expressions
1038  /// and block literals if the normal declaration context does not
1039  /// suffice, e.g., in a default function argument.
1041 
1042  /// The context information used to mangle lambda expressions
1043  /// and block literals within this context.
1044  ///
1045  /// This mangling information is allocated lazily, since most contexts
1046  /// do not have lambda expressions or block literals.
1047  std::unique_ptr<MangleNumberingContext> MangleNumbering;
1048 
1049  /// If we are processing a decltype type, a set of call expressions
1050  /// for which we have deferred checking the completeness of the return type.
1052 
1053  /// If we are processing a decltype type, a set of temporary binding
1054  /// expressions for which we have deferred checking the destructor.
1056 
1057  llvm::SmallPtrSet<const Expr *, 8> PossibleDerefs;
1058 
1059  /// \brief Describes whether we are in an expression constext which we have
1060  /// to handle differently.
1062  EK_Decltype, EK_TemplateArgument, EK_Other
1063  } ExprContext;
1064 
1066  unsigned NumCleanupObjects,
1067  CleanupInfo ParentCleanup,
1068  Decl *ManglingContextDecl,
1069  ExpressionKind ExprContext)
1070  : Context(Context), ParentCleanup(ParentCleanup),
1071  NumCleanupObjects(NumCleanupObjects), NumTypos(0),
1072  ManglingContextDecl(ManglingContextDecl), MangleNumbering(),
1073  ExprContext(ExprContext) {}
1074 
1075  /// Retrieve the mangling numbering context, used to consistently
1076  /// number constructs like lambdas for mangling.
1077  MangleNumberingContext &getMangleNumberingContext(ASTContext &Ctx);
1078 
1079  bool isUnevaluated() const {
1080  return Context == ExpressionEvaluationContext::Unevaluated ||
1081  Context == ExpressionEvaluationContext::UnevaluatedAbstract ||
1082  Context == ExpressionEvaluationContext::UnevaluatedList;
1083  }
1084  bool isConstantEvaluated() const {
1085  return Context == ExpressionEvaluationContext::ConstantEvaluated;
1086  }
1087  };
1088 
1089  /// A stack of expression evaluation contexts.
1091 
1092  /// Emit a warning for all pending noderef expressions that we recorded.
1093  void WarnOnPendingNoDerefs(ExpressionEvaluationContextRecord &Rec);
1094 
1095  /// Compute the mangling number context for a lambda expression or
1096  /// block literal.
1097  ///
1098  /// \param DC - The DeclContext containing the lambda expression or
1099  /// block literal.
1100  /// \param[out] ManglingContextDecl - Returns the ManglingContextDecl
1101  /// associated with the context, if relevant.
1102  MangleNumberingContext *getCurrentMangleNumberContext(
1103  const DeclContext *DC,
1104  Decl *&ManglingContextDecl);
1105 
1106 
1107  /// SpecialMemberOverloadResult - The overloading result for a special member
1108  /// function.
1109  ///
1110  /// This is basically a wrapper around PointerIntPair. The lowest bits of the
1111  /// integer are used to determine whether overload resolution succeeded.
1113  public:
1114  enum Kind {
1117  Success
1118  };
1119 
1120  private:
1121  llvm::PointerIntPair<CXXMethodDecl*, 2> Pair;
1122 
1123  public:
1126  : Pair(MD, MD->isDeleted() ? NoMemberOrDeleted : Success) {}
1127 
1128  CXXMethodDecl *getMethod() const { return Pair.getPointer(); }
1129  void setMethod(CXXMethodDecl *MD) { Pair.setPointer(MD); }
1130 
1131  Kind getKind() const { return static_cast<Kind>(Pair.getInt()); }
1132  void setKind(Kind K) { Pair.setInt(K); }
1133  };
1134 
1136  : public llvm::FastFoldingSetNode,
1138  public:
1139  SpecialMemberOverloadResultEntry(const llvm::FoldingSetNodeID &ID)
1140  : FastFoldingSetNode(ID)
1141  {}
1142  };
1143 
1144  /// A cache of special member function overload resolution results
1145  /// for C++ records.
1146  llvm::FoldingSet<SpecialMemberOverloadResultEntry> SpecialMemberCache;
1147 
1148  /// A cache of the flags available in enumerations with the flag_bits
1149  /// attribute.
1150  mutable llvm::DenseMap<const EnumDecl*, llvm::APInt> FlagBitsCache;
1151 
1152  /// The kind of translation unit we are processing.
1153  ///
1154  /// When we're processing a complete translation unit, Sema will perform
1155  /// end-of-translation-unit semantic tasks (such as creating
1156  /// initializers for tentative definitions in C) once parsing has
1157  /// completed. Modules and precompiled headers perform different kinds of
1158  /// checks.
1160 
1161  llvm::BumpPtrAllocator BumpAlloc;
1162 
1163  /// The number of SFINAE diagnostics that have been trapped.
1165 
1166  typedef llvm::DenseMap<ParmVarDecl *, llvm::TinyPtrVector<ParmVarDecl *>>
1168 
1169  /// A mapping from parameters with unparsed default arguments to the
1170  /// set of instantiations of each parameter.
1171  ///
1172  /// This mapping is a temporary data structure used when parsing
1173  /// nested class templates or nested classes of class templates,
1174  /// where we might end up instantiating an inner class before the
1175  /// default arguments of its methods have been parsed.
1177 
1178  // Contains the locations of the beginning of unparsed default
1179  // argument locations.
1180  llvm::DenseMap<ParmVarDecl *, SourceLocation> UnparsedDefaultArgLocs;
1181 
1182  /// UndefinedInternals - all the used, undefined objects which require a
1183  /// definition in this translation unit.
1184  llvm::MapVector<NamedDecl *, SourceLocation> UndefinedButUsed;
1185 
1186  /// Determine if VD, which must be a variable or function, is an external
1187  /// symbol that nonetheless can't be referenced from outside this translation
1188  /// unit because its type has no linkage and it's not extern "C".
1189  bool isExternalWithNoLinkageType(ValueDecl *VD);
1190 
1191  /// Obtain a sorted list of functions that are undefined but ODR-used.
1192  void getUndefinedButUsed(
1193  SmallVectorImpl<std::pair<NamedDecl *, SourceLocation> > &Undefined);
1194 
1195  /// Retrieves list of suspicious delete-expressions that will be checked at
1196  /// the end of translation unit.
1197  const llvm::MapVector<FieldDecl *, DeleteLocs> &
1198  getMismatchingDeleteExpressions() const;
1199 
1200  typedef std::pair<ObjCMethodList, ObjCMethodList> GlobalMethods;
1201  typedef llvm::DenseMap<Selector, GlobalMethods> GlobalMethodPool;
1202 
1203  /// Method Pool - allows efficient lookup when typechecking messages to "id".
1204  /// We need to maintain a list, since selectors can have differing signatures
1205  /// across classes. In Cocoa, this happens to be extremely uncommon (only 1%
1206  /// of selectors are "overloaded").
1207  /// At the head of the list it is recorded whether there were 0, 1, or >= 2
1208  /// methods inside categories with a particular selector.
1209  GlobalMethodPool MethodPool;
1210 
1211  /// Method selectors used in a \@selector expression. Used for implementation
1212  /// of -Wselector.
1213  llvm::MapVector<Selector, SourceLocation> ReferencedSelectors;
1214 
1215  /// List of SourceLocations where 'self' is implicitly retained inside a
1216  /// block.
1219 
1220  /// Kinds of C++ special members.
1228  CXXInvalid
1229  };
1230 
1231  typedef llvm::PointerIntPair<CXXRecordDecl *, 3, CXXSpecialMember>
1233 
1234  /// The C++ special members which we are currently in the process of
1235  /// declaring. If this process recursively triggers the declaration of the
1236  /// same special member, we should act as if it is not yet declared.
1237  llvm::SmallPtrSet<SpecialMemberDecl, 4> SpecialMembersBeingDeclared;
1238 
1239  /// The function definitions which were renamed as part of typo-correction
1240  /// to match their respective declarations. We want to keep track of them
1241  /// to ensure that we don't emit a "redefinition" error if we encounter a
1242  /// correctly named definition after the renamed definition.
1243  llvm::SmallPtrSet<const NamedDecl *, 4> TypoCorrectedFunctionDefinitions;
1244 
1245  /// Stack of types that correspond to the parameter entities that are
1246  /// currently being copy-initialized. Can be empty.
1248 
1249  void ReadMethodPool(Selector Sel);
1250  void updateOutOfDateSelector(Selector Sel);
1251 
1252  /// Private Helper predicate to check for 'self'.
1253  bool isSelfExpr(Expr *RExpr);
1254  bool isSelfExpr(Expr *RExpr, const ObjCMethodDecl *Method);
1255 
1256  /// Cause the active diagnostic on the DiagosticsEngine to be
1257  /// emitted. This is closely coupled to the SemaDiagnosticBuilder class and
1258  /// should not be used elsewhere.
1259  void EmitCurrentDiagnostic(unsigned DiagID);
1260 
1261  /// Records and restores the FP_CONTRACT state on entry/exit of compound
1262  /// statements.
1264  public:
1265  FPContractStateRAII(Sema &S) : S(S), OldFPFeaturesState(S.FPFeatures) {}
1266  ~FPContractStateRAII() { S.FPFeatures = OldFPFeaturesState; }
1267 
1268  private:
1269  Sema& S;
1270  FPOptions OldFPFeaturesState;
1271  };
1272 
1273  void addImplicitTypedef(StringRef Name, QualType T);
1274 
1275 public:
1276  Sema(Preprocessor &pp, ASTContext &ctxt, ASTConsumer &consumer,
1278  CodeCompleteConsumer *CompletionConsumer = nullptr);
1279  ~Sema();
1280 
1281  /// Perform initialization that occurs after the parser has been
1282  /// initialized but before it parses anything.
1283  void Initialize();
1284 
1285  const LangOptions &getLangOpts() const { return LangOpts; }
1286  OpenCLOptions &getOpenCLOptions() { return OpenCLFeatures; }
1287  FPOptions &getFPOptions() { return FPFeatures; }
1288 
1289  DiagnosticsEngine &getDiagnostics() const { return Diags; }
1290  SourceManager &getSourceManager() const { return SourceMgr; }
1291  Preprocessor &getPreprocessor() const { return PP; }
1292  ASTContext &getASTContext() const { return Context; }
1293  ASTConsumer &getASTConsumer() const { return Consumer; }
1294  ASTMutationListener *getASTMutationListener() const;
1295  ExternalSemaSource* getExternalSource() const { return ExternalSource; }
1296 
1297  ///Registers an external source. If an external source already exists,
1298  /// creates a multiplex external source and appends to it.
1299  ///
1300  ///\param[in] E - A non-null external sema source.
1301  ///
1302  void addExternalSource(ExternalSemaSource *E);
1303 
1304  void PrintStats() const;
1305 
1306  /// Helper class that creates diagnostics with optional
1307  /// template instantiation stacks.
1308  ///
1309  /// This class provides a wrapper around the basic DiagnosticBuilder
1310  /// class that emits diagnostics. SemaDiagnosticBuilder is
1311  /// responsible for emitting the diagnostic (as DiagnosticBuilder
1312  /// does) and, if the diagnostic comes from inside a template
1313  /// instantiation, printing the template instantiation stack as
1314  /// well.
1316  Sema &SemaRef;
1317  unsigned DiagID;
1318 
1319  public:
1320  SemaDiagnosticBuilder(DiagnosticBuilder &DB, Sema &SemaRef, unsigned DiagID)
1321  : DiagnosticBuilder(DB), SemaRef(SemaRef), DiagID(DiagID) { }
1322 
1323  // This is a cunning lie. DiagnosticBuilder actually performs move
1324  // construction in its copy constructor (but due to varied uses, it's not
1325  // possible to conveniently express this as actual move construction). So
1326  // the default copy ctor here is fine, because the base class disables the
1327  // source anyway, so the user-defined ~SemaDiagnosticBuilder is a safe no-op
1328  // in that case anwyay.
1329  SemaDiagnosticBuilder(const SemaDiagnosticBuilder&) = default;
1330 
1332  // If we aren't active, there is nothing to do.
1333  if (!isActive()) return;
1334 
1335  // Otherwise, we need to emit the diagnostic. First flush the underlying
1336  // DiagnosticBuilder data, and clear the diagnostic builder itself so it
1337  // won't emit the diagnostic in its own destructor.
1338  //
1339  // This seems wasteful, in that as written the DiagnosticBuilder dtor will
1340  // do its own needless checks to see if the diagnostic needs to be
1341  // emitted. However, because we take care to ensure that the builder
1342  // objects never escape, a sufficiently smart compiler will be able to
1343  // eliminate that code.
1344  FlushCounts();
1345  Clear();
1346 
1347  // Dispatch to Sema to emit the diagnostic.
1348  SemaRef.EmitCurrentDiagnostic(DiagID);
1349  }
1350 
1351  /// Teach operator<< to produce an object of the correct type.
1352  template<typename T>
1354  const SemaDiagnosticBuilder &Diag, const T &Value) {
1355  const DiagnosticBuilder &BaseDiag = Diag;
1356  BaseDiag << Value;
1357  return Diag;
1358  }
1359  };
1360 
1361  /// Emit a diagnostic.
1363  DiagnosticBuilder DB = Diags.Report(Loc, DiagID);
1364  return SemaDiagnosticBuilder(DB, *this, DiagID);
1365  }
1366 
1367  /// Emit a partial diagnostic.
1369 
1370  /// Build a partial diagnostic.
1371  PartialDiagnostic PDiag(unsigned DiagID = 0); // in SemaInternal.h
1372 
1373  bool findMacroSpelling(SourceLocation &loc, StringRef name);
1374 
1375  /// Get a string to suggest for zero-initialization of a type.
1376  std::string
1377  getFixItZeroInitializerForType(QualType T, SourceLocation Loc) const;
1378  std::string getFixItZeroLiteralForType(QualType T, SourceLocation Loc) const;
1379 
1380  /// Calls \c Lexer::getLocForEndOfToken()
1381  SourceLocation getLocForEndOfToken(SourceLocation Loc, unsigned Offset = 0);
1382 
1383  /// Retrieve the module loader associated with the preprocessor.
1384  ModuleLoader &getModuleLoader() const;
1385 
1386  void emitAndClearUnusedLocalTypedefWarnings();
1387 
1389  /// The global module fragment, between 'module;' and a module-declaration.
1391  /// A normal translation unit fragment. For a non-module unit, this is the
1392  /// entire translation unit. Otherwise, it runs from the module-declaration
1393  /// to the private-module-fragment (if any) or the end of the TU (if not).
1395  /// The private module fragment, between 'module :private;' and the end of
1396  /// the translation unit.
1397  Private
1398  };
1399 
1400  void ActOnStartOfTranslationUnit();
1401  void ActOnEndOfTranslationUnit();
1402  void ActOnEndOfTranslationUnitFragment(TUFragmentKind Kind);
1403 
1404  void CheckDelegatingCtorCycles();
1405 
1406  Scope *getScopeForContext(DeclContext *Ctx);
1407 
1408  void PushFunctionScope();
1409  void PushBlockScope(Scope *BlockScope, BlockDecl *Block);
1410  sema::LambdaScopeInfo *PushLambdaScope();
1411 
1412  /// This is used to inform Sema what the current TemplateParameterDepth
1413  /// is during Parsing. Currently it is used to pass on the depth
1414  /// when parsing generic lambda 'auto' parameters.
1415  void RecordParsingTemplateParameterDepth(unsigned Depth);
1416 
1417  void PushCapturedRegionScope(Scope *RegionScope, CapturedDecl *CD,
1418  RecordDecl *RD,
1419  CapturedRegionKind K);
1420 
1421  /// Custom deleter to allow FunctionScopeInfos to be kept alive for a short
1422  /// time after they've been popped.
1424  Sema *Self;
1425 
1426  public:
1427  explicit PoppedFunctionScopeDeleter(Sema *Self) : Self(Self) {}
1428  void operator()(sema::FunctionScopeInfo *Scope) const;
1429  };
1430 
1431  using PoppedFunctionScopePtr =
1432  std::unique_ptr<sema::FunctionScopeInfo, PoppedFunctionScopeDeleter>;
1433 
1435  PopFunctionScopeInfo(const sema::AnalysisBasedWarnings::Policy *WP = nullptr,
1436  const Decl *D = nullptr,
1437  QualType BlockType = QualType());
1438 
1440  return FunctionScopes.empty() ? nullptr : FunctionScopes.back();
1441  }
1442 
1443  sema::FunctionScopeInfo *getEnclosingFunction() const;
1444 
1445  void setFunctionHasBranchIntoScope();
1446  void setFunctionHasBranchProtectedScope();
1447  void setFunctionHasIndirectGoto();
1448 
1449  void PushCompoundScope(bool IsStmtExpr);
1450  void PopCompoundScope();
1451 
1452  sema::CompoundScopeInfo &getCurCompoundScope() const;
1453 
1454  bool hasAnyUnrecoverableErrorsInThisFunction() const;
1455 
1456  /// Retrieve the current block, if any.
1457  sema::BlockScopeInfo *getCurBlock();
1458 
1459  /// Retrieve the current lambda scope info, if any.
1460  /// \param IgnoreNonLambdaCapturingScope true if should find the top-most
1461  /// lambda scope info ignoring all inner capturing scopes that are not
1462  /// lambda scopes.
1464  getCurLambda(bool IgnoreNonLambdaCapturingScope = false);
1465 
1466  /// Retrieve the current generic lambda info, if any.
1467  sema::LambdaScopeInfo *getCurGenericLambda();
1468 
1469  /// Retrieve the current captured region, if any.
1470  sema::CapturedRegionScopeInfo *getCurCapturedRegion();
1471 
1472  /// WeakTopLevelDeclDecls - access to \#pragma weak-generated Decls
1473  SmallVectorImpl<Decl *> &WeakTopLevelDecls() { return WeakTopLevelDecl; }
1474 
1475  void ActOnComment(SourceRange Comment);
1476 
1477  //===--------------------------------------------------------------------===//
1478  // Type Analysis / Processing: SemaType.cpp.
1479  //
1480 
1481  QualType BuildQualifiedType(QualType T, SourceLocation Loc, Qualifiers Qs,
1482  const DeclSpec *DS = nullptr);
1483  QualType BuildQualifiedType(QualType T, SourceLocation Loc, unsigned CVRA,
1484  const DeclSpec *DS = nullptr);
1485  QualType BuildPointerType(QualType T,
1486  SourceLocation Loc, DeclarationName Entity);
1487  QualType BuildReferenceType(QualType T, bool LValueRef,
1488  SourceLocation Loc, DeclarationName Entity);
1489  QualType BuildArrayType(QualType T, ArrayType::ArraySizeModifier ASM,
1490  Expr *ArraySize, unsigned Quals,
1491  SourceRange Brackets, DeclarationName Entity);
1492  QualType BuildVectorType(QualType T, Expr *VecSize, SourceLocation AttrLoc);
1493  QualType BuildExtVectorType(QualType T, Expr *ArraySize,
1494  SourceLocation AttrLoc);
1495  QualType BuildAddressSpaceAttr(QualType &T, LangAS ASIdx, Expr *AddrSpace,
1496  SourceLocation AttrLoc);
1497 
1498  /// Same as above, but constructs the AddressSpace index if not provided.
1499  QualType BuildAddressSpaceAttr(QualType &T, Expr *AddrSpace,
1500  SourceLocation AttrLoc);
1501 
1502  bool CheckFunctionReturnType(QualType T, SourceLocation Loc);
1503 
1504  /// Build a function type.
1505  ///
1506  /// This routine checks the function type according to C++ rules and
1507  /// under the assumption that the result type and parameter types have
1508  /// just been instantiated from a template. It therefore duplicates
1509  /// some of the behavior of GetTypeForDeclarator, but in a much
1510  /// simpler form that is only suitable for this narrow use case.
1511  ///
1512  /// \param T The return type of the function.
1513  ///
1514  /// \param ParamTypes The parameter types of the function. This array
1515  /// will be modified to account for adjustments to the types of the
1516  /// function parameters.
1517  ///
1518  /// \param Loc The location of the entity whose type involves this
1519  /// function type or, if there is no such entity, the location of the
1520  /// type that will have function type.
1521  ///
1522  /// \param Entity The name of the entity that involves the function
1523  /// type, if known.
1524  ///
1525  /// \param EPI Extra information about the function type. Usually this will
1526  /// be taken from an existing function with the same prototype.
1527  ///
1528  /// \returns A suitable function type, if there are no errors. The
1529  /// unqualified type will always be a FunctionProtoType.
1530  /// Otherwise, returns a NULL type.
1531  QualType BuildFunctionType(QualType T,
1532  MutableArrayRef<QualType> ParamTypes,
1533  SourceLocation Loc, DeclarationName Entity,
1534  const FunctionProtoType::ExtProtoInfo &EPI);
1535 
1536  QualType BuildMemberPointerType(QualType T, QualType Class,
1537  SourceLocation Loc,
1538  DeclarationName Entity);
1539  QualType BuildBlockPointerType(QualType T,
1540  SourceLocation Loc, DeclarationName Entity);
1541  QualType BuildParenType(QualType T);
1542  QualType BuildAtomicType(QualType T, SourceLocation Loc);
1543  QualType BuildReadPipeType(QualType T,
1544  SourceLocation Loc);
1545  QualType BuildWritePipeType(QualType T,
1546  SourceLocation Loc);
1547 
1548  TypeSourceInfo *GetTypeForDeclarator(Declarator &D, Scope *S);
1549  TypeSourceInfo *GetTypeForDeclaratorCast(Declarator &D, QualType FromTy);
1550 
1551  /// Package the given type and TSI into a ParsedType.
1552  ParsedType CreateParsedType(QualType T, TypeSourceInfo *TInfo);
1553  DeclarationNameInfo GetNameForDeclarator(Declarator &D);
1554  DeclarationNameInfo GetNameFromUnqualifiedId(const UnqualifiedId &Name);
1555  static QualType GetTypeFromParser(ParsedType Ty,
1556  TypeSourceInfo **TInfo = nullptr);
1557  CanThrowResult canThrow(const Expr *E);
1558  const FunctionProtoType *ResolveExceptionSpec(SourceLocation Loc,
1559  const FunctionProtoType *FPT);
1560  void UpdateExceptionSpec(FunctionDecl *FD,
1562  bool CheckSpecifiedExceptionType(QualType &T, SourceRange Range);
1563  bool CheckDistantExceptionSpec(QualType T);
1564  bool CheckEquivalentExceptionSpec(FunctionDecl *Old, FunctionDecl *New);
1565  bool CheckEquivalentExceptionSpec(
1566  const FunctionProtoType *Old, SourceLocation OldLoc,
1567  const FunctionProtoType *New, SourceLocation NewLoc);
1568  bool CheckEquivalentExceptionSpec(
1569  const PartialDiagnostic &DiagID, const PartialDiagnostic & NoteID,
1570  const FunctionProtoType *Old, SourceLocation OldLoc,
1571  const FunctionProtoType *New, SourceLocation NewLoc);
1572  bool handlerCanCatch(QualType HandlerType, QualType ExceptionType);
1573  bool CheckExceptionSpecSubset(const PartialDiagnostic &DiagID,
1574  const PartialDiagnostic &NestedDiagID,
1575  const PartialDiagnostic &NoteID,
1576  const PartialDiagnostic &NoThrowDiagID,
1577  const FunctionProtoType *Superset,
1578  SourceLocation SuperLoc,
1579  const FunctionProtoType *Subset,
1580  SourceLocation SubLoc);
1581  bool CheckParamExceptionSpec(const PartialDiagnostic &NestedDiagID,
1582  const PartialDiagnostic &NoteID,
1583  const FunctionProtoType *Target,
1584  SourceLocation TargetLoc,
1585  const FunctionProtoType *Source,
1586  SourceLocation SourceLoc);
1587 
1588  TypeResult ActOnTypeName(Scope *S, Declarator &D);
1589 
1590  /// The parser has parsed the context-sensitive type 'instancetype'
1591  /// in an Objective-C message declaration. Return the appropriate type.
1592  ParsedType ActOnObjCInstanceType(SourceLocation Loc);
1593 
1594  /// Abstract class used to diagnose incomplete types.
1595  struct TypeDiagnoser {
1597 
1598  virtual void diagnose(Sema &S, SourceLocation Loc, QualType T) = 0;
1599  virtual ~TypeDiagnoser() {}
1600  };
1601 
1602  static int getPrintable(int I) { return I; }
1603  static unsigned getPrintable(unsigned I) { return I; }
1604  static bool getPrintable(bool B) { return B; }
1605  static const char * getPrintable(const char *S) { return S; }
1606  static StringRef getPrintable(StringRef S) { return S; }
1607  static const std::string &getPrintable(const std::string &S) { return S; }
1608  static const IdentifierInfo *getPrintable(const IdentifierInfo *II) {
1609  return II;
1610  }
1612  static QualType getPrintable(QualType T) { return T; }
1613  static SourceRange getPrintable(SourceRange R) { return R; }
1614  static SourceRange getPrintable(SourceLocation L) { return L; }
1615  static SourceRange getPrintable(const Expr *E) { return E->getSourceRange(); }
1616  static SourceRange getPrintable(TypeLoc TL) { return TL.getSourceRange();}
1617 
1618  template <typename... Ts> class BoundTypeDiagnoser : public TypeDiagnoser {
1619  unsigned DiagID;
1620  std::tuple<const Ts &...> Args;
1621 
1622  template <std::size_t... Is>
1623  void emit(const SemaDiagnosticBuilder &DB,
1624  llvm::index_sequence<Is...>) const {
1625  // Apply all tuple elements to the builder in order.
1626  bool Dummy[] = {false, (DB << getPrintable(std::get<Is>(Args)))...};
1627  (void)Dummy;
1628  }
1629 
1630  public:
1631  BoundTypeDiagnoser(unsigned DiagID, const Ts &...Args)
1632  : TypeDiagnoser(), DiagID(DiagID), Args(Args...) {
1633  assert(DiagID != 0 && "no diagnostic for type diagnoser");
1634  }
1635 
1636  void diagnose(Sema &S, SourceLocation Loc, QualType T) override {
1637  const SemaDiagnosticBuilder &DB = S.Diag(Loc, DiagID);
1638  emit(DB, llvm::index_sequence_for<Ts...>());
1639  DB << T;
1640  }
1641  };
1642 
1643 private:
1644  /// Methods for marking which expressions involve dereferencing a pointer
1645  /// marked with the 'noderef' attribute. Expressions are checked bottom up as
1646  /// they are parsed, meaning that a noderef pointer may not be accessed. For
1647  /// example, in `&*p` where `p` is a noderef pointer, we will first parse the
1648  /// `*p`, but need to check that `address of` is called on it. This requires
1649  /// keeping a container of all pending expressions and checking if the address
1650  /// of them are eventually taken.
1651  void CheckSubscriptAccessOfNoDeref(const ArraySubscriptExpr *E);
1652  void CheckAddressOfNoDeref(const Expr *E);
1653  void CheckMemberAccessOfNoDeref(const MemberExpr *E);
1654 
1655  bool RequireCompleteTypeImpl(SourceLocation Loc, QualType T,
1656  TypeDiagnoser *Diagnoser);
1657 
1658  struct ModuleScope {
1659  SourceLocation BeginLoc;
1660  clang::Module *Module = nullptr;
1661  bool ModuleInterface = false;
1662  bool ImplicitGlobalModuleFragment = false;
1663  VisibleModuleSet OuterVisibleModules;
1664  };
1665  /// The modules we're currently parsing.
1667 
1668  /// Namespace definitions that we will export when they finish.
1669  llvm::SmallPtrSet<const NamespaceDecl*, 8> DeferredExportedNamespaces;
1670 
1671  /// Get the module whose scope we are currently within.
1672  Module *getCurrentModule() const {
1673  return ModuleScopes.empty() ? nullptr : ModuleScopes.back().Module;
1674  }
1675 
1676  VisibleModuleSet VisibleModules;
1677 
1678 public:
1679  /// Get the module owning an entity.
1680  Module *getOwningModule(Decl *Entity) { return Entity->getOwningModule(); }
1681 
1682  /// Make a merged definition of an existing hidden definition \p ND
1683  /// visible at the specified location.
1684  void makeMergedDefinitionVisible(NamedDecl *ND);
1685 
1686  bool isModuleVisible(const Module *M, bool ModulePrivate = false);
1687 
1688  /// Determine whether a declaration is visible to name lookup.
1689  bool isVisible(const NamedDecl *D) {
1690  return !D->isHidden() || isVisibleSlow(D);
1691  }
1692 
1693  /// Determine whether any declaration of an entity is visible.
1694  bool
1696  llvm::SmallVectorImpl<Module *> *Modules = nullptr) {
1697  return isVisible(D) || hasVisibleDeclarationSlow(D, Modules);
1698  }
1699  bool hasVisibleDeclarationSlow(const NamedDecl *D,
1701 
1702  bool hasVisibleMergedDefinition(NamedDecl *Def);
1703  bool hasMergedDefinitionInCurrentModule(NamedDecl *Def);
1704 
1705  /// Determine if \p D and \p Suggested have a structurally compatible
1706  /// layout as described in C11 6.2.7/1.
1707  bool hasStructuralCompatLayout(Decl *D, Decl *Suggested);
1708 
1709  /// Determine if \p D has a visible definition. If not, suggest a declaration
1710  /// that should be made visible to expose the definition.
1711  bool hasVisibleDefinition(NamedDecl *D, NamedDecl **Suggested,
1712  bool OnlyNeedComplete = false);
1714  NamedDecl *Hidden;
1715  return hasVisibleDefinition(const_cast<NamedDecl*>(D), &Hidden);
1716  }
1717 
1718  /// Determine if the template parameter \p D has a visible default argument.
1719  bool
1721  llvm::SmallVectorImpl<Module *> *Modules = nullptr);
1722 
1723  /// Determine if there is a visible declaration of \p D that is an explicit
1724  /// specialization declaration for a specialization of a template. (For a
1725  /// member specialization, use hasVisibleMemberSpecialization.)
1726  bool hasVisibleExplicitSpecialization(
1727  const NamedDecl *D, llvm::SmallVectorImpl<Module *> *Modules = nullptr);
1728 
1729  /// Determine if there is a visible declaration of \p D that is a member
1730  /// specialization declaration (as opposed to an instantiated declaration).
1731  bool hasVisibleMemberSpecialization(
1732  const NamedDecl *D, llvm::SmallVectorImpl<Module *> *Modules = nullptr);
1733 
1734  /// Determine if \p A and \p B are equivalent internal linkage declarations
1735  /// from different modules, and thus an ambiguity error can be downgraded to
1736  /// an extension warning.
1737  bool isEquivalentInternalLinkageDeclaration(const NamedDecl *A,
1738  const NamedDecl *B);
1739  void diagnoseEquivalentInternalLinkageDeclarations(
1740  SourceLocation Loc, const NamedDecl *D,
1742 
1743  bool isUsualDeallocationFunction(const CXXMethodDecl *FD);
1744 
1746  return !RequireCompleteTypeImpl(Loc, T, nullptr);
1747  }
1748  bool RequireCompleteType(SourceLocation Loc, QualType T,
1749  TypeDiagnoser &Diagnoser);
1750  bool RequireCompleteType(SourceLocation Loc, QualType T,
1751  unsigned DiagID);
1752 
1753  template <typename... Ts>
1754  bool RequireCompleteType(SourceLocation Loc, QualType T, unsigned DiagID,
1755  const Ts &...Args) {
1756  BoundTypeDiagnoser<Ts...> Diagnoser(DiagID, Args...);
1757  return RequireCompleteType(Loc, T, Diagnoser);
1758  }
1759 
1760  void completeExprArrayBound(Expr *E);
1761  bool RequireCompleteExprType(Expr *E, TypeDiagnoser &Diagnoser);
1762  bool RequireCompleteExprType(Expr *E, unsigned DiagID);
1763 
1764  template <typename... Ts>
1765  bool RequireCompleteExprType(Expr *E, unsigned DiagID, const Ts &...Args) {
1766  BoundTypeDiagnoser<Ts...> Diagnoser(DiagID, Args...);
1767  return RequireCompleteExprType(E, Diagnoser);
1768  }
1769 
1770  bool RequireLiteralType(SourceLocation Loc, QualType T,
1771  TypeDiagnoser &Diagnoser);
1772  bool RequireLiteralType(SourceLocation Loc, QualType T, unsigned DiagID);
1773 
1774  template <typename... Ts>
1775  bool RequireLiteralType(SourceLocation Loc, QualType T, unsigned DiagID,
1776  const Ts &...Args) {
1777  BoundTypeDiagnoser<Ts...> Diagnoser(DiagID, Args...);
1778  return RequireLiteralType(Loc, T, Diagnoser);
1779  }
1780 
1781  QualType getElaboratedType(ElaboratedTypeKeyword Keyword,
1782  const CXXScopeSpec &SS, QualType T,
1783  TagDecl *OwnedTagDecl = nullptr);
1784 
1785  QualType BuildTypeofExprType(Expr *E, SourceLocation Loc);
1786  /// If AsUnevaluated is false, E is treated as though it were an evaluated
1787  /// context, such as when building a type for decltype(auto).
1788  QualType BuildDecltypeType(Expr *E, SourceLocation Loc,
1789  bool AsUnevaluated = true);
1790  QualType BuildUnaryTransformType(QualType BaseType,
1792  SourceLocation Loc);
1793 
1794  //===--------------------------------------------------------------------===//
1795  // Symbol table / Decl tracking callbacks: SemaDecl.cpp.
1796  //
1797 
1798  struct SkipBodyInfo {
1800  : ShouldSkip(false), CheckSameAsPrevious(false), Previous(nullptr),
1801  New(nullptr) {}
1806  };
1807 
1808  DeclGroupPtrTy ConvertDeclToDeclGroup(Decl *Ptr, Decl *OwnedType = nullptr);
1809 
1810  void DiagnoseUseOfUnimplementedSelectors();
1811 
1812  bool isSimpleTypeSpecifier(tok::TokenKind Kind) const;
1813 
1815  Scope *S, CXXScopeSpec *SS = nullptr,
1816  bool isClassName = false, bool HasTrailingDot = false,
1817  ParsedType ObjectType = nullptr,
1818  bool IsCtorOrDtorName = false,
1819  bool WantNontrivialTypeSourceInfo = false,
1820  bool IsClassTemplateDeductionContext = true,
1821  IdentifierInfo **CorrectedII = nullptr);
1822  TypeSpecifierType isTagName(IdentifierInfo &II, Scope *S);
1823  bool isMicrosoftMissingTypename(const CXXScopeSpec *SS, Scope *S);
1824  void DiagnoseUnknownTypeName(IdentifierInfo *&II,
1825  SourceLocation IILoc,
1826  Scope *S,
1827  CXXScopeSpec *SS,
1828  ParsedType &SuggestedType,
1829  bool IsTemplateName = false);
1830 
1831  /// Attempt to behave like MSVC in situations where lookup of an unqualified
1832  /// type name has failed in a dependent context. In these situations, we
1833  /// automatically form a DependentTypeName that will retry lookup in a related
1834  /// scope during instantiation.
1835  ParsedType ActOnMSVCUnknownTypeName(const IdentifierInfo &II,
1836  SourceLocation NameLoc,
1837  bool IsTemplateTypeArg);
1838 
1839  /// Describes the result of the name lookup and resolution performed
1840  /// by \c ClassifyName().
1852  };
1853 
1856  ExprResult Expr;
1857  TemplateName Template;
1858  ParsedType Type;
1859 
1860  explicit NameClassification(NameClassificationKind Kind) : Kind(Kind) {}
1861 
1862  public:
1863  NameClassification(ExprResult Expr) : Kind(NC_Expression), Expr(Expr) {}
1864 
1865  NameClassification(ParsedType Type) : Kind(NC_Type), Type(Type) {}
1866 
1867  NameClassification(const IdentifierInfo *Keyword) : Kind(NC_Keyword) {}
1868 
1870  return NameClassification(NC_Error);
1871  }
1872 
1874  return NameClassification(NC_Unknown);
1875  }
1876 
1878  return NameClassification(NC_NestedNameSpecifier);
1879  }
1880 
1882  NameClassification Result(NC_TypeTemplate);
1883  Result.Template = Name;
1884  return Result;
1885  }
1886 
1888  NameClassification Result(NC_VarTemplate);
1889  Result.Template = Name;
1890  return Result;
1891  }
1892 
1894  NameClassification Result(NC_FunctionTemplate);
1895  Result.Template = Name;
1896  return Result;
1897  }
1898 
1900  NameClassification Result(NC_UndeclaredTemplate);
1901  Result.Template = Name;
1902  return Result;
1903  }
1904 
1906 
1908  assert(Kind == NC_Type);
1909  return Type;
1910  }
1911 
1913  assert(Kind == NC_Expression);
1914  return Expr;
1915  }
1916 
1918  assert(Kind == NC_TypeTemplate || Kind == NC_FunctionTemplate ||
1919  Kind == NC_VarTemplate || Kind == NC_UndeclaredTemplate);
1920  return Template;
1921  }
1922 
1924  switch (Kind) {
1925  case NC_TypeTemplate:
1926  return TNK_Type_template;
1927  case NC_FunctionTemplate:
1928  return TNK_Function_template;
1929  case NC_VarTemplate:
1930  return TNK_Var_template;
1931  case NC_UndeclaredTemplate:
1932  return TNK_Undeclared_template;
1933  default:
1934  llvm_unreachable("unsupported name classification.");
1935  }
1936  }
1937  };
1938 
1939  /// Perform name lookup on the given name, classifying it based on
1940  /// the results of name lookup and the following token.
1941  ///
1942  /// This routine is used by the parser to resolve identifiers and help direct
1943  /// parsing. When the identifier cannot be found, this routine will attempt
1944  /// to correct the typo and classify based on the resulting name.
1945  ///
1946  /// \param S The scope in which we're performing name lookup.
1947  ///
1948  /// \param SS The nested-name-specifier that precedes the name.
1949  ///
1950  /// \param Name The identifier. If typo correction finds an alternative name,
1951  /// this pointer parameter will be updated accordingly.
1952  ///
1953  /// \param NameLoc The location of the identifier.
1954  ///
1955  /// \param NextToken The token following the identifier. Used to help
1956  /// disambiguate the name.
1957  ///
1958  /// \param IsAddressOfOperand True if this name is the operand of a unary
1959  /// address of ('&') expression, assuming it is classified as an
1960  /// expression.
1961  ///
1962  /// \param CCC The correction callback, if typo correction is desired.
1963  NameClassification ClassifyName(Scope *S, CXXScopeSpec &SS,
1964  IdentifierInfo *&Name, SourceLocation NameLoc,
1965  const Token &NextToken,
1966  bool IsAddressOfOperand,
1967  CorrectionCandidateCallback *CCC = nullptr);
1968 
1969  /// Describes the detailed kind of a template name. Used in diagnostics.
1971  ClassTemplate,
1972  FunctionTemplate,
1973  VarTemplate,
1974  AliasTemplate,
1975  TemplateTemplateParam,
1976  Concept,
1977  DependentTemplate
1978  };
1980  getTemplateNameKindForDiagnostics(TemplateName Name);
1981 
1982  /// Determine whether it's plausible that E was intended to be a
1983  /// template-name.
1984  bool mightBeIntendedToBeTemplateName(ExprResult E, bool &Dependent) {
1985  if (!getLangOpts().CPlusPlus || E.isInvalid())
1986  return false;
1987  Dependent = false;
1988  if (auto *DRE = dyn_cast<DeclRefExpr>(E.get()))
1989  return !DRE->hasExplicitTemplateArgs();
1990  if (auto *ME = dyn_cast<MemberExpr>(E.get()))
1991  return !ME->hasExplicitTemplateArgs();
1992  Dependent = true;
1993  if (auto *DSDRE = dyn_cast<DependentScopeDeclRefExpr>(E.get()))
1994  return !DSDRE->hasExplicitTemplateArgs();
1995  if (auto *DSME = dyn_cast<CXXDependentScopeMemberExpr>(E.get()))
1996  return !DSME->hasExplicitTemplateArgs();
1997  // Any additional cases recognized here should also be handled by
1998  // diagnoseExprIntendedAsTemplateName.
1999  return false;
2000  }
2001  void diagnoseExprIntendedAsTemplateName(Scope *S, ExprResult TemplateName,
2004 
2005  Decl *ActOnDeclarator(Scope *S, Declarator &D);
2006 
2007  NamedDecl *HandleDeclarator(Scope *S, Declarator &D,
2008  MultiTemplateParamsArg TemplateParameterLists);
2009  void RegisterLocallyScopedExternCDecl(NamedDecl *ND, Scope *S);
2010  bool DiagnoseClassNameShadow(DeclContext *DC, DeclarationNameInfo Info);
2011  bool diagnoseQualifiedDeclaration(CXXScopeSpec &SS, DeclContext *DC,
2012  DeclarationName Name, SourceLocation Loc,
2013  bool IsTemplateId);
2014  void
2015  diagnoseIgnoredQualifiers(unsigned DiagID, unsigned Quals,
2016  SourceLocation FallbackLoc,
2017  SourceLocation ConstQualLoc = SourceLocation(),
2018  SourceLocation VolatileQualLoc = SourceLocation(),
2019  SourceLocation RestrictQualLoc = SourceLocation(),
2020  SourceLocation AtomicQualLoc = SourceLocation(),
2021  SourceLocation UnalignedQualLoc = SourceLocation());
2022 
2023  static bool adjustContextForLocalExternDecl(DeclContext *&DC);
2024  void DiagnoseFunctionSpecifiers(const DeclSpec &DS);
2025  NamedDecl *getShadowedDeclaration(const TypedefNameDecl *D,
2026  const LookupResult &R);
2027  NamedDecl *getShadowedDeclaration(const VarDecl *D, const LookupResult &R);
2028  void CheckShadow(NamedDecl *D, NamedDecl *ShadowedDecl,
2029  const LookupResult &R);
2030  void CheckShadow(Scope *S, VarDecl *D);
2031 
2032  /// Warn if 'E', which is an expression that is about to be modified, refers
2033  /// to a shadowing declaration.
2034  void CheckShadowingDeclModification(Expr *E, SourceLocation Loc);
2035 
2036  void DiagnoseShadowingLambdaDecls(const sema::LambdaScopeInfo *LSI);
2037 
2038 private:
2039  /// Map of current shadowing declarations to shadowed declarations. Warn if
2040  /// it looks like the user is trying to modify the shadowing declaration.
2041  llvm::DenseMap<const NamedDecl *, const NamedDecl *> ShadowingDecls;
2042 
2043 public:
2044  void CheckCastAlign(Expr *Op, QualType T, SourceRange TRange);
2045  void handleTagNumbering(const TagDecl *Tag, Scope *TagScope);
2046  void setTagNameForLinkagePurposes(TagDecl *TagFromDeclSpec,
2047  TypedefNameDecl *NewTD);
2048  void CheckTypedefForVariablyModifiedType(Scope *S, TypedefNameDecl *D);
2049  NamedDecl* ActOnTypedefDeclarator(Scope* S, Declarator& D, DeclContext* DC,
2050  TypeSourceInfo *TInfo,
2052  NamedDecl* ActOnTypedefNameDecl(Scope* S, DeclContext* DC, TypedefNameDecl *D,
2053  LookupResult &Previous, bool &Redeclaration);
2054  NamedDecl *ActOnVariableDeclarator(Scope *S, Declarator &D, DeclContext *DC,
2055  TypeSourceInfo *TInfo,
2056  LookupResult &Previous,
2057  MultiTemplateParamsArg TemplateParamLists,
2058  bool &AddToScope,
2059  ArrayRef<BindingDecl *> Bindings = None);
2060  NamedDecl *
2061  ActOnDecompositionDeclarator(Scope *S, Declarator &D,
2062  MultiTemplateParamsArg TemplateParamLists);
2063  // Returns true if the variable declaration is a redeclaration
2064  bool CheckVariableDeclaration(VarDecl *NewVD, LookupResult &Previous);
2065  void CheckVariableDeclarationType(VarDecl *NewVD);
2066  bool DeduceVariableDeclarationType(VarDecl *VDecl, bool DirectInit,
2067  Expr *Init);
2068  void CheckCompleteVariableDeclaration(VarDecl *VD);
2069  void CheckCompleteDecompositionDeclaration(DecompositionDecl *DD);
2070  void MaybeSuggestAddingStaticToDecl(const FunctionDecl *D);
2071 
2072  NamedDecl* ActOnFunctionDeclarator(Scope* S, Declarator& D, DeclContext* DC,
2073  TypeSourceInfo *TInfo,
2074  LookupResult &Previous,
2075  MultiTemplateParamsArg TemplateParamLists,
2076  bool &AddToScope);
2077  bool AddOverriddenMethods(CXXRecordDecl *DC, CXXMethodDecl *MD);
2078 
2079  bool CheckConstexprFunctionDecl(const FunctionDecl *FD);
2080  bool CheckConstexprFunctionBody(const FunctionDecl *FD, Stmt *Body);
2081 
2082  void DiagnoseHiddenVirtualMethods(CXXMethodDecl *MD);
2083  void FindHiddenVirtualMethods(CXXMethodDecl *MD,
2084  SmallVectorImpl<CXXMethodDecl*> &OverloadedMethods);
2085  void NoteHiddenVirtualMethods(CXXMethodDecl *MD,
2086  SmallVectorImpl<CXXMethodDecl*> &OverloadedMethods);
2087  // Returns true if the function declaration is a redeclaration
2088  bool CheckFunctionDeclaration(Scope *S,
2089  FunctionDecl *NewFD, LookupResult &Previous,
2090  bool IsMemberSpecialization);
2091  bool shouldLinkDependentDeclWithPrevious(Decl *D, Decl *OldDecl);
2092  bool canFullyTypeCheckRedeclaration(ValueDecl *NewD, ValueDecl *OldD,
2093  QualType NewT, QualType OldT);
2094  void CheckMain(FunctionDecl *FD, const DeclSpec &D);
2095  void CheckMSVCRTEntryPoint(FunctionDecl *FD);
2096  Attr *getImplicitCodeSegOrSectionAttrForFunction(const FunctionDecl *FD,
2097  bool IsDefinition);
2098  void CheckFunctionOrTemplateParamDeclarator(Scope *S, Declarator &D);
2099  Decl *ActOnParamDeclarator(Scope *S, Declarator &D);
2100  ParmVarDecl *BuildParmVarDeclForTypedef(DeclContext *DC,
2101  SourceLocation Loc,
2102  QualType T);
2103  ParmVarDecl *CheckParameter(DeclContext *DC, SourceLocation StartLoc,
2104  SourceLocation NameLoc, IdentifierInfo *Name,
2105  QualType T, TypeSourceInfo *TSInfo,
2106  StorageClass SC);
2107  void ActOnParamDefaultArgument(Decl *param,
2108  SourceLocation EqualLoc,
2109  Expr *defarg);
2110  void ActOnParamUnparsedDefaultArgument(Decl *param,
2111  SourceLocation EqualLoc,
2112  SourceLocation ArgLoc);
2113  void ActOnParamDefaultArgumentError(Decl *param, SourceLocation EqualLoc);
2114  bool SetParamDefaultArgument(ParmVarDecl *Param, Expr *DefaultArg,
2115  SourceLocation EqualLoc);
2116 
2117  // Contexts where using non-trivial C union types can be disallowed. This is
2118  // passed to err_non_trivial_c_union_in_invalid_context.
2120  // Function parameter.
2122  // Function return.
2124  // Default-initialized object.
2126  // Variable with automatic storage duration.
2128  // Initializer expression that might copy from another object.
2130  // Assignment.
2132  // Compound literal.
2134  // Block capture.
2136  // lvalue-to-rvalue conversion of volatile type.
2138  };
2139 
2140  /// Emit diagnostics if the initializer or any of its explicit or
2141  /// implicitly-generated subexpressions require copying or
2142  /// default-initializing a type that is or contains a C union type that is
2143  /// non-trivial to copy or default-initialize.
2144  void checkNonTrivialCUnionInInitializer(const Expr *Init, SourceLocation Loc);
2145 
2146  // These flags are passed to checkNonTrivialCUnion.
2148  NTCUK_Init = 0x1,
2149  NTCUK_Destruct = 0x2,
2150  NTCUK_Copy = 0x4,
2151  };
2152 
2153  /// Emit diagnostics if a non-trivial C union type or a struct that contains
2154  /// a non-trivial C union is used in an invalid context.
2155  void checkNonTrivialCUnion(QualType QT, SourceLocation Loc,
2156  NonTrivialCUnionContext UseContext,
2157  unsigned NonTrivialKind);
2158 
2159  void AddInitializerToDecl(Decl *dcl, Expr *init, bool DirectInit);
2160  void ActOnUninitializedDecl(Decl *dcl);
2161  void ActOnInitializerError(Decl *Dcl);
2162 
2163  void ActOnPureSpecifier(Decl *D, SourceLocation PureSpecLoc);
2164  void ActOnCXXForRangeDecl(Decl *D);
2165  StmtResult ActOnCXXForRangeIdentifier(Scope *S, SourceLocation IdentLoc,
2166  IdentifierInfo *Ident,
2167  ParsedAttributes &Attrs,
2168  SourceLocation AttrEnd);
2169  void SetDeclDeleted(Decl *dcl, SourceLocation DelLoc);
2170  void SetDeclDefaulted(Decl *dcl, SourceLocation DefaultLoc);
2171  void CheckStaticLocalForDllExport(VarDecl *VD);
2172  void FinalizeDeclaration(Decl *D);
2173  DeclGroupPtrTy FinalizeDeclaratorGroup(Scope *S, const DeclSpec &DS,
2174  ArrayRef<Decl *> Group);
2175  DeclGroupPtrTy BuildDeclaratorGroup(MutableArrayRef<Decl *> Group);
2176 
2177  /// Should be called on all declarations that might have attached
2178  /// documentation comments.
2179  void ActOnDocumentableDecl(Decl *D);
2180  void ActOnDocumentableDecls(ArrayRef<Decl *> Group);
2181 
2182  void ActOnFinishKNRParamDeclarations(Scope *S, Declarator &D,
2183  SourceLocation LocAfterDecls);
2184  void CheckForFunctionRedefinition(
2185  FunctionDecl *FD, const FunctionDecl *EffectiveDefinition = nullptr,
2186  SkipBodyInfo *SkipBody = nullptr);
2187  Decl *ActOnStartOfFunctionDef(Scope *S, Declarator &D,
2188  MultiTemplateParamsArg TemplateParamLists,
2189  SkipBodyInfo *SkipBody = nullptr);
2190  Decl *ActOnStartOfFunctionDef(Scope *S, Decl *D,
2191  SkipBodyInfo *SkipBody = nullptr);
2192  void ActOnStartOfObjCMethodDef(Scope *S, Decl *D);
2194  return D && isa<ObjCMethodDecl>(D);
2195  }
2196 
2197  /// Determine whether we can delay parsing the body of a function or
2198  /// function template until it is used, assuming we don't care about emitting
2199  /// code for that function.
2200  ///
2201  /// This will be \c false if we may need the body of the function in the
2202  /// middle of parsing an expression (where it's impractical to switch to
2203  /// parsing a different function), for instance, if it's constexpr in C++11
2204  /// or has an 'auto' return type in C++14. These cases are essentially bugs.
2205  bool canDelayFunctionBody(const Declarator &D);
2206 
2207  /// Determine whether we can skip parsing the body of a function
2208  /// definition, assuming we don't care about analyzing its body or emitting
2209  /// code for that function.
2210  ///
2211  /// This will be \c false only if we may need the body of the function in
2212  /// order to parse the rest of the program (for instance, if it is
2213  /// \c constexpr in C++11 or has an 'auto' return type in C++14).
2214  bool canSkipFunctionBody(Decl *D);
2215 
2216  void computeNRVO(Stmt *Body, sema::FunctionScopeInfo *Scope);
2217  Decl *ActOnFinishFunctionBody(Decl *Decl, Stmt *Body);
2218  Decl *ActOnFinishFunctionBody(Decl *Decl, Stmt *Body, bool IsInstantiation);
2219  Decl *ActOnSkippedFunctionBody(Decl *Decl);
2220  void ActOnFinishInlineFunctionDef(FunctionDecl *D);
2221 
2222  /// ActOnFinishDelayedAttribute - Invoked when we have finished parsing an
2223  /// attribute for which parsing is delayed.
2224  void ActOnFinishDelayedAttribute(Scope *S, Decl *D, ParsedAttributes &Attrs);
2225 
2226  /// Diagnose any unused parameters in the given sequence of
2227  /// ParmVarDecl pointers.
2228  void DiagnoseUnusedParameters(ArrayRef<ParmVarDecl *> Parameters);
2229 
2230  /// Diagnose whether the size of parameters or return value of a
2231  /// function or obj-c method definition is pass-by-value and larger than a
2232  /// specified threshold.
2233  void
2234  DiagnoseSizeOfParametersAndReturnValue(ArrayRef<ParmVarDecl *> Parameters,
2235  QualType ReturnTy, NamedDecl *D);
2236 
2237  void DiagnoseInvalidJumps(Stmt *Body);
2238  Decl *ActOnFileScopeAsmDecl(Expr *expr,
2239  SourceLocation AsmLoc,
2240  SourceLocation RParenLoc);
2241 
2242  /// Handle a C++11 empty-declaration and attribute-declaration.
2243  Decl *ActOnEmptyDeclaration(Scope *S, const ParsedAttributesView &AttrList,
2244  SourceLocation SemiLoc);
2245 
2246  enum class ModuleDeclKind {
2247  Interface, ///< 'export module X;'
2248  Implementation, ///< 'module X;'
2249  };
2250 
2251  /// The parser has processed a module-declaration that begins the definition
2252  /// of a module interface or implementation.
2253  DeclGroupPtrTy ActOnModuleDecl(SourceLocation StartLoc,
2254  SourceLocation ModuleLoc, ModuleDeclKind MDK,
2255  ModuleIdPath Path, bool IsFirstDecl);
2256 
2257  /// The parser has processed a global-module-fragment declaration that begins
2258  /// the definition of the global module fragment of the current module unit.
2259  /// \param ModuleLoc The location of the 'module' keyword.
2260  DeclGroupPtrTy ActOnGlobalModuleFragmentDecl(SourceLocation ModuleLoc);
2261 
2262  /// The parser has processed a private-module-fragment declaration that begins
2263  /// the definition of the private module fragment of the current module unit.
2264  /// \param ModuleLoc The location of the 'module' keyword.
2265  /// \param PrivateLoc The location of the 'private' keyword.
2266  DeclGroupPtrTy ActOnPrivateModuleFragmentDecl(SourceLocation ModuleLoc,
2267  SourceLocation PrivateLoc);
2268 
2269  /// The parser has processed a module import declaration.
2270  ///
2271  /// \param StartLoc The location of the first token in the declaration. This
2272  /// could be the location of an '@', 'export', or 'import'.
2273  /// \param ExportLoc The location of the 'export' keyword, if any.
2274  /// \param ImportLoc The location of the 'import' keyword.
2275  /// \param Path The module access path.
2276  DeclResult ActOnModuleImport(SourceLocation StartLoc,
2277  SourceLocation ExportLoc,
2278  SourceLocation ImportLoc, ModuleIdPath Path);
2279  DeclResult ActOnModuleImport(SourceLocation StartLoc,
2280  SourceLocation ExportLoc,
2281  SourceLocation ImportLoc, Module *M,
2282  ModuleIdPath Path = {});
2283 
2284  /// The parser has processed a module import translated from a
2285  /// #include or similar preprocessing directive.
2286  void ActOnModuleInclude(SourceLocation DirectiveLoc, Module *Mod);
2287  void BuildModuleInclude(SourceLocation DirectiveLoc, Module *Mod);
2288 
2289  /// The parsed has entered a submodule.
2290  void ActOnModuleBegin(SourceLocation DirectiveLoc, Module *Mod);
2291  /// The parser has left a submodule.
2292  void ActOnModuleEnd(SourceLocation DirectiveLoc, Module *Mod);
2293 
2294  /// Create an implicit import of the given module at the given
2295  /// source location, for error recovery, if possible.
2296  ///
2297  /// This routine is typically used when an entity found by name lookup
2298  /// is actually hidden within a module that we know about but the user
2299  /// has forgotten to import.
2300  void createImplicitModuleImportForErrorRecovery(SourceLocation Loc,
2301  Module *Mod);
2302 
2303  /// Kinds of missing import. Note, the values of these enumerators correspond
2304  /// to %select values in diagnostics.
2305  enum class MissingImportKind {
2306  Declaration,
2307  Definition,
2308  DefaultArgument,
2309  ExplicitSpecialization,
2310  PartialSpecialization
2311  };
2312 
2313  /// Diagnose that the specified declaration needs to be visible but
2314  /// isn't, and suggest a module import that would resolve the problem.
2315  void diagnoseMissingImport(SourceLocation Loc, NamedDecl *Decl,
2316  MissingImportKind MIK, bool Recover = true);
2317  void diagnoseMissingImport(SourceLocation Loc, NamedDecl *Decl,
2318  SourceLocation DeclLoc, ArrayRef<Module *> Modules,
2319  MissingImportKind MIK, bool Recover);
2320 
2321  Decl *ActOnStartExportDecl(Scope *S, SourceLocation ExportLoc,
2322  SourceLocation LBraceLoc);
2323  Decl *ActOnFinishExportDecl(Scope *S, Decl *ExportDecl,
2324  SourceLocation RBraceLoc);
2325 
2326  /// We've found a use of a templated declaration that would trigger an
2327  /// implicit instantiation. Check that any relevant explicit specializations
2328  /// and partial specializations are visible, and diagnose if not.
2329  void checkSpecializationVisibility(SourceLocation Loc, NamedDecl *Spec);
2330 
2331  /// We've found a use of a template specialization that would select a
2332  /// partial specialization. Check that the partial specialization is visible,
2333  /// and diagnose if not.
2334  void checkPartialSpecializationVisibility(SourceLocation Loc,
2335  NamedDecl *Spec);
2336 
2337  /// Retrieve a suitable printing policy for diagnostics.
2339  return getPrintingPolicy(Context, PP);
2340  }
2341 
2342  /// Retrieve a suitable printing policy for diagnostics.
2343  static PrintingPolicy getPrintingPolicy(const ASTContext &Ctx,
2344  const Preprocessor &PP);
2345 
2346  /// Scope actions.
2347  void ActOnPopScope(SourceLocation Loc, Scope *S);
2348  void ActOnTranslationUnitScope(Scope *S);
2349 
2350  Decl *ParsedFreeStandingDeclSpec(Scope *S, AccessSpecifier AS, DeclSpec &DS,
2351  RecordDecl *&AnonRecord);
2352  Decl *ParsedFreeStandingDeclSpec(Scope *S, AccessSpecifier AS, DeclSpec &DS,
2353  MultiTemplateParamsArg TemplateParams,
2354  bool IsExplicitInstantiation,
2355  RecordDecl *&AnonRecord);
2356 
2357  Decl *BuildAnonymousStructOrUnion(Scope *S, DeclSpec &DS,
2358  AccessSpecifier AS,
2359  RecordDecl *Record,
2360  const PrintingPolicy &Policy);
2361 
2362  Decl *BuildMicrosoftCAnonymousStruct(Scope *S, DeclSpec &DS,
2363  RecordDecl *Record);
2364 
2365  /// Common ways to introduce type names without a tag for use in diagnostics.
2366  /// Keep in sync with err_tag_reference_non_tag.
2367  enum NonTagKind {
2377  };
2378 
2379  /// Given a non-tag type declaration, returns an enum useful for indicating
2380  /// what kind of non-tag type this is.
2381  NonTagKind getNonTagTypeDeclKind(const Decl *D, TagTypeKind TTK);
2382 
2383  bool isAcceptableTagRedeclaration(const TagDecl *Previous,
2384  TagTypeKind NewTag, bool isDefinition,
2385  SourceLocation NewTagLoc,
2386  const IdentifierInfo *Name);
2387 
2388  enum TagUseKind {
2389  TUK_Reference, // Reference to a tag: 'struct foo *X;'
2390  TUK_Declaration, // Fwd decl of a tag: 'struct foo;'
2391  TUK_Definition, // Definition of a tag: 'struct foo { int X; } Y;'
2392  TUK_Friend // Friend declaration: 'friend struct foo;'
2393  };
2394 
2395  Decl *ActOnTag(Scope *S, unsigned TagSpec, TagUseKind TUK,
2396  SourceLocation KWLoc, CXXScopeSpec &SS, IdentifierInfo *Name,
2397  SourceLocation NameLoc, const ParsedAttributesView &Attr,
2398  AccessSpecifier AS, SourceLocation ModulePrivateLoc,
2399  MultiTemplateParamsArg TemplateParameterLists, bool &OwnedDecl,
2400  bool &IsDependent, SourceLocation ScopedEnumKWLoc,
2401  bool ScopedEnumUsesClassTag, TypeResult UnderlyingType,
2402  bool IsTypeSpecifier, bool IsTemplateParamOrArg,
2403  SkipBodyInfo *SkipBody = nullptr);
2404 
2405  Decl *ActOnTemplatedFriendTag(Scope *S, SourceLocation FriendLoc,
2406  unsigned TagSpec, SourceLocation TagLoc,
2407  CXXScopeSpec &SS, IdentifierInfo *Name,
2408  SourceLocation NameLoc,
2409  const ParsedAttributesView &Attr,
2410  MultiTemplateParamsArg TempParamLists);
2411 
2412  TypeResult ActOnDependentTag(Scope *S,
2413  unsigned TagSpec,
2414  TagUseKind TUK,
2415  const CXXScopeSpec &SS,
2416  IdentifierInfo *Name,
2417  SourceLocation TagLoc,
2418  SourceLocation NameLoc);
2419 
2420  void ActOnDefs(Scope *S, Decl *TagD, SourceLocation DeclStart,
2421  IdentifierInfo *ClassName,
2422  SmallVectorImpl<Decl *> &Decls);
2423  Decl *ActOnField(Scope *S, Decl *TagD, SourceLocation DeclStart,
2424  Declarator &D, Expr *BitfieldWidth);
2425 
2426  FieldDecl *HandleField(Scope *S, RecordDecl *TagD, SourceLocation DeclStart,
2427  Declarator &D, Expr *BitfieldWidth,
2428  InClassInitStyle InitStyle,
2429  AccessSpecifier AS);
2430  MSPropertyDecl *HandleMSProperty(Scope *S, RecordDecl *TagD,
2431  SourceLocation DeclStart, Declarator &D,
2432  Expr *BitfieldWidth,
2433  InClassInitStyle InitStyle,
2434  AccessSpecifier AS,
2435  const ParsedAttr &MSPropertyAttr);
2436 
2437  FieldDecl *CheckFieldDecl(DeclarationName Name, QualType T,
2438  TypeSourceInfo *TInfo,
2439  RecordDecl *Record, SourceLocation Loc,
2440  bool Mutable, Expr *BitfieldWidth,
2441  InClassInitStyle InitStyle,
2442  SourceLocation TSSL,
2443  AccessSpecifier AS, NamedDecl *PrevDecl,
2444  Declarator *D = nullptr);
2445 
2446  bool CheckNontrivialField(FieldDecl *FD);
2447  void DiagnoseNontrivial(const CXXRecordDecl *Record, CXXSpecialMember CSM);
2448 
2450  /// The triviality of a method unaffected by "trivial_abi".
2452 
2453  /// The triviality of a method affected by "trivial_abi".
2454  TAH_ConsiderTrivialABI
2455  };
2456 
2457  bool SpecialMemberIsTrivial(CXXMethodDecl *MD, CXXSpecialMember CSM,
2458  TrivialABIHandling TAH = TAH_IgnoreTrivialABI,
2459  bool Diagnose = false);
2460  CXXSpecialMember getSpecialMember(const CXXMethodDecl *MD);
2461  void ActOnLastBitfield(SourceLocation DeclStart,
2462  SmallVectorImpl<Decl *> &AllIvarDecls);
2463  Decl *ActOnIvar(Scope *S, SourceLocation DeclStart,
2464  Declarator &D, Expr *BitfieldWidth,
2465  tok::ObjCKeywordKind visibility);
2466 
2467  // This is used for both record definitions and ObjC interface declarations.
2468  void ActOnFields(Scope *S, SourceLocation RecLoc, Decl *TagDecl,
2469  ArrayRef<Decl *> Fields, SourceLocation LBrac,
2470  SourceLocation RBrac, const ParsedAttributesView &AttrList);
2471 
2472  /// ActOnTagStartDefinition - Invoked when we have entered the
2473  /// scope of a tag's definition (e.g., for an enumeration, class,
2474  /// struct, or union).
2475  void ActOnTagStartDefinition(Scope *S, Decl *TagDecl);
2476 
2477  /// Perform ODR-like check for C/ObjC when merging tag types from modules.
2478  /// Differently from C++, actually parse the body and reject / error out
2479  /// in case of a structural mismatch.
2480  bool ActOnDuplicateDefinition(DeclSpec &DS, Decl *Prev,
2481  SkipBodyInfo &SkipBody);
2482 
2484 
2485  /// Invoked when we enter a tag definition that we're skipping.
2486  SkippedDefinitionContext ActOnTagStartSkippedDefinition(Scope *S, Decl *TD);
2487 
2488  Decl *ActOnObjCContainerStartDefinition(Decl *IDecl);
2489 
2490  /// ActOnStartCXXMemberDeclarations - Invoked when we have parsed a
2491  /// C++ record definition's base-specifiers clause and are starting its
2492  /// member declarations.
2493  void ActOnStartCXXMemberDeclarations(Scope *S, Decl *TagDecl,
2494  SourceLocation FinalLoc,
2495  bool IsFinalSpelledSealed,
2496  SourceLocation LBraceLoc);
2497 
2498  /// ActOnTagFinishDefinition - Invoked once we have finished parsing
2499  /// the definition of a tag (enumeration, class, struct, or union).
2500  void ActOnTagFinishDefinition(Scope *S, Decl *TagDecl,
2501  SourceRange BraceRange);
2502 
2503  void ActOnTagFinishSkippedDefinition(SkippedDefinitionContext Context);
2504 
2505  void ActOnObjCContainerFinishDefinition();
2506 
2507  /// Invoked when we must temporarily exit the objective-c container
2508  /// scope for parsing/looking-up C constructs.
2509  ///
2510  /// Must be followed by a call to \see ActOnObjCReenterContainerContext
2511  void ActOnObjCTemporaryExitContainerContext(DeclContext *DC);
2512  void ActOnObjCReenterContainerContext(DeclContext *DC);
2513 
2514  /// ActOnTagDefinitionError - Invoked when there was an unrecoverable
2515  /// error parsing the definition of a tag.
2516  void ActOnTagDefinitionError(Scope *S, Decl *TagDecl);
2517 
2518  EnumConstantDecl *CheckEnumConstant(EnumDecl *Enum,
2519  EnumConstantDecl *LastEnumConst,
2520  SourceLocation IdLoc,
2521  IdentifierInfo *Id,
2522  Expr *val);
2523  bool CheckEnumUnderlyingType(TypeSourceInfo *TI);
2524  bool CheckEnumRedeclaration(SourceLocation EnumLoc, bool IsScoped,
2525  QualType EnumUnderlyingTy, bool IsFixed,
2526  const EnumDecl *Prev);
2527 
2528  /// Determine whether the body of an anonymous enumeration should be skipped.
2529  /// \param II The name of the first enumerator.
2530  SkipBodyInfo shouldSkipAnonEnumBody(Scope *S, IdentifierInfo *II,
2531  SourceLocation IILoc);
2532 
2533  Decl *ActOnEnumConstant(Scope *S, Decl *EnumDecl, Decl *LastEnumConstant,
2535  const ParsedAttributesView &Attrs,
2536  SourceLocation EqualLoc, Expr *Val);
2537  void ActOnEnumBody(SourceLocation EnumLoc, SourceRange BraceRange,
2538  Decl *EnumDecl, ArrayRef<Decl *> Elements, Scope *S,
2539  const ParsedAttributesView &Attr);
2540 
2541  DeclContext *getContainingDC(DeclContext *DC);
2542 
2543  /// Set the current declaration context until it gets popped.
2544  void PushDeclContext(Scope *S, DeclContext *DC);
2545  void PopDeclContext();
2546 
2547  /// EnterDeclaratorContext - Used when we must lookup names in the context
2548  /// of a declarator's nested name specifier.
2549  void EnterDeclaratorContext(Scope *S, DeclContext *DC);
2550  void ExitDeclaratorContext(Scope *S);
2551 
2552  /// Push the parameters of D, which must be a function, into scope.
2553  void ActOnReenterFunctionContext(Scope* S, Decl* D);
2554  void ActOnExitFunctionContext();
2555 
2556  DeclContext *getFunctionLevelDeclContext();
2557 
2558  /// getCurFunctionDecl - If inside of a function body, this returns a pointer
2559  /// to the function decl for the function being parsed. If we're currently
2560  /// in a 'block', this returns the containing context.
2561  FunctionDecl *getCurFunctionDecl();
2562 
2563  /// getCurMethodDecl - If inside of a method body, this returns a pointer to
2564  /// the method decl for the method being parsed. If we're currently
2565  /// in a 'block', this returns the containing context.
2566  ObjCMethodDecl *getCurMethodDecl();
2567 
2568  /// getCurFunctionOrMethodDecl - Return the Decl for the current ObjC method
2569  /// or C function we're in, otherwise return null. If we're currently
2570  /// in a 'block', this returns the containing context.
2571  NamedDecl *getCurFunctionOrMethodDecl();
2572 
2573  /// Add this decl to the scope shadowed decl chains.
2574  void PushOnScopeChains(NamedDecl *D, Scope *S, bool AddToContext = true);
2575 
2576  /// isDeclInScope - If 'Ctx' is a function/method, isDeclInScope returns true
2577  /// if 'D' is in Scope 'S', otherwise 'S' is ignored and isDeclInScope returns
2578  /// true if 'D' belongs to the given declaration context.
2579  ///
2580  /// \param AllowInlineNamespace If \c true, allow the declaration to be in the
2581  /// enclosing namespace set of the context, rather than contained
2582  /// directly within it.
2583  bool isDeclInScope(NamedDecl *D, DeclContext *Ctx, Scope *S = nullptr,
2584  bool AllowInlineNamespace = false);
2585 
2586  /// Finds the scope corresponding to the given decl context, if it
2587  /// happens to be an enclosing scope. Otherwise return NULL.
2588  static Scope *getScopeForDeclContext(Scope *S, DeclContext *DC);
2589 
2590  /// Subroutines of ActOnDeclarator().
2591  TypedefDecl *ParseTypedefDecl(Scope *S, Declarator &D, QualType T,
2592  TypeSourceInfo *TInfo);
2593  bool isIncompatibleTypedef(TypeDecl *Old, TypedefNameDecl *New);
2594 
2595  /// Describes the kind of merge to perform for availability
2596  /// attributes (including "deprecated", "unavailable", and "availability").
2598  /// Don't merge availability attributes at all.
2600  /// Merge availability attributes for a redeclaration, which requires
2601  /// an exact match.
2603  /// Merge availability attributes for an override, which requires
2604  /// an exact match or a weakening of constraints.
2606  /// Merge availability attributes for an implementation of
2607  /// a protocol requirement.
2609  };
2610 
2611  /// Describes the kind of priority given to an availability attribute.
2612  ///
2613  /// The sum of priorities deteremines the final priority of the attribute.
2614  /// The final priority determines how the attribute will be merged.
2615  /// An attribute with a lower priority will always remove higher priority
2616  /// attributes for the specified platform when it is being applied. An
2617  /// attribute with a higher priority will not be applied if the declaration
2618  /// already has an availability attribute with a lower priority for the
2619  /// specified platform. The final prirority values are not expected to match
2620  /// the values in this enumeration, but instead should be treated as a plain
2621  /// integer value. This enumeration just names the priority weights that are
2622  /// used to calculate that final vaue.
2624  /// The availability attribute was specified explicitly next to the
2625  /// declaration.
2626  AP_Explicit = 0,
2627 
2628  /// The availability attribute was applied using '#pragma clang attribute'.
2629  AP_PragmaClangAttribute = 1,
2630 
2631  /// The availability attribute for a specific platform was inferred from
2632  /// an availability attribute for another platform.
2633  AP_InferredFromOtherPlatform = 2
2634  };
2635 
2636  /// Attribute merging methods. Return true if a new attribute was added.
2637  AvailabilityAttr *mergeAvailabilityAttr(
2638  NamedDecl *D, SourceRange Range, IdentifierInfo *Platform, bool Implicit,
2639  VersionTuple Introduced, VersionTuple Deprecated, VersionTuple Obsoleted,
2640  bool IsUnavailable, StringRef Message, bool IsStrict,
2641  StringRef Replacement, AvailabilityMergeKind AMK, int Priority,
2642  unsigned AttrSpellingListIndex);
2643  TypeVisibilityAttr *mergeTypeVisibilityAttr(Decl *D, SourceRange Range,
2644  TypeVisibilityAttr::VisibilityType Vis,
2645  unsigned AttrSpellingListIndex);
2646  VisibilityAttr *mergeVisibilityAttr(Decl *D, SourceRange Range,
2647  VisibilityAttr::VisibilityType Vis,
2648  unsigned AttrSpellingListIndex);
2649  UuidAttr *mergeUuidAttr(Decl *D, SourceRange Range,
2650  unsigned AttrSpellingListIndex, StringRef Uuid);
2651  DLLImportAttr *mergeDLLImportAttr(Decl *D, SourceRange Range,
2652  unsigned AttrSpellingListIndex);
2653  DLLExportAttr *mergeDLLExportAttr(Decl *D, SourceRange Range,
2654  unsigned AttrSpellingListIndex);
2655  MSInheritanceAttr *
2656  mergeMSInheritanceAttr(Decl *D, SourceRange Range, bool BestCase,
2657  unsigned AttrSpellingListIndex,
2658  MSInheritanceAttr::Spelling SemanticSpelling);
2659  FormatAttr *mergeFormatAttr(Decl *D, SourceRange Range,
2660  IdentifierInfo *Format, int FormatIdx,
2661  int FirstArg, unsigned AttrSpellingListIndex);
2662  SectionAttr *mergeSectionAttr(Decl *D, SourceRange Range, StringRef Name,
2663  unsigned AttrSpellingListIndex);
2664  CodeSegAttr *mergeCodeSegAttr(Decl *D, SourceRange Range, StringRef Name,
2665  unsigned AttrSpellingListIndex);
2666  AlwaysInlineAttr *mergeAlwaysInlineAttr(Decl *D, SourceRange Range,
2667  IdentifierInfo *Ident,
2668  unsigned AttrSpellingListIndex);
2669  MinSizeAttr *mergeMinSizeAttr(Decl *D, SourceRange Range,
2670  unsigned AttrSpellingListIndex);
2671  NoSpeculativeLoadHardeningAttr *
2672  mergeNoSpeculativeLoadHardeningAttr(Decl *D,
2673  const NoSpeculativeLoadHardeningAttr &AL);
2674  SpeculativeLoadHardeningAttr *
2675  mergeSpeculativeLoadHardeningAttr(Decl *D,
2676  const SpeculativeLoadHardeningAttr &AL);
2677  OptimizeNoneAttr *mergeOptimizeNoneAttr(Decl *D, SourceRange Range,
2678  unsigned AttrSpellingListIndex);
2679  InternalLinkageAttr *mergeInternalLinkageAttr(Decl *D, const ParsedAttr &AL);
2680  InternalLinkageAttr *mergeInternalLinkageAttr(Decl *D,
2681  const InternalLinkageAttr &AL);
2682  CommonAttr *mergeCommonAttr(Decl *D, const ParsedAttr &AL);
2683  CommonAttr *mergeCommonAttr(Decl *D, const CommonAttr &AL);
2684 
2685  void mergeDeclAttributes(NamedDecl *New, Decl *Old,
2686  AvailabilityMergeKind AMK = AMK_Redeclaration);
2687  void MergeTypedefNameDecl(Scope *S, TypedefNameDecl *New,
2688  LookupResult &OldDecls);
2689  bool MergeFunctionDecl(FunctionDecl *New, NamedDecl *&Old, Scope *S,
2690  bool MergeTypeWithOld);
2691  bool MergeCompatibleFunctionDecls(FunctionDecl *New, FunctionDecl *Old,
2692  Scope *S, bool MergeTypeWithOld);
2693  void mergeObjCMethodDecls(ObjCMethodDecl *New, ObjCMethodDecl *Old);
2694  void MergeVarDecl(VarDecl *New, LookupResult &Previous);
2695  void MergeVarDeclTypes(VarDecl *New, VarDecl *Old, bool MergeTypeWithOld);
2696  void MergeVarDeclExceptionSpecs(VarDecl *New, VarDecl *Old);
2697  bool checkVarDeclRedefinition(VarDecl *OldDefn, VarDecl *NewDefn);
2698  void notePreviousDefinition(const NamedDecl *Old, SourceLocation New);
2699  bool MergeCXXFunctionDecl(FunctionDecl *New, FunctionDecl *Old, Scope *S);
2700 
2701  // AssignmentAction - This is used by all the assignment diagnostic functions
2702  // to represent what is actually causing the operation
2711  AA_Passing_CFAudited
2712  };
2713 
2714  /// C++ Overloading.
2716  /// This is a legitimate overload: the existing declarations are
2717  /// functions or function templates with different signatures.
2719 
2720  /// This is not an overload because the signature exactly matches
2721  /// an existing declaration.
2723 
2724  /// This is not an overload because the lookup results contain a
2725  /// non-function.
2726  Ovl_NonFunction
2727  };
2728  OverloadKind CheckOverload(Scope *S,
2729  FunctionDecl *New,
2730  const LookupResult &OldDecls,
2731  NamedDecl *&OldDecl,
2732  bool IsForUsingDecl);
2733  bool IsOverload(FunctionDecl *New, FunctionDecl *Old, bool IsForUsingDecl,
2734  bool ConsiderCudaAttrs = true);
2735 
2737  TryImplicitConversion(Expr *From, QualType ToType,
2738  bool SuppressUserConversions,
2739  bool AllowExplicit,
2740  bool InOverloadResolution,
2741  bool CStyle,
2742  bool AllowObjCWritebackConversion);
2743 
2744  bool IsIntegralPromotion(Expr *From, QualType FromType, QualType ToType);
2745  bool IsFloatingPointPromotion(QualType FromType, QualType ToType);
2746  bool IsComplexPromotion(QualType FromType, QualType ToType);
2747  bool IsPointerConversion(Expr *From, QualType FromType, QualType ToType,
2748  bool InOverloadResolution,
2749  QualType& ConvertedType, bool &IncompatibleObjC);
2750  bool isObjCPointerConversion(QualType FromType, QualType ToType,
2751  QualType& ConvertedType, bool &IncompatibleObjC);
2752  bool isObjCWritebackConversion(QualType FromType, QualType ToType,
2753  QualType &ConvertedType);
2754  bool IsBlockPointerConversion(QualType FromType, QualType ToType,
2755  QualType& ConvertedType);
2756  bool FunctionParamTypesAreEqual(const FunctionProtoType *OldType,
2757  const FunctionProtoType *NewType,
2758  unsigned *ArgPos = nullptr);
2759  void HandleFunctionTypeMismatch(PartialDiagnostic &PDiag,
2760  QualType FromType, QualType ToType);
2761 
2762  void maybeExtendBlockObject(ExprResult &E);
2763  CastKind PrepareCastToObjCObjectPointer(ExprResult &E);
2764  bool CheckPointerConversion(Expr *From, QualType ToType,
2765  CastKind &Kind,
2766  CXXCastPath& BasePath,
2767  bool IgnoreBaseAccess,
2768  bool Diagnose = true);
2769  bool IsMemberPointerConversion(Expr *From, QualType FromType, QualType ToType,
2770  bool InOverloadResolution,
2771  QualType &ConvertedType);
2772  bool CheckMemberPointerConversion(Expr *From, QualType ToType,
2773  CastKind &Kind,
2774  CXXCastPath &BasePath,
2775  bool IgnoreBaseAccess);
2776  bool IsQualificationConversion(QualType FromType, QualType ToType,
2777  bool CStyle, bool &ObjCLifetimeConversion);
2778  bool IsFunctionConversion(QualType FromType, QualType ToType,
2779  QualType &ResultTy);
2780  bool DiagnoseMultipleUserDefinedConversion(Expr *From, QualType ToType);
2781  bool isSameOrCompatibleFunctionType(CanQualType Param, CanQualType Arg);
2782 
2783  ExprResult PerformMoveOrCopyInitialization(const InitializedEntity &Entity,
2784  const VarDecl *NRVOCandidate,
2785  QualType ResultType,
2786  Expr *Value,
2787  bool AllowNRVO = true);
2788 
2789  bool CanPerformCopyInitialization(const InitializedEntity &Entity,
2790  ExprResult Init);
2791  ExprResult PerformCopyInitialization(const InitializedEntity &Entity,
2792  SourceLocation EqualLoc,
2793  ExprResult Init,
2794  bool TopLevelOfInitList = false,
2795  bool AllowExplicit = false);
2796  ExprResult PerformObjectArgumentInitialization(Expr *From,
2797  NestedNameSpecifier *Qualifier,
2798  NamedDecl *FoundDecl,
2799  CXXMethodDecl *Method);
2800 
2801  /// Check that the lifetime of the initializer (and its subobjects) is
2802  /// sufficient for initializing the entity, and perform lifetime extension
2803  /// (when permitted) if not.
2804  void checkInitializerLifetime(const InitializedEntity &Entity, Expr *Init);
2805 
2806  ExprResult PerformContextuallyConvertToBool(Expr *From);
2807  ExprResult PerformContextuallyConvertToObjCPointer(Expr *From);
2808 
2809  /// Contexts in which a converted constant expression is required.
2810  enum CCEKind {
2811  CCEK_CaseValue, ///< Expression in a case label.
2812  CCEK_Enumerator, ///< Enumerator value with fixed underlying type.
2813  CCEK_TemplateArg, ///< Value of a non-type template parameter.
2814  CCEK_NewExpr, ///< Constant expression in a noptr-new-declarator.
2815  CCEK_ConstexprIf, ///< Condition in a constexpr if statement.
2816  CCEK_ExplicitBool ///< Condition in an explicit(bool) specifier.
2817  };
2819  llvm::APSInt &Value, CCEKind CCE);
2821  APValue &Value, CCEKind CCE);
2822 
2823  /// Abstract base class used to perform a contextual implicit
2824  /// conversion from an expression to any type passing a filter.
2826  public:
2827  bool Suppress;
2829 
2830  ContextualImplicitConverter(bool Suppress = false,
2831  bool SuppressConversion = false)
2832  : Suppress(Suppress), SuppressConversion(SuppressConversion) {}
2833 
2834  /// Determine whether the specified type is a valid destination type
2835  /// for this conversion.
2836  virtual bool match(QualType T) = 0;
2837 
2838  /// Emits a diagnostic complaining that the expression does not have
2839  /// integral or enumeration type.
2840  virtual SemaDiagnosticBuilder
2841  diagnoseNoMatch(Sema &S, SourceLocation Loc, QualType T) = 0;
2842 
2843  /// Emits a diagnostic when the expression has incomplete class type.
2844  virtual SemaDiagnosticBuilder
2845  diagnoseIncomplete(Sema &S, SourceLocation Loc, QualType T) = 0;
2846 
2847  /// Emits a diagnostic when the only matching conversion function
2848  /// is explicit.
2849  virtual SemaDiagnosticBuilder diagnoseExplicitConv(
2850  Sema &S, SourceLocation Loc, QualType T, QualType ConvTy) = 0;
2851 
2852  /// Emits a note for the explicit conversion function.
2853  virtual SemaDiagnosticBuilder
2854  noteExplicitConv(Sema &S, CXXConversionDecl *Conv, QualType ConvTy) = 0;
2855 
2856  /// Emits a diagnostic when there are multiple possible conversion
2857  /// functions.
2858  virtual SemaDiagnosticBuilder
2859  diagnoseAmbiguous(Sema &S, SourceLocation Loc, QualType T) = 0;
2860 
2861  /// Emits a note for one of the candidate conversions.
2862  virtual SemaDiagnosticBuilder
2863  noteAmbiguous(Sema &S, CXXConversionDecl *Conv, QualType ConvTy) = 0;
2864 
2865  /// Emits a diagnostic when we picked a conversion function
2866  /// (for cases when we are not allowed to pick a conversion function).
2867  virtual SemaDiagnosticBuilder diagnoseConversion(
2868  Sema &S, SourceLocation Loc, QualType T, QualType ConvTy) = 0;
2869 
2871  };
2872 
2874  bool AllowScopedEnumerations;
2875 
2876  public:
2877  ICEConvertDiagnoser(bool AllowScopedEnumerations,
2878  bool Suppress, bool SuppressConversion)
2879  : ContextualImplicitConverter(Suppress, SuppressConversion),
2880  AllowScopedEnumerations(AllowScopedEnumerations) {}
2881 
2882  /// Match an integral or (possibly scoped) enumeration type.
2883  bool match(QualType T) override;
2884 
2887  return diagnoseNotInt(S, Loc, T);
2888  }
2889 
2890  /// Emits a diagnostic complaining that the expression does not have
2891  /// integral or enumeration type.
2892  virtual SemaDiagnosticBuilder
2893  diagnoseNotInt(Sema &S, SourceLocation Loc, QualType T) = 0;
2894  };
2895 
2896  /// Perform a contextual implicit conversion.
2897  ExprResult PerformContextualImplicitConversion(
2898  SourceLocation Loc, Expr *FromE, ContextualImplicitConverter &Converter);
2899 
2900 
2904  OS_Error
2905  };
2906  ObjCSubscriptKind CheckSubscriptingKind(Expr *FromE);
2907 
2908  // Note that LK_String is intentionally after the other literals, as
2909  // this is used for diagnostics logic.
2917  LK_None
2918  };
2919  ObjCLiteralKind CheckLiteralKind(Expr *FromE);
2920 
2921  ExprResult PerformObjectMemberConversion(Expr *From,
2922  NestedNameSpecifier *Qualifier,
2923  NamedDecl *FoundDecl,
2924  NamedDecl *Member);
2925 
2926  // Members have to be NamespaceDecl* or TranslationUnitDecl*.
2927  // TODO: make this is a typesafe union.
2930 
2932 
2933  void AddOverloadCandidate(FunctionDecl *Function, DeclAccessPair FoundDecl,
2934  ArrayRef<Expr *> Args,
2935  OverloadCandidateSet &CandidateSet,
2936  bool SuppressUserConversions = false,
2937  bool PartialOverloading = false,
2938  bool AllowExplicit = true,
2939  bool AllowExplicitConversion = false,
2940  ADLCallKind IsADLCandidate = ADLCallKind::NotADL,
2941  ConversionSequenceList EarlyConversions = None);
2942  void AddFunctionCandidates(const UnresolvedSetImpl &Functions,
2943  ArrayRef<Expr *> Args,
2944  OverloadCandidateSet &CandidateSet,
2945  TemplateArgumentListInfo *ExplicitTemplateArgs = nullptr,
2946  bool SuppressUserConversions = false,
2947  bool PartialOverloading = false,
2948  bool FirstArgumentIsBase = false);
2949  void AddMethodCandidate(DeclAccessPair FoundDecl,
2950  QualType ObjectType,
2951  Expr::Classification ObjectClassification,
2952  ArrayRef<Expr *> Args,
2953  OverloadCandidateSet& CandidateSet,
2954  bool SuppressUserConversion = false);
2955  void AddMethodCandidate(CXXMethodDecl *Method,
2956  DeclAccessPair FoundDecl,
2957  CXXRecordDecl *ActingContext, QualType ObjectType,
2958  Expr::Classification ObjectClassification,
2959  ArrayRef<Expr *> Args,
2960  OverloadCandidateSet& CandidateSet,
2961  bool SuppressUserConversions = false,
2962  bool PartialOverloading = false,
2963  ConversionSequenceList EarlyConversions = None);
2964  void AddMethodTemplateCandidate(FunctionTemplateDecl *MethodTmpl,
2965  DeclAccessPair FoundDecl,
2966  CXXRecordDecl *ActingContext,
2967  TemplateArgumentListInfo *ExplicitTemplateArgs,
2968  QualType ObjectType,
2969  Expr::Classification ObjectClassification,
2970  ArrayRef<Expr *> Args,
2971  OverloadCandidateSet& CandidateSet,
2972  bool SuppressUserConversions = false,
2973  bool PartialOverloading = false);
2974  void AddTemplateOverloadCandidate(
2975  FunctionTemplateDecl *FunctionTemplate, DeclAccessPair FoundDecl,
2976  TemplateArgumentListInfo *ExplicitTemplateArgs, ArrayRef<Expr *> Args,
2977  OverloadCandidateSet &CandidateSet, bool SuppressUserConversions = false,
2978  bool PartialOverloading = false, bool AllowExplicit = true,
2979  ADLCallKind IsADLCandidate = ADLCallKind::NotADL);
2980  bool CheckNonDependentConversions(FunctionTemplateDecl *FunctionTemplate,
2981  ArrayRef<QualType> ParamTypes,
2982  ArrayRef<Expr *> Args,
2983  OverloadCandidateSet &CandidateSet,
2984  ConversionSequenceList &Conversions,
2985  bool SuppressUserConversions,
2986  CXXRecordDecl *ActingContext = nullptr,
2987  QualType ObjectType = QualType(),
2989  ObjectClassification = {});
2990  void AddConversionCandidate(
2991  CXXConversionDecl *Conversion, DeclAccessPair FoundDecl,
2992  CXXRecordDecl *ActingContext, Expr *From, QualType ToType,
2993  OverloadCandidateSet &CandidateSet, bool AllowObjCConversionOnExplicit,
2994  bool AllowExplicit, bool AllowResultConversion = true);
2995  void AddTemplateConversionCandidate(
2996  FunctionTemplateDecl *FunctionTemplate, DeclAccessPair FoundDecl,
2997  CXXRecordDecl *ActingContext, Expr *From, QualType ToType,
2998  OverloadCandidateSet &CandidateSet, bool AllowObjCConversionOnExplicit,
2999  bool AllowExplicit, bool AllowResultConversion = true);
3000  void AddSurrogateCandidate(CXXConversionDecl *Conversion,
3001  DeclAccessPair FoundDecl,
3002  CXXRecordDecl *ActingContext,
3003  const FunctionProtoType *Proto,
3004  Expr *Object, ArrayRef<Expr *> Args,
3005  OverloadCandidateSet& CandidateSet);
3006  void AddMemberOperatorCandidates(OverloadedOperatorKind Op,
3007  SourceLocation OpLoc, ArrayRef<Expr *> Args,
3008  OverloadCandidateSet& CandidateSet,
3009  SourceRange OpRange = SourceRange());
3010  void AddBuiltinCandidate(QualType *ParamTys, ArrayRef<Expr *> Args,
3011  OverloadCandidateSet& CandidateSet,
3012  bool IsAssignmentOperator = false,
3013  unsigned NumContextualBoolArguments = 0);
3014  void AddBuiltinOperatorCandidates(OverloadedOperatorKind Op,
3015  SourceLocation OpLoc, ArrayRef<Expr *> Args,
3016  OverloadCandidateSet& CandidateSet);
3017  void AddArgumentDependentLookupCandidates(DeclarationName Name,
3018  SourceLocation Loc,
3019  ArrayRef<Expr *> Args,
3020  TemplateArgumentListInfo *ExplicitTemplateArgs,
3021  OverloadCandidateSet& CandidateSet,
3022  bool PartialOverloading = false);
3023 
3024  // Emit as a 'note' the specific overload candidate
3025  void NoteOverloadCandidate(NamedDecl *Found, FunctionDecl *Fn,
3026  QualType DestType = QualType(),
3027  bool TakingAddress = false);
3028 
3029  // Emit as a series of 'note's all template and non-templates identified by
3030  // the expression Expr
3031  void NoteAllOverloadCandidates(Expr *E, QualType DestType = QualType(),
3032  bool TakingAddress = false);
3033 
3034  /// Check the enable_if expressions on the given function. Returns the first
3035  /// failing attribute, or NULL if they were all successful.
3036  EnableIfAttr *CheckEnableIf(FunctionDecl *Function, ArrayRef<Expr *> Args,
3037  bool MissingImplicitThis = false);
3038 
3039  /// Find the failed Boolean condition within a given Boolean
3040  /// constant expression, and describe it with a string.
3041  std::pair<Expr *, std::string> findFailedBooleanCondition(Expr *Cond);
3042 
3043  /// Emit diagnostics for the diagnose_if attributes on Function, ignoring any
3044  /// non-ArgDependent DiagnoseIfAttrs.
3045  ///
3046  /// Argument-dependent diagnose_if attributes should be checked each time a
3047  /// function is used as a direct callee of a function call.
3048  ///
3049  /// Returns true if any errors were emitted.
3050  bool diagnoseArgDependentDiagnoseIfAttrs(const FunctionDecl *Function,
3051  const Expr *ThisArg,
3053  SourceLocation Loc);
3054 
3055  /// Emit diagnostics for the diagnose_if attributes on Function, ignoring any
3056  /// ArgDependent DiagnoseIfAttrs.
3057  ///
3058  /// Argument-independent diagnose_if attributes should be checked on every use
3059  /// of a function.
3060  ///
3061  /// Returns true if any errors were emitted.
3062  bool diagnoseArgIndependentDiagnoseIfAttrs(const NamedDecl *ND,
3063  SourceLocation Loc);
3064 
3065  /// Returns whether the given function's address can be taken or not,
3066  /// optionally emitting a diagnostic if the address can't be taken.
3067  ///
3068  /// Returns false if taking the address of the function is illegal.
3069  bool checkAddressOfFunctionIsAvailable(const FunctionDecl *Function,
3070  bool Complain = false,
3071  SourceLocation Loc = SourceLocation());
3072 
3073  // [PossiblyAFunctionType] --> [Return]
3074  // NonFunctionType --> NonFunctionType
3075  // R (A) --> R(A)
3076  // R (*)(A) --> R (A)
3077  // R (&)(A) --> R (A)
3078  // R (S::*)(A) --> R (A)
3079  QualType ExtractUnqualifiedFunctionType(QualType PossiblyAFunctionType);
3080 
3081  FunctionDecl *
3082  ResolveAddressOfOverloadedFunction(Expr *AddressOfExpr,
3083  QualType TargetType,
3084  bool Complain,
3085  DeclAccessPair &Found,
3086  bool *pHadMultipleCandidates = nullptr);
3087 
3088  FunctionDecl *
3089  resolveAddressOfOnlyViableOverloadCandidate(Expr *E,
3090  DeclAccessPair &FoundResult);
3091 
3092  bool resolveAndFixAddressOfOnlyViableOverloadCandidate(
3093  ExprResult &SrcExpr, bool DoFunctionPointerConversion = false);
3094 
3095  FunctionDecl *
3096  ResolveSingleFunctionTemplateSpecialization(OverloadExpr *ovl,
3097  bool Complain = false,
3098  DeclAccessPair *Found = nullptr);
3099 
3100  bool ResolveAndFixSingleFunctionTemplateSpecialization(
3101  ExprResult &SrcExpr,
3102  bool DoFunctionPointerConverion = false,
3103  bool Complain = false,
3104  SourceRange OpRangeForComplaining = SourceRange(),
3105  QualType DestTypeForComplaining = QualType(),
3106  unsigned DiagIDForComplaining = 0);
3107 
3108 
3109  Expr *FixOverloadedFunctionReference(Expr *E,
3110  DeclAccessPair FoundDecl,
3111  FunctionDecl *Fn);
3112  ExprResult FixOverloadedFunctionReference(ExprResult,
3113  DeclAccessPair FoundDecl,
3114  FunctionDecl *Fn);
3115 
3116  void AddOverloadedCallCandidates(UnresolvedLookupExpr *ULE,
3117  ArrayRef<Expr *> Args,
3118  OverloadCandidateSet &CandidateSet,
3119  bool PartialOverloading = false);
3120 
3121  // An enum used to represent the different possible results of building a
3122  // range-based for loop.
3126  FRS_DiagnosticIssued
3127  };
3128 
3129  ForRangeStatus BuildForRangeBeginEndCall(SourceLocation Loc,
3130  SourceLocation RangeLoc,
3131  const DeclarationNameInfo &NameInfo,
3132  LookupResult &MemberLookup,
3133  OverloadCandidateSet *CandidateSet,
3134  Expr *Range, ExprResult *CallExpr);
3135 
3136  ExprResult BuildOverloadedCallExpr(Scope *S, Expr *Fn,
3137  UnresolvedLookupExpr *ULE,
3138  SourceLocation LParenLoc,
3139  MultiExprArg Args,
3140  SourceLocation RParenLoc,
3141  Expr *ExecConfig,
3142  bool AllowTypoCorrection=true,
3143  bool CalleesAddressIsTaken=false);
3144 
3145  bool buildOverloadedCallSet(Scope *S, Expr *Fn, UnresolvedLookupExpr *ULE,
3146  MultiExprArg Args, SourceLocation RParenLoc,
3147  OverloadCandidateSet *CandidateSet,
3148  ExprResult *Result);
3149 
3150  ExprResult CreateOverloadedUnaryOp(SourceLocation OpLoc,
3151  UnaryOperatorKind Opc,
3152  const UnresolvedSetImpl &Fns,
3153  Expr *input, bool RequiresADL = true);
3154 
3155  ExprResult CreateOverloadedBinOp(SourceLocation OpLoc,
3156  BinaryOperatorKind Opc,
3157  const UnresolvedSetImpl &Fns,
3158  Expr *LHS, Expr *RHS,
3159  bool RequiresADL = true);
3160 
3161  ExprResult CreateOverloadedArraySubscriptExpr(SourceLocation LLoc,
3162  SourceLocation RLoc,
3163  Expr *Base,Expr *Idx);
3164 
3165  ExprResult
3166  BuildCallToMemberFunction(Scope *S, Expr *MemExpr,
3167  SourceLocation LParenLoc,
3168  MultiExprArg Args,
3169  SourceLocation RParenLoc);
3170  ExprResult
3171  BuildCallToObjectOfClassType(Scope *S, Expr *Object, SourceLocation LParenLoc,
3172  MultiExprArg Args,
3173  SourceLocation RParenLoc);
3174 
3175  ExprResult BuildOverloadedArrowExpr(Scope *S, Expr *Base,
3176  SourceLocation OpLoc,
3177  bool *NoArrowOperatorFound = nullptr);
3178 
3179  /// CheckCallReturnType - Checks that a call expression's return type is
3180  /// complete. Returns true on failure. The location passed in is the location
3181  /// that best represents the call.
3182  bool CheckCallReturnType(QualType ReturnType, SourceLocation Loc,
3183  CallExpr *CE, FunctionDecl *FD);
3184 
3185  /// Helpers for dealing with blocks and functions.
3186  bool CheckParmsForFunctionDef(ArrayRef<ParmVarDecl *> Parameters,
3187  bool CheckParameterNames);
3188  void CheckCXXDefaultArguments(FunctionDecl *FD);
3189  void CheckExtraCXXDefaultArguments(Declarator &D);
3190  Scope *getNonFieldDeclScope(Scope *S);
3191 
3192  /// \name Name lookup
3193  ///
3194  /// These routines provide name lookup that is used during semantic
3195  /// analysis to resolve the various kinds of names (identifiers,
3196  /// overloaded operator names, constructor names, etc.) into zero or
3197  /// more declarations within a particular scope. The major entry
3198  /// points are LookupName, which performs unqualified name lookup,
3199  /// and LookupQualifiedName, which performs qualified name lookup.
3200  ///
3201  /// All name lookup is performed based on some specific criteria,
3202  /// which specify what names will be visible to name lookup and how
3203  /// far name lookup should work. These criteria are important both
3204  /// for capturing language semantics (certain lookups will ignore
3205  /// certain names, for example) and for performance, since name
3206  /// lookup is often a bottleneck in the compilation of C++. Name
3207  /// lookup criteria is specified via the LookupCriteria enumeration.
3208  ///
3209  /// The results of name lookup can vary based on the kind of name
3210  /// lookup performed, the current language, and the translation
3211  /// unit. In C, for example, name lookup will either return nothing
3212  /// (no entity found) or a single declaration. In C++, name lookup
3213  /// can additionally refer to a set of overloaded functions or
3214  /// result in an ambiguity. All of the possible results of name
3215  /// lookup are captured by the LookupResult class, which provides
3216  /// the ability to distinguish among them.
3217  //@{
3218 
3219  /// Describes the kind of name lookup to perform.
3221  /// Ordinary name lookup, which finds ordinary names (functions,
3222  /// variables, typedefs, etc.) in C and most kinds of names
3223  /// (functions, variables, members, types, etc.) in C++.
3224  LookupOrdinaryName = 0,
3225  /// Tag name lookup, which finds the names of enums, classes,
3226  /// structs, and unions.
3228  /// Label name lookup.
3230  /// Member name lookup, which finds the names of
3231  /// class/struct/union members.
3233  /// Look up of an operator name (e.g., operator+) for use with
3234  /// operator overloading. This lookup is similar to ordinary name
3235  /// lookup, but will ignore any declarations that are class members.
3237  /// Look up of a name that precedes the '::' scope resolution
3238  /// operator in C++. This lookup completely ignores operator, object,
3239  /// function, and enumerator names (C++ [basic.lookup.qual]p1).
3241  /// Look up a namespace name within a C++ using directive or
3242  /// namespace alias definition, ignoring non-namespace names (C++
3243  /// [basic.lookup.udir]p1).
3245  /// Look up all declarations in a scope with the given name,
3246  /// including resolved using declarations. This is appropriate
3247  /// for checking redeclarations for a using declaration.
3249  /// Look up an ordinary name that is going to be redeclared as a
3250  /// name with linkage. This lookup ignores any declarations that
3251  /// are outside of the current scope unless they have linkage. See
3252  /// C99 6.2.2p4-5 and C++ [basic.link]p6.
3254  /// Look up a friend of a local class. This lookup does not look
3255  /// outside the innermost non-class scope. See C++11 [class.friend]p11.
3257  /// Look up the name of an Objective-C protocol.
3259  /// Look up implicit 'self' parameter of an objective-c method.
3261  /// Look up the name of an OpenMP user-defined reduction operation.
3263  /// Look up the name of an OpenMP user-defined mapper.
3265  /// Look up any declaration with any name.
3266  LookupAnyName
3267  };
3268 
3269  /// Specifies whether (or how) name lookup is being performed for a
3270  /// redeclaration (vs. a reference).
3272  /// The lookup is a reference to this name that is not for the
3273  /// purpose of redeclaring the name.
3274  NotForRedeclaration = 0,
3275  /// The lookup results will be used for redeclaration of a name,
3276  /// if an entity by that name already exists and is visible.
3278  /// The lookup results will be used for redeclaration of a name
3279  /// with external linkage; non-visible lookup results with external linkage
3280  /// may also be found.
3281  ForExternalRedeclaration
3282  };
3283 
3285  // A declaration with an owning module for linkage can never link against
3286  // anything that is not visible. We don't need to check linkage here; if
3287  // the context has internal linkage, redeclaration lookup won't find things
3288  // from other TUs, and we can't safely compute linkage yet in general.
3289  if (cast<Decl>(CurContext)
3290  ->getOwningModuleForLinkage(/*IgnoreLinkage*/true))
3291  return ForVisibleRedeclaration;
3292  return ForExternalRedeclaration;
3293  }
3294 
3295  /// The possible outcomes of name lookup for a literal operator.
3297  /// The lookup resulted in an error.
3299  /// The lookup found no match but no diagnostic was issued.
3301  /// The lookup found a single 'cooked' literal operator, which
3302  /// expects a normal literal to be built and passed to it.
3304  /// The lookup found a single 'raw' literal operator, which expects
3305  /// a string literal containing the spelling of the literal token.
3307  /// The lookup found an overload set of literal operator templates,
3308  /// which expect the characters of the spelling of the literal token to be
3309  /// passed as a non-type template argument pack.
3311  /// The lookup found an overload set of literal operator templates,
3312  /// which expect the character type and characters of the spelling of the
3313  /// string literal token to be passed as template arguments.
3314  LOLR_StringTemplate
3315  };
3316 
3317  SpecialMemberOverloadResult LookupSpecialMember(CXXRecordDecl *D,
3319  bool ConstArg,
3320  bool VolatileArg,
3321  bool RValueThis,
3322  bool ConstThis,
3323  bool VolatileThis);
3324 
3325  typedef std::function<void(const TypoCorrection &)> TypoDiagnosticGenerator;
3326  typedef std::function<ExprResult(Sema &, TypoExpr *, TypoCorrection)>
3328 
3329 private:
3330  bool CppLookupName(LookupResult &R, Scope *S);
3331 
3332  struct TypoExprState {
3333  std::unique_ptr<TypoCorrectionConsumer> Consumer;
3334  TypoDiagnosticGenerator DiagHandler;
3335  TypoRecoveryCallback RecoveryHandler;
3336  TypoExprState();
3337  TypoExprState(TypoExprState &&other) noexcept;
3338  TypoExprState &operator=(TypoExprState &&other) noexcept;
3339  };
3340 
3341  /// The set of unhandled TypoExprs and their associated state.
3342  llvm::MapVector<TypoExpr *, TypoExprState> DelayedTypos;
3343 
3344  /// Creates a new TypoExpr AST node.
3345  TypoExpr *createDelayedTypo(std::unique_ptr<TypoCorrectionConsumer> TCC,
3346  TypoDiagnosticGenerator TDG,
3347  TypoRecoveryCallback TRC);
3348 
3349  // The set of known/encountered (unique, canonicalized) NamespaceDecls.
3350  //
3351  // The boolean value will be true to indicate that the namespace was loaded
3352  // from an AST/PCH file, or false otherwise.
3353  llvm::MapVector<NamespaceDecl*, bool> KnownNamespaces;
3354 
3355  /// Whether we have already loaded known namespaces from an extenal
3356  /// source.
3357  bool LoadedExternalKnownNamespaces;
3358 
3359  /// Helper for CorrectTypo and CorrectTypoDelayed used to create and
3360  /// populate a new TypoCorrectionConsumer. Returns nullptr if typo correction
3361  /// should be skipped entirely.
3362  std::unique_ptr<TypoCorrectionConsumer>
3363  makeTypoCorrectionConsumer(const DeclarationNameInfo &Typo,
3364  Sema::LookupNameKind LookupKind, Scope *S,
3365  CXXScopeSpec *SS,
3367  DeclContext *MemberContext, bool EnteringContext,
3368  const ObjCObjectPointerType *OPT,
3369  bool ErrorRecovery);
3370 
3371 public:
3372  const TypoExprState &getTypoExprState(TypoExpr *TE) const;
3373 
3374  /// Clears the state of the given TypoExpr.
3375  void clearDelayedTypo(TypoExpr *TE);
3376 
3377  /// Look up a name, looking for a single declaration. Return
3378  /// null if the results were absent, ambiguous, or overloaded.
3379  ///
3380  /// It is preferable to use the elaborated form and explicitly handle
3381  /// ambiguity and overloaded.
3382  NamedDecl *LookupSingleName(Scope *S, DeclarationName Name,
3383  SourceLocation Loc,
3384  LookupNameKind NameKind,
3385  RedeclarationKind Redecl
3386  = NotForRedeclaration);
3387  bool LookupName(LookupResult &R, Scope *S,
3388  bool AllowBuiltinCreation = false);
3389  bool LookupQualifiedName(LookupResult &R, DeclContext *LookupCtx,
3390  bool InUnqualifiedLookup = false);
3391  bool LookupQualifiedName(LookupResult &R, DeclContext *LookupCtx,
3392  CXXScopeSpec &SS);
3393  bool LookupParsedName(LookupResult &R, Scope *S, CXXScopeSpec *SS,
3394  bool AllowBuiltinCreation = false,
3395  bool EnteringContext = false);
3396  ObjCProtocolDecl *LookupProtocol(IdentifierInfo *II, SourceLocation IdLoc,
3397  RedeclarationKind Redecl
3398  = NotForRedeclaration);
3399  bool LookupInSuper(LookupResult &R, CXXRecordDecl *Class);
3400 
3401  void LookupOverloadedOperatorName(OverloadedOperatorKind Op, Scope *S,
3402  QualType T1, QualType T2,
3403  UnresolvedSetImpl &Functions);
3404 
3405  LabelDecl *LookupOrCreateLabel(IdentifierInfo *II, SourceLocation IdentLoc,
3406  SourceLocation GnuLabelLoc = SourceLocation());
3407 
3408  DeclContextLookupResult LookupConstructors(CXXRecordDecl *Class);
3409  CXXConstructorDecl *LookupDefaultConstructor(CXXRecordDecl *Class);
3410  CXXConstructorDecl *LookupCopyingConstructor(CXXRecordDecl *Class,
3411  unsigned Quals);
3412  CXXMethodDecl *LookupCopyingAssignment(CXXRecordDecl *Class, unsigned Quals,
3413  bool RValueThis, unsigned ThisQuals);
3414  CXXConstructorDecl *LookupMovingConstructor(CXXRecordDecl *Class,
3415  unsigned Quals);
3416  CXXMethodDecl *LookupMovingAssignment(CXXRecordDecl *Class, unsigned Quals,
3417  bool RValueThis, unsigned ThisQuals);
3418  CXXDestructorDecl *LookupDestructor(CXXRecordDecl *Class);
3419 
3420  bool checkLiteralOperatorId(const CXXScopeSpec &SS, const UnqualifiedId &Id);
3421  LiteralOperatorLookupResult LookupLiteralOperator(Scope *S, LookupResult &R,
3422  ArrayRef<QualType> ArgTys,
3423  bool AllowRaw,
3424  bool AllowTemplate,
3425  bool AllowStringTemplate,
3426  bool DiagnoseMissing);
3427  bool isKnownName(StringRef name);
3428 
3429  void ArgumentDependentLookup(DeclarationName Name, SourceLocation Loc,
3430  ArrayRef<Expr *> Args, ADLResult &Functions);
3431 
3432  void LookupVisibleDecls(Scope *S, LookupNameKind Kind,
3433  VisibleDeclConsumer &Consumer,
3434  bool IncludeGlobalScope = true,
3435  bool LoadExternal = true);
3437  VisibleDeclConsumer &Consumer,
3438  bool IncludeGlobalScope = true,
3439  bool IncludeDependentBases = false,
3440  bool LoadExternal = true);
3441 
3443  CTK_NonError, // CorrectTypo used in a non error recovery situation.
3444  CTK_ErrorRecovery // CorrectTypo used in normal error recovery.
3445  };
3446 
3447  TypoCorrection CorrectTypo(const DeclarationNameInfo &Typo,
3448  Sema::LookupNameKind LookupKind,
3449  Scope *S, CXXScopeSpec *SS,
3451  CorrectTypoKind Mode,
3452  DeclContext *MemberContext = nullptr,
3453  bool EnteringContext = false,
3454  const ObjCObjectPointerType *OPT = nullptr,
3455  bool RecordFailure = true);
3456 
3457  TypoExpr *CorrectTypoDelayed(const DeclarationNameInfo &Typo,
3458  Sema::LookupNameKind LookupKind, Scope *S,
3459  CXXScopeSpec *SS,
3461  TypoDiagnosticGenerator TDG,
3463  DeclContext *MemberContext = nullptr,
3464  bool EnteringContext = false,
3465  const ObjCObjectPointerType *OPT = nullptr);
3466 
3467  /// Process any TypoExprs in the given Expr and its children,
3468  /// generating diagnostics as appropriate and returning a new Expr if there
3469  /// were typos that were all successfully corrected and ExprError if one or
3470  /// more typos could not be corrected.
3471  ///
3472  /// \param E The Expr to check for TypoExprs.
3473  ///
3474  /// \param InitDecl A VarDecl to avoid because the Expr being corrected is its
3475  /// initializer.
3476  ///
3477  /// \param Filter A function applied to a newly rebuilt Expr to determine if
3478  /// it is an acceptable/usable result from a single combination of typo
3479  /// corrections. As long as the filter returns ExprError, different
3480  /// combinations of corrections will be tried until all are exhausted.
3481  ExprResult
3482  CorrectDelayedTyposInExpr(Expr *E, VarDecl *InitDecl = nullptr,
3483  llvm::function_ref<ExprResult(Expr *)> Filter =
3484  [](Expr *E) -> ExprResult { return E; });
3485 
3486  ExprResult
3488  llvm::function_ref<ExprResult(Expr *)> Filter) {
3489  return CorrectDelayedTyposInExpr(E, nullptr, Filter);
3490  }
3491 
3492  ExprResult
3493  CorrectDelayedTyposInExpr(ExprResult ER, VarDecl *InitDecl = nullptr,
3494  llvm::function_ref<ExprResult(Expr *)> Filter =
3495  [](Expr *E) -> ExprResult { return E; }) {
3496  return ER.isInvalid() ? ER : CorrectDelayedTyposInExpr(ER.get(), Filter);
3497  }
3498 
3499  ExprResult
3501  llvm::function_ref<ExprResult(Expr *)> Filter) {
3502  return CorrectDelayedTyposInExpr(ER, nullptr, Filter);
3503  }
3504 
3505  void diagnoseTypo(const TypoCorrection &Correction,
3506  const PartialDiagnostic &TypoDiag,
3507  bool ErrorRecovery = true);
3508 
3509  void diagnoseTypo(const TypoCorrection &Correction,
3510  const PartialDiagnostic &TypoDiag,
3511  const PartialDiagnostic &PrevNote,
3512  bool ErrorRecovery = true);
3513 
3514  void MarkTypoCorrectedFunctionDefinition(const NamedDecl *F);
3515 
3516  void FindAssociatedClassesAndNamespaces(SourceLocation InstantiationLoc,
3517  ArrayRef<Expr *> Args,
3518  AssociatedNamespaceSet &AssociatedNamespaces,
3519  AssociatedClassSet &AssociatedClasses);
3520 
3521  void FilterLookupForScope(LookupResult &R, DeclContext *Ctx, Scope *S,
3522  bool ConsiderLinkage, bool AllowInlineNamespace);
3523 
3524  bool CheckRedeclarationModuleOwnership(NamedDecl *New, NamedDecl *Old);
3525 
3526  void DiagnoseAmbiguousLookup(LookupResult &Result);
3527  //@}
3528 
3529  ObjCInterfaceDecl *getObjCInterfaceDecl(IdentifierInfo *&Id,
3530  SourceLocation IdLoc,
3531  bool TypoCorrection = false);
3532  NamedDecl *LazilyCreateBuiltin(IdentifierInfo *II, unsigned ID,
3533  Scope *S, bool ForRedeclaration,
3534  SourceLocation Loc);
3535  NamedDecl *ImplicitlyDefineFunction(SourceLocation Loc, IdentifierInfo &II,
3536  Scope *S);
3537  void AddKnownFunctionAttributes(FunctionDecl *FD);
3538 
3539  // More parsing and symbol table subroutines.
3540 
3541  void ProcessPragmaWeak(Scope *S, Decl *D);
3542  // Decl attributes - this routine is the top level dispatcher.
3543  void ProcessDeclAttributes(Scope *S, Decl *D, const Declarator &PD);
3544  // Helper for delayed processing of attributes.
3545  void ProcessDeclAttributeDelayed(Decl *D,
3546  const ParsedAttributesView &AttrList);
3547  void ProcessDeclAttributeList(Scope *S, Decl *D, const ParsedAttributesView &AL,
3548  bool IncludeCXX11Attributes = true);
3549  bool ProcessAccessDeclAttributeList(AccessSpecDecl *ASDecl,
3550  const ParsedAttributesView &AttrList);
3551 
3552  void checkUnusedDeclAttributes(Declarator &D);
3553 
3554  /// Determine if type T is a valid subject for a nonnull and similar
3555  /// attributes. By default, we look through references (the behavior used by
3556  /// nonnull), but if the second parameter is true, then we treat a reference
3557  /// type as valid.
3558  bool isValidPointerAttrType(QualType T, bool RefOkay = false);
3559 
3560  bool CheckRegparmAttr(const ParsedAttr &attr, unsigned &value);
3561  bool CheckCallingConvAttr(const ParsedAttr &attr, CallingConv &CC,
3562  const FunctionDecl *FD = nullptr);
3563  bool CheckAttrTarget(const ParsedAttr &CurrAttr);
3564  bool CheckAttrNoArgs(const ParsedAttr &CurrAttr);
3565  bool checkStringLiteralArgumentAttr(const ParsedAttr &Attr, unsigned ArgNum,
3566  StringRef &Str,
3567  SourceLocation *ArgLocation = nullptr);
3568  bool checkSectionName(SourceLocation LiteralLoc, StringRef Str);
3569  bool checkTargetAttr(SourceLocation LiteralLoc, StringRef Str);
3570  bool checkMSInheritanceAttrOnDefinition(
3571  CXXRecordDecl *RD, SourceRange Range, bool BestCase,
3572  MSInheritanceAttr::Spelling SemanticSpelling);
3573 
3574  void CheckAlignasUnderalignment(Decl *D);
3575 
3576  /// Adjust the calling convention of a method to be the ABI default if it
3577  /// wasn't specified explicitly. This handles method types formed from
3578  /// function type typedefs and typename template arguments.
3579  void adjustMemberFunctionCC(QualType &T, bool IsStatic, bool IsCtorOrDtor,
3580  SourceLocation Loc);
3581 
3582  // Check if there is an explicit attribute, but only look through parens.
3583  // The intent is to look for an attribute on the current declarator, but not
3584  // one that came from a typedef.
3585  bool hasExplicitCallingConv(QualType T);
3586 
3587  /// Get the outermost AttributedType node that sets a calling convention.
3588  /// Valid types should not have multiple attributes with different CCs.
3589  const AttributedType *getCallingConvAttributedType(QualType T) const;
3590 
3591  /// Stmt attributes - this routine is the top level dispatcher.
3592  StmtResult ProcessStmtAttributes(Stmt *Stmt,
3593  const ParsedAttributesView &Attrs,
3594  SourceRange Range);
3595 
3596  void WarnConflictingTypedMethods(ObjCMethodDecl *Method,
3597  ObjCMethodDecl *MethodDecl,
3598  bool IsProtocolMethodDecl);
3599 
3600  void CheckConflictingOverridingMethod(ObjCMethodDecl *Method,
3601  ObjCMethodDecl *Overridden,
3602  bool IsProtocolMethodDecl);
3603 
3604  /// WarnExactTypedMethods - This routine issues a warning if method
3605  /// implementation declaration matches exactly that of its declaration.
3606  void WarnExactTypedMethods(ObjCMethodDecl *Method,
3607  ObjCMethodDecl *MethodDecl,
3608  bool IsProtocolMethodDecl);
3609 
3610  typedef llvm::SmallPtrSet<Selector, 8> SelectorSet;
3611 
3612  /// CheckImplementationIvars - This routine checks if the instance variables
3613  /// listed in the implelementation match those listed in the interface.
3614  void CheckImplementationIvars(ObjCImplementationDecl *ImpDecl,
3615  ObjCIvarDecl **Fields, unsigned nIvars,
3616  SourceLocation Loc);
3617 
3618  /// ImplMethodsVsClassMethods - This is main routine to warn if any method
3619  /// remains unimplemented in the class or category \@implementation.
3620  void ImplMethodsVsClassMethods(Scope *S, ObjCImplDecl* IMPDecl,
3621  ObjCContainerDecl* IDecl,
3622  bool IncompleteImpl = false);
3623 
3624  /// DiagnoseUnimplementedProperties - This routine warns on those properties
3625  /// which must be implemented by this implementation.
3626  void DiagnoseUnimplementedProperties(Scope *S, ObjCImplDecl* IMPDecl,
3627  ObjCContainerDecl *CDecl,
3628  bool SynthesizeProperties);
3629 
3630  /// Diagnose any null-resettable synthesized setters.
3631  void diagnoseNullResettableSynthesizedSetters(const ObjCImplDecl *impDecl);
3632 
3633  /// DefaultSynthesizeProperties - This routine default synthesizes all
3634  /// properties which must be synthesized in the class's \@implementation.
3635  void DefaultSynthesizeProperties(Scope *S, ObjCImplDecl *IMPDecl,
3636  ObjCInterfaceDecl *IDecl,
3637  SourceLocation AtEnd);
3638  void DefaultSynthesizeProperties(Scope *S, Decl *D, SourceLocation AtEnd);
3639 
3640  /// IvarBacksCurrentMethodAccessor - This routine returns 'true' if 'IV' is
3641  /// an ivar synthesized for 'Method' and 'Method' is a property accessor
3642  /// declared in class 'IFace'.
3643  bool IvarBacksCurrentMethodAccessor(ObjCInterfaceDecl *IFace,
3644  ObjCMethodDecl *Method, ObjCIvarDecl *IV);
3645 
3646  /// DiagnoseUnusedBackingIvarInAccessor - Issue an 'unused' warning if ivar which
3647  /// backs the property is not used in the property's accessor.
3648  void DiagnoseUnusedBackingIvarInAccessor(Scope *S,
3649  const ObjCImplementationDecl *ImplD);
3650 
3651  /// GetIvarBackingPropertyAccessor - If method is a property setter/getter and
3652  /// it property has a backing ivar, returns this ivar; otherwise, returns NULL.
3653  /// It also returns ivar's property on success.
3654  ObjCIvarDecl *GetIvarBackingPropertyAccessor(const ObjCMethodDecl *Method,
3655  const ObjCPropertyDecl *&PDecl) const;
3656 
3657  /// Called by ActOnProperty to handle \@property declarations in
3658  /// class extensions.
3659  ObjCPropertyDecl *HandlePropertyInClassExtension(Scope *S,
3660  SourceLocation AtLoc,
3661  SourceLocation LParenLoc,
3662  FieldDeclarator &FD,
3663  Selector GetterSel,
3664  SourceLocation GetterNameLoc,
3665  Selector SetterSel,
3666  SourceLocation SetterNameLoc,
3667  const bool isReadWrite,
3668  unsigned &Attributes,
3669  const unsigned AttributesAsWritten,
3670  QualType T,
3671  TypeSourceInfo *TSI,
3672  tok::ObjCKeywordKind MethodImplKind);
3673 
3674  /// Called by ActOnProperty and HandlePropertyInClassExtension to
3675  /// handle creating the ObjcPropertyDecl for a category or \@interface.
3676  ObjCPropertyDecl *CreatePropertyDecl(Scope *S,
3677  ObjCContainerDecl *CDecl,
3678  SourceLocation AtLoc,
3679  SourceLocation LParenLoc,
3680  FieldDeclarator &FD,
3681  Selector GetterSel,
3682  SourceLocation GetterNameLoc,
3683  Selector SetterSel,
3684  SourceLocation SetterNameLoc,
3685  const bool isReadWrite,
3686  const unsigned Attributes,
3687  const unsigned AttributesAsWritten,
3688  QualType T,
3689  TypeSourceInfo *TSI,
3690  tok::ObjCKeywordKind MethodImplKind,
3691  DeclContext *lexicalDC = nullptr);
3692 
3693  /// AtomicPropertySetterGetterRules - This routine enforces the rule (via
3694  /// warning) when atomic property has one but not the other user-declared
3695  /// setter or getter.
3696  void AtomicPropertySetterGetterRules(ObjCImplDecl* IMPDecl,
3697  ObjCInterfaceDecl* IDecl);
3698 
3699  void DiagnoseOwningPropertyGetterSynthesis(const ObjCImplementationDecl *D);
3700 
3701  void DiagnoseMissingDesignatedInitOverrides(
3702  const ObjCImplementationDecl *ImplD,
3703  const ObjCInterfaceDecl *IFD);
3704 
3705  void DiagnoseDuplicateIvars(ObjCInterfaceDecl *ID, ObjCInterfaceDecl *SID);
3706 
3709  MMS_strict
3710  };
3711 
3712  /// MatchTwoMethodDeclarations - Checks if two methods' type match and returns
3713  /// true, or false, accordingly.
3714  bool MatchTwoMethodDeclarations(const ObjCMethodDecl *Method,
3715  const ObjCMethodDecl *PrevMethod,
3716  MethodMatchStrategy strategy = MMS_strict);
3717 
3718  /// MatchAllMethodDeclarations - Check methods declaraed in interface or
3719  /// or protocol against those declared in their implementations.
3720  void MatchAllMethodDeclarations(const SelectorSet &InsMap,
3721  const SelectorSet &ClsMap,
3722  SelectorSet &InsMapSeen,
3723  SelectorSet &ClsMapSeen,
3724  ObjCImplDecl* IMPDecl,
3725  ObjCContainerDecl* IDecl,
3726  bool &IncompleteImpl,
3727  bool ImmediateClass,
3728  bool WarnCategoryMethodImpl=false);
3729 
3730  /// CheckCategoryVsClassMethodMatches - Checks that methods implemented in
3731  /// category matches with those implemented in its primary class and
3732  /// warns each time an exact match is found.
3733  void CheckCategoryVsClassMethodMatches(ObjCCategoryImplDecl *CatIMP);
3734 
3735  /// Add the given method to the list of globally-known methods.
3736  void addMethodToGlobalList(ObjCMethodList *List, ObjCMethodDecl *Method);
3737 
3738 private:
3739  /// AddMethodToGlobalPool - Add an instance or factory method to the global
3740  /// pool. See descriptoin of AddInstanceMethodToGlobalPool.
3741  void AddMethodToGlobalPool(ObjCMethodDecl *Method, bool impl, bool instance);
3742 
3743  /// LookupMethodInGlobalPool - Returns the instance or factory method and
3744  /// optionally warns if there are multiple signatures.
3745  ObjCMethodDecl *LookupMethodInGlobalPool(Selector Sel, SourceRange R,
3746  bool receiverIdOrClass,
3747  bool instance);
3748 
3749 public:
3750  /// - Returns instance or factory methods in global method pool for
3751  /// given selector. It checks the desired kind first, if none is found, and
3752  /// parameter checkTheOther is set, it then checks the other kind. If no such
3753  /// method or only one method is found, function returns false; otherwise, it
3754  /// returns true.
3755  bool
3756  CollectMultipleMethodsInGlobalPool(Selector Sel,
3758  bool InstanceFirst, bool CheckTheOther,
3759  const ObjCObjectType *TypeBound = nullptr);
3760 
3761  bool
3762  AreMultipleMethodsInGlobalPool(Selector Sel, ObjCMethodDecl *BestMethod,
3763  SourceRange R, bool receiverIdOrClass,
3765 
3766  void
3767  DiagnoseMultipleMethodInGlobalPool(SmallVectorImpl<ObjCMethodDecl*> &Methods,
3768  Selector Sel, SourceRange R,
3769  bool receiverIdOrClass);
3770 
3771 private:
3772  /// - Returns a selector which best matches given argument list or
3773  /// nullptr if none could be found
3774  ObjCMethodDecl *SelectBestMethod(Selector Sel, MultiExprArg Args,
3775  bool IsInstance,
3777 
3778 
3779  /// Record the typo correction failure and return an empty correction.
3780  TypoCorrection FailedCorrection(IdentifierInfo *Typo, SourceLocation TypoLoc,
3781  bool RecordFailure = true) {
3782  if (RecordFailure)
3783  TypoCorrectionFailures[Typo].insert(TypoLoc);
3784  return TypoCorrection();
3785  }
3786 
3787 public:
3788  /// AddInstanceMethodToGlobalPool - All instance methods in a translation
3789  /// unit are added to a global pool. This allows us to efficiently associate
3790  /// a selector with a method declaraation for purposes of typechecking
3791  /// messages sent to "id" (where the class of the object is unknown).
3792  void AddInstanceMethodToGlobalPool(ObjCMethodDecl *Method, bool impl=false) {
3793  AddMethodToGlobalPool(Method, impl, /*instance*/true);
3794  }
3795 
3796  /// AddFactoryMethodToGlobalPool - Same as above, but for factory methods.
3797  void AddFactoryMethodToGlobalPool(ObjCMethodDecl *Method, bool impl=false) {
3798  AddMethodToGlobalPool(Method, impl, /*instance*/false);
3799  }
3800 
3801  /// AddAnyMethodToGlobalPool - Add any method, instance or factory to global
3802  /// pool.
3803  void AddAnyMethodToGlobalPool(Decl *D);
3804 
3805  /// LookupInstanceMethodInGlobalPool - Returns the method and warns if
3806  /// there are multiple signatures.
3808  bool receiverIdOrClass=false) {
3809  return LookupMethodInGlobalPool(Sel, R, receiverIdOrClass,
3810  /*instance*/true);
3811  }
3812 
3813  /// LookupFactoryMethodInGlobalPool - Returns the method and warns if
3814  /// there are multiple signatures.
3816  bool receiverIdOrClass=false) {
3817  return LookupMethodInGlobalPool(Sel, R, receiverIdOrClass,
3818  /*instance*/false);
3819  }
3820 
3821  const ObjCMethodDecl *SelectorsForTypoCorrection(Selector Sel,
3822  QualType ObjectType=QualType());
3823  /// LookupImplementedMethodInGlobalPool - Returns the method which has an
3824  /// implementation.
3825  ObjCMethodDecl *LookupImplementedMethodInGlobalPool(Selector Sel);
3826 
3827  /// CollectIvarsToConstructOrDestruct - Collect those ivars which require
3828  /// initialization.
3829  void CollectIvarsToConstructOrDestruct(ObjCInterfaceDecl *OI,
3831 
3832  //===--------------------------------------------------------------------===//
3833  // Statement Parsing Callbacks: SemaStmt.cpp.
3834 public:
3835  class FullExprArg {
3836  public:
3837  FullExprArg() : E(nullptr) { }
3838  FullExprArg(Sema &actions) : E(nullptr) { }
3839 
3841  return E;
3842  }
3843 
3844  Expr *get() const { return E; }
3845 
3847  return E;
3848  }
3849 
3850  private:
3851  // FIXME: No need to make the entire Sema class a friend when it's just
3852  // Sema::MakeFullExpr that needs access to the constructor below.
3853  friend class Sema;
3854 
3855  explicit FullExprArg(Expr *expr) : E(expr) {}
3856 
3857  Expr *E;
3858  };
3859 
3861  return MakeFullExpr(Arg, Arg ? Arg->getExprLoc() : SourceLocation());
3862  }
3864  return FullExprArg(
3865  ActOnFinishFullExpr(Arg, CC, /*DiscardedValue*/ false).get());
3866  }
3868  ExprResult FE =
3869  ActOnFinishFullExpr(Arg, Arg ? Arg->getExprLoc() : SourceLocation(),
3870  /*DiscardedValue*/ true);
3871  return FullExprArg(FE.get());
3872  }
3873 
3874  StmtResult ActOnExprStmt(ExprResult Arg, bool DiscardedValue = true);
3875  StmtResult ActOnExprStmtError();
3876 
3877  StmtResult ActOnNullStmt(SourceLocation SemiLoc,
3878  bool HasLeadingEmptyMacro = false);
3879 
3880  void ActOnStartOfCompoundStmt(bool IsStmtExpr);
3881  void ActOnFinishOfCompoundStmt();
3882  StmtResult ActOnCompoundStmt(SourceLocation L, SourceLocation R,
3883  ArrayRef<Stmt *> Elts, bool isStmtExpr);
3884 
3885  /// A RAII object to enter scope of a compound statement.
3887  public:
3888  CompoundScopeRAII(Sema &S, bool IsStmtExpr = false) : S(S) {
3889  S.ActOnStartOfCompoundStmt(IsStmtExpr);
3890  }
3891 
3893  S.ActOnFinishOfCompoundStmt();
3894  }
3895 
3896  private:
3897  Sema &S;
3898  };
3899 
3900  /// An RAII helper that pops function a function scope on exit.
3903  bool Active;
3904  FunctionScopeRAII(Sema &S) : S(S), Active(true) {}
3906  if (Active)
3908  }
3909  void disable() { Active = false; }
3910  };
3911 
3912  StmtResult ActOnDeclStmt(DeclGroupPtrTy Decl,
3913  SourceLocation StartLoc,
3914  SourceLocation EndLoc);
3915  void ActOnForEachDeclStmt(DeclGroupPtrTy Decl);
3916  StmtResult ActOnForEachLValueExpr(Expr *E);
3917  ExprResult ActOnCaseExpr(SourceLocation CaseLoc, ExprResult Val);
3918  StmtResult ActOnCaseStmt(SourceLocation CaseLoc, ExprResult LHS,
3919  SourceLocation DotDotDotLoc, ExprResult RHS,
3921  void ActOnCaseStmtBody(Stmt *CaseStmt, Stmt *SubStmt);
3922 
3923  StmtResult ActOnDefaultStmt(SourceLocation DefaultLoc,
3924  SourceLocation ColonLoc,
3925  Stmt *SubStmt, Scope *CurScope);
3926  StmtResult ActOnLabelStmt(SourceLocation IdentLoc, LabelDecl *TheDecl,
3927  SourceLocation ColonLoc, Stmt *SubStmt);
3928 
3929  StmtResult ActOnAttributedStmt(SourceLocation AttrLoc,
3930  ArrayRef<const Attr*> Attrs,
3931  Stmt *SubStmt);
3932 
3933  class ConditionResult;
3934  StmtResult ActOnIfStmt(SourceLocation IfLoc, bool IsConstexpr,
3935  Stmt *InitStmt,
3936  ConditionResult Cond, Stmt *ThenVal,
3937  SourceLocation ElseLoc, Stmt *ElseVal);
3938  StmtResult BuildIfStmt(SourceLocation IfLoc, bool IsConstexpr,
3939  Stmt *InitStmt,
3940  ConditionResult Cond, Stmt *ThenVal,
3941  SourceLocation ElseLoc, Stmt *ElseVal);
3942  StmtResult ActOnStartOfSwitchStmt(SourceLocation SwitchLoc,
3943  Stmt *InitStmt,
3944  ConditionResult Cond);
3945  StmtResult ActOnFinishSwitchStmt(SourceLocation SwitchLoc,
3946  Stmt *Switch, Stmt *Body);
3947  StmtResult ActOnWhileStmt(SourceLocation WhileLoc, ConditionResult Cond,
3948  Stmt *Body);
3949  StmtResult ActOnDoStmt(SourceLocation DoLoc, Stmt *Body,
3950  SourceLocation WhileLoc, SourceLocation CondLParen,
3951  Expr *Cond, SourceLocation CondRParen);
3952 
3953  StmtResult ActOnForStmt(SourceLocation ForLoc,
3954  SourceLocation LParenLoc,
3955  Stmt *First,
3956  ConditionResult Second,
3957  FullExprArg Third,
3958  SourceLocation RParenLoc,
3959  Stmt *Body);
3960  ExprResult CheckObjCForCollectionOperand(SourceLocation forLoc,
3961  Expr *collection);
3962  StmtResult ActOnObjCForCollectionStmt(SourceLocation ForColLoc,
3963  Stmt *First, Expr *collection,
3964  SourceLocation RParenLoc);
3965  StmtResult FinishObjCForCollectionStmt(Stmt *ForCollection, Stmt *Body);
3966 
3968  /// Initial building of a for-range statement.
3970  /// Instantiation or recovery rebuild of a for-range statement. Don't
3971  /// attempt any typo-correction.
3973  /// Determining whether a for-range statement could be built. Avoid any
3974  /// unnecessary or irreversible actions.
3975  BFRK_Check
3976  };
3977 
3978  StmtResult ActOnCXXForRangeStmt(Scope *S, SourceLocation ForLoc,
3979  SourceLocation CoawaitLoc,
3980  Stmt *InitStmt,
3981  Stmt *LoopVar,
3982  SourceLocation ColonLoc, Expr *Collection,
3983  SourceLocation RParenLoc,
3985  StmtResult BuildCXXForRangeStmt(SourceLocation ForLoc,
3986  SourceLocation CoawaitLoc,
3987  Stmt *InitStmt,
3988  SourceLocation ColonLoc,
3989  Stmt *RangeDecl, Stmt *Begin, Stmt *End,
3990  Expr *Cond, Expr *Inc,
3991  Stmt *LoopVarDecl,
3992  SourceLocation RParenLoc,
3994  StmtResult FinishCXXForRangeStmt(Stmt *ForRange, Stmt *Body);
3995 
3996  StmtResult ActOnGotoStmt(SourceLocation GotoLoc,
3997  SourceLocation LabelLoc,
3998  LabelDecl *TheDecl);
3999  StmtResult ActOnIndirectGotoStmt(SourceLocation GotoLoc,
4000  SourceLocation StarLoc,
4001  Expr *DestExp);
4002  StmtResult ActOnContinueStmt(SourceLocation ContinueLoc, Scope *CurScope);
4003  StmtResult ActOnBreakStmt(SourceLocation BreakLoc, Scope *CurScope);
4004 
4005  void ActOnCapturedRegionStart(SourceLocation Loc, Scope *CurScope,
4006  CapturedRegionKind Kind, unsigned NumParams);
4007  typedef std::pair<StringRef, QualType> CapturedParamNameType;
4008  void ActOnCapturedRegionStart(SourceLocation Loc, Scope *CurScope,
4011  StmtResult ActOnCapturedRegionEnd(Stmt *S);
4012  void ActOnCapturedRegionError();
4013  RecordDecl *CreateCapturedStmtRecordDecl(CapturedDecl *&CD,
4014  SourceLocation Loc,
4015  unsigned NumParams);
4016 
4018  CES_Strict = 0,
4019  CES_AllowParameters = 1,
4020  CES_AllowDifferentTypes = 2,
4021  CES_AllowExceptionVariables = 4,
4022  CES_FormerDefault = (CES_AllowParameters),
4023  CES_Default = (CES_AllowParameters | CES_AllowDifferentTypes),
4024  CES_AsIfByStdMove = (CES_AllowParameters | CES_AllowDifferentTypes |
4025  CES_AllowExceptionVariables),
4026  };
4027 
4028  VarDecl *getCopyElisionCandidate(QualType ReturnType, Expr *E,
4030  bool isCopyElisionCandidate(QualType ReturnType, const VarDecl *VD,
4032 
4033  StmtResult ActOnReturnStmt(SourceLocation ReturnLoc, Expr *RetValExp,
4034  Scope *CurScope);
4035  StmtResult BuildReturnStmt(SourceLocation ReturnLoc, Expr *RetValExp);
4036  StmtResult ActOnCapScopeReturnStmt(SourceLocation ReturnLoc, Expr *RetValExp);
4037 
4038  StmtResult ActOnGCCAsmStmt(SourceLocation AsmLoc, bool IsSimple,
4039  bool IsVolatile, unsigned NumOutputs,
4040  unsigned NumInputs, IdentifierInfo **Names,
4041  MultiExprArg Constraints, MultiExprArg Exprs,
4042  Expr *AsmString, MultiExprArg Clobbers,
4043  unsigned NumLabels,
4044  SourceLocation RParenLoc);
4045 
4046  void FillInlineAsmIdentifierInfo(Expr *Res,
4047  llvm::InlineAsmIdentifierInfo &Info);
4048  ExprResult LookupInlineAsmIdentifier(CXXScopeSpec &SS,
4049  SourceLocation TemplateKWLoc,
4050  UnqualifiedId &Id,
4051  bool IsUnevaluatedContext);
4052  bool LookupInlineAsmField(StringRef Base, StringRef Member,
4053  unsigned &Offset, SourceLocation AsmLoc);
4054  ExprResult LookupInlineAsmVarDeclField(Expr *RefExpr, StringRef Member,
4055  SourceLocation AsmLoc);
4056  StmtResult ActOnMSAsmStmt(SourceLocation AsmLoc, SourceLocation LBraceLoc,
4057  ArrayRef<Token> AsmToks,
4058  StringRef AsmString,
4059  unsigned NumOutputs, unsigned NumInputs,
4060  ArrayRef<StringRef> Constraints,
4061  ArrayRef<StringRef> Clobbers,
4062  ArrayRef<Expr*> Exprs,
4063  SourceLocation EndLoc);
4064  LabelDecl *GetOrCreateMSAsmLabel(StringRef ExternalLabelName,
4065  SourceLocation Location,
4066  bool AlwaysCreate);
4067 
4068  VarDecl *BuildObjCExceptionDecl(TypeSourceInfo *TInfo, QualType ExceptionType,
4069  SourceLocation StartLoc,
4070  SourceLocation IdLoc, IdentifierInfo *Id,
4071  bool Invalid = false);
4072 
4073  Decl *ActOnObjCExceptionDecl(Scope *S, Declarator &D);
4074 
4075  StmtResult ActOnObjCAtCatchStmt(SourceLocation AtLoc, SourceLocation RParen,
4076  Decl *Parm, Stmt *Body);
4077 
4078  StmtResult ActOnObjCAtFinallyStmt(SourceLocation AtLoc, Stmt *Body);
4079 
4080  StmtResult ActOnObjCAtTryStmt(SourceLocation AtLoc, Stmt *Try,
4081  MultiStmtArg Catch, Stmt *Finally);
4082 
4083  StmtResult BuildObjCAtThrowStmt(SourceLocation AtLoc, Expr *Throw);
4084  StmtResult ActOnObjCAtThrowStmt(SourceLocation AtLoc, Expr *Throw,
4085  Scope *CurScope);
4086  ExprResult ActOnObjCAtSynchronizedOperand(SourceLocation atLoc,
4087  Expr *operand);
4088  StmtResult ActOnObjCAtSynchronizedStmt(SourceLocation AtLoc,
4089  Expr *SynchExpr,
4090  Stmt *SynchBody);
4091 
4092  StmtResult ActOnObjCAutoreleasePoolStmt(SourceLocation AtLoc, Stmt *Body);
4093 
4094  VarDecl *BuildExceptionDeclaration(Scope *S, TypeSourceInfo *TInfo,
4095  SourceLocation StartLoc,
4096  SourceLocation IdLoc,
4097  IdentifierInfo *Id);
4098 
4099  Decl *ActOnExceptionDeclarator(Scope *S, Declarator &D);
4100 
4101  StmtResult ActOnCXXCatchBlock(SourceLocation CatchLoc,
4102  Decl *ExDecl, Stmt *HandlerBlock);
4103  StmtResult ActOnCXXTryBlock(SourceLocation TryLoc, Stmt *TryBlock,
4104  ArrayRef<Stmt *> Handlers);
4105 
4106  StmtResult ActOnSEHTryBlock(bool IsCXXTry, // try (true) or __try (false) ?
4107  SourceLocation TryLoc, Stmt *TryBlock,
4108  Stmt *Handler);
4109  StmtResult ActOnSEHExceptBlock(SourceLocation Loc,
4110  Expr *FilterExpr,
4111  Stmt *Block);
4112  void ActOnStartSEHFinallyBlock();
4113  void ActOnAbortSEHFinallyBlock();
4114  StmtResult ActOnFinishSEHFinallyBlock(SourceLocation Loc, Stmt *Block);
4115  StmtResult ActOnSEHLeaveStmt(SourceLocation Loc, Scope *CurScope);
4116 
4117  void DiagnoseReturnInConstructorExceptionHandler(CXXTryStmt *TryBlock);
4118 
4119  bool ShouldWarnIfUnusedFileScopedDecl(const DeclaratorDecl *D) const;
4120 
4121  /// If it's a file scoped decl that must warn if not used, keep track
4122  /// of it.
4123  void MarkUnusedFileScopedDecl(const DeclaratorDecl *D);
4124 
4125  /// DiagnoseUnusedExprResult - If the statement passed in is an expression
4126  /// whose result is unused, warn.
4127  void DiagnoseUnusedExprResult(const Stmt *S);
4128  void DiagnoseUnusedNestedTypedefs(const RecordDecl *D);
4129  void DiagnoseUnusedDecl(const NamedDecl *ND);
4130 
4131  /// Emit \p DiagID if statement located on \p StmtLoc has a suspicious null
4132  /// statement as a \p Body, and it is located on the same line.
4133  ///
4134  /// This helps prevent bugs due to typos, such as:
4135  /// if (condition);
4136  /// do_stuff();
4137  void DiagnoseEmptyStmtBody(SourceLocation StmtLoc,
4138  const Stmt *Body,
4139  unsigned DiagID);
4140 
4141  /// Warn if a for/while loop statement \p S, which is followed by
4142  /// \p PossibleBody, has a suspicious null statement as a body.
4143  void DiagnoseEmptyLoopBody(const Stmt *S,
4144  const Stmt *PossibleBody);
4145 
4146  /// Warn if a value is moved to itself.
4147  void DiagnoseSelfMove(const Expr *LHSExpr, const Expr *RHSExpr,
4148  SourceLocation OpLoc);
4149 
4150  /// Warn if we're implicitly casting from a _Nullable pointer type to a
4151  /// _Nonnull one.
4152  void diagnoseNullableToNonnullConversion(QualType DstType, QualType SrcType,
4153  SourceLocation Loc);
4154 
4155  /// Warn when implicitly casting 0 to nullptr.
4156  void diagnoseZeroToNullptrConversion(CastKind Kind, const Expr *E);
4157 
4159  return DelayedDiagnostics.push(pool);
4160  }
4161  void PopParsingDeclaration(ParsingDeclState state, Decl *decl);
4162 
4163  typedef ProcessingContextState ParsingClassState;
4164  ParsingClassState PushParsingClass() {
4166  }
4167  void PopParsingClass(ParsingClassState state) {
4169  }
4170 
4171  void redelayDiagnostics(sema::DelayedDiagnosticPool &pool);
4172 
4173  void DiagnoseAvailabilityOfDecl(NamedDecl *D, ArrayRef<SourceLocation> Locs,
4174  const ObjCInterfaceDecl *UnknownObjCClass,
4175  bool ObjCPropertyAccess,
4176  bool AvoidPartialAvailabilityChecks = false,
4177  ObjCInterfaceDecl *ClassReceiver = nullptr);
4178 
4179  bool makeUnavailableInSystemHeader(SourceLocation loc,
4180  UnavailableAttr::ImplicitReason reason);
4181 
4182  /// Issue any -Wunguarded-availability warnings in \c FD
4183  void DiagnoseUnguardedAvailabilityViolations(Decl *FD);
4184 
4185  //===--------------------------------------------------------------------===//
4186  // Expression Parsing Callbacks: SemaExpr.cpp.
4187 
4188  bool CanUseDecl(NamedDecl *D, bool TreatUnavailableAsInvalid);
4189  bool DiagnoseUseOfDecl(NamedDecl *D, ArrayRef<SourceLocation> Locs,
4190  const ObjCInterfaceDecl *UnknownObjCClass = nullptr,
4191  bool ObjCPropertyAccess = false,
4192  bool AvoidPartialAvailabilityChecks = false,
4193  ObjCInterfaceDecl *ClassReciever = nullptr);
4194  void NoteDeletedFunction(FunctionDecl *FD);
4195  void NoteDeletedInheritingConstructor(CXXConstructorDecl *CD);
4196  bool DiagnosePropertyAccessorMismatch(ObjCPropertyDecl *PD,
4197  ObjCMethodDecl *Getter,
4198  SourceLocation Loc);
4199  void DiagnoseSentinelCalls(NamedDecl *D, SourceLocation Loc,
4200  ArrayRef<Expr *> Args);
4201 
4202  void PushExpressionEvaluationContext(
4203  ExpressionEvaluationContext NewContext, Decl *LambdaContextDecl = nullptr,
4205  ExpressionEvaluationContextRecord::EK_Other);
4206  enum ReuseLambdaContextDecl_t { ReuseLambdaContextDecl };
4207  void PushExpressionEvaluationContext(
4210  ExpressionEvaluationContextRecord::EK_Other);
4211  void PopExpressionEvaluationContext();
4212 
4213  void DiscardCleanupsInEvaluationContext();
4214 
4215  ExprResult TransformToPotentiallyEvaluated(Expr *E);
4216  ExprResult HandleExprEvaluationContextForTypeof(Expr *E);
4217 
4218  ExprResult ActOnConstantExpression(ExprResult Res);
4219 
4220  // Functions for marking a declaration referenced. These functions also
4221  // contain the relevant logic for marking if a reference to a function or
4222  // variable is an odr-use (in the C++11 sense). There are separate variants
4223  // for expressions referring to a decl; these exist because odr-use marking
4224  // needs to be delayed for some constant variables when we build one of the
4225  // named expressions.
4226  //
4227  // MightBeOdrUse indicates whether the use could possibly be an odr-use, and
4228  // should usually be true. This only needs to be set to false if the lack of
4229  // odr-use cannot be determined from the current context (for instance,
4230  // because the name denotes a virtual function and was written without an
4231  // explicit nested-name-specifier).
4232  void MarkAnyDeclReferenced(SourceLocation Loc, Decl *D, bool MightBeOdrUse);
4233  void MarkFunctionReferenced(SourceLocation Loc, FunctionDecl *Func,
4234  bool MightBeOdrUse = true);
4235  void MarkVariableReferenced(SourceLocation Loc, VarDecl *Var);
4236  void MarkDeclRefReferenced(DeclRefExpr *E, const Expr *Base = nullptr);
4237  void MarkMemberReferenced(MemberExpr *E);
4238  void MarkFunctionParmPackReferenced(FunctionParmPackExpr *E);
4239  void MarkCaptureUsedInEnclosingContext(VarDecl *Capture, SourceLocation Loc,
4240  unsigned CapturingScopeIndex);
4241 
4242  ExprResult CheckLValueToRValueConversionOperand(Expr *E);
4243  void CleanupVarDeclMarking();
4244 
4246  TryCapture_Implicit, TryCapture_ExplicitByVal, TryCapture_ExplicitByRef
4247  };
4248 
4249  /// Try to capture the given variable.
4250  ///
4251  /// \param Var The variable to capture.
4252  ///
4253  /// \param Loc The location at which the capture occurs.
4254  ///
4255  /// \param Kind The kind of capture, which may be implicit (for either a
4256  /// block or a lambda), or explicit by-value or by-reference (for a lambda).
4257  ///
4258  /// \param EllipsisLoc The location of the ellipsis, if one is provided in
4259  /// an explicit lambda capture.
4260  ///
4261  /// \param BuildAndDiagnose Whether we are actually supposed to add the
4262  /// captures or diagnose errors. If false, this routine merely check whether
4263  /// the capture can occur without performing the capture itself or complaining
4264  /// if the variable cannot be captured.
4265  ///
4266  /// \param CaptureType Will be set to the type of the field used to capture
4267  /// this variable in the innermost block or lambda. Only valid when the
4268  /// variable can be captured.
4269  ///
4270  /// \param DeclRefType Will be set to the type of a reference to the capture
4271  /// from within the current scope. Only valid when the variable can be
4272  /// captured.
4273  ///
4274  /// \param FunctionScopeIndexToStopAt If non-null, it points to the index
4275  /// of the FunctionScopeInfo stack beyond which we do not attempt to capture.
4276  /// This is useful when enclosing lambdas must speculatively capture
4277  /// variables that may or may not be used in certain specializations of
4278  /// a nested generic lambda.
4279  ///
4280  /// \returns true if an error occurred (i.e., the variable cannot be
4281  /// captured) and false if the capture succeeded.
4282  bool tryCaptureVariable(VarDecl *Var, SourceLocation Loc, TryCaptureKind Kind,
4283  SourceLocation EllipsisLoc, bool BuildAndDiagnose,
4284  QualType &CaptureType,
4285  QualType &DeclRefType,
4286  const unsigned *const FunctionScopeIndexToStopAt);
4287 
4288  /// Try to capture the given variable.
4289  bool tryCaptureVariable(VarDecl *Var, SourceLocation Loc,
4290  TryCaptureKind Kind = TryCapture_Implicit,
4291  SourceLocation EllipsisLoc = SourceLocation());
4292 
4293  /// Checks if the variable must be captured.
4294  bool NeedToCaptureVariable(VarDecl *Var, SourceLocation Loc);
4295 
4296  /// Given a variable, determine the type that a reference to that
4297  /// variable will have in the given scope.
4298  QualType getCapturedDeclRefType(VarDecl *Var, SourceLocation Loc);
4299 
4300  /// Mark all of the declarations referenced within a particular AST node as
4301  /// referenced. Used when template instantiation instantiates a non-dependent
4302  /// type -- entities referenced by the type are now referenced.
4303  void MarkDeclarationsReferencedInType(SourceLocation Loc, QualType T);
4304  void MarkDeclarationsReferencedInExpr(Expr *E,
4305  bool SkipLocalVariables = false);
4306 
4307  /// Try to recover by turning the given expression into a
4308  /// call. Returns true if recovery was attempted or an error was
4309  /// emitted; this may also leave the ExprResult invalid.
4310  bool tryToRecoverWithCall(ExprResult &E, const PartialDiagnostic &PD,
4311  bool ForceComplain = false,
4312  bool (*IsPlausibleResult)(QualType) = nullptr);
4313 
4314  /// Figure out if an expression could be turned into a call.
4315  bool tryExprAsCall(Expr &E, QualType &ZeroArgCallReturnTy,
4316  UnresolvedSetImpl &NonTemplateOverloads);
4317 
4318  /// Conditionally issue a diagnostic based on the current
4319  /// evaluation context.
4320  ///
4321  /// \param Statement If Statement is non-null, delay reporting the
4322  /// diagnostic until the function body is parsed, and then do a basic
4323  /// reachability analysis to determine if the statement is reachable.
4324  /// If it is unreachable, the diagnostic will not be emitted.
4325  bool DiagRuntimeBehavior(SourceLocation Loc, const Stmt *Statement,
4326  const PartialDiagnostic &PD);
4327  /// Similar, but diagnostic is only produced if all the specified statements
4328  /// are reachable.
4329  bool DiagRuntimeBehavior(SourceLocation Loc, ArrayRef<const Stmt*> Stmts,
4330  const PartialDiagnostic &PD);
4331 
4332  // Primary Expressions.
4333  SourceRange getExprRange(Expr *E) const;
4334 
4335  ExprResult ActOnIdExpression(
4336  Scope *S, CXXScopeSpec &SS, SourceLocation TemplateKWLoc,
4337  UnqualifiedId &Id, bool HasTrailingLParen, bool IsAddressOfOperand,
4338  CorrectionCandidateCallback *CCC = nullptr,
4339  bool IsInlineAsmIdentifier = false, Token *KeywordReplacement = nullptr);
4340 
4341  void DecomposeUnqualifiedId(const UnqualifiedId &Id,
4342  TemplateArgumentListInfo &Buffer,
4343  DeclarationNameInfo &NameInfo,
4344  const TemplateArgumentListInfo *&TemplateArgs);
4345 
4346  bool
4347  DiagnoseEmptyLookup(Scope *S, CXXScopeSpec &SS, LookupResult &R,
4349  TemplateArgumentListInfo *ExplicitTemplateArgs = nullptr,
4350  ArrayRef<Expr *> Args = None, TypoExpr **Out = nullptr);
4351 
4352  ExprResult LookupInObjCMethod(LookupResult &LookUp, Scope *S,
4353  IdentifierInfo *II,
4354  bool AllowBuiltinCreation=false);
4355 
4356  ExprResult ActOnDependentIdExpression(const CXXScopeSpec &SS,
4357  SourceLocation TemplateKWLoc,
4358  const DeclarationNameInfo &NameInfo,
4359  bool isAddressOfOperand,
4360  const TemplateArgumentListInfo *TemplateArgs);
4361 
4362  /// If \p D cannot be odr-used in the current expression evaluation context,
4363  /// return a reason explaining why. Otherwise, return NOUR_None.
4364  NonOdrUseReason getNonOdrUseReasonInCurrentContext(ValueDecl *D);
4365 
4366  DeclRefExpr *BuildDeclRefExpr(ValueDecl *D, QualType Ty, ExprValueKind VK,
4367  SourceLocation Loc,
4368  const CXXScopeSpec *SS = nullptr);
4369  DeclRefExpr *
4370  BuildDeclRefExpr(ValueDecl *D, QualType Ty, ExprValueKind VK,
4371  const DeclarationNameInfo &NameInfo,
4372  const CXXScopeSpec *SS = nullptr,
4373  NamedDecl *FoundD = nullptr,
4374  SourceLocation TemplateKWLoc = SourceLocation(),
4375  const TemplateArgumentListInfo *TemplateArgs = nullptr);
4376  DeclRefExpr *
4377  BuildDeclRefExpr(ValueDecl *D, QualType Ty, ExprValueKind VK,
4378  const DeclarationNameInfo &NameInfo,
4380  NamedDecl *FoundD = nullptr,
4381  SourceLocation TemplateKWLoc = SourceLocation(),
4382  const TemplateArgumentListInfo *TemplateArgs = nullptr);
4383 
4384  ExprResult
4385  BuildAnonymousStructUnionMemberReference(
4386  const CXXScopeSpec &SS,
4387  SourceLocation nameLoc,
4388  IndirectFieldDecl *indirectField,
4389  DeclAccessPair FoundDecl = DeclAccessPair::make(nullptr, AS_none),
4390  Expr *baseObjectExpr = nullptr,
4391  SourceLocation opLoc = SourceLocation());
4392 
4393  ExprResult BuildPossibleImplicitMemberExpr(const CXXScopeSpec &SS,
4394  SourceLocation TemplateKWLoc,
4395  LookupResult &R,
4396  const TemplateArgumentListInfo *TemplateArgs,
4397  const Scope *S);
4398  ExprResult BuildImplicitMemberExpr(const CXXScopeSpec &SS,
4399  SourceLocation TemplateKWLoc,
4400  LookupResult &R,
4401  const TemplateArgumentListInfo *TemplateArgs,
4402  bool IsDefiniteInstance,
4403  const Scope *S);
4404  bool UseArgumentDependentLookup(const CXXScopeSpec &SS,
4405  const LookupResult &R,
4406  bool HasTrailingLParen);
4407 
4408  ExprResult
4409  BuildQualifiedDeclarationNameExpr(CXXScopeSpec &SS,
4410  const DeclarationNameInfo &NameInfo,
4411  bool IsAddressOfOperand, const Scope *S,
4412  TypeSourceInfo **RecoveryTSI = nullptr);
4413 
4414  ExprResult BuildDependentDeclRefExpr(const CXXScopeSpec &SS,
4415  SourceLocation TemplateKWLoc,
4416  const DeclarationNameInfo &NameInfo,
4417  const TemplateArgumentListInfo *TemplateArgs);
4418 
4419  ExprResult BuildDeclarationNameExpr(const CXXScopeSpec &SS,
4420  LookupResult &R,
4421  bool NeedsADL,
4422  bool AcceptInvalidDecl = false);
4423  ExprResult BuildDeclarationNameExpr(
4424  const CXXScopeSpec &SS, const DeclarationNameInfo &NameInfo, NamedDecl *D,
4425  NamedDecl *FoundD = nullptr,
4426  const TemplateArgumentListInfo *TemplateArgs = nullptr,
4427  bool AcceptInvalidDecl = false);
4428 
4429  ExprResult BuildLiteralOperatorCall(LookupResult &R,
4430  DeclarationNameInfo &SuffixInfo,
4431  ArrayRef<Expr *> Args,
4432  SourceLocation LitEndLoc,
4433  TemplateArgumentListInfo *ExplicitTemplateArgs = nullptr);
4434 
4435  ExprResult BuildPredefinedExpr(SourceLocation Loc,
4437  ExprResult ActOnPredefinedExpr(SourceLocation Loc, tok::TokenKind Kind);
4438  ExprResult ActOnIntegerConstant(SourceLocation Loc, uint64_t Val);
4439 
4440  bool CheckLoopHintExpr(Expr *E, SourceLocation Loc);
4441 
4442  ExprResult ActOnNumericConstant(const Token &Tok, Scope *UDLScope = nullptr);
4443  ExprResult ActOnCharacterConstant(const Token &Tok,
4444  Scope *UDLScope = nullptr);
4445  ExprResult ActOnParenExpr(SourceLocation L, SourceLocation R, Expr *E);
4446  ExprResult ActOnParenListExpr(SourceLocation L,
4447  SourceLocation R,
4448  MultiExprArg Val);
4449 
4450  /// ActOnStringLiteral - The specified tokens were lexed as pasted string
4451  /// fragments (e.g. "foo" "bar" L"baz").
4452  ExprResult ActOnStringLiteral(ArrayRef<Token> StringToks,
4453  Scope *UDLScope = nullptr);
4454 
4455  ExprResult ActOnGenericSelectionExpr(SourceLocation KeyLoc,
4456  SourceLocation DefaultLoc,
4457  SourceLocation RParenLoc,
4458  Expr *ControllingExpr,
4459  ArrayRef<ParsedType> ArgTypes,
4460  ArrayRef<Expr *> ArgExprs);
4461  ExprResult CreateGenericSelectionExpr(SourceLocation KeyLoc,
4462  SourceLocation DefaultLoc,
4463  SourceLocation RParenLoc,
4464  Expr *ControllingExpr,
4466  ArrayRef<Expr *> Exprs);
4467 
4468  // Binary/Unary Operators. 'Tok' is the token for the operator.
4469  ExprResult CreateBuiltinUnaryOp(SourceLocation OpLoc, UnaryOperatorKind Opc,
4470  Expr *InputExpr);
4471  ExprResult BuildUnaryOp(Scope *S, SourceLocation OpLoc,
4472  UnaryOperatorKind Opc, Expr *Input);
4473  ExprResult ActOnUnaryOp(Scope *S, SourceLocation OpLoc,
4474  tok::TokenKind Op, Expr *Input);
4475 
4476  bool isQualifiedMemberAccess(Expr *E);
4477  QualType CheckAddressOfOperand(ExprResult &Operand, SourceLocation OpLoc);
4478 
4479  ExprResult CreateUnaryExprOrTypeTraitExpr(TypeSourceInfo *TInfo,
4480  SourceLocation OpLoc,
4481  UnaryExprOrTypeTrait ExprKind,
4482  SourceRange R);
4483  ExprResult CreateUnaryExprOrTypeTraitExpr(Expr *E, SourceLocation OpLoc,
4484  UnaryExprOrTypeTrait ExprKind);
4485  ExprResult
4486  ActOnUnaryExprOrTypeTraitExpr(SourceLocation OpLoc,
4487  UnaryExprOrTypeTrait ExprKind,
4488  bool IsType, void *TyOrEx,
4489  SourceRange ArgRange);
4490 
4491  ExprResult CheckPlaceholderExpr(Expr *E);
4492  bool CheckVecStepExpr(Expr *E);
4493 
4494  bool CheckUnaryExprOrTypeTraitOperand(Expr *E, UnaryExprOrTypeTrait ExprKind);
4495  bool CheckUnaryExprOrTypeTraitOperand(QualType ExprType, SourceLocation OpLoc,
4496  SourceRange ExprRange,
4497  UnaryExprOrTypeTrait ExprKind);
4498  ExprResult ActOnSizeofParameterPackExpr(Scope *S,
4499  SourceLocation OpLoc,
4500  IdentifierInfo &Name,
4501  SourceLocation NameLoc,
4502  SourceLocation RParenLoc);
4503  ExprResult ActOnPostfixUnaryOp(Scope *S, SourceLocation OpLoc,
4504  tok::TokenKind Kind, Expr *Input);
4505 
4506  ExprResult ActOnArraySubscriptExpr(Scope *S, Expr *Base, SourceLocation LLoc,
4507  Expr *Idx, SourceLocation RLoc);
4508  ExprResult CreateBuiltinArraySubscriptExpr(Expr *Base, SourceLocation LLoc,
4509  Expr *Idx, SourceLocation RLoc);
4510  ExprResult ActOnOMPArraySectionExpr(Expr *Base, SourceLocation LBLoc,
4511  Expr *LowerBound, SourceLocation ColonLoc,
4512  Expr *Length, SourceLocation RBLoc);
4513 
4514  // This struct is for use by ActOnMemberAccess to allow
4515  // BuildMemberReferenceExpr to be able to reinvoke ActOnMemberAccess after
4516  // changing the access operator from a '.' to a '->' (to see if that is the
4517  // change needed to fix an error about an unknown member, e.g. when the class
4518  // defines a custom operator->).
4520  Scope *S;
4523  };
4524 
4525  ExprResult BuildMemberReferenceExpr(
4526  Expr *Base, QualType BaseType, SourceLocation OpLoc, bool IsArrow,
4527  CXXScopeSpec &SS, SourceLocation TemplateKWLoc,
4528  NamedDecl *FirstQualifierInScope, const DeclarationNameInfo &NameInfo,
4529  const TemplateArgumentListInfo *TemplateArgs,
4530  const Scope *S,
4531  ActOnMemberAccessExtraArgs *ExtraArgs = nullptr);
4532 
4533  ExprResult
4534  BuildMemberReferenceExpr(Expr *Base, QualType BaseType, SourceLocation OpLoc,
4535  bool IsArrow, const CXXScopeSpec &SS,
4536  SourceLocation TemplateKWLoc,
4537  NamedDecl *FirstQualifierInScope, LookupResult &R,
4538  const TemplateArgumentListInfo *TemplateArgs,
4539  const Scope *S,
4540  bool SuppressQualifierCheck = false,
4541  ActOnMemberAccessExtraArgs *ExtraArgs = nullptr);
4542 
4543  ExprResult BuildFieldReferenceExpr(Expr *BaseExpr, bool IsArrow,
4544  SourceLocation OpLoc,
4545  const CXXScopeSpec &SS, FieldDecl *Field,
4546  DeclAccessPair FoundDecl,
4547  const DeclarationNameInfo &MemberNameInfo);
4548 
4549  ExprResult PerformMemberExprBaseConversion(Expr *Base, bool IsArrow);
4550 
4551  bool CheckQualifiedMemberReference(Expr *BaseExpr, QualType BaseType,
4552  const CXXScopeSpec &SS,
4553  const LookupResult &R);
4554 
4555  ExprResult ActOnDependentMemberExpr(Expr *Base, QualType BaseType,
4556  bool IsArrow, SourceLocation OpLoc,
4557  const CXXScopeSpec &SS,
4558  SourceLocation TemplateKWLoc,
4559  NamedDecl *FirstQualifierInScope,
4560  const DeclarationNameInfo &NameInfo,
4561  const TemplateArgumentListInfo *TemplateArgs);
4562 
4563  ExprResult ActOnMemberAccessExpr(Scope *S, Expr *Base,
4564  SourceLocation OpLoc,
4565  tok::TokenKind OpKind,
4566  CXXScopeSpec &SS,
4567  SourceLocation TemplateKWLoc,
4568  UnqualifiedId &Member,
4569  Decl *ObjCImpDecl);
4570 
4571  MemberExpr *
4572  BuildMemberExpr(Expr *Base, bool IsArrow, SourceLocation OpLoc,
4573  const CXXScopeSpec *SS, SourceLocation TemplateKWLoc,
4574  ValueDecl *Member, DeclAccessPair FoundDecl,
4575  bool HadMultipleCandidates,
4576  const DeclarationNameInfo &MemberNameInfo, QualType Ty,
4578  const TemplateArgumentListInfo *TemplateArgs = nullptr);
4579  MemberExpr *
4580  BuildMemberExpr(Expr *Base, bool IsArrow, SourceLocation OpLoc,
4581  NestedNameSpecifierLoc NNS, SourceLocation TemplateKWLoc,
4582  ValueDecl *Member, DeclAccessPair FoundDecl,
4583  bool HadMultipleCandidates,
4584  const DeclarationNameInfo &MemberNameInfo, QualType Ty,
4586  const TemplateArgumentListInfo *TemplateArgs = nullptr);
4587 
4588  void ActOnDefaultCtorInitializers(Decl *CDtorDecl);
4589  bool ConvertArgumentsForCall(CallExpr *Call, Expr *Fn,
4590  FunctionDecl *FDecl,
4591  const FunctionProtoType *Proto,
4592  ArrayRef<Expr *> Args,
4593  SourceLocation RParenLoc,
4594  bool ExecConfig = false);
4595  void CheckStaticArrayArgument(SourceLocation CallLoc,
4596  ParmVarDecl *Param,
4597  const Expr *ArgExpr);
4598 
4599  /// ActOnCallExpr - Handle a call to Fn with the specified array of arguments.
4600  /// This provides the location of the left/right parens and a list of comma
4601  /// locations.
4602  ExprResult ActOnCallExpr(Scope *S, Expr *Fn, SourceLocation LParenLoc,
4603  MultiExprArg ArgExprs, SourceLocation RParenLoc,
4604  Expr *ExecConfig = nullptr);
4605  ExprResult BuildCallExpr(Scope *S, Expr *Fn, SourceLocation LParenLoc,
4606  MultiExprArg ArgExprs, SourceLocation RParenLoc,
4607  Expr *ExecConfig = nullptr,
4608  bool IsExecConfig = false);
4609  ExprResult
4610  BuildResolvedCallExpr(Expr *Fn, NamedDecl *NDecl, SourceLocation LParenLoc,
4611  ArrayRef<Expr *> Arg, SourceLocation RParenLoc,
4612  Expr *Config = nullptr, bool IsExecConfig = false,
4613  ADLCallKind UsesADL = ADLCallKind::NotADL);
4614 
4615  ExprResult ActOnCUDAExecConfigExpr(Scope *S, SourceLocation LLLLoc,
4616  MultiExprArg ExecConfig,
4617  SourceLocation GGGLoc);
4618 
4619  ExprResult ActOnCastExpr(Scope *S, SourceLocation LParenLoc,
4620  Declarator &D, ParsedType &Ty,
4621  SourceLocation RParenLoc, Expr *CastExpr);
4622  ExprResult BuildCStyleCastExpr(SourceLocation LParenLoc,
4623  TypeSourceInfo *Ty,
4624  SourceLocation RParenLoc,
4625  Expr *Op);
4626  CastKind PrepareScalarCast(ExprResult &src, QualType destType);
4627 
4628  /// Build an altivec or OpenCL literal.
4629  ExprResult BuildVectorLiteral(SourceLocation LParenLoc,
4630  SourceLocation RParenLoc, Expr *E,
4631  TypeSourceInfo *TInfo);
4632 
4633  ExprResult MaybeConvertParenListExprToParenExpr(Scope *S, Expr *ME);
4634 
4635  ExprResult ActOnCompoundLiteral(SourceLocation LParenLoc,
4636  ParsedType Ty,
4637  SourceLocation RParenLoc,
4638  Expr *InitExpr);
4639 
4640  ExprResult BuildCompoundLiteralExpr(SourceLocation LParenLoc,
4641  TypeSourceInfo *TInfo,
4642  SourceLocation RParenLoc,
4643  Expr *LiteralExpr);
4644 
4645  ExprResult ActOnInitList(SourceLocation LBraceLoc,
4646  MultiExprArg InitArgList,
4647  SourceLocation RBraceLoc);
4648 
4649  ExprResult ActOnDesignatedInitializer(Designation &Desig,
4650  SourceLocation Loc,
4651  bool GNUSyntax,
4652  ExprResult Init);
4653 
4654 private:
4655  static BinaryOperatorKind ConvertTokenKindToBinaryOpcode(tok::TokenKind Kind);
4656 
4657 public:
4658  ExprResult ActOnBinOp(Scope *S, SourceLocation TokLoc,
4659  tok::TokenKind Kind, Expr *LHSExpr, Expr *RHSExpr);
4660  ExprResult BuildBinOp(Scope *S, SourceLocation OpLoc,
4661  BinaryOperatorKind Opc, Expr *LHSExpr, Expr *RHSExpr);
4662  ExprResult CreateBuiltinBinOp(SourceLocation OpLoc, BinaryOperatorKind Opc,
4663  Expr *LHSExpr, Expr *RHSExpr);
4664 
4665  void DiagnoseCommaOperator(const Expr *LHS, SourceLocation Loc);
4666 
4667  /// ActOnConditionalOp - Parse a ?: operation. Note that 'LHS' may be null
4668  /// in the case of a the GNU conditional expr extension.
4669  ExprResult ActOnConditionalOp(SourceLocation QuestionLoc,
4670  SourceLocation ColonLoc,
4671  Expr *CondExpr, Expr *LHSExpr, Expr *RHSExpr);
4672 
4673  /// ActOnAddrLabel - Parse the GNU address of label extension: "&&foo".
4674  ExprResult ActOnAddrLabel(SourceLocation OpLoc, SourceLocation LabLoc,
4675  LabelDecl *TheDecl);
4676 
4677  void ActOnStartStmtExpr();
4678  ExprResult ActOnStmtExpr(SourceLocation LPLoc, Stmt *SubStmt,
4679  SourceLocation RPLoc); // "({..})"
4680  // Handle the final expression in a statement expression.
4681  ExprResult ActOnStmtExprResult(ExprResult E);
4682  void ActOnStmtExprError();
4683 
4684  // __builtin_offsetof(type, identifier(.identifier|[expr])*)
4687  bool isBrackets; // true if [expr], false if .ident
4688  union {
4691  } U;
4692  };
4693 
4694  /// __builtin_offsetof(type, a.b[123][456].c)
4695  ExprResult BuildBuiltinOffsetOf(SourceLocation BuiltinLoc,
4696  TypeSourceInfo *TInfo,
4697  ArrayRef<OffsetOfComponent> Components,
4698  SourceLocation RParenLoc);
4699  ExprResult ActOnBuiltinOffsetOf(Scope *S,
4700  SourceLocation BuiltinLoc,
4702  ParsedType ParsedArgTy,
4703  ArrayRef<OffsetOfComponent> Components,
4704  SourceLocation RParenLoc);
4705 
4706  // __builtin_choose_expr(constExpr, expr1, expr2)
4707  ExprResult ActOnChooseExpr(SourceLocation BuiltinLoc,
4708  Expr *CondExpr, Expr *LHSExpr,
4709  Expr *RHSExpr, SourceLocation RPLoc);
4710 
4711  // __builtin_va_arg(expr, type)
4712  ExprResult ActOnVAArg(SourceLocation BuiltinLoc, Expr *E, ParsedType Ty,
4713  SourceLocation RPLoc);
4714  ExprResult BuildVAArgExpr(SourceLocation BuiltinLoc, Expr *E,
4715  TypeSourceInfo *TInfo, SourceLocation RPLoc);
4716 
4717  // __builtin_LINE(), __builtin_FUNCTION(), __builtin_FILE(),
4718  // __builtin_COLUMN()
4719  ExprResult ActOnSourceLocExpr(SourceLocExpr::IdentKind Kind,
4720  SourceLocation BuiltinLoc,
4721  SourceLocation RPLoc);
4722 
4723  // Build a potentially resolved SourceLocExpr.
4724  ExprResult BuildSourceLocExpr(SourceLocExpr::IdentKind Kind,
4725  SourceLocation BuiltinLoc, SourceLocation RPLoc,
4726  DeclContext *ParentContext);
4727 
4728  // __null
4729  ExprResult ActOnGNUNullExpr(SourceLocation TokenLoc);
4730 
4731  bool CheckCaseExpression(Expr *E);
4732 
4733  /// Describes the result of an "if-exists" condition check.
4735  /// The symbol exists.
4737 
4738  /// The symbol does not exist.
4740 
4741  /// The name is a dependent name, so the results will differ
4742  /// from one instantiation to the next.
4744 
4745  /// An error occurred.
4746  IER_Error
4747  };
4748 
4750  CheckMicrosoftIfExistsSymbol(Scope *S, CXXScopeSpec &SS,
4751  const DeclarationNameInfo &TargetNameInfo);
4752 
4754  CheckMicrosoftIfExistsSymbol(Scope *S, SourceLocation KeywordLoc,
4755  bool IsIfExists, CXXScopeSpec &SS,
4756  UnqualifiedId &Name);
4757 
4758  StmtResult BuildMSDependentExistsStmt(SourceLocation KeywordLoc,
4759  bool IsIfExists,
4760  NestedNameSpecifierLoc QualifierLoc,
4761  DeclarationNameInfo NameInfo,
4762  Stmt *Nested);
4763  StmtResult ActOnMSDependentExistsStmt(SourceLocation KeywordLoc,
4764  bool IsIfExists,
4765  CXXScopeSpec &SS, UnqualifiedId &Name,
4766  Stmt *Nested);
4767 
4768  //===------------------------- "Block" Extension ------------------------===//
4769 
4770  /// ActOnBlockStart - This callback is invoked when a block literal is
4771  /// started.
4772  void ActOnBlockStart(SourceLocation CaretLoc, Scope *CurScope);
4773 
4774  /// ActOnBlockArguments - This callback allows processing of block arguments.
4775  /// If there are no arguments, this is still invoked.
4776  void ActOnBlockArguments(SourceLocation CaretLoc, Declarator &ParamInfo,
4777  Scope *CurScope);
4778 
4779  /// ActOnBlockError - If there is an error parsing a block, this callback
4780  /// is invoked to pop the information about the block from the action impl.
4781  void ActOnBlockError(SourceLocation CaretLoc, Scope *CurScope);
4782 
4783  /// ActOnBlockStmtExpr - This is called when the body of a block statement
4784  /// literal was successfully completed. ^(int x){...}
4785  ExprResult ActOnBlockStmtExpr(SourceLocation CaretLoc, Stmt *Body,
4786  Scope *CurScope);
4787 
4788  //===---------------------------- Clang Extensions ----------------------===//
4789 
4790  /// __builtin_convertvector(...)
4791  ExprResult ActOnConvertVectorExpr(Expr *E, ParsedType ParsedDestTy,
4792  SourceLocation BuiltinLoc,
4793  SourceLocation RParenLoc);
4794 
4795  //===---------------------------- OpenCL Features -----------------------===//
4796 
4797  /// __builtin_astype(...)
4798  ExprResult ActOnAsTypeExpr(Expr *E, ParsedType ParsedDestTy,
4799  SourceLocation BuiltinLoc,
4800  SourceLocation RParenLoc);
4801 
4802  //===---------------------------- C++ Features --------------------------===//
4803 
4804  // Act on C++ namespaces
4805  Decl *ActOnStartNamespaceDef(Scope *S, SourceLocation InlineLoc,
4806  SourceLocation NamespaceLoc,
4807  SourceLocation IdentLoc, IdentifierInfo *Ident,
4808  SourceLocation LBrace,
4809  const ParsedAttributesView &AttrList,
4811  void ActOnFinishNamespaceDef(Decl *Dcl, SourceLocation RBrace);
4812 
4813  NamespaceDecl *getStdNamespace() const;
4814  NamespaceDecl *getOrCreateStdNamespace();
4815 
4816  NamespaceDecl *lookupStdExperimentalNamespace();
4817 
4818  CXXRecordDecl *getStdBadAlloc() const;
4819  EnumDecl *getStdAlignValT() const;
4820 
4821 private:
4822  // A cache representing if we've fully checked the various comparison category
4823  // types stored in ASTContext. The bit-index corresponds to the integer value
4824  // of a ComparisonCategoryType enumerator.
4825  llvm::SmallBitVector FullyCheckedComparisonCategories;
4826 
4827  ValueDecl *tryLookupCtorInitMemberDecl(CXXRecordDecl *ClassDecl,
4828  CXXScopeSpec &SS,
4829  ParsedType TemplateTypeTy,
4830  IdentifierInfo *MemberOrBase);
4831 
4832 public:
4833  /// Lookup the specified comparison category types in the standard
4834  /// library, an check the VarDecls possibly returned by the operator<=>
4835  /// builtins for that type.
4836  ///
4837  /// \return The type of the comparison category type corresponding to the
4838  /// specified Kind, or a null type if an error occurs
4839  QualType CheckComparisonCategoryType(ComparisonCategoryType Kind,
4840  SourceLocation Loc);
4841 
4842  /// Tests whether Ty is an instance of std::initializer_list and, if
4843  /// it is and Element is not NULL, assigns the element type to Element.
4844  bool isStdInitializerList(QualType Ty, QualType *Element);
4845 
4846  /// Looks for the std::initializer_list template and instantiates it
4847  /// with Element, or emits an error if it's not found.
4848  ///
4849  /// \returns The instantiated template, or null on error.
4850  QualType BuildStdInitializerList(QualType Element, SourceLocation Loc);
4851 
4852  /// Determine whether Ctor is an initializer-list constructor, as
4853  /// defined in [dcl.init.list]p2.
4854  bool isInitListConstructor(const FunctionDecl *Ctor);
4855 
4856  Decl *ActOnUsingDirective(Scope *CurScope, SourceLocation UsingLoc,
4857  SourceLocation NamespcLoc, CXXScopeSpec &SS,
4858  SourceLocation IdentLoc,
4859  IdentifierInfo *NamespcName,
4860  const ParsedAttributesView &AttrList);
4861 
4862  void PushUsingDirective(Scope *S, UsingDirectiveDecl *UDir);
4863 
4864  Decl *ActOnNamespaceAliasDef(Scope *CurScope,
4865  SourceLocation NamespaceLoc,
4866  SourceLocation AliasLoc,
4867  IdentifierInfo *Alias,
4868  CXXScopeSpec &SS,
4869  SourceLocation IdentLoc,
4870  IdentifierInfo *Ident);
4871 
4872  void HideUsingShadowDecl(Scope *S, UsingShadowDecl *Shadow);
4873  bool CheckUsingShadowDecl(UsingDecl *UD, NamedDecl *Target,
4874  const LookupResult &PreviousDecls,
4875  UsingShadowDecl *&PrevShadow);
4876  UsingShadowDecl *BuildUsingShadowDecl(Scope *S, UsingDecl *UD,
4877  NamedDecl *Target,
4878  UsingShadowDecl *PrevDecl);
4879 
4880  bool CheckUsingDeclRedeclaration(SourceLocation UsingLoc,
4881  bool HasTypenameKeyword,
4882  const CXXScopeSpec &SS,
4883  SourceLocation NameLoc,
4884  const LookupResult &Previous);
4885  bool CheckUsingDeclQualifier(SourceLocation UsingLoc,
4886  bool HasTypename,
4887  const CXXScopeSpec &SS,
4888  const DeclarationNameInfo &NameInfo,
4889  SourceLocation NameLoc);
4890 
4891  NamedDecl *BuildUsingDeclaration(
4892  Scope *S, AccessSpecifier AS, SourceLocation UsingLoc,
4893  bool HasTypenameKeyword, SourceLocation TypenameLoc, CXXScopeSpec &SS,
4894  DeclarationNameInfo NameInfo, SourceLocation EllipsisLoc,
4895  const ParsedAttributesView &AttrList, bool IsInstantiation);
4896  NamedDecl *BuildUsingPackDecl(NamedDecl *InstantiatedFrom,
4897  ArrayRef<NamedDecl *> Expansions);
4898 
4899  bool CheckInheritingConstructorUsingDecl(UsingDecl *UD);
4900 
4901  /// Given a derived-class using shadow declaration for a constructor and the
4902  /// correspnding base class constructor, find or create the implicit
4903  /// synthesized derived class constructor to use for this initialization.
4904  CXXConstructorDecl *
4905  findInheritingConstructor(SourceLocation Loc, CXXConstructorDecl *BaseCtor,
4906  ConstructorUsingShadowDecl *DerivedShadow);
4907 
4908  Decl *ActOnUsingDeclaration(Scope *CurScope, AccessSpecifier AS,
4909  SourceLocation UsingLoc,
4910  SourceLocation TypenameLoc, CXXScopeSpec &SS,
4911  UnqualifiedId &Name, SourceLocation EllipsisLoc,
4912  const ParsedAttributesView &AttrList);
4913  Decl *ActOnAliasDeclaration(Scope *CurScope, AccessSpecifier AS,
4914  MultiTemplateParamsArg TemplateParams,
4915  SourceLocation UsingLoc, UnqualifiedId &Name,
4916  const ParsedAttributesView &AttrList,
4917  TypeResult Type, Decl *DeclFromDeclSpec);
4918 
4919  /// BuildCXXConstructExpr - Creates a complete call to a constructor,
4920  /// including handling of its default argument expressions.
4921  ///
4922  /// \param ConstructKind - a CXXConstructExpr::ConstructionKind
4923  ExprResult
4924  BuildCXXConstructExpr(SourceLocation ConstructLoc, QualType DeclInitType,
4925  NamedDecl *FoundDecl,
4926  CXXConstructorDecl *Constructor, MultiExprArg Exprs,
4927  bool HadMultipleCandidates, bool IsListInitialization,
4928  bool IsStdInitListInitialization,
4929  bool RequiresZeroInit, unsigned ConstructKind,
4930  SourceRange ParenRange);
4931 
4932  /// Build a CXXConstructExpr whose constructor has already been resolved if
4933  /// it denotes an inherited constructor.
4934  ExprResult
4935  BuildCXXConstructExpr(SourceLocation ConstructLoc, QualType DeclInitType,
4936  CXXConstructorDecl *Constructor, bool Elidable,
4937  MultiExprArg Exprs,
4938  bool HadMultipleCandidates, bool IsListInitialization,
4939  bool IsStdInitListInitialization,
4940  bool RequiresZeroInit, unsigned ConstructKind,
4941  SourceRange ParenRange);
4942 
4943  // FIXME: Can we remove this and have the above BuildCXXConstructExpr check if
4944  // the constructor can be elidable?
4945  ExprResult
4946  BuildCXXConstructExpr(SourceLocation ConstructLoc, QualType DeclInitType,
4947  NamedDecl *FoundDecl,
4948  CXXConstructorDecl *Constructor, bool Elidable,
4949  MultiExprArg Exprs, bool HadMultipleCandidates,
4950  bool IsListInitialization,
4951  bool IsStdInitListInitialization, bool RequiresZeroInit,
4952  unsigned ConstructKind, SourceRange ParenRange);
4953 
4954  ExprResult BuildCXXDefaultInitExpr(SourceLocation Loc, FieldDecl *Field);
4955 
4956 
4957  /// Instantiate or parse a C++ default argument expression as necessary.
4958  /// Return true on error.
4959  bool CheckCXXDefaultArgExpr(SourceLocation CallLoc, FunctionDecl *FD,
4960  ParmVarDecl *Param);
4961 
4962  /// BuildCXXDefaultArgExpr - Creates a CXXDefaultArgExpr, instantiating
4963  /// the default expr if needed.
4964  ExprResult BuildCXXDefaultArgExpr(SourceLocation CallLoc,
4965  FunctionDecl *FD,
4966  ParmVarDecl *Param);
4967 
4968  /// FinalizeVarWithDestructor - Prepare for calling destructor on the
4969  /// constructed variable.
4970  void FinalizeVarWithDestructor(VarDecl *VD, const RecordType *DeclInitType);
4971 
4972  /// Helper class that collects exception specifications for
4973  /// implicitly-declared special member functions.
4975  // Pointer to allow copying
4976  Sema *Self;
4977  // We order exception specifications thus:
4978  // noexcept is the most restrictive, but is only used in C++11.
4979  // throw() comes next.
4980  // Then a throw(collected exceptions)
4981  // Finally no specification, which is expressed as noexcept(false).
4982  // throw(...) is used instead if any called function uses it.
4983  ExceptionSpecificationType ComputedEST;
4984  llvm::SmallPtrSet<CanQualType, 4> ExceptionsSeen;
4985  SmallVector<QualType, 4> Exceptions;
4986 
4987  void ClearExceptions() {
4988  ExceptionsSeen.clear();
4989  Exceptions.clear();
4990  }
4991 
4992  public:
4994  : Self(&Self), ComputedEST(EST_BasicNoexcept) {
4995  if (!Self.getLangOpts().CPlusPlus11)
4996  ComputedEST = EST_DynamicNone;
4997  }
4998 
4999  /// Get the computed exception specification type.
5001  assert(!isComputedNoexcept(ComputedEST) &&
5002  "noexcept(expr) should not be a possible result");
5003  return ComputedEST;
5004  }
5005 
5006  /// The number of exceptions in the exception specification.
5007  unsigned size() const { return Exceptions.size(); }
5008 
5009  /// The set of exceptions in the exception specification.
5010  const QualType *data() const { return Exceptions.data(); }
5011 
5012  /// Integrate another called method into the collected data.
5013  void CalledDecl(SourceLocation CallLoc, const CXXMethodDecl *Method);
5014 
5015  /// Integrate an invoked expression into the collected data.
5016  void CalledExpr(Expr *E);
5017 
5018  /// Overwrite an EPI's exception specification with this
5019  /// computed exception specification.
5022  ESI.Type = getExceptionSpecType();
5023  if (ESI.Type == EST_Dynamic) {
5024  ESI.Exceptions = Exceptions;
5025  } else if (ESI.Type == EST_None) {
5026  /// C++11 [except.spec]p14:
5027  /// The exception-specification is noexcept(false) if the set of
5028  /// potential exceptions of the special member function contains "any"
5029  ESI.Type = EST_NoexceptFalse;
5031  tok::kw_false).get();
5032  }
5033  return ESI;
5034  }
5035  };
5036 
5037  /// Determine what sort of exception specification a defaulted
5038  /// copy constructor of a class will have.
5040  ComputeDefaultedDefaultCtorExceptionSpec(SourceLocation Loc,
5041  CXXMethodDecl *MD);
5042 
5043  /// Determine what sort of exception specification a defaulted
5044  /// default constructor of a class will have, and whether the parameter
5045  /// will be const.
5047  ComputeDefaultedCopyCtorExceptionSpec(CXXMethodDecl *MD);
5048 
5049  /// Determine what sort of exception specification a defaulted
5050  /// copy assignment operator of a class will have, and whether the
5051  /// parameter will be const.
5053  ComputeDefaultedCopyAssignmentExceptionSpec(CXXMethodDecl *MD);
5054 
5055  /// Determine what sort of exception specification a defaulted move
5056  /// constructor of a class will have.
5058  ComputeDefaultedMoveCtorExceptionSpec(CXXMethodDecl *MD);
5059 
5060  /// Determine what sort of exception specification a defaulted move
5061  /// assignment operator of a class will have.
5063  ComputeDefaultedMoveAssignmentExceptionSpec(CXXMethodDecl *MD);
5064 
5065  /// Determine what sort of exception specification a defaulted
5066  /// destructor of a class will have.
5068  ComputeDefaultedDtorExceptionSpec(CXXMethodDecl *MD);
5069 
5070  /// Determine what sort of exception specification an inheriting
5071  /// constructor of a class will have.
5073  ComputeInheritingCtorExceptionSpec(SourceLocation Loc,
5074  CXXConstructorDecl *CD);
5075 
5076  /// Evaluate the implicit exception specification for a defaulted
5077  /// special member function.
5078  void EvaluateImplicitExceptionSpec(SourceLocation Loc, CXXMethodDecl *MD);
5079 
5080  /// Check the given noexcept-specifier, convert its expression, and compute
5081  /// the appropriate ExceptionSpecificationType.
5082  ExprResult ActOnNoexceptSpec(SourceLocation NoexceptLoc, Expr *NoexceptExpr,
5084 
5085  /// Check the given exception-specification and update the
5086  /// exception specification information with the results.
5087  void checkExceptionSpecification(bool IsTopLevel,
5089  ArrayRef<ParsedType> DynamicExceptions,
5090  ArrayRef<SourceRange> DynamicExceptionRanges,
5091  Expr *NoexceptExpr,
5092  SmallVectorImpl<QualType> &Exceptions,
5094 
5095  /// Determine if we're in a case where we need to (incorrectly) eagerly
5096  /// parse an exception specification to work around a libstdc++ bug.
5097  bool isLibstdcxxEagerExceptionSpecHack(const Declarator &D);
5098 
5099  /// Add an exception-specification to the given member function
5100  /// (or member function template). The exception-specification was parsed
5101  /// after the method itself was declared.
5102  void actOnDelayedExceptionSpecification(Decl *Method,
5104  SourceRange SpecificationRange,
5105  ArrayRef<ParsedType> DynamicExceptions,
5106  ArrayRef<SourceRange> DynamicExceptionRanges,
5107  Expr *NoexceptExpr);
5108 
5110 
5111  /// Determine if a special member function should have a deleted
5112  /// definition when it is defaulted.
5113  bool ShouldDeleteSpecialMember(CXXMethodDecl *MD, CXXSpecialMember CSM,
5114  InheritedConstructorInfo *ICI = nullptr,
5115  bool Diagnose = false);
5116 
5117  /// Declare the implicit default constructor for the given class.
5118  ///
5119  /// \param ClassDecl The class declaration into which the implicit
5120  /// default constructor will be added.
5121  ///
5122  /// \returns The implicitly-declared default constructor.
5123  CXXConstructorDecl *DeclareImplicitDefaultConstructor(
5124  CXXRecordDecl *ClassDecl);
5125 
5126  /// DefineImplicitDefaultConstructor - Checks for feasibility of
5127  /// defining this constructor as the default constructor.
5128  void DefineImplicitDefaultConstructor(SourceLocation CurrentLocation,
5129  CXXConstructorDecl *Constructor);
5130 
5131  /// Declare the implicit destructor for the given class.
5132  ///
5133  /// \param ClassDecl The class declaration into which the implicit
5134  /// destructor will be added.
5135  ///
5136  /// \returns The implicitly-declared destructor.
5137  CXXDestructorDecl *DeclareImplicitDestructor(CXXRecordDecl *ClassDecl);
5138 
5139  /// DefineImplicitDestructor - Checks for feasibility of
5140  /// defining this destructor as the default destructor.
5141  void DefineImplicitDestructor(SourceLocation CurrentLocation,
5142  CXXDestructorDecl *Destructor);
5143 
5144  /// Build an exception spec for destructors that don't have one.
5145  ///
5146  /// C++11 says that user-defined destructors with no exception spec get one
5147  /// that looks as if the destructor was implicitly declared.
5148  void AdjustDestructorExceptionSpec(CXXDestructorDecl *Destructor);
5149 
5150  /// Define the specified inheriting constructor.
5151  void DefineInheritingConstructor(SourceLocation UseLoc,
5152  CXXConstructorDecl *Constructor);
5153 
5154  /// Declare the implicit copy constructor for the given class.
5155  ///
5156  /// \param ClassDecl The class declaration into which the implicit
5157  /// copy constructor will be added.
5158  ///
5159  /// \returns The implicitly-declared copy constructor.
5160  CXXConstructorDecl *DeclareImplicitCopyConstructor(CXXRecordDecl *ClassDecl);
5161 
5162  /// DefineImplicitCopyConstructor - Checks for feasibility of
5163  /// defining this constructor as the copy constructor.
5164  void DefineImplicitCopyConstructor(SourceLocation CurrentLocation,
5165  CXXConstructorDecl *Constructor);
5166 
5167  /// Declare the implicit move constructor for the given class.
5168  ///
5169  /// \param ClassDecl The Class declaration into which the implicit
5170  /// move constructor will be added.
5171  ///
5172  /// \returns The implicitly-declared move constructor, or NULL if it wasn't
5173  /// declared.
5174  CXXConstructorDecl *DeclareImplicitMoveConstructor(CXXRecordDecl *ClassDecl);
5175 
5176  /// DefineImplicitMoveConstructor - Checks for feasibility of
5177  /// defining this constructor as the move constructor.
5178  void DefineImplicitMoveConstructor(SourceLocation CurrentLocation,
5179  CXXConstructorDecl *Constructor);
5180 
5181  /// Declare the implicit copy assignment operator for the given class.
5182  ///
5183  /// \param ClassDecl The class declaration into which the implicit
5184  /// copy assignment operator will be added.
5185  ///
5186  /// \returns The implicitly-declared copy assignment operator.
5187  CXXMethodDecl *DeclareImplicitCopyAssignment(CXXRecordDecl *ClassDecl);
5188 
5189  /// Defines an implicitly-declared copy assignment operator.
5190  void DefineImplicitCopyAssignment(SourceLocation CurrentLocation,
5191  CXXMethodDecl *MethodDecl);
5192 
5193  /// Declare the implicit move assignment operator for the given class.
5194  ///
5195  /// \param ClassDecl The Class declaration into which the implicit
5196  /// move assignment operator will be added.
5197  ///
5198  /// \returns The implicitly-declared move assignment operator, or NULL if it
5199  /// wasn't declared.
5200  CXXMethodDecl *DeclareImplicitMoveAssignment(CXXRecordDecl *ClassDecl);
5201 
5202  /// Defines an implicitly-declared move assignment operator.
5203  void DefineImplicitMoveAssignment(SourceLocation CurrentLocation,
5204  CXXMethodDecl *MethodDecl);
5205 
5206  /// Force the declaration of any implicitly-declared members of this
5207  /// class.
5208  void ForceDeclarationOfImplicitMembers(CXXRecordDecl *Class);
5209 
5210  /// Check a completed declaration of an implicit special member.
5211  void CheckImplicitSpecialMemberDeclaration(Scope *S, FunctionDecl *FD);
5212 
5213  /// Determine whether the given function is an implicitly-deleted
5214  /// special member function.
5215  bool isImplicitlyDeleted(FunctionDecl *FD);
5216 
5217  /// Check whether 'this' shows up in the type of a static member
5218  /// function after the (naturally empty) cv-qualifier-seq would be.
5219  ///
5220  /// \returns true if an error occurred.
5221  bool checkThisInStaticMemberFunctionType(CXXMethodDecl *Method);
5222 
5223  /// Whether this' shows up in the exception specification of a static
5224  /// member function.
5225  bool checkThisInStaticMemberFunctionExceptionSpec(CXXMethodDecl *Method);
5226 
5227  /// Check whether 'this' shows up in the attributes of the given
5228  /// static member function.
5229  ///
5230  /// \returns true if an error occurred.
5231  bool checkThisInStaticMemberFunctionAttributes(CXXMethodDecl *Method);
5232 
5233  /// MaybeBindToTemporary - If the passed in expression has a record type with
5234  /// a non-trivial destructor, this will return CXXBindTemporaryExpr. Otherwise
5235  /// it simply returns the passed in expression.
5236  ExprResult MaybeBindToTemporary(Expr *E);
5237 
5238  bool CompleteConstructorCall(CXXConstructorDecl *Constructor,
5239  MultiExprArg ArgsPtr,
5240  SourceLocation Loc,
5241  SmallVectorImpl<Expr*> &ConvertedArgs,
5242  bool AllowExplicit = false,
5243  bool IsListInitialization = false);
5244 
5245  ParsedType getInheritingConstructorName(CXXScopeSpec &SS,
5246  SourceLocation NameLoc,
5247  IdentifierInfo &Name);
5248 
5249  ParsedType getConstructorName(IdentifierInfo &II, SourceLocation NameLoc,
5250  Scope *S, CXXScopeSpec &SS,
5251  bool EnteringContext);
5252  ParsedType getDestructorName(SourceLocation TildeLoc,
5253  IdentifierInfo &II, SourceLocation NameLoc,
5254  Scope *S, CXXScopeSpec &SS,
5255  ParsedType ObjectType,
5256  bool EnteringContext);
5257 
5258  ParsedType getDestructorTypeForDecltype(const DeclSpec &DS,
5259  ParsedType ObjectType);
5260 
5261  // Checks that reinterpret casts don't have undefined behavior.
5262  void CheckCompatibleReinterpretCast(QualType SrcType, QualType DestType,
5263  bool IsDereference, SourceRange Range);
5264 
5265  /// ActOnCXXNamedCast - Parse {dynamic,static,reinterpret,const}_cast's.
5266  ExprResult ActOnCXXNamedCast(SourceLocation OpLoc,
5268  SourceLocation LAngleBracketLoc,
5269  Declarator &D,
5270  SourceLocation RAngleBracketLoc,
5271  SourceLocation LParenLoc,
5272  Expr *E,
5273  SourceLocation RParenLoc);
5274 
5275  ExprResult BuildCXXNamedCast(SourceLocation OpLoc,
5276  tok::TokenKind Kind,
5277  TypeSourceInfo *Ty,
5278  Expr *E,
5279  SourceRange AngleBrackets,
5280  SourceRange Parens);
5281 
5282  ExprResult ActOnBuiltinBitCastExpr(SourceLocation KWLoc, Declarator &Dcl,
5283  ExprResult Operand,
5284  SourceLocation RParenLoc);
5285 
5286  ExprResult BuildBuiltinBitCastExpr(SourceLocation KWLoc, TypeSourceInfo *TSI,
5287  Expr *Operand, SourceLocation RParenLoc);
5288 
5289  ExprResult BuildCXXTypeId(QualType TypeInfoType,
5290  SourceLocation TypeidLoc,
5291  TypeSourceInfo *Operand,
5292  SourceLocation RParenLoc);
5293  ExprResult BuildCXXTypeId(QualType TypeInfoType,
5294  SourceLocation TypeidLoc,
5295  Expr *Operand,
5296  SourceLocation RParenLoc);
5297 
5298  /// ActOnCXXTypeid - Parse typeid( something ).
5299  ExprResult ActOnCXXTypeid(SourceLocation OpLoc,
5300  SourceLocation LParenLoc, bool isType,
5301  void *TyOrExpr,
5302  SourceLocation RParenLoc);
5303 
5304  ExprResult BuildCXXUuidof(QualType TypeInfoType,
5305  SourceLocation TypeidLoc,
5306  TypeSourceInfo *Operand,
5307  SourceLocation RParenLoc);
5308  ExprResult BuildCXXUuidof(QualType TypeInfoType,
5309  SourceLocation TypeidLoc,
5310  Expr *Operand,
5311  SourceLocation RParenLoc);
5312 
5313  /// ActOnCXXUuidof - Parse __uuidof( something ).
5314  ExprResult ActOnCXXUuidof(SourceLocation OpLoc,
5315  SourceLocation LParenLoc, bool isType,
5316  void *TyOrExpr,
5317  SourceLocation RParenLoc);
5318 
5319  /// Handle a C++1z fold-expression: ( expr op ... op expr ).
5320  ExprResult ActOnCXXFoldExpr(SourceLocation LParenLoc, Expr *LHS,
5321  tok::TokenKind Operator,
5322  SourceLocation EllipsisLoc, Expr *RHS,
5323  SourceLocation RParenLoc);
5324  ExprResult BuildCXXFoldExpr(SourceLocation LParenLoc, Expr *LHS,
5325  BinaryOperatorKind Operator,
5326  SourceLocation EllipsisLoc, Expr *RHS,
5327  SourceLocation RParenLoc,
5328  Optional<unsigned> NumExpansions);
5329  ExprResult BuildEmptyCXXFoldExpr(SourceLocation EllipsisLoc,
5330  BinaryOperatorKind Operator);
5331 
5332  //// ActOnCXXThis - Parse 'this' pointer.
5333  ExprResult ActOnCXXThis(SourceLocation loc);
5334 
5335  /// Build a CXXThisExpr and mark it referenced in the current context.
5336  Expr *BuildCXXThisExpr(SourceLocation Loc, QualType Type, bool IsImplicit);
5337  void MarkThisReferenced(CXXThisExpr *This);
5338 
5339  /// Try to retrieve the type of the 'this' pointer.
5340  ///
5341  /// \returns The type of 'this', if possible. Otherwise, returns a NULL type.
5342  QualType getCurrentThisType();
5343 
5344  /// When non-NULL, the C++ 'this' expression is allowed despite the
5345  /// current context not being a non-static member function. In such cases,
5346  /// this provides the type used for 'this'.
5348 
5349  /// RAII object used to temporarily allow the C++ 'this' expression
5350  /// to be used, with the given qualifiers on the current class type.
5352  Sema &S;
5353  QualType OldCXXThisTypeOverride;
5354  bool Enabled;
5355 
5356  public:
5357  /// Introduce a new scope where 'this' may be allowed (when enabled),
5358  /// using the given declaration (which is either a class template or a
5359  /// class) along with the given qualifiers.
5360  /// along with the qualifiers placed on '*this'.
5361  CXXThisScopeRAII(Sema &S, Decl *ContextDecl, Qualifiers CXXThisTypeQuals,
5362  bool Enabled = true);
5363 
5364  ~CXXThisScopeRAII();
5365  };
5366 
5367  /// Make sure the value of 'this' is actually available in the current
5368  /// context, if it is a potentially evaluated context.
5369  ///
5370  /// \param Loc The location at which the capture of 'this' occurs.
5371  ///
5372  /// \param Explicit Whether 'this' is explicitly captured in a lambda
5373  /// capture list.
5374  ///
5375  /// \param FunctionScopeIndexToStopAt If non-null, it points to the index
5376  /// of the FunctionScopeInfo stack beyond which we do not attempt to capture.
5377  /// This is useful when enclosing lambdas must speculatively capture
5378  /// 'this' that may or may not be used in certain specializations of
5379  /// a nested generic lambda (depending on whether the name resolves to
5380  /// a non-static member function or a static function).
5381  /// \return returns 'true' if failed, 'false' if success.
5382  bool CheckCXXThisCapture(SourceLocation Loc, bool Explicit = false,
5383  bool BuildAndDiagnose = true,
5384  const unsigned *const FunctionScopeIndexToStopAt = nullptr,
5385  bool ByCopy = false);
5386 
5387  /// Determine whether the given type is the type of *this that is used
5388  /// outside of the body of a member function for a type that is currently
5389  /// being defined.
5390  bool isThisOutsideMemberFunctionBody(QualType BaseType);
5391 
5392  /// ActOnCXXBoolLiteral - Parse {true,false} literals.
5393  ExprResult ActOnCXXBoolLiteral(SourceLocation OpLoc, tok::TokenKind Kind);
5394 
5395 
5396  /// ActOnObjCBoolLiteral - Parse {__objc_yes,__objc_no} literals.
5397  ExprResult ActOnObjCBoolLiteral(SourceLocation OpLoc, tok::TokenKind Kind);
5398 
5399  ExprResult
5400  ActOnObjCAvailabilityCheckExpr(llvm::ArrayRef<AvailabilitySpec> AvailSpecs,
5401  SourceLocation AtLoc, SourceLocation RParen);
5402 
5403  /// ActOnCXXNullPtrLiteral - Parse 'nullptr'.
5404  ExprResult ActOnCXXNullPtrLiteral(SourceLocation Loc);
5405 
5406  //// ActOnCXXThrow - Parse throw expressions.
5407  ExprResult ActOnCXXThrow(Scope *S, SourceLocation OpLoc, Expr *expr);
5408  ExprResult BuildCXXThrow(SourceLocation OpLoc, Expr *Ex,
5409  bool IsThrownVarInScope);
5410  bool CheckCXXThrowOperand(SourceLocation ThrowLoc, QualType ThrowTy, Expr *E);
5411 
5412  /// ActOnCXXTypeConstructExpr - Parse construction of a specified type.
5413  /// Can be interpreted either as function-style casting ("int(x)")
5414  /// or class type construction ("ClassType(x,y,z)")
5415  /// or creation of a value-initialized type ("int()").
5416  ExprResult ActOnCXXTypeConstructExpr(ParsedType TypeRep,
5417  SourceLocation LParenOrBraceLoc,
5418  MultiExprArg Exprs,
5419  SourceLocation RParenOrBraceLoc,
5420  bool ListInitialization);
5421 
5422  ExprResult BuildCXXTypeConstructExpr(TypeSourceInfo *Type,
5423  SourceLocation LParenLoc,
5424  MultiExprArg Exprs,
5425  SourceLocation RParenLoc,
5426  bool ListInitialization);
5427 
5428  /// ActOnCXXNew - Parsed a C++ 'new' expression.
5429  ExprResult ActOnCXXNew(SourceLocation StartLoc, bool UseGlobal,
5430  SourceLocation PlacementLParen,
5431  MultiExprArg PlacementArgs,
5432  SourceLocation PlacementRParen,
5433  SourceRange TypeIdParens, Declarator &D,
5434  Expr *Initializer);
5435  ExprResult BuildCXXNew(SourceRange Range, bool UseGlobal,
5436  SourceLocation PlacementLParen,
5437  MultiExprArg PlacementArgs,
5438  SourceLocation PlacementRParen,
5439  SourceRange TypeIdParens,
5440  QualType AllocType,
5441  TypeSourceInfo *AllocTypeInfo,
5442  Optional<Expr *> ArraySize,
5443  SourceRange DirectInitRange,
5444  Expr *Initializer);
5445 
5446  /// Determine whether \p FD is an aligned allocation or deallocation
5447  /// function that is unavailable.
5448  bool isUnavailableAlignedAllocationFunction(const FunctionDecl &FD) const;
5449 
5450  /// Produce diagnostics if \p FD is an aligned allocation or deallocation
5451  /// function that is unavailable.
5452  void diagnoseUnavailableAlignedAllocation(const FunctionDecl &FD,
5453  SourceLocation Loc);
5454 
5455  bool CheckAllocatedType(QualType AllocType, SourceLocation Loc,
5456  SourceRange R);
5457 
5458  /// The scope in which to find allocation functions.
5460  /// Only look for allocation functions in the global scope.
5462  /// Only look for allocation functions in the scope of the
5463  /// allocated class.
5465  /// Look for allocation functions in both the global scope
5466  /// and in the scope of the allocated class.
5467  AFS_Both
5468  };
5469 
5470  /// Finds the overloads of operator new and delete that are appropriate
5471  /// for the allocation.
5472  bool FindAllocationFunctions(SourceLocation StartLoc, SourceRange Range,
5473  AllocationFunctionScope NewScope,
5474  AllocationFunctionScope DeleteScope,
5475  QualType AllocType, bool IsArray,
5476  bool &PassAlignment, MultiExprArg PlaceArgs,
5477  FunctionDecl *&OperatorNew,
5478  FunctionDecl *&OperatorDelete,
5479  bool Diagnose = true);
5480  void DeclareGlobalNewDelete();
5481  void DeclareGlobalAllocationFunction(DeclarationName Name, QualType Return,
5482  ArrayRef<QualType> Params);
5483 
5484  bool FindDeallocationFunction(SourceLocation StartLoc, CXXRecordDecl *RD,
5485  DeclarationName Name, FunctionDecl* &Operator,
5486  bool Diagnose = true);
5487  FunctionDecl *FindUsualDeallocationFunction(SourceLocation StartLoc,
5488  bool CanProvideSize,
5489  bool Overaligned,
5490  DeclarationName Name);
5491  FunctionDecl *FindDeallocationFunctionForDestructor(SourceLocation StartLoc,
5492  CXXRecordDecl *RD);
5493 
5494  /// ActOnCXXDelete - Parsed a C++ 'delete' expression
5495  ExprResult ActOnCXXDelete(SourceLocation StartLoc,
5496  bool UseGlobal, bool ArrayForm,
5497  Expr *Operand);
5498  void CheckVirtualDtorCall(CXXDestructorDecl *dtor, SourceLocation Loc,
5499  bool IsDelete, bool CallCanBeVirtual,
5500  bool WarnOnNonAbstractTypes,
5501  SourceLocation DtorLoc);
5502 
5503  ExprResult ActOnNoexceptExpr(SourceLocation KeyLoc, SourceLocation LParen,
5504  Expr *Operand, SourceLocation RParen);
5505  ExprResult BuildCXXNoexceptExpr(SourceLocation KeyLoc, Expr *Operand,
5506  SourceLocation RParen);
5507 
5508  /// Parsed one of the type trait support pseudo-functions.
5509  ExprResult ActOnTypeTrait(TypeTrait Kind, SourceLocation KWLoc,
5510  ArrayRef<ParsedType> Args,
5511  SourceLocation RParenLoc);
5512  ExprResult BuildTypeTrait(TypeTrait Kind, SourceLocation KWLoc,
5514  SourceLocation RParenLoc);
5515 
5516  /// ActOnArrayTypeTrait - Parsed one of the binary type trait support
5517  /// pseudo-functions.
5518  ExprResult ActOnArrayTypeTrait(ArrayTypeTrait ATT,
5519  SourceLocation KWLoc,
5520  ParsedType LhsTy,
5521  Expr *DimExpr,
5522  SourceLocation RParen);
5523 
5524  ExprResult BuildArrayTypeTrait(ArrayTypeTrait ATT,
5525  SourceLocation KWLoc,
5526  TypeSourceInfo *TSInfo,
5527  Expr *DimExpr,
5528  SourceLocation RParen);
5529 
5530  /// ActOnExpressionTrait - Parsed one of the unary type trait support
5531  /// pseudo-functions.
5532  ExprResult ActOnExpressionTrait(ExpressionTrait OET,
5533  SourceLocation KWLoc,
5534  Expr *Queried,
5535  SourceLocation RParen);
5536 
5537  ExprResult BuildExpressionTrait(ExpressionTrait OET,
5538  SourceLocation KWLoc,
5539  Expr *Queried,
5540  SourceLocation RParen);
5541 
5542  ExprResult ActOnStartCXXMemberReference(Scope *S,
5543  Expr *Base,
5544  SourceLocation OpLoc,
5545  tok::TokenKind OpKind,
5546  ParsedType &ObjectType,
5547  bool &MayBePseudoDestructor);
5548 
5549  ExprResult BuildPseudoDestructorExpr(Expr *Base,
5550  SourceLocation OpLoc,
5551  tok::TokenKind OpKind,
5552  const CXXScopeSpec &SS,
5553  TypeSourceInfo *ScopeType,
5554  SourceLocation CCLoc,
5555  SourceLocation TildeLoc,
5556  PseudoDestructorTypeStorage DestroyedType);
5557 
5558  ExprResult ActOnPseudoDestructorExpr(Scope *S, Expr *Base,
5559  SourceLocation OpLoc,
5560  tok::TokenKind OpKind,
5561  CXXScopeSpec &SS,
5562  UnqualifiedId &FirstTypeName,
5563  SourceLocation CCLoc,
5564  SourceLocation TildeLoc,
5565  UnqualifiedId &SecondTypeName);
5566 
5567  ExprResult ActOnPseudoDestructorExpr(Scope *S, Expr *Base,
5568  SourceLocation OpLoc,
5569  tok::TokenKind OpKind,
5570  SourceLocation TildeLoc,
5571  const DeclSpec& DS);
5572 
5573  /// MaybeCreateExprWithCleanups - If the current full-expression
5574  /// requires any cleanups, surround it with a ExprWithCleanups node.
5575  /// Otherwise, just returns the passed-in expression.
5576  Expr *MaybeCreateExprWithCleanups(Expr *SubExpr);
5577  Stmt *MaybeCreateStmtWithCleanups(Stmt *SubStmt);
5578  ExprResult MaybeCreateExprWithCleanups(ExprResult SubExpr);
5579 
5581  CreateMaterializeTemporaryExpr(QualType T, Expr *Temporary,
5582  bool BoundToLvalueReference);
5583 
5584  ExprResult ActOnFinishFullExpr(Expr *Expr, bool DiscardedValue) {
5585  return ActOnFinishFullExpr(
5586  Expr, Expr ? Expr->getExprLoc() : SourceLocation(), DiscardedValue);
5587  }
5588  ExprResult ActOnFinishFullExpr(Expr *Expr, SourceLocation CC,
5589  bool DiscardedValue, bool IsConstexpr = false);
5590  StmtResult ActOnFinishFullStmt(Stmt *Stmt);
5591 
5592  // Marks SS invalid if it represents an incomplete type.
5593  bool RequireCompleteDeclContext(CXXScopeSpec &SS, DeclContext *DC);
5594 
5595  DeclContext *computeDeclContext(QualType T);
5596  DeclContext *computeDeclContext(const CXXScopeSpec &SS,
5597  bool EnteringContext = false);
5598  bool isDependentScopeSpecifier(const CXXScopeSpec &SS);
5600 
5601  /// The parser has parsed a global nested-name-specifier '::'.
5602  ///
5603  /// \param CCLoc The location of the '::'.
5604  ///
5605  /// \param SS The nested-name-specifier, which will be updated in-place
5606  /// to reflect the parsed nested-name-specifier.
5607  ///
5608  /// \returns true if an error occurred, false otherwise.
5609  bool ActOnCXXGlobalScopeSpecifier(SourceLocation CCLoc, CXXScopeSpec &SS);
5610 
5611  /// The parser has parsed a '__super' nested-name-specifier.
5612  ///
5613  /// \param SuperLoc The location of the '__super' keyword.
5614  ///
5615  /// \param ColonColonLoc The location of the '::'.
5616  ///
5617  /// \param SS The nested-name-specifier, which will be updated in-place
5618  /// to reflect the parsed nested-name-specifier.
5619  ///
5620  /// \returns true if an error occurred, false otherwise.
5621  bool ActOnSuperScopeSpecifier(SourceLocation SuperLoc,
5622  SourceLocation ColonColonLoc, CXXScopeSpec &SS);
5623 
5624  bool isAcceptableNestedNameSpecifier(const NamedDecl *SD,
5625  bool *CanCorrect = nullptr);
5626  NamedDecl *FindFirstQualifierInScope(Scope *S, NestedNameSpecifier *NNS);
5627 
5628  /// Keeps information about an identifier in a nested-name-spec.
5629  ///
5631  /// The type of the object, if we're parsing nested-name-specifier in
5632  /// a member access expression.
5634 
5635  /// The identifier preceding the '::'.
5637 
5638  /// The location of the identifier.
5640 
5641  /// The location of the '::'.
5643 
5644  /// Creates info object for the most typical case.
5646  SourceLocation ColonColonLoc, ParsedType ObjectType = ParsedType())
5647  : ObjectType(ObjectType), Identifier(II), IdentifierLoc(IdLoc),
5648  CCLoc(ColonColonLoc) {
5649  }
5650 
5652  SourceLocation ColonColonLoc, QualType ObjectType)
5653  : ObjectType(ParsedType::make(ObjectType)), Identifier(II),
5654  IdentifierLoc(IdLoc), CCLoc(ColonColonLoc) {
5655  }
5656  };
5657 
5658  bool isNonTypeNestedNameSpecifier(Scope *S, CXXScopeSpec &SS,
5659  NestedNameSpecInfo &IdInfo);
5660 
5661  bool BuildCXXNestedNameSpecifier(Scope *S,
5662  NestedNameSpecInfo &IdInfo,
5663  bool EnteringContext,
5664  CXXScopeSpec &SS,
5665  NamedDecl *ScopeLookupResult,
5666  bool ErrorRecoveryLookup,
5667  bool *IsCorrectedToColon = nullptr,
5668  bool OnlyNamespace = false);
5669 
5670  /// The parser has parsed a nested-name-specifier 'identifier::'.
5671  ///
5672  /// \param S The scope in which this nested-name-specifier occurs.
5673  ///
5674  /// \param IdInfo Parser information about an identifier in the
5675  /// nested-name-spec.
5676  ///
5677  /// \param EnteringContext Whether we're entering the context nominated by
5678  /// this nested-name-specifier.
5679  ///
5680  /// \param SS The nested-name-specifier, which is both an input
5681  /// parameter (the nested-name-specifier before this type) and an
5682  /// output parameter (containing the full nested-name-specifier,
5683  /// including this new type).
5684  ///
5685  /// \param ErrorRecoveryLookup If true, then this method is called to improve
5686  /// error recovery. In this case do not emit error message.
5687  ///
5688  /// \param IsCorrectedToColon If not null, suggestions to replace '::' -> ':'
5689  /// are allowed. The bool value pointed by this parameter is set to 'true'
5690  /// if the identifier is treated as if it was followed by ':', not '::'.
5691  ///
5692  /// \param OnlyNamespace If true, only considers namespaces in lookup.
5693  ///
5694  /// \returns true if an error occurred, false otherwise.
5695  bool ActOnCXXNestedNameSpecifier(Scope *S,
5696  NestedNameSpecInfo &IdInfo,
5697  bool EnteringContext,
5698  CXXScopeSpec &SS,
5699  bool ErrorRecoveryLookup = false,
5700  bool *IsCorrectedToColon = nullptr,
5701  bool OnlyNamespace = false);
5702 
5703  ExprResult ActOnDecltypeExpression(Expr *E);
5704 
5705  bool ActOnCXXNestedNameSpecifierDecltype(CXXScopeSpec &SS,
5706  const DeclSpec &DS,
5707  SourceLocation ColonColonLoc);
5708 
5709  bool IsInvalidUnlessNestedName(Scope *S, CXXScopeSpec &SS,
5710  NestedNameSpecInfo &IdInfo,
5711  bool EnteringContext);
5712 
5713  /// The parser has parsed a nested-name-specifier
5714  /// 'template[opt] template-name < template-args >::'.
5715  ///
5716  /// \param S The scope in which this nested-name-specifier occurs.
5717  ///
5718  /// \param SS The nested-name-specifier, which is both an input
5719  /// parameter (the nested-name-specifier before this type) and an
5720  /// output parameter (containing the full nested-name-specifier,
5721  /// including this new type).
5722  ///
5723  /// \param TemplateKWLoc the location of the 'template' keyword, if any.
5724  /// \param TemplateName the template name.
5725  /// \param TemplateNameLoc The location of the template name.
5726  /// \param LAngleLoc The location of the opening angle bracket ('<').
5727  /// \param TemplateArgs The template arguments.
5728  /// \param RAngleLoc The location of the closing angle bracket ('>').
5729  /// \param CCLoc The location of the '::'.
5730  ///
5731  /// \param EnteringContext Whether we're entering the context of the
5732  /// nested-name-specifier.
5733  ///
5734  ///
5735  /// \returns true if an error occurred, false otherwise.
5736  bool ActOnCXXNestedNameSpecifier(Scope *S,
5737  CXXScopeSpec &SS,
5738  SourceLocation TemplateKWLoc,
5739  TemplateTy TemplateName,
5740  SourceLocation TemplateNameLoc,
5741  SourceLocation LAngleLoc,
5742  ASTTemplateArgsPtr TemplateArgs,
5743  SourceLocation RAngleLoc,
5744  SourceLocation CCLoc,
5745  bool EnteringContext);
5746 
5747  /// Given a C++ nested-name-specifier, produce an annotation value
5748  /// that the parser can use later to reconstruct the given
5749  /// nested-name-specifier.
5750  ///
5751  /// \param SS A nested-name-specifier.
5752  ///
5753  /// \returns A pointer containing all of the information in the
5754  /// nested-name-specifier \p SS.
5755  void *SaveNestedNameSpecifierAnnotation(CXXScopeSpec &SS);
5756 
5757  /// Given an annotation pointer for a nested-name-specifier, restore
5758  /// the nested-name-specifier structure.
5759  ///
5760  /// \param Annotation The annotation pointer, produced by
5761  /// \c SaveNestedNameSpecifierAnnotation().
5762  ///
5763  /// \param AnnotationRange The source range corresponding to the annotation.
5764  ///
5765  /// \param SS The nested-name-specifier that will be updated with the contents
5766  /// of the annotation pointer.
5767  void RestoreNestedNameSpecifierAnnotation(void *Annotation,
5768  SourceRange AnnotationRange,
5769  CXXScopeSpec &SS);
5770 
5771  bool ShouldEnterDeclaratorScope(Scope *S, const CXXScopeSpec &SS);
5772 
5773  /// ActOnCXXEnterDeclaratorScope - Called when a C++ scope specifier (global
5774  /// scope or nested-name-specifier) is parsed, part of a declarator-id.
5775  /// After this method is called, according to [C++ 3.4.3p3], names should be
5776  /// looked up in the declarator-id's scope, until the declarator is parsed and
5777  /// ActOnCXXExitDeclaratorScope is called.
5778  /// The 'SS' should be a non-empty valid CXXScopeSpec.
5779  bool ActOnCXXEnterDeclaratorScope(Scope *S, CXXScopeSpec &SS);
5780 
5781  /// ActOnCXXExitDeclaratorScope - Called when a declarator that previously
5782  /// invoked ActOnCXXEnterDeclaratorScope(), is finished. 'SS' is the same
5783  /// CXXScopeSpec that was passed to ActOnCXXEnterDeclaratorScope as well.
5784  /// Used to indicate that names should revert to being looked up in the
5785  /// defining scope.
5786  void ActOnCXXExitDeclaratorScope(Scope *S, const CXXScopeSpec &SS);
5787 
5788  /// ActOnCXXEnterDeclInitializer - Invoked when we are about to parse an
5789  /// initializer for the declaration 'Dcl'.
5790  /// After this method is called, according to [C++ 3.4.1p13], if 'Dcl' is a
5791  /// static data member of class X, names should be looked up in the scope of
5792  /// class X.
5793  void ActOnCXXEnterDeclInitializer(Scope *S, Decl *Dcl);
5794 
5795  /// ActOnCXXExitDeclInitializer - Invoked after we are finished parsing an
5796  /// initializer for the declaration 'Dcl'.
5797  void ActOnCXXExitDeclInitializer(Scope *S, Decl *Dcl);
5798 
5799  /// Create a new lambda closure type.
5800  CXXRecordDecl *createLambdaClosureType(SourceRange IntroducerRange,
5801  TypeSourceInfo *Info,
5802  bool KnownDependent,
5803  LambdaCaptureDefault CaptureDefault);
5804 
5805  /// Start the definition of a lambda expression.
5806  CXXMethodDecl *
5807  startLambdaDefinition(CXXRecordDecl *Class, SourceRange IntroducerRange,
5808  TypeSourceInfo *MethodType, SourceLocation EndLoc,
5809  ArrayRef<ParmVarDecl *> Params,
5810  ConstexprSpecKind ConstexprKind,
5811  Optional<std::pair<unsigned, Decl *>> Mangling = None);
5812 
5813  /// Endow the lambda scope info with the relevant properties.
5814  void buildLambdaScope(sema::LambdaScopeInfo *LSI,
5815  CXXMethodDecl *CallOperator,
5816  SourceRange IntroducerRange,
5817  LambdaCaptureDefault CaptureDefault,
5818  SourceLocation CaptureDefaultLoc,
5819  bool ExplicitParams,
5820  bool ExplicitResultType,
5821  bool Mutable);
5822 
5823  /// Perform initialization analysis of the init-capture and perform
5824  /// any implicit conversions such as an lvalue-to-rvalue conversion if
5825  /// not being used to initialize a reference.
5827  SourceLocation Loc, bool ByRef, SourceLocation EllipsisLoc,
5828  IdentifierInfo *Id, LambdaCaptureInitKind InitKind, Expr *&Init) {
5829  return ParsedType::make(buildLambdaInitCaptureInitialization(
5830  Loc, ByRef, EllipsisLoc, None, Id,
5831  InitKind != LambdaCaptureInitKind::CopyInit, Init));
5832  }
5833  QualType buildLambdaInitCaptureInitialization(
5834  SourceLocation Loc, bool ByRef, SourceLocation EllipsisLoc,
5835  Optional<unsigned> NumExpansions, IdentifierInfo *Id, bool DirectInit,
5836  Expr *&Init);
5837 
5838  /// Create a dummy variable within the declcontext of the lambda's
5839  /// call operator, for name lookup purposes for a lambda init capture.
5840  ///
5841  /// CodeGen handles emission of lambda captures, ignoring these dummy
5842  /// variables appropriately.
5843  VarDecl *createLambdaInitCaptureVarDecl(SourceLocation Loc,
5844  QualType InitCaptureType,
5845  SourceLocation EllipsisLoc,
5846  IdentifierInfo *Id,
5847  unsigned InitStyle, Expr *Init);
5848 
5849  /// Add an init-capture to a lambda scope.
5850  void addInitCapture(sema::LambdaScopeInfo *LSI, VarDecl *Var);
5851 
5852  /// Note that we have finished the explicit captures for the
5853  /// given lambda.
5854  void finishLambdaExplicitCaptures(sema::LambdaScopeInfo *LSI);
5855 
5856  /// \brief This is called after parsing the explicit template parameter list
5857  /// on a lambda (if it exists) in C++2a.
5858  void ActOnLambdaExplicitTemplateParameterList(SourceLocation LAngleLoc,
5859  ArrayRef<NamedDecl *> TParams,
5860  SourceLocation RAngleLoc);
5861 
5862  /// Introduce the lambda parameters into scope.
5863  void addLambdaParameters(
5865  CXXMethodDecl *CallOperator, Scope *CurScope);
5866 
5867  /// Deduce a block or lambda's return type based on the return
5868  /// statements present in the body.
5869  void deduceClosureReturnType(sema::CapturingScopeInfo &CSI);
5870 
5871  /// ActOnStartOfLambdaDefinition - This is called just before we start
5872  /// parsing the body of a lambda; it analyzes the explicit captures and
5873  /// arguments, and sets up various data-structures for the body of the
5874  /// lambda.
5875  void ActOnStartOfLambdaDefinition(LambdaIntroducer &Intro,
5876  Declarator &ParamInfo, Scope *CurScope);
5877 
5878  /// ActOnLambdaError - If there is an error parsing a lambda, this callback
5879  /// is invoked to pop the information about the lambda.
5880  void ActOnLambdaError(SourceLocation StartLoc, Scope *CurScope,
5881  bool IsInstantiation = false);
5882 
5883  /// ActOnLambdaExpr - This is called when the body of a lambda expression
5884  /// was successfully completed.
5885  ExprResult ActOnLambdaExpr(SourceLocation StartLoc, Stmt *Body,
5886  Scope *CurScope);
5887 
5888  /// Does copying/destroying the captured variable have side effects?
5889  bool CaptureHasSideEffects(const sema::Capture &From);
5890 
5891  /// Diagnose if an explicit lambda capture is unused. Returns true if a
5892  /// diagnostic is emitted.
5893  bool DiagnoseUnusedLambdaCapture(SourceRange CaptureRange,
5894  const sema::Capture &From);
5895 
5896  /// Build a FieldDecl suitable to hold the given capture.
5897  FieldDecl *BuildCaptureField(RecordDecl *RD, const sema::Capture &Capture);
5898 
5899  /// Initialize the given capture with a suitable expression.
5900  ExprResult BuildCaptureInit(const sema::Capture &Capture,
5901  SourceLocation ImplicitCaptureLoc,
5902  bool IsOpenMPMapping = false);
5903 
5904  /// Complete a lambda-expression having processed and attached the
5905  /// lambda body.
5906  ExprResult BuildLambdaExpr(SourceLocation StartLoc, SourceLocation EndLoc,
5907  sema::LambdaScopeInfo *LSI);
5908 
5909  /// Get the return type to use for a lambda's conversion function(s) to
5910  /// function pointer type, given the type of the call operator.
5911  QualType
5912  getLambdaConversionFunctionResultType(const FunctionProtoType *CallOpType);
5913 
5914  /// Define the "body" of the conversion from a lambda object to a
5915  /// function pointer.
5916  ///
5917  /// This routine doesn't actually define a sensible body; rather, it fills
5918  /// in the initialization expression needed to copy the lambda object into
5919  /// the block, and IR generation actually generates the real body of the
5920  /// block pointer conversion.
5921  void DefineImplicitLambdaToFunctionPointerConversion(
5922  SourceLocation CurrentLoc, CXXConversionDecl *Conv);
5923 
5924  /// Define the "body" of the conversion from a lambda object to a
5925  /// block pointer.
5926  ///
5927  /// This routine doesn't actually define a sensible body; rather, it fills
5928  /// in the initialization expression needed to copy the lambda object into
5929  /// the block, and IR generation actually generates the real body of the
5930  /// block pointer conversion.
5931  void DefineImplicitLambdaToBlockPointerConversion(SourceLocation CurrentLoc,
5932  CXXConversionDecl *Conv);
5933 
5934  ExprResult BuildBlockForLambdaConversion(SourceLocation CurrentLocation,
5935  SourceLocation ConvLocation,
5936  CXXConversionDecl *Conv,
5937  Expr *Src);
5938 
5939  // ParseObjCStringLiteral - Parse Objective-C string literals.
5940  ExprResult ParseObjCStringLiteral(SourceLocation *AtLocs,
5941  ArrayRef<Expr *> Strings);
5942 
5943  ExprResult BuildObjCStringLiteral(SourceLocation AtLoc, StringLiteral *S);
5944 
5945  /// BuildObjCNumericLiteral - builds an ObjCBoxedExpr AST node for the
5946  /// numeric literal expression. Type of the expression will be "NSNumber *"
5947  /// or "id" if NSNumber is unavailable.
5948  ExprResult BuildObjCNumericLiteral(SourceLocation AtLoc, Expr *Number);
5949  ExprResult ActOnObjCBoolLiteral(SourceLocation AtLoc, SourceLocation ValueLoc,
5950  bool Value);
5951  ExprResult BuildObjCArrayLiteral(SourceRange SR, MultiExprArg Elements);
5952 
5953  /// BuildObjCBoxedExpr - builds an ObjCBoxedExpr AST node for the
5954  /// '@' prefixed parenthesized expression. The type of the expression will
5955  /// either be "NSNumber *", "NSString *" or "NSValue *" depending on the type
5956  /// of ValueType, which is allowed to be a built-in numeric type, "char *",
5957  /// "const char *" or C structure with attribute 'objc_boxable'.
5958  ExprResult BuildObjCBoxedExpr(SourceRange SR, Expr *ValueExpr);
5959 
5960  ExprResult BuildObjCSubscriptExpression(SourceLocation RB, Expr *BaseExpr,
5961  Expr *IndexExpr,
5962  ObjCMethodDecl *getterMethod,
5963  ObjCMethodDecl *setterMethod);
5964 
5965  ExprResult BuildObjCDictionaryLiteral(SourceRange SR,
5967 
5968  ExprResult BuildObjCEncodeExpression(SourceLocation AtLoc,
5969  TypeSourceInfo *EncodedTypeInfo,
5970  SourceLocation RParenLoc);
5971  ExprResult BuildCXXMemberCallExpr(Expr *Exp, NamedDecl *FoundDecl,
5972  CXXConversionDecl *Method,
5973  bool HadMultipleCandidates);
5974 
5975  ExprResult ParseObjCEncodeExpression(SourceLocation AtLoc,
5976  SourceLocation EncodeLoc,
5977  SourceLocation LParenLoc,
5978  ParsedType Ty,
5979  SourceLocation RParenLoc);
5980 
5981  /// ParseObjCSelectorExpression - Build selector expression for \@selector
5982  ExprResult ParseObjCSelectorExpression(Selector Sel,
5983  SourceLocation AtLoc,
5984  SourceLocation SelLoc,
5985  SourceLocation LParenLoc,
5986  SourceLocation RParenLoc,
5987  bool WarnMultipleSelectors);
5988 
5989  /// ParseObjCProtocolExpression - Build protocol expression for \@protocol
5990  ExprResult ParseObjCProtocolExpression(IdentifierInfo * ProtocolName,
5991  SourceLocation AtLoc,
5992  SourceLocation ProtoLoc,
5993  SourceLocation LParenLoc,
5994  SourceLocation ProtoIdLoc,
5995  SourceLocation RParenLoc);
5996 
5997  //===--------------------------------------------------------------------===//
5998  // C++ Declarations
5999  //
6000  Decl *ActOnStartLinkageSpecification(Scope *S,
6001  SourceLocation ExternLoc,
6002  Expr *LangStr,
6003  SourceLocation LBraceLoc);
6004  Decl *ActOnFinishLinkageSpecification(Scope *S,
6005  Decl *LinkageSpec,
6006  SourceLocation RBraceLoc);
6007 
6008 
6009  //===--------------------------------------------------------------------===//
6010  // C++ Classes
6011  //
6012  CXXRecordDecl *getCurrentClass(Scope *S, const CXXScopeSpec *SS);
6013  bool isCurrentClassName(const IdentifierInfo &II, Scope *S,
6014  const CXXScopeSpec *SS = nullptr);
6015  bool isCurrentClassNameTypo(IdentifierInfo *&II, const CXXScopeSpec *SS);
6016 
6017  bool ActOnAccessSpecifier(AccessSpecifier Access, SourceLocation ASLoc,
6018  SourceLocation ColonLoc,
6019  const ParsedAttributesView &Attrs);
6020 
6021  NamedDecl *ActOnCXXMemberDeclarator(Scope *S, AccessSpecifier AS,
6022  Declarator &D,
6023  MultiTemplateParamsArg TemplateParameterLists,
6024  Expr *BitfieldWidth, const VirtSpecifiers &VS,
6025  InClassInitStyle InitStyle);
6026 
6027  void ActOnStartCXXInClassMemberInitializer();
6028  void ActOnFinishCXXInClassMemberInitializer(Decl *VarDecl,
6029  SourceLocation EqualLoc,
6030  Expr *Init);
6031 
6032  MemInitResult ActOnMemInitializer(Decl *ConstructorD,
6033  Scope *S,
6034  CXXScopeSpec &SS,
6035  IdentifierInfo *MemberOrBase,
6036  ParsedType TemplateTypeTy,
6037  const DeclSpec &DS,
6038  SourceLocation IdLoc,
6039  SourceLocation LParenLoc,
6040  ArrayRef<Expr *> Args,
6041  SourceLocation RParenLoc,
6042  SourceLocation EllipsisLoc);
6043 
6044  MemInitResult ActOnMemInitializer(Decl *ConstructorD,
6045  Scope *S,
6046  CXXScopeSpec &SS,
6047  IdentifierInfo *MemberOrBase,
6048  ParsedType TemplateTypeTy,
6049  const DeclSpec &DS,
6050  SourceLocation IdLoc,
6051  Expr *InitList,
6052  SourceLocation EllipsisLoc);
6053 
6054  MemInitResult BuildMemInitializer(Decl *ConstructorD,
6055  Scope *S,
6056  CXXScopeSpec &SS,
6057  IdentifierInfo *MemberOrBase,
6058  ParsedType TemplateTypeTy,
6059  const DeclSpec &DS,
6060  SourceLocation IdLoc,
6061  Expr *Init,
6062  SourceLocation EllipsisLoc);
6063 
6064  MemInitResult BuildMemberInitializer(ValueDecl *Member,
6065  Expr *Init,
6066  SourceLocation IdLoc);
6067 
6068  MemInitResult BuildBaseInitializer(QualType BaseType,
6069  TypeSourceInfo *BaseTInfo,
6070  Expr *Init,
6071  CXXRecordDecl *ClassDecl,
6072  SourceLocation EllipsisLoc);
6073 
6074  MemInitResult BuildDelegatingInitializer(TypeSourceInfo *TInfo,
6075  Expr *Init,
6076  CXXRecordDecl *ClassDecl);
6077 
6078  bool SetDelegatingInitializer(CXXConstructorDecl *Constructor,
6079  CXXCtorInitializer *Initializer);
6080 
6081  bool SetCtorInitializers(CXXConstructorDecl *Constructor, bool AnyErrors,
6082  ArrayRef<CXXCtorInitializer *> Initializers = None);
6083 
6084  void SetIvarInitializers(ObjCImplementationDecl *ObjCImplementation);
6085 
6086 
6087  /// MarkBaseAndMemberDestructorsReferenced - Given a record decl,
6088  /// mark all the non-trivial destructors of its members and bases as
6089  /// referenced.
6090  void MarkBaseAndMemberDestructorsReferenced(SourceLocation Loc,
6091  CXXRecordDecl *Record);
6092 
6093  /// The list of classes whose vtables have been used within
6094  /// this translation unit, and the source locations at which the
6095  /// first use occurred.
6096  typedef std::pair<CXXRecordDecl*, SourceLocation> VTableUse;
6097 
6098  /// The list of vtables that are required but have not yet been
6099  /// materialized.
6101 
6102  /// The set of classes whose vtables have been used within
6103  /// this translation unit, and a bit that will be true if the vtable is
6104  /// required to be emitted (otherwise, it should be emitted only if needed
6105  /// by code generation).
6106  llvm::DenseMap<CXXRecordDecl *, bool> VTablesUsed;
6107 
6108  /// Load any externally-stored vtable uses.
6109  void LoadExternalVTableUses();
6110 
6111  /// Note that the vtable for the given class was used at the
6112  /// given location.
6113  void MarkVTableUsed(SourceLocation Loc, CXXRecordDecl *Class,
6114  bool DefinitionRequired = false);
6115 
6116  /// Mark the exception specifications of all virtual member functions
6117  /// in the given class as needed.
6118  void MarkVirtualMemberExceptionSpecsNeeded(SourceLocation Loc,
6119  const CXXRecordDecl *RD);
6120 
6121  /// MarkVirtualMembersReferenced - Will mark all members of the given
6122  /// CXXRecordDecl referenced.
6123  void MarkVirtualMembersReferenced(SourceLocation Loc, const CXXRecordDecl *RD,
6124  bool ConstexprOnly = false);
6125 
6126  /// Define all of the vtables that have been used in this
6127  /// translation unit and reference any virtual members used by those
6128  /// vtables.
6129  ///
6130  /// \returns true if any work was done, false otherwise.
6131  bool DefineUsedVTables();
6132 
6133  void AddImplicitlyDeclaredMembersToClass(CXXRecordDecl *ClassDecl);
6134 
6135  void ActOnMemInitializers(Decl *ConstructorDecl,
6136  SourceLocation ColonLoc,
6138  bool AnyErrors);
6139 
6140  /// Check class-level dllimport/dllexport attribute. The caller must
6141  /// ensure that referenceDLLExportedClassMethods is called some point later
6142  /// when all outer classes of Class are complete.
6143  void checkClassLevelDLLAttribute(CXXRecordDecl *Class);
6144  void checkClassLevelCodeSegAttribute(CXXRecordDecl *Class);
6145 
6146  void referenceDLLExportedClassMethods();
6147 
6148  void propagateDLLAttrToBaseClassTemplate(
6149  CXXRecordDecl *Class, Attr *ClassAttr,
6150  ClassTemplateSpecializationDecl *BaseTemplateSpec,
6151  SourceLocation BaseLoc);
6152 
6153  void CheckCompletedCXXClass(CXXRecordDecl *Record);
6154 
6155  /// Check that the C++ class annoated with "trivial_abi" satisfies all the
6156  /// conditions that are needed for the attribute to have an effect.
6157  void checkIllFormedTrivialABIStruct(CXXRecordDecl &RD);
6158 
6159  void ActOnFinishCXXMemberSpecification(Scope *S, SourceLocation RLoc,
6160  Decl *TagDecl, SourceLocation LBrac,
6161  SourceLocation RBrac,
6162  const ParsedAttributesView &AttrList);
6163  void ActOnFinishCXXMemberDecls();
6164  void ActOnFinishCXXNonNestedClass(Decl *D);
6165 
6166  void ActOnReenterCXXMethodParameter(Scope *S, ParmVarDecl *Param);
6167  unsigned ActOnReenterTemplateScope(Scope *S, Decl *Template);
6168  void ActOnStartDelayedMemberDeclarations(Scope *S, Decl *Record);
6169  void ActOnStartDelayedCXXMethodDeclaration(Scope *S, Decl *Method);
6170  void ActOnDelayedCXXMethodParameter(Scope *S, Decl *Param);
6171  void ActOnFinishDelayedMemberDeclarations(Scope *S, Decl *Record);
6172  void ActOnFinishDelayedCXXMethodDeclaration(Scope *S, Decl *Method);
6173  void ActOnFinishDelayedMemberInitializers(Decl *Record);
6174  void MarkAsLateParsedTemplate(FunctionDecl *FD, Decl *FnD,
6175  CachedTokens &Toks);
6176  void UnmarkAsLateParsedTemplate(FunctionDecl *FD);
6177  bool IsInsideALocalClassWithinATemplateFunction();
6178 
6179  Decl *ActOnStaticAssertDeclaration(SourceLocation StaticAssertLoc,
6180  Expr *AssertExpr,
6181  Expr *AssertMessageExpr,
6182  SourceLocation RParenLoc);
6183  Decl *BuildStaticAssertDeclaration(SourceLocation StaticAssertLoc,
6184  Expr *AssertExpr,
6185  StringLiteral *AssertMessageExpr,
6186  SourceLocation RParenLoc,
6187  bool Failed);
6188 
6189  FriendDecl *CheckFriendTypeDecl(SourceLocation LocStart,
6190  SourceLocation FriendLoc,
6191  TypeSourceInfo *TSInfo);
6192  Decl *ActOnFriendTypeDecl(Scope *S, const DeclSpec &DS,
6193  MultiTemplateParamsArg TemplateParams);
6194  NamedDecl *ActOnFriendFunctionDecl(Scope *S, Declarator &D,
6195  MultiTemplateParamsArg TemplateParams);
6196 
6197  QualType CheckConstructorDeclarator(Declarator &D, QualType R,
6198  StorageClass& SC);
6199  void CheckConstructor(CXXConstructorDecl *Constructor);
6200  QualType CheckDestructorDeclarator(Declarator &D, QualType R,
6201  StorageClass& SC);
6202  bool CheckDestructor(CXXDestructorDecl *Destructor);
6203  void CheckConversionDeclarator(Declarator &D, QualType &R,
6204  StorageClass& SC);
6205  Decl *ActOnConversionDeclarator(CXXConversionDecl *Conversion);
6206  void CheckDeductionGuideDeclarator(Declarator &D, QualType &R,
6207  StorageClass &SC);
6208  void CheckDeductionGuideTemplate(FunctionTemplateDecl *TD);
6209 
6210  void CheckExplicitlyDefaultedSpecialMember(CXXMethodDecl *MD);
6211  void CheckDelayedMemberExceptionSpecs();
6212 
6213  //===--------------------------------------------------------------------===//
6214  // C++ Derived Classes
6215  //
6216 
6217  /// ActOnBaseSpecifier - Parsed a base specifier
6218  CXXBaseSpecifier *CheckBaseSpecifier(CXXRecordDecl *Class,
6219  SourceRange SpecifierRange,
6220  bool Virtual, AccessSpecifier Access,
6221  TypeSourceInfo *TInfo,
6222  SourceLocation EllipsisLoc);
6223 
6224  BaseResult ActOnBaseSpecifier(Decl *classdecl,
6225  SourceRange SpecifierRange,
6226  ParsedAttributes &Attrs,
6227  bool Virtual, AccessSpecifier Access,
6228  ParsedType basetype,
6229  SourceLocation BaseLoc,
6230  SourceLocation EllipsisLoc);
6231 
6232  bool AttachBaseSpecifiers(CXXRecordDecl *Class,
6234  void ActOnBaseSpecifiers(Decl *ClassDecl,
6236 
6237  bool IsDerivedFrom(SourceLocation Loc, QualType Derived, QualType Base);
6238  bool IsDerivedFrom(SourceLocation Loc, QualType Derived, QualType Base,
6239  CXXBasePaths &Paths);
6240 
6241  // FIXME: I don't like this name.
6242  void BuildBasePathArray(const CXXBasePaths &Paths, CXXCastPath &BasePath);
6243 
6244  bool CheckDerivedToBaseConversion(QualType Derived, QualType Base,
6245  SourceLocation Loc, SourceRange Range,
6246  CXXCastPath *BasePath = nullptr,
6247  bool IgnoreAccess = false);
6248  bool CheckDerivedToBaseConversion(QualType Derived, QualType Base,
6249  unsigned InaccessibleBaseID,
6250  unsigned AmbigiousBaseConvID,
6251  SourceLocation Loc, SourceRange Range,
6252  DeclarationName Name,
6253  CXXCastPath *BasePath,
6254  bool IgnoreAccess = false);
6255 
6256  std::string getAmbiguousPathsDisplayString(CXXBasePaths &Paths);
6257 
6258  bool CheckOverridingFunctionAttributes(const CXXMethodDecl *New,
6259  const CXXMethodDecl *Old);
6260 
6261  /// CheckOverridingFunctionReturnType - Checks whether the return types are
6262  /// covariant, according to C++ [class.virtual]p5.
6263  bool CheckOverridingFunctionReturnType(const CXXMethodDecl *New,
6264  const CXXMethodDecl *Old);
6265 
6266  /// CheckOverridingFunctionExceptionSpec - Checks whether the exception
6267  /// spec is a subset of base spec.
6268  bool CheckOverridingFunctionExceptionSpec(const CXXMethodDecl *New,
6269  const CXXMethodDecl *Old);
6270 
6271  bool CheckPureMethod(CXXMethodDecl *Method, SourceRange InitRange);
6272 
6273  /// CheckOverrideControl - Check C++11 override control semantics.
6274  void CheckOverrideControl(NamedDecl *D);
6275 
6276  /// DiagnoseAbsenceOfOverrideControl - Diagnose if 'override' keyword was
6277  /// not used in the declaration of an overriding method.
6278  void DiagnoseAbsenceOfOverrideControl(NamedDecl *D);
6279 
6280  /// CheckForFunctionMarkedFinal - Checks whether a virtual member function
6281  /// overrides a virtual member function marked 'final', according to
6282  /// C++11 [class.virtual]p4.
6283  bool CheckIfOverriddenFunctionIsMarkedFinal(const CXXMethodDecl *New,
6284  const CXXMethodDecl *Old);
6285 
6286 
6287  //===--------------------------------------------------------------------===//
6288  // C++ Access Control
6289  //
6290 
6295  AR_delayed
6296  };
6297 
6298  bool SetMemberAccessSpecifier(NamedDecl *MemberDecl,
6299  NamedDecl *PrevMemberDecl,
6300  AccessSpecifier LexicalAS);
6301 
6302  AccessResult CheckUnresolvedMemberAccess(UnresolvedMemberExpr *E,
6303  DeclAccessPair FoundDecl);
6304  AccessResult CheckUnresolvedLookupAccess(UnresolvedLookupExpr *E,
6305  DeclAccessPair FoundDecl);
6306  AccessResult CheckAllocationAccess(SourceLocation OperatorLoc,
6307  SourceRange PlacementRange,
6308  CXXRecordDecl *NamingClass,
6309  DeclAccessPair FoundDecl,
6310  bool Diagnose = true);
6311  AccessResult CheckConstructorAccess(SourceLocation Loc,
6312  CXXConstructorDecl *D,
6313  DeclAccessPair FoundDecl,
6314  const InitializedEntity &Entity,
6315  bool IsCopyBindingRefToTemp = false);
6316  AccessResult CheckConstructorAccess(SourceLocation Loc,
6317  CXXConstructorDecl *D,
6318  DeclAccessPair FoundDecl,
6319  const InitializedEntity &Entity,
6320  const PartialDiagnostic &PDiag);
6321  AccessResult CheckDestructorAccess(SourceLocation Loc,
6322  CXXDestructorDecl *Dtor,
6323  const PartialDiagnostic &PDiag,
6324  QualType objectType = QualType());
6325  AccessResult CheckFriendAccess(NamedDecl *D);
6326  AccessResult CheckMemberAccess(SourceLocation UseLoc,
6327  CXXRecordDecl *NamingClass,
6328  DeclAccessPair Found);
6329  AccessResult
6330  CheckStructuredBindingMemberAccess(SourceLocation UseLoc,
6331  CXXRecordDecl *DecomposedClass,
6332  DeclAccessPair Field);
6333  AccessResult CheckMemberOperatorAccess(SourceLocation Loc,
6334  Expr *ObjectExpr,
6335  Expr *ArgExpr,
6336  DeclAccessPair FoundDecl);
6337  AccessResult CheckAddressOfMemberAccess(Expr *OvlExpr,
6338  DeclAccessPair FoundDecl);
6339  AccessResult CheckBaseClassAccess(SourceLocation AccessLoc,
6340  QualType Base, QualType Derived,
6341  const CXXBasePath &Path,
6342  unsigned DiagID,
6343  bool ForceCheck = false,
6344  bool ForceUnprivileged = false);
6345  void CheckLookupAccess(const LookupResult &R);
6346  bool IsSimplyAccessible(NamedDecl *Decl, CXXRecordDecl *NamingClass,
6347  QualType BaseType);
6348  bool isSpecialMemberAccessibleForDeletion(CXXMethodDecl *decl,
6349  AccessSpecifier access,
6350  QualType objectType);
6351 
6352  void HandleDependentAccessCheck(const DependentDiagnostic &DD,
6353  const MultiLevelTemplateArgumentList &TemplateArgs);
6354  void PerformDependentDiagnostics(const DeclContext *Pattern,
6355  const MultiLevelTemplateArgumentList &TemplateArgs);
6356 
6357  void HandleDelayedAccessCheck(sema::DelayedDiagnostic &DD, Decl *Ctx);
6358 
6359  /// When true, access checking violations are treated as SFINAE
6360  /// failures rather than hard errors.
6362 
6364  AbstractNone = -1,
6371  AbstractArrayType
6372  };
6373 
6374  bool isAbstractType(SourceLocation Loc, QualType T);
6375  bool RequireNonAbstractType(SourceLocation Loc, QualType T,
6376  TypeDiagnoser &Diagnoser);
6377  template <typename... Ts>
6378  bool RequireNonAbstractType(SourceLocation Loc, QualType T, unsigned DiagID,
6379  const Ts &...Args) {
6380  BoundTypeDiagnoser<Ts...> Diagnoser(DiagID, Args...);
6381  return RequireNonAbstractType(Loc, T, Diagnoser);
6382  }
6383 
6384  void DiagnoseAbstractType(const CXXRecordDecl *RD);
6385 
6386  //===--------------------------------------------------------------------===//
6387  // C++ Overloaded Operators [C++ 13.5]
6388  //
6389 
6390  bool CheckOverloadedOperatorDeclaration(FunctionDecl *FnDecl);
6391 
6392  bool CheckLiteralOperatorDeclaration(FunctionDecl *FnDecl);
6393 
6394  //===--------------------------------------------------------------------===//
6395  // C++ Templates [C++ 14]
6396  //
6397  void FilterAcceptableTemplateNames(LookupResult &R,
6398  bool AllowFunctionTemplates = true,
6399  bool AllowDependent = true);
6400  bool hasAnyAcceptableTemplateNames(LookupResult &R,
6401  bool AllowFunctionTemplates = true,
6402  bool AllowDependent = true,
6403  bool AllowNonTemplateFunctions = false);
6404  /// Try to interpret the lookup result D as a template-name.
6405  ///
6406  /// \param D A declaration found by name lookup.
6407  /// \param AllowFunctionTemplates Whether function templates should be
6408  /// considered valid results.
6409  /// \param AllowDependent Whether unresolved using declarations (that might
6410  /// name templates) should be considered valid results.
6411  NamedDecl *getAsTemplateNameDecl(NamedDecl *D,
6412  bool AllowFunctionTemplates = true,
6413  bool AllowDependent = true);
6414 
6415  enum class AssumedTemplateKind {
6416  /// This is not assumed to be a template name.
6417  None,
6418  /// This is assumed to be a template name because lookup found nothing.
6419  FoundNothing,
6420  /// This is assumed to be a template name because lookup found one or more
6421  /// functions (but no function templates).
6422  FoundFunctions,
6423  };
6424  bool LookupTemplateName(LookupResult &R, Scope *S, CXXScopeSpec &SS,
6425  QualType ObjectType, bool EnteringContext,
6426  bool &MemberOfUnknownSpecialization,
6427  SourceLocation TemplateKWLoc = SourceLocation(),
6428  AssumedTemplateKind *ATK = nullptr);
6429 
6430  TemplateNameKind isTemplateName(Scope *S,
6431  CXXScopeSpec &SS,
6432  bool hasTemplateKeyword,
6433  const UnqualifiedId &Name,
6434  ParsedType ObjectType,
6435  bool EnteringContext,
6436  TemplateTy &Template,
6437  bool &MemberOfUnknownSpecialization);
6438 
6439  /// Try to resolve an undeclared template name as a type template.
6440  ///
6441  /// Sets II to the identifier corresponding to the template name, and updates
6442  /// Name to a corresponding (typo-corrected) type template name and TNK to
6443  /// the corresponding kind, if possible.
6444  void ActOnUndeclaredTypeTemplateName(Scope *S, TemplateTy &Name,
6445  TemplateNameKind &TNK,
6446  SourceLocation NameLoc,
6447  IdentifierInfo *&II);
6448 
6449  bool resolveAssumedTemplateNameAsType(Scope *S, TemplateName &Name,
6450  SourceLocation NameLoc,
6451  bool Diagnose = true);
6452 
6453  /// Determine whether a particular identifier might be the name in a C++1z
6454  /// deduction-guide declaration.
6455  bool isDeductionGuideName(Scope *S, const IdentifierInfo &Name,
6456  SourceLocation NameLoc,
6457  ParsedTemplateTy *Template = nullptr);
6458 
6459  bool DiagnoseUnknownTemplateName(const IdentifierInfo &II,
6460  SourceLocation IILoc,
6461  Scope *S,
6462  const CXXScopeSpec *SS,
6463  TemplateTy &SuggestedTemplate,
6464  TemplateNameKind &SuggestedKind);
6465 
6466  bool DiagnoseUninstantiableTemplate(SourceLocation PointOfInstantiation,
6467  NamedDecl *Instantiation,
6468  bool InstantiatedFromMember,
6469  const NamedDecl *Pattern,
6470  const NamedDecl *PatternDef,
6472  bool Complain = true);
6473 
6474  void DiagnoseTemplateParameterShadow(SourceLocation Loc, Decl *PrevDecl);
6475  TemplateDecl *AdjustDeclIfTemplate(Decl *&Decl);
6476 
6477  NamedDecl *ActOnTypeParameter(Scope *S, bool Typename,
6478  SourceLocation EllipsisLoc,
6479  SourceLocation KeyLoc,
6480  IdentifierInfo *ParamName,
6481  SourceLocation ParamNameLoc,
6482  unsigned Depth, unsigned Position,
6483  SourceLocation EqualLoc,
6484  ParsedType DefaultArg);
6485 
6486  QualType CheckNonTypeTemplateParameterType(TypeSourceInfo *&TSI,
6487  SourceLocation Loc);
6488  QualType CheckNonTypeTemplateParameterType(QualType T, SourceLocation Loc);
6489 
6490  NamedDecl *ActOnNonTypeTemplateParameter(Scope *S, Declarator &D,
6491  unsigned Depth,
6492  unsigned Position,
6493  SourceLocation EqualLoc,
6494  Expr *DefaultArg);
6495  NamedDecl *ActOnTemplateTemplateParameter(Scope *S,
6496  SourceLocation TmpLoc,
6497  TemplateParameterList *Params,
6498  SourceLocation EllipsisLoc,
6499  IdentifierInfo *ParamName,
6500  SourceLocation ParamNameLoc,
6501  unsigned Depth,
6502  unsigned Position,
6503  SourceLocation EqualLoc,
6504  ParsedTemplateArgument DefaultArg);
6505 
6507  ActOnTemplateParameterList(unsigned Depth,
6508  SourceLocation ExportLoc,
6509  SourceLocation TemplateLoc,
6510  SourceLocation LAngleLoc,
6511  ArrayRef<NamedDecl *> Params,
6512  SourceLocation RAngleLoc,
6513  Expr *RequiresClause);
6514 
6515  /// The context in which we are checking a template parameter list.
6524  TPC_TypeAliasTemplate
6525  };
6526 
6527  bool CheckTemplateParameterList(TemplateParameterList *NewParams,
6528  TemplateParameterList *OldParams,
6530  SkipBodyInfo *SkipBody = nullptr);
6531  TemplateParameterList *MatchTemplateParametersToScopeSpecifier(
6532  SourceLocation DeclStartLoc, SourceLocation DeclLoc,
6533  const CXXScopeSpec &SS, TemplateIdAnnotation *TemplateId,
6535  bool IsFriend, bool &IsMemberSpecialization, bool &Invalid);
6536 
6537  DeclResult CheckClassTemplate(
6538  Scope *S, unsigned TagSpec, TagUseKind TUK, SourceLocation KWLoc,
6539  CXXScopeSpec &SS, IdentifierInfo *Name, SourceLocation NameLoc,
6540  const ParsedAttributesView &Attr, TemplateParameterList *TemplateParams,
6541  AccessSpecifier AS, SourceLocation ModulePrivateLoc,
6542  SourceLocation FriendLoc, unsigned NumOuterTemplateParamLists,
6543  TemplateParameterList **OuterTemplateParamLists,
6544  SkipBodyInfo *SkipBody = nullptr);
6545 
6546  TemplateArgumentLoc getTrivialTemplateArgumentLoc(const TemplateArgument &Arg,
6547  QualType NTTPType,
6548  SourceLocation Loc);
6549 
6550  void translateTemplateArguments(const ASTTemplateArgsPtr &In,
6552 
6553  ParsedTemplateArgument ActOnTemplateTypeArgument(TypeResult ParsedType);
6554 
6555  void NoteAllFoundTemplates(TemplateName Name);
6556 
6557  QualType CheckTemplateIdType(TemplateName Template,
6558  SourceLocation TemplateLoc,
6559  TemplateArgumentListInfo &TemplateArgs);
6560 
6561  TypeResult
6562  ActOnTemplateIdType(Scope *S, CXXScopeSpec &SS, SourceLocation TemplateKWLoc,
6563  TemplateTy Template, IdentifierInfo *TemplateII,
6564  SourceLocation TemplateIILoc, SourceLocation LAngleLoc,
6565  ASTTemplateArgsPtr TemplateArgs, SourceLocation RAngleLoc,
6566  bool IsCtorOrDtorName = false, bool IsClassName = false);
6567 
6568  /// Parsed an elaborated-type-specifier that refers to a template-id,
6569  /// such as \c class T::template apply<U>.
6570  TypeResult ActOnTagTemplateIdType(TagUseKind TUK,
6571  TypeSpecifierType TagSpec,
6572  SourceLocation TagLoc,
6573  CXXScopeSpec &SS,
6574  SourceLocation TemplateKWLoc,
6575  TemplateTy TemplateD,
6576  SourceLocation TemplateLoc,
6577  SourceLocation LAngleLoc,
6578  ASTTemplateArgsPtr TemplateArgsIn,
6579  SourceLocation RAngleLoc);
6580 
6581  DeclResult ActOnVarTemplateSpecialization(
6582  Scope *S, Declarator &D, TypeSourceInfo *DI,
6583  SourceLocation TemplateKWLoc, TemplateParameterList *TemplateParams,
6585 
6586  DeclResult CheckVarTemplateId(VarTemplateDecl *Template,
6587  SourceLocation TemplateLoc,
6588  SourceLocation TemplateNameLoc,
6589  const TemplateArgumentListInfo &TemplateArgs);
6590 
6591  ExprResult CheckVarTemplateId(const CXXScopeSpec &SS,
6592  const DeclarationNameInfo &NameInfo,
6593  VarTemplateDecl *Template,
6594  SourceLocation TemplateLoc,
6595  const TemplateArgumentListInfo *TemplateArgs);
6596 
6597  ExprResult
6598  CheckConceptTemplateId(const CXXScopeSpec &SS,
6599  const DeclarationNameInfo &NameInfo,
6600  ConceptDecl *Template,
6601  SourceLocation TemplateLoc,
6602  const TemplateArgumentListInfo *TemplateArgs);
6603 
6604  void diagnoseMissingTemplateArguments(TemplateName Name, SourceLocation Loc);
6605 
6606  ExprResult BuildTemplateIdExpr(const CXXScopeSpec &SS,
6607  SourceLocation TemplateKWLoc,
6608  LookupResult &R,
6609  bool RequiresADL,
6610  const TemplateArgumentListInfo *TemplateArgs);
6611 
6612  ExprResult BuildQualifiedTemplateIdExpr(CXXScopeSpec &SS,
6613  SourceLocation TemplateKWLoc,
6614  const DeclarationNameInfo &NameInfo,
6615  const TemplateArgumentListInfo *TemplateArgs);
6616 
6617  TemplateNameKind ActOnDependentTemplateName(
6618  Scope *S, CXXScopeSpec &SS, SourceLocation TemplateKWLoc,
6619  const UnqualifiedId &Name, ParsedType ObjectType, bool EnteringContext,
6620  TemplateTy &Template, bool AllowInjectedClassName = false);
6621 
6622  DeclResult ActOnClassTemplateSpecialization(
6623  Scope *S, unsigned TagSpec, TagUseKind TUK, SourceLocation KWLoc,
6624  SourceLocation ModulePrivateLoc, TemplateIdAnnotation &TemplateId,
6625  const ParsedAttributesView &Attr,
6626  MultiTemplateParamsArg TemplateParameterLists,
6627  SkipBodyInfo *SkipBody = nullptr);
6628 
6629  bool CheckTemplatePartialSpecializationArgs(SourceLocation Loc,
6630  TemplateDecl *PrimaryTemplate,
6631  unsigned NumExplicitArgs,
6633  void CheckTemplatePartialSpecialization(
6635  void CheckTemplatePartialSpecialization(
6637 
6638  Decl *ActOnTemplateDeclarator(Scope *S,
6639  MultiTemplateParamsArg TemplateParameterLists,
6640  Declarator &D);
6641 
6642  bool
6643  CheckSpecializationInstantiationRedecl(SourceLocation NewLoc,
6645  NamedDecl *PrevDecl,
6647  SourceLocation PrevPtOfInstantiation,
6648  bool &SuppressNew);
6649 
6650  bool CheckDependentFunctionTemplateSpecialization(FunctionDecl *FD,
6651  const TemplateArgumentListInfo &ExplicitTemplateArgs,
6652  LookupResult &Previous);
6653 
6654  bool CheckFunctionTemplateSpecialization(
6655  FunctionDecl *FD, TemplateArgumentListInfo *ExplicitTemplateArgs,
6656  LookupResult &Previous, bool QualifiedFriend = false);
6657  bool CheckMemberSpecialization(NamedDecl *Member, LookupResult &Previous);
6658  void CompleteMemberSpecialization(NamedDecl *Member, LookupResult &Previous);
6659 
6660  DeclResult ActOnExplicitInstantiation(
6661  Scope *S, SourceLocation ExternLoc, SourceLocation TemplateLoc,
6662  unsigned TagSpec, SourceLocation KWLoc, const CXXScopeSpec &SS,
6663  TemplateTy Template, SourceLocation TemplateNameLoc,
6664  SourceLocation LAngleLoc, ASTTemplateArgsPtr TemplateArgs,
6665  SourceLocation RAngleLoc, const ParsedAttributesView &Attr);
6666 
6667  DeclResult ActOnExplicitInstantiation(Scope *S, SourceLocation ExternLoc,
6668  SourceLocation TemplateLoc,
6669  unsigned TagSpec, SourceLocation KWLoc,
6670  CXXScopeSpec &SS, IdentifierInfo *Name,
6671  SourceLocation NameLoc,
6672  const ParsedAttributesView &Attr);
6673 
6674  DeclResult ActOnExplicitInstantiation(Scope *S,
6675  SourceLocation ExternLoc,
6676  SourceLocation TemplateLoc,
6677  Declarator &D);
6678 
6680  SubstDefaultTemplateArgumentIfAvailable(TemplateDecl *Template,
6681  SourceLocation TemplateLoc,
6682  SourceLocation RAngleLoc,
6683  Decl *Param,
6685  &Converted,
6686  bool &HasDefaultArg);
6687 
6688  /// Specifies the context in which a particular template
6689  /// argument is being checked.
6691  /// The template argument was specified in the code or was
6692  /// instantiated with some deduced template arguments.
6694 
6695  /// The template argument was deduced via template argument
6696  /// deduction.
6698 
6699  /// The template argument was deduced from an array bound
6700  /// via template argument deduction.
6701  CTAK_DeducedFromArrayBound
6702  };
6703 
6704  bool CheckTemplateArgument(NamedDecl *Param,
6705  TemplateArgumentLoc &Arg,
6706  NamedDecl *Template,
6707  SourceLocation TemplateLoc,
6708  SourceLocation RAngleLoc,
6709  unsigned ArgumentPackIndex,
6711  CheckTemplateArgumentKind CTAK = CTAK_Specified);
6712 
6713  /// Check that the given template arguments can be be provided to
6714  /// the given template, converting the arguments along the way.
6715  ///
6716  /// \param Template The template to which the template arguments are being
6717  /// provided.
6718  ///
6719  /// \param TemplateLoc The location of the template name in the source.
6720  ///
6721  /// \param TemplateArgs The list of template arguments. If the template is
6722  /// a template template parameter, this function may extend the set of
6723  /// template arguments to also include substituted, defaulted template
6724  /// arguments.
6725  ///
6726  /// \param PartialTemplateArgs True if the list of template arguments is
6727  /// intentionally partial, e.g., because we're checking just the initial
6728  /// set of template arguments.
6729  ///
6730  /// \param Converted Will receive the converted, canonicalized template
6731  /// arguments.
6732  ///
6733  /// \param UpdateArgsWithConversions If \c true, update \p TemplateArgs to
6734  /// contain the converted forms of the template arguments as written.
6735  /// Otherwise, \p TemplateArgs will not be modified.
6736  ///
6737  /// \returns true if an error occurred, false otherwise.
6738  bool CheckTemplateArgumentList(TemplateDecl *Template,
6739  SourceLocation TemplateLoc,
6740  TemplateArgumentListInfo &TemplateArgs,
6741  bool PartialTemplateArgs,
6743  bool UpdateArgsWithConversions = true);
6744 
6745  bool CheckTemplateTypeArgument(TemplateTypeParmDecl *Param,
6746  TemplateArgumentLoc &Arg,
6748 
6749  bool CheckTemplateArgument(TemplateTypeParmDecl *Param,
6750  TypeSourceInfo *Arg);
6751  ExprResult CheckTemplateArgument(NonTypeTemplateParmDecl *Param,
6752  QualType InstantiatedParamType, Expr *Arg,
6753  TemplateArgument &Converted,
6754  CheckTemplateArgumentKind CTAK = CTAK_Specified);
6755  bool CheckTemplateTemplateArgument(TemplateParameterList *Params,
6756  TemplateArgumentLoc &Arg);
6757 
6758  ExprResult
6759  BuildExpressionFromDeclTemplateArgument(const TemplateArgument &Arg,
6760  QualType ParamType,
6761  SourceLocation Loc);
6762  ExprResult
6763  BuildExpressionFromIntegralTemplateArgument(const TemplateArgument &Arg,
6764  SourceLocation Loc);
6765 
6766  /// Enumeration describing how template parameter lists are compared
6767  /// for equality.
6769  /// We are matching the template parameter lists of two templates
6770  /// that might be redeclarations.
6771  ///
6772  /// \code
6773  /// template<typename T> struct X;
6774  /// template<typename T> struct X;
6775  /// \endcode
6777 
6778  /// We are matching the template parameter lists of two template
6779  /// template parameters as part of matching the template parameter lists
6780  /// of two templates that might be redeclarations.
6781  ///
6782  /// \code
6783  /// template<template<int I> class TT> struct X;
6784  /// template<template<int Value> class Other> struct X;
6785  /// \endcode
6787 
6788  /// We are matching the template parameter lists of a template
6789  /// template argument against the template parameter lists of a template
6790  /// template parameter.
6791  ///
6792  /// \code
6793  /// template<template<int Value> class Metafun> struct X;
6794  /// template<int Value> struct integer_c;
6795  /// X<integer_c> xic;
6796  /// \endcode
6797  TPL_TemplateTemplateArgumentMatch
6798  };
6799 
6800  bool TemplateParameterListsAreEqual(TemplateParameterList *New,
6801  TemplateParameterList *Old,
6802  bool Complain,
6804  SourceLocation TemplateArgLoc
6805  = SourceLocation());
6806 
6807  bool CheckTemplateDeclScope(Scope *S, TemplateParameterList *TemplateParams);
6808 
6809  /// Called when the parser has parsed a C++ typename
6810  /// specifier, e.g., "typename T::type".
6811  ///
6812  /// \param S The scope in which this typename type occurs.
6813  /// \param TypenameLoc the location of the 'typename' keyword
6814  /// \param SS the nested-name-specifier following the typename (e.g., 'T::').
6815  /// \param II the identifier we're retrieving (e.g., 'type' in the example).
6816  /// \param IdLoc the location of the identifier.
6817  TypeResult
6818  ActOnTypenameType(Scope *S, SourceLocation TypenameLoc,
6819  const CXXScopeSpec &SS, const IdentifierInfo &II,
6820  SourceLocation IdLoc);
6821 
6822  /// Called when the parser has parsed a C++ typename
6823  /// specifier that ends in a template-id, e.g.,
6824  /// "typename MetaFun::template apply<T1, T2>".
6825  ///
6826  /// \param S The scope in which this typename type occurs.
6827  /// \param TypenameLoc the location of the 'typename' keyword
6828  /// \param SS the nested-name-specifier following the typename (e.g., 'T::').
6829  /// \param TemplateLoc the location of the 'template' keyword, if any.
6830  /// \param TemplateName The template name.
6831  /// \param TemplateII The identifier used to name the template.
6832  /// \param TemplateIILoc The location of the template name.
6833  /// \param LAngleLoc The location of the opening angle bracket ('<').
6834  /// \param TemplateArgs The template arguments.
6835  /// \param RAngleLoc The location of the closing angle bracket ('>').
6836  TypeResult
6837  ActOnTypenameType(Scope *S, SourceLocation TypenameLoc,
6838  const CXXScopeSpec &SS,
6839  SourceLocation TemplateLoc,
6840  TemplateTy TemplateName,
6841  IdentifierInfo *TemplateII,
6842  SourceLocation TemplateIILoc,
6843  SourceLocation LAngleLoc,
6844  ASTTemplateArgsPtr TemplateArgs,
6845  SourceLocation RAngleLoc);
6846 
6847  QualType CheckTypenameType(ElaboratedTypeKeyword Keyword,
6848  SourceLocation KeywordLoc,
6849  NestedNameSpecifierLoc QualifierLoc,
6850  const IdentifierInfo &II,
6851  SourceLocation IILoc);
6852 
6853  TypeSourceInfo *RebuildTypeInCurrentInstantiation(TypeSourceInfo *T,
6854  SourceLocation Loc,
6855  DeclarationName Name);
6856  bool RebuildNestedNameSpecifierInCurrentInstantiation(CXXScopeSpec &SS);
6857 
6858  ExprResult RebuildExprInCurrentInstantiation(Expr *E);
6859  bool RebuildTemplateParamsInCurrentInstantiation(
6860  TemplateParameterList *Params);
6861 
6862  std::string
6863  getTemplateArgumentBindingsText(const TemplateParameterList *Params,
6864  const TemplateArgumentList &Args);
6865 
6866  std::string
6867  getTemplateArgumentBindingsText(const TemplateParameterList *Params,
6868  const TemplateArgument *Args,
6869  unsigned NumArgs);
6870 
6871  // Concepts
6872  Decl *ActOnConceptDefinition(
6873  Scope *S, MultiTemplateParamsArg TemplateParameterLists,
6874  IdentifierInfo *Name, SourceLocation NameLoc, Expr *ConstraintExpr);
6875 
6876  //===--------------------------------------------------------------------===//
6877  // C++ Variadic Templates (C++0x [temp.variadic])
6878  //===--------------------------------------------------------------------===//
6879 
6880  /// Determine whether an unexpanded parameter pack might be permitted in this
6881  /// location. Useful for error recovery.
6882  bool isUnexpandedParameterPackPermitted();
6883 
6884  /// The context in which an unexpanded parameter pack is
6885  /// being diagnosed.
6886  ///
6887  /// Note that the values of this enumeration line up with the first
6888  /// argument to the \c err_unexpanded_parameter_pack diagnostic.
6890  /// An arbitrary expression.
6891  UPPC_Expression = 0,
6892 
6893  /// The base type of a class type.
6895 
6896  /// The type of an arbitrary declaration.
6898 
6899  /// The type of a data member.
6901 
6902  /// The size of a bit-field.
6904 
6905  /// The expression in a static assertion.
6907 
6908  /// The fixed underlying type of an enumeration.
6910 
6911  /// The enumerator value.
6913 
6914  /// A using declaration.
6916 
6917  /// A friend declaration.
6919 
6920  /// A declaration qualifier.
6922 
6923  /// An initializer.
6925 
6926  /// A default argument.
6928 
6929  /// The type of a non-type template parameter.
6931 
6932  /// The type of an exception.
6934 
6935  /// Partial specialization.
6937 
6938  /// Microsoft __if_exists.
6940 
6941  /// Microsoft __if_not_exists.
6943 
6944  /// Lambda expression.
6946 
6947  /// Block expression,
6948  UPPC_Block
6949  };
6950 
6951  /// Diagnose unexpanded parameter packs.
6952  ///
6953  /// \param Loc The location at which we should emit the diagnostic.
6954  ///
6955  /// \param UPPC The context in which we are diagnosing unexpanded
6956  /// parameter packs.
6957  ///
6958  /// \param Unexpanded the set of unexpanded parameter packs.
6959  ///
6960  /// \returns true if an error occurred, false otherwise.
6964 
6965  /// If the given type contains an unexpanded parameter pack,
6966  /// diagnose the error.
6967  ///
6968  /// \param Loc The source location where a diagnostc should be emitted.
6969  ///
6970  /// \param T The type that is being checked for unexpanded parameter
6971  /// packs.
6972  ///
6973  /// \returns true if an error occurred, false otherwise.
6974  bool DiagnoseUnexpandedParameterPack(SourceLocation Loc, TypeSourceInfo *T,
6976 
6977  /// If the given expression contains an unexpanded parameter
6978  /// pack, diagnose the error.
6979  ///
6980  /// \param E The expression that is being checked for unexpanded
6981  /// parameter packs.
6982  ///
6983  /// \returns true if an error occurred, false otherwise.
6984  bool DiagnoseUnexpandedParameterPack(Expr *E,
6985  UnexpandedParameterPackContext UPPC = UPPC_Expression);
6986 
6987  /// If the given nested-name-specifier contains an unexpanded
6988  /// parameter pack, diagnose the error.
6989  ///
6990  /// \param SS The nested-name-specifier that is being checked for
6991  /// unexpanded parameter packs.
6992  ///
6993  /// \returns true if an error occurred, false otherwise.
6994  bool DiagnoseUnexpandedParameterPack(const CXXScopeSpec &SS,
6996 
6997  /// If the given name contains an unexpanded parameter pack,
6998  /// diagnose the error.
6999  ///
7000  /// \param NameInfo The name (with source location information) that
7001  /// is being checked for unexpanded parameter packs.
7002  ///
7003  /// \returns true if an error occurred, false otherwise.
7004  bool DiagnoseUnexpandedParameterPack(const DeclarationNameInfo &NameInfo,
7006 
7007  /// If the given template name contains an unexpanded parameter pack,
7008  /// diagnose the error.
7009  ///
7010  /// \param Loc The location of the template name.
7011  ///
7012  /// \param Template The template name that is being checked for unexpanded
7013  /// parameter packs.
7014  ///
7015  /// \returns true if an error occurred, false otherwise.
7016  bool DiagnoseUnexpandedParameterPack(SourceLocation Loc,
7017  TemplateName Template,
7019 
7020  /// If the given template argument contains an unexpanded parameter
7021  /// pack, diagnose the error.
7022  ///
7023  /// \param Arg The template argument that is being checked for unexpanded
7024  /// parameter packs.
7025  ///
7026  /// \returns true if an error occurred, false otherwise.
7027  bool DiagnoseUnexpandedParameterPack(TemplateArgumentLoc Arg,
7029 
7030  /// Collect the set of unexpanded parameter packs within the given
7031  /// template argument.
7032  ///
7033  /// \param Arg The template argument that will be traversed to find
7034  /// unexpanded parameter packs.
7037 
7038  /// Collect the set of unexpanded parameter packs within the given
7039  /// template argument.
7040  ///
7041  /// \param Arg The template argument that will be traversed to find
7042  /// unexpanded parameter packs.
7045 
7046  /// Collect the set of unexpanded parameter packs within the given
7047  /// type.
7048  ///
7049  /// \param T The type that will be traversed to find
7050  /// unexpanded parameter packs.
7053 
7054  /// Collect the set of unexpanded parameter packs within the given
7055  /// type.
7056  ///
7057  /// \param TL The type that will be traversed to find
7058  /// unexpanded parameter packs.
7061 
7062  /// Collect the set of unexpanded parameter packs within the given
7063  /// nested-name-specifier.
7064  ///
7065  /// \param NNS The nested-name-specifier that will be traversed to find
7066  /// unexpanded parameter packs.
7069 
7070  /// Collect the set of unexpanded parameter packs within the given
7071  /// name.
7072  ///
7073  /// \param NameInfo The name that will be traversed to find
7074  /// unexpanded parameter packs.
7077 
7078  /// Invoked when parsing a template argument followed by an
7079  /// ellipsis, which creates a pack expansion.
7080  ///
7081  /// \param Arg The template argument preceding the ellipsis, which
7082  /// may already be invalid.
7083  ///
7084  /// \param EllipsisLoc The location of the ellipsis.
7085  ParsedTemplateArgument ActOnPackExpansion(const ParsedTemplateArgument &Arg,
7086  SourceLocation EllipsisLoc);
7087 
7088  /// Invoked when parsing a type followed by an ellipsis, which
7089  /// creates a pack expansion.
7090  ///
7091  /// \param Type The type preceding the ellipsis, which will become
7092  /// the pattern of the pack expansion.
7093  ///
7094  /// \param EllipsisLoc The location of the ellipsis.
7095  TypeResult ActOnPackExpansion(ParsedType Type, SourceLocation EllipsisLoc);
7096 
7097  /// Construct a pack expansion type from the pattern of the pack
7098  /// expansion.
7099  TypeSourceInfo *CheckPackExpansion(TypeSourceInfo *Pattern,
7100  SourceLocation EllipsisLoc,
7101  Optional<unsigned> NumExpansions);
7102 
7103  /// Construct a pack expansion type from the pattern of the pack
7104  /// expansion.
7105  QualType CheckPackExpansion(QualType Pattern,
7106  SourceRange PatternRange,
7107  SourceLocation EllipsisLoc,
7108  Optional<unsigned> NumExpansions);
7109 
7110  /// Invoked when parsing an expression followed by an ellipsis, which
7111  /// creates a pack expansion.
7112  ///
7113  /// \param Pattern The expression preceding the ellipsis, which will become
7114  /// the pattern of the pack expansion.
7115  ///
7116  /// \param EllipsisLoc The location of the ellipsis.
7117  ExprResult ActOnPackExpansion(Expr *Pattern, SourceLocation EllipsisLoc);
7118 
7119  /// Invoked when parsing an expression followed by an ellipsis, which
7120  /// creates a pack expansion.
7121  ///
7122  /// \param Pattern The expression preceding the ellipsis, which will become
7123  /// the pattern of the pack expansion.
7124  ///
7125  /// \param EllipsisLoc The location of the ellipsis.
7126  ExprResult CheckPackExpansion(Expr *Pattern, SourceLocation EllipsisLoc,
7127  Optional<unsigned> NumExpansions);
7128 
7129  /// Determine whether we could expand a pack expansion with the
7130  /// given set of parameter packs into separate arguments by repeatedly
7131  /// transforming the pattern.
7132  ///
7133  /// \param EllipsisLoc The location of the ellipsis that identifies the
7134  /// pack expansion.
7135  ///
7136  /// \param PatternRange The source range that covers the entire pattern of
7137  /// the pack expansion.
7138  ///
7139  /// \param Unexpanded The set of unexpanded parameter packs within the
7140  /// pattern.
7141  ///
7142  /// \param ShouldExpand Will be set to \c true if the transformer should
7143  /// expand the corresponding pack expansions into separate arguments. When
7144  /// set, \c NumExpansions must also be set.
7145  ///
7146  /// \param RetainExpansion Whether the caller should add an unexpanded
7147  /// pack expansion after all of the expanded arguments. This is used
7148  /// when extending explicitly-specified template argument packs per
7149  /// C++0x [temp.arg.explicit]p9.
7150  ///
7151  /// \param NumExpansions The number of separate arguments that will be in
7152  /// the expanded form of the corresponding pack expansion. This is both an
7153  /// input and an output parameter, which can be set by the caller if the
7154  /// number of expansions is known a priori (e.g., due to a prior substitution)
7155  /// and will be set by the callee when the number of expansions is known.
7156  /// The callee must set this value when \c ShouldExpand is \c true; it may
7157  /// set this value in other cases.
7158  ///
7159  /// \returns true if an error occurred (e.g., because the parameter packs
7160  /// are to be instantiated with arguments of different lengths), false
7161  /// otherwise. If false, \c ShouldExpand (and possibly \c NumExpansions)
7162  /// must be set.
7163  bool CheckParameterPacksForExpansion(SourceLocation EllipsisLoc,
7164  SourceRange PatternRange,
7166  const MultiLevelTemplateArgumentList &TemplateArgs,
7167  bool &ShouldExpand,
7168  bool &RetainExpansion,
7169  Optional<unsigned> &NumExpansions);
7170 
7171  /// Determine the number of arguments in the given pack expansion
7172  /// type.
7173  ///
7174  /// This routine assumes that the number of arguments in the expansion is
7175  /// consistent across all of the unexpanded parameter packs in its pattern.
7176  ///
7177  /// Returns an empty Optional if the type can't be expanded.
7178  Optional<unsigned> getNumArgumentsInExpansion(QualType T,
7179  const MultiLevelTemplateArgumentList &TemplateArgs);
7180 
7181  /// Determine whether the given declarator contains any unexpanded
7182  /// parameter packs.
7183  ///
7184  /// This routine is used by the parser to disambiguate function declarators
7185  /// with an ellipsis prior to the ')', e.g.,
7186  ///
7187  /// \code
7188  /// void f(T...);
7189  /// \endcode
7190  ///
7191  /// To determine whether we have an (unnamed) function parameter pack or
7192  /// a variadic function.
7193  ///
7194  /// \returns true if the declarator contains any unexpanded parameter packs,
7195  /// false otherwise.
7196  bool containsUnexpandedParameterPacks(Declarator &D);
7197 
7198  /// Returns the pattern of the pack expansion for a template argument.
7199  ///
7200  /// \param OrigLoc The template argument to expand.
7201  ///
7202  /// \param Ellipsis Will be set to the location of the ellipsis.
7203  ///
7204  /// \param NumExpansions Will be set to the number of expansions that will
7205  /// be generated from this pack expansion, if known a priori.
7206  TemplateArgumentLoc getTemplateArgumentPackExpansionPattern(
7207  TemplateArgumentLoc OrigLoc,
7208  SourceLocation &Ellipsis,
7209  Optional<unsigned> &NumExpansions) const;
7210 
7211  /// Given a template argument that contains an unexpanded parameter pack, but
7212  /// which has already been substituted, attempt to determine the number of
7213  /// elements that will be produced once this argument is fully-expanded.
7214  ///
7215  /// This is intended for use when transforming 'sizeof...(Arg)' in order to
7216  /// avoid actually expanding the pack where possible.
7217  Optional<unsigned> getFullyPackExpandedSize(TemplateArgument Arg);
7218 
7219  //===--------------------------------------------------------------------===//
7220  // C++ Template Argument Deduction (C++ [temp.deduct])
7221  //===--------------------------------------------------------------------===//
7222 
7223  /// Adjust the type \p ArgFunctionType to match the calling convention,
7224  /// noreturn, and optionally the exception specification of \p FunctionType.
7225  /// Deduction often wants to ignore these properties when matching function
7226  /// types.
7227  QualType adjustCCAndNoReturn(QualType ArgFunctionType, QualType FunctionType,
7228  bool AdjustExceptionSpec = false);
7229 
7230  /// Describes the result of template argument deduction.
7231  ///
7232  /// The TemplateDeductionResult enumeration describes the result of
7233  /// template argument deduction, as returned from
7234  /// DeduceTemplateArguments(). The separate TemplateDeductionInfo
7235  /// structure provides additional information about the results of
7236  /// template argument deduction, e.g., the deduced template argument
7237  /// list (if successful) or the specific template parameters or
7238  /// deduced arguments that were involved in the failure.
7240  /// Template argument deduction was successful.
7241  TDK_Success = 0,
7242  /// The declaration was invalid; do nothing.
7244  /// Template argument deduction exceeded the maximum template
7245  /// instantiation depth (which has already been diagnosed).
7247  /// Template argument deduction did not deduce a value
7248  /// for every template parameter.
7250  /// Template argument deduction did not deduce a value for every
7251  /// expansion of an expanded template parameter pack.
7253  /// Template argument deduction produced inconsistent
7254  /// deduced values for the given template parameter.
7256  /// Template argument deduction failed due to inconsistent
7257  /// cv-qualifiers on a template parameter type that would
7258  /// otherwise be deduced, e.g., we tried to deduce T in "const T"
7259  /// but were given a non-const "X".
7261  /// Substitution of the deduced template argument values
7262  /// resulted in an error.
7264  /// After substituting deduced template arguments, a dependent
7265  /// parameter type did not match the corresponding argument.
7267  /// After substituting deduced template arguments, an element of
7268  /// a dependent parameter type did not match the corresponding element
7269  /// of the corresponding argument (when deducing from an initializer list).
7271  /// A non-depnedent component of the parameter did not match the
7272  /// corresponding component of the argument.
7274  /// When performing template argument deduction for a function
7275  /// template, there were too many call arguments.
7277  /// When performing template argument deduction for a function
7278  /// template, there were too few call arguments.
7280  /// The explicitly-specified template arguments were not valid
7281  /// template arguments for the given template.
7283  /// Checking non-dependent argument conversions failed.
7285  /// Deduction failed; that's all we know.
7287  /// CUDA Target attributes do not match.
7288  TDK_CUDATargetMismatch
7289  };
7290 
7293  const TemplateArgumentList &TemplateArgs,
7295 
7298  const TemplateArgumentList &TemplateArgs,
7300 
7301  TemplateDeductionResult SubstituteExplicitTemplateArguments(
7302  FunctionTemplateDecl *FunctionTemplate,
7303  TemplateArgumentListInfo &ExplicitTemplateArgs,
7307 
7308  /// brief A function argument from which we performed template argument
7309  // deduction for a call.
7311  OriginalCallArg(QualType OriginalParamType, bool DecomposedParam,
7312  unsigned ArgIdx, QualType OriginalArgType)
7313  : OriginalParamType(OriginalParamType),
7314  DecomposedParam(DecomposedParam), ArgIdx(ArgIdx),
7315  OriginalArgType(OriginalArgType) {}
7316 
7319  unsigned ArgIdx;
7321  };
7322 
7324  FunctionTemplateDecl *FunctionTemplate,
7326  unsigned NumExplicitlySpecified, FunctionDecl *&Specialization,
7328  SmallVectorImpl<OriginalCallArg> const *OriginalCallArgs = nullptr,
7329  bool PartialOverloading = false,
7330  llvm::function_ref<bool()> CheckNonDependent = []{ return false; });
7331 
7333  FunctionTemplateDecl *FunctionTemplate,
7334  TemplateArgumentListInfo *ExplicitTemplateArgs, ArrayRef<Expr *> Args,
7335  FunctionDecl *&Specialization, sema::TemplateDeductionInfo &Info,
7336  bool PartialOverloading,
7337  llvm::function_ref<bool(ArrayRef<QualType>)> CheckNonDependent);
7338 
7341  TemplateArgumentListInfo *ExplicitTemplateArgs,
7342  QualType ArgFunctionType,
7343  FunctionDecl *&Specialization,
7345  bool IsAddressOfFunction = false);
7346 
7349  QualType ToType,
7350  CXXConversionDecl *&Specialization,
7352 
7355  TemplateArgumentListInfo *ExplicitTemplateArgs,
7356  FunctionDecl *&Specialization,
7358  bool IsAddressOfFunction = false);
7359 
7360  /// Substitute Replacement for \p auto in \p TypeWithAuto
7361  QualType SubstAutoType(QualType TypeWithAuto, QualType Replacement);
7362  /// Substitute Replacement for auto in TypeWithAuto
7363  TypeSourceInfo* SubstAutoTypeSourceInfo(TypeSourceInfo *TypeWithAuto,
7364  QualType Replacement);
7365  /// Completely replace the \c auto in \p TypeWithAuto by
7366  /// \p Replacement. This does not retain any \c auto type sugar.
7367  QualType ReplaceAutoType(QualType TypeWithAuto, QualType Replacement);
7368 
7369  /// Result type of DeduceAutoType.
7373  DAR_FailedAlreadyDiagnosed
7374  };
7375 
7377  DeduceAutoType(TypeSourceInfo *AutoType, Expr *&Initializer, QualType &Result,
7378  Optional<unsigned> DependentDeductionDepth = None);
7380  DeduceAutoType(TypeLoc AutoTypeLoc, Expr *&Initializer, QualType &Result,
7381  Optional<unsigned> DependentDeductionDepth = None);
7382  void DiagnoseAutoDeductionFailure(VarDecl *VDecl, Expr *Init);
7383  bool DeduceReturnType(FunctionDecl *FD, SourceLocation Loc,
7384  bool Diagnose = true);
7385 
7386  /// Declare implicit deduction guides for a class template if we've
7387  /// not already done so.
7388  void DeclareImplicitDeductionGuides(TemplateDecl *Template,
7389  SourceLocation Loc);
7390 
7391  QualType DeduceTemplateSpecializationFromInitializer(
7392  TypeSourceInfo *TInfo, const InitializedEntity &Entity,
7393  const InitializationKind &Kind, MultiExprArg Init);
7394 
7395  QualType deduceVarTypeFromInitializer(VarDecl *VDecl, DeclarationName Name,
7396  QualType Type, TypeSourceInfo *TSI,
7397  SourceRange Range, bool DirectInit,
7398  Expr *Init);
7399 
7400  TypeLoc getReturnTypeLoc(FunctionDecl *FD) const;
7401 
7402  bool DeduceFunctionTypeFromReturnExpr(FunctionDecl *FD,
7403  SourceLocation ReturnLoc,
7404  Expr *&RetExpr, AutoType *AT);
7405 
7406  FunctionTemplateDecl *getMoreSpecializedTemplate(FunctionTemplateDecl *FT1,
7407  FunctionTemplateDecl *FT2,
7408  SourceLocation Loc,
7410  unsigned NumCallArguments1,
7411  unsigned NumCallArguments2);
7413  getMostSpecialized(UnresolvedSetIterator SBegin, UnresolvedSetIterator SEnd,
7414  TemplateSpecCandidateSet &FailedCandidates,
7415  SourceLocation Loc,
7416  const PartialDiagnostic &NoneDiag,
7417  const PartialDiagnostic &AmbigDiag,
7418  const PartialDiagnostic &CandidateDiag,
7419  bool Complain = true, QualType TargetType = QualType());
7420 
7422  getMoreSpecializedPartialSpecialization(
7425  SourceLocation Loc);
7426 
7427  bool isMoreSpecializedThanPrimary(ClassTemplatePartialSpecializationDecl *T,
7429 
7430  VarTemplatePartialSpecializationDecl *getMoreSpecializedPartialSpecialization(
7433 
7434  bool isMoreSpecializedThanPrimary(VarTemplatePartialSpecializationDecl *T,
7436 
7437  bool isTemplateTemplateParameterAtLeastAsSpecializedAs(
7439 
7440  void MarkUsedTemplateParameters(const TemplateArgumentList &TemplateArgs,
7441  bool OnlyDeduced,
7442  unsigned Depth,
7443  llvm::SmallBitVector &Used);
7445  const FunctionTemplateDecl *FunctionTemplate,
7446  llvm::SmallBitVector &Deduced) {
7447  return MarkDeducedTemplateParameters(Context, FunctionTemplate, Deduced);
7448  }
7449  static void MarkDeducedTemplateParameters(ASTContext &Ctx,
7450  const FunctionTemplateDecl *FunctionTemplate,
7451  llvm::SmallBitVector &Deduced);
7452 
7453  //===--------------------------------------------------------------------===//
7454  // C++ Template Instantiation
7455  //
7456 
7458  getTemplateInstantiationArgs(NamedDecl *D,
7459  const TemplateArgumentList *Innermost = nullptr,
7460  bool RelativeToPrimary = false,
7461  const FunctionDecl *Pattern = nullptr);
7462 
7463  /// A context in which code is being synthesized (where a source location
7464  /// alone is not sufficient to identify the context). This covers template
7465  /// instantiation and various forms of implicitly-generated functions.
7467  /// The kind of template instantiation we are performing
7469  /// We are instantiating a template declaration. The entity is
7470  /// the declaration we're instantiating (e.g., a CXXRecordDecl).
7472 
7473  /// We are instantiating a default argument for a template
7474  /// parameter. The Entity is the template parameter whose argument is
7475  /// being instantiated, the Template is the template, and the
7476  /// TemplateArgs/NumTemplateArguments provide the template arguments as
7477  /// specified.
7479 
7480  /// We are instantiating a default argument for a function.
7481  /// The Entity is the ParmVarDecl, and TemplateArgs/NumTemplateArgs
7482  /// provides the template arguments as specified.
7484 
7485  /// We are substituting explicit template arguments provided for
7486  /// a function template. The entity is a FunctionTemplateDecl.
7488 
7489  /// We are substituting template argument determined as part of
7490  /// template argument deduction for either a class template
7491  /// partial specialization or a function template. The
7492  /// Entity is either a {Class|Var}TemplatePartialSpecializationDecl or
7493  /// a TemplateDecl.
7495 
7496  /// We are substituting prior template arguments into a new
7497  /// template parameter. The template parameter itself is either a
7498  /// NonTypeTemplateParmDecl or a TemplateTemplateParmDecl.
7500 
7501  /// We are checking the validity of a default template argument that
7502  /// has been used when naming a template-id.
7504 
7505  /// We are computing the exception specification for a defaulted special
7506  /// member function.
7508 
7509  /// We are instantiating the exception specification for a function
7510  /// template which was deferred until it was needed.
7512 
7513  /// We are declaring an implicit special member function.
7515 
7516  /// We are defining a synthesized function (such as a defaulted special
7517  /// member).
7519 
7520  /// Added for Template instantiation observation.
7521  /// Memoization means we are _not_ instantiating a template because
7522  /// it is already instantiated (but we entered a context where we
7523  /// would have had to if it was not already instantiated).
7524  Memoization
7525  } Kind;
7526 
7527  /// Was the enclosing context a non-instantiation SFINAE context?
7529 
7530  /// The point of instantiation or synthesis within the source code.
7532 
7533  /// The entity that is being synthesized.
7534  Decl *Entity;
7535 
7536  /// The template (or partial specialization) in which we are
7537  /// performing the instantiation, for substitutions of prior template
7538  /// arguments.
7540 
7541  /// The list of template arguments we are substituting, if they
7542  /// are not part of the entity.
7544 
7545  // FIXME: Wrap this union around more members, or perhaps store the
7546  // kind-specific members in the RAII object owning the context.
7547  union {
7548  /// The number of template arguments in TemplateArgs.
7550 
7551  /// The special member being declared or defined.
7553  };
7554 
7556  assert(Kind != DeclaringSpecialMember);
7557  return {TemplateArgs, NumTemplateArgs};
7558  }
7559 
7560  /// The template deduction info object associated with the
7561  /// substitution or checking of explicit or deduced template arguments.
7563 
7564  /// The source range that covers the construct that cause
7565  /// the instantiation, e.g., the template-id that causes a class
7566  /// template instantiation.
7568 
7570  : Kind(TemplateInstantiation),
7571  SavedInNonInstantiationSFINAEContext(false), Entity(nullptr),
7572  Template(nullptr), TemplateArgs(nullptr), NumTemplateArgs(0),
7573  DeductionInfo(nullptr) {}
7574 
7575  /// Determines whether this template is an actual instantiation
7576  /// that should be counted toward the maximum instantiation depth.
7577  bool isInstantiationRecord() const;
7578  };
7579 
7580  /// List of active code synthesis contexts.
7581  ///
7582  /// This vector is treated as a stack. As synthesis of one entity requires
7583  /// synthesis of another, additional contexts are pushed onto the stack.
7585 
7586  /// Specializations whose definitions are currently being instantiated.
7588 
7589  /// Non-dependent types used in templates that have already been instantiated
7590  /// by some template instantiation.
7592 
7593  /// Extra modules inspected when performing a lookup during a template
7594  /// instantiation. Computed lazily.
7596 
7597  /// Cache of additional modules that should be used for name lookup
7598  /// within the current template instantiation. Computed lazily; use
7599  /// getLookupModules() to get a complete set.
7601 
7602  /// Get the set of additional modules that should be checked during
7603  /// name lookup. A module and its imports become visible when instanting a
7604  /// template defined within it.
7605  llvm::DenseSet<Module*> &getLookupModules();
7606 
7607  /// Map from the most recent declaration of a namespace to the most
7608  /// recent visible declaration of that namespace.
7609  llvm::DenseMap<NamedDecl*, NamedDecl*> VisibleNamespaceCache;
7610 
7611  /// Whether we are in a SFINAE context that is not associated with
7612  /// template instantiation.
7613  ///
7614  /// This is used when setting up a SFINAE trap (\c see SFINAETrap) outside
7615  /// of a template instantiation or template argument deduction.
7617 
7618  /// The number of \p CodeSynthesisContexts that are not template
7619  /// instantiations and, therefore, should not be counted as part of the
7620  /// instantiation depth.
7621  ///
7622  /// When the instantiation depth reaches the user-configurable limit
7623  /// \p LangOptions::InstantiationDepth we will abort instantiation.
7624  // FIXME: Should we have a similar limit for other forms of synthesis?
7626 
7627  /// The depth of the context stack at the point when the most recent
7628  /// error or warning was produced.
7629  ///
7630  /// This value is used to suppress printing of redundant context stacks
7631  /// when there are multiple errors or warnings in the same instantiation.
7632  // FIXME: Does this belong in Sema? It's tough to implement it anywhere else.
7633  unsigned LastEmittedCodeSynthesisContextDepth = 0;
7634 
7635  /// The template instantiation callbacks to trace or track
7636  /// instantiations (objects can be chained).
7637  ///
7638  /// This callbacks is used to print, trace or track template
7639  /// instantiations as they are being constructed.
7640  std::vector<std::unique_ptr<TemplateInstantiationCallback>>
7642 
7643  /// The current index into pack expansion arguments that will be
7644  /// used for substitution of parameter packs.
7645  ///
7646  /// The pack expansion index will be -1 to indicate that parameter packs
7647  /// should be instantiated as themselves. Otherwise, the index specifies
7648  /// which argument within the parameter pack will be used for substitution.
7650 
7651  /// RAII object used to change the argument pack substitution index
7652  /// within a \c Sema object.
7653  ///
7654  /// See \c ArgumentPackSubstitutionIndex for more information.
7656  Sema &Self;
7657  int OldSubstitutionIndex;
7658 
7659  public:
7660  ArgumentPackSubstitutionIndexRAII(Sema &Self, int NewSubstitutionIndex)
7661  : Self(Self), OldSubstitutionIndex(Self.ArgumentPackSubstitutionIndex) {
7662  Self.ArgumentPackSubstitutionIndex = NewSubstitutionIndex;
7663  }
7664 
7666  Self.ArgumentPackSubstitutionIndex = OldSubstitutionIndex;
7667  }
7668  };
7669 
7670  friend class ArgumentPackSubstitutionRAII;
7671 
7672  /// For each declaration that involved template argument deduction, the
7673  /// set of diagnostics that were suppressed during that template argument
7674  /// deduction.
7675  ///
7676  /// FIXME: Serialize this structure to the AST file.
7677  typedef llvm::DenseMap<Decl *, SmallVector<PartialDiagnosticAt, 1> >
7680 
7681  /// A stack object to be created when performing template
7682  /// instantiation.
7683  ///
7684  /// Construction of an object of type \c InstantiatingTemplate
7685  /// pushes the current instantiation onto the stack of active
7686  /// instantiations. If the size of this stack exceeds the maximum
7687  /// number of recursive template instantiations, construction
7688  /// produces an error and evaluates true.
7689  ///
7690  /// Destruction of this object will pop the named instantiation off
7691  /// the stack.
7693  /// Note that we are instantiating a class template,
7694  /// function template, variable template, alias template,
7695  /// or a member thereof.
7696  InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
7697  Decl *Entity,
7698  SourceRange InstantiationRange = SourceRange());
7699 
7701  /// Note that we are instantiating an exception specification
7702  /// of a function template.
7703  InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
7704  FunctionDecl *Entity, ExceptionSpecification,
7705  SourceRange InstantiationRange = SourceRange());
7706 
7707  /// Note that we are instantiating a default argument in a
7708  /// template-id.
7709  InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
7710  TemplateParameter Param, TemplateDecl *Template,
7711  ArrayRef<TemplateArgument> TemplateArgs,
7712  SourceRange InstantiationRange = SourceRange());
7713 
7714  /// Note that we are substituting either explicitly-specified or
7715  /// deduced template arguments during function template argument deduction.
7716  InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
7717  FunctionTemplateDecl *FunctionTemplate,
7718  ArrayRef<TemplateArgument> TemplateArgs,
7720  sema::TemplateDeductionInfo &DeductionInfo,
7721  SourceRange InstantiationRange = SourceRange());
7722 
7723  /// Note that we are instantiating as part of template
7724  /// argument deduction for a class template declaration.
7725  InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
7726  TemplateDecl *Template,
7727  ArrayRef<TemplateArgument> TemplateArgs,
7728  sema::TemplateDeductionInfo &DeductionInfo,
7729  SourceRange InstantiationRange = SourceRange());
7730 
7731  /// Note that we are instantiating as part of template
7732  /// argument deduction for a class template partial
7733  /// specialization.
7734  InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
7736  ArrayRef<TemplateArgument> TemplateArgs,
7737  sema::TemplateDeductionInfo &DeductionInfo,
7738  SourceRange InstantiationRange = SourceRange());
7739 
7740  /// Note that we are instantiating as part of template
7741  /// argument deduction for a variable template partial
7742  /// specialization.
7743  InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
7745  ArrayRef<TemplateArgument> TemplateArgs,
7746  sema::TemplateDeductionInfo &DeductionInfo,
7747  SourceRange InstantiationRange = SourceRange());
7748 
7749  /// Note that we are instantiating a default argument for a function
7750  /// parameter.
7751  InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
7752  ParmVarDecl *Param,
7753  ArrayRef<TemplateArgument> TemplateArgs,
7754  SourceRange InstantiationRange = SourceRange());
7755 
7756  /// Note that we are substituting prior template arguments into a
7757  /// non-type parameter.
7758  InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
7759  NamedDecl *Template,
7760  NonTypeTemplateParmDecl *Param,
7761  ArrayRef<TemplateArgument> TemplateArgs,
7762  SourceRange InstantiationRange);
7763 
7764  /// Note that we are substituting prior template arguments into a
7765  /// template template parameter.
7766  InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
7767  NamedDecl *Template,
7768  TemplateTemplateParmDecl *Param,
7769  ArrayRef<TemplateArgument> TemplateArgs,
7770  SourceRange InstantiationRange);
7771 
7772  /// Note that we are checking the default template argument
7773  /// against the template parameter for a given template-id.
7774  InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
7775  TemplateDecl *Template,
7776  NamedDecl *Param,
7777  ArrayRef<TemplateArgument> TemplateArgs,
7778  SourceRange InstantiationRange);
7779 
7780 
7781  /// Note that we have finished instantiating this template.
7782  void Clear();
7783 
7784  ~InstantiatingTemplate() { Clear(); }
7785 
7786  /// Determines whether we have exceeded the maximum
7787  /// recursive template instantiations.
7788  bool isInvalid() const { return Invalid; }
7789 
7790  /// Determine whether we are already instantiating this
7791  /// specialization in some surrounding active instantiation.
7792  bool isAlreadyInstantiating() const { return AlreadyInstantiating; }
7793 
7794  private:
7795  Sema &SemaRef;
7796  bool Invalid;
7797  bool AlreadyInstantiating;
7798  bool CheckInstantiationDepth(SourceLocation PointOfInstantiation,
7799  SourceRange InstantiationRange);
7800 
7803  SourceLocation PointOfInstantiation, SourceRange InstantiationRange,
7804  Decl *Entity, NamedDecl *Template = nullptr,
7805  ArrayRef<TemplateArgument> TemplateArgs = None,
7806  sema::TemplateDeductionInfo *DeductionInfo = nullptr);
7807 
7809 
7811  operator=(const InstantiatingTemplate&) = delete;
7812  };
7813 
7814  void pushCodeSynthesisContext(CodeSynthesisContext Ctx);
7815  void popCodeSynthesisContext();
7816 
7817  /// Determine whether we are currently performing template instantiation.
7819  return CodeSynthesisContexts.size() > NonInstantiationEntries;
7820  }
7821 
7823  if (!CodeSynthesisContexts.empty() &&
7824  CodeSynthesisContexts.size() != LastEmittedCodeSynthesisContextDepth) {
7825  PrintInstantiationStack();
7826  LastEmittedCodeSynthesisContextDepth = CodeSynthesisContexts.size();
7827  }
7828  if (PragmaAttributeCurrentTargetDecl)
7829  PrintPragmaAttributeInstantiationPoint();
7830  }
7831  void PrintInstantiationStack();
7832 
7833  void PrintPragmaAttributeInstantiationPoint();
7834 
7835  /// Determines whether we are currently in a context where
7836  /// template argument substitution failures are not considered
7837  /// errors.
7838  ///
7839  /// \returns An empty \c Optional if we're not in a SFINAE context.
7840  /// Otherwise, contains a pointer that, if non-NULL, contains the nearest
7841  /// template-deduction context object, which can be used to capture
7842  /// diagnostics that will be suppressed.
7843  Optional<sema::TemplateDeductionInfo *> isSFINAEContext() const;
7844 
7845  /// Determines whether we are currently in a context that
7846  /// is not evaluated as per C++ [expr] p5.
7847  bool isUnevaluatedContext() const {
7848  assert(!ExprEvalContexts.empty() &&
7849  "Must be in an expression evaluation context");
7850  return ExprEvalContexts.back().isUnevaluated();
7851  }
7852 
7853  /// RAII class used to determine whether SFINAE has
7854  /// trapped any errors that occur during template argument
7855  /// deduction.
7856  class SFINAETrap {
7857  Sema &SemaRef;
7858  unsigned PrevSFINAEErrors;
7859  bool PrevInNonInstantiationSFINAEContext;
7860  bool PrevAccessCheckingSFINAE;
7861  bool PrevLastDiagnosticIgnored;
7862 
7863  public:
7864  explicit SFINAETrap(Sema &SemaRef, bool AccessCheckingSFINAE = false)
7865  : SemaRef(SemaRef), PrevSFINAEErrors(SemaRef.NumSFINAEErrors),
7866  PrevInNonInstantiationSFINAEContext(
7867  SemaRef.InNonInstantiationSFINAEContext),
7868  PrevAccessCheckingSFINAE(SemaRef.AccessCheckingSFINAE),
7869  PrevLastDiagnosticIgnored(
7870  SemaRef.getDiagnostics().isLastDiagnosticIgnored())
7871  {
7872  if (!SemaRef.isSFINAEContext())
7873  SemaRef.InNonInstantiationSFINAEContext = true;
7874  SemaRef.AccessCheckingSFINAE = AccessCheckingSFINAE;
7875  }
7876 
7878  SemaRef.NumSFINAEErrors = PrevSFINAEErrors;
7880  = PrevInNonInstantiationSFINAEContext;
7881  SemaRef.AccessCheckingSFINAE = PrevAccessCheckingSFINAE;
7883  PrevLastDiagnosticIgnored);
7884  }
7885 
7886  /// Determine whether any SFINAE errors have been trapped.
7887  bool hasErrorOccurred() const {
7888  return SemaRef.NumSFINAEErrors > PrevSFINAEErrors;
7889  }
7890  };
7891 
7892  /// RAII class used to indicate that we are performing provisional
7893  /// semantic analysis to determine the validity of a construct, so
7894  /// typo-correction and diagnostics in the immediate context (not within
7895  /// implicitly-instantiated templates) should be suppressed.
7897  Sema &SemaRef;
7898  // FIXME: Using a SFINAETrap for this is a hack.
7899  SFINAETrap Trap;
7900  bool PrevDisableTypoCorrection;
7901  public:
7902  explicit TentativeAnalysisScope(Sema &SemaRef)
7903  : SemaRef(SemaRef), Trap(SemaRef, true),
7904  PrevDisableTypoCorrection(SemaRef.DisableTypoCorrection) {
7905  SemaRef.DisableTypoCorrection = true;
7906  }
7908  SemaRef.DisableTypoCorrection = PrevDisableTypoCorrection;
7909  }
7910  };
7911 
7912  /// The current instantiation scope used to store local
7913  /// variables.
7915 
7916  /// Tracks whether we are in a context where typo correction is
7917  /// disabled.
7919 
7920  /// The number of typos corrected by CorrectTypo.
7921  unsigned TyposCorrected;
7922 
7923  typedef llvm::SmallSet<SourceLocation, 2> SrcLocSet;
7924  typedef llvm::DenseMap<IdentifierInfo *, SrcLocSet> IdentifierSourceLocations;
7925 
7926  /// A cache containing identifiers for which typo correction failed and
7927  /// their locations, so that repeated attempts to correct an identifier in a
7928  /// given location are ignored if typo correction already failed for it.
7929  IdentifierSourceLocations TypoCorrectionFailures;
7930 
7931  /// Worker object for performing CFG-based warnings.
7934 
7935  /// An entity for which implicit template instantiation is required.
7936  ///
7937  /// The source location associated with the declaration is the first place in
7938  /// the source code where the declaration was "used". It is not necessarily
7939  /// the point of instantiation (which will be either before or after the
7940  /// namespace-scope declaration that triggered this implicit instantiation),
7941  /// However, it is the location that diagnostics should generally refer to,
7942  /// because users will need to know what code triggered the instantiation.
7943  typedef std::pair<ValueDecl *, SourceLocation> PendingImplicitInstantiation;
7944 
7945  /// The queue of implicit template instantiations that are required
7946  /// but have not yet been performed.
7947  std::deque<PendingImplicitInstantiation> PendingInstantiations;
7948 
7949  /// Queue of implicit template instantiations that cannot be performed
7950  /// eagerly.
7952 
7954  public:
7956  : S(S), Enabled(Enabled) {
7957  if (!Enabled) return;
7958 
7959  SavedPendingInstantiations.swap(S.PendingInstantiations);
7960  SavedVTableUses.swap(S.VTableUses);
7961  }
7962 
7963  void perform() {
7964  if (Enabled) {
7965  S.DefineUsedVTables();
7966  S.PerformPendingInstantiations();
7967  }
7968  }
7969 
7971  if (!Enabled) return;
7972 
7973  // Restore the set of pending vtables.
7974  assert(S.VTableUses.empty() &&
7975  "VTableUses should be empty before it is discarded.");
7976  S.VTableUses.swap(SavedVTableUses);
7977 
7978  // Restore the set of pending implicit instantiations.
7979  assert(S.PendingInstantiations.empty() &&
7980  "PendingInstantiations should be empty before it is discarded.");
7981  S.PendingInstantiations.swap(SavedPendingInstantiations);
7982  }
7983 
7984  private:
7985  Sema &S;
7986  SmallVector<VTableUse, 16> SavedVTableUses;
7987  std::deque<PendingImplicitInstantiation> SavedPendingInstantiations;
7988  bool Enabled;
7989  };
7990 
7991  /// The queue of implicit template instantiations that are required
7992  /// and must be performed within the current local scope.
7993  ///
7994  /// This queue is only used for member functions of local classes in
7995  /// templates, which must be instantiated in the same scope as their
7996  /// enclosing function, so that they can reference function-local
7997  /// types, static variables, enumerators, etc.
7998  std::deque<PendingImplicitInstantiation> PendingLocalImplicitInstantiations;
7999 
8001  public:
8003  SavedPendingLocalImplicitInstantiations.swap(
8005  }
8006 
8007  void perform() { S.PerformPendingInstantiations(/*LocalOnly=*/true); }
8008 
8010  assert(S.PendingLocalImplicitInstantiations.empty() &&
8011  "there shouldn't be any pending local implicit instantiations");
8012  SavedPendingLocalImplicitInstantiations.swap(
8013  S.PendingLocalImplicitInstantiations);
8014  }
8015 
8016  private:
8017  Sema &S;
8018  std::deque<PendingImplicitInstantiation>
8019  SavedPendingLocalImplicitInstantiations;
8020  };
8021 
8022  /// A helper class for building up ExtParameterInfos.
8025  bool HasInteresting = false;
8026 
8027  public:
8028  /// Set the ExtParameterInfo for the parameter at the given index,
8029  ///
8030  void set(unsigned index, FunctionProtoType::ExtParameterInfo info) {
8031  assert(Infos.size() <= index);
8032  Infos.resize(index);
8033  Infos.push_back(info);
8034 
8035  if (!HasInteresting)
8036  HasInteresting = (info != FunctionProtoType::ExtParameterInfo());
8037  }
8038 
8039  /// Return a pointer (suitable for setting in an ExtProtoInfo) to the
8040  /// ExtParameterInfo array we've built up.
8041  const FunctionProtoType::ExtParameterInfo *
8042  getPointerOrNull(unsigned numParams) {
8043  if (!HasInteresting) return nullptr;
8044  Infos.resize(numParams);
8045  return Infos.data();
8046  }
8047  };
8048 
8049  void PerformPendingInstantiations(bool LocalOnly = false);
8050 
8051  TypeSourceInfo *SubstType(TypeSourceInfo *T,
8052  const MultiLevelTemplateArgumentList &TemplateArgs,
8053  SourceLocation Loc, DeclarationName Entity,
8054  bool AllowDeducedTST = false);
8055 
8056  QualType SubstType(QualType T,
8057  const MultiLevelTemplateArgumentList &TemplateArgs,
8058  SourceLocation Loc, DeclarationName Entity);
8059 
8060  TypeSourceInfo *SubstType(TypeLoc TL,
8061  const MultiLevelTemplateArgumentList &TemplateArgs,
8062  SourceLocation Loc, DeclarationName Entity);
8063 
8064  TypeSourceInfo *SubstFunctionDeclType(TypeSourceInfo *T,
8065  const MultiLevelTemplateArgumentList &TemplateArgs,
8066  SourceLocation Loc,
8067  DeclarationName Entity,
8068  CXXRecordDecl *ThisContext,
8069  Qualifiers ThisTypeQuals);
8070  void SubstExceptionSpec(FunctionDecl *New, const FunctionProtoType *Proto,
8071  const MultiLevelTemplateArgumentList &Args);
8072  bool SubstExceptionSpec(SourceLocation Loc,
8074  SmallVectorImpl<QualType> &ExceptionStorage,
8075  const MultiLevelTemplateArgumentList &Args);
8076  ParmVarDecl *SubstParmVarDecl(ParmVarDecl *D,
8077  const MultiLevelTemplateArgumentList &TemplateArgs,
8078  int indexAdjustment,
8079  Optional<unsigned> NumExpansions,
8080  bool ExpectParameterPack);
8081  bool SubstParmTypes(SourceLocation Loc, ArrayRef<ParmVarDecl *> Params,
8082  const FunctionProtoType::ExtParameterInfo *ExtParamInfos,
8083  const MultiLevelTemplateArgumentList &TemplateArgs,
8084  SmallVectorImpl<QualType> &ParamTypes,
8085  SmallVectorImpl<ParmVarDecl *> *OutParams,
8086  ExtParameterInfoBuilder &ParamInfos);
8087  ExprResult SubstExpr(Expr *E,
8088  const MultiLevelTemplateArgumentList &TemplateArgs);
8089 
8090  /// Substitute the given template arguments into a list of
8091  /// expressions, expanding pack expansions if required.
8092  ///
8093  /// \param Exprs The list of expressions to substitute into.
8094  ///
8095  /// \param IsCall Whether this is some form of call, in which case
8096  /// default arguments will be dropped.
8097  ///
8098  /// \param TemplateArgs The set of template arguments to substitute.
8099  ///
8100  /// \param Outputs Will receive all of the substituted arguments.
8101  ///
8102  /// \returns true if an error occurred, false otherwise.
8103  bool SubstExprs(ArrayRef<Expr *> Exprs, bool IsCall,
8104  const MultiLevelTemplateArgumentList &TemplateArgs,
8105  SmallVectorImpl<Expr *> &Outputs);
8106 
8107  StmtResult SubstStmt(Stmt *S,
8108  const MultiLevelTemplateArgumentList &TemplateArgs);
8109 
8111  SubstTemplateParams(TemplateParameterList *Params, DeclContext *Owner,
8112  const MultiLevelTemplateArgumentList &TemplateArgs);
8113 
8114  Decl *SubstDecl(Decl *D, DeclContext *Owner,
8115  const MultiLevelTemplateArgumentList &TemplateArgs);
8116 
8117  ExprResult SubstInitializer(Expr *E,
8118  const MultiLevelTemplateArgumentList &TemplateArgs,
8119  bool CXXDirectInit);
8120 
8121  bool
8122  SubstBaseSpecifiers(CXXRecordDecl *Instantiation,
8123  CXXRecordDecl *Pattern,
8124  const MultiLevelTemplateArgumentList &TemplateArgs);
8125 
8126  bool
8127  InstantiateClass(SourceLocation PointOfInstantiation,
8128  CXXRecordDecl *Instantiation, CXXRecordDecl *Pattern,
8129  const MultiLevelTemplateArgumentList &TemplateArgs,
8131  bool Complain = true);
8132 
8133  bool InstantiateEnum(SourceLocation PointOfInstantiation,
8134  EnumDecl *Instantiation, EnumDecl *Pattern,
8135  const MultiLevelTemplateArgumentList &TemplateArgs,
8137 
8138  bool InstantiateInClassInitializer(
8139  SourceLocation PointOfInstantiation, FieldDecl *Instantiation,
8140  FieldDecl *Pattern, const MultiLevelTemplateArgumentList &TemplateArgs);
8141 
8143  const Attr *TmplAttr;
8145  Decl *NewDecl;
8146 
8148  Decl *D)
8149  : TmplAttr(A), Scope(S), NewDecl(D)
8150  { }
8151  };
8153 
8154  void InstantiateAttrs(const MultiLevelTemplateArgumentList &TemplateArgs,
8155  const Decl *Pattern, Decl *Inst,
8156  LateInstantiatedAttrVec *LateAttrs = nullptr,
8157  LocalInstantiationScope *OuterMostScope = nullptr);
8158 
8159  void
8160  InstantiateAttrsForDecl(const MultiLevelTemplateArgumentList &TemplateArgs,
8161  const Decl *Pattern, Decl *Inst,
8162  LateInstantiatedAttrVec *LateAttrs = nullptr,
8163  LocalInstantiationScope *OuterMostScope = nullptr);
8164 
8165  bool usesPartialOrExplicitSpecialization(
8166  SourceLocation Loc, ClassTemplateSpecializationDecl *ClassTemplateSpec);
8167 
8168  bool
8169  InstantiateClassTemplateSpecialization(SourceLocation PointOfInstantiation,
8170  ClassTemplateSpecializationDecl *ClassTemplateSpec,
8172  bool Complain = true);
8173 
8174  void InstantiateClassMembers(SourceLocation PointOfInstantiation,
8175  CXXRecordDecl *Instantiation,
8176  const MultiLevelTemplateArgumentList &TemplateArgs,
8178 
8179  void InstantiateClassTemplateSpecializationMembers(
8180  SourceLocation PointOfInstantiation,
8181  ClassTemplateSpecializationDecl *ClassTemplateSpec,
8183 
8185  SubstNestedNameSpecifierLoc(NestedNameSpecifierLoc NNS,
8186  const MultiLevelTemplateArgumentList &TemplateArgs);
8187 
8189  SubstDeclarationNameInfo(const DeclarationNameInfo &NameInfo,
8190  const MultiLevelTemplateArgumentList &TemplateArgs);
8191  TemplateName
8192  SubstTemplateName(NestedNameSpecifierLoc QualifierLoc, TemplateName Name,
8193  SourceLocation Loc,
8194  const MultiLevelTemplateArgumentList &TemplateArgs);
8195  bool Subst(const TemplateArgumentLoc *Args, unsigned NumArgs,
8196  TemplateArgumentListInfo &Result,
8197  const MultiLevelTemplateArgumentList &TemplateArgs);
8198 
8199  void InstantiateExceptionSpec(SourceLocation PointOfInstantiation,
8200  FunctionDecl *Function);
8201  FunctionDecl *InstantiateFunctionDeclaration(FunctionTemplateDecl *FTD,
8202  const TemplateArgumentList *Args,
8203  SourceLocation Loc);
8204  void InstantiateFunctionDefinition(SourceLocation PointOfInstantiation,
8205  FunctionDecl *Function,
8206  bool Recursive = false,
8207  bool DefinitionRequired = false,
8208  bool AtEndOfTU = false);
8209  VarTemplateSpecializationDecl *BuildVarTemplateInstantiation(
8210  VarTemplateDecl *VarTemplate, VarDecl *FromVar,
8211  const TemplateArgumentList &TemplateArgList,
8212  const TemplateArgumentListInfo &TemplateArgsInfo,
8214  SourceLocation PointOfInstantiation, void *InsertPos,
8215  LateInstantiatedAttrVec *LateAttrs = nullptr,
8216  LocalInstantiationScope *StartingScope = nullptr);
8217  VarTemplateSpecializationDecl *CompleteVarTemplateSpecializationDecl(
8218  VarTemplateSpecializationDecl *VarSpec, VarDecl *PatternDecl,
8219  const MultiLevelTemplateArgumentList &TemplateArgs);
8220  void
8221  BuildVariableInstantiation(VarDecl *NewVar, VarDecl *OldVar,
8222  const MultiLevelTemplateArgumentList &TemplateArgs,
8223  LateInstantiatedAttrVec *LateAttrs,
8224  DeclContext *Owner,
8225  LocalInstantiationScope *StartingScope,
8226  bool InstantiatingVarTemplate = false,
8227  VarTemplateSpecializationDecl *PrevVTSD = nullptr);
8228  void InstantiateVariableInitializer(
8229  VarDecl *Var, VarDecl *OldVar,
8230  const MultiLevelTemplateArgumentList &TemplateArgs);
8231  void InstantiateVariableDefinition(SourceLocation PointOfInstantiation,
8232  VarDecl *Var, bool Recursive = false,
8233  bool DefinitionRequired = false,
8234  bool AtEndOfTU = false);
8235 
8236  void InstantiateMemInitializers(CXXConstructorDecl *New,
8237  const CXXConstructorDecl *Tmpl,
8238  const MultiLevelTemplateArgumentList &TemplateArgs);
8239 
8240  NamedDecl *FindInstantiatedDecl(SourceLocation Loc, NamedDecl *D,
8241  const MultiLevelTemplateArgumentList &TemplateArgs,
8242  bool FindingInstantiatedContext = false);
8243  DeclContext *FindInstantiatedContext(SourceLocation Loc, DeclContext *DC,
8244  const MultiLevelTemplateArgumentList &TemplateArgs);
8245 
8246  // Objective-C declarations.
8248  OCK_None = -1,
8249  OCK_Interface = 0,
8254  OCK_CategoryImplementation
8255  };
8256  ObjCContainerKind getObjCContainerKind() const;
8257 
8258  DeclResult actOnObjCTypeParam(Scope *S,
8259  ObjCTypeParamVariance variance,
8260  SourceLocation varianceLoc,
8261  unsigned index,
8262  IdentifierInfo *paramName,
8263  SourceLocation paramLoc,
8264  SourceLocation colonLoc,
8265  ParsedType typeBound);
8266 
8267  ObjCTypeParamList *actOnObjCTypeParamList(Scope *S, SourceLocation lAngleLoc,
8268  ArrayRef<Decl *> typeParams,
8269  SourceLocation rAngleLoc);
8270  void popObjCTypeParamList(Scope *S, ObjCTypeParamList *typeParamList);
8271 
8272  Decl *ActOnStartClassInterface(
8273  Scope *S, SourceLocation AtInterfaceLoc, IdentifierInfo *ClassName,
8274  SourceLocation ClassLoc, ObjCTypeParamList *typeParamList,
8275  IdentifierInfo *SuperName, SourceLocation SuperLoc,
8276  ArrayRef<ParsedType> SuperTypeArgs, SourceRange SuperTypeArgsRange,
8277  Decl *const *ProtoRefs, unsigned NumProtoRefs,
8278  const SourceLocation *ProtoLocs, SourceLocation EndProtoLoc,
8279  const ParsedAttributesView &AttrList);
8280 
8281  void ActOnSuperClassOfClassInterface(Scope *S,
8282  SourceLocation AtInterfaceLoc,
8283  ObjCInterfaceDecl *IDecl,
8284  IdentifierInfo *ClassName,
8285  SourceLocation ClassLoc,
8286  IdentifierInfo *SuperName,
8287  SourceLocation SuperLoc,
8288  ArrayRef<ParsedType> SuperTypeArgs,
8289  SourceRange SuperTypeArgsRange);
8290 
8291  void ActOnTypedefedProtocols(SmallVectorImpl<Decl *> &ProtocolRefs,
8292  SmallVectorImpl<SourceLocation> &ProtocolLocs,
8293  IdentifierInfo *SuperName,
8294  SourceLocation SuperLoc);
8295 
8296  Decl *ActOnCompatibilityAlias(
8297  SourceLocation AtCompatibilityAliasLoc,
8298  IdentifierInfo *AliasName, SourceLocation AliasLocation,
8299  IdentifierInfo *ClassName, SourceLocation ClassLocation);
8300 
8301  bool CheckForwardProtocolDeclarationForCircularDependency(
8302  IdentifierInfo *PName,
8303  SourceLocation &PLoc, SourceLocation PrevLoc,
8304  const ObjCList<ObjCProtocolDecl> &PList);
8305 
8306  Decl *ActOnStartProtocolInterface(
8307  SourceLocation AtProtoInterfaceLoc, IdentifierInfo *ProtocolName,
8308  SourceLocation ProtocolLoc, Decl *const *ProtoRefNames,
8309  unsigned NumProtoRefs, const SourceLocation *ProtoLocs,
8310  SourceLocation EndProtoLoc, const ParsedAttributesView &AttrList);
8311 
8312  Decl *ActOnStartCategoryInterface(
8313  SourceLocation AtInterfaceLoc, IdentifierInfo *ClassName,
8314  SourceLocation ClassLoc, ObjCTypeParamList *typeParamList,
8315  IdentifierInfo *CategoryName, SourceLocation CategoryLoc,
8316  Decl *const *ProtoRefs, unsigned NumProtoRefs,
8317  const SourceLocation *ProtoLocs, SourceLocation EndProtoLoc,
8318  const ParsedAttributesView &AttrList);
8319 
8320  Decl *ActOnStartClassImplementation(SourceLocation AtClassImplLoc,
8321  IdentifierInfo *ClassName,
8322  SourceLocation ClassLoc,
8323  IdentifierInfo *SuperClassname,
8324  SourceLocation SuperClassLoc,
8325  const ParsedAttributesView &AttrList);
8326 
8327  Decl *ActOnStartCategoryImplementation(SourceLocation AtCatImplLoc,
8328  IdentifierInfo *ClassName,
8329  SourceLocation ClassLoc,
8330  IdentifierInfo *CatName,
8331  SourceLocation CatLoc,
8332  const ParsedAttributesView &AttrList);
8333 
8334  DeclGroupPtrTy ActOnFinishObjCImplementation(Decl *ObjCImpDecl,
8335  ArrayRef<Decl *> Decls);
8336 
8337  DeclGroupPtrTy ActOnForwardClassDeclaration(SourceLocation Loc,
8338  IdentifierInfo **IdentList,
8339  SourceLocation *IdentLocs,
8340  ArrayRef<ObjCTypeParamList *> TypeParamLists,
8341  unsigned NumElts);
8342 
8343  DeclGroupPtrTy
8344  ActOnForwardProtocolDeclaration(SourceLocation AtProtoclLoc,
8345  ArrayRef<IdentifierLocPair> IdentList,
8346  const ParsedAttributesView &attrList);
8347 
8348  void FindProtocolDeclaration(bool WarnOnDeclarations, bool ForObjCContainer,
8349  ArrayRef<IdentifierLocPair> ProtocolId,
8350  SmallVectorImpl<Decl *> &Protocols);
8351 
8352  void DiagnoseTypeArgsAndProtocols(IdentifierInfo *ProtocolId,
8353  SourceLocation ProtocolLoc,
8354  IdentifierInfo *TypeArgId,
8355  SourceLocation TypeArgLoc,
8356  bool SelectProtocolFirst = false);
8357 
8358  /// Given a list of identifiers (and their locations), resolve the
8359  /// names to either Objective-C protocol qualifiers or type
8360  /// arguments, as appropriate.
8361  void actOnObjCTypeArgsOrProtocolQualifiers(
8362  Scope *S,
8363  ParsedType baseType,
8364  SourceLocation lAngleLoc,
8365  ArrayRef<IdentifierInfo *> identifiers,
8366  ArrayRef<SourceLocation> identifierLocs,
8367  SourceLocation rAngleLoc,
8368  SourceLocation &typeArgsLAngleLoc,
8369  SmallVectorImpl<ParsedType> &typeArgs,
8370  SourceLocation &typeArgsRAngleLoc,
8371  SourceLocation &protocolLAngleLoc,
8372  SmallVectorImpl<Decl *> &protocols,
8373  SourceLocation &protocolRAngleLoc,
8374  bool warnOnIncompleteProtocols);
8375 
8376  /// Build a an Objective-C protocol-qualified 'id' type where no
8377  /// base type was specified.
8378  TypeResult actOnObjCProtocolQualifierType(
8379  SourceLocation lAngleLoc,
8380  ArrayRef<Decl *> protocols,
8381  ArrayRef<SourceLocation> protocolLocs,
8382  SourceLocation rAngleLoc);
8383 
8384  /// Build a specialized and/or protocol-qualified Objective-C type.
8385  TypeResult actOnObjCTypeArgsAndProtocolQualifiers(
8386  Scope *S,
8387  SourceLocation Loc,
8388  ParsedType BaseType,
8389  SourceLocation TypeArgsLAngleLoc,
8390  ArrayRef<ParsedType> TypeArgs,
8391  SourceLocation TypeArgsRAngleLoc,
8392  SourceLocation ProtocolLAngleLoc,
8393  ArrayRef<Decl *> Protocols,
8394  ArrayRef<SourceLocation> ProtocolLocs,
8395  SourceLocation ProtocolRAngleLoc);
8396 
8397  /// Build an Objective-C type parameter type.
8398  QualType BuildObjCTypeParamType(const ObjCTypeParamDecl *Decl,
8399  SourceLocation ProtocolLAngleLoc,
8400  ArrayRef<ObjCProtocolDecl *> Protocols,
8401  ArrayRef<SourceLocation> ProtocolLocs,
8402  SourceLocation ProtocolRAngleLoc,
8403  bool FailOnError = false);
8404 
8405  /// Build an Objective-C object pointer type.
8406  QualType BuildObjCObjectType(QualType BaseType,
8407  SourceLocation Loc,
8408  SourceLocation TypeArgsLAngleLoc,
8409  ArrayRef<TypeSourceInfo *> TypeArgs,
8410  SourceLocation TypeArgsRAngleLoc,
8411  SourceLocation ProtocolLAngleLoc,
8412  ArrayRef<ObjCProtocolDecl *> Protocols,
8413  ArrayRef<SourceLocation> ProtocolLocs,
8414  SourceLocation ProtocolRAngleLoc,
8415  bool FailOnError = false);
8416 
8417  /// Ensure attributes are consistent with type.
8418  /// \param [in, out] Attributes The attributes to check; they will
8419  /// be modified to be consistent with \p PropertyTy.
8420  void CheckObjCPropertyAttributes(Decl *PropertyPtrTy,
8421  SourceLocation Loc,
8422  unsigned &Attributes,
8423  bool propertyInPrimaryClass);
8424 
8425  /// Process the specified property declaration and create decls for the
8426  /// setters and getters as needed.
8427  /// \param property The property declaration being processed
8428  void ProcessPropertyDecl(ObjCPropertyDecl *property);
8429 
8430 
8431  void DiagnosePropertyMismatch(ObjCPropertyDecl *Property,
8432  ObjCPropertyDecl *SuperProperty,
8433  const IdentifierInfo *Name,
8434  bool OverridingProtocolProperty);
8435 
8436  void DiagnoseClassExtensionDupMethods(ObjCCategoryDecl *CAT,
8437  ObjCInterfaceDecl *ID);
8438 
8439  Decl *ActOnAtEnd(Scope *S, SourceRange AtEnd,
8440  ArrayRef<Decl *> allMethods = None,
8441  ArrayRef<DeclGroupPtrTy> allTUVars = None);
8442 
8443  Decl *ActOnProperty(Scope *S, SourceLocation AtLoc,
8444  SourceLocation LParenLoc,
8445  FieldDeclarator &FD, ObjCDeclSpec &ODS,
8446  Selector GetterSel, Selector SetterSel,
8447  tok::ObjCKeywordKind MethodImplKind,
8448  DeclContext *lexicalDC = nullptr);
8449 
8450  Decl *ActOnPropertyImplDecl(Scope *S,
8451  SourceLocation AtLoc,
8452  SourceLocation PropertyLoc,
8453  bool ImplKind,
8454  IdentifierInfo *PropertyId,
8455  IdentifierInfo *PropertyIvar,
8456  SourceLocation PropertyIvarLoc,
8457  ObjCPropertyQueryKind QueryKind);
8458 
8465  OSMK_NonRetainingInit
8466  };
8467 
8468  struct ObjCArgInfo {
8471  // The Type is null if no type was specified, and the DeclSpec is invalid
8472  // in this case.
8475 
8476  /// ArgAttrs - Attribute list for this argument.
8478  };
8479 
8480  Decl *ActOnMethodDeclaration(
8481  Scope *S,
8482  SourceLocation BeginLoc, // location of the + or -.
8483  SourceLocation EndLoc, // location of the ; or {.
8484  tok::TokenKind MethodType, ObjCDeclSpec &ReturnQT, ParsedType ReturnType,
8485  ArrayRef<SourceLocation> SelectorLocs, Selector Sel,
8486  // optional arguments. The number of types/arguments is obtained
8487  // from the Sel.getNumArgs().
8488  ObjCArgInfo *ArgInfo, DeclaratorChunk::ParamInfo *CParamInfo,
8489  unsigned CNumArgs, // c-style args
8490  const ParsedAttributesView &AttrList, tok::ObjCKeywordKind MethodImplKind,
8491  bool isVariadic, bool MethodDefinition);
8492 
8493  ObjCMethodDecl *LookupMethodInQualifiedType(Selector Sel,
8494  const ObjCObjectPointerType *OPT,
8495  bool IsInstance);
8496  ObjCMethodDecl *LookupMethodInObjectType(Selector Sel, QualType Ty,
8497  bool IsInstance);
8498 
8499  bool CheckARCMethodDecl(ObjCMethodDecl *method);
8500  bool inferObjCARCLifetime(ValueDecl *decl);
8501 
8502  ExprResult
8503  HandleExprPropertyRefExpr(const ObjCObjectPointerType *OPT,
8504  Expr *BaseExpr,
8505  SourceLocation OpLoc,
8506  DeclarationName MemberName,
8507  SourceLocation MemberLoc,
8508  SourceLocation SuperLoc, QualType SuperType,
8509  bool Super);
8510 
8511  ExprResult
8512  ActOnClassPropertyRefExpr(IdentifierInfo &receiverName,
8513  IdentifierInfo &propertyName,
8514  SourceLocation receiverNameLoc,
8515  SourceLocation propertyNameLoc);
8516 
8517  ObjCMethodDecl *tryCaptureObjCSelf(SourceLocation Loc);
8518 
8519  /// Describes the kind of message expression indicated by a message
8520  /// send that starts with an identifier.
8522  /// The message is sent to 'super'.
8524  /// The message is an instance message.
8526  /// The message is a class message, and the identifier is a type
8527  /// name.
8528  ObjCClassMessage
8529  };
8530 
8531  ObjCMessageKind getObjCMessageKind(Scope *S,
8532  IdentifierInfo *Name,
8533  SourceLocation NameLoc,
8534  bool IsSuper,
8535  bool HasTrailingDot,
8536  ParsedType &ReceiverType);
8537 
8538  ExprResult ActOnSuperMessage(Scope *S, SourceLocation SuperLoc,
8539  Selector Sel,
8540  SourceLocation LBracLoc,
8541  ArrayRef<SourceLocation> SelectorLocs,
8542  SourceLocation RBracLoc,
8543  MultiExprArg Args);
8544 
8545  ExprResult BuildClassMessage(TypeSourceInfo *ReceiverTypeInfo,
8546  QualType ReceiverType,
8547  SourceLocation SuperLoc,
8548  Selector Sel,
8549  ObjCMethodDecl *Method,
8550  SourceLocation LBracLoc,
8551  ArrayRef<SourceLocation> SelectorLocs,
8552  SourceLocation RBracLoc,
8553  MultiExprArg Args,
8554  bool isImplicit = false);
8555 
8556  ExprResult BuildClassMessageImplicit(QualType ReceiverType,
8557  bool isSuperReceiver,
8558  SourceLocation Loc,
8559  Selector Sel,
8560  ObjCMethodDecl *Method,
8561  MultiExprArg Args);
8562 
8563  ExprResult ActOnClassMessage(Scope *S,
8564  ParsedType Receiver,
8565  Selector Sel,
8566  SourceLocation LBracLoc,
8567  ArrayRef<SourceLocation> SelectorLocs,
8568  SourceLocation RBracLoc,
8569  MultiExprArg Args);
8570 
8571  ExprResult BuildInstanceMessage(Expr *Receiver,
8572  QualType ReceiverType,
8573  SourceLocation SuperLoc,
8574  Selector Sel,
8575  ObjCMethodDecl *Method,
8576  SourceLocation LBracLoc,
8577  ArrayRef<SourceLocation> SelectorLocs,
8578  SourceLocation RBracLoc,
8579  MultiExprArg Args,
8580  bool isImplicit = false);
8581 
8582  ExprResult BuildInstanceMessageImplicit(Expr *Receiver,
8583  QualType ReceiverType,
8584  SourceLocation Loc,
8585  Selector Sel,
8586  ObjCMethodDecl *Method,
8587  MultiExprArg Args);
8588 
8589  ExprResult ActOnInstanceMessage(Scope *S,
8590  Expr *Receiver,
8591  Selector Sel,
8592  SourceLocation LBracLoc,
8593  ArrayRef<SourceLocation> SelectorLocs,
8594  SourceLocation RBracLoc,
8595  MultiExprArg Args);
8596 
8597  ExprResult BuildObjCBridgedCast(SourceLocation LParenLoc,
8598  ObjCBridgeCastKind Kind,
8599  SourceLocation BridgeKeywordLoc,
8600  TypeSourceInfo *TSInfo,
8601  Expr *SubExpr);
8602 
8603  ExprResult ActOnObjCBridgedCast(Scope *S,
8604  SourceLocation LParenLoc,
8605  ObjCBridgeCastKind Kind,
8606  SourceLocation BridgeKeywordLoc,
8607  ParsedType Type,
8608  SourceLocation RParenLoc,
8609  Expr *SubExpr);
8610 
8611  void CheckTollFreeBridgeCast(QualType castType, Expr *castExpr);
8612 
8613  void CheckObjCBridgeRelatedCast(QualType castType, Expr *castExpr);
8614 
8615  bool CheckTollFreeBridgeStaticCast(QualType castType, Expr *castExpr,
8616  CastKind &Kind);
8617 
8618  bool checkObjCBridgeRelatedComponents(SourceLocation Loc,
8619  QualType DestType, QualType SrcType,
8620  ObjCInterfaceDecl *&RelatedClass,
8621  ObjCMethodDecl *&ClassMethod,
8622  ObjCMethodDecl *&InstanceMethod,
8623  TypedefNameDecl *&TDNDecl,
8624  bool CfToNs, bool Diagnose = true);
8625 
8626  bool CheckObjCBridgeRelatedConversions(SourceLocation Loc,
8627  QualType DestType, QualType SrcType,
8628  Expr *&SrcExpr, bool Diagnose = true);
8629 
8630  bool ConversionToObjCStringLiteralCheck(QualType DstType, Expr *&SrcExpr,
8631  bool Diagnose = true);
8632 
8633  bool checkInitMethod(ObjCMethodDecl *method, QualType receiverTypeIfCall);
8634 
8635  /// Check whether the given new method is a valid override of the
8636  /// given overridden method, and set any properties that should be inherited.
8637  void CheckObjCMethodOverride(ObjCMethodDecl *NewMethod,
8638  const ObjCMethodDecl *Overridden);
8639 
8640  /// Describes the compatibility of a result type with its method.
8644  RTC_Unknown
8645  };
8646 
8647  void CheckObjCMethodOverrides(ObjCMethodDecl *ObjCMethod,
8648  ObjCInterfaceDecl *CurrentClass,
8650 
8652  POAK_Native, // #pragma options align=native
8653  POAK_Natural, // #pragma options align=natural
8654  POAK_Packed, // #pragma options align=packed
8655  POAK_Power, // #pragma options align=power
8656  POAK_Mac68k, // #pragma options align=mac68k
8657  POAK_Reset // #pragma options align=reset
8658  };
8659 
8660  /// ActOnPragmaClangSection - Called on well formed \#pragma clang section
8661  void ActOnPragmaClangSection(SourceLocation PragmaLoc,
8662  PragmaClangSectionAction Action,
8663  PragmaClangSectionKind SecKind, StringRef SecName);
8664 
8665  /// ActOnPragmaOptionsAlign - Called on well formed \#pragma options align.
8666  void ActOnPragmaOptionsAlign(PragmaOptionsAlignKind Kind,
8667  SourceLocation PragmaLoc);
8668 
8669  /// ActOnPragmaPack - Called on well formed \#pragma pack(...).
8670  void ActOnPragmaPack(SourceLocation PragmaLoc, PragmaMsStackAction Action,
8671  StringRef SlotLabel, Expr *Alignment);
8672 
8674  NonDefaultStateAtInclude,
8675  ChangedStateAtExit
8676  };
8677 
8678  void DiagnoseNonDefaultPragmaPack(PragmaPackDiagnoseKind Kind,
8679  SourceLocation IncludeLoc);
8680  void DiagnoseUnterminatedPragmaPack();
8681 
8682  /// ActOnPragmaMSStruct - Called on well formed \#pragma ms_struct [on|off].
8683  void ActOnPragmaMSStruct(PragmaMSStructKind Kind);
8684 
8685  /// ActOnPragmaMSComment - Called on well formed
8686  /// \#pragma comment(kind, "arg").
8687  void ActOnPragmaMSComment(SourceLocation CommentLoc, PragmaMSCommentKind Kind,
8688  StringRef Arg);
8689 
8690  /// ActOnPragmaMSPointersToMembers - called on well formed \#pragma
8691  /// pointers_to_members(representation method[, general purpose
8692  /// representation]).
8693  void ActOnPragmaMSPointersToMembers(
8695  SourceLocation PragmaLoc);
8696 
8697  /// Called on well formed \#pragma vtordisp().
8698  void ActOnPragmaMSVtorDisp(PragmaMsStackAction Action,
8699  SourceLocation PragmaLoc,
8700  MSVtorDispAttr::Mode Value);
8701 
8707  };
8708 
8709  bool UnifySection(StringRef SectionName,
8710  int SectionFlags,
8711  DeclaratorDecl *TheDecl);
8712  bool UnifySection(StringRef SectionName,
8713  int SectionFlags,
8714  SourceLocation PragmaSectionLocation);
8715 
8716  /// Called on well formed \#pragma bss_seg/data_seg/const_seg/code_seg.
8717  void ActOnPragmaMSSeg(SourceLocation PragmaLocation,
8718  PragmaMsStackAction Action,
8719  llvm::StringRef StackSlotLabel,
8720  StringLiteral *SegmentName,
8721  llvm::StringRef PragmaName);
8722 
8723  /// Called on well formed \#pragma section().
8724  void ActOnPragmaMSSection(SourceLocation PragmaLocation,
8725  int SectionFlags, StringLiteral *SegmentName);
8726 
8727  /// Called on well-formed \#pragma init_seg().
8728  void ActOnPragmaMSInitSeg(SourceLocation PragmaLocation,
8729  StringLiteral *SegmentName);
8730 
8731  /// Called on #pragma clang __debug dump II
8732  void ActOnPragmaDump(Scope *S, SourceLocation Loc, IdentifierInfo *II);
8733 
8734  /// ActOnPragmaDetectMismatch - Call on well-formed \#pragma detect_mismatch
8735  void ActOnPragmaDetectMismatch(SourceLocation Loc, StringRef Name,
8736  StringRef Value);
8737 
8738  /// ActOnPragmaUnused - Called on well-formed '\#pragma unused'.
8739  void ActOnPragmaUnused(const Token &Identifier,
8740  Scope *curScope,
8741  SourceLocation PragmaLoc);
8742 
8743  /// ActOnPragmaVisibility - Called on well formed \#pragma GCC visibility... .
8744  void ActOnPragmaVisibility(const IdentifierInfo* VisType,
8745  SourceLocation PragmaLoc);
8746 
8747  NamedDecl *DeclClonePragmaWeak(NamedDecl *ND, IdentifierInfo *II,
8748  SourceLocation Loc);
8749  void DeclApplyPragmaWeak(Scope *S, NamedDecl *ND, WeakInfo &W);
8750 
8751  /// ActOnPragmaWeakID - Called on well formed \#pragma weak ident.
8752  void ActOnPragmaWeakID(IdentifierInfo* WeakName,
8753  SourceLocation PragmaLoc,
8754  SourceLocation WeakNameLoc);
8755 
8756  /// ActOnPragmaRedefineExtname - Called on well formed
8757  /// \#pragma redefine_extname oldname newname.
8758  void ActOnPragmaRedefineExtname(IdentifierInfo* WeakName,
8759  IdentifierInfo* AliasName,
8760  SourceLocation PragmaLoc,
8761  SourceLocation WeakNameLoc,
8762  SourceLocation AliasNameLoc);
8763 
8764  /// ActOnPragmaWeakAlias - Called on well formed \#pragma weak ident = ident.
8765  void ActOnPragmaWeakAlias(IdentifierInfo* WeakName,
8766  IdentifierInfo* AliasName,
8767  SourceLocation PragmaLoc,
8768  SourceLocation WeakNameLoc,
8769  SourceLocation AliasNameLoc);
8770 
8771  /// ActOnPragmaFPContract - Called on well formed
8772  /// \#pragma {STDC,OPENCL} FP_CONTRACT and
8773  /// \#pragma clang fp contract
8774  void ActOnPragmaFPContract(LangOptions::FPContractModeKind FPC);
8775 
8776  /// ActOnPragmaFenvAccess - Called on well formed
8777  /// \#pragma STDC FENV_ACCESS
8778  void ActOnPragmaFEnvAccess(LangOptions::FEnvAccessModeKind FPC);
8779 
8780  /// AddAlignmentAttributesForRecord - Adds any needed alignment attributes to
8781  /// a the record decl, to handle '\#pragma pack' and '\#pragma options align'.
8782  void AddAlignmentAttributesForRecord(RecordDecl *RD);
8783 
8784  /// AddMsStructLayoutForRecord - Adds ms_struct layout attribute to record.
8785  void AddMsStructLayoutForRecord(RecordDecl *RD);
8786 
8787  /// FreePackedContext - Deallocate and null out PackContext.
8788  void FreePackedContext();
8789 
8790  /// PushNamespaceVisibilityAttr - Note that we've entered a
8791  /// namespace with a visibility attribute.
8792  void PushNamespaceVisibilityAttr(const VisibilityAttr *Attr,
8793  SourceLocation Loc);
8794 
8795  /// AddPushedVisibilityAttribute - If '\#pragma GCC visibility' was used,
8796  /// add an appropriate visibility attribute.
8797  void AddPushedVisibilityAttribute(Decl *RD);
8798 
8799  /// PopPragmaVisibility - Pop the top element of the visibility stack; used
8800  /// for '\#pragma GCC visibility' and visibility attributes on namespaces.
8801  void PopPragmaVisibility(bool IsNamespaceEnd, SourceLocation EndLoc);
8802 
8803  /// FreeVisContext - Deallocate and null out VisContext.
8804  void FreeVisContext();
8805 
8806  /// AddCFAuditedAttribute - Check whether we're currently within
8807  /// '\#pragma clang arc_cf_code_audited' and, if so, consider adding
8808  /// the appropriate attribute.
8809  void AddCFAuditedAttribute(Decl *D);
8810 
8811  void ActOnPragmaAttributeAttribute(ParsedAttr &Attribute,
8812  SourceLocation PragmaLoc,
8814  void ActOnPragmaAttributeEmptyPush(SourceLocation PragmaLoc,
8815  const IdentifierInfo *Namespace);
8816 
8817  /// Called on well-formed '\#pragma clang attribute pop'.
8818  void ActOnPragmaAttributePop(SourceLocation PragmaLoc,
8819  const IdentifierInfo *Namespace);
8820 
8821  /// Adds the attributes that have been specified using the
8822  /// '\#pragma clang attribute push' directives to the given declaration.
8823  void AddPragmaAttributes(Scope *S, Decl *D);
8824 
8825  void DiagnoseUnterminatedPragmaAttribute();
8826 
8827  /// Called on well formed \#pragma clang optimize.
8828  void ActOnPragmaOptimize(bool On, SourceLocation PragmaLoc);
8829 
8830  /// Get the location for the currently active "\#pragma clang optimize
8831  /// off". If this location is invalid, then the state of the pragma is "on".
8833  return OptimizeOffPragmaLocation;
8834  }
8835 
8836  /// Only called on function definitions; if there is a pragma in scope
8837  /// with the effect of a range-based optnone, consider marking the function
8838  /// with attribute optnone.
8839  void AddRangeBasedOptnone(FunctionDecl *FD);
8840 
8841  /// Adds the 'optnone' attribute to the function declaration if there
8842  /// are no conflicts; Loc represents the location causing the 'optnone'
8843  /// attribute to be added (usually because of a pragma).
8844  void AddOptnoneAttributeIfNoConflicts(FunctionDecl *FD, SourceLocation Loc);
8845 
8846  /// AddAlignedAttr - Adds an aligned attribute to a particular declaration.
8847  void AddAlignedAttr(SourceRange AttrRange, Decl *D, Expr *E,
8848  unsigned SpellingListIndex, bool IsPackExpansion);
8849  void AddAlignedAttr(SourceRange AttrRange, Decl *D, TypeSourceInfo *T,
8850  unsigned SpellingListIndex, bool IsPackExpansion);
8851 
8852  /// AddAssumeAlignedAttr - Adds an assume_aligned attribute to a particular
8853  /// declaration.
8854  void AddAssumeAlignedAttr(SourceRange AttrRange, Decl *D, Expr *E, Expr *OE,
8855  unsigned SpellingListIndex);
8856 
8857  /// AddAllocAlignAttr - Adds an alloc_align attribute to a particular
8858  /// declaration.
8859  void AddAllocAlignAttr(SourceRange AttrRange, Decl *D, Expr *ParamExpr,
8860  unsigned SpellingListIndex);
8861 
8862  /// AddAlignValueAttr - Adds an align_value attribute to a particular
8863  /// declaration.
8864  void AddAlignValueAttr(SourceRange AttrRange, Decl *D, Expr *E,
8865  unsigned SpellingListIndex);
8866 
8867  /// AddLaunchBoundsAttr - Adds a launch_bounds attribute to a particular
8868  /// declaration.
8869  void AddLaunchBoundsAttr(SourceRange AttrRange, Decl *D, Expr *MaxThreads,
8870  Expr *MinBlocks, unsigned SpellingListIndex);
8871 
8872  /// AddModeAttr - Adds a mode attribute to a particular declaration.
8873  void AddModeAttr(SourceRange AttrRange, Decl *D, IdentifierInfo *Name,
8874  unsigned SpellingListIndex, bool InInstantiation = false);
8875 
8876  void AddParameterABIAttr(SourceRange AttrRange, Decl *D,
8877  ParameterABI ABI, unsigned SpellingListIndex);
8878 
8879  enum class RetainOwnershipKind {NS, CF, OS};
8880  void AddXConsumedAttr(Decl *D, SourceRange SR, unsigned SpellingIndex,
8881  RetainOwnershipKind K, bool IsTemplateInstantiation);
8882 
8883  /// addAMDGPUFlatWorkGroupSizeAttr - Adds an amdgpu_flat_work_group_size
8884  /// attribute to a particular declaration.
8885  void addAMDGPUFlatWorkGroupSizeAttr(SourceRange AttrRange, Decl *D, Expr *Min,
8886  Expr *Max, unsigned SpellingListIndex);
8887 
8888  /// addAMDGPUWavePersEUAttr - Adds an amdgpu_waves_per_eu attribute to a
8889  /// particular declaration.
8890  void addAMDGPUWavesPerEUAttr(SourceRange AttrRange, Decl *D, Expr *Min,
8891  Expr *Max, unsigned SpellingListIndex);
8892 
8893  bool checkNSReturnsRetainedReturnType(SourceLocation loc, QualType type);
8894 
8895  //===--------------------------------------------------------------------===//
8896  // C++ Coroutines TS
8897  //
8898  bool ActOnCoroutineBodyStart(Scope *S, SourceLocation KwLoc,
8899  StringRef Keyword);
8900  ExprResult ActOnCoawaitExpr(Scope *S, SourceLocation KwLoc, Expr *E);
8901  ExprResult ActOnCoyieldExpr(Scope *S, SourceLocation KwLoc, Expr *E);
8902  StmtResult ActOnCoreturnStmt(Scope *S, SourceLocation KwLoc, Expr *E);
8903 
8904  ExprResult BuildResolvedCoawaitExpr(SourceLocation KwLoc, Expr *E,
8905  bool IsImplicit = false);
8906  ExprResult BuildUnresolvedCoawaitExpr(SourceLocation KwLoc, Expr *E,
8907  UnresolvedLookupExpr* Lookup);
8908  ExprResult BuildCoyieldExpr(SourceLocation KwLoc, Expr *E);
8909  StmtResult BuildCoreturnStmt(SourceLocation KwLoc, Expr *E,
8910  bool IsImplicit = false);
8911  StmtResult BuildCoroutineBodyStmt(CoroutineBodyStmt::CtorArgs);
8912  bool buildCoroutineParameterMoves(SourceLocation Loc);
8913  VarDecl *buildCoroutinePromise(SourceLocation Loc);
8914  void CheckCompletedCoroutineBody(FunctionDecl *FD, Stmt *&Body);
8915  ClassTemplateDecl *lookupCoroutineTraits(SourceLocation KwLoc,
8916  SourceLocation FuncLoc);
8917 
8918  //===--------------------------------------------------------------------===//
8919  // OpenCL extensions.
8920  //
8921 private:
8922  std::string CurrOpenCLExtension;
8923  /// Extensions required by an OpenCL type.
8924  llvm::DenseMap<const Type*, std::set<std::string>> OpenCLTypeExtMap;
8925  /// Extensions required by an OpenCL declaration.
8926  llvm::DenseMap<const Decl*, std::set<std::string>> OpenCLDeclExtMap;
8927 public:
8928  llvm::StringRef getCurrentOpenCLExtension() const {
8929  return CurrOpenCLExtension;
8930  }
8931 
8932  /// Check if a function declaration \p FD associates with any
8933  /// extensions present in OpenCLDeclExtMap and if so return the
8934  /// extension(s) name(s).
8935  std::string getOpenCLExtensionsFromDeclExtMap(FunctionDecl *FD);
8936 
8937  /// Check if a function type \p FT associates with any
8938  /// extensions present in OpenCLTypeExtMap and if so return the
8939  /// extension(s) name(s).
8940  std::string getOpenCLExtensionsFromTypeExtMap(FunctionType *FT);
8941 
8942  /// Find an extension in an appropriate extension map and return its name
8943  template<typename T, typename MapT>
8944  std::string getOpenCLExtensionsFromExtMap(T* FT, MapT &Map);
8945 
8946  void setCurrentOpenCLExtension(llvm::StringRef Ext) {
8947  CurrOpenCLExtension = Ext;
8948  }
8949 
8950  /// Set OpenCL extensions for a type which can only be used when these
8951  /// OpenCL extensions are enabled. If \p Exts is empty, do nothing.
8952  /// \param Exts A space separated list of OpenCL extensions.
8953  void setOpenCLExtensionForType(QualType T, llvm::StringRef Exts);
8954 
8955  /// Set OpenCL extensions for a declaration which can only be
8956  /// used when these OpenCL extensions are enabled. If \p Exts is empty, do
8957  /// nothing.
8958  /// \param Exts A space separated list of OpenCL extensions.
8959  void setOpenCLExtensionForDecl(Decl *FD, llvm::StringRef Exts);
8960 
8961  /// Set current OpenCL extensions for a type which can only be used
8962  /// when these OpenCL extensions are enabled. If current OpenCL extension is
8963  /// empty, do nothing.
8964  void setCurrentOpenCLExtensionForType(QualType T);
8965 
8966  /// Set current OpenCL extensions for a declaration which
8967  /// can only be used when these OpenCL extensions are enabled. If current
8968  /// OpenCL extension is empty, do nothing.
8969  void setCurrentOpenCLExtensionForDecl(Decl *FD);
8970 
8971  bool isOpenCLDisabledDecl(Decl *FD);
8972 
8973  /// Check if type \p T corresponding to declaration specifier \p DS
8974  /// is disabled due to required OpenCL extensions being disabled. If so,
8975  /// emit diagnostics.
8976  /// \return true if type is disabled.
8977  bool checkOpenCLDisabledTypeDeclSpec(const DeclSpec &DS, QualType T);
8978 
8979  /// Check if declaration \p D used by expression \p E
8980  /// is disabled due to required OpenCL extensions being disabled. If so,
8981  /// emit diagnostics.
8982  /// \return true if type is disabled.
8983  bool checkOpenCLDisabledDecl(const NamedDecl &D, const Expr &E);
8984 
8985  //===--------------------------------------------------------------------===//
8986  // OpenMP directives and clauses.
8987  //
8988 private:
8989  void *VarDataSharingAttributesStack;
8990  /// Number of nested '#pragma omp declare target' directives.
8991  unsigned DeclareTargetNestingLevel = 0;
8992  /// Initialization of data-sharing attributes stack.
8993  void InitDataSharingAttributesStack();
8994  void DestroyDataSharingAttributesStack();
8995  ExprResult
8996  VerifyPositiveIntegerConstantInClause(Expr *Op, OpenMPClauseKind CKind,
8997  bool StrictlyPositive = true);
8998  /// Returns OpenMP nesting level for current directive.
8999  unsigned getOpenMPNestingLevel() const;
9000 
9001  /// Adjusts the function scopes index for the target-based regions.
9002  void adjustOpenMPTargetScopeIndex(unsigned &FunctionScopesIndex,
9003  unsigned Level) const;
9004 
9005  /// Push new OpenMP function region for non-capturing function.
9006  void pushOpenMPFunctionRegion();
9007 
9008  /// Pop OpenMP function region for non-capturing function.
9009  void popOpenMPFunctionRegion(const sema::FunctionScopeInfo *OldFSI);
9010 
9011  /// Check whether we're allowed to call Callee from the current function.
9012  void checkOpenMPDeviceFunction(SourceLocation Loc, FunctionDecl *Callee);
9013 
9014  /// Check if the expression is allowed to be used in expressions for the
9015  /// OpenMP devices.
9016  void checkOpenMPDeviceExpr(const Expr *E);
9017 
9018  /// Checks if a type or a declaration is disabled due to the owning extension
9019  /// being disabled, and emits diagnostic messages if it is disabled.
9020  /// \param D type or declaration to be checked.
9021  /// \param DiagLoc source location for the diagnostic message.
9022  /// \param DiagInfo information to be emitted for the diagnostic message.
9023  /// \param SrcRange source range of the declaration.
9024  /// \param Map maps type or declaration to the extensions.
9025  /// \param Selector selects diagnostic message: 0 for type and 1 for
9026  /// declaration.
9027  /// \return true if the type or declaration is disabled.
9028  template <typename T, typename DiagLocT, typename DiagInfoT, typename MapT>
9029  bool checkOpenCLDisabledTypeOrDecl(T D, DiagLocT DiagLoc, DiagInfoT DiagInfo,
9030  MapT &Map, unsigned Selector = 0,
9031  SourceRange SrcRange = SourceRange());
9032 
9033 public:
9034  /// Function tries to capture lambda's captured variables in the OpenMP region
9035  /// before the original lambda is captured.
9036  void tryCaptureOpenMPLambdas(ValueDecl *V);
9037 
9038  /// Return true if the provided declaration \a VD should be captured by
9039  /// reference.
9040  /// \param Level Relative level of nested OpenMP construct for that the check
9041  /// is performed.
9042  bool isOpenMPCapturedByRef(const ValueDecl *D, unsigned Level) const;
9043 
9044  /// Check if the specified variable is used in one of the private
9045  /// clauses (private, firstprivate, lastprivate, reduction etc.) in OpenMP
9046  /// constructs.
9047  VarDecl *isOpenMPCapturedDecl(ValueDecl *D, bool CheckScopeInfo = false,
9048  unsigned StopAt = 0);
9049  ExprResult getOpenMPCapturedExpr(VarDecl *Capture, ExprValueKind VK,
9050  ExprObjectKind OK, SourceLocation Loc);
9051 
9052  /// If the current region is a loop-based region, mark the start of the loop
9053  /// construct.
9054  void startOpenMPLoop();
9055 
9056  /// Check if the specified variable is used in 'private' clause.
9057  /// \param Level Relative level of nested OpenMP construct for that the check
9058  /// is performed.
9059  bool isOpenMPPrivateDecl(const ValueDecl *D, unsigned Level) const;
9060 
9061  /// Sets OpenMP capture kind (OMPC_private, OMPC_firstprivate, OMPC_map etc.)
9062  /// for \p FD based on DSA for the provided corresponding captured declaration
9063  /// \p D.
9064  void setOpenMPCaptureKind(FieldDecl *FD, const ValueDecl *D, unsigned Level);
9065 
9066  /// Check if the specified variable is captured by 'target' directive.
9067  /// \param Level Relative level of nested OpenMP construct for that the check
9068  /// is performed.
9069  bool isOpenMPTargetCapturedDecl(const ValueDecl *D, unsigned Level) const;
9070 
9071  ExprResult PerformOpenMPImplicitIntegerConversion(SourceLocation OpLoc,
9072  Expr *Op);
9073  /// Called on start of new data sharing attribute block.
9074  void StartOpenMPDSABlock(OpenMPDirectiveKind K,
9075  const DeclarationNameInfo &DirName, Scope *CurScope,
9076  SourceLocation Loc);
9077  /// Start analysis of clauses.
9078  void StartOpenMPClause(OpenMPClauseKind K);
9079  /// End analysis of clauses.
9080  void EndOpenMPClause();
9081  /// Called on end of data sharing attribute block.
9082  void EndOpenMPDSABlock(Stmt *CurDirective);
9083 
9084  /// Check if the current region is an OpenMP loop region and if it is,
9085  /// mark loop control variable, used in \p Init for loop initialization, as
9086  /// private by default.
9087  /// \param Init First part of the for loop.
9088  void ActOnOpenMPLoopInitialization(SourceLocation ForLoc, Stmt *Init);
9089 
9090  // OpenMP directives and clauses.
9091  /// Called on correct id-expression from the '#pragma omp
9092  /// threadprivate'.
9093  ExprResult ActOnOpenMPIdExpression(Scope *CurScope, CXXScopeSpec &ScopeSpec,
9094  const DeclarationNameInfo &Id,
9095  OpenMPDirectiveKind Kind);
9096  /// Called on well-formed '#pragma omp threadprivate'.
9097  DeclGroupPtrTy ActOnOpenMPThreadprivateDirective(
9098  SourceLocation Loc,
9099  ArrayRef<Expr *> VarList);
9100  /// Builds a new OpenMPThreadPrivateDecl and checks its correctness.
9101  OMPThreadPrivateDecl *CheckOMPThreadPrivateDecl(SourceLocation Loc,
9102  ArrayRef<Expr *> VarList);
9103  /// Called on well-formed '#pragma omp allocate'.
9104  DeclGroupPtrTy ActOnOpenMPAllocateDirective(SourceLocation Loc,
9105  ArrayRef<Expr *> VarList,
9106  ArrayRef<OMPClause *> Clauses,
9107  DeclContext *Owner = nullptr);
9108  /// Called on well-formed '#pragma omp requires'.
9109  DeclGroupPtrTy ActOnOpenMPRequiresDirective(SourceLocation Loc,
9110  ArrayRef<OMPClause *> ClauseList);
9111  /// Check restrictions on Requires directive
9112  OMPRequiresDecl *CheckOMPRequiresDecl(SourceLocation Loc,
9113  ArrayRef<OMPClause *> Clauses);
9114  /// Check if the specified type is allowed to be used in 'omp declare
9115  /// reduction' construct.
9116  QualType ActOnOpenMPDeclareReductionType(SourceLocation TyLoc,
9118  /// Called on start of '#pragma omp declare reduction'.
9119  DeclGroupPtrTy ActOnOpenMPDeclareReductionDirectiveStart(
9120  Scope *S, DeclContext *DC, DeclarationName Name,
9121  ArrayRef<std::pair<QualType, SourceLocation>> ReductionTypes,
9122  AccessSpecifier AS, Decl *PrevDeclInScope = nullptr);
9123  /// Initialize declare reduction construct initializer.
9124  void ActOnOpenMPDeclareReductionCombinerStart(Scope *S, Decl *D);
9125  /// Finish current declare reduction construct initializer.
9126  void ActOnOpenMPDeclareReductionCombinerEnd(Decl *D, Expr *Combiner);
9127  /// Initialize declare reduction construct initializer.
9128  /// \return omp_priv variable.
9129  VarDecl *ActOnOpenMPDeclareReductionInitializerStart(Scope *S, Decl *D);
9130  /// Finish current declare reduction construct initializer.
9131  void ActOnOpenMPDeclareReductionInitializerEnd(Decl *D, Expr *Initializer,
9132  VarDecl *OmpPrivParm);
9133  /// Called at the end of '#pragma omp declare reduction'.
9134  DeclGroupPtrTy ActOnOpenMPDeclareReductionDirectiveEnd(
9135  Scope *S, DeclGroupPtrTy DeclReductions, bool IsValid);
9136 
9137  /// Check variable declaration in 'omp declare mapper' construct.
9138  TypeResult ActOnOpenMPDeclareMapperVarDecl(Scope *S, Declarator &D);
9139  /// Check if the specified type is allowed to be used in 'omp declare
9140  /// mapper' construct.
9141  QualType ActOnOpenMPDeclareMapperType(SourceLocation TyLoc,
9142  TypeResult ParsedType);
9143  /// Called on start of '#pragma omp declare mapper'.
9144  OMPDeclareMapperDecl *ActOnOpenMPDeclareMapperDirectiveStart(
9145  Scope *S, DeclContext *DC, DeclarationName Name, QualType MapperType,
9147  Decl *PrevDeclInScope = nullptr);
9148  /// Build the mapper variable of '#pragma omp declare mapper'.
9149  void ActOnOpenMPDeclareMapperDirectiveVarDecl(OMPDeclareMapperDecl *DMD,
9150  Scope *S, QualType MapperType,
9151  SourceLocation StartLoc,
9152  DeclarationName VN);
9153  /// Called at the end of '#pragma omp declare mapper'.
9154  DeclGroupPtrTy
9155  ActOnOpenMPDeclareMapperDirectiveEnd(OMPDeclareMapperDecl *D, Scope *S,
9156  ArrayRef<OMPClause *> ClauseList);
9157 
9158  /// Called on the start of target region i.e. '#pragma omp declare target'.
9159  bool ActOnStartOpenMPDeclareTargetDirective(SourceLocation Loc);
9160  /// Called at the end of target region i.e. '#pragme omp end declare target'.
9161  void ActOnFinishOpenMPDeclareTargetDirective();
9162  /// Called on correct id-expression from the '#pragma omp declare target'.
9163  void ActOnOpenMPDeclareTargetName(Scope *CurScope, CXXScopeSpec &ScopeSpec,
9164  const DeclarationNameInfo &Id,
9165  OMPDeclareTargetDeclAttr::MapTypeTy MT,
9166  NamedDeclSetType &SameDirectiveDecls);
9167  /// Check declaration inside target region.
9168  void
9169  checkDeclIsAllowedInOpenMPTarget(Expr *E, Decl *D,
9170  SourceLocation IdLoc = SourceLocation());
9171  /// Return true inside OpenMP declare target region.
9173  return DeclareTargetNestingLevel > 0;
9174  }
9175  /// Return true inside OpenMP target region.
9176  bool isInOpenMPTargetExecutionDirective() const;
9177 
9178  /// Return the number of captured regions created for an OpenMP directive.
9179  static int getOpenMPCaptureLevels(OpenMPDirectiveKind Kind);
9180 
9181  /// Initialization of captured region for OpenMP region.
9182  void ActOnOpenMPRegionStart(OpenMPDirectiveKind DKind, Scope *CurScope);
9183  /// End of OpenMP region.
9184  ///
9185  /// \param S Statement associated with the current OpenMP region.
9186  /// \param Clauses List of clauses for the current OpenMP region.
9187  ///
9188  /// \returns Statement for finished OpenMP region.
9189  StmtResult ActOnOpenMPRegionEnd(StmtResult S, ArrayRef<OMPClause *> Clauses);
9190  StmtResult ActOnOpenMPExecutableDirective(
9191  OpenMPDirectiveKind Kind, const DeclarationNameInfo &DirName,
9192  OpenMPDirectiveKind CancelRegion, ArrayRef<OMPClause *> Clauses,
9193  Stmt *AStmt, SourceLocation StartLoc, SourceLocation EndLoc);
9194  /// Called on well-formed '\#pragma omp parallel' after parsing
9195  /// of the associated statement.
9196  StmtResult ActOnOpenMPParallelDirective(ArrayRef<OMPClause *> Clauses,
9197  Stmt *AStmt,
9198  SourceLocation StartLoc,
9199  SourceLocation EndLoc);
9200  using VarsWithInheritedDSAType =
9201  llvm::SmallDenseMap<const ValueDecl *, const Expr *, 4>;
9202  /// Called on well-formed '\#pragma omp simd' after parsing
9203  /// of the associated statement.
9204  StmtResult
9205  ActOnOpenMPSimdDirective(ArrayRef<OMPClause *> Clauses, Stmt *AStmt,
9206  SourceLocation StartLoc, SourceLocation EndLoc,
9207  VarsWithInheritedDSAType &VarsWithImplicitDSA);
9208  /// Called on well-formed '\#pragma omp for' after parsing
9209  /// of the associated statement.
9210  StmtResult
9211  ActOnOpenMPForDirective(ArrayRef<OMPClause *> Clauses, Stmt *AStmt,
9212  SourceLocation StartLoc, SourceLocation EndLoc,
9213  VarsWithInheritedDSAType &VarsWithImplicitDSA);
9214  /// Called on well-formed '\#pragma omp for simd' after parsing
9215  /// of the associated statement.
9216  StmtResult
9217  ActOnOpenMPForSimdDirective(ArrayRef<OMPClause *> Clauses, Stmt *AStmt,
9218  SourceLocation StartLoc, SourceLocation EndLoc,
9219  VarsWithInheritedDSAType &VarsWithImplicitDSA);
9220  /// Called on well-formed '\#pragma omp sections' after parsing
9221  /// of the associated statement.
9222  StmtResult ActOnOpenMPSectionsDirective(ArrayRef<OMPClause *> Clauses,
9223  Stmt *AStmt, SourceLocation StartLoc,
9224  SourceLocation EndLoc);
9225  /// Called on well-formed '\#pragma omp section' after parsing of the
9226  /// associated statement.
9227  StmtResult ActOnOpenMPSectionDirective(Stmt *AStmt, SourceLocation StartLoc,
9228  SourceLocation EndLoc);
9229  /// Called on well-formed '\#pragma omp single' after parsing of the
9230  /// associated statement.
9231  StmtResult ActOnOpenMPSingleDirective(ArrayRef<OMPClause *> Clauses,
9232  Stmt *AStmt, SourceLocation StartLoc,
9233  SourceLocation EndLoc);
9234  /// Called on well-formed '\#pragma omp master' after parsing of the
9235  /// associated statement.
9236  StmtResult ActOnOpenMPMasterDirective(Stmt *AStmt, SourceLocation StartLoc,
9237  SourceLocation EndLoc);
9238  /// Called on well-formed '\#pragma omp critical' after parsing of the
9239  /// associated statement.
9240  StmtResult ActOnOpenMPCriticalDirective(const DeclarationNameInfo &DirName,
9241  ArrayRef<OMPClause *> Clauses,
9242  Stmt *AStmt, SourceLocation StartLoc,
9243  SourceLocation EndLoc);
9244  /// Called on well-formed '\#pragma omp parallel for' after parsing
9245  /// of the associated statement.
9246  StmtResult ActOnOpenMPParallelForDirective(
9247  ArrayRef<OMPClause *> Clauses, Stmt *AStmt, SourceLocation StartLoc,
9248  SourceLocation EndLoc, VarsWithInheritedDSAType &VarsWithImplicitDSA);
9249  /// Called on well-formed '\#pragma omp parallel for simd' after
9250  /// parsing of the associated statement.
9251  StmtResult ActOnOpenMPParallelForSimdDirective(
9252  ArrayRef<OMPClause *> Clauses, Stmt *AStmt, SourceLocation StartLoc,
9253  SourceLocation EndLoc, VarsWithInheritedDSAType &VarsWithImplicitDSA);
9254  /// Called on well-formed '\#pragma omp parallel sections' after
9255  /// parsing of the associated statement.
9256  StmtResult ActOnOpenMPParallelSectionsDirective(ArrayRef<OMPClause *> Clauses,
9257  Stmt *AStmt,
9258  SourceLocation StartLoc,
9259  SourceLocation EndLoc);
9260  /// Called on well-formed '\#pragma omp task' after parsing of the
9261  /// associated statement.
9262  StmtResult ActOnOpenMPTaskDirective(ArrayRef<OMPClause *> Clauses,
9263  Stmt *AStmt, SourceLocation StartLoc,
9264  SourceLocation EndLoc);
9265  /// Called on well-formed '\#pragma omp taskyield'.
9266  StmtResult ActOnOpenMPTaskyieldDirective(SourceLocation StartLoc,
9267  SourceLocation EndLoc);
9268  /// Called on well-formed '\#pragma omp barrier'.
9269  StmtResult ActOnOpenMPBarrierDirective(SourceLocation StartLoc,
9270  SourceLocation EndLoc);
9271  /// Called on well-formed '\#pragma omp taskwait'.
9272  StmtResult ActOnOpenMPTaskwaitDirective(SourceLocation StartLoc,
9273  SourceLocation EndLoc);
9274  /// Called on well-formed '\#pragma omp taskgroup'.
9275  StmtResult ActOnOpenMPTaskgroupDirective(ArrayRef<OMPClause *> Clauses,
9276  Stmt *AStmt, SourceLocation StartLoc,
9277  SourceLocation EndLoc);
9278  /// Called on well-formed '\#pragma omp flush'.
9279  StmtResult ActOnOpenMPFlushDirective(ArrayRef<OMPClause *> Clauses,
9280  SourceLocation StartLoc,
9281  SourceLocation EndLoc);
9282  /// Called on well-formed '\#pragma omp ordered' after parsing of the
9283  /// associated statement.
9284  StmtResult ActOnOpenMPOrderedDirective(ArrayRef<OMPClause *> Clauses,
9285  Stmt *AStmt, SourceLocation StartLoc,
9286  SourceLocation EndLoc);
9287  /// Called on well-formed '\#pragma omp atomic' after parsing of the
9288  /// associated statement.
9289  StmtResult ActOnOpenMPAtomicDirective(ArrayRef<OMPClause *> Clauses,
9290  Stmt *AStmt, SourceLocation StartLoc,
9291  SourceLocation EndLoc);
9292  /// Called on well-formed '\#pragma omp target' after parsing of the
9293  /// associated statement.
9294  StmtResult ActOnOpenMPTargetDirective(ArrayRef<OMPClause *> Clauses,
9295  Stmt *AStmt, SourceLocation StartLoc,
9296  SourceLocation EndLoc);
9297  /// Called on well-formed '\#pragma omp target data' after parsing of
9298  /// the associated statement.
9299  StmtResult ActOnOpenMPTargetDataDirective(ArrayRef<OMPClause *> Clauses,
9300  Stmt *AStmt, SourceLocation StartLoc,
9301  SourceLocation EndLoc);
9302  /// Called on well-formed '\#pragma omp target enter data' after
9303  /// parsing of the associated statement.
9304  StmtResult ActOnOpenMPTargetEnterDataDirective(ArrayRef<OMPClause *> Clauses,
9305  SourceLocation StartLoc,
9306  SourceLocation EndLoc,
9307  Stmt *AStmt);
9308  /// Called on well-formed '\#pragma omp target exit data' after
9309  /// parsing of the associated statement.
9310  StmtResult ActOnOpenMPTargetExitDataDirective(ArrayRef<OMPClause *> Clauses,
9311  SourceLocation StartLoc,
9312  SourceLocation EndLoc,
9313  Stmt *AStmt);
9314  /// Called on well-formed '\#pragma omp target parallel' after
9315  /// parsing of the associated statement.
9316  StmtResult ActOnOpenMPTargetParallelDirective(ArrayRef<OMPClause *> Clauses,
9317  Stmt *AStmt,
9318  SourceLocation StartLoc,
9319  SourceLocation EndLoc);
9320  /// Called on well-formed '\#pragma omp target parallel for' after
9321  /// parsing of the associated statement.
9322  StmtResult ActOnOpenMPTargetParallelForDirective(
9323  ArrayRef<OMPClause *> Clauses, Stmt *AStmt, SourceLocation StartLoc,
9324  SourceLocation EndLoc, VarsWithInheritedDSAType &VarsWithImplicitDSA);
9325  /// Called on well-formed '\#pragma omp teams' after parsing of the
9326  /// associated statement.
9327  StmtResult ActOnOpenMPTeamsDirective(ArrayRef<OMPClause *> Clauses,
9328  Stmt *AStmt, SourceLocation StartLoc,
9329  SourceLocation EndLoc);
9330  /// Called on well-formed '\#pragma omp cancellation point'.
9331  StmtResult
9332  ActOnOpenMPCancellationPointDirective(SourceLocation StartLoc,
9333  SourceLocation EndLoc,
9334  OpenMPDirectiveKind CancelRegion);
9335  /// Called on well-formed '\#pragma omp cancel'.
9336  StmtResult ActOnOpenMPCancelDirective(ArrayRef<OMPClause *> Clauses,
9337  SourceLocation StartLoc,
9338  SourceLocation EndLoc,
9339  OpenMPDirectiveKind CancelRegion);
9340  /// Called on well-formed '\#pragma omp taskloop' after parsing of the
9341  /// associated statement.
9342  StmtResult
9343  ActOnOpenMPTaskLoopDirective(ArrayRef<OMPClause *> Clauses, Stmt *AStmt,
9344  SourceLocation StartLoc, SourceLocation EndLoc,
9345  VarsWithInheritedDSAType &VarsWithImplicitDSA);
9346  /// Called on well-formed '\#pragma omp taskloop simd' after parsing of
9347  /// the associated statement.
9348  StmtResult ActOnOpenMPTaskLoopSimdDirective(
9349  ArrayRef<OMPClause *> Clauses, Stmt *AStmt, SourceLocation StartLoc,
9350  SourceLocation EndLoc, VarsWithInheritedDSAType &VarsWithImplicitDSA);
9351  /// Called on well-formed '\#pragma omp distribute' after parsing
9352  /// of the associated statement.
9353  StmtResult
9354  ActOnOpenMPDistributeDirective(ArrayRef<OMPClause *> Clauses, Stmt *AStmt,
9355  SourceLocation StartLoc, SourceLocation EndLoc,
9356  VarsWithInheritedDSAType &VarsWithImplicitDSA);
9357  /// Called on well-formed '\#pragma omp target update'.
9358  StmtResult ActOnOpenMPTargetUpdateDirective(ArrayRef<OMPClause *> Clauses,
9359  SourceLocation StartLoc,
9360  SourceLocation EndLoc,
9361  Stmt *AStmt);
9362  /// Called on well-formed '\#pragma omp distribute parallel for' after
9363  /// parsing of the associated statement.
9364  StmtResult ActOnOpenMPDistributeParallelForDirective(
9365  ArrayRef<OMPClause *> Clauses, Stmt *AStmt, SourceLocation StartLoc,
9366  SourceLocation EndLoc, VarsWithInheritedDSAType &VarsWithImplicitDSA);
9367  /// Called on well-formed '\#pragma omp distribute parallel for simd'
9368  /// after parsing of the associated statement.
9369  StmtResult ActOnOpenMPDistributeParallelForSimdDirective(
9370  ArrayRef<OMPClause *> Clauses, Stmt *AStmt, SourceLocation StartLoc,
9371  SourceLocation EndLoc, VarsWithInheritedDSAType &VarsWithImplicitDSA);
9372  /// Called on well-formed '\#pragma omp distribute simd' after
9373  /// parsing of the associated statement.
9374  StmtResult ActOnOpenMPDistributeSimdDirective(
9375  ArrayRef<OMPClause *> Clauses, Stmt *AStmt, SourceLocation StartLoc,
9376  SourceLocation EndLoc, VarsWithInheritedDSAType &VarsWithImplicitDSA);
9377  /// Called on well-formed '\#pragma omp target parallel for simd' after
9378  /// parsing of the associated statement.
9379  StmtResult ActOnOpenMPTargetParallelForSimdDirective(
9380  ArrayRef<OMPClause *> Clauses, Stmt *AStmt, SourceLocation StartLoc,
9381  SourceLocation EndLoc, VarsWithInheritedDSAType &VarsWithImplicitDSA);
9382  /// Called on well-formed '\#pragma omp target simd' after parsing of
9383  /// the associated statement.
9384  StmtResult
9385  ActOnOpenMPTargetSimdDirective(ArrayRef<OMPClause *> Clauses, Stmt *AStmt,
9386  SourceLocation StartLoc, SourceLocation EndLoc,
9387  VarsWithInheritedDSAType &VarsWithImplicitDSA);
9388  /// Called on well-formed '\#pragma omp teams distribute' after parsing of
9389  /// the associated statement.
9390  StmtResult ActOnOpenMPTeamsDistributeDirective(
9391  ArrayRef<OMPClause *> Clauses, Stmt *AStmt, SourceLocation StartLoc,
9392  SourceLocation EndLoc, VarsWithInheritedDSAType &VarsWithImplicitDSA);
9393  /// Called on well-formed '\#pragma omp teams distribute simd' after parsing
9394  /// of the associated statement.
9395  StmtResult ActOnOpenMPTeamsDistributeSimdDirective(
9396  ArrayRef<OMPClause *> Clauses, Stmt *AStmt, SourceLocation StartLoc,
9397  SourceLocation EndLoc, VarsWithInheritedDSAType &VarsWithImplicitDSA);
9398  /// Called on well-formed '\#pragma omp teams distribute parallel for simd'
9399  /// after parsing of the associated statement.
9400  StmtResult ActOnOpenMPTeamsDistributeParallelForSimdDirective(
9401  ArrayRef<OMPClause *> Clauses, Stmt *AStmt, SourceLocation StartLoc,
9402  SourceLocation EndLoc, VarsWithInheritedDSAType &VarsWithImplicitDSA);
9403  /// Called on well-formed '\#pragma omp teams distribute parallel for'
9404  /// after parsing of the associated statement.
9405  StmtResult ActOnOpenMPTeamsDistributeParallelForDirective(
9406  ArrayRef<OMPClause *> Clauses, Stmt *AStmt, SourceLocation StartLoc,
9407  SourceLocation EndLoc, VarsWithInheritedDSAType &VarsWithImplicitDSA);
9408  /// Called on well-formed '\#pragma omp target teams' after parsing of the
9409  /// associated statement.
9410  StmtResult ActOnOpenMPTargetTeamsDirective(ArrayRef<OMPClause *> Clauses,
9411  Stmt *AStmt,
9412  SourceLocation StartLoc,
9413  SourceLocation EndLoc);
9414  /// Called on well-formed '\#pragma omp target teams distribute' after parsing
9415  /// of the associated statement.
9416  StmtResult ActOnOpenMPTargetTeamsDistributeDirective(
9417  ArrayRef<OMPClause *> Clauses, Stmt *AStmt, SourceLocation StartLoc,
9418  SourceLocation EndLoc, VarsWithInheritedDSAType &VarsWithImplicitDSA);
9419  /// Called on well-formed '\#pragma omp target teams distribute parallel for'
9420  /// after parsing of the associated statement.
9421  StmtResult ActOnOpenMPTargetTeamsDistributeParallelForDirective(
9422  ArrayRef<OMPClause *> Clauses, Stmt *AStmt, SourceLocation StartLoc,
9423  SourceLocation EndLoc, VarsWithInheritedDSAType &VarsWithImplicitDSA);
9424  /// Called on well-formed '\#pragma omp target teams distribute parallel for
9425  /// simd' after parsing of the associated statement.
9426  StmtResult ActOnOpenMPTargetTeamsDistributeParallelForSimdDirective(
9427  ArrayRef<OMPClause *> Clauses, Stmt *AStmt, SourceLocation StartLoc,
9428  SourceLocation EndLoc, VarsWithInheritedDSAType &VarsWithImplicitDSA);
9429  /// Called on well-formed '\#pragma omp target teams distribute simd' after
9430  /// parsing of the associated statement.
9431  StmtResult ActOnOpenMPTargetTeamsDistributeSimdDirective(
9432  ArrayRef<OMPClause *> Clauses, Stmt *AStmt, SourceLocation StartLoc,
9433  SourceLocation EndLoc, VarsWithInheritedDSAType &VarsWithImplicitDSA);
9434 
9435  /// Checks correctness of linear modifiers.
9436  bool CheckOpenMPLinearModifier(OpenMPLinearClauseKind LinKind,
9437  SourceLocation LinLoc);
9438  /// Checks that the specified declaration matches requirements for the linear
9439  /// decls.
9440  bool CheckOpenMPLinearDecl(const ValueDecl *D, SourceLocation ELoc,
9441  OpenMPLinearClauseKind LinKind, QualType Type);
9442 
9443  /// Called on well-formed '\#pragma omp declare simd' after parsing of
9444  /// the associated method/function.
9445  DeclGroupPtrTy ActOnOpenMPDeclareSimdDirective(
9446  DeclGroupPtrTy DG, OMPDeclareSimdDeclAttr::BranchStateTy BS,
9447  Expr *Simdlen, ArrayRef<Expr *> Uniforms, ArrayRef<Expr *> Aligneds,
9448  ArrayRef<Expr *> Alignments, ArrayRef<Expr *> Linears,
9449  ArrayRef<unsigned> LinModifiers, ArrayRef<Expr *> Steps, SourceRange SR);
9450 
9451  OMPClause *ActOnOpenMPSingleExprClause(OpenMPClauseKind Kind,
9452  Expr *Expr,
9453  SourceLocation StartLoc,
9454  SourceLocation LParenLoc,
9455  SourceLocation EndLoc);
9456  /// Called on well-formed 'allocator' clause.
9457  OMPClause *ActOnOpenMPAllocatorClause(Expr *Allocator,
9458  SourceLocation StartLoc,
9459  SourceLocation LParenLoc,
9460  SourceLocation EndLoc);
9461  /// Called on well-formed 'if' clause.
9462  OMPClause *ActOnOpenMPIfClause(OpenMPDirectiveKind NameModifier,
9463  Expr *Condition, SourceLocation StartLoc,
9464  SourceLocation LParenLoc,
9465  SourceLocation NameModifierLoc,
9466  SourceLocation ColonLoc,
9467  SourceLocation EndLoc);
9468  /// Called on well-formed 'final' clause.
9469  OMPClause *ActOnOpenMPFinalClause(Expr *Condition, SourceLocation StartLoc,
9470  SourceLocation LParenLoc,
9471  SourceLocation EndLoc);
9472  /// Called on well-formed 'num_threads' clause.
9473  OMPClause *ActOnOpenMPNumThreadsClause(Expr *NumThreads,
9474  SourceLocation StartLoc,
9475  SourceLocation LParenLoc,
9476  SourceLocation EndLoc);
9477  /// Called on well-formed 'safelen' clause.
9478  OMPClause *ActOnOpenMPSafelenClause(Expr *Length,
9479  SourceLocation StartLoc,
9480  SourceLocation LParenLoc,
9481  SourceLocation EndLoc);
9482  /// Called on well-formed 'simdlen' clause.
9483  OMPClause *ActOnOpenMPSimdlenClause(Expr *Length, SourceLocation StartLoc,
9484  SourceLocation LParenLoc,
9485  SourceLocation EndLoc);
9486  /// Called on well-formed 'collapse' clause.
9487  OMPClause *ActOnOpenMPCollapseClause(Expr *NumForLoops,
9488  SourceLocation StartLoc,
9489  SourceLocation LParenLoc,
9490  SourceLocation EndLoc);
9491  /// Called on well-formed 'ordered' clause.
9492  OMPClause *
9493  ActOnOpenMPOrderedClause(SourceLocation StartLoc, SourceLocation EndLoc,
9494  SourceLocation LParenLoc = SourceLocation(),
9495  Expr *NumForLoops = nullptr);
9496  /// Called on well-formed 'grainsize' clause.
9497  OMPClause *ActOnOpenMPGrainsizeClause(Expr *Size, SourceLocation StartLoc,
9498  SourceLocation LParenLoc,
9499  SourceLocation EndLoc);
9500  /// Called on well-formed 'num_tasks' clause.
9501  OMPClause *ActOnOpenMPNumTasksClause(Expr *NumTasks, SourceLocation StartLoc,
9502  SourceLocation LParenLoc,
9503  SourceLocation EndLoc);
9504  /// Called on well-formed 'hint' clause.
9505  OMPClause *ActOnOpenMPHintClause(Expr *Hint, SourceLocation StartLoc,
9506  SourceLocation LParenLoc,
9507  SourceLocation EndLoc);
9508 
9509  OMPClause *ActOnOpenMPSimpleClause(OpenMPClauseKind Kind,
9510  unsigned Argument,
9511  SourceLocation ArgumentLoc,
9512  SourceLocation StartLoc,
9513  SourceLocation LParenLoc,
9514  SourceLocation EndLoc);
9515  /// Called on well-formed 'default' clause.
9516  OMPClause *ActOnOpenMPDefaultClause(OpenMPDefaultClauseKind Kind,
9517  SourceLocation KindLoc,
9518  SourceLocation StartLoc,
9519  SourceLocation LParenLoc,
9520  SourceLocation EndLoc);
9521  /// Called on well-formed 'proc_bind' clause.
9522  OMPClause *ActOnOpenMPProcBindClause(OpenMPProcBindClauseKind Kind,
9523  SourceLocation KindLoc,
9524  SourceLocation StartLoc,
9525  SourceLocation LParenLoc,
9526  SourceLocation EndLoc);
9527 
9528  OMPClause *ActOnOpenMPSingleExprWithArgClause(
9529  OpenMPClauseKind Kind, ArrayRef<unsigned> Arguments, Expr *Expr,
9530  SourceLocation StartLoc, SourceLocation LParenLoc,
9531  ArrayRef<SourceLocation> ArgumentsLoc, SourceLocation DelimLoc,
9532  SourceLocation EndLoc);
9533  /// Called on well-formed 'schedule' clause.
9534  OMPClause *ActOnOpenMPScheduleClause(
9536  OpenMPScheduleClauseKind Kind, Expr *ChunkSize, SourceLocation StartLoc,
9537  SourceLocation LParenLoc, SourceLocation M1Loc, SourceLocation M2Loc,
9538  SourceLocation KindLoc, SourceLocation CommaLoc, SourceLocation EndLoc);
9539 
9540  OMPClause *ActOnOpenMPClause(OpenMPClauseKind Kind, SourceLocation StartLoc,
9541  SourceLocation EndLoc);
9542  /// Called on well-formed 'nowait' clause.
9543  OMPClause *ActOnOpenMPNowaitClause(SourceLocation StartLoc,
9544  SourceLocation EndLoc);
9545  /// Called on well-formed 'untied' clause.
9546  OMPClause *ActOnOpenMPUntiedClause(SourceLocation StartLoc,
9547  SourceLocation EndLoc);
9548  /// Called on well-formed 'mergeable' clause.
9549  OMPClause *ActOnOpenMPMergeableClause(SourceLocation StartLoc,
9550  SourceLocation EndLoc);
9551  /// Called on well-formed 'read' clause.
9552  OMPClause *ActOnOpenMPReadClause(SourceLocation StartLoc,
9553  SourceLocation EndLoc);
9554  /// Called on well-formed 'write' clause.
9555  OMPClause *ActOnOpenMPWriteClause(SourceLocation StartLoc,
9556  SourceLocation EndLoc);
9557  /// Called on well-formed 'update' clause.
9558  OMPClause *ActOnOpenMPUpdateClause(SourceLocation StartLoc,
9559  SourceLocation EndLoc);
9560  /// Called on well-formed 'capture' clause.
9561  OMPClause *ActOnOpenMPCaptureClause(SourceLocation StartLoc,
9562  SourceLocation EndLoc);
9563  /// Called on well-formed 'seq_cst' clause.
9564  OMPClause *ActOnOpenMPSeqCstClause(SourceLocation StartLoc,
9565  SourceLocation EndLoc);
9566  /// Called on well-formed 'threads' clause.
9567  OMPClause *ActOnOpenMPThreadsClause(SourceLocation StartLoc,
9568  SourceLocation EndLoc);
9569  /// Called on well-formed 'simd' clause.
9570  OMPClause *ActOnOpenMPSIMDClause(SourceLocation StartLoc,
9571  SourceLocation EndLoc);
9572  /// Called on well-formed 'nogroup' clause.
9573  OMPClause *ActOnOpenMPNogroupClause(SourceLocation StartLoc,
9574  SourceLocation EndLoc);
9575  /// Called on well-formed 'unified_address' clause.
9576  OMPClause *ActOnOpenMPUnifiedAddressClause(SourceLocation StartLoc,
9577  SourceLocation EndLoc);
9578 
9579  /// Called on well-formed 'unified_address' clause.
9580  OMPClause *ActOnOpenMPUnifiedSharedMemoryClause(SourceLocation StartLoc,
9581  SourceLocation EndLoc);
9582 
9583  /// Called on well-formed 'reverse_offload' clause.
9584  OMPClause *ActOnOpenMPReverseOffloadClause(SourceLocation StartLoc,
9585  SourceLocation EndLoc);
9586 
9587  /// Called on well-formed 'dynamic_allocators' clause.
9588  OMPClause *ActOnOpenMPDynamicAllocatorsClause(SourceLocation StartLoc,
9589  SourceLocation EndLoc);
9590 
9591  /// Called on well-formed 'atomic_default_mem_order' clause.
9592  OMPClause *ActOnOpenMPAtomicDefaultMemOrderClause(
9594  SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc);
9595 
9596  OMPClause *ActOnOpenMPVarListClause(
9597  OpenMPClauseKind Kind, ArrayRef<Expr *> Vars, Expr *TailExpr,
9598  const OMPVarListLocTy &Locs, SourceLocation ColonLoc,
9599  CXXScopeSpec &ReductionOrMapperIdScopeSpec,
9600  DeclarationNameInfo &ReductionOrMapperId, OpenMPDependClauseKind DepKind,
9601  OpenMPLinearClauseKind LinKind,
9602  ArrayRef<OpenMPMapModifierKind> MapTypeModifiers,
9603  ArrayRef<SourceLocation> MapTypeModifiersLoc, OpenMPMapClauseKind MapType,
9604  bool IsMapTypeImplicit, SourceLocation DepLinMapLoc);
9605  /// Called on well-formed 'allocate' clause.
9606  OMPClause *
9607  ActOnOpenMPAllocateClause(Expr *Allocator, ArrayRef<Expr *> VarList,
9608  SourceLocation StartLoc, SourceLocation ColonLoc,
9609  SourceLocation LParenLoc, SourceLocation EndLoc);
9610  /// Called on well-formed 'private' clause.
9611  OMPClause *ActOnOpenMPPrivateClause(ArrayRef<Expr *> VarList,
9612  SourceLocation StartLoc,
9613  SourceLocation LParenLoc,
9614  SourceLocation EndLoc);
9615  /// Called on well-formed 'firstprivate' clause.
9616  OMPClause *ActOnOpenMPFirstprivateClause(ArrayRef<Expr *> VarList,
9617  SourceLocation StartLoc,
9618  SourceLocation LParenLoc,
9619  SourceLocation EndLoc);
9620  /// Called on well-formed 'lastprivate' clause.
9621  OMPClause *ActOnOpenMPLastprivateClause(ArrayRef<Expr *> VarList,
9622  SourceLocation StartLoc,
9623  SourceLocation LParenLoc,
9624  SourceLocation EndLoc);
9625  /// Called on well-formed 'shared' clause.
9626  OMPClause *ActOnOpenMPSharedClause(ArrayRef<Expr *> VarList,
9627  SourceLocation StartLoc,
9628  SourceLocation LParenLoc,
9629  SourceLocation EndLoc);
9630  /// Called on well-formed 'reduction' clause.
9631  OMPClause *ActOnOpenMPReductionClause(
9632  ArrayRef<Expr *> VarList, SourceLocation StartLoc,
9633  SourceLocation LParenLoc, SourceLocation ColonLoc, SourceLocation EndLoc,
9634  CXXScopeSpec &ReductionIdScopeSpec,
9635  const DeclarationNameInfo &ReductionId,
9636  ArrayRef<Expr *> UnresolvedReductions = llvm::None);
9637  /// Called on well-formed 'task_reduction' clause.
9638  OMPClause *ActOnOpenMPTaskReductionClause(
9639  ArrayRef<Expr *> VarList, SourceLocation StartLoc,
9640  SourceLocation LParenLoc, SourceLocation ColonLoc, SourceLocation EndLoc,
9641  CXXScopeSpec &ReductionIdScopeSpec,
9642  const DeclarationNameInfo &ReductionId,
9643  ArrayRef<Expr *> UnresolvedReductions = llvm::None);
9644  /// Called on well-formed 'in_reduction' clause.
9645  OMPClause *ActOnOpenMPInReductionClause(
9646  ArrayRef<Expr *> VarList, SourceLocation StartLoc,
9647  SourceLocation LParenLoc, SourceLocation ColonLoc, SourceLocation EndLoc,
9648  CXXScopeSpec &ReductionIdScopeSpec,
9649  const DeclarationNameInfo &ReductionId,
9650  ArrayRef<Expr *> UnresolvedReductions = llvm::None);
9651  /// Called on well-formed 'linear' clause.
9652  OMPClause *
9653  ActOnOpenMPLinearClause(ArrayRef<Expr *> VarList, Expr *Step,
9654  SourceLocation StartLoc, SourceLocation LParenLoc,
9655  OpenMPLinearClauseKind LinKind, SourceLocation LinLoc,
9656  SourceLocation ColonLoc, SourceLocation EndLoc);
9657  /// Called on well-formed 'aligned' clause.
9658  OMPClause *ActOnOpenMPAlignedClause(ArrayRef<Expr *> VarList,
9659  Expr *Alignment,
9660  SourceLocation StartLoc,
9661  SourceLocation LParenLoc,
9662  SourceLocation ColonLoc,
9663  SourceLocation EndLoc);
9664  /// Called on well-formed 'copyin' clause.
9665  OMPClause *ActOnOpenMPCopyinClause(ArrayRef<Expr *> VarList,
9666  SourceLocation StartLoc,
9667  SourceLocation LParenLoc,
9668  SourceLocation EndLoc);
9669  /// Called on well-formed 'copyprivate' clause.
9670  OMPClause *ActOnOpenMPCopyprivateClause(ArrayRef<Expr *> VarList,
9671  SourceLocation StartLoc,
9672  SourceLocation LParenLoc,
9673  SourceLocation EndLoc);
9674  /// Called on well-formed 'flush' pseudo clause.
9675  OMPClause *ActOnOpenMPFlushClause(ArrayRef<Expr *> VarList,
9676  SourceLocation StartLoc,
9677  SourceLocation LParenLoc,
9678  SourceLocation EndLoc);
9679  /// Called on well-formed 'depend' clause.
9680  OMPClause *
9681  ActOnOpenMPDependClause(OpenMPDependClauseKind DepKind, SourceLocation DepLoc,
9682  SourceLocation ColonLoc, ArrayRef<Expr *> VarList,
9683  SourceLocation StartLoc, SourceLocation LParenLoc,
9684  SourceLocation EndLoc);
9685  /// Called on well-formed 'device' clause.
9686  OMPClause *ActOnOpenMPDeviceClause(Expr *Device, SourceLocation StartLoc,
9687  SourceLocation LParenLoc,
9688  SourceLocation EndLoc);
9689  /// Called on well-formed 'map' clause.
9690  OMPClause *
9691  ActOnOpenMPMapClause(ArrayRef<OpenMPMapModifierKind> MapTypeModifiers,
9692  ArrayRef<SourceLocation> MapTypeModifiersLoc,
9693  CXXScopeSpec &MapperIdScopeSpec,
9694  DeclarationNameInfo &MapperId,
9695  OpenMPMapClauseKind MapType, bool IsMapTypeImplicit,
9696  SourceLocation MapLoc, SourceLocation ColonLoc,
9697  ArrayRef<Expr *> VarList, const OMPVarListLocTy &Locs,
9698  ArrayRef<Expr *> UnresolvedMappers = llvm::None);
9699  /// Called on well-formed 'num_teams' clause.
9700  OMPClause *ActOnOpenMPNumTeamsClause(Expr *NumTeams, SourceLocation StartLoc,
9701  SourceLocation LParenLoc,
9702  SourceLocation EndLoc);
9703  /// Called on well-formed 'thread_limit' clause.
9704  OMPClause *ActOnOpenMPThreadLimitClause(Expr *ThreadLimit,
9705  SourceLocation StartLoc,
9706  SourceLocation LParenLoc,
9707  SourceLocation EndLoc);
9708  /// Called on well-formed 'priority' clause.
9709  OMPClause *ActOnOpenMPPriorityClause(Expr *Priority, SourceLocation StartLoc,
9710  SourceLocation LParenLoc,
9711  SourceLocation EndLoc);
9712  /// Called on well-formed 'dist_schedule' clause.
9713  OMPClause *ActOnOpenMPDistScheduleClause(
9714  OpenMPDistScheduleClauseKind Kind, Expr *ChunkSize,
9715  SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation KindLoc,
9716  SourceLocation CommaLoc, SourceLocation EndLoc);
9717  /// Called on well-formed 'defaultmap' clause.
9718  OMPClause *ActOnOpenMPDefaultmapClause(
9720  SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation MLoc,
9721  SourceLocation KindLoc, SourceLocation EndLoc);
9722  /// Called on well-formed 'to' clause.
9723  OMPClause *
9724  ActOnOpenMPToClause(ArrayRef<Expr *> VarList, CXXScopeSpec &MapperIdScopeSpec,
9725  DeclarationNameInfo &MapperId,
9726  const OMPVarListLocTy &Locs,
9727  ArrayRef<Expr *> UnresolvedMappers = llvm::None);
9728  /// Called on well-formed 'from' clause.
9729  OMPClause *ActOnOpenMPFromClause(
9730  ArrayRef<Expr *> VarList, CXXScopeSpec &MapperIdScopeSpec,
9731  DeclarationNameInfo &MapperId, const OMPVarListLocTy &Locs,
9732  ArrayRef<Expr *> UnresolvedMappers = llvm::None);
9733  /// Called on well-formed 'use_device_ptr' clause.
9734  OMPClause *ActOnOpenMPUseDevicePtrClause(ArrayRef<Expr *> VarList,
9735  const OMPVarListLocTy &Locs);
9736  /// Called on well-formed 'is_device_ptr' clause.
9737  OMPClause *ActOnOpenMPIsDevicePtrClause(ArrayRef<Expr *> VarList,
9738  const OMPVarListLocTy &Locs);
9739 
9740  /// The kind of conversion being performed.
9742  /// An implicit conversion.
9744  /// A C-style cast.
9746  /// A functional-style cast.
9748  /// A cast other than a C-style cast.
9750  /// A conversion for an operand of a builtin overloaded operator.
9751  CCK_ForBuiltinOverloadedOp
9752  };
9753 
9754  static bool isCast(CheckedConversionKind CCK) {
9755  return CCK == CCK_CStyleCast || CCK == CCK_FunctionalCast ||
9756  CCK == CCK_OtherCast;
9757  }
9758 
9759  /// ImpCastExprToType - If Expr is not of type 'Type', insert an implicit
9760  /// cast. If there is already an implicit cast, merge into the existing one.
9761  /// If isLvalue, the result of the cast is an lvalue.
9762  ExprResult ImpCastExprToType(Expr *E, QualType Type, CastKind CK,
9763  ExprValueKind VK = VK_RValue,
9764  const CXXCastPath *BasePath = nullptr,
9766  = CCK_ImplicitConversion);
9767 
9768  /// ScalarTypeToBooleanCastKind - Returns the cast kind corresponding
9769  /// to the conversion from scalar type ScalarTy to the Boolean type.
9770  static CastKind ScalarTypeToBooleanCastKind(QualType ScalarTy);
9771 
9772  /// IgnoredValueConversions - Given that an expression's result is
9773  /// syntactically ignored, perform any conversions that are
9774  /// required.
9775  ExprResult IgnoredValueConversions(Expr *E);
9776 
9777  // UsualUnaryConversions - promotes integers (C99 6.3.1.1p2) and converts
9778  // functions and arrays to their respective pointers (C99 6.3.2.1).
9779  ExprResult UsualUnaryConversions(Expr *E);
9780 
9781  /// CallExprUnaryConversions - a special case of an unary conversion
9782  /// performed on a function designator of a call expression.
9783  ExprResult CallExprUnaryConversions(Expr *E);
9784 
9785  // DefaultFunctionArrayConversion - converts functions and arrays
9786  // to their respective pointers (C99 6.3.2.1).
9787  ExprResult DefaultFunctionArrayConversion(Expr *E, bool Diagnose = true);
9788 
9789  // DefaultFunctionArrayLvalueConversion - converts functions and
9790  // arrays to their respective pointers and performs the
9791  // lvalue-to-rvalue conversion.
9792  ExprResult DefaultFunctionArrayLvalueConversion(Expr *E,
9793  bool Diagnose = true);
9794 
9795  // DefaultLvalueConversion - performs lvalue-to-rvalue conversion on
9796  // the operand. This is DefaultFunctionArrayLvalueConversion,
9797  // except that it assumes the operand isn't of function or array
9798  // type.
9799  ExprResult DefaultLvalueConversion(Expr *E);
9800 
9801  // DefaultArgumentPromotion (C99 6.5.2.2p6). Used for function calls that
9802  // do not have a prototype. Integer promotions are performed on each
9803  // argument, and arguments that have type float are promoted to double.
9804  ExprResult DefaultArgumentPromotion(Expr *E);
9805 
9806  /// If \p E is a prvalue denoting an unmaterialized temporary, materialize
9807  /// it as an xvalue. In C++98, the result will still be a prvalue, because
9808  /// we don't have xvalues there.
9809  ExprResult TemporaryMaterializationConversion(Expr *E);
9810 
9811  // Used for emitting the right warning by DefaultVariadicArgumentPromotion
9817  VariadicDoesNotApply
9818  };
9819 
9820  VariadicCallType getVariadicCallType(FunctionDecl *FDecl,
9821  const FunctionProtoType *Proto,
9822  Expr *Fn);
9823 
9824  // Used for determining in which context a type is allowed to be passed to a
9825  // vararg function.
9826  enum VarArgKind {
9831  VAK_Invalid
9832  };
9833 
9834  // Determines which VarArgKind fits an expression.
9835  VarArgKind isValidVarArgType(const QualType &Ty);
9836 
9837  /// Check to see if the given expression is a valid argument to a variadic
9838  /// function, issuing a diagnostic if not.
9839  void checkVariadicArgument(const Expr *E, VariadicCallType CT);
9840 
9841  /// Check to see if a given expression could have '.c_str()' called on it.
9842  bool hasCStrMethod(const Expr *E);
9843 
9844  /// GatherArgumentsForCall - Collector argument expressions for various
9845  /// form of call prototypes.
9846  bool GatherArgumentsForCall(SourceLocation CallLoc, FunctionDecl *FDecl,
9847  const FunctionProtoType *Proto,
9848  unsigned FirstParam, ArrayRef<Expr *> Args,
9849  SmallVectorImpl<Expr *> &AllArgs,
9850  VariadicCallType CallType = VariadicDoesNotApply,
9851  bool AllowExplicit = false,
9852  bool IsListInitialization = false);
9853 
9854  // DefaultVariadicArgumentPromotion - Like DefaultArgumentPromotion, but
9855  // will create a runtime trap if the resulting type is not a POD type.
9856  ExprResult DefaultVariadicArgumentPromotion(Expr *E, VariadicCallType CT,
9857  FunctionDecl *FDecl);
9858 
9859  // UsualArithmeticConversions - performs the UsualUnaryConversions on it's
9860  // operands and then handles various conversions that are common to binary
9861  // operators (C99 6.3.1.8). If both operands aren't arithmetic, this
9862  // routine returns the first non-arithmetic type found. The client is
9863  // responsible for emitting appropriate error diagnostics.
9864  QualType UsualArithmeticConversions(ExprResult &LHS, ExprResult &RHS,
9865  bool IsCompAssign = false);
9866 
9867  /// AssignConvertType - All of the 'assignment' semantic checks return this
9868  /// enum to indicate whether the assignment was allowed. These checks are
9869  /// done for simple assignments, as well as initialization, return from
9870  /// function, argument passing, etc. The query is phrased in terms of a
9871  /// source and destination type.
9873  /// Compatible - the types are compatible according to the standard.
9875 
9876  /// PointerToInt - The assignment converts a pointer to an int, which we
9877  /// accept as an extension.
9879 
9880  /// IntToPointer - The assignment converts an int to a pointer, which we
9881  /// accept as an extension.
9883 
9884  /// FunctionVoidPointer - The assignment is between a function pointer and
9885  /// void*, which the standard doesn't allow, but we accept as an extension.
9887 
9888  /// IncompatiblePointer - The assignment is between two pointers types that
9889  /// are not compatible, but we accept them as an extension.
9891 
9892  /// IncompatiblePointerSign - The assignment is between two pointers types
9893  /// which point to integers which have a different sign, but are otherwise
9894  /// identical. This is a subset of the above, but broken out because it's by
9895  /// far the most common case of incompatible pointers.
9897 
9898  /// CompatiblePointerDiscardsQualifiers - The assignment discards
9899  /// c/v/r qualifiers, which we accept as an extension.
9901 
9902  /// IncompatiblePointerDiscardsQualifiers - The assignment
9903  /// discards qualifiers that we don't permit to be discarded,
9904  /// like address spaces.
9906 
9907  /// IncompatibleNestedPointerAddressSpaceMismatch - The assignment
9908  /// changes address spaces in nested pointer types which is not allowed.
9909  /// For instance, converting __private int ** to __generic int ** is
9910  /// illegal even though __private could be converted to __generic.
9912 
9913  /// IncompatibleNestedPointerQualifiers - The assignment is between two
9914  /// nested pointer types, and the qualifiers other than the first two
9915  /// levels differ e.g. char ** -> const char **, but we accept them as an
9916  /// extension.
9918 
9919  /// IncompatibleVectors - The assignment is between two vector types that
9920  /// have the same size, which we accept as an extension.
9922 
9923  /// IntToBlockPointer - The assignment converts an int to a block
9924  /// pointer. We disallow this.
9926 
9927  /// IncompatibleBlockPointer - The assignment is between two block
9928  /// pointers types that are not compatible.
9930 
9931  /// IncompatibleObjCQualifiedId - The assignment is between a qualified
9932  /// id type and something else (that is incompatible with it). For example,
9933  /// "id <XXX>" = "Foo *", where "Foo *" doesn't implement the XXX protocol.
9935 
9936  /// IncompatibleObjCWeakRef - Assigning a weak-unavailable object to an
9937  /// object with __weak qualifier.
9939 
9940  /// Incompatible - We reject this conversion outright, it is invalid to
9941  /// represent it in the AST.
9942  Incompatible
9943  };
9944 
9945  /// DiagnoseAssignmentResult - Emit a diagnostic, if required, for the
9946  /// assignment conversion type specified by ConvTy. This returns true if the
9947  /// conversion was invalid or false if the conversion was accepted.
9948  bool DiagnoseAssignmentResult(AssignConvertType ConvTy,
9949  SourceLocation Loc,
9950  QualType DstType, QualType SrcType,
9951  Expr *SrcExpr, AssignmentAction Action,
9952  bool *Complained = nullptr);
9953 
9954  /// IsValueInFlagEnum - Determine if a value is allowed as part of a flag
9955  /// enum. If AllowMask is true, then we also allow the complement of a valid
9956  /// value, to be used as a mask.
9957  bool IsValueInFlagEnum(const EnumDecl *ED, const llvm::APInt &Val,
9958  bool AllowMask) const;
9959 
9960  /// DiagnoseAssignmentEnum - Warn if assignment to enum is a constant
9961  /// integer not in the range of enum values.
9962  void DiagnoseAssignmentEnum(QualType DstType, QualType SrcType,
9963  Expr *SrcExpr);
9964 
9965  /// CheckAssignmentConstraints - Perform type checking for assignment,
9966  /// argument passing, variable initialization, and function return values.
9967  /// C99 6.5.16.
9968  AssignConvertType CheckAssignmentConstraints(SourceLocation Loc,
9969  QualType LHSType,
9970  QualType RHSType);
9971 
9972  /// Check assignment constraints and optionally prepare for a conversion of
9973  /// the RHS to the LHS type. The conversion is prepared for if ConvertRHS
9974  /// is true.
9975  AssignConvertType CheckAssignmentConstraints(QualType LHSType,
9976  ExprResult &RHS,
9977  CastKind &Kind,
9978  bool ConvertRHS = true);
9979 
9980  /// Check assignment constraints for an assignment of RHS to LHSType.
9981  ///
9982  /// \param LHSType The destination type for the assignment.
9983  /// \param RHS The source expression for the assignment.
9984  /// \param Diagnose If \c true, diagnostics may be produced when checking
9985  /// for assignability. If a diagnostic is produced, \p RHS will be
9986  /// set to ExprError(). Note that this function may still return
9987  /// without producing a diagnostic, even for an invalid assignment.
9988  /// \param DiagnoseCFAudited If \c true, the target is a function parameter
9989  /// in an audited Core Foundation API and does not need to be checked
9990  /// for ARC retain issues.
9991  /// \param ConvertRHS If \c true, \p RHS will be updated to model the
9992  /// conversions necessary to perform the assignment. If \c false,
9993  /// \p Diagnose must also be \c false.
9994  AssignConvertType CheckSingleAssignmentConstraints(
9995  QualType LHSType, ExprResult &RHS, bool Diagnose = true,
9996  bool DiagnoseCFAudited = false, bool ConvertRHS = true);
9997 
9998  // If the lhs type is a transparent union, check whether we
9999  // can initialize the transparent union with the given expression.
10000  AssignConvertType CheckTransparentUnionArgumentConstraints(QualType ArgType,
10001  ExprResult &RHS);
10002 
10003  bool IsStringLiteralToNonConstPointerConversion(Expr *From, QualType ToType);
10004 
10005  bool CheckExceptionSpecCompatibility(Expr *From, QualType ToType);
10006 
10007  ExprResult PerformImplicitConversion(Expr *From, QualType ToType,
10008  AssignmentAction Action,
10009  bool AllowExplicit = false);
10010  ExprResult PerformImplicitConversion(Expr *From, QualType ToType,
10011  AssignmentAction Action,
10012  bool AllowExplicit,
10014  ExprResult PerformImplicitConversion(Expr *From, QualType ToType,
10015  const ImplicitConversionSequence& ICS,
10016  AssignmentAction Action,
10018  = CCK_ImplicitConversion);
10019  ExprResult PerformImplicitConversion(Expr *From, QualType ToType,
10020  const StandardConversionSequence& SCS,
10021  AssignmentAction Action,
10022  CheckedConversionKind CCK);
10023 
10024  ExprResult PerformQualificationConversion(
10025  Expr *E, QualType Ty, ExprValueKind VK = VK_RValue,
10026  CheckedConversionKind CCK = CCK_ImplicitConversion);
10027 
10028  /// the following "Check" methods will return a valid/converted QualType
10029  /// or a null QualType (indicating an error diagnostic was issued).
10030 
10031  /// type checking binary operators (subroutines of CreateBuiltinBinOp).
10032  QualType InvalidOperands(SourceLocation Loc, ExprResult &LHS,
10033  ExprResult &RHS);
10034  QualType InvalidLogicalVectorOperands(SourceLocation Loc, ExprResult &LHS,
10035  ExprResult &RHS);
10036  QualType CheckPointerToMemberOperands( // C++ 5.5
10037  ExprResult &LHS, ExprResult &RHS, ExprValueKind &VK,
10038  SourceLocation OpLoc, bool isIndirect);
10039  QualType CheckMultiplyDivideOperands( // C99 6.5.5
10040  ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, bool IsCompAssign,
10041  bool IsDivide);
10042  QualType CheckRemainderOperands( // C99 6.5.5
10043  ExprResult &LHS, ExprResult &RHS, SourceLocation Loc,
10044  bool IsCompAssign = false);
10045  QualType CheckAdditionOperands( // C99 6.5.6
10046  ExprResult &LHS, ExprResult &RHS, SourceLocation Loc,
10047  BinaryOperatorKind Opc, QualType* CompLHSTy = nullptr);
10048  QualType CheckSubtractionOperands( // C99 6.5.6
10049  ExprResult &LHS, ExprResult &RHS, SourceLocation Loc,
10050  QualType* CompLHSTy = nullptr);
10051  QualType CheckShiftOperands( // C99 6.5.7
10052  ExprResult &LHS, ExprResult &RHS, SourceLocation Loc,
10053  BinaryOperatorKind Opc, bool IsCompAssign = false);
10054  QualType CheckCompareOperands( // C99 6.5.8/9
10055  ExprResult &LHS, ExprResult &RHS, SourceLocation Loc,
10056  BinaryOperatorKind Opc);
10057  QualType CheckBitwiseOperands( // C99 6.5.[10...12]
10058  ExprResult &LHS, ExprResult &RHS, SourceLocation Loc,
10059  BinaryOperatorKind Opc);
10060  QualType CheckLogicalOperands( // C99 6.5.[13,14]
10061  ExprResult &LHS, ExprResult &RHS, SourceLocation Loc,
10062  BinaryOperatorKind Opc);
10063  // CheckAssignmentOperands is used for both simple and compound assignment.
10064  // For simple assignment, pass both expressions and a null converted type.
10065  // For compound assignment, pass both expressions and the converted type.
10066  QualType CheckAssignmentOperands( // C99 6.5.16.[1,2]
10067  Expr *LHSExpr, ExprResult &RHS, SourceLocation Loc, QualType CompoundType);
10068 
10069  ExprResult checkPseudoObjectIncDec(Scope *S, SourceLocation OpLoc,
10070  UnaryOperatorKind Opcode, Expr *Op);
10071  ExprResult checkPseudoObjectAssignment(Scope *S, SourceLocation OpLoc,
10072  BinaryOperatorKind Opcode,
10073  Expr *LHS, Expr *RHS);
10074  ExprResult checkPseudoObjectRValue(Expr *E);
10075  Expr *recreateSyntacticForm(PseudoObjectExpr *E);
10076 
10077  QualType CheckConditionalOperands( // C99 6.5.15
10078  ExprResult &Cond, ExprResult &LHS, ExprResult &RHS,
10079  ExprValueKind &VK, ExprObjectKind &OK, SourceLocation QuestionLoc);
10080  QualType CXXCheckConditionalOperands( // C++ 5.16
10081  ExprResult &cond, ExprResult &lhs, ExprResult &rhs,
10082  ExprValueKind &VK, ExprObjectKind &OK, SourceLocation questionLoc);
10083  QualType FindCompositePointerType(SourceLocation Loc, Expr *&E1, Expr *&E2,
10084  bool ConvertArgs = true);
10086  ExprResult &E1, ExprResult &E2,
10087  bool ConvertArgs = true) {
10088  Expr *E1Tmp = E1.get(), *E2Tmp = E2.get();
10089  QualType Composite =
10090  FindCompositePointerType(Loc, E1Tmp, E2Tmp, ConvertArgs);
10091  E1 = E1Tmp;
10092  E2 = E2Tmp;
10093  return Composite;
10094  }
10095 
10096  QualType FindCompositeObjCPointerType(ExprResult &LHS, ExprResult &RHS,
10097  SourceLocation QuestionLoc);
10098 
10099  bool DiagnoseConditionalForNull(Expr *LHSExpr, Expr *RHSExpr,
10100  SourceLocation QuestionLoc);
10101 
10102  void DiagnoseAlwaysNonNullPointer(Expr *E,
10104  bool IsEqual, SourceRange Range);
10105 
10106  /// type checking for vector binary operators.
10107  QualType CheckVectorOperands(ExprResult &LHS, ExprResult &RHS,
10108  SourceLocation Loc, bool IsCompAssign,
10109  bool AllowBothBool, bool AllowBoolConversion);
10110  QualType GetSignedVectorType(QualType V);
10111  QualType CheckVectorCompareOperands(ExprResult &LHS, ExprResult &RHS,
10112  SourceLocation Loc,
10113  BinaryOperatorKind Opc);
10114  QualType CheckVectorLogicalOperands(ExprResult &LHS, ExprResult &RHS,
10115  SourceLocation Loc);
10116 
10117  bool areLaxCompatibleVectorTypes(QualType srcType, QualType destType);
10118  bool isLaxVectorConversion(QualType srcType, QualType destType);
10119 
10120  /// type checking declaration initializers (C99 6.7.8)
10121  bool CheckForConstantInitializer(Expr *e, QualType t);
10122 
10123  // type checking C++ declaration initializers (C++ [dcl.init]).
10124 
10125  /// ReferenceCompareResult - Expresses the result of comparing two
10126  /// types (cv1 T1 and cv2 T2) to determine their compatibility for the
10127  /// purposes of initialization by reference (C++ [dcl.init.ref]p4).
10129  /// Ref_Incompatible - The two types are incompatible, so direct
10130  /// reference binding is not possible.
10131  Ref_Incompatible = 0,
10132  /// Ref_Related - The two types are reference-related, which means
10133  /// that their unqualified forms (T1 and T2) are either the same
10134  /// or T1 is a base class of T2.
10136  /// Ref_Compatible - The two types are reference-compatible.
10137  Ref_Compatible
10138  };
10139 
10140  ReferenceCompareResult CompareReferenceRelationship(SourceLocation Loc,
10141  QualType T1, QualType T2,
10142  bool &DerivedToBase,
10143  bool &ObjCConversion,
10144  bool &ObjCLifetimeConversion);
10145 
10146  ExprResult checkUnknownAnyCast(SourceRange TypeRange, QualType CastType,
10147  Expr *CastExpr, CastKind &CastKind,
10148  ExprValueKind &VK, CXXCastPath &Path);
10149 
10150  /// Force an expression with unknown-type to an expression of the
10151  /// given type.
10152  ExprResult forceUnknownAnyToType(Expr *E, QualType ToType);
10153 
10154  /// Type-check an expression that's being passed to an
10155  /// __unknown_anytype parameter.
10156  ExprResult checkUnknownAnyArg(SourceLocation callLoc,
10157  Expr *result, QualType &paramType);
10158 
10159  // CheckVectorCast - check type constraints for vectors.
10160  // Since vectors are an extension, there are no C standard reference for this.
10161  // We allow casting between vectors and integer datatypes of the same size.
10162  // returns true if the cast is invalid
10163  bool CheckVectorCast(SourceRange R, QualType VectorTy, QualType Ty,
10164  CastKind &Kind);
10165 
10166  /// Prepare `SplattedExpr` for a vector splat operation, adding
10167  /// implicit casts if necessary.
10168  ExprResult prepareVectorSplat(QualType VectorTy, Expr *SplattedExpr);
10169 
10170  // CheckExtVectorCast - check type constraints for extended vectors.
10171  // Since vectors are an extension, there are no C standard reference for this.
10172  // We allow casting between vectors and integer datatypes of the same size,
10173  // or vectors and the element type of that vector.
10174  // returns the cast expr
10175  ExprResult CheckExtVectorCast(SourceRange R, QualType DestTy, Expr *CastExpr,
10176  CastKind &Kind);
10177 
10178  ExprResult BuildCXXFunctionalCastExpr(TypeSourceInfo *TInfo, QualType Type,
10179  SourceLocation LParenLoc,
10180  Expr *CastExpr,
10181  SourceLocation RParenLoc);
10182 
10183  enum ARCConversionResult { ACR_okay, ACR_unbridged, ACR_error };
10184 
10185  /// Checks for invalid conversions and casts between
10186  /// retainable pointers and other pointer kinds for ARC and Weak.
10187  ARCConversionResult CheckObjCConversion(SourceRange castRange,
10188  QualType castType, Expr *&op,
10190  bool Diagnose = true,
10191  bool DiagnoseCFAudited = false,
10192  BinaryOperatorKind Opc = BO_PtrMemD
10193  );
10194 
10195  Expr *stripARCUnbridgedCast(Expr *e);
10196  void diagnoseARCUnbridgedCast(Expr *e);
10197 
10198  bool CheckObjCARCUnavailableWeakConversion(QualType castType,
10199  QualType ExprType);
10200 
10201  /// checkRetainCycles - Check whether an Objective-C message send
10202  /// might create an obvious retain cycle.
10203  void checkRetainCycles(ObjCMessageExpr *msg);
10204  void checkRetainCycles(Expr *receiver, Expr *argument);
10205  void checkRetainCycles(VarDecl *Var, Expr *Init);
10206 
10207  /// checkUnsafeAssigns - Check whether +1 expr is being assigned
10208  /// to weak/__unsafe_unretained type.
10209  bool checkUnsafeAssigns(SourceLocation Loc, QualType LHS, Expr *RHS);
10210 
10211  /// checkUnsafeExprAssigns - Check whether +1 expr is being assigned
10212  /// to weak/__unsafe_unretained expression.
10213  void checkUnsafeExprAssigns(SourceLocation Loc, Expr *LHS, Expr *RHS);
10214 
10215  /// CheckMessageArgumentTypes - Check types in an Obj-C message send.
10216  /// \param Method - May be null.
10217  /// \param [out] ReturnType - The return type of the send.
10218  /// \return true iff there were any incompatible types.
10219  bool CheckMessageArgumentTypes(const Expr *Receiver, QualType ReceiverType,
10220  MultiExprArg Args, Selector Sel,
10221  ArrayRef<SourceLocation> SelectorLocs,
10222  ObjCMethodDecl *Method, bool isClassMessage,
10223  bool isSuperMessage, SourceLocation lbrac,
10224  SourceLocation rbrac, SourceRange RecRange,
10225  QualType &ReturnType, ExprValueKind &VK);
10226 
10227  /// Determine the result of a message send expression based on
10228  /// the type of the receiver, the method expected to receive the message,
10229  /// and the form of the message send.
10230  QualType getMessageSendResultType(const Expr *Receiver, QualType ReceiverType,
10231  ObjCMethodDecl *Method, bool isClassMessage,
10232  bool isSuperMessage);
10233 
10234  /// If the given expression involves a message send to a method
10235  /// with a related result type, emit a note describing what happened.
10236  void EmitRelatedResultTypeNote(const Expr *E);
10237 
10238  /// Given that we had incompatible pointer types in a return
10239  /// statement, check whether we're in a method with a related result
10240  /// type, and if so, emit a note describing what happened.
10241  void EmitRelatedResultTypeNoteForReturn(QualType destType);
10242 
10244  Decl *ConditionVar;
10245  FullExprArg Condition;
10246  bool Invalid;
10247  bool HasKnownValue;
10248  bool KnownValue;
10249 
10250  friend class Sema;
10251  ConditionResult(Sema &S, Decl *ConditionVar, FullExprArg Condition,
10252  bool IsConstexpr)
10253  : ConditionVar(ConditionVar), Condition(Condition), Invalid(false),
10254  HasKnownValue(IsConstexpr && Condition.get() &&
10255  !Condition.get()->isValueDependent()),
10256  KnownValue(HasKnownValue &&
10257  !!Condition.get()->EvaluateKnownConstInt(S.Context)) {}
10258  explicit ConditionResult(bool Invalid)
10259  : ConditionVar(nullptr), Condition(nullptr), Invalid(Invalid),
10260  HasKnownValue(false), KnownValue(false) {}
10261 
10262  public:
10264  bool isInvalid() const { return Invalid; }
10265  std::pair<VarDecl *, Expr *> get() const {
10266  return std::make_pair(cast_or_null<VarDecl>(ConditionVar),
10267  Condition.get());
10268  }
10270  if (!HasKnownValue)
10271  return None;
10272  return KnownValue;
10273  }
10274  };
10276 
10277  enum class ConditionKind {
10278  Boolean, ///< A boolean condition, from 'if', 'while', 'for', or 'do'.
10279  ConstexprIf, ///< A constant boolean condition from 'if constexpr'.
10280  Switch ///< An integral condition for a 'switch' statement.
10281  };
10282 
10283  ConditionResult ActOnCondition(Scope *S, SourceLocation Loc,
10284  Expr *SubExpr, ConditionKind CK);
10285 
10286  ConditionResult ActOnConditionVariable(Decl *ConditionVar,
10287  SourceLocation StmtLoc,
10288  ConditionKind CK);
10289 
10290  DeclResult ActOnCXXConditionDeclaration(Scope *S, Declarator &D);
10291 
10292  ExprResult CheckConditionVariable(VarDecl *ConditionVar,
10293  SourceLocation StmtLoc,
10294  ConditionKind CK);
10295  ExprResult CheckSwitchCondition(SourceLocation SwitchLoc, Expr *Cond);
10296 
10297  /// CheckBooleanCondition - Diagnose problems involving the use of
10298  /// the given expression as a boolean condition (e.g. in an if
10299  /// statement). Also performs the standard function and array
10300  /// decays, possibly changing the input variable.
10301  ///
10302  /// \param Loc - A location associated with the condition, e.g. the
10303  /// 'if' keyword.
10304  /// \return true iff there were any errors
10305  ExprResult CheckBooleanCondition(SourceLocation Loc, Expr *E,
10306  bool IsConstexpr = false);
10307 
10308  /// ActOnExplicitBoolSpecifier - Build an ExplicitSpecifier from an expression
10309  /// found in an explicit(bool) specifier.
10310  ExplicitSpecifier ActOnExplicitBoolSpecifier(Expr *E);
10311 
10312  /// tryResolveExplicitSpecifier - Attempt to resolve the explict specifier.
10313  /// Returns true if the explicit specifier is now resolved.
10314  bool tryResolveExplicitSpecifier(ExplicitSpecifier &ExplicitSpec);
10315 
10316  /// DiagnoseAssignmentAsCondition - Given that an expression is
10317  /// being used as a boolean condition, warn if it's an assignment.
10318  void DiagnoseAssignmentAsCondition(Expr *E);
10319 
10320  /// Redundant parentheses over an equality comparison can indicate
10321  /// that the user intended an assignment used as condition.
10322  void DiagnoseEqualityWithExtraParens(ParenExpr *ParenE);
10323 
10324  /// CheckCXXBooleanCondition - Returns true if conversion to bool is invalid.
10325  ExprResult CheckCXXBooleanCondition(Expr *CondExpr, bool IsConstexpr = false);
10326 
10327  /// ConvertIntegerToTypeWarnOnOverflow - Convert the specified APInt to have
10328  /// the specified width and sign. If an overflow occurs, detect it and emit
10329  /// the specified diagnostic.
10330  void ConvertIntegerToTypeWarnOnOverflow(llvm::APSInt &OldVal,
10331  unsigned NewWidth, bool NewSign,
10332  SourceLocation Loc, unsigned DiagID);
10333 
10334  /// Checks that the Objective-C declaration is declared in the global scope.
10335  /// Emits an error and marks the declaration as invalid if it's not declared
10336  /// in the global scope.
10337  bool CheckObjCDeclScope(Decl *D);
10338 
10339  /// Abstract base class used for diagnosing integer constant
10340  /// expression violations.
10342  public:
10343  bool Suppress;
10344 
10345  VerifyICEDiagnoser(bool Suppress = false) : Suppress(Suppress) { }
10346 
10347  virtual void diagnoseNotICE(Sema &S, SourceLocation Loc, SourceRange SR) =0;
10348  virtual void diagnoseFold(Sema &S, SourceLocation Loc, SourceRange SR);
10349  virtual ~VerifyICEDiagnoser() { }
10350  };
10351 
10352  /// VerifyIntegerConstantExpression - Verifies that an expression is an ICE,
10353  /// and reports the appropriate diagnostics. Returns false on success.
10354  /// Can optionally return the value of the expression.
10355  ExprResult VerifyIntegerConstantExpression(Expr *E, llvm::APSInt *Result,
10356  VerifyICEDiagnoser &Diagnoser,
10357  bool AllowFold = true);
10358  ExprResult VerifyIntegerConstantExpression(Expr *E, llvm::APSInt *Result,
10359  unsigned DiagID,
10360  bool AllowFold = true);
10361  ExprResult VerifyIntegerConstantExpression(Expr *E,
10362  llvm::APSInt *Result = nullptr);
10363 
10364  /// VerifyBitField - verifies that a bit field expression is an ICE and has
10365  /// the correct width, and that the field type is valid.
10366  /// Returns false on success.
10367  /// Can optionally return whether the bit-field is of width 0
10368  ExprResult VerifyBitField(SourceLocation FieldLoc, IdentifierInfo *FieldName,
10369  QualType FieldTy, bool IsMsStruct,
10370  Expr *BitWidth, bool *ZeroWidth = nullptr);
10371 
10372 private:
10373  unsigned ForceCUDAHostDeviceDepth = 0;
10374 
10375 public:
10376  /// Increments our count of the number of times we've seen a pragma forcing
10377  /// functions to be __host__ __device__. So long as this count is greater
10378  /// than zero, all functions encountered will be __host__ __device__.
10379  void PushForceCUDAHostDevice();
10380 
10381  /// Decrements our count of the number of times we've seen a pragma forcing
10382  /// functions to be __host__ __device__. Returns false if the count is 0
10383  /// before incrementing, so you can emit an error.
10384  bool PopForceCUDAHostDevice();
10385 
10386  /// Diagnostics that are emitted only if we discover that the given function
10387  /// must be codegen'ed. Because handling these correctly adds overhead to
10388  /// compilation, this is currently only enabled for CUDA compilations.
10389  llvm::DenseMap<CanonicalDeclPtr<FunctionDecl>,
10390  std::vector<PartialDiagnosticAt>>
10392 
10393  /// A pair of a canonical FunctionDecl and a SourceLocation. When used as the
10394  /// key in a hashtable, both the FD and location are hashed.
10398  };
10399 
10400  /// FunctionDecls and SourceLocations for which CheckCUDACall has emitted a
10401  /// (maybe deferred) "bad call" diagnostic. We use this to avoid emitting the
10402  /// same deferred diag twice.
10404 
10405  /// An inverse call graph, mapping known-emitted functions to one of their
10406  /// known-emitted callers (plus the location of the call).
10407  ///
10408  /// Functions that we can tell a priori must be emitted aren't added to this
10409  /// map.
10410  llvm::DenseMap</* Callee = */ CanonicalDeclPtr<FunctionDecl>,
10411  /* Caller = */ FunctionDeclAndLoc>
10413 
10414  /// A partial call graph maintained during CUDA/OpenMP device code compilation
10415  /// to support deferred diagnostics.
10416  ///
10417  /// Functions are only added here if, at the time they're considered, they are
10418  /// not known-emitted. As soon as we discover that a function is
10419  /// known-emitted, we remove it and everything it transitively calls from this
10420  /// set and add those functions to DeviceKnownEmittedFns.
10421  llvm::DenseMap</* Caller = */ CanonicalDeclPtr<FunctionDecl>,
10422  /* Callees = */ llvm::MapVector<CanonicalDeclPtr<FunctionDecl>,
10423  SourceLocation>>
10425 
10426  /// Diagnostic builder for CUDA/OpenMP devices errors which may or may not be
10427  /// deferred.
10428  ///
10429  /// In CUDA, there exist constructs (e.g. variable-length arrays, try/catch)
10430  /// which are not allowed to appear inside __device__ functions and are
10431  /// allowed to appear in __host__ __device__ functions only if the host+device
10432  /// function is never codegen'ed.
10433  ///
10434  /// To handle this, we use the notion of "deferred diagnostics", where we
10435  /// attach a diagnostic to a FunctionDecl that's emitted iff it's codegen'ed.
10436  ///
10437  /// This class lets you emit either a regular diagnostic, a deferred
10438  /// diagnostic, or no diagnostic at all, according to an argument you pass to
10439  /// its constructor, thus simplifying the process of creating these "maybe
10440  /// deferred" diagnostics.
10442  public:
10443  enum Kind {
10444  /// Emit no diagnostics.
10446  /// Emit the diagnostic immediately (i.e., behave like Sema::Diag()).
10448  /// Emit the diagnostic immediately, and, if it's a warning or error, also
10449  /// emit a call stack showing how this function can be reached by an a
10450  /// priori known-emitted function.
10452  /// Create a deferred diagnostic, which is emitted only if the function
10453  /// it's attached to is codegen'ed. Also emit a call stack as with
10454  /// K_ImmediateWithCallStack.
10455  K_Deferred
10456  };
10457 
10458  DeviceDiagBuilder(Kind K, SourceLocation Loc, unsigned DiagID,
10459  FunctionDecl *Fn, Sema &S);
10461  DeviceDiagBuilder(const DeviceDiagBuilder &) = default;
10462  ~DeviceDiagBuilder();
10463 
10464  /// Convertible to bool: True if we immediately emitted an error, false if
10465  /// we didn't emit an error or we created a deferred error.
10466  ///
10467  /// Example usage:
10468  ///
10469  /// if (DeviceDiagBuilder(...) << foo << bar)
10470  /// return ExprError();
10471  ///
10472  /// But see CUDADiagIfDeviceCode() and CUDADiagIfHostCode() -- you probably
10473  /// want to use these instead of creating a DeviceDiagBuilder yourself.
10474  operator bool() const { return ImmediateDiag.hasValue(); }
10475 
10476  template <typename T>
10478  const T &Value) {
10479  if (Diag.ImmediateDiag.hasValue())
10480  *Diag.ImmediateDiag << Value;
10481  else if (Diag.PartialDiagId.hasValue())
10482  Diag.S.DeviceDeferredDiags[Diag.Fn][*Diag.PartialDiagId].second
10483  << Value;
10484  return Diag;
10485  }
10486 
10487  private:
10488  Sema &S;
10489  SourceLocation Loc;
10490  unsigned DiagID;
10491  FunctionDecl *Fn;
10492  bool ShowCallStack;
10493 
10494  // Invariant: At most one of these Optionals has a value.
10495  // FIXME: Switch these to a Variant once that exists.
10497  llvm::Optional<unsigned> PartialDiagId;
10498  };
10499 
10500  /// Indicate that this function (and thus everything it transtively calls)
10501  /// will be codegen'ed, and emit any deferred diagnostics on this function and
10502  /// its (transitive) callees.
10503  void markKnownEmitted(
10504  Sema &S, FunctionDecl *OrigCaller, FunctionDecl *OrigCallee,
10505  SourceLocation OrigLoc,
10506  const llvm::function_ref<bool(Sema &, FunctionDecl *)> IsKnownEmitted);
10507 
10508  /// Creates a DeviceDiagBuilder that emits the diagnostic if the current context
10509  /// is "used as device code".
10510  ///
10511  /// - If CurContext is a __host__ function, does not emit any diagnostics.
10512  /// - If CurContext is a __device__ or __global__ function, emits the
10513  /// diagnostics immediately.
10514  /// - If CurContext is a __host__ __device__ function and we are compiling for
10515  /// the device, creates a diagnostic which is emitted if and when we realize
10516  /// that the function will be codegen'ed.
10517  ///
10518  /// Example usage:
10519  ///
10520  /// // Variable-length arrays are not allowed in CUDA device code.
10521  /// if (CUDADiagIfDeviceCode(Loc, diag::err_cuda_vla) << CurrentCUDATarget())
10522  /// return ExprError();
10523  /// // Otherwise, continue parsing as normal.
10524  DeviceDiagBuilder CUDADiagIfDeviceCode(SourceLocation Loc, unsigned DiagID);
10525 
10526  /// Creates a DeviceDiagBuilder that emits the diagnostic if the current context
10527  /// is "used as host code".
10528  ///
10529  /// Same as CUDADiagIfDeviceCode, with "host" and "device" switched.
10530  DeviceDiagBuilder CUDADiagIfHostCode(SourceLocation Loc, unsigned DiagID);
10531 
10532  /// Creates a DeviceDiagBuilder that emits the diagnostic if the current
10533  /// context is "used as device code".
10534  ///
10535  /// - If CurContext is a `declare target` function or it is known that the
10536  /// function is emitted for the device, emits the diagnostics immediately.
10537  /// - If CurContext is a non-`declare target` function and we are compiling
10538  /// for the device, creates a diagnostic which is emitted if and when we
10539  /// realize that the function will be codegen'ed.
10540  ///
10541  /// Example usage:
10542  ///
10543  /// // Variable-length arrays are not allowed in NVPTX device code.
10544  /// if (diagIfOpenMPDeviceCode(Loc, diag::err_vla_unsupported))
10545  /// return ExprError();
10546  /// // Otherwise, continue parsing as normal.
10547  DeviceDiagBuilder diagIfOpenMPDeviceCode(SourceLocation Loc, unsigned DiagID);
10548 
10549  DeviceDiagBuilder targetDiag(SourceLocation Loc, unsigned DiagID);
10550 
10556  CFT_InvalidTarget
10557  };
10558 
10559  /// Determines whether the given function is a CUDA device/host/kernel/etc.
10560  /// function.
10561  ///
10562  /// Use this rather than examining the function's attributes yourself -- you
10563  /// will get it wrong. Returns CFT_Host if D is null.
10564  CUDAFunctionTarget IdentifyCUDATarget(const FunctionDecl *D,
10565  bool IgnoreImplicitHDAttr = false);
10566  CUDAFunctionTarget IdentifyCUDATarget(const ParsedAttributesView &Attrs);
10567 
10568  /// Gets the CUDA target for the current context.
10570  return IdentifyCUDATarget(dyn_cast<FunctionDecl>(CurContext));
10571  }
10572 
10573  // CUDA function call preference. Must be ordered numerically from
10574  // worst to best.
10576  CFP_Never, // Invalid caller/callee combination.
10577  CFP_WrongSide, // Calls from host-device to host or device
10578  // function that do not match current compilation
10579  // mode.
10580  CFP_HostDevice, // Any calls to host/device functions.
10581  CFP_SameSide, // Calls from host-device to host or device
10582  // function matching current compilation mode.
10583  CFP_Native, // host-to-host or device-to-device calls.
10584  };
10585 
10586  /// Identifies relative preference of a given Caller/Callee
10587  /// combination, based on their host/device attributes.
10588  /// \param Caller function which needs address of \p Callee.
10589  /// nullptr in case of global context.
10590  /// \param Callee target function
10591  ///
10592  /// \returns preference value for particular Caller/Callee combination.
10593  CUDAFunctionPreference IdentifyCUDAPreference(const FunctionDecl *Caller,
10594  const FunctionDecl *Callee);
10595 
10596  /// Determines whether Caller may invoke Callee, based on their CUDA
10597  /// host/device attributes. Returns false if the call is not allowed.
10598  ///
10599  /// Note: Will return true for CFP_WrongSide calls. These may appear in
10600  /// semantically correct CUDA programs, but only if they're never codegen'ed.
10601  bool IsAllowedCUDACall(const FunctionDecl *Caller,
10602  const FunctionDecl *Callee) {
10603  return IdentifyCUDAPreference(Caller, Callee) != CFP_Never;
10604  }
10605 
10606  /// May add implicit CUDAHostAttr and CUDADeviceAttr attributes to FD,
10607  /// depending on FD and the current compilation settings.
10608  void maybeAddCUDAHostDeviceAttrs(FunctionDecl *FD,
10609  const LookupResult &Previous);
10610 
10611 public:
10612  /// Check whether we're allowed to call Callee from the current context.
10613  ///
10614  /// - If the call is never allowed in a semantically-correct program
10615  /// (CFP_Never), emits an error and returns false.
10616  ///
10617  /// - If the call is allowed in semantically-correct programs, but only if
10618  /// it's never codegen'ed (CFP_WrongSide), creates a deferred diagnostic to
10619  /// be emitted if and when the caller is codegen'ed, and returns true.
10620  ///
10621  /// Will only create deferred diagnostics for a given SourceLocation once,
10622  /// so you can safely call this multiple times without generating duplicate
10623  /// deferred errors.
10624  ///
10625  /// - Otherwise, returns true without emitting any diagnostics.
10626  bool CheckCUDACall(SourceLocation Loc, FunctionDecl *Callee);
10627 
10628  /// Set __device__ or __host__ __device__ attributes on the given lambda
10629  /// operator() method.
10630  ///
10631  /// CUDA lambdas declared inside __device__ or __global__ functions inherit
10632  /// the __device__ attribute. Similarly, lambdas inside __host__ __device__
10633  /// functions become __host__ __device__ themselves.
10634  void CUDASetLambdaAttrs(CXXMethodDecl *Method);
10635 
10636  /// Finds a function in \p Matches with highest calling priority
10637  /// from \p Caller context and erases all functions with lower
10638  /// calling priority.
10639  void EraseUnwantedCUDAMatches(
10640  const FunctionDecl *Caller,
10641  SmallVectorImpl<std::pair<DeclAccessPair, FunctionDecl *>> &Matches);
10642 
10643  /// Given a implicit special member, infer its CUDA target from the
10644  /// calls it needs to make to underlying base/field special members.
10645  /// \param ClassDecl the class for which the member is being created.
10646  /// \param CSM the kind of special member.
10647  /// \param MemberDecl the special member itself.
10648  /// \param ConstRHS true if this is a copy operation with a const object on
10649  /// its RHS.
10650  /// \param Diagnose true if this call should emit diagnostics.
10651  /// \return true if there was an error inferring.
10652  /// The result of this call is implicit CUDA target attribute(s) attached to
10653  /// the member declaration.
10654  bool inferCUDATargetForImplicitSpecialMember(CXXRecordDecl *ClassDecl,
10655  CXXSpecialMember CSM,
10656  CXXMethodDecl *MemberDecl,
10657  bool ConstRHS,
10658  bool Diagnose);
10659 
10660  /// \return true if \p CD can be considered empty according to CUDA
10661  /// (E.2.3.1 in CUDA 7.5 Programming guide).
10662  bool isEmptyCudaConstructor(SourceLocation Loc, CXXConstructorDecl *CD);
10663  bool isEmptyCudaDestructor(SourceLocation Loc, CXXDestructorDecl *CD);
10664 
10665  // \brief Checks that initializers of \p Var satisfy CUDA restrictions. In
10666  // case of error emits appropriate diagnostic and invalidates \p Var.
10667  //
10668  // \details CUDA allows only empty constructors as initializers for global
10669  // variables (see E.2.3.1, CUDA 7.5). The same restriction also applies to all
10670  // __shared__ variables whether they are local or not (they all are implicitly
10671  // static in CUDA). One exception is that CUDA allows constant initializers
10672  // for __constant__ and __device__ variables.
10673  void checkAllowedCUDAInitializer(VarDecl *VD);
10674 
10675  /// Check whether NewFD is a valid overload for CUDA. Emits
10676  /// diagnostics and invalidates NewFD if not.
10677  void checkCUDATargetOverload(FunctionDecl *NewFD,
10678  const LookupResult &Previous);
10679  /// Copies target attributes from the template TD to the function FD.
10680  void inheritCUDATargetAttrs(FunctionDecl *FD, const FunctionTemplateDecl &TD);
10681 
10682  /// Returns the name of the launch configuration function. This is the name
10683  /// of the function that will be called to configure kernel call, with the
10684  /// parameters specified via <<<>>>.
10685  std::string getCudaConfigureFuncName() const;
10686 
10687  /// \name Code completion
10688  //@{
10689  /// Describes the context in which code completion occurs.
10691  /// Code completion occurs at top-level or namespace context.
10693  /// Code completion occurs within a class, struct, or union.
10695  /// Code completion occurs within an Objective-C interface, protocol,
10696  /// or category.
10698  /// Code completion occurs within an Objective-C implementation or
10699  /// category implementation
10701  /// Code completion occurs within the list of instance variables
10702  /// in an Objective-C interface, protocol, category, or implementation.
10704  /// Code completion occurs following one or more template
10705  /// headers.
10707  /// Code completion occurs following one or more template
10708  /// headers within a class.
10710  /// Code completion occurs within an expression.
10712  /// Code completion occurs within a statement, which may
10713  /// also be an expression or a declaration.
10715  /// Code completion occurs at the beginning of the
10716  /// initialization statement (or expression) in a for loop.
10718  /// Code completion occurs within the condition of an if,
10719  /// while, switch, or for statement.
10721  /// Code completion occurs within the body of a function on a
10722  /// recovery path, where we do not have a specific handle on our position
10723  /// in the grammar.
10725  /// Code completion occurs where only a type is permitted.
10727  /// Code completion occurs in a parenthesized expression, which
10728  /// might also be a type cast.
10730  /// Code completion occurs within a sequence of declaration
10731  /// specifiers within a function, method, or block.
10732  PCC_LocalDeclarationSpecifiers
10733  };
10734 
10735  void CodeCompleteModuleImport(SourceLocation ImportLoc, ModuleIdPath Path);
10736  void CodeCompleteOrdinaryName(Scope *S,
10737  ParserCompletionContext CompletionContext);
10738  void CodeCompleteDeclSpec(Scope *S, DeclSpec &DS,
10739  bool AllowNonIdentifiers,
10740  bool AllowNestedNameSpecifiers);
10741 
10743  void CodeCompleteExpression(Scope *S,
10744  const CodeCompleteExpressionData &Data);
10745  void CodeCompleteExpression(Scope *S, QualType PreferredType,
10746  bool IsParenthesized = false);
10747  void CodeCompleteMemberReferenceExpr(Scope *S, Expr *Base, Expr *OtherOpBase,
10748  SourceLocation OpLoc, bool IsArrow,
10749  bool IsBaseExprStatement,
10750  QualType PreferredType);
10751  void CodeCompletePostfixExpression(Scope *S, ExprResult LHS,
10752  QualType PreferredType);
10753  void CodeCompleteTag(Scope *S, unsigned TagSpec);
10754  void CodeCompleteTypeQualifiers(DeclSpec &DS);
10755  void CodeCompleteFunctionQualifiers(DeclSpec &DS, Declarator &D,
10756  const VirtSpecifiers *VS = nullptr);
10757  void CodeCompleteBracketDeclarator(Scope *S);
10758  void CodeCompleteCase(Scope *S);
10759  /// Reports signatures for a call to CodeCompleteConsumer and returns the
10760  /// preferred type for the current argument. Returned type can be null.
10761  QualType ProduceCallSignatureHelp(Scope *S, Expr *Fn, ArrayRef<Expr *> Args,
10762  SourceLocation OpenParLoc);
10763  QualType ProduceConstructorSignatureHelp(Scope *S, QualType Type,
10764  SourceLocation Loc,
10765  ArrayRef<Expr *> Args,
10766  SourceLocation OpenParLoc);
10767  QualType ProduceCtorInitMemberSignatureHelp(Scope *S, Decl *ConstructorDecl,
10768  CXXScopeSpec SS,
10769  ParsedType TemplateTypeTy,
10770  ArrayRef<Expr *> ArgExprs,
10771  IdentifierInfo *II,
10772  SourceLocation OpenParLoc);
10773  void CodeCompleteInitializer(Scope *S, Decl *D);
10774  void CodeCompleteAfterIf(Scope *S);
10775 
10776  void CodeCompleteQualifiedId(Scope *S, CXXScopeSpec &SS, bool EnteringContext,
10777  QualType BaseType, QualType PreferredType);
10778  void CodeCompleteUsing(Scope *S);
10779  void CodeCompleteUsingDirective(Scope *S);
10780  void CodeCompleteNamespaceDecl(Scope *S);
10781  void CodeCompleteNamespaceAliasDecl(Scope *S);
10782  void CodeCompleteOperatorName(Scope *S);
10783  void CodeCompleteConstructorInitializer(
10784  Decl *Constructor,
10785  ArrayRef<CXXCtorInitializer *> Initializers);
10786 
10787  void CodeCompleteLambdaIntroducer(Scope *S, LambdaIntroducer &Intro,
10788  bool AfterAmpersand);
10789 
10790  void CodeCompleteObjCAtDirective(Scope *S);
10791  void CodeCompleteObjCAtVisibility(Scope *S);
10792  void CodeCompleteObjCAtStatement(Scope *S);
10793  void CodeCompleteObjCAtExpression(Scope *S);
10794  void CodeCompleteObjCPropertyFlags(Scope *S, ObjCDeclSpec &ODS);
10795  void CodeCompleteObjCPropertyGetter(Scope *S);
10796  void CodeCompleteObjCPropertySetter(Scope *S);
10797  void CodeCompleteObjCPassingType(Scope *S, ObjCDeclSpec &DS,
10798  bool IsParameter);
10799  void CodeCompleteObjCMessageReceiver(Scope *S);
10800  void CodeCompleteObjCSuperMessage(Scope *S, SourceLocation SuperLoc,
10801  ArrayRef<IdentifierInfo *> SelIdents,
10802  bool AtArgumentExpression);
10803  void CodeCompleteObjCClassMessage(Scope *S, ParsedType Receiver,
10804  ArrayRef<IdentifierInfo *> SelIdents,
10805  bool AtArgumentExpression,
10806  bool IsSuper = false);
10807  void CodeCompleteObjCInstanceMessage(Scope *S, Expr *Receiver,
10808  ArrayRef<IdentifierInfo *> SelIdents,
10809  bool AtArgumentExpression,
10810  ObjCInterfaceDecl *Super = nullptr);
10811  void CodeCompleteObjCForCollection(Scope *S,
10812  DeclGroupPtrTy IterationVar);
10813  void CodeCompleteObjCSelector(Scope *S,
10814  ArrayRef<IdentifierInfo *> SelIdents);
10815  void CodeCompleteObjCProtocolReferences(
10816  ArrayRef<IdentifierLocPair> Protocols);
10817  void CodeCompleteObjCProtocolDecl(Scope *S);
10818  void CodeCompleteObjCInterfaceDecl(Scope *S);
10819  void CodeCompleteObjCSuperclass(Scope *S,
10820  IdentifierInfo *ClassName,
10821  SourceLocation ClassNameLoc);
10822  void CodeCompleteObjCImplementationDecl(Scope *S);
10823  void CodeCompleteObjCInterfaceCategory(Scope *S,
10824  IdentifierInfo *ClassName,
10825  SourceLocation ClassNameLoc);
10826  void CodeCompleteObjCImplementationCategory(Scope *S,
10827  IdentifierInfo *ClassName,
10828  SourceLocation ClassNameLoc);
10829  void CodeCompleteObjCPropertyDefinition(Scope *S);
10830  void CodeCompleteObjCPropertySynthesizeIvar(Scope *S,
10831  IdentifierInfo *PropertyName);
10832  void CodeCompleteObjCMethodDecl(Scope *S, Optional<bool> IsInstanceMethod,
10833  ParsedType ReturnType);
10834  void CodeCompleteObjCMethodDeclSelector(Scope *S,
10835  bool IsInstanceMethod,
10836  bool AtParameterName,
10837  ParsedType ReturnType,
10838  ArrayRef<IdentifierInfo *> SelIdents);
10839  void CodeCompleteObjCClassPropertyRefExpr(Scope *S, IdentifierInfo &ClassName,
10840  SourceLocation ClassNameLoc,
10841  bool IsBaseExprStatement);
10842  void CodeCompletePreprocessorDirective(bool InConditional);
10843  void CodeCompleteInPreprocessorConditionalExclusion(Scope *S);
10844  void CodeCompletePreprocessorMacroName(bool IsDefinition);
10845  void CodeCompletePreprocessorExpression();
10846  void CodeCompletePreprocessorMacroArgument(Scope *S,
10847  IdentifierInfo *Macro,
10849  unsigned Argument);
10850  void CodeCompleteIncludedFile(llvm::StringRef Dir, bool IsAngled);
10851  void CodeCompleteNaturalLanguage();
10852  void CodeCompleteAvailabilityPlatformName();
10853  void GatherGlobalCodeCompletions(CodeCompletionAllocator &Allocator,
10854  CodeCompletionTUInfo &CCTUInfo,
10856  //@}
10857 
10858  //===--------------------------------------------------------------------===//
10859  // Extra semantic analysis beyond the C type system
10860 
10861 public:
10862  SourceLocation getLocationOfStringLiteralByte(const StringLiteral *SL,
10863  unsigned ByteNo) const;
10864 
10865 private:
10866  void CheckArrayAccess(const Expr *BaseExpr, const Expr *IndexExpr,
10867  const ArraySubscriptExpr *ASE=nullptr,
10868  bool AllowOnePastEnd=true, bool IndexNegated=false);
10869  void CheckArrayAccess(const Expr *E);
10870  // Used to grab the relevant information from a FormatAttr and a
10871  // FunctionDeclaration.
10872  struct FormatStringInfo {
10873  unsigned FormatIdx;
10874  unsigned FirstDataArg;
10875  bool HasVAListArg;
10876  };
10877 
10878  static bool getFormatStringInfo(const FormatAttr *Format, bool IsCXXMember,
10879  FormatStringInfo *FSI);
10880  bool CheckFunctionCall(FunctionDecl *FDecl, CallExpr *TheCall,
10881  const FunctionProtoType *Proto);
10882  bool CheckObjCMethodCall(ObjCMethodDecl *Method, SourceLocation loc,
10883  ArrayRef<const Expr *> Args);
10884  bool CheckPointerCall(NamedDecl *NDecl, CallExpr *TheCall,
10885  const FunctionProtoType *Proto);
10886  bool CheckOtherCall(CallExpr *TheCall, const FunctionProtoType *Proto);
10887  void CheckConstructorCall(FunctionDecl *FDecl,
10889  const FunctionProtoType *Proto,
10890  SourceLocation Loc);
10891 
10892  void checkCall(NamedDecl *FDecl, const FunctionProtoType *Proto,
10893  const Expr *ThisArg, ArrayRef<const Expr *> Args,
10894  bool IsMemberFunction, SourceLocation Loc, SourceRange Range,
10895  VariadicCallType CallType);
10896 
10897  bool CheckObjCString(Expr *Arg);
10898  ExprResult CheckOSLogFormatStringArg(Expr *Arg);
10899 
10900  ExprResult CheckBuiltinFunctionCall(FunctionDecl *FDecl,
10901  unsigned BuiltinID, CallExpr *TheCall);
10902  void checkFortifiedBuiltinMemoryFunction(FunctionDecl *FD, CallExpr *TheCall);
10903 
10904  bool CheckARMBuiltinExclusiveCall(unsigned BuiltinID, CallExpr *TheCall,
10905  unsigned MaxWidth);
10906  bool CheckNeonBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall);
10907  bool CheckARMBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall);
10908 
10909  bool CheckAArch64BuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall);
10910  bool CheckHexagonBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall);
10911  bool CheckHexagonBuiltinCpu(unsigned BuiltinID, CallExpr *TheCall);
10912  bool CheckHexagonBuiltinArgument(unsigned BuiltinID, CallExpr *TheCall);
10913  bool CheckMipsBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall);
10914  bool CheckSystemZBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall);
10915  bool CheckX86BuiltinRoundingOrSAE(unsigned BuiltinID, CallExpr *TheCall);
10916  bool CheckX86BuiltinGatherScatterScale(unsigned BuiltinID, CallExpr *TheCall);
10917  bool CheckX86BuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall);
10918  bool CheckPPCBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall);
10919 
10920  bool SemaBuiltinVAStart(unsigned BuiltinID, CallExpr *TheCall);
10921  bool SemaBuiltinVAStartARMMicrosoft(CallExpr *Call);
10922  bool SemaBuiltinUnorderedCompare(CallExpr *TheCall);
10923  bool SemaBuiltinFPClassification(CallExpr *TheCall, unsigned NumArgs);
10924  bool SemaBuiltinVSX(CallExpr *TheCall);
10925  bool SemaBuiltinOSLogFormat(CallExpr *TheCall);
10926 
10927 public:
10928  // Used by C++ template instantiation.
10929  ExprResult SemaBuiltinShuffleVector(CallExpr *TheCall);
10930  ExprResult SemaConvertVectorExpr(Expr *E, TypeSourceInfo *TInfo,
10931  SourceLocation BuiltinLoc,
10932  SourceLocation RParenLoc);
10933 
10934 private:
10935  bool SemaBuiltinPrefetch(CallExpr *TheCall);
10936  bool SemaBuiltinAllocaWithAlign(CallExpr *TheCall);
10937  bool SemaBuiltinAssume(CallExpr *TheCall);
10938  bool SemaBuiltinAssumeAligned(CallExpr *TheCall);
10939  bool SemaBuiltinLongjmp(CallExpr *TheCall);
10940  bool SemaBuiltinSetjmp(CallExpr *TheCall);
10941  ExprResult SemaBuiltinAtomicOverloaded(ExprResult TheCallResult);
10942  ExprResult SemaBuiltinNontemporalOverloaded(ExprResult TheCallResult);
10943  ExprResult SemaAtomicOpsOverloaded(ExprResult TheCallResult,
10945  ExprResult SemaBuiltinOperatorNewDeleteOverloaded(ExprResult TheCallResult,
10946  bool IsDelete);
10947  bool SemaBuiltinConstantArg(CallExpr *TheCall, int ArgNum,
10948  llvm::APSInt &Result);
10949  bool SemaBuiltinConstantArgRange(CallExpr *TheCall, int ArgNum, int Low,
10950  int High, bool RangeIsError = true);
10951  bool SemaBuiltinConstantArgMultiple(CallExpr *TheCall, int ArgNum,
10952  unsigned Multiple);
10953  bool SemaBuiltinARMSpecialReg(unsigned BuiltinID, CallExpr *TheCall,
10954  int ArgNum, unsigned ExpectedFieldNum,
10955  bool AllowName);
10956  bool SemaBuiltinARMMemoryTaggingCall(unsigned BuiltinID, CallExpr *TheCall);
10957 public:
10968  FST_Unknown
10969  };
10970  static FormatStringType GetFormatStringType(const FormatAttr *Format);
10971 
10972  bool FormatStringHasSArg(const StringLiteral *FExpr);
10973 
10974  static bool GetFormatNSStringIdx(const FormatAttr *Format, unsigned &Idx);
10975 
10976 private:
10977  bool CheckFormatArguments(const FormatAttr *Format,
10979  bool IsCXXMember,
10980  VariadicCallType CallType,
10981  SourceLocation Loc, SourceRange Range,
10982  llvm::SmallBitVector &CheckedVarArgs);
10983  bool CheckFormatArguments(ArrayRef<const Expr *> Args,
10984  bool HasVAListArg, unsigned format_idx,
10985  unsigned firstDataArg, FormatStringType Type,
10986  VariadicCallType CallType,
10988  llvm::SmallBitVector &CheckedVarArgs);
10989 
10990  void CheckAbsoluteValueFunction(const CallExpr *Call,
10991  const FunctionDecl *FDecl);
10992 
10993  void CheckMaxUnsignedZero(const CallExpr *Call, const FunctionDecl *FDecl);
10994 
10995  void CheckMemaccessArguments(const CallExpr *Call,
10996  unsigned BId,
10997  IdentifierInfo *FnName);
10998 
10999  void CheckStrlcpycatArguments(const CallExpr *Call,
11000  IdentifierInfo *FnName);
11001 
11002  void CheckStrncatArguments(const CallExpr *Call,
11003  IdentifierInfo *FnName);
11004 
11005  void CheckReturnValExpr(Expr *RetValExp, QualType lhsType,
11006  SourceLocation ReturnLoc,
11007  bool isObjCMethod = false,
11008  const AttrVec *Attrs = nullptr,
11009  const FunctionDecl *FD = nullptr);
11010 
11011 public:
11012  void CheckFloatComparison(SourceLocation Loc, Expr *LHS, Expr *RHS);
11013 
11014 private:
11015  void CheckImplicitConversions(Expr *E, SourceLocation CC = SourceLocation());
11016  void CheckBoolLikeConversion(Expr *E, SourceLocation CC);
11017  void CheckForIntOverflow(Expr *E);
11018  void CheckUnsequencedOperations(Expr *E);
11019 
11020  /// Perform semantic checks on a completed expression. This will either
11021  /// be a full-expression or a default argument expression.
11022  void CheckCompletedExpr(Expr *E, SourceLocation CheckLoc = SourceLocation(),
11023  bool IsConstexpr = false);
11024 
11025  void CheckBitFieldInitialization(SourceLocation InitLoc, FieldDecl *Field,
11026  Expr *Init);
11027 
11028  /// Check if there is a field shadowing.
11029  void CheckShadowInheritedFields(const SourceLocation &Loc,
11030  DeclarationName FieldName,
11031  const CXXRecordDecl *RD,
11032  bool DeclIsField = true);
11033 
11034  /// Check if the given expression contains 'break' or 'continue'
11035  /// statement that produces control flow different from GCC.
11036  void CheckBreakContinueBinding(Expr *E);
11037 
11038  /// Check whether receiver is mutable ObjC container which
11039  /// attempts to add itself into the container
11040  void CheckObjCCircularContainer(ObjCMessageExpr *Message);
11041 
11042  void AnalyzeDeleteExprMismatch(const CXXDeleteExpr *DE);
11043  void AnalyzeDeleteExprMismatch(FieldDecl *Field, SourceLocation DeleteLoc,
11044  bool DeleteWasArrayForm);
11045 public:
11046  /// Register a magic integral constant to be used as a type tag.
11047  void RegisterTypeTagForDatatype(const IdentifierInfo *ArgumentKind,
11048  uint64_t MagicValue, QualType Type,
11049  bool LayoutCompatible, bool MustBeNull);
11050 
11051  struct TypeTagData {
11053 
11054  TypeTagData(QualType Type, bool LayoutCompatible, bool MustBeNull) :
11055  Type(Type), LayoutCompatible(LayoutCompatible),
11056  MustBeNull(MustBeNull)
11057  {}
11058 
11060 
11061  /// If true, \c Type should be compared with other expression's types for
11062  /// layout-compatibility.
11063  unsigned LayoutCompatible : 1;
11064  unsigned MustBeNull : 1;
11065  };
11066 
11067  /// A pair of ArgumentKind identifier and magic value. This uniquely
11068  /// identifies the magic value.
11069  typedef std::pair<const IdentifierInfo *, uint64_t> TypeTagMagicValue;
11070 
11071 private:
11072  /// A map from magic value to type information.
11073  std::unique_ptr<llvm::DenseMap<TypeTagMagicValue, TypeTagData>>
11074  TypeTagForDatatypeMagicValues;
11075 
11076  /// Peform checks on a call of a function with argument_with_type_tag
11077  /// or pointer_with_type_tag attributes.
11078  void CheckArgumentWithTypeTag(const ArgumentWithTypeTagAttr *Attr,
11079  const ArrayRef<const Expr *> ExprArgs,
11080  SourceLocation CallSiteLoc);
11081 
11082  /// Check if we are taking the address of a packed field
11083  /// as this may be a problem if the pointer value is dereferenced.
11084  void CheckAddressOfPackedMember(Expr *rhs);
11085 
11086  /// The parser's current scope.
11087  ///
11088  /// The parser maintains this state here.
11089  Scope *CurScope;
11090 
11091  mutable IdentifierInfo *Ident_super;
11092  mutable IdentifierInfo *Ident___float128;
11093 
11094  /// Nullability type specifiers.
11095  IdentifierInfo *Ident__Nonnull = nullptr;
11096  IdentifierInfo *Ident__Nullable = nullptr;
11097  IdentifierInfo *Ident__Null_unspecified = nullptr;
11098 
11099  IdentifierInfo *Ident_NSError = nullptr;
11100 
11101  /// The handler for the FileChanged preprocessor events.
11102  ///
11103  /// Used for diagnostics that implement custom semantic analysis for #include
11104  /// directives, like -Wpragma-pack.
11105  sema::SemaPPCallbacks *SemaPPCallbackHandler;
11106 
11107 protected:
11108  friend class Parser;
11110  friend class ASTReader;
11111  friend class ASTDeclReader;
11112  friend class ASTWriter;
11113 
11114 public:
11115  /// Retrieve the keyword associated
11116  IdentifierInfo *getNullabilityKeyword(NullabilityKind nullability);
11117 
11118  /// The struct behind the CFErrorRef pointer.
11119  RecordDecl *CFError = nullptr;
11120 
11121  /// Retrieve the identifier "NSError".
11122  IdentifierInfo *getNSErrorIdent();
11123 
11124  /// Retrieve the parser's current scope.
11125  ///
11126  /// This routine must only be used when it is certain that semantic analysis
11127  /// and the parser are in precisely the same context, which is not the case
11128  /// when, e.g., we are performing any kind of template instantiation.
11129  /// Therefore, the only safe places to use this scope are in the parser
11130  /// itself and in routines directly invoked from the parser and *never* from
11131  /// template substitution or instantiation.
11132  Scope *getCurScope() const { return CurScope; }
11133 
11135  return CurScope->incrementMSManglingNumber();
11136  }
11137 
11138  IdentifierInfo *getSuperIdentifier() const;
11139  IdentifierInfo *getFloat128Identifier() const;
11140 
11141  Decl *getObjCDeclContext() const;
11142 
11144  return OriginalLexicalContext ? OriginalLexicalContext : CurContext;
11145  }
11146 
11148  const DeclContext *DC = getCurLexicalContext();
11149  // A category implicitly has the attribute of the interface.
11150  if (const ObjCCategoryDecl *CatD = dyn_cast<ObjCCategoryDecl>(DC))
11151  DC = CatD->getClassInterface();
11152  return DC;
11153  }
11154 
11155  /// To be used for checking whether the arguments being passed to
11156  /// function exceeds the number of parameters expected for it.
11157  static bool TooManyArguments(size_t NumParams, size_t NumArgs,
11158  bool PartialOverloading = false) {
11159  // We check whether we're just after a comma in code-completion.
11160  if (NumArgs > 0 && PartialOverloading)
11161  return NumArgs + 1 > NumParams; // If so, we view as an extra argument.
11162  return NumArgs > NumParams;
11163  }
11164 
11165  // Emitting members of dllexported classes is delayed until the class
11166  // (including field initializers) is fully parsed.
11169 
11170 private:
11171  class SavePendingParsedClassStateRAII {
11172  public:
11173  SavePendingParsedClassStateRAII(Sema &S) : S(S) { swapSavedState(); }
11174 
11175  ~SavePendingParsedClassStateRAII() {
11176  assert(S.DelayedOverridingExceptionSpecChecks.empty() &&
11177  "there shouldn't be any pending delayed exception spec checks");
11178  assert(S.DelayedEquivalentExceptionSpecChecks.empty() &&
11179  "there shouldn't be any pending delayed exception spec checks");
11180  assert(S.DelayedDllExportClasses.empty() &&
11181  "there shouldn't be any pending delayed DLL export classes");
11182  swapSavedState();
11183  }
11184 
11185  private:
11186  Sema &S;
11187  decltype(DelayedOverridingExceptionSpecChecks)
11188  SavedOverridingExceptionSpecChecks;
11189  decltype(DelayedEquivalentExceptionSpecChecks)
11190  SavedEquivalentExceptionSpecChecks;
11191  decltype(DelayedDllExportClasses) SavedDllExportClasses;
11192 
11193  void swapSavedState() {
11194  SavedOverridingExceptionSpecChecks.swap(
11196  SavedEquivalentExceptionSpecChecks.swap(
11198  SavedDllExportClasses.swap(S.DelayedDllExportClasses);
11199  }
11200  };
11201 
11202  /// Helper class that collects misaligned member designations and
11203  /// their location info for delayed diagnostics.
11204  struct MisalignedMember {
11205  Expr *E;
11206  RecordDecl *RD;
11207  ValueDecl *MD;
11208  CharUnits Alignment;
11209 
11210  MisalignedMember() : E(), RD(), MD(), Alignment() {}
11211  MisalignedMember(Expr *E, RecordDecl *RD, ValueDecl *MD,
11212  CharUnits Alignment)
11213  : E(E), RD(RD), MD(MD), Alignment(Alignment) {}
11214  explicit MisalignedMember(Expr *E)
11215  : MisalignedMember(E, nullptr, nullptr, CharUnits()) {}
11216 
11217  bool operator==(const MisalignedMember &m) { return this->E == m.E; }
11218  };
11219  /// Small set of gathered accesses to potentially misaligned members
11220  /// due to the packed attribute.
11221  SmallVector<MisalignedMember, 4> MisalignedMembers;
11222 
11223  /// Adds an expression to the set of gathered misaligned members.
11224  void AddPotentialMisalignedMembers(Expr *E, RecordDecl *RD, ValueDecl *MD,
11225  CharUnits Alignment);
11226 
11227 public:
11228  /// Diagnoses the current set of gathered accesses. This typically
11229  /// happens at full expression level. The set is cleared after emitting the
11230  /// diagnostics.
11231  void DiagnoseMisalignedMembers();
11232 
11233  /// This function checks if the expression is in the sef of potentially
11234  /// misaligned members and it is converted to some pointer type T with lower
11235  /// or equal alignment requirements. If so it removes it. This is used when
11236  /// we do not want to diagnose such misaligned access (e.g. in conversions to
11237  /// void*).
11238  void DiscardMisalignedMemberAddress(const Type *T, Expr *E);
11239 
11240  /// This function calls Action when it determines that E designates a
11241  /// misaligned member due to the packed attribute. This is used to emit
11242  /// local diagnostics like in reference binding.
11243  void RefersToMemberWithReducedAlignment(
11244  Expr *E,
11245  llvm::function_ref<void(Expr *, RecordDecl *, FieldDecl *, CharUnits)>
11246  Action);
11247 
11248  /// Describes the reason a calling convention specification was ignored, used
11249  /// for diagnostics.
11251  ForThisTarget = 0,
11252  VariadicFunction,
11253  ConstructorDestructor,
11254  BuiltinFunction
11255  };
11256 };
11257 
11258 /// RAII object that enters a new expression evaluation context.
11260  Sema &Actions;
11261  bool Entered = true;
11262 
11263 public:
11265  Sema &Actions, Sema::ExpressionEvaluationContext NewContext,
11266  Decl *LambdaContextDecl = nullptr,
11268  Sema::ExpressionEvaluationContextRecord::EK_Other,
11269  bool ShouldEnter = true)
11270  : Actions(Actions), Entered(ShouldEnter) {
11271  if (Entered)
11272  Actions.PushExpressionEvaluationContext(NewContext, LambdaContextDecl,
11273  ExprContext);
11274  }
11276  Sema &Actions, Sema::ExpressionEvaluationContext NewContext,
11279  Sema::ExpressionEvaluationContextRecord::EK_Other)
11280  : Actions(Actions) {
11282  NewContext, Sema::ReuseLambdaContextDecl, ExprContext);
11283  }
11284 
11285  enum InitListTag { InitList };
11287  bool ShouldEnter = true)
11288  : Actions(Actions), Entered(false) {
11289  // In C++11 onwards, narrowing checks are performed on the contents of
11290  // braced-init-lists, even when they occur within unevaluated operands.
11291  // Therefore we still need to instantiate constexpr functions used in such
11292  // a context.
11293  if (ShouldEnter && Actions.isUnevaluatedContext() &&
11294  Actions.getLangOpts().CPlusPlus11) {
11296  Sema::ExpressionEvaluationContext::UnevaluatedList);
11297  Entered = true;
11298  }
11299  }
11300 
11302  if (Entered)
11304  }
11305 };
11306 
11310 
11311 /// Contains a late templated function.
11312 /// Will be parsed at the end of the translation unit, used by Sema & Parser.
11315  /// The template function declaration to be late parsed.
11316  Decl *D;
11317 };
11318 } // end namespace clang
11319 
11320 namespace llvm {
11321 // Hash a FunctionDeclAndLoc by looking at both its FunctionDecl and its
11322 // SourceLocation.
11323 template <> struct DenseMapInfo<clang::Sema::FunctionDeclAndLoc> {
11326 
11328  return {FDBaseInfo::getEmptyKey(), clang::SourceLocation()};
11329  }
11330 
11332  return {FDBaseInfo::getTombstoneKey(), clang::SourceLocation()};
11333  }
11334 
11335  static unsigned getHashValue(const FunctionDeclAndLoc &FDL) {
11336  return hash_combine(FDBaseInfo::getHashValue(FDL.FD),
11337  FDL.Loc.getRawEncoding());
11338  }
11339 
11340  static bool isEqual(const FunctionDeclAndLoc &LHS,
11341  const FunctionDeclAndLoc &RHS) {
11342  return LHS.FD == RHS.FD && LHS.Loc == RHS.Loc;
11343  }
11344 };
11345 } // namespace llvm
11346 
11347 #endif
FileNullabilityMap NullabilityMap
A mapping that describes the nullability we&#39;ve seen in each header file.
Definition: Sema.h:539
Abstract class used to diagnose incomplete types.
Definition: Sema.h:1595
bool IsStatic
Definition: Format.cpp:1722
VariadicCallType
Definition: Sema.h:9812
ObjCInterfaceDecl * NSStringDecl
The declaration of the Objective-C NSString class.
Definition: Sema.h:927
PragmaStack< StringLiteral * > CodeSegStack
Definition: Sema.h:523
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:661
We are defining a synthesized function (such as a defaulted special member).
Definition: Sema.h:7518
static void collectUnexpandedParameterPacks(Sema &S, TemplateParameterList *Params, SmallVectorImpl< UnexpandedParameterPack > &Unexpanded)
The lookup results will be used for redeclaration of a name, if an entity by that name already exists...
Definition: Sema.h:3277
Represents a function declaration or definition.
Definition: Decl.h:1748
bool RequireCompleteExprType(Expr *E, unsigned DiagID, const Ts &...Args)
Definition: Sema.h:1765
llvm::SmallSetVector< const TypedefNameDecl *, 4 > UnusedLocalTypedefNameCandidates
Set containing all typedefs that are likely unused.
Definition: Sema.h:623
A set of visible modules.
Definition: Module.h:596
UnexpandedParameterPackContext
The context in which an unexpanded parameter pack is being diagnosed.
Definition: Sema.h:6889
std::pair< llvm::PointerUnion< const TemplateTypeParmType *, NamedDecl * >, SourceLocation > UnexpandedParameterPack
Definition: Sema.h:227
SourceLocation getOptimizeOffPragmaLocation() const
Get the location for the currently active "\#pragma clang optimize off". If this location is invalid...
Definition: Sema.h:8832
static DiagnosticBuilder Diag(DiagnosticsEngine *Diags, const LangOptions &Features, FullSourceLoc TokLoc, const char *TokBegin, const char *TokRangeBegin, const char *TokRangeEnd, unsigned DiagID)
Produce a diagnostic highlighting some portion of a literal.
ExtVectorDeclsType ExtVectorDecls
ExtVectorDecls - This is a list all the extended vector types.
Definition: Sema.h:611
NestedNameSpecInfo(IdentifierInfo *II, SourceLocation IdLoc, SourceLocation ColonColonLoc, ParsedType ObjectType=ParsedType())
Creates info object for the most typical case.
Definition: Sema.h:5645
ExternalSemaSource * getExternalSource() const
Definition: Sema.h:1295
IncompatibleNestedPointerAddressSpaceMismatch - The assignment changes address spaces in nested point...
Definition: Sema.h:9911
SuppressedDiagnosticsMap SuppressedDiagnostics
Definition: Sema.h:7679
CXXMethodDecl * getMethod() const
Definition: Sema.h:1128
no exception specification
Smart pointer class that efficiently represents Objective-C method names.
Module * getOwningModule() const
Get the module that owns this declaration (for visibility purposes).
Definition: DeclBase.h:759
void PushExpressionEvaluationContext(ExpressionEvaluationContext NewContext, Decl *LambdaContextDecl=nullptr, ExpressionEvaluationContextRecord::ExpressionKind Type=ExpressionEvaluationContextRecord::EK_Other)
Definition: SemaExpr.cpp:14715
if(T->getSizeExpr()) TRY_TO(TraverseStmt(T -> getSizeExpr()))
unsigned getRawEncoding() const
When a SourceLocation itself cannot be used, this returns an (opaque) 32-bit integer encoding for it...
PointerToInt - The assignment converts a pointer to an int, which we accept as an extension...
Definition: Sema.h:9878
Stores the type being destroyed by a pseudo-destructor expression.
Definition: ExprCXX.h:2334
A (possibly-)qualified type.
Definition: Type.h:643
ASTConsumer & Consumer
Definition: Sema.h:375
Keeps information about an identifier in a nested-name-spec.
Definition: Sema.h:5630
GlobalEagerInstantiationScope(Sema &S, bool Enabled)
Definition: Sema.h:7955
Simple class containing the result of Sema::CorrectTypo.
TemplateDeductionResult
Describes the result of template argument deduction.
Definition: Sema.h:7239
LateTemplateParserCB * LateTemplateParser
Definition: Sema.h:693
SmallVectorImpl< Decl * > & WeakTopLevelDecls()
WeakTopLevelDeclDecls - access to #pragma weak-generated Decls.
Definition: Sema.h:1473
Instantiation or recovery rebuild of a for-range statement.
Definition: Sema.h:3972
NameClassification(const IdentifierInfo *Keyword)
Definition: Sema.h:1867
llvm::PointerUnion3< TemplateTypeParmDecl *, NonTypeTemplateParmDecl *, TemplateTemplateParmDecl * > TemplateParameter
Stores a template parameter of any kind.
Definition: DeclTemplate.h:61
void SentinelAction(PragmaMsStackAction Action, StringRef Label)
Definition: Sema.h:479
ASTConsumer - This is an abstract interface that should be implemented by clients that read ASTs...
Definition: ASTConsumer.h:33
Defines enumerations for the type traits support.
A cast other than a C-style cast.
Definition: Sema.h:9749
LateParsedTemplateMapT LateParsedTemplateMap
Definition: Sema.h:688
SmallVector< PackIncludeState, 8 > PackIncludeStack
Definition: Sema.h:518
A stack-allocated class that identifies which local variable declaration instantiations are present i...
Definition: Template.h:227
llvm::MutableArrayRef< ImplicitConversionSequence > ConversionSequenceList
A list of implicit conversion sequences for the arguments of an OverloadCandidate.
Definition: Overload.h:736
FormatStringType
Definition: Sema.h:10958
CorrectTypoKind
Definition: Sema.h:3442
static bool getPrintable(bool B)
Definition: Sema.h:1604
bool operator==(CanQual< T > x, CanQual< U > y)
static void LookupVisibleDecls(DeclContext *Ctx, LookupResult &Result, bool QualifiedNameLookup, bool InBaseClass, VisibleDeclConsumer &Consumer, VisibleDeclsRecord &Visited, bool IncludeDependentBases, bool LoadExternal)
Code completion occurs within a class, struct, or union.
Definition: Sema.h:10694
RecordDecl * MSVCGuidDecl
The MSVC "_GUID" struct, which is defined in MSVC header files.
Definition: Sema.h:906
std::vector< std::unique_ptr< TemplateInstantiationCallback > > TemplateInstCallbacks
The template instantiation callbacks to trace or track instantiations (objects can be chained)...
Definition: Sema.h:7641
OpenCL supported extensions and optional core features.
Definition: OpenCLOptions.h:23
PragmaStack< StringLiteral * > DataSegStack
Definition: Sema.h:520
Represents a lazily-loaded vector of data.
Emit the diagnostic immediately, and, if it&#39;s a warning or error, also emit a call stack showing how ...
Definition: Sema.h:10451
ObjCBridgeCastKind
The kind of bridging performed by the Objective-C bridge cast.
std::unique_ptr< RecordDeclSetTy > PureVirtualClassDiagSet
PureVirtualClassDiagSet - a set of class declarations which we have emitted a list of pure virtual fu...
Definition: Sema.h:639
A class which encapsulates the logic for delaying diagnostics during parsing and other processing...
Definition: Sema.h:716
OpenMPDefaultmapClauseKind
OpenMP attributes for &#39;defaultmap&#39; clause.
Definition: OpenMPKinds.h:131
Specialize PointerLikeTypeTraits to allow LazyGenerationalUpdatePtr to be placed into a PointerUnion...
Definition: Dominators.h:30
A structure used to record information about a failed template argument deduction, for diagnosis.
static ConditionResult ConditionError()
Definition: Sema.h:10275
Checking non-dependent argument conversions failed.
Definition: Sema.h:7284
An initializer.
Definition: Sema.h:6924
TypePropertyCache< Private > Cache
Definition: Type.cpp:3553
ObjCMessageKind
Describes the kind of message expression indicated by a message send that starts with an identifier...
Definition: Sema.h:8521
Look up the name of an Objective-C protocol.
Definition: Sema.h:3258
Decl * Entity
The entity that is being synthesized.
Definition: Sema.h:7534
QualType CXXThisTypeOverride
When non-NULL, the C++ &#39;this&#39; expression is allowed despite the current context not being a non-stati...
Definition: Sema.h:5347
OpenCLOptions OpenCLFeatures
Definition: Sema.h:369
Stmt - This represents one statement.
Definition: Stmt.h:66
NullabilityKind
Describes the nullability of a particular type.
Definition: Specifiers.h:314
We are matching the template parameter lists of two templates that might be redeclarations.
Definition: Sema.h:6776
FunctionType - C99 6.7.5.3 - Function Declarators.
Definition: Type.h:3387
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:5826
FullExprArg MakeFullExpr(Expr *Arg)
Definition: Sema.h:3860
Provides information about an attempted template argument deduction, whose success or failure was des...
Merge availability attributes for an override, which requires an exact match or a weakening of constr...
Definition: Sema.h:2605
Microsoft __if_not_exists.
Definition: Sema.h:6942
An instance of this object exists for each enum constant that is defined.
Definition: Decl.h:2819
LazyVector< CXXConstructorDecl *, ExternalSemaSource, &ExternalSemaSource::ReadDelegatingConstructors, 2, 2 > DelegatingCtorDeclsType
Definition: Sema.h:665
bool hasValue() const
Definition: Sema.h:489
The name refers to a function template or a set of overloaded functions that includes at least one fu...
Definition: TemplateKinds.h:26
Represents the declaration of a typedef-name via the &#39;typedef&#39; type specifier.
Definition: Decl.h:3051
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:675
ObjCSubscriptKind
Definition: Sema.h:2901
llvm::StringRef StackSlotLabel
Definition: Sema.h:450
SmallVector< Scope *, 2 > CurrentSEHFinally
Stack of active SEH __finally scopes. Can be empty.
Definition: Sema.h:403
void setCurrentOpenCLExtension(llvm::StringRef Ext)
Definition: Sema.h:8946
Defines the clang::Module class, which describes a module in the source code.
OriginalCallArg(QualType OriginalParamType, bool DecomposedParam, unsigned ArgIdx, QualType OriginalArgType)
Definition: Sema.h:7311
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID)
Emit a diagnostic.
Definition: Sema.h:1362
Decl - This represents one declaration (or definition), e.g.
Definition: DeclBase.h:88
NonTrivialCUnionContext
Definition: Sema.h:2119
A normal translation unit fragment.
Definition: Sema.h:1394
Captures information about "declaration specifiers" specific to Objective-C.
Definition: DeclSpec.h:799
LambdaCaptureDefault
The default, if any, capture method for a lambda expression.
Definition: Lambda.h:22
std::deque< PendingImplicitInstantiation > PendingInstantiations
The queue of implicit template instantiations that are required but have not yet been performed...
Definition: Sema.h:7947
AssignConvertType
AssignConvertType - All of the &#39;assignment&#39; semantic checks return this enum to indicate whether the ...
Definition: Sema.h:9872
A reference to a name which we were able to look up during parsing but could not resolve to a specifi...
Definition: ExprCXX.h:2943
Microsoft __if_exists.
Definition: Sema.h:6939
PragmaOptionsAlignKind
Definition: Sema.h:8651
Defines the C++ template declaration subclasses.
StringRef P
Scope * TUScope
Translation Unit Scope - useful to Objective-C actions that need to lookup file scope declarations in...
Definition: Sema.h:877
Represents a C++11 auto or C++14 decltype(auto) type.
Definition: Type.h:4817
DeclContext * OriginalLexicalContext
Generally null except when we temporarily switch decl contexts, like in.
Definition: Sema.h:390
ParenExpr - This represents a parethesized expression, e.g.
Definition: Expr.h:1964
SmallVector< CodeSynthesisContext, 16 > CodeSynthesisContexts
List of active code synthesis contexts.
Definition: Sema.h:7584
The size of a bit-field.
Definition: Sema.h:6903
SmallVector< Module *, 16 > CodeSynthesisContextLookupModules
Extra modules inspected when performing a lookup during a template instantiation. ...
Definition: Sema.h:7595
The base class of the type hierarchy.
Definition: Type.h:1433
std::deque< PendingImplicitInstantiation > PendingLocalImplicitInstantiations
The queue of implicit template instantiations that are required and must be performed within the curr...
Definition: Sema.h:7998
void AddFactoryMethodToGlobalPool(ObjCMethodDecl *Method, bool impl=false)
AddFactoryMethodToGlobalPool - Same as above, but for factory methods.
Definition: Sema.h:3797
SmallVector< PragmaAttributeEntry, 2 > Entries
Definition: Sema.h:562
llvm::MapVector< const FunctionDecl *, std::unique_ptr< LateParsedTemplate > > LateParsedTemplateMapT
Definition: Sema.h:687
MissingImportKind
Kinds of missing import.
Definition: Sema.h:2305
DiagnosticBuilder Report(SourceLocation Loc, unsigned DiagID)
Issue the message to the client.
Definition: Diagnostic.h:1297
Declaration of a variable template.
ForRangeStatus
Definition: Sema.h:3123
TemplateParamListContext
The context in which we are checking a template parameter list.
Definition: Sema.h:6516
Represent a C++ namespace.
Definition: Decl.h:514
Template argument deduction produced inconsistent deduced values for the given template parameter...
Definition: Sema.h:7255
RedeclarationKind
Specifies whether (or how) name lookup is being performed for a redeclaration (vs.
Definition: Sema.h:3271
AccessSpecifier
A C++ access specifier (public, private, protected), plus the special value "none" which means differ...
Definition: Specifiers.h:112
LazyVector< const DeclaratorDecl *, ExternalSemaSource, &ExternalSemaSource::ReadUnusedFileScopedDecls, 2, 2 > UnusedFileScopedDeclsType
Definition: Sema.h:657
A container of type source information.
Definition: Decl.h:86
static const IdentifierInfo * getPrintable(const IdentifierInfo *II)
Definition: Sema.h:1608
Store information needed for an explicit specifier.
Definition: DeclCXX.h:2001
Wrapper for void* pointer.
Definition: Ownership.h:50
Parser - This implements a parser for the C family of languages.
Definition: Parser.h:57
Look up of a name that precedes the &#39;::&#39; scope resolution operator in C++.
Definition: Sema.h:3240
std::pair< ValueDecl *, SourceLocation > PendingImplicitInstantiation
An entity for which implicit template instantiation is required.
Definition: Sema.h:7943
bool hasVisibleDeclaration(const NamedDecl *D, llvm::SmallVectorImpl< Module *> *Modules=nullptr)
Determine whether any declaration of an entity is visible.
Definition: Sema.h:1695
Floating point control options.
Definition: LangOptions.h:307
RangeSelector name(std::string ID)
Given a node with a "name", (like NamedDecl, DeclRefExpr or CxxCtorInitializer) selects the name&#39;s to...
We are instantiating a default argument for a template parameter.
Definition: Sema.h:7478
DelayedDiagnosticsState pushUndelayed()
Enter a new scope where access and deprecation diagnostics are not delayed.
Definition: Sema.h:753
Abstract base class used for diagnosing integer constant expression violations.
Definition: Sema.h:10341
FileNullability Nullability
Definition: Sema.h:256
Represents a path from a specific derived class (which is not represented as part of the path) to a p...
LiteralOperatorLookupResult
The possible outcomes of name lookup for a literal operator.
Definition: Sema.h:3296
Represents a C++ constructor within a class.
Definition: DeclCXX.h:2574
Represents a prvalue temporary that is written into memory so that a reference can bind to it...
Definition: ExprCXX.h:4325
OpenMPDefaultmapClauseModifier
OpenMP modifiers for &#39;defaultmap&#39; clause.
Definition: OpenMPKinds.h:139
SpecialMemberOverloadResultEntry(const llvm::FoldingSetNodeID &ID)
Definition: Sema.h:1139
unsigned NonInstantiationEntries
The number of CodeSynthesisContexts that are not template instantiations and, therefore, should not be counted as part of the instantiation depth.
Definition: Sema.h:7625
NameClassificationKind getKind() const
Definition: Sema.h:1905
static void MarkUsedTemplateParameters(ASTContext &Ctx, const TemplateArgument &TemplateArg, bool OnlyDeduced, unsigned Depth, llvm::SmallBitVector &Used)
Mark the template parameters that are used by this template argument.
VerifyICEDiagnoser(bool Suppress=false)
Definition: Sema.h:10345
EnterExpressionEvaluationContext(Sema &Actions, Sema::ExpressionEvaluationContext NewContext, Sema::ReuseLambdaContextDecl_t, Sema::ExpressionEvaluationContextRecord::ExpressionKind ExprContext=Sema::ExpressionEvaluationContextRecord::EK_Other)
Definition: Sema.h:11275
RAII object to handle the state changes required to synthesize a function body.
Definition: Sema.h:811
Look up a namespace name within a C++ using directive or namespace alias definition, ignoring non-namespace names (C++ [basic.lookup.udir]p1).
Definition: Sema.h:3244
Consumes visible declarations found when searching for all visible names within a given scope or cont...
Definition: Lookup.h:765
bool DisableTypoCorrection
Tracks whether we are in a context where typo correction is disabled.
Definition: Sema.h:7918
Retains information about a function, method, or block that is currently being parsed.
Definition: ScopeInfo.h:97
FriendDecl - Represents the declaration of a friend entity, which can be a function, a type, or a templated function or type.
Definition: DeclFriend.h:53
RAII object that enters a new expression evaluation context.
Definition: Sema.h:11259
Represents a variable declaration or definition.
Definition: Decl.h:812
IfExistsResult
Describes the result of an "if-exists" condition check.
Definition: Sema.h:4734
ExpressionKind
Describes whether we are in an expression constext which we have to handle differently.
Definition: Sema.h:1061
CleanupInfo Cleanup
Used to control the generation of ExprWithCleanups.
Definition: Sema.h:583
Information about one declarator, including the parsed type information and the identifier.
Definition: DeclSpec.h:1775
DiagnosticsEngine & Diags
Definition: Sema.h:376
llvm::SmallSetVector< DeclContext *, 16 > AssociatedNamespaceSet
Definition: Sema.h:2928
const internal::VariadicDynCastAllOfMatcher< Stmt, Expr > expr
Matches expressions.
PrintingPolicy getPrintingPolicy() const
Retrieve a suitable printing policy for diagnostics.
Definition: Sema.h:2338
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:1243
Records and restores the FP_CONTRACT state on entry/exit of compound statements.
Definition: Sema.h:1263
Extra information about a function prototype.
Definition: Type.h:3799
ExpressionEvaluationContextRecord(ExpressionEvaluationContext Context, unsigned NumCleanupObjects, CleanupInfo ParentCleanup, Decl *ManglingContextDecl, ExpressionKind ExprContext)
Definition: Sema.h:1065
TypeSpecifierType
Specifies the kind of type.
Definition: Specifiers.h:59
LangAS
Defines the address space values used by the address space qualifier of QualType. ...
Definition: AddressSpaces.h:25
CUDAFunctionPreference
Definition: Sema.h:10575
Represents a variable template specialization, which refers to a variable template with a given set o...
ObjCMethodDecl - Represents an instance or class method declaration.
Definition: DeclObjC.h:138
SmallVector< CXXRecordDecl *, 4 > DelayedDllExportClasses
Definition: Sema.h:11167
void diagnose(Sema &S, SourceLocation Loc, QualType T) override
Definition: Sema.h:1636
ExprResult ActOnFinishFullExpr(Expr *Expr, bool DiscardedValue)
Definition: Sema.h:5584
RAII object used to temporarily allow the C++ &#39;this&#39; expression to be used, with the given qualifiers...
Definition: Sema.h:5351
llvm::MapVector< NamedDecl *, SourceLocation > UndefinedButUsed
UndefinedInternals - all the used, undefined objects which require a definition in this translation u...
Definition: Sema.h:1184
The lookup found a single &#39;cooked&#39; literal operator, which expects a normal literal to be built and p...
Definition: Sema.h:3303
PragmaClangSection PragmaClangBSSSection
Definition: Sema.h:432
RangeSelector range(RangeSelector Begin, RangeSelector End)
Selects from the start of Begin and to the end of End.
BoundTypeDiagnoser(unsigned DiagID, const Ts &...Args)
Definition: Sema.h:1631
Stores a list of template parameters for a TemplateDecl and its derived classes.
Definition: DeclTemplate.h:67
Describes how types, statements, expressions, and declarations should be printed. ...
Definition: PrettyPrinter.h:37
A context in which code is being synthesized (where a source location alone is not sufficient to iden...
Definition: Sema.h:7466
Code completion occurs within an Objective-C implementation or category implementation.
Definition: Sema.h:10700
ObjCMethodDecl * ValueWithBytesObjCTypeMethod
The declaration of the valueWithBytes:objCType: method.
Definition: Sema.h:936
llvm::MapVector< Selector, SourceLocation > ReferencedSelectors
Method selectors used in a @selector expression.
Definition: Sema.h:1213
bool IsDecltype
Whether we are in a decltype expression.
Definition: Sema.h:1021
NestedNameSpecInfo(IdentifierInfo *II, SourceLocation IdLoc, SourceLocation ColonColonLoc, QualType ObjectType)
Definition: Sema.h:5651
static NameClassification NestedNameSpecifier()
Definition: Sema.h:1877
SourceLocation PragmaLocation
Definition: Sema.h:452
Look up an ordinary name that is going to be redeclared as a name with linkage.
Definition: Sema.h:3253
FunctionProtoType::ExceptionSpecInfo getExceptionSpec() const
Overwrite an EPI&#39;s exception specification with this computed exception specification.
Definition: Sema.h:5020
Represents a parameter to a function.
Definition: Decl.h:1564
OpenCLOptions & getOpenCLOptions()
Definition: Sema.h:1286
Defines the clang::Expr interface and subclasses for C++ expressions.
ObjCInterfaceDecl * NSDictionaryDecl
The declaration of the Objective-C NSDictionary class.
Definition: Sema.h:945
FPOptions & getFPOptions()
Definition: Sema.h:1287
const TemplateArgument * TemplateArgs
The list of template arguments we are substituting, if they are not part of the entity.
Definition: Sema.h:7543
The collection of all-type qualifiers we support.
Definition: Type.h:137
MethodMatchStrategy
Definition: Sema.h:3707
Information about a template-id annotation token.
static SourceRange getPrintable(TypeLoc TL)
Definition: Sema.h:1616
void setMethod(CXXMethodDecl *MD)
Definition: Sema.h:1129
void threadSafetyCleanup(BeforeSet *Cache)
Base wrapper for a particular "section" of type source info.
Definition: TypeLoc.h:56
Represents a struct/union/class.
Definition: Decl.h:3626
enum clang::Sema::CodeSynthesisContext::SynthesisKind Kind
friend const SemaDiagnosticBuilder & operator<<(const SemaDiagnosticBuilder &Diag, const T &Value)
Teach operator<< to produce an object of the correct type.
Definition: Sema.h:1353
ContextualImplicitConverter(bool Suppress=false, bool SuppressConversion=false)
Definition: Sema.h:2830
Represents a class template specialization, which refers to a class template with a given set of temp...
One of these records is kept for each identifier that is lexed.
std::unique_ptr< NSAPI > NSAPIObj
Caches identifiers/selectors for NSFoundation APIs.
Definition: Sema.h:909
LocalInstantiationScope * CurrentInstantiationScope
The current instantiation scope used to store local variables.
Definition: Sema.h:7914
The lookup found a single &#39;raw&#39; literal operator, which expects a string literal containing the spell...
Definition: Sema.h:3306
IntToPointer - The assignment converts an int to a pointer, which we accept as an extension...
Definition: Sema.h:9882
CompoundScopeRAII(Sema &S, bool IsStmtExpr=false)
Definition: Sema.h:3888
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:683
Step
Definition: OpenMPClause.h:151
IncompatibleObjCWeakRef - Assigning a weak-unavailable object to an object with __weak qualifier...
Definition: Sema.h:9938
Enumerator value with fixed underlying type.
Definition: Sema.h:2812
Value of a non-type template parameter.
Definition: Sema.h:2813
Represents a class type in Objective C.
Definition: Type.h:5608
CallingConventionIgnoredReason
Describes the reason a calling convention specification was ignored, used for diagnostics.
Definition: Sema.h:11250
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition: ASTContext.h:154
A C++ nested-name-specifier augmented with source location information.
Lookup for the name failed, but we&#39;re assuming it was a template name anyway.
Definition: TemplateKinds.h:50
bool inTemplateInstantiation() const
Determine whether we are currently performing template instantiation.
Definition: Sema.h:7818
The results of name lookup within a DeclContext.
Definition: DeclBase.h:1195
A C-style cast.
Definition: Sema.h:9745
Base class for callback objects used by Sema::CorrectTypo to check the validity of a potential typo c...
FileNullability & operator[](FileID file)
Definition: Sema.h:260
OpenMPLinearClauseKind
OpenMP attributes for &#39;linear&#39; clause.
Definition: OpenMPKinds.h:83
Represents a member of a struct/union/class.
Definition: Decl.h:2607
IdentifierSourceLocations TypoCorrectionFailures
A cache containing identifiers for which typo correction failed and their locations, so that repeated attempts to correct an identifier in a given location are ignored if typo correction already failed for it.
Definition: Sema.h:7929
std::unique_ptr< sema::FunctionScopeInfo > CachedFunctionScope
Definition: Sema.h:598
threadSafety::BeforeSet * ThreadSafetyDeclCache
Definition: Sema.h:7933
ObjCInterfaceDecl * NSValueDecl
The declaration of the Objective-C NSValue class.
Definition: Sema.h:915
UnaryExprOrTypeTrait
Names for the "expression or type" traits.
Definition: TypeTraits.h:96
NamedDecl * Template
The template (or partial specialization) in which we are performing the instantiation, for substitutions of prior template arguments.
Definition: Sema.h:7539
Code completion occurs following one or more template headers within a class.
Definition: Sema.h:10709
This is not an overload because the signature exactly matches an existing declaration.
Definition: Sema.h:2722
The iterator over UnresolvedSets.
Definition: UnresolvedSet.h:31
CachedTokens Toks
Definition: Sema.h:11314
Token - This structure provides full information about a lexed token.
Definition: Token.h:34
__SIZE_TYPE__ size_t
The unsigned integer type of the result of the sizeof operator.
Definition: opencl-c-base.h:40
CompatiblePointerDiscardsQualifiers - The assignment discards c/v/r qualifiers, which we accept as an...
Definition: Sema.h:9900
bool isInvalid() const
Definition: Sema.h:10264
ParsingDeclState PushParsingDeclaration(sema::DelayedDiagnosticPool &pool)
Definition: Sema.h:4158
The fixed underlying type of an enumeration.
Definition: Sema.h:6909
bool isExternallyDeclarable() const
Determine whether this declaration can be redeclared in a different translation unit.
Definition: Decl.h:385
Represents a C++ member access expression for which lookup produced a set of overloaded functions...
Definition: ExprCXX.h:3677
TemplateName getTemplateName() const
Definition: Sema.h:1917
LazyVector< VarDecl *, ExternalSemaSource, &ExternalSemaSource::ReadTentativeDefinitions, 2, 2 > TentativeDefinitionsType
Definition: Sema.h:650
Defines some OpenMP-specific enums and functions.
OpaquePtr< QualType > ParsedType
An opaque type for threading parsed type information through the parser.
Definition: Ownership.h:244
Represents an access specifier followed by colon &#39;:&#39;.
Definition: DeclCXX.h:132
The type of a non-type template parameter.
Definition: Sema.h:6930
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
Definition: LangOptions.h:49
ArrayRef< std::pair< IdentifierInfo *, SourceLocation > > ModuleIdPath
A sequence of identifier/location pairs used to describe a particular module or submodule, e.g., std.vector.
Definition: ModuleLoader.h:32
i32 captured_struct **param SharedsTy A type which contains references the shared variables *param Shareds Context with the list of shared variables from the p *TaskFunction *param Data Additional data for task generation like final * state
void PopExpressionEvaluationContext()
Definition: SemaExpr.cpp:14778
OverloadKind
C++ Overloading.
Definition: Sema.h:2715
Code completion occurs where only a type is permitted.
Definition: Sema.h:10726
Describes a module or submodule.
Definition: Module.h:64
llvm::BumpPtrAllocator BumpAlloc
Definition: Sema.h:1161
ObjCMethodDecl * LookupFactoryMethodInGlobalPool(Selector Sel, SourceRange R, bool receiverIdOrClass=false)
LookupFactoryMethodInGlobalPool - Returns the method and warns if there are multiple signatures...
Definition: Sema.h:3815
bool isConstantEvaluated()
Definition: Sema.h:804
This little struct is used to capture information about structure field declarators, which is basically just a bitfield size.
Definition: DeclSpec.h:2500
SpecialMemberOverloadResult - The overloading result for a special member function.
Definition: Sema.h:1112
bool AccessCheckingSFINAE
When true, access checking violations are treated as SFINAE failures rather than hard errors...
Definition: Sema.h:6361
An r-value expression (a pr-value in the C++11 taxonomy) produces a temporary value.
Definition: Specifiers.h:124
The type of an exception.
Definition: Sema.h:6933
Code completion occurs at top-level or namespace context.
Definition: Sema.h:10692
A pair of a canonical FunctionDecl and a SourceLocation.
Definition: Sema.h:10395
We are instantiating the exception specification for a function template which was deferred until it ...
Definition: Sema.h:7511
SemaDiagnosticBuilder(DiagnosticBuilder &DB, Sema &SemaRef, unsigned DiagID)
Definition: Sema.h:1320
OpenMPDistScheduleClauseKind
OpenMP attributes for &#39;dist_schedule&#39; clause.
Definition: OpenMPKinds.h:124
An allocator used specifically for the purpose of code completion.
unsigned TyposCorrected
The number of typos corrected by CorrectTypo.
Definition: Sema.h:7921
Represents a C++ using-declaration.
Definition: DeclCXX.h:3488
Code completion occurs within the body of a function on a recovery path, where we do not have a speci...
Definition: Sema.h:10724
llvm::SmallVector< QualType, 4 > CurrentParameterCopyTypes
Stack of types that correspond to the parameter entities that are currently being copy-initialized...
Definition: Sema.h:1247
BinaryOperatorKind
Represents a C++ unqualified-id that has been parsed.
Definition: DeclSpec.h:944
bool isCompleteType(SourceLocation Loc, QualType T)
Definition: Sema.h:1745
ParsedAttributesView ArgAttrs
ArgAttrs - Attribute list for this argument.
Definition: Sema.h:8477
static ExprResult CheckConvertedConstantExpression(Sema &S, Expr *From, QualType T, APValue &Value, Sema::CCEKind CCE, bool RequireInt)
CheckConvertedConstantExpression - Check that the expression From is a converted constant expression ...
Look up implicit &#39;self&#39; parameter of an objective-c method.
Definition: Sema.h:3260
Represents the results of name lookup.
Definition: Lookup.h:46
PtrTy get() const
Definition: Ownership.h:170
static const std::string & getPrintable(const std::string &S)
Definition: Sema.h:1607
RAII class used to indicate that we are performing provisional semantic analysis to determine the val...
Definition: Sema.h:7896
ObjCContainerDecl - Represents a container for method declarations.
Definition: DeclObjC.h:968
static NameClassification UndeclaredTemplate(TemplateName Name)
Definition: Sema.h:1899
static void hash_combine(std::size_t &seed, const T &v)
CharUnits - This is an opaque type for sizes expressed in character units.
Definition: CharUnits.h:37
TemplateSpecCandidateSet - A set of generalized overload candidates, used in template specializations...
A convenient class for passing around template argument information.
Definition: TemplateBase.h:554
bool AllowAbstractFieldReference
A flag to indicate that we&#39;re in a context that permits abstract references to fields.
Definition: Sema.h:962
const FormatToken & Tok
Module * getOwningModule(Decl *Entity)
Get the module owning an entity.
Definition: Sema.h:1680
bool isObjCMethodDecl(Decl *D)
Definition: Sema.h:2193
ICEConvertDiagnoser(bool AllowScopedEnumerations, bool Suppress, bool SuppressConversion)
Definition: Sema.h:2877
Code completion occurs following one or more template headers.
Definition: Sema.h:10706
The base type of a class type.
Definition: Sema.h:6894
Keeps track of the mangled names of lambda expressions and block literals within a particular context...
Look up all declarations in a scope with the given name, including resolved using declarations...
Definition: Sema.h:3248
Code completion occurs within an expression.
Definition: Sema.h:10711
PragmaStack(const ValueType &Default)
Definition: Sema.h:486
std::pair< SourceLocation, bool > DeleteExprLoc
Delete-expressions to be analyzed at the end of translation unit.
Definition: Sema.h:630
ObjCContainerKind
Definition: Sema.h:8247
unsigned LayoutCompatible
If true, Type should be compared with other expression&#39;s types for layout-compatibility.
Definition: Sema.h:11063
ExprResult getExpression() const
Definition: Sema.h:1912
Concrete class used by the front-end to report problems and issues.
Definition: Diagnostic.h:149
void incrementMSManglingNumber() const
Definition: Sema.h:11134
llvm::DenseSet< Module * > LookupModulesCache
Cache of additional modules that should be used for name lookup within the current template instantia...
Definition: Sema.h:7600
GlobalMethodPool MethodPool
Method Pool - allows efficient lookup when typechecking messages to "id".
Definition: Sema.h:1209
Represents a declaration of a type.
Definition: Decl.h:2907
Substitution of the deduced template argument values resulted in an error.
Definition: Sema.h:7263
A set of unresolved declarations.
Definition: UnresolvedSet.h:60
SourceLocation PointOfInstantiation
The point of instantiation or synthesis within the source code.
Definition: Sema.h:7531
Look up the name of an OpenMP user-defined reduction operation.
Definition: Sema.h:3262
Template argument deduction exceeded the maximum template instantiation depth (which has already been...
Definition: Sema.h:7246
void MarkDeducedTemplateParameters(const FunctionTemplateDecl *FunctionTemplate, llvm::SmallBitVector &Deduced)
Definition: Sema.h:7444
CheckedConversionKind
The kind of conversion being performed.
Definition: Sema.h:9741
EnterExpressionEvaluationContext(Sema &Actions, InitListTag, bool ShouldEnter=true)
Definition: Sema.h:11286
std::pair< StringRef, QualType > CapturedParamNameType
Definition: Sema.h:4007
std::function< ExprResult(Sema &, TypoExpr *, TypoCorrection)> TypoRecoveryCallback
Definition: Sema.h:3327
LazyDeclPtr StdBadAlloc
The C++ "std::bad_alloc" class, which is defined by the C++ standard library.
Definition: Sema.h:884
Scope - A scope is a transient data structure that is used while parsing the program.
Definition: Scope.h:40
The type of a data member.
Definition: Sema.h:6900
PreferredTypeBuilder(QualType Type)
Definition: Sema.h:284
Emit no diagnostics.
Definition: Sema.h:10445
CaseStmt - Represent a case statement.
Definition: Stmt.h:1478
NonTagKind
Common ways to introduce type names without a tag for use in diagnostics.
Definition: Sema.h:2367
TypoExpr - Internal placeholder for expressions where typo correction still needs to be performed and...
Definition: Expr.h:5926
void popUndelayed(DelayedDiagnosticsState state)
Undo a previous pushUndelayed().
Definition: Sema.h:761
SourceLocation Loc
The location of the push attribute.
Definition: Sema.h:559
PragmaPackDiagnoseKind
Definition: Sema.h:8673
Represents a C++ nested-name-specifier or a global scope specifier.
Definition: DeclSpec.h:63
CastExpr - Base class for type casts, including both implicit casts (ImplicitCastExpr) and explicit c...
Definition: Expr.h:3121
Represents an Objective-C protocol declaration.
Definition: DeclObjC.h:2063
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:7678
AccessResult
Definition: Sema.h:6291
ArrayTypeTrait
Names for the array type traits.
Definition: TypeTraits.h:90
const internal::VariadicDynCastAllOfMatcher< Stmt, CastExpr > castExpr
Matches any cast nodes of Clang&#39;s AST.
static bool checkAddressOfFunctionIsAvailable(Sema &S, const FunctionDecl *FD, bool Complain, bool InOverloadResolution, SourceLocation Loc)
Returns true if we can take the address of the function.
void incrementMSManglingNumber()
Definition: Scope.h:297
Preprocessor & PP
Definition: Sema.h:373
ObjCInterfaceDecl * NSNumberDecl
The declaration of the Objective-C NSNumber class.
Definition: Sema.h:912
const LangOptions & getLangOpts() const
Definition: Sema.h:1285
LambdaCaptureInitKind
Definition: DeclSpec.h:2551
sema::AnalysisBasedWarnings AnalysisWarnings
Worker object for performing CFG-based warnings.
Definition: Sema.h:7932
SmallVector< BoundNodes, 1 > match(MatcherT Matcher, const NodeT &Node, ASTContext &Context)
Returns the results of matching Matcher on Node.
MaybeODRUseExprSet MaybeODRUseExprs
Definition: Sema.h:596
Represents the body of a CapturedStmt, and serves as its DeclContext.
Definition: Decl.h:4108
bool isUnevaluatedContext() const
Determines whether we are currently in a context that is not evaluated as per C++ [expr] p5...
Definition: Sema.h:7847
Represents an ObjC class declaration.
Definition: DeclObjC.h:1171
SmallVector< LambdaExpr *, 2 > Lambdas
The lambdas that are present within this context, if it is indeed an unevaluated context.
Definition: Sema.h:1035
Member name lookup, which finds the names of class/struct/union members.
Definition: Sema.h:3232
IncompatiblePointerSign - The assignment is between two pointers types which point to integers which ...
Definition: Sema.h:9896
NamespaceDecl * StdExperimentalNamespaceCache
The C++ "std::experimental" namespace, where the experimental parts of the standard library resides...
Definition: Sema.h:892
llvm::DenseMap< IdentifierInfo *, AsmLabelAttr * > ExtnameUndeclaredIdentifiers
ExtnameUndeclaredIdentifiers - Identifiers contained in #pragma redefine_extname before declared...
Definition: Sema.h:859
bool mightBeIntendedToBeTemplateName(ExprResult E, bool &Dependent)
Determine whether it&#39;s plausible that E was intended to be a template-name.
Definition: Sema.h:1984
FullExprArg(Sema &actions)
Definition: Sema.h:3838
ObjCMethodDecl * StringWithUTF8StringMethod
The declaration of the stringWithUTF8String: method.
Definition: Sema.h:933
const LangOptions & LangOpts
Definition: Sema.h:372
static NameClassification TypeTemplate(TemplateName Name)
Definition: Sema.h:1881
RAII object used to change the argument pack substitution index within a Sema object.
Definition: Sema.h:7655
uint8_t PointerKind
Which kind of pointer declarator we saw.
Definition: Sema.h:241
Contains information about the compound statement currently being parsed.
Definition: ScopeInfo.h:67
TemplateNameKindForDiagnostics
Describes the detailed kind of a template name. Used in diagnostics.
Definition: Sema.h:1970
Represents the this expression in C++.
Definition: ExprCXX.h:1006
ParsingClassState PushParsingClass()
Definition: Sema.h:4164
unsigned NumCleanupObjects
The number of active cleanup objects when we entered this expression evaluation context.
Definition: Sema.h:1025
llvm::SmallVector< DeleteExprLoc, 4 > DeleteLocs
Definition: Sema.h:631
A helper class for building up ExtParameterInfos.
Definition: Sema.h:8023
void AddInstanceMethodToGlobalPool(ObjCMethodDecl *Method, bool impl=false)
AddInstanceMethodToGlobalPool - All instance methods in a translation unit are added to a global pool...
Definition: Sema.h:3792
TypeTrait
Names for traits that operate specifically on types.
Definition: TypeTraits.h:20
bool MSStructPragmaOn
Definition: Sema.h:396
We are matching the template parameter lists of two template template parameters as part of matching ...
Definition: Sema.h:6786
DiagnosticsEngine & getDiagnostics() const
Definition: Sema.h:1289
RAII class used to determine whether SFINAE has trapped any errors that occur during template argumen...
Definition: Sema.h:7856
Defines the clang::TemplateNameKind enum.
ArgumentPackSubstitutionIndexRAII(Sema &Self, int NewSubstitutionIndex)
Definition: Sema.h:7660
CXXSpecialMember
Kinds of C++ special members.
Definition: Sema.h:1221
static Sema::TemplateDeductionResult DeduceTemplateArguments(Sema &S, TemplateParameterList *TemplateParams, const TemplateArgument &Param, TemplateArgument Arg, TemplateDeductionInfo &Info, SmallVectorImpl< DeducedTemplateArgument > &Deduced)
llvm::Optional< bool > getKnownValue() const
Definition: Sema.h:10269
virtual ~TypeDiagnoser()
Definition: Sema.h:1599
We are substituting explicit template arguments provided for a function template. ...
Definition: Sema.h:7487
IdentifierInfo * IdentInfo
Definition: Sema.h:4689
Sema - This implements semantic analysis and AST building for C.
Definition: Sema.h:328
Merge availability attributes for an implementation of a protocol requirement.
Definition: Sema.h:2608
A little helper class used to produce diagnostics.
Definition: Diagnostic.h:1045
Represents a prototype with parameter type info, e.g.
Definition: Type.h:3719
A functional-style cast.
Definition: Sema.h:9747
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:1051
TentativeDefinitionsType TentativeDefinitions
All the tentative definitions encountered in the TU.
Definition: Sema.h:653
ResultTypeCompatibilityKind
Describes the compatibility of a result type with its method.
Definition: Sema.h:8641
llvm::DenseMap< Selector, GlobalMethods > GlobalMethodPool
Definition: Sema.h:1201
static bool isEqual(const FunctionDeclAndLoc &LHS, const FunctionDeclAndLoc &RHS)
Definition: Sema.h:11340
Retains information about a captured region.
Definition: ScopeInfo.h:741
llvm::SmallPtrSet< Selector, 8 > SelectorSet
Definition: Sema.h:3610
A RAII object to enter scope of a compound statement.
Definition: Sema.h:3886
Represents a ValueDecl that came out of a declarator.
Definition: Decl.h:688
CastKind
CastKind - The kind of operation required for a conversion.
The return type of classify().
Definition: Expr.h:311
friend const DeviceDiagBuilder & operator<<(const DeviceDiagBuilder &Diag, const T &Value)
Definition: Sema.h:10477
Template argument deduction did not deduce a value for every template parameter.
Definition: Sema.h:7249
static FunctionDeclAndLoc getTombstoneKey()
Definition: Sema.h:11331
FunctionVoidPointer - The assignment is between a function pointer and void*, which the standard does...
Definition: Sema.h:9886
llvm::FoldingSet< SpecialMemberOverloadResultEntry > SpecialMemberCache
A cache of special member function overload resolution results for C++ records.
Definition: Sema.h:1146
ArraySizeModifier
Capture whether this is a normal array (e.g.
Definition: Type.h:2850
llvm::SmallPtrSet< Expr *, 2 > MaybeODRUseExprSet
Store a set of either DeclRefExprs or MemberExprs that contain a reference to a variable (constant) t...
Definition: Sema.h:595
const Decl * PragmaAttributeCurrentTargetDecl
The declaration that is currently receiving an attribute from the #pragma attribute stack...
Definition: Sema.h:569
TemplateParameterListEqualKind
Enumeration describing how template parameter lists are compared for equality.
Definition: Sema.h:6768
DelayedDiagnosticsState ParsingDeclState
Definition: Sema.h:711
We are instantiating a template declaration.
Definition: Sema.h:7471
SourceLocation NameLoc
Definition: Sema.h:8470
Captures information about a #pragma weak directive.
Definition: Weak.h:24
std::function< void(const TypoCorrection &)> TypoDiagnosticGenerator
Definition: Sema.h:3325
This represents &#39;#pragma omp requires...&#39; directive.
Definition: DeclOpenMP.h:345
Scope * getCurScope() const
Retrieve the parser&#39;s current scope.
Definition: Sema.h:11132
unsigned Offset
Definition: Format.cpp:1713
TUFragmentKind
Definition: Sema.h:1388
llvm::PointerIntPair< CXXRecordDecl *, 3, CXXSpecialMember > SpecialMemberDecl
Definition: Sema.h:1232
SourceLocation IdentifierLoc
The location of the identifier.
Definition: Sema.h:5639
Allows QualTypes to be sorted and hence used in maps and sets.
NameClassification(ParsedType Type)
Definition: Sema.h:1865
SmallVector< PendingImplicitInstantiation, 1 > LateParsedInstantiations
Queue of implicit template instantiations that cannot be performed eagerly.
Definition: Sema.h:7951
Retains information about a block that is currently being parsed.
Definition: ScopeInfo.h:715
void popWithoutEmitting(DelayedDiagnosticsState state)
Leave a delayed-diagnostic state that was previously pushed.
Definition: Sema.h:747
const char * getTypeName(ID Id)
getTypeName - Return the name of the type for Id.
Definition: Types.cpp:38
llvm::DenseSet< FunctionDeclAndLoc > LocsWithCUDACallDiags
FunctionDecls and SourceLocations for which CheckCUDACall has emitted a (maybe deferred) "bad call" d...
Definition: Sema.h:10403
Represents a shadow constructor declaration introduced into a class by a C++11 using-declaration that...
Definition: DeclCXX.h:3376
Represents a block literal declaration, which is like an unnamed FunctionDecl.
Definition: Decl.h:3915
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
Definition: Decl.h:636
This represents one expression.
Definition: Expr.h:108
LookupNameKind
Describes the kind of name lookup to perform.
Definition: Sema.h:3220
SourceLocation End
SmallVector< Decl *, 2 > WeakTopLevelDecl
WeakTopLevelDecl - Translation-unit scoped declarations generated by #pragma weak during processing o...
Definition: Sema.h:870
DelayedDiagnosticsState push(sema::DelayedDiagnosticPool &pool)
Enter a new scope.
Definition: Sema.h:737
ExprValueKind
The categorization of expression values, currently following the C++11 scheme.
Definition: Specifiers.h:121
NonTrivialCUnionKind
Definition: Sema.h:2147
Slot(llvm::StringRef StackSlotLabel, ValueType Value, SourceLocation PragmaLocation, SourceLocation PragmaPushLocation)
Definition: Sema.h:454
std::string Label
ModuleDeclKind
Definition: Sema.h:2246
Helper class that collects exception specifications for implicitly-declared special member functions...
Definition: Sema.h:4974
int Id
Definition: ASTDiff.cpp:190
When performing template argument deduction for a function template, there were too many call argumen...
Definition: Sema.h:7276
llvm::SmallPtrSet< const Decl *, 4 > ParsingInitForAutoVars
ParsingInitForAutoVars - a set of declarations with auto types for which we are currently parsing the...
Definition: Sema.h:643
Look up the name of an OpenMP user-defined mapper.
Definition: Sema.h:3264
StateNode * Previous
Declaration of a template type parameter.
The message is an instance message.
Definition: Sema.h:8525
This file defines the classes used to store parsed information about declaration-specifiers and decla...
bool isInvalid() const
Determines whether we have exceeded the maximum recursive template instantiations.
Definition: Sema.h:7788
We are substituting template argument determined as part of template argument deduction for either a ...
Definition: Sema.h:7494
ElaboratedTypeKeyword
The elaboration keyword that precedes a qualified type name or introduces an elaborated-type-specifie...
Definition: Type.h:5120
#define V(N, I)
Definition: ASTContext.h:2907
Represents a C++ destructor within a class.
Definition: DeclCXX.h:2838
LazyDeclPtr StdNamespace
The C++ "std" namespace, where the standard library resides.
Definition: Sema.h:880
const internal::VariadicAllOfMatcher< Decl > decl
Matches declarations.
Code completion occurs within an Objective-C interface, protocol, or category.
Definition: Sema.h:10697
bool InNonInstantiationSFINAEContext
Whether we are in a SFINAE context that is not associated with template instantiation.
Definition: Sema.h:7616
IncompatibleVectors - The assignment is between two vector types that have the same size...
Definition: Sema.h:9921
llvm::MapVector< IdentifierInfo *, WeakInfo > WeakUndeclaredIdentifiers
WeakUndeclaredIdentifiers - Identifiers contained in #pragma weak before declared.
Definition: Sema.h:853
#define bool
Definition: stdbool.h:15
OpenMPClauseKind
OpenMP clauses.
Definition: OpenMPKinds.h:32
QualType FindCompositePointerType(SourceLocation Loc, ExprResult &E1, ExprResult &E2, bool ConvertArgs=true)
Definition: Sema.h:10085
PragmaStack< StringLiteral * > BSSSegStack
Definition: Sema.h:521
SourceLocation LocStart
Definition: Sema.h:4686
Initial building of a for-range statement.
Definition: Sema.h:3969
SourceLocation Begin
When performing template argument deduction for a function template, there were too few call argument...
Definition: Sema.h:7279
IdentifierResolver - Keeps track of shadowed decls on enclosing scopes.
An abstract interface that should be implemented by listeners that want to be notified when an AST en...
PragmaClangSectionAction
Definition: Sema.h:417
CXXTryStmt - A C++ try block, including all handlers.
Definition: StmtCXX.h:68
IncompatiblePointerDiscardsQualifiers - The assignment discards qualifiers that we don&#39;t permit to be...
Definition: Sema.h:9905
NonTypeTemplateParmDecl - Declares a non-type template parameter, e.g., "Size" in.
Ref_Related - The two types are reference-related, which means that their unqualified forms (T1 and T...
Definition: Sema.h:10135
Represents a C++ template name within the type system.
Definition: TemplateName.h:187
QualType NSNumberPointer
Pointer to NSNumber type (NSNumber *).
Definition: Sema.h:918
ReferenceCompareResult
ReferenceCompareResult - Expresses the result of comparing two types (cv1 T1 and cv2 T2) to determine...
Definition: Sema.h:10128
Defines the clang::TypeLoc interface and its subclasses.
int Depth
Definition: ASTDiff.cpp:190
Keeps track of expected type during expression parsing.
Definition: Sema.h:281
bool isVisible(const NamedDecl *D)
Determine whether a declaration is visible to name lookup.
Definition: Sema.h:1689
Code completion occurs within a statement, which may also be an expression or a declaration.
Definition: Sema.h:10714
std::unique_ptr< MangleNumberingContext > MangleNumbering
The context information used to mangle lambda expressions and block literals within this context...
Definition: Sema.h:1047
TemplateNameKind
Specifies the kind of template name that an identifier refers to.
Definition: TemplateKinds.h:20
SmallVector< LateInstantiatedAttribute, 16 > LateInstantiatedAttrVec
Definition: Sema.h:8152
SmallVector< VTableUse, 16 > VTableUses
The list of vtables that are required but have not yet been materialized.
Definition: Sema.h:6100
An RAII helper that pops function a function scope on exit.
Definition: Sema.h:3901
StorageClass
Storage classes.
Definition: Specifiers.h:234
CleanupInfo ParentCleanup
Whether the enclosing context needed a cleanup.
Definition: Sema.h:1018
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:11157
SmallVector< sema::FunctionScopeInfo *, 4 > FunctionScopes
Stack containing information about each of the nested function, block, and method scopes that are cur...
Definition: Sema.h:602
PragmaMSCommentKind
Definition: PragmaKinds.h:14
InClassInitStyle
In-class initialization styles for non-static data members.
Definition: Specifiers.h:257
Partial specialization.
Definition: Sema.h:6936
NameClassification(ExprResult Expr)
Definition: Sema.h:1863
An expression that sends a message to the given Objective-C object or class.
Definition: ExprObjC.h:950
A mapping from file IDs to a record of whether we&#39;ve seen nullability information in that file...
Definition: Sema.h:249
Data structure that captures multiple levels of template argument lists for use in template instantia...
Definition: Template.h:64
llvm::SmallPtrSet< const Expr *, 8 > PossibleDerefs
Definition: Sema.h:1057
bool isInvalid() const
Definition: Ownership.h:166
Preprocessor & getPreprocessor() const
Definition: Sema.h:1291
IdentifierInfo * Identifier
The identifier preceding the &#39;::&#39;.
Definition: Sema.h:5636
bool RequireCompleteType(SourceLocation Loc, QualType T, unsigned DiagID, const Ts &...Args)
Definition: Sema.h:1754
TemplateTemplateParmDecl - Declares a template template parameter, e.g., "T" in.
ObjCMethodDecl * ArrayWithObjectsMethod
The declaration of the arrayWithObjects:count: method.
Definition: Sema.h:942
const FunctionProtoType::ExtParameterInfo * getPointerOrNull(unsigned numParams)
Return a pointer (suitable for setting in an ExtProtoInfo) to the ExtParameterInfo array we&#39;ve built ...
Definition: Sema.h:8042
void addContextNote(SourceLocation UseLoc)
Definition: Sema.h:828
The symbol exists.
Definition: Sema.h:4736
SmallVector< attr::SubjectMatchRule, 4 > MatchRules
Definition: Sema.h:552
After substituting deduced template arguments, a dependent parameter type did not match the correspon...
Definition: Sema.h:7266
Represents a C++ conversion function within a class.
Definition: DeclCXX.h:2899
Code completion occurs within the list of instance variables in an Objective-C interface, protocol, category, or implementation.
Definition: Sema.h:10703
OpenMPProcBindClauseKind
OpenMP attributes for &#39;proc_bind&#39; clause.
Definition: OpenMPKinds.h:50
ObjCTypeParamVariance
Describes the variance of a given generic parameter.
Definition: DeclObjC.h:533
PragmaClangSectionKind
pragma clang section kind
Definition: Sema.h:409
const SourceManager & SM
Definition: Format.cpp:1572
ObjCKeywordKind
Provides a namespace for Objective-C keywords which start with an &#39;@&#39;.
Definition: TokenKinds.h:40
SmallVector< CXXMethodDecl *, 4 > DelayedDllExportMemberFunctions
Definition: Sema.h:11168
CallingConv
CallingConv - Specifies the calling convention that a function uses.
Definition: Specifiers.h:264
SourceLocation PointerLoc
The first pointer declarator (of any pointer kind) in the file that does not have a corresponding nul...
Definition: Sema.h:234
unsigned NumSFINAEErrors
The number of SFINAE diagnostics that have been trapped.
Definition: Sema.h:1164
This is a legitimate overload: the existing declarations are functions or function templates with dif...
Definition: Sema.h:2718
An abstract interface that should be implemented by external AST sources that also provide informatio...
ExprResult CorrectDelayedTyposInExpr(ExprResult ER, llvm::function_ref< ExprResult(Expr *)> Filter)
Definition: Sema.h:3500
CanonicalDeclPtr< FunctionDecl > FD
Definition: Sema.h:10396
static StringRef getPrintable(StringRef S)
Definition: Sema.h:1606
BuildForRangeKind
Definition: Sema.h:3967
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:669
A declaration qualifier.
Definition: Sema.h:6921
AvailabilityPriority
Describes the kind of priority given to an availability attribute.
Definition: Sema.h:2623
std::pair< const IdentifierInfo *, uint64_t > TypeTagMagicValue
A pair of ArgumentKind identifier and magic value.
Definition: Sema.h:11069
noexcept(expression), evals to &#39;false&#39;
LazyVector< TypedefNameDecl *, ExternalSemaSource, &ExternalSemaSource::ReadExtVectorDecls, 2, 2 > ExtVectorDeclsType
Definition: Sema.h:606
bool hasVisibleDefinition(const NamedDecl *D)
Definition: Sema.h:1713
StringLiteral * CurInitSeg
Last section used with #pragma init_seg.
Definition: Sema.h:542
CanThrowResult
Possible results from evaluation of a noexcept expression.
bool isComputedNoexcept(ExceptionSpecificationType ESpecType)
static unsigned getPrintable(unsigned I)
Definition: Sema.h:1603
static bool DiagnoseUnexpandedParameterPacks(Sema &S, TemplateTemplateParmDecl *TTP)
Check for unexpanded parameter packs within the template parameters of a template template parameter...
Represents a C++ Modules TS module export declaration.
Definition: Decl.h:4278
NameClassificationKind
Describes the result of the name lookup and resolution performed by ClassifyName().
Definition: Sema.h:1841
void pushCodeSynthesisContext(CodeSynthesisContext Ctx)
llvm::cl::opt< std::string > Filter
We are declaring an implicit special member function.
Definition: Sema.h:7514
ARCConversionResult
Definition: Sema.h:10183
CXXSpecialMember SpecialMember
The special member being declared or defined.
Definition: Sema.h:7552
#define false
Definition: stdbool.h:17
Tag name lookup, which finds the names of enums, classes, structs, and unions.
Definition: Sema.h:3227
RecordDecl * CXXTypeInfoDecl
The C++ "type_info" declaration, which is defined in <typeinfo>.
Definition: Sema.h:903
Kind
A reference to an overloaded function set, either an UnresolvedLookupExpr or an UnresolvedMemberExpr...
Definition: ExprCXX.h:2750
ImplicitConversionSequence - Represents an implicit conversion sequence, which may be a standard conv...
Definition: Overload.h:486
PragmaSectionKind
Definition: Sema.h:8702
ActionResult - This structure is used while parsing/acting on expressions, stmts, etc...
Definition: Ownership.h:153
ExceptionSpecificationType Type
The kind of exception specification this is.
Definition: Type.h:3775
PseudoObjectExpr - An expression which accesses a pseudo-object l-value.
Definition: Expr.h:5663
SmallVector< CXXBaseSpecifier *, 4 > CXXCastPath
A simple array of base specifiers.
Definition: Expr.h:56
Represents the parsed form of a C++ template argument.
A stack object to be created when performing template instantiation.
Definition: Sema.h:7692
TypeTagData(QualType Type, bool LayoutCompatible, bool MustBeNull)
Definition: Sema.h:11054
ASTContext & getASTContext() const
Definition: Sema.h:1292
LazyDeclPtr StdAlignValT
The C++ "std::align_val_t" enum class, which is defined by the C++ standard library.
Definition: Sema.h:888
llvm::SmallDenseMap< const ValueDecl *, const Expr *, 4 > VarsWithInheritedDSAType
Definition: Sema.h:9201
DeduceAutoResult
Result type of DeduceAutoType.
Definition: Sema.h:7370
Encodes a location in the source.
We are computing the exception specification for a defaulted special member function.
Definition: Sema.h:7507
OpenMPDependClauseKind
OpenMP attributes for &#39;depend&#39; clause.
Definition: OpenMPKinds.h:75
Defines enumerations for expression traits intrinsics.
SourceLocation CurrentPragmaLocation
Definition: Sema.h:494
Diagnostic builder for CUDA/OpenMP devices errors which may or may not be deferred.
Definition: Sema.h:10441
ObjCPropertyQueryKind
Definition: DeclObjC.h:716
static unsigned getHashValue(const FunctionDeclAndLoc &FDL)
Definition: Sema.h:11335
static const char * getPrintable(const char *S)
Definition: Sema.h:1605
sema::TemplateDeductionInfo * DeductionInfo
The template deduction info object associated with the substitution or checking of explicit or deduce...
Definition: Sema.h:7562
static SourceRange getPrintable(const Expr *E)
Definition: Sema.h:1615
Template argument deduction failed due to inconsistent cv-qualifiers on a template parameter type tha...
Definition: Sema.h:7260
Represents the declaration of a struct/union/class/enum.
Definition: Decl.h:3097
OpenMPDirectiveKind
OpenMP directives.
Definition: OpenMPKinds.h:22
Represents the declaration of a label.
Definition: Decl.h:468
IncompatiblePointer - The assignment is between two pointers types that are not compatible, but we accept them as an extension.
Definition: Sema.h:9890
ParsedAttr - Represents a syntactic attribute.
Definition: ParsedAttr.h:116
Template argument deduction did not deduce a value for every expansion of an expanded template parame...
Definition: Sema.h:7252
SynthesisKind
The kind of template instantiation we are performing.
Definition: Sema.h:7468
DelayedDiagnosticsState ProcessingContextState
Definition: Sema.h:712
Decl * ManglingContextDecl
The declaration that provides context for lambda expressions and block literals if the normal declara...
Definition: Sema.h:1040
ExprObjectKind
A further classification of the kind of object referenced by an l-value or x-value.
Definition: Specifiers.h:138
ClassTemplateDecl * StdInitializerList
The C++ "std::initializer_list" template, which is defined in <initializer_list>. ...
Definition: Sema.h:896
ObjCSpecialMethodKind
Definition: Sema.h:8459
Represents a static or instance method of a struct/union/class.
Definition: DeclCXX.h:2114
ParsedType getType() const
Definition: Sema.h:1907
SourceLocation CCLoc
The location of the &#39;::&#39;.
Definition: Sema.h:5642
bool shouldDelayDiagnostics()
Determines whether diagnostics should be delayed.
Definition: Sema.h:728
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
Only look for allocation functions in the scope of the allocated class.
Definition: Sema.h:5464
TemplateNameKind getTemplateNameKind() const
Definition: Sema.h:1923
llvm::SmallPtrSet< const CXXRecordDecl *, 8 > RecordDeclSetTy
Definition: Sema.h:634
SFINAETrap(Sema &SemaRef, bool AccessCheckingSFINAE=false)
Definition: Sema.h:7864
We are checking the validity of a default template argument that has been used when naming a template...
Definition: Sema.h:7503
The declaration was invalid; do nothing.
Definition: Sema.h:7243
static DeclarationName getPrintable(DeclarationName N)
Definition: Sema.h:1611
__m64_union t
Definition: emmintrin.h:2059
ObjCCategoryDecl - Represents a category declaration.
Definition: DeclObjC.h:2279
This is a basic class for representing single OpenMP clause.
Definition: OpenMPClause.h:50
The message is sent to &#39;super&#39;.
Definition: Sema.h:8523
static bool hasVisibleDefaultArgument(Sema &S, const ParmDecl *D, llvm::SmallVectorImpl< Module *> *Modules)
static bool isCast(CheckedConversionKind CCK)
Definition: Sema.h:9754
bool CollectStats
Flag indicating whether or not to collect detailed statistics.
Definition: Sema.h:380
static void CheckBoolLikeConversion(Sema &S, Expr *E, SourceLocation CC)
Check conversion of given expression to boolean.
TokenKind
Provides a simple uniform namespace for tokens from all C languages.
Definition: TokenKinds.h:24
SourceLocation PragmaLocation
Definition: Sema.h:425
bool RequireNonAbstractType(SourceLocation Loc, QualType T, unsigned DiagID, const Ts &...Args)
Definition: Sema.h:6378
Describes the kind of initialization being performed, along with location information for tokens rela...
PragmaStack< MSVtorDispAttr::Mode > VtorDispStack
Whether to insert vtordisps prior to virtual bases in the Microsoft C++ ABI.
Definition: Sema.h:507
A friend declaration.
Definition: Sema.h:6918
AbstractDiagSelID
Definition: Sema.h:6363
void EmitCurrentDiagnostic(unsigned DiagID)
Cause the active diagnostic on the DiagosticsEngine to be emitted.
Definition: Sema.cpp:1258
SourceLocation OptimizeOffPragmaLocation
This represents the last location of a "#pragma clang optimize off" directive if such a directive has...
Definition: Sema.h:574
Represents a C++11 virt-specifier-seq.
Definition: DeclSpec.h:2509
CodeCompleteConsumer * CodeCompleter
Code-completion consumer.
Definition: Sema.h:383
unsigned NumTypos
The number of typos encountered during this expression evaluation context (i.e.
Definition: Sema.h:1029
Represents one property declaration in an Objective-C interface.
Definition: DeclObjC.h:728
void SetLateTemplateParser(LateTemplateParserCB *LTP, LateTemplateParserCleanupCB *LTPCleanup, void *P)
Definition: Sema.h:697
OpaquePtr< TemplateName > TemplateTy
Definition: Sema.h:366
llvm::DenseSet< std::pair< Decl *, unsigned > > InstantiatingSpecializations
Specializations whose definitions are currently being instantiated.
Definition: Sema.h:7587
A default argument.
Definition: Sema.h:6927
llvm::SmallSetVector< CXXRecordDecl *, 16 > AssociatedClassSet
Definition: Sema.h:2929
const IdentifierInfo * Namespace
The namespace of this push group.
Definition: Sema.h:561
std::unique_ptr< CXXFieldCollector > FieldCollector
FieldCollector - Collects CXXFieldDecls during parsing of C++ classes.
Definition: Sema.h:614
static NameClassification FunctionTemplate(TemplateName Name)
Definition: Sema.h:1893
The name is a dependent name, so the results will differ from one instantiation to the next...
Definition: Sema.h:4743
bool IsBuildingRecoveryCallExpr
Flag indicating if Sema is building a recovery call expression.
Definition: Sema.h:580
DeductionFailureInfo MakeDeductionFailureInfo(ASTContext &Context, Sema::TemplateDeductionResult TDK, sema::TemplateDeductionInfo &Info)
Convert from Sema&#39;s representation of template deduction information to the form used in overload-can...
OverloadCandidateSet - A set of overload candidates, used in C++ overload resolution (C++ 13...
Definition: Overload.h:846
Constant expression in a noptr-new-declarator.
Definition: Sema.h:2814
ParameterABI
Kinds of parameter ABI.
Definition: Specifiers.h:337
llvm::DenseMap< ParmVarDecl *, llvm::TinyPtrVector< ParmVarDecl * > > UnparsedDefaultArgInstantiationsMap
Definition: Sema.h:1167
TentativeAnalysisScope(Sema &SemaRef)
Definition: Sema.h:7902
ASTConsumer & getASTConsumer() const
Definition: Sema.h:1293
CUDAFunctionTarget CurrentCUDATarget()
Gets the CUDA target for the current context.
Definition: Sema.h:10569
SourceLocation getExprLoc() const LLVM_READONLY
getExprLoc - Return the preferred location for the arrow when diagnosing a problem with a generic exp...
Definition: Expr.cpp:215
SynthesizedFunctionScope(Sema &S, DeclContext *DC)
Definition: Sema.h:817
void setLastDiagnosticIgnored(bool Ignored=true)
Pretend that the last diagnostic issued was ignored, so any subsequent notes will be suppressed...
Definition: Diagnostic.h:670
QualType NSValuePointer
Pointer to NSValue type (NSValue *).
Definition: Sema.h:921
Defines various enumerations that describe declaration and type specifiers.
A POD class for pairing a NamedDecl* with an access specifier.
The expression in a static assertion.
Definition: Sema.h:6906
Expression in a case label.
Definition: Sema.h:2811
ReuseLambdaContextDecl_t
Definition: Sema.h:4206
A class for storing results from argument-dependent lookup.
Definition: Lookup.h:798
OpaquePtr< QualType > TypeTy
Definition: Sema.h:367
static std::enable_if< IsPartialSpecialization< T >::value, Sema::TemplateDeductionResult >::type FinishTemplateArgumentDeduction(Sema &S, T *Partial, bool IsPartialOrdering, const TemplateArgumentList &TemplateArgs, SmallVectorImpl< DeducedTemplateArgument > &Deduced, TemplateDeductionInfo &Info)
Complete template argument deduction for a partial specialization.
Base class for declarations which introduce a typedef-name.
Definition: Decl.h:2949
Abstract interface for a consumer of code-completion information.
An opaque identifier used by SourceManager which refers to a source file (MemoryBuffer) along with it...
Represents a reference to a function parameter pack or init-capture pack that has been substituted bu...
Definition: ExprCXX.h:4243
Represents a template argument.
Definition: TemplateBase.h:50
ParserCompletionContext
Describes the context in which code completion occurs.
Definition: Sema.h:10690
ObjCDeclSpec DeclSpec
Definition: Sema.h:8474
TagTypeKind
The kind of a tag type.
Definition: Type.h:5101
OpenMPScheduleClauseModifier
OpenMP modifiers for &#39;schedule&#39; clause.
Definition: OpenMPKinds.h:66
Abstract base class used to perform a contextual implicit conversion from an expression to any type p...
Definition: Sema.h:2825
Dataflow Directional Tag Classes.
llvm::DenseMap< IdentifierInfo *, SrcLocSet > IdentifierSourceLocations
Definition: Sema.h:7924
LateTemplateParserCleanupCB * LateTemplateParserCleanup
Definition: Sema.h:694
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:1055
ConstexprSpecKind
Define the kind of constexpr specifier.
Definition: Specifiers.h:32
SourceLocation ImplicitMSInheritanceAttrLoc
Source location for newly created implicit MSInheritanceAttrs.
Definition: Sema.h:406
int ArgumentPackSubstitutionIndex
The current index into pack expansion arguments that will be used for substitution of parameter packs...
Definition: Sema.h:7649
Don&#39;t merge availability attributes at all.
Definition: Sema.h:2599
unsigned NumTemplateArgs
The number of template arguments in TemplateArgs.
Definition: Sema.h:7549
UnaryOperatorKind
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
Definition: DeclBase.h:1271
const DeclContext * getCurObjCLexicalContext() const
Definition: Sema.h:11147
Represents a delete expression for memory deallocation and destructor calls, e.g. ...
Definition: ExprCXX.h:2265
static ImplicitConversionSequence TryImplicitConversion(Sema &S, Expr *From, QualType ToType, bool SuppressUserConversions, bool AllowExplicit, bool InOverloadResolution, bool CStyle, bool AllowObjCWritebackConversion, bool AllowObjCConversionOnExplicit)
TryImplicitConversion - Attempt to perform an implicit conversion from the given expression (Expr) to...
The base class of all kinds of template declarations (e.g., class, function, etc.).
Definition: DeclTemplate.h:403
OverloadedOperatorKind
Enumeration specifying the different kinds of C++ overloaded operators.
Definition: OperatorKinds.h:21
llvm::SmallVector< std::pair< SourceLocation, const BlockDecl * >, 1 > ImplicitlyRetainedSelfLocs
List of SourceLocations where &#39;self&#39; is implicitly retained inside a block.
Definition: Sema.h:1218
We are instantiating a default argument for a function.
Definition: Sema.h:7483
OpenMPAtomicDefaultMemOrderClauseKind
OpenMP attributes for &#39;atomic_default_mem_order&#39; clause.
Definition: OpenMPKinds.h:148
bool RequireLiteralType(SourceLocation Loc, QualType T, unsigned DiagID, const Ts &...Args)
Definition: Sema.h:1775
Reads an AST files chain containing the contents of a translation unit.
Definition: ASTReader.h:354
Represents a field injected from an anonymous union/struct into the parent scope. ...
Definition: Decl.h:2858
bool IsAllowedCUDACall(const FunctionDecl *Caller, const FunctionDecl *Callee)
Determines whether Caller may invoke Callee, based on their CUDA host/device attributes.
Definition: Sema.h:10601
static NameClassification VarTemplate(TemplateName Name)
Definition: Sema.h:1887
SourceLocation PointerEndLoc
The end location for the first pointer declarator in the file.
Definition: Sema.h:238
Custom deleter to allow FunctionScopeInfos to be kept alive for a short time after they&#39;ve been poppe...
Definition: Sema.h:1423
LateInstantiatedAttribute(const Attr *A, LocalInstantiationScope *S, Decl *D)
Definition: Sema.h:8147
A decomposition declaration.
Definition: DeclCXX.h:3988
ClassTemplateDecl * StdCoroutineTraitsCache
The C++ "std::coroutine_traits" template, which is defined in <coroutine_traits>
Definition: Sema.h:900
llvm::SmallSet< SourceLocation, 2 > SrcLocSet
Definition: Sema.h:7923
A non-depnedent component of the parameter did not match the corresponding component of the argument...
Definition: Sema.h:7273
bool GlobalNewDeleteDeclared
A flag to remember whether the implicit forms of operator new and delete have been declared...
Definition: Sema.h:958
The name of a declaration.
Represents the declaration of an Objective-C type parameter.
Definition: DeclObjC.h:558
unsigned size() const
The number of exceptions in the exception specification.
Definition: Sema.h:5007
SourceRange InstantiationRange
The source range that covers the construct that cause the instantiation, e.g., the template-id that c...
Definition: Sema.h:7567
Label name lookup.
Definition: Sema.h:3229
llvm::SmallPtrSet< SpecialMemberDecl, 4 > SpecialMembersBeingDeclared
The C++ special members which we are currently in the process of declaring.
Definition: Sema.h:1237
PragmaClangSection PragmaClangRodataSection
Definition: Sema.h:434
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:6096
ExpressionEvaluationContext Context
The expression evaluation context.
Definition: Sema.h:1015
AllocationFunctionScope
The scope in which to find allocation functions.
Definition: Sema.h:5459
Represents an enum.
Definition: Decl.h:3359
IncompatibleBlockPointer - The assignment is between two block pointers types that are not compatible...
Definition: Sema.h:9929
The lookup found an overload set of literal operator templates, which expect the characters of the sp...
Definition: Sema.h:3310
Emit the diagnostic immediately (i.e., behave like Sema::Diag()).
Definition: Sema.h:10447
TemplateSpecializationKind
Describes the kind of template specialization that a particular template specialization declaration r...
Definition: Specifiers.h:174
IdentifierResolver IdResolver
Definition: Sema.h:872
Optional< sema::TemplateDeductionInfo * > isSFINAEContext() const
Determines whether we are currently in a context where template argument substitution failures are no...
Expr * get() const
Definition: Sema.h:3844
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspnd...
SpecialMemberOverloadResult(CXXMethodDecl *MD)
Definition: Sema.h:1125
Abstract interface for a module loader.
Definition: ModuleLoader.h:73
The name refers to a template whose specialization produces a type.
Definition: TemplateKinds.h:30
ContextRAII(Sema &S, DeclContext *ContextToPush, bool NewThisContext=true)
Definition: Sema.h:776
bool isHidden() const
Determine whether this declaration might be hidden from name lookup.
Definition: DeclBase.h:774
llvm::MapVector< FieldDecl *, DeleteLocs > DeleteExprs
Definition: Sema.h:632
A dependently-generated diagnostic.
PragmaMsStackAction
Definition: Sema.h:437
Represents a pointer to an Objective C object.
Definition: Type.h:5864
AvailabilityMergeKind
Describes the kind of merge to perform for availability attributes (including "deprecated", "unavailable", and "availability").
Definition: Sema.h:2597
PragmaClangSection PragmaClangDataSection
Definition: Sema.h:433
void LateTemplateParserCB(void *P, LateParsedTemplate &LPT)
Callback to the parser to parse templated functions when needed.
Definition: Sema.h:691
SourceRange getSourceRange() const LLVM_READONLY
Get the full source range.
Definition: TypeLoc.h:150
Encapsulates the data about a macro definition (e.g.
Definition: MacroInfo.h:39
ObjCMethodDecl * LookupInstanceMethodInGlobalPool(Selector Sel, SourceRange R, bool receiverIdOrClass=false)
LookupInstanceMethodInGlobalPool - Returns the method and warns if there are multiple signatures...
Definition: Sema.h:3807
llvm::DenseSet< QualType > InstantiatedNonDependentTypes
Non-dependent types used in templates that have already been instantiated by some template instantiat...
Definition: Sema.h:7591
ObjCImplementationDecl - Represents a class definition - this is where method definitions are specifi...
Definition: DeclObjC.h:2551
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
Definition: Type.h:4438
DeclarationName VAListTagName
VAListTagName - The declaration name corresponding to __va_list_tag.
Definition: Sema.h:394
EnterExpressionEvaluationContext(Sema &Actions, Sema::ExpressionEvaluationContext NewContext, Decl *LambdaContextDecl=nullptr, Sema::ExpressionEvaluationContextRecord::ExpressionKind ExprContext=Sema::ExpressionEvaluationContextRecord::EK_Other, bool ShouldEnter=true)
Definition: Sema.h:11264
Location wrapper for a TemplateArgument.
Definition: TemplateBase.h:449
SmallVector< PragmaAttributeGroup, 2 > PragmaAttributeStack
Definition: Sema.h:565
The template argument was specified in the code or was instantiated with some deduced template argume...
Definition: Sema.h:6693
ArraySubscriptExpr - [C99 6.5.2.1] Array Subscripting.
Definition: Expr.h:2432
CheckTemplateArgumentKind
Specifies the context in which a particular template argument is being checked.
Definition: Sema.h:6690
ObjCLiteralKind
Definition: Sema.h:2910
ValueType CurrentValue
Definition: Sema.h:493
LocalInstantiationScope * Scope
Definition: Sema.h:8144
IntToBlockPointer - The assignment converts an int to a block pointer.
Definition: Sema.h:9925
Represents a C++ base or member initializer.
Definition: DeclCXX.h:2346
ExprResult ActOnCXXBoolLiteral(SourceLocation OpLoc, tok::TokenKind Kind)
ActOnCXXBoolLiteral - Parse {true,false} literals.
const QualType * data() const
The set of exceptions in the exception specification.
Definition: Sema.h:5010
DeclContext * getCurLexicalContext() const
Definition: Sema.h:11143
void * OpaqueParser
Definition: Sema.h:695
UnparsedDefaultArgInstantiationsMap UnparsedDefaultArgInstantiations
A mapping from parameters with unparsed default arguments to the set of instantiations of each parame...
Definition: Sema.h:1176
OpenMPScheduleClauseKind
OpenMP attributes for &#39;schedule&#39; clause.
Definition: OpenMPKinds.h:58
SmallVector< ExpressionEvaluationContextRecord, 8 > ExprEvalContexts
A stack of expression evaluation contexts.
Definition: Sema.h:1090
llvm::StringRef getCurrentOpenCLExtension() const
Definition: Sema.h:8928
bool isInOpenMPDeclareTargetContext() const
Return true inside OpenMP declare target region.
Definition: Sema.h:9172
static NameClassification Error()
Definition: Sema.h:1869
llvm::SmallSetVector< NamedDecl *, 16 > NamedDeclSetType
Definition: Sema.h:616
ExceptionSpecificationType
The various types of exception specifications that exist in C++11.
PragmaMSStructKind
Definition: PragmaKinds.h:23
Holds information about the various types of exception specification.
Definition: Type.h:3773
OpenMPDefaultClauseKind
OpenMP attributes for &#39;default&#39; clause.
Definition: OpenMPKinds.h:42
ArrayRef< TemplateArgument > template_arguments() const
Definition: Sema.h:7555
Deduction failed; that&#39;s all we know.
Definition: Sema.h:7286
static NameClassification Unknown()
Definition: Sema.h:1873
ObjCInterfaceDecl * NSArrayDecl
The declaration of the Objective-C NSArray class.
Definition: Sema.h:939
SmallVector< BlockDecl *, 8 > ExprCleanupObjects
ExprCleanupObjects - This is the stack of objects requiring cleanup that are created by the current f...
Definition: Sema.h:588
APValue - This class implements a discriminated union of [uninitialized] [APSInt] [APFloat]...
Definition: APValue.h:76
static SourceRange getPrintable(SourceLocation L)
Definition: Sema.h:1614
Represents a base class of a C++ class.
Definition: DeclCXX.h:192
static bool IsKnownEmitted(Sema &S, FunctionDecl *FD)
Definition: SemaCUDA.cpp:590
bool SavedInNonInstantiationSFINAEContext
Was the enclosing context a non-instantiation SFINAE context?
Definition: Sema.h:7528
void ActOnStartOfCompoundStmt(bool IsStmtExpr)
Definition: SemaStmt.cpp:338
PragmaStack< StringLiteral * > ConstSegStack
Definition: Sema.h:522
Condition in a constexpr if statement.
Definition: Sema.h:2815
ArrayRef< QualType > Exceptions
Explicitly-specified list of exception types.
Definition: Type.h:3778
ProcessingContextState ParsingClassState
Definition: Sema.h:4163
PragmaClangSection PragmaClangTextSection
Definition: Sema.h:435
ParsedType ObjectType
The type of the object, if we&#39;re parsing nested-name-specifier in a member access expression...
Definition: Sema.h:5633
void * SkippedDefinitionContext
Definition: Sema.h:2483
Describes whether we&#39;ve seen any nullability information for the given file.
Definition: Sema.h:231
QualType QIDNSCopying
id<NSCopying> type.
Definition: Sema.h:951
RedeclarationKind forRedeclarationInCurContext()
Definition: Sema.h:3284
An implicit conversion.
Definition: Sema.h:9743
TrivialABIHandling
Definition: Sema.h:2449
bool isAlreadyInstantiating() const
Determine whether we are already instantiating this specialization in some surrounding active instant...
Definition: Sema.h:7792
A template argument list.
Definition: DeclTemplate.h:214
Merge availability attributes for a redeclaration, which requires an exact match. ...
Definition: Sema.h:2602
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:2886
bool isConstantEvaluatedOverride
Used to change context to isConstantEvaluated without pushing a heavy ExpressionEvaluationContextReco...
Definition: Sema.h:802
Expr * NoexceptExpr
Noexcept expression, if this is a computed noexcept specification.
Definition: Type.h:3781
llvm::DenseMap< CanonicalDeclPtr< FunctionDecl >, std::vector< PartialDiagnosticAt > > DeviceDeferredDiags
Diagnostics that are emitted only if we discover that the given function must be codegen&#39;ed.
Definition: Sema.h:10391
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:7609
An attributed type is a type to which a type attribute has been applied.
Definition: Type.h:4493
CCEKind
Contexts in which a converted constant expression is required.
Definition: Sema.h:2810
static void BuildBasePathArray(const CXXBasePath &Path, CXXCastPath &BasePathArray)
OpaquePtr< DeclGroupRef > DeclGroupPtrTy
Definition: Sema.h:365
MemberExpr - [C99 6.5.2.3] Structure and Union Members.
Definition: Expr.h:2807
ExprResult CorrectDelayedTyposInExpr(Expr *E, llvm::function_ref< ExprResult(Expr *)> Filter)
Definition: Sema.h:3487
Data structure used to record current or nested expression evaluation contexts.
Definition: Sema.h:1013
void * VisContext
VisContext - Manages the stack for #pragma GCC visibility.
Definition: Sema.h:546
Describes the sequence of initializations required to initialize a given object or reference with a s...
The lookup found no match but no diagnostic was issued.
Definition: Sema.h:3300
Captures information about "declaration specifiers".
Definition: DeclSpec.h:228
Code completion occurs at the beginning of the initialization statement (or expression) in a for loop...
Definition: Sema.h:10717
void LateTemplateParserCleanupCB(void *P)
Definition: Sema.h:692
ActionResult< Expr * > ExprResult
Definition: Ownership.h:263
Only look for allocation functions in the global scope.
Definition: Sema.h:5461
SourceLocation PragmaPushLocation
Definition: Sema.h:453
sema::DelayedDiagnosticPool * getCurrentPool() const
Returns the current delayed-diagnostics pool.
Definition: Sema.h:731
Represents a C++ struct/union/class.
Definition: DeclCXX.h:300
Compatible - the types are compatible according to the standard.
Definition: Sema.h:9874
Decl * D
The template function declaration to be late parsed.
Definition: Sema.h:11316
CUDAFunctionTarget
Definition: Sema.h:10551
sema::FunctionScopeInfo * getCurFunction() const
Definition: Sema.h:1439
Look up a friend of a local class.
Definition: Sema.h:3256
void PopParsingClass(ParsingClassState state)
Definition: Sema.h:4167
A diagnostic message which has been conditionally emitted pending the complete parsing of the current...
OpenMPMapClauseKind
OpenMP mapping kind for &#39;map&#39; clause.
Definition: OpenMPKinds.h:91
ObjCIvarDecl - Represents an ObjC instance variable.
Definition: DeclObjC.h:1944
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:1704
LangOptions::PragmaMSPointersToMembersKind MSPointerToMemberRepresentationMethod
Controls member pointer representation format under the MS ABI.
Definition: Sema.h:400
TryCaptureKind
Definition: Sema.h:4245
std::unique_ptr< sema::FunctionScopeInfo, PoppedFunctionScopeDeleter > PoppedFunctionScopePtr
Definition: Sema.h:1432
llvm::DenseMap< int, SourceRange > ParsedSubjectMatchRuleSet
Selector RespondsToSelectorSel
will hold &#39;respondsToSelector:&#39;
Definition: Sema.h:954
TPOC
The context in which partial ordering of function templates occurs.
Definition: Template.h:160
DeclContext * CurContext
CurContext - This is the current declaration context of parsing.
Definition: Sema.h:386
TranslationUnitKind
Describes the kind of translation unit being processed.
Definition: LangOptions.h:362
Declaration of a class template.
Stores a list of Objective-C type parameters for a parameterized class or a category/extension thereo...
Definition: DeclObjC.h:636
The enumerator value.
Definition: Sema.h:6912
Writes an AST file containing the contents of a translation unit.
Definition: ASTWriter.h:103
SourceManager & getSourceManager() const
Definition: Sema.h:1290
After substituting deduced template arguments, an element of a dependent parameter type did not match...
Definition: Sema.h:7270
This represents &#39;#pragma omp declare mapper ...&#39; directive.
Definition: DeclOpenMP.h:217
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation tokens are not useful in isolation - they are low level value objects created/interpre...
Definition: Stmt.cpp:251
TranslationUnitKind TUKind
The kind of translation unit we are processing.
Definition: Sema.h:1159
ExpressionEvaluationContext
Describes how the expressions currently being parsed are evaluated at run-time, if at all...
Definition: Sema.h:966
StringLiteral - This represents a string literal expression, e.g.
Definition: Expr.h:1681
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
Definition: Expr.h:2516
Represents a complete lambda introducer.
Definition: DeclSpec.h:2559
We are substituting prior template arguments into a new template parameter.
Definition: Sema.h:7499
a linked list of methods with the same selector name but different signatures.
std::pair< ObjCMethodList, ObjCMethodList > GlobalMethods
Definition: Sema.h:1200
The translation unit is a complete translation unit.
Definition: LangOptions.h:364
ExprResult CorrectDelayedTyposInExpr(ExprResult ER, VarDecl *InitDecl=nullptr, llvm::function_ref< ExprResult(Expr *)> Filter=[](Expr *E) -> ExprResult { return E;})
Definition: Sema.h:3493
ExceptionSpecificationType getExceptionSpecType() const
Get the computed exception specification type.
Definition: Sema.h:5000
A using declaration.
Definition: Sema.h:6915
NonOdrUseReason
The reason why a DeclRefExpr does not constitute an odr-use.
Definition: Specifiers.h:159
Designation - Represent a full designation, which is a sequence of designators.
Definition: Designator.h:180
FPOptions FPFeatures
Definition: Sema.h:370
AssumedTemplateKind
Definition: Sema.h:6415
FullExprArg MakeFullExpr(Expr *Arg, SourceLocation CC)
Definition: Sema.h:3863
The name refers to a variable template whose specialization produces a variable.
Definition: TemplateKinds.h:33
static CXXRecordDecl * getCurrentInstantiationOf(QualType T, DeclContext *CurContext)
Find the current instantiation that associated with the given type.
A reference to a declared variable, function, enum, etc.
Definition: Expr.h:1141
result[0]
Definition: emmintrin.h:120
static SourceRange getPrintable(SourceRange R)
Definition: Sema.h:1613
Code completion occurs within the condition of an if, while, switch, or for statement.
Definition: Sema.h:10720
Lambda expression.
Definition: Sema.h:6945
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:6106
SourceManager & SourceMgr
Definition: Sema.h:377
CapturedRegionKind
The different kinds of captured statement.
Definition: CapturedStmt.h:16
BasePaths - Represents the set of paths from a derived class to one of its (direct or indirect) bases...
Contains a late templated function.
Definition: Sema.h:11313
llvm::DenseMap< CanonicalDeclPtr< FunctionDecl >, FunctionDeclAndLoc > DeviceKnownEmittedFns
An inverse call graph, mapping known-emitted functions to one of their known-emitted callers (plus th...
Definition: Sema.h:10412
ParamInfo - An array of paraminfo objects is allocated whenever a function declarator is parsed...
Definition: DeclSpec.h:1234
A push&#39;d group of PragmaAttributeEntries.
Definition: Sema.h:557
static int getPrintable(int I)
Definition: Sema.h:1602
class clang::Sema::DelayedDiagnostics DelayedDiagnostics
This structure contains most locations needed for by an OMPVarListClause.
Definition: OpenMPClause.h:169
PragmaStack< unsigned > PackStack
Definition: Sema.h:511
A collection of diagnostics which were delayed.
An instance of this class represents the declaration of a property member.
Definition: DeclCXX.h:4059
#define true
Definition: stdbool.h:16
A wrapper class around a pointer that always points to its canonical declaration. ...
Definition: Redeclarable.h:347
A trivial tuple used to represent a source range.
ASTContext & Context
Definition: Sema.h:374
IncompatibleObjCQualifiedId - The assignment is between a qualified id type and something else (that ...
Definition: Sema.h:9934
This represents a decl that may have a name.
Definition: Decl.h:248
QualType NSStringPointer
Pointer to NSString type (NSString *).
Definition: Sema.h:930
FullExprArg MakeFullDiscardedValueExpr(Expr *Arg)
Definition: Sema.h:3867
Represents C++ using-directive.
Definition: DeclCXX.h:3052
The template argument was deduced via template argument deduction.
Definition: Sema.h:6697
SourceLocation CurrentPragmaLocation
Definition: Sema.h:515
Look up of an operator name (e.g., operator+) for use with operator overloading.
Definition: Sema.h:3236
Describes an entity that is being initialized.
static QualType getPrintable(QualType T)
Definition: Sema.h:1612
ComparisonCategoryType
An enumeration representing the different comparison categories types.
The global module fragment, between &#39;module;&#39; and a module-declaration.
Definition: Sema.h:1390
ExprResult release()
Definition: Sema.h:3840
NamedDecl * Previous
Definition: Sema.h:1804
The type of an arbitrary declaration.
Definition: Sema.h:6897
AssignmentAction
Definition: Sema.h:2703
ParsedAttributes - A collection of parsed attributes.
Definition: ParsedAttr.h:906
SourceLocation ColonLoc
Location of &#39;:&#39;.
Definition: OpenMPClause.h:107
SmallVector< Slot, 2 > Stack
Definition: Sema.h:491
brief A function argument from which we performed template argument
Definition: Sema.h:7310
CopyElisionSemanticsKind
Definition: Sema.h:4017
This represents &#39;#pragma omp threadprivate ...&#39; directive.
Definition: DeclOpenMP.h:39
RetainOwnershipKind
Definition: Sema.h:8879
ObjCCategoryImplDecl - An object of this class encapsulates a category @implementation declaration...
Definition: DeclObjC.h:2498
The explicitly-specified template arguments were not valid template arguments for the given template...
Definition: Sema.h:7282
The lookup resulted in an error.
Definition: Sema.h:3298
This class handles loading and caching of source files into memory.
void PrintContextStack()
Definition: Sema.h:7822
IncompatibleNestedPointerQualifiers - The assignment is between two nested pointer types...
Definition: Sema.h:9917
The symbol does not exist.
Definition: Sema.h:4739
Declaration of a template function.
llvm::DenseMap< const EnumDecl *, llvm::APInt > FlagBitsCache
A cache of the flags available in enumerations with the flag_bits attribute.
Definition: Sema.h:1150
Code completion occurs in a parenthesized expression, which might also be a type cast.
Definition: Sema.h:10729
void PushFunctionScope()
Enter a new function scope.
Definition: Sema.cpp:1599
NullPointerConstantKind
Enumeration used to describe the kind of Null pointer constant returned from isNullPointerConstant()...
Definition: Expr.h:704
NamedDeclSetType UnusedPrivateFields
Set containing all declared private fields that are not used.
Definition: Sema.h:619
Attr - This represents one attribute.
Definition: Attr.h:43
IdentifierInfo * Name
Definition: Sema.h:8469
CastType
Definition: SemaCast.cpp:45
llvm::DenseMap< CanonicalDeclPtr< FunctionDecl >, llvm::MapVector< CanonicalDeclPtr< FunctionDecl >, SourceLocation > > DeviceCallGraph
A partial call graph maintained during CUDA/OpenMP device code compilation to support deferred diagno...
Definition: Sema.h:10424
This an attribute introduced by #pragma clang attribute.
Definition: Sema.h:549
Represents a shadow declaration introduced into a scope by a (resolved) using declaration.
Definition: DeclCXX.h:3275
ObjCMethodDecl * DictionaryWithObjectsMethod
The declaration of the dictionaryWithObjects:forKeys:count: method.
Definition: Sema.h:948
Helper class that creates diagnostics with optional template instantiation stacks.
Definition: Sema.h:1315
Engages in a tight little dance with the lexer to efficiently preprocess tokens.
Definition: Preprocessor.h:124
The triviality of a method unaffected by "trivial_abi".
Definition: Sema.h:2451
bool hasErrorOccurred() const
Determine whether any SFINAE errors have been trapped.
Definition: Sema.h:7887
llvm::DenseMap< ParmVarDecl *, SourceLocation > UnparsedDefaultArgLocs
Definition: Sema.h:1180
A RAII object to temporarily push a declaration context.
Definition: Sema.h:768
ValueType DefaultValue
Definition: Sema.h:492
StandardConversionSequence - represents a standard conversion sequence (C++ 13.3.3.1.1).
Definition: Overload.h:229
SourceLocation CurInitSegLoc
Definition: Sema.h:543