clang  7.0.0
Sema.h
Go to the documentation of this file.
1 //===--- Sema.h - Semantic Analysis & AST Building --------------*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file defines the Sema class, which performs semantic analysis and
11 // builds ASTs.
12 //
13 //===----------------------------------------------------------------------===//
14 
15 #ifndef LLVM_CLANG_SEMA_SEMA_H
16 #define LLVM_CLANG_SEMA_SEMA_H
17 
18 #include "clang/AST/Attr.h"
19 #include "clang/AST/Availability.h"
21 #include "clang/AST/DeclTemplate.h"
23 #include "clang/AST/Expr.h"
24 #include "clang/AST/ExprCXX.h"
25 #include "clang/AST/ExprObjC.h"
27 #include "clang/AST/LocInfoType.h"
29 #include "clang/AST/NSAPI.h"
31 #include "clang/AST/StmtCXX.h"
32 #include "clang/AST/TypeLoc.h"
33 #include "clang/AST/TypeOrdering.h"
35 #include "clang/Basic/Module.h"
38 #include "clang/Basic/Specifiers.h"
40 #include "clang/Basic/TypeTraits.h"
42 #include "clang/Sema/CleanupInfo.h"
43 #include "clang/Sema/DeclSpec.h"
47 #include "clang/Sema/Ownership.h"
48 #include "clang/Sema/Scope.h"
50 #include "clang/Sema/Weak.h"
51 #include "llvm/ADT/ArrayRef.h"
52 #include "llvm/ADT/Optional.h"
53 #include "llvm/ADT/SetVector.h"
54 #include "llvm/ADT/SmallBitVector.h"
55 #include "llvm/ADT/SmallPtrSet.h"
56 #include "llvm/ADT/SmallVector.h"
57 #include "llvm/ADT/TinyPtrVector.h"
58 #include <deque>
59 #include <memory>
60 #include <string>
61 #include <vector>
62 
63 namespace llvm {
64  class APSInt;
65  template <typename ValueT> struct DenseMapInfo;
66  template <typename ValueT, typename ValueInfoT> class DenseSet;
67  class SmallBitVector;
68  struct InlineAsmIdentifierInfo;
69 }
70 
71 namespace clang {
72  class ADLResult;
73  class ASTConsumer;
74  class ASTContext;
75  class ASTMutationListener;
76  class ASTReader;
77  class ASTWriter;
78  class ArrayType;
79  class ParsedAttr;
80  class BindingDecl;
81  class BlockDecl;
82  class CapturedDecl;
83  class CXXBasePath;
84  class CXXBasePaths;
85  class CXXBindTemporaryExpr;
87  class CXXConstructorDecl;
88  class CXXConversionDecl;
89  class CXXDeleteExpr;
90  class CXXDestructorDecl;
91  class CXXFieldCollector;
92  class CXXMemberCallExpr;
93  class CXXMethodDecl;
94  class CXXScopeSpec;
95  class CXXTemporary;
96  class CXXTryStmt;
97  class CallExpr;
98  class ClassTemplateDecl;
99  class ClassTemplatePartialSpecializationDecl;
100  class ClassTemplateSpecializationDecl;
101  class VarTemplatePartialSpecializationDecl;
102  class CodeCompleteConsumer;
103  class CodeCompletionAllocator;
104  class CodeCompletionTUInfo;
105  class CodeCompletionResult;
106  class CoroutineBodyStmt;
107  class Decl;
108  class DeclAccessPair;
109  class DeclContext;
110  class DeclRefExpr;
111  class DeclaratorDecl;
112  class DeducedTemplateArgument;
113  class DependentDiagnostic;
114  class DesignatedInitExpr;
115  class Designation;
116  class EnableIfAttr;
117  class EnumConstantDecl;
118  class Expr;
119  class ExtVectorType;
120  class FormatAttr;
121  class FriendDecl;
122  class FunctionDecl;
123  class FunctionProtoType;
124  class FunctionTemplateDecl;
125  class ImplicitConversionSequence;
127  class InitListExpr;
128  class InitializationKind;
129  class InitializationSequence;
130  class InitializedEntity;
131  class IntegerLiteral;
132  class LabelStmt;
133  class LambdaExpr;
134  class LangOptions;
135  class LocalInstantiationScope;
136  class LookupResult;
137  class MacroInfo;
139  class ModuleLoader;
140  class MultiLevelTemplateArgumentList;
141  class NamedDecl;
142  class ObjCCategoryDecl;
143  class ObjCCategoryImplDecl;
144  class ObjCCompatibleAliasDecl;
145  class ObjCContainerDecl;
146  class ObjCImplDecl;
147  class ObjCImplementationDecl;
148  class ObjCInterfaceDecl;
149  class ObjCIvarDecl;
150  template <class T> class ObjCList;
151  class ObjCMessageExpr;
152  class ObjCMethodDecl;
153  class ObjCPropertyDecl;
154  class ObjCProtocolDecl;
155  class OMPThreadPrivateDecl;
156  class OMPDeclareReductionDecl;
157  class OMPDeclareSimdDecl;
158  class OMPClause;
159  struct OverloadCandidate;
160  class OverloadCandidateSet;
161  class OverloadExpr;
162  class ParenListExpr;
163  class ParmVarDecl;
164  class Preprocessor;
165  class PseudoDestructorTypeStorage;
166  class PseudoObjectExpr;
167  class QualType;
168  class StandardConversionSequence;
169  class Stmt;
170  class StringLiteral;
171  class SwitchStmt;
172  class TemplateArgument;
173  class TemplateArgumentList;
174  class TemplateArgumentLoc;
175  class TemplateDecl;
176  class TemplateInstantiationCallback;
177  class TemplateParameterList;
178  class TemplatePartialOrderingContext;
179  class TemplateTemplateParmDecl;
180  class Token;
181  class TypeAliasDecl;
182  class TypedefDecl;
183  class TypedefNameDecl;
184  class TypeLoc;
185  class TypoCorrectionConsumer;
186  class UnqualifiedId;
187  class UnresolvedLookupExpr;
188  class UnresolvedMemberExpr;
189  class UnresolvedSetImpl;
190  class UnresolvedSetIterator;
191  class UsingDecl;
192  class UsingShadowDecl;
193  class ValueDecl;
194  class VarDecl;
195  class VarTemplateSpecializationDecl;
196  class VisibilityAttr;
197  class VisibleDeclConsumer;
198  class IndirectFieldDecl;
199  struct DeductionFailureInfo;
200  class TemplateSpecCandidateSet;
201 
202 namespace sema {
203  class AccessedEntity;
204  class BlockScopeInfo;
205  class Capture;
206  class CapturedRegionScopeInfo;
207  class CapturingScopeInfo;
208  class CompoundScopeInfo;
209  class DelayedDiagnostic;
210  class DelayedDiagnosticPool;
211  class FunctionScopeInfo;
212  class LambdaScopeInfo;
213  class PossiblyUnreachableDiag;
214  class SemaPPCallbacks;
215  class TemplateDeductionInfo;
216 }
217 
218 namespace threadSafety {
219  class BeforeSet;
220  void threadSafetyCleanup(BeforeSet* Cache);
221 }
222 
223 // FIXME: No way to easily map from TemplateTypeParmTypes to
224 // TemplateTypeParmDecls, so we have this horrible PointerUnion.
225 typedef std::pair<llvm::PointerUnion<const TemplateTypeParmType*, NamedDecl*>,
227 
228 /// Describes whether we've seen any nullability information for the given
229 /// file.
231  /// The first pointer declarator (of any pointer kind) in the file that does
232  /// not have a corresponding nullability annotation.
234 
235  /// The end location for the first pointer declarator in the file. Used for
236  /// placing fix-its.
238 
239  /// Which kind of pointer declarator we saw.
240  uint8_t PointerKind;
241 
242  /// Whether we saw any type nullability annotations in the given file.
243  bool SawTypeNullability = false;
244 };
245 
246 /// A mapping from file IDs to a record of whether we've seen nullability
247 /// information in that file.
249  /// A mapping from file IDs to the nullability information for each file ID.
250  llvm::DenseMap<FileID, FileNullability> Map;
251 
252  /// A single-element cache based on the file ID.
253  struct {
256  } Cache;
257 
258 public:
260  // Check the single-element cache.
261  if (file == Cache.File)
262  return Cache.Nullability;
263 
264  // It's not in the single-element cache; flush the cache if we have one.
265  if (!Cache.File.isInvalid()) {
266  Map[Cache.File] = Cache.Nullability;
267  }
268 
269  // Pull this entry into the cache.
270  Cache.File = file;
271  Cache.Nullability = Map[file];
272  return Cache.Nullability;
273  }
274 };
275 
276 /// Sema - This implements semantic analysis and AST building for C.
277 class Sema {
278  Sema(const Sema &) = delete;
279  void operator=(const Sema &) = delete;
280 
281  ///Source of additional semantic information.
282  ExternalSemaSource *ExternalSource;
283 
284  ///Whether Sema has generated a multiplexer and has to delete it.
285  bool isMultiplexExternalSource;
286 
287  static bool mightHaveNonExternalLinkage(const DeclaratorDecl *FD);
288 
289  bool isVisibleSlow(const NamedDecl *D);
290 
291  /// Determine whether two declarations should be linked together, given that
292  /// the old declaration might not be visible and the new declaration might
293  /// not have external linkage.
294  bool shouldLinkPossiblyHiddenDecl(const NamedDecl *Old,
295  const NamedDecl *New) {
296  if (isVisible(Old))
297  return true;
298  // See comment in below overload for why it's safe to compute the linkage
299  // of the new declaration here.
300  if (New->isExternallyDeclarable()) {
301  assert(Old->isExternallyDeclarable() &&
302  "should not have found a non-externally-declarable previous decl");
303  return true;
304  }
305  return false;
306  }
307  bool shouldLinkPossiblyHiddenDecl(LookupResult &Old, const NamedDecl *New);
308 
309 public:
313 
316 
323 
324  /// Flag indicating whether or not to collect detailed statistics.
326 
327  /// Code-completion consumer.
329 
330  /// CurContext - This is the current declaration context of parsing.
332 
333  /// Generally null except when we temporarily switch decl contexts,
334  /// like in \see ActOnObjCTemporaryExitContainerContext.
336 
337  /// VAListTagName - The declaration name corresponding to __va_list_tag.
338  /// This is used as part of a hack to omit that class from ADL results.
340 
341  bool MSStructPragmaOn; // True when \#pragma ms_struct on
342 
343  /// Controls member pointer representation format under the MS ABI.
346 
347  /// Stack of active SEH __finally scopes. Can be empty.
349 
350  /// Source location for newly created implicit MSInheritanceAttrs
352 
353  /// pragma clang section kind
355  PCSK_Invalid = 0,
356  PCSK_BSS = 1,
357  PCSK_Data = 2,
358  PCSK_Rodata = 3,
359  PCSK_Text = 4
360  };
361 
363  PCSA_Set = 0,
364  PCSA_Clear = 1
365  };
366 
368  std::string SectionName;
369  bool Valid = false;
371 
372  void Act(SourceLocation PragmaLocation,
374  StringLiteral* Name);
375  };
376 
381 
383  PSK_Reset = 0x0, // #pragma ()
384  PSK_Set = 0x1, // #pragma (value)
385  PSK_Push = 0x2, // #pragma (push[, id])
386  PSK_Pop = 0x4, // #pragma (pop[, id])
387  PSK_Show = 0x8, // #pragma (show) -- only for "pack"!
388  PSK_Push_Set = PSK_Push | PSK_Set, // #pragma (push[, id], value)
389  PSK_Pop_Set = PSK_Pop | PSK_Set, // #pragma (pop[, id], value)
390  };
391 
392  template<typename ValueType>
393  struct PragmaStack {
394  struct Slot {
395  llvm::StringRef StackSlotLabel;
396  ValueType Value;
399  Slot(llvm::StringRef StackSlotLabel, ValueType Value,
400  SourceLocation PragmaLocation, SourceLocation PragmaPushLocation)
401  : StackSlotLabel(StackSlotLabel), Value(Value),
402  PragmaLocation(PragmaLocation),
403  PragmaPushLocation(PragmaPushLocation) {}
404  };
405  void Act(SourceLocation PragmaLocation,
406  PragmaMsStackAction Action,
407  llvm::StringRef StackSlotLabel,
408  ValueType Value);
409 
410  // MSVC seems to add artificial slots to #pragma stacks on entering a C++
411  // method body to restore the stacks on exit, so it works like this:
412  //
413  // struct S {
414  // #pragma <name>(push, InternalPragmaSlot, <current_pragma_value>)
415  // void Method {}
416  // #pragma <name>(pop, InternalPragmaSlot)
417  // };
418  //
419  // It works even with #pragma vtordisp, although MSVC doesn't support
420  // #pragma vtordisp(push [, id], n)
421  // syntax.
422  //
423  // Push / pop a named sentinel slot.
424  void SentinelAction(PragmaMsStackAction Action, StringRef Label) {
425  assert((Action == PSK_Push || Action == PSK_Pop) &&
426  "Can only push / pop #pragma stack sentinels!");
427  Act(CurrentPragmaLocation, Action, Label, CurrentValue);
428  }
429 
430  // Constructors.
431  explicit PragmaStack(const ValueType &Default)
432  : DefaultValue(Default), CurrentValue(Default) {}
433 
434  bool hasValue() const { return CurrentValue != DefaultValue; }
435 
437  ValueType DefaultValue; // Value used for PSK_Reset action.
438  ValueType CurrentValue;
440  };
441  // FIXME: We should serialize / deserialize these if they occur in a PCH (but
442  // we shouldn't do so if they're in a module).
443 
444  /// Whether to insert vtordisps prior to virtual bases in the Microsoft
445  /// C++ ABI. Possible values are 0, 1, and 2, which mean:
446  ///
447  /// 0: Suppress all vtordisps
448  /// 1: Insert vtordisps in the presence of vbase overrides and non-trivial
449  /// structors
450  /// 2: Always insert vtordisps to support RTTI on partially constructed
451  /// objects
453  // #pragma pack.
454  // Sentinel to represent when the stack is set to mac68k alignment.
455  static const unsigned kMac68kAlignmentSentinel = ~0U;
457  // The current #pragma pack values and locations at each #include.
459  unsigned CurrentValue;
461  bool HasNonDefaultValue, ShouldWarnOnInclude;
462  };
464  // Segment #pragmas.
469 
470  // RAII object to push / pop sentinel slots for all MS #pragma stacks.
471  // Actions should be performed only if we enter / exit a C++ method body.
473  public:
474  PragmaStackSentinelRAII(Sema &S, StringRef SlotLabel, bool ShouldAct);
476 
477  private:
478  Sema &S;
479  StringRef SlotLabel;
480  bool ShouldAct;
481  };
482 
483  /// A mapping that describes the nullability we've seen in each header file.
485 
486  /// Last section used with #pragma init_seg.
489 
490  /// VisContext - Manages the stack for \#pragma GCC visibility.
491  void *VisContext; // Really a "PragmaVisStack*"
492 
493  /// This represents the stack of attributes that were pushed by
494  /// \#pragma clang attribute.
499  bool IsUsed;
500  };
502 
503  /// The declaration that is currently receiving an attribute from the
504  /// #pragma attribute stack.
506 
507  /// This represents the last location of a "#pragma clang optimize off"
508  /// directive if such a directive has not been closed by an "on" yet. If
509  /// optimizations are currently "on", this is set to an invalid location.
511 
512  /// Flag indicating if Sema is building a recovery call expression.
513  ///
514  /// This flag is used to avoid building recovery call expressions
515  /// if Sema is already doing so, which would cause infinite recursions.
517 
518  /// Used to control the generation of ExprWithCleanups.
520 
521  /// ExprCleanupObjects - This is the stack of objects requiring
522  /// cleanup that are created by the current full expression. The
523  /// element type here is ExprWithCleanups::Object.
525 
526  /// Store a list of either DeclRefExprs or MemberExprs
527  /// that contain a reference to a variable (constant) that may or may not
528  /// be odr-used in this Expr, and we won't know until all lvalue-to-rvalue
529  /// and discarded value conversions have been applied to all subexpressions
530  /// of the enclosing full expression. This is cleared at the end of each
531  /// full expression.
532  llvm::SmallPtrSet<Expr*, 2> MaybeODRUseExprs;
533 
534  std::unique_ptr<sema::FunctionScopeInfo> PreallocatedFunctionScope;
535 
536  /// Stack containing information about each of the nested
537  /// function, block, and method scopes that are currently active.
539 
541  &ExternalSemaSource::ReadExtVectorDecls, 2, 2>
543 
544  /// ExtVectorDecls - This is a list all the extended vector types. This allows
545  /// us to associate a raw vector type with one of the ext_vector type names.
546  /// This is only necessary for issuing pretty diagnostics.
548 
549  /// FieldCollector - Collects CXXFieldDecls during parsing of C++ classes.
550  std::unique_ptr<CXXFieldCollector> FieldCollector;
551 
553 
554  /// Set containing all declared private fields that are not used.
555  NamedDeclSetType UnusedPrivateFields;
556 
557  /// Set containing all typedefs that are likely unused.
560 
561  /// Delete-expressions to be analyzed at the end of translation unit
562  ///
563  /// This list contains class members, and locations of delete-expressions
564  /// that could not be proven as to whether they mismatch with new-expression
565  /// used in initializer of the field.
566  typedef std::pair<SourceLocation, bool> DeleteExprLoc;
568  llvm::MapVector<FieldDecl *, DeleteLocs> DeleteExprs;
569 
570  typedef llvm::SmallPtrSet<const CXXRecordDecl*, 8> RecordDeclSetTy;
571 
572  /// PureVirtualClassDiagSet - a set of class declarations which we have
573  /// emitted a list of pure virtual functions. Used to prevent emitting the
574  /// same list more than once.
575  std::unique_ptr<RecordDeclSetTy> PureVirtualClassDiagSet;
576 
577  /// ParsingInitForAutoVars - a set of declarations with auto types for which
578  /// we are currently parsing the initializer.
579  llvm::SmallPtrSet<const Decl*, 4> ParsingInitForAutoVars;
580 
581  /// Look for a locally scoped extern "C" declaration by the given name.
582  NamedDecl *findLocallyScopedExternCDecl(DeclarationName Name);
583 
584  typedef LazyVector<VarDecl *, ExternalSemaSource,
585  &ExternalSemaSource::ReadTentativeDefinitions, 2, 2>
587 
588  /// All the tentative definitions encountered in the TU.
590 
591  typedef LazyVector<const DeclaratorDecl *, ExternalSemaSource,
592  &ExternalSemaSource::ReadUnusedFileScopedDecls, 2, 2>
594 
595  /// The set of file scoped decls seen so far that have not been used
596  /// and must warn if not used. Only contains the first declaration.
598 
599  typedef LazyVector<CXXConstructorDecl *, ExternalSemaSource,
600  &ExternalSemaSource::ReadDelegatingConstructors, 2, 2>
602 
603  /// All the delegating constructors seen so far in the file, used for
604  /// cycle detection at the end of the TU.
606 
607  /// All the overriding functions seen during a class definition
608  /// that had their exception spec checks delayed, plus the overridden
609  /// function.
612 
613  /// All the members seen during a class definition which were both
614  /// explicitly defaulted and had explicitly-specified exception
615  /// specifications, along with the function type containing their
616  /// user-specified exception specification. Those exception specifications
617  /// were overridden with the default specifications, but we still need to
618  /// check whether they are compatible with the default specification, and
619  /// we can't do that until the nesting set of class definitions is complete.
622 
623  typedef llvm::MapVector<const FunctionDecl *,
624  std::unique_ptr<LateParsedTemplate>>
627 
628  /// Callback to the parser to parse templated functions when needed.
629  typedef void LateTemplateParserCB(void *P, LateParsedTemplate &LPT);
630  typedef void LateTemplateParserCleanupCB(void *P);
631  LateTemplateParserCB *LateTemplateParser;
632  LateTemplateParserCleanupCB *LateTemplateParserCleanup;
634 
635  void SetLateTemplateParser(LateTemplateParserCB *LTP,
636  LateTemplateParserCleanupCB *LTPCleanup,
637  void *P) {
638  LateTemplateParser = LTP;
639  LateTemplateParserCleanup = LTPCleanup;
640  OpaqueParser = P;
641  }
642 
643  class DelayedDiagnostics;
644 
646  sema::DelayedDiagnosticPool *SavedPool;
648  };
651 
652  /// A class which encapsulates the logic for delaying diagnostics
653  /// during parsing and other processing.
655  /// The current pool of diagnostics into which delayed
656  /// diagnostics should go.
658 
659  public:
660  DelayedDiagnostics() : CurPool(nullptr) {}
661 
662  /// Adds a delayed diagnostic.
663  void add(const sema::DelayedDiagnostic &diag); // in DelayedDiagnostic.h
664 
665  /// Determines whether diagnostics should be delayed.
666  bool shouldDelayDiagnostics() { return CurPool != nullptr; }
667 
668  /// Returns the current delayed-diagnostics pool.
670  return CurPool;
671  }
672 
673  /// Enter a new scope. Access and deprecation diagnostics will be
674  /// collected in this pool.
677  state.SavedPool = CurPool;
678  CurPool = &pool;
679  return state;
680  }
681 
682  /// Leave a delayed-diagnostic state that was previously pushed.
683  /// Do not emit any of the diagnostics. This is performed as part
684  /// of the bookkeeping of popping a pool "properly".
686  CurPool = state.SavedPool;
687  }
688 
689  /// Enter a new scope where access and deprecation diagnostics are
690  /// not delayed.
693  state.SavedPool = CurPool;
694  CurPool = nullptr;
695  return state;
696  }
697 
698  /// Undo a previous pushUndelayed().
700  assert(CurPool == nullptr);
701  CurPool = state.SavedPool;
702  }
704 
705  /// A RAII object to temporarily push a declaration context.
706  class ContextRAII {
707  private:
708  Sema &S;
709  DeclContext *SavedContext;
710  ProcessingContextState SavedContextState;
711  QualType SavedCXXThisTypeOverride;
712 
713  public:
714  ContextRAII(Sema &S, DeclContext *ContextToPush, bool NewThisContext = true)
715  : S(S), SavedContext(S.CurContext),
716  SavedContextState(S.DelayedDiagnostics.pushUndelayed()),
717  SavedCXXThisTypeOverride(S.CXXThisTypeOverride)
718  {
719  assert(ContextToPush && "pushing null context");
720  S.CurContext = ContextToPush;
721  if (NewThisContext)
723  }
724 
725  void pop() {
726  if (!SavedContext) return;
727  S.CurContext = SavedContext;
728  S.DelayedDiagnostics.popUndelayed(SavedContextState);
729  S.CXXThisTypeOverride = SavedCXXThisTypeOverride;
730  SavedContext = nullptr;
731  }
732 
734  pop();
735  }
736  };
737 
738  /// RAII object to handle the state changes required to synthesize
739  /// a function body.
741  Sema &S;
742  Sema::ContextRAII SavedContext;
743  bool PushedCodeSynthesisContext = false;
744 
745  public:
747  : S(S), SavedContext(S, DC) {
748  S.PushFunctionScope();
750  Sema::ExpressionEvaluationContext::PotentiallyEvaluated);
751  if (auto *FD = dyn_cast<FunctionDecl>(DC))
752  FD->setWillHaveBody(true);
753  else
754  assert(isa<ObjCMethodDecl>(DC));
755  }
756 
758  assert(!PushedCodeSynthesisContext);
759 
761  Ctx.Kind = Sema::CodeSynthesisContext::DefiningSynthesizedFunction;
762  Ctx.PointOfInstantiation = UseLoc;
763  Ctx.Entity = cast<Decl>(S.CurContext);
765 
766  PushedCodeSynthesisContext = true;
767  }
768 
770  if (PushedCodeSynthesisContext)
772  if (auto *FD = dyn_cast<FunctionDecl>(S.CurContext))
773  FD->setWillHaveBody(false);
776  }
777  };
778 
779  /// WeakUndeclaredIdentifiers - Identifiers contained in
780  /// \#pragma weak before declared. rare. may alias another
781  /// identifier, declared or undeclared
782  llvm::MapVector<IdentifierInfo *, WeakInfo> WeakUndeclaredIdentifiers;
783 
784  /// ExtnameUndeclaredIdentifiers - Identifiers contained in
785  /// \#pragma redefine_extname before declared. Used in Solaris system headers
786  /// to define functions that occur in multiple standards to call the version
787  /// in the currently selected standard.
788  llvm::DenseMap<IdentifierInfo*,AsmLabelAttr*> ExtnameUndeclaredIdentifiers;
789 
790 
791  /// Load weak undeclared identifiers from the external source.
792  void LoadExternalWeakUndeclaredIdentifiers();
793 
794  /// WeakTopLevelDecl - Translation-unit scoped declarations generated by
795  /// \#pragma weak during processing of other Decls.
796  /// I couldn't figure out a clean way to generate these in-line, so
797  /// we store them here and handle separately -- which is a hack.
798  /// It would be best to refactor this.
800 
802 
803  /// Translation Unit Scope - useful to Objective-C actions that need
804  /// to lookup file scope declarations in the "ordinary" C decl namespace.
805  /// For example, user-defined classes, built-in "id" type, etc.
807 
808  /// The C++ "std" namespace, where the standard library resides.
810 
811  /// The C++ "std::bad_alloc" class, which is defined by the C++
812  /// standard library.
814 
815  /// The C++ "std::align_val_t" enum class, which is defined by the C++
816  /// standard library.
818 
819  /// The C++ "std::experimental" namespace, where the experimental parts
820  /// of the standard library resides.
822 
823  /// The C++ "std::initializer_list" template, which is defined in
824  /// <initializer_list>.
826 
827  /// The C++ "std::coroutine_traits" template, which is defined in
828  /// <coroutine_traits>
830 
831  /// The C++ "type_info" declaration, which is defined in <typeinfo>.
833 
834  /// The MSVC "_GUID" struct, which is defined in MSVC header files.
836 
837  /// Caches identifiers/selectors for NSFoundation APIs.
838  std::unique_ptr<NSAPI> NSAPIObj;
839 
840  /// The declaration of the Objective-C NSNumber class.
842 
843  /// The declaration of the Objective-C NSValue class.
845 
846  /// Pointer to NSNumber type (NSNumber *).
848 
849  /// Pointer to NSValue type (NSValue *).
851 
852  /// The Objective-C NSNumber methods used to create NSNumber literals.
853  ObjCMethodDecl *NSNumberLiteralMethods[NSAPI::NumNSNumberLiteralMethods];
854 
855  /// The declaration of the Objective-C NSString class.
857 
858  /// Pointer to NSString type (NSString *).
860 
861  /// The declaration of the stringWithUTF8String: method.
863 
864  /// The declaration of the valueWithBytes:objCType: method.
866 
867  /// The declaration of the Objective-C NSArray class.
869 
870  /// The declaration of the arrayWithObjects:count: method.
872 
873  /// The declaration of the Objective-C NSDictionary class.
875 
876  /// The declaration of the dictionaryWithObjects:forKeys:count: method.
878 
879  /// id<NSCopying> type.
881 
882  /// will hold 'respondsToSelector:'
884 
885  /// A flag to remember whether the implicit forms of operator new and delete
886  /// have been declared.
888 
889  /// A flag to indicate that we're in a context that permits abstract
890  /// references to fields. This is really a
892 
893  /// Describes how the expressions currently being parsed are
894  /// evaluated at run-time, if at all.
896  /// The current expression and its subexpressions occur within an
897  /// unevaluated operand (C++11 [expr]p7), such as the subexpression of
898  /// \c sizeof, where the type of the expression may be significant but
899  /// no code will be generated to evaluate the value of the expression at
900  /// run time.
901  Unevaluated,
902 
903  /// The current expression occurs within a braced-init-list within
904  /// an unevaluated operand. This is mostly like a regular unevaluated
905  /// context, except that we still instantiate constexpr functions that are
906  /// referenced here so that we can perform narrowing checks correctly.
907  UnevaluatedList,
908 
909  /// The current expression occurs within a discarded statement.
910  /// This behaves largely similarly to an unevaluated operand in preventing
911  /// definitions from being required, but not in other ways.
912  DiscardedStatement,
913 
914  /// The current expression occurs within an unevaluated
915  /// operand that unconditionally permits abstract references to
916  /// fields, such as a SIZE operator in MS-style inline assembly.
917  UnevaluatedAbstract,
918 
919  /// The current context is "potentially evaluated" in C++11 terms,
920  /// but the expression is evaluated at compile-time (like the values of
921  /// cases in a switch statement).
922  ConstantEvaluated,
923 
924  /// The current expression is potentially evaluated at run time,
925  /// which means that code may be generated to evaluate the value of the
926  /// expression at run time.
927  PotentiallyEvaluated,
928 
929  /// The current expression is potentially evaluated, but any
930  /// declarations referenced inside that expression are only used if
931  /// in fact the current expression is used.
932  ///
933  /// This value is used when parsing default function arguments, for which
934  /// we would like to provide diagnostics (e.g., passing non-POD arguments
935  /// through varargs) but do not want to mark declarations as "referenced"
936  /// until the default argument is used.
937  PotentiallyEvaluatedIfUsed
938  };
939 
940  /// Data structure used to record current or nested
941  /// expression evaluation contexts.
943  /// The expression evaluation context.
945 
946  /// Whether the enclosing context needed a cleanup.
948 
949  /// Whether we are in a decltype expression.
951 
952  /// The number of active cleanup objects when we entered
953  /// this expression evaluation context.
955 
956  /// The number of typos encountered during this expression evaluation
957  /// context (i.e. the number of TypoExprs created).
958  unsigned NumTypos;
959 
960  llvm::SmallPtrSet<Expr*, 2> SavedMaybeODRUseExprs;
961 
962  /// The lambdas that are present within this context, if it
963  /// is indeed an unevaluated context.
965 
966  /// The declaration that provides context for lambda expressions
967  /// and block literals if the normal declaration context does not
968  /// suffice, e.g., in a default function argument.
970 
971  /// The context information used to mangle lambda expressions
972  /// and block literals within this context.
973  ///
974  /// This mangling information is allocated lazily, since most contexts
975  /// do not have lambda expressions or block literals.
976  std::unique_ptr<MangleNumberingContext> MangleNumbering;
977 
978  /// If we are processing a decltype type, a set of call expressions
979  /// for which we have deferred checking the completeness of the return type.
981 
982  /// If we are processing a decltype type, a set of temporary binding
983  /// expressions for which we have deferred checking the destructor.
985 
986  /// \brief Describes whether we are in an expression constext which we have
987  /// to handle differently.
989  EK_Decltype, EK_TemplateArgument, EK_Other
990  } ExprContext;
991 
993  unsigned NumCleanupObjects,
994  CleanupInfo ParentCleanup,
995  Decl *ManglingContextDecl,
996  ExpressionKind ExprContext)
997  : Context(Context), ParentCleanup(ParentCleanup),
998  NumCleanupObjects(NumCleanupObjects), NumTypos(0),
999  ManglingContextDecl(ManglingContextDecl), MangleNumbering(),
1000  ExprContext(ExprContext) {}
1001 
1002  /// Retrieve the mangling numbering context, used to consistently
1003  /// number constructs like lambdas for mangling.
1004  MangleNumberingContext &getMangleNumberingContext(ASTContext &Ctx);
1005 
1006  bool isUnevaluated() const {
1007  return Context == ExpressionEvaluationContext::Unevaluated ||
1008  Context == ExpressionEvaluationContext::UnevaluatedAbstract ||
1009  Context == ExpressionEvaluationContext::UnevaluatedList;
1010  }
1011  bool isConstantEvaluated() const {
1012  return Context == ExpressionEvaluationContext::ConstantEvaluated;
1013  }
1014  };
1015 
1016  /// A stack of expression evaluation contexts.
1018 
1019  /// Compute the mangling number context for a lambda expression or
1020  /// block literal.
1021  ///
1022  /// \param DC - The DeclContext containing the lambda expression or
1023  /// block literal.
1024  /// \param[out] ManglingContextDecl - Returns the ManglingContextDecl
1025  /// associated with the context, if relevant.
1026  MangleNumberingContext *getCurrentMangleNumberContext(
1027  const DeclContext *DC,
1028  Decl *&ManglingContextDecl);
1029 
1030 
1031  /// SpecialMemberOverloadResult - The overloading result for a special member
1032  /// function.
1033  ///
1034  /// This is basically a wrapper around PointerIntPair. The lowest bits of the
1035  /// integer are used to determine whether overload resolution succeeded.
1037  public:
1038  enum Kind {
1041  Success
1042  };
1043 
1044  private:
1045  llvm::PointerIntPair<CXXMethodDecl*, 2> Pair;
1046 
1047  public:
1050  : Pair(MD, MD->isDeleted() ? NoMemberOrDeleted : Success) {}
1051 
1052  CXXMethodDecl *getMethod() const { return Pair.getPointer(); }
1053  void setMethod(CXXMethodDecl *MD) { Pair.setPointer(MD); }
1054 
1055  Kind getKind() const { return static_cast<Kind>(Pair.getInt()); }
1056  void setKind(Kind K) { Pair.setInt(K); }
1057  };
1058 
1060  : public llvm::FastFoldingSetNode,
1062  public:
1063  SpecialMemberOverloadResultEntry(const llvm::FoldingSetNodeID &ID)
1064  : FastFoldingSetNode(ID)
1065  {}
1066  };
1067 
1068  /// A cache of special member function overload resolution results
1069  /// for C++ records.
1070  llvm::FoldingSet<SpecialMemberOverloadResultEntry> SpecialMemberCache;
1071 
1072  /// A cache of the flags available in enumerations with the flag_bits
1073  /// attribute.
1074  mutable llvm::DenseMap<const EnumDecl*, llvm::APInt> FlagBitsCache;
1075 
1076  /// The kind of translation unit we are processing.
1077  ///
1078  /// When we're processing a complete translation unit, Sema will perform
1079  /// end-of-translation-unit semantic tasks (such as creating
1080  /// initializers for tentative definitions in C) once parsing has
1081  /// completed. Modules and precompiled headers perform different kinds of
1082  /// checks.
1084 
1085  llvm::BumpPtrAllocator BumpAlloc;
1086 
1087  /// The number of SFINAE diagnostics that have been trapped.
1089 
1090  typedef llvm::DenseMap<ParmVarDecl *, llvm::TinyPtrVector<ParmVarDecl *>>
1092 
1093  /// A mapping from parameters with unparsed default arguments to the
1094  /// set of instantiations of each parameter.
1095  ///
1096  /// This mapping is a temporary data structure used when parsing
1097  /// nested class templates or nested classes of class templates,
1098  /// where we might end up instantiating an inner class before the
1099  /// default arguments of its methods have been parsed.
1101 
1102  // Contains the locations of the beginning of unparsed default
1103  // argument locations.
1104  llvm::DenseMap<ParmVarDecl *, SourceLocation> UnparsedDefaultArgLocs;
1105 
1106  /// UndefinedInternals - all the used, undefined objects which require a
1107  /// definition in this translation unit.
1108  llvm::MapVector<NamedDecl *, SourceLocation> UndefinedButUsed;
1109 
1110  /// Determine if VD, which must be a variable or function, is an external
1111  /// symbol that nonetheless can't be referenced from outside this translation
1112  /// unit because its type has no linkage and it's not extern "C".
1113  bool isExternalWithNoLinkageType(ValueDecl *VD);
1114 
1115  /// Obtain a sorted list of functions that are undefined but ODR-used.
1116  void getUndefinedButUsed(
1117  SmallVectorImpl<std::pair<NamedDecl *, SourceLocation> > &Undefined);
1118 
1119  /// Retrieves list of suspicious delete-expressions that will be checked at
1120  /// the end of translation unit.
1121  const llvm::MapVector<FieldDecl *, DeleteLocs> &
1122  getMismatchingDeleteExpressions() const;
1123 
1124  typedef std::pair<ObjCMethodList, ObjCMethodList> GlobalMethods;
1125  typedef llvm::DenseMap<Selector, GlobalMethods> GlobalMethodPool;
1126 
1127  /// Method Pool - allows efficient lookup when typechecking messages to "id".
1128  /// We need to maintain a list, since selectors can have differing signatures
1129  /// across classes. In Cocoa, this happens to be extremely uncommon (only 1%
1130  /// of selectors are "overloaded").
1131  /// At the head of the list it is recorded whether there were 0, 1, or >= 2
1132  /// methods inside categories with a particular selector.
1133  GlobalMethodPool MethodPool;
1134 
1135  /// Method selectors used in a \@selector expression. Used for implementation
1136  /// of -Wselector.
1137  llvm::MapVector<Selector, SourceLocation> ReferencedSelectors;
1138 
1139  /// Kinds of C++ special members.
1147  CXXInvalid
1148  };
1149 
1150  typedef llvm::PointerIntPair<CXXRecordDecl *, 3, CXXSpecialMember>
1152 
1153  /// The C++ special members which we are currently in the process of
1154  /// declaring. If this process recursively triggers the declaration of the
1155  /// same special member, we should act as if it is not yet declared.
1156  llvm::SmallPtrSet<SpecialMemberDecl, 4> SpecialMembersBeingDeclared;
1157 
1158  /// The function definitions which were renamed as part of typo-correction
1159  /// to match their respective declarations. We want to keep track of them
1160  /// to ensure that we don't emit a "redefinition" error if we encounter a
1161  /// correctly named definition after the renamed definition.
1162  llvm::SmallPtrSet<const NamedDecl *, 4> TypoCorrectedFunctionDefinitions;
1163 
1164  /// Stack of types that correspond to the parameter entities that are
1165  /// currently being copy-initialized. Can be empty.
1167 
1168  void ReadMethodPool(Selector Sel);
1169  void updateOutOfDateSelector(Selector Sel);
1170 
1171  /// Private Helper predicate to check for 'self'.
1172  bool isSelfExpr(Expr *RExpr);
1173  bool isSelfExpr(Expr *RExpr, const ObjCMethodDecl *Method);
1174 
1175  /// Cause the active diagnostic on the DiagosticsEngine to be
1176  /// emitted. This is closely coupled to the SemaDiagnosticBuilder class and
1177  /// should not be used elsewhere.
1178  void EmitCurrentDiagnostic(unsigned DiagID);
1179 
1180  /// Records and restores the FP_CONTRACT state on entry/exit of compound
1181  /// statements.
1183  public:
1184  FPContractStateRAII(Sema &S) : S(S), OldFPFeaturesState(S.FPFeatures) {}
1185  ~FPContractStateRAII() { S.FPFeatures = OldFPFeaturesState; }
1186 
1187  private:
1188  Sema& S;
1189  FPOptions OldFPFeaturesState;
1190  };
1191 
1192  void addImplicitTypedef(StringRef Name, QualType T);
1193 
1194 public:
1195  Sema(Preprocessor &pp, ASTContext &ctxt, ASTConsumer &consumer,
1197  CodeCompleteConsumer *CompletionConsumer = nullptr);
1198  ~Sema();
1199 
1200  /// Perform initialization that occurs after the parser has been
1201  /// initialized but before it parses anything.
1202  void Initialize();
1203 
1204  const LangOptions &getLangOpts() const { return LangOpts; }
1205  OpenCLOptions &getOpenCLOptions() { return OpenCLFeatures; }
1206  FPOptions &getFPOptions() { return FPFeatures; }
1207 
1208  DiagnosticsEngine &getDiagnostics() const { return Diags; }
1209  SourceManager &getSourceManager() const { return SourceMgr; }
1210  Preprocessor &getPreprocessor() const { return PP; }
1211  ASTContext &getASTContext() const { return Context; }
1212  ASTConsumer &getASTConsumer() const { return Consumer; }
1213  ASTMutationListener *getASTMutationListener() const;
1214  ExternalSemaSource* getExternalSource() const { return ExternalSource; }
1215 
1216  ///Registers an external source. If an external source already exists,
1217  /// creates a multiplex external source and appends to it.
1218  ///
1219  ///\param[in] E - A non-null external sema source.
1220  ///
1221  void addExternalSource(ExternalSemaSource *E);
1222 
1223  void PrintStats() const;
1224 
1225  /// Helper class that creates diagnostics with optional
1226  /// template instantiation stacks.
1227  ///
1228  /// This class provides a wrapper around the basic DiagnosticBuilder
1229  /// class that emits diagnostics. SemaDiagnosticBuilder is
1230  /// responsible for emitting the diagnostic (as DiagnosticBuilder
1231  /// does) and, if the diagnostic comes from inside a template
1232  /// instantiation, printing the template instantiation stack as
1233  /// well.
1235  Sema &SemaRef;
1236  unsigned DiagID;
1237 
1238  public:
1239  SemaDiagnosticBuilder(DiagnosticBuilder &DB, Sema &SemaRef, unsigned DiagID)
1240  : DiagnosticBuilder(DB), SemaRef(SemaRef), DiagID(DiagID) { }
1241 
1242  // This is a cunning lie. DiagnosticBuilder actually performs move
1243  // construction in its copy constructor (but due to varied uses, it's not
1244  // possible to conveniently express this as actual move construction). So
1245  // the default copy ctor here is fine, because the base class disables the
1246  // source anyway, so the user-defined ~SemaDiagnosticBuilder is a safe no-op
1247  // in that case anwyay.
1248  SemaDiagnosticBuilder(const SemaDiagnosticBuilder&) = default;
1249 
1251  // If we aren't active, there is nothing to do.
1252  if (!isActive()) return;
1253 
1254  // Otherwise, we need to emit the diagnostic. First flush the underlying
1255  // DiagnosticBuilder data, and clear the diagnostic builder itself so it
1256  // won't emit the diagnostic in its own destructor.
1257  //
1258  // This seems wasteful, in that as written the DiagnosticBuilder dtor will
1259  // do its own needless checks to see if the diagnostic needs to be
1260  // emitted. However, because we take care to ensure that the builder
1261  // objects never escape, a sufficiently smart compiler will be able to
1262  // eliminate that code.
1263  FlushCounts();
1264  Clear();
1265 
1266  // Dispatch to Sema to emit the diagnostic.
1267  SemaRef.EmitCurrentDiagnostic(DiagID);
1268  }
1269 
1270  /// Teach operator<< to produce an object of the correct type.
1271  template<typename T>
1273  const SemaDiagnosticBuilder &Diag, const T &Value) {
1274  const DiagnosticBuilder &BaseDiag = Diag;
1275  BaseDiag << Value;
1276  return Diag;
1277  }
1278  };
1279 
1280  /// Emit a diagnostic.
1282  DiagnosticBuilder DB = Diags.Report(Loc, DiagID);
1283  return SemaDiagnosticBuilder(DB, *this, DiagID);
1284  }
1285 
1286  /// Emit a partial diagnostic.
1288 
1289  /// Build a partial diagnostic.
1290  PartialDiagnostic PDiag(unsigned DiagID = 0); // in SemaInternal.h
1291 
1292  bool findMacroSpelling(SourceLocation &loc, StringRef name);
1293 
1294  /// Get a string to suggest for zero-initialization of a type.
1295  std::string
1296  getFixItZeroInitializerForType(QualType T, SourceLocation Loc) const;
1297  std::string getFixItZeroLiteralForType(QualType T, SourceLocation Loc) const;
1298 
1299  /// Calls \c Lexer::getLocForEndOfToken()
1300  SourceLocation getLocForEndOfToken(SourceLocation Loc, unsigned Offset = 0);
1301 
1302  /// Retrieve the module loader associated with the preprocessor.
1303  ModuleLoader &getModuleLoader() const;
1304 
1305  void emitAndClearUnusedLocalTypedefWarnings();
1306 
1307  void ActOnStartOfTranslationUnit();
1308  void ActOnEndOfTranslationUnit();
1309 
1310  void CheckDelegatingCtorCycles();
1311 
1312  Scope *getScopeForContext(DeclContext *Ctx);
1313 
1314  void PushFunctionScope();
1315  void PushBlockScope(Scope *BlockScope, BlockDecl *Block);
1316  sema::LambdaScopeInfo *PushLambdaScope();
1317 
1318  /// This is used to inform Sema what the current TemplateParameterDepth
1319  /// is during Parsing. Currently it is used to pass on the depth
1320  /// when parsing generic lambda 'auto' parameters.
1321  void RecordParsingTemplateParameterDepth(unsigned Depth);
1322 
1323  void PushCapturedRegionScope(Scope *RegionScope, CapturedDecl *CD,
1324  RecordDecl *RD,
1325  CapturedRegionKind K);
1326  void
1327  PopFunctionScopeInfo(const sema::AnalysisBasedWarnings::Policy *WP = nullptr,
1328  const Decl *D = nullptr,
1329  const BlockExpr *blkExpr = nullptr);
1330 
1332  return FunctionScopes.empty() ? nullptr : FunctionScopes.back();
1333  }
1334 
1335  sema::FunctionScopeInfo *getEnclosingFunction() const;
1336 
1337  void setFunctionHasBranchIntoScope();
1338  void setFunctionHasBranchProtectedScope();
1339  void setFunctionHasIndirectGoto();
1340 
1341  void PushCompoundScope(bool IsStmtExpr);
1342  void PopCompoundScope();
1343 
1344  sema::CompoundScopeInfo &getCurCompoundScope() const;
1345 
1346  bool hasAnyUnrecoverableErrorsInThisFunction() const;
1347 
1348  /// Retrieve the current block, if any.
1349  sema::BlockScopeInfo *getCurBlock();
1350 
1351  /// Retrieve the current lambda scope info, if any.
1352  /// \param IgnoreNonLambdaCapturingScope true if should find the top-most
1353  /// lambda scope info ignoring all inner capturing scopes that are not
1354  /// lambda scopes.
1356  getCurLambda(bool IgnoreNonLambdaCapturingScope = false);
1357 
1358  /// Retrieve the current generic lambda info, if any.
1359  sema::LambdaScopeInfo *getCurGenericLambda();
1360 
1361  /// Retrieve the current captured region, if any.
1362  sema::CapturedRegionScopeInfo *getCurCapturedRegion();
1363 
1364  /// WeakTopLevelDeclDecls - access to \#pragma weak-generated Decls
1365  SmallVectorImpl<Decl *> &WeakTopLevelDecls() { return WeakTopLevelDecl; }
1366 
1367  void ActOnComment(SourceRange Comment);
1368 
1369  //===--------------------------------------------------------------------===//
1370  // Type Analysis / Processing: SemaType.cpp.
1371  //
1372 
1373  QualType BuildQualifiedType(QualType T, SourceLocation Loc, Qualifiers Qs,
1374  const DeclSpec *DS = nullptr);
1375  QualType BuildQualifiedType(QualType T, SourceLocation Loc, unsigned CVRA,
1376  const DeclSpec *DS = nullptr);
1377  QualType BuildPointerType(QualType T,
1378  SourceLocation Loc, DeclarationName Entity);
1379  QualType BuildReferenceType(QualType T, bool LValueRef,
1380  SourceLocation Loc, DeclarationName Entity);
1381  QualType BuildArrayType(QualType T, ArrayType::ArraySizeModifier ASM,
1382  Expr *ArraySize, unsigned Quals,
1383  SourceRange Brackets, DeclarationName Entity);
1384  QualType BuildVectorType(QualType T, Expr *VecSize, SourceLocation AttrLoc);
1385  QualType BuildExtVectorType(QualType T, Expr *ArraySize,
1386  SourceLocation AttrLoc);
1387  QualType BuildAddressSpaceAttr(QualType &T, Expr *AddrSpace,
1388  SourceLocation AttrLoc);
1389 
1390  bool CheckFunctionReturnType(QualType T, SourceLocation Loc);
1391 
1392  /// Build a function type.
1393  ///
1394  /// This routine checks the function type according to C++ rules and
1395  /// under the assumption that the result type and parameter types have
1396  /// just been instantiated from a template. It therefore duplicates
1397  /// some of the behavior of GetTypeForDeclarator, but in a much
1398  /// simpler form that is only suitable for this narrow use case.
1399  ///
1400  /// \param T The return type of the function.
1401  ///
1402  /// \param ParamTypes The parameter types of the function. This array
1403  /// will be modified to account for adjustments to the types of the
1404  /// function parameters.
1405  ///
1406  /// \param Loc The location of the entity whose type involves this
1407  /// function type or, if there is no such entity, the location of the
1408  /// type that will have function type.
1409  ///
1410  /// \param Entity The name of the entity that involves the function
1411  /// type, if known.
1412  ///
1413  /// \param EPI Extra information about the function type. Usually this will
1414  /// be taken from an existing function with the same prototype.
1415  ///
1416  /// \returns A suitable function type, if there are no errors. The
1417  /// unqualified type will always be a FunctionProtoType.
1418  /// Otherwise, returns a NULL type.
1419  QualType BuildFunctionType(QualType T,
1420  MutableArrayRef<QualType> ParamTypes,
1421  SourceLocation Loc, DeclarationName Entity,
1422  const FunctionProtoType::ExtProtoInfo &EPI);
1423 
1424  QualType BuildMemberPointerType(QualType T, QualType Class,
1425  SourceLocation Loc,
1426  DeclarationName Entity);
1427  QualType BuildBlockPointerType(QualType T,
1428  SourceLocation Loc, DeclarationName Entity);
1429  QualType BuildParenType(QualType T);
1430  QualType BuildAtomicType(QualType T, SourceLocation Loc);
1431  QualType BuildReadPipeType(QualType T,
1432  SourceLocation Loc);
1433  QualType BuildWritePipeType(QualType T,
1434  SourceLocation Loc);
1435 
1436  TypeSourceInfo *GetTypeForDeclarator(Declarator &D, Scope *S);
1437  TypeSourceInfo *GetTypeForDeclaratorCast(Declarator &D, QualType FromTy);
1438  TypeSourceInfo *GetTypeSourceInfoForDeclarator(Declarator &D, QualType T,
1439  TypeSourceInfo *ReturnTypeInfo);
1440 
1441  /// Package the given type and TSI into a ParsedType.
1442  ParsedType CreateParsedType(QualType T, TypeSourceInfo *TInfo);
1443  DeclarationNameInfo GetNameForDeclarator(Declarator &D);
1444  DeclarationNameInfo GetNameFromUnqualifiedId(const UnqualifiedId &Name);
1445  static QualType GetTypeFromParser(ParsedType Ty,
1446  TypeSourceInfo **TInfo = nullptr);
1447  CanThrowResult canThrow(const Expr *E);
1448  const FunctionProtoType *ResolveExceptionSpec(SourceLocation Loc,
1449  const FunctionProtoType *FPT);
1450  void UpdateExceptionSpec(FunctionDecl *FD,
1452  bool CheckSpecifiedExceptionType(QualType &T, SourceRange Range);
1453  bool CheckDistantExceptionSpec(QualType T);
1454  bool CheckEquivalentExceptionSpec(FunctionDecl *Old, FunctionDecl *New);
1455  bool CheckEquivalentExceptionSpec(
1456  const FunctionProtoType *Old, SourceLocation OldLoc,
1457  const FunctionProtoType *New, SourceLocation NewLoc);
1458  bool CheckEquivalentExceptionSpec(
1459  const PartialDiagnostic &DiagID, const PartialDiagnostic & NoteID,
1460  const FunctionProtoType *Old, SourceLocation OldLoc,
1461  const FunctionProtoType *New, SourceLocation NewLoc);
1462  bool handlerCanCatch(QualType HandlerType, QualType ExceptionType);
1463  bool CheckExceptionSpecSubset(const PartialDiagnostic &DiagID,
1464  const PartialDiagnostic &NestedDiagID,
1465  const PartialDiagnostic &NoteID,
1466  const FunctionProtoType *Superset,
1467  SourceLocation SuperLoc,
1468  const FunctionProtoType *Subset,
1469  SourceLocation SubLoc);
1470  bool CheckParamExceptionSpec(const PartialDiagnostic &NestedDiagID,
1471  const PartialDiagnostic &NoteID,
1472  const FunctionProtoType *Target,
1473  SourceLocation TargetLoc,
1474  const FunctionProtoType *Source,
1475  SourceLocation SourceLoc);
1476 
1477  TypeResult ActOnTypeName(Scope *S, Declarator &D);
1478 
1479  /// The parser has parsed the context-sensitive type 'instancetype'
1480  /// in an Objective-C message declaration. Return the appropriate type.
1481  ParsedType ActOnObjCInstanceType(SourceLocation Loc);
1482 
1483  /// Abstract class used to diagnose incomplete types.
1484  struct TypeDiagnoser {
1486 
1487  virtual void diagnose(Sema &S, SourceLocation Loc, QualType T) = 0;
1488  virtual ~TypeDiagnoser() {}
1489  };
1490 
1491  static int getPrintable(int I) { return I; }
1492  static unsigned getPrintable(unsigned I) { return I; }
1493  static bool getPrintable(bool B) { return B; }
1494  static const char * getPrintable(const char *S) { return S; }
1495  static StringRef getPrintable(StringRef S) { return S; }
1496  static const std::string &getPrintable(const std::string &S) { return S; }
1497  static const IdentifierInfo *getPrintable(const IdentifierInfo *II) {
1498  return II;
1499  }
1501  static QualType getPrintable(QualType T) { return T; }
1502  static SourceRange getPrintable(SourceRange R) { return R; }
1503  static SourceRange getPrintable(SourceLocation L) { return L; }
1504  static SourceRange getPrintable(const Expr *E) { return E->getSourceRange(); }
1505  static SourceRange getPrintable(TypeLoc TL) { return TL.getSourceRange();}
1506 
1507  template <typename... Ts> class BoundTypeDiagnoser : public TypeDiagnoser {
1508  unsigned DiagID;
1509  std::tuple<const Ts &...> Args;
1510 
1511  template <std::size_t... Is>
1512  void emit(const SemaDiagnosticBuilder &DB,
1513  llvm::index_sequence<Is...>) const {
1514  // Apply all tuple elements to the builder in order.
1515  bool Dummy[] = {false, (DB << getPrintable(std::get<Is>(Args)))...};
1516  (void)Dummy;
1517  }
1518 
1519  public:
1520  BoundTypeDiagnoser(unsigned DiagID, const Ts &...Args)
1521  : TypeDiagnoser(), DiagID(DiagID), Args(Args...) {
1522  assert(DiagID != 0 && "no diagnostic for type diagnoser");
1523  }
1524 
1525  void diagnose(Sema &S, SourceLocation Loc, QualType T) override {
1526  const SemaDiagnosticBuilder &DB = S.Diag(Loc, DiagID);
1527  emit(DB, llvm::index_sequence_for<Ts...>());
1528  DB << T;
1529  }
1530  };
1531 
1532 private:
1533  bool RequireCompleteTypeImpl(SourceLocation Loc, QualType T,
1534  TypeDiagnoser *Diagnoser);
1535 
1536  struct ModuleScope {
1537  clang::Module *Module = nullptr;
1538  bool ModuleInterface = false;
1539  VisibleModuleSet OuterVisibleModules;
1540  };
1541  /// The modules we're currently parsing.
1543 
1544  /// Get the module whose scope we are currently within.
1545  Module *getCurrentModule() const {
1546  return ModuleScopes.empty() ? nullptr : ModuleScopes.back().Module;
1547  }
1548 
1549  VisibleModuleSet VisibleModules;
1550 
1551 public:
1552  /// Get the module owning an entity.
1553  Module *getOwningModule(Decl *Entity) { return Entity->getOwningModule(); }
1554 
1555  /// Make a merged definition of an existing hidden definition \p ND
1556  /// visible at the specified location.
1557  void makeMergedDefinitionVisible(NamedDecl *ND);
1558 
1559  bool isModuleVisible(const Module *M) { return VisibleModules.isVisible(M); }
1560 
1561  /// Determine whether a declaration is visible to name lookup.
1562  bool isVisible(const NamedDecl *D) {
1563  return !D->isHidden() || isVisibleSlow(D);
1564  }
1565 
1566  /// Determine whether any declaration of an entity is visible.
1567  bool
1569  llvm::SmallVectorImpl<Module *> *Modules = nullptr) {
1570  return isVisible(D) || hasVisibleDeclarationSlow(D, Modules);
1571  }
1572  bool hasVisibleDeclarationSlow(const NamedDecl *D,
1574 
1575  bool hasVisibleMergedDefinition(NamedDecl *Def);
1576  bool hasMergedDefinitionInCurrentModule(NamedDecl *Def);
1577 
1578  /// Determine if \p D and \p Suggested have a structurally compatible
1579  /// layout as described in C11 6.2.7/1.
1580  bool hasStructuralCompatLayout(Decl *D, Decl *Suggested);
1581 
1582  /// Determine if \p D has a visible definition. If not, suggest a declaration
1583  /// that should be made visible to expose the definition.
1584  bool hasVisibleDefinition(NamedDecl *D, NamedDecl **Suggested,
1585  bool OnlyNeedComplete = false);
1587  NamedDecl *Hidden;
1588  return hasVisibleDefinition(const_cast<NamedDecl*>(D), &Hidden);
1589  }
1590 
1591  /// Determine if the template parameter \p D has a visible default argument.
1592  bool
1594  llvm::SmallVectorImpl<Module *> *Modules = nullptr);
1595 
1596  /// Determine if there is a visible declaration of \p D that is an explicit
1597  /// specialization declaration for a specialization of a template. (For a
1598  /// member specialization, use hasVisibleMemberSpecialization.)
1599  bool hasVisibleExplicitSpecialization(
1600  const NamedDecl *D, llvm::SmallVectorImpl<Module *> *Modules = nullptr);
1601 
1602  /// Determine if there is a visible declaration of \p D that is a member
1603  /// specialization declaration (as opposed to an instantiated declaration).
1604  bool hasVisibleMemberSpecialization(
1605  const NamedDecl *D, llvm::SmallVectorImpl<Module *> *Modules = nullptr);
1606 
1607  /// Determine if \p A and \p B are equivalent internal linkage declarations
1608  /// from different modules, and thus an ambiguity error can be downgraded to
1609  /// an extension warning.
1610  bool isEquivalentInternalLinkageDeclaration(const NamedDecl *A,
1611  const NamedDecl *B);
1612  void diagnoseEquivalentInternalLinkageDeclarations(
1613  SourceLocation Loc, const NamedDecl *D,
1615 
1617  return !RequireCompleteTypeImpl(Loc, T, nullptr);
1618  }
1619  bool RequireCompleteType(SourceLocation Loc, QualType T,
1620  TypeDiagnoser &Diagnoser);
1621  bool RequireCompleteType(SourceLocation Loc, QualType T,
1622  unsigned DiagID);
1623 
1624  template <typename... Ts>
1625  bool RequireCompleteType(SourceLocation Loc, QualType T, unsigned DiagID,
1626  const Ts &...Args) {
1627  BoundTypeDiagnoser<Ts...> Diagnoser(DiagID, Args...);
1628  return RequireCompleteType(Loc, T, Diagnoser);
1629  }
1630 
1631  void completeExprArrayBound(Expr *E);
1632  bool RequireCompleteExprType(Expr *E, TypeDiagnoser &Diagnoser);
1633  bool RequireCompleteExprType(Expr *E, unsigned DiagID);
1634 
1635  template <typename... Ts>
1636  bool RequireCompleteExprType(Expr *E, unsigned DiagID, const Ts &...Args) {
1637  BoundTypeDiagnoser<Ts...> Diagnoser(DiagID, Args...);
1638  return RequireCompleteExprType(E, Diagnoser);
1639  }
1640 
1641  bool RequireLiteralType(SourceLocation Loc, QualType T,
1642  TypeDiagnoser &Diagnoser);
1643  bool RequireLiteralType(SourceLocation Loc, QualType T, unsigned DiagID);
1644 
1645  template <typename... Ts>
1646  bool RequireLiteralType(SourceLocation Loc, QualType T, unsigned DiagID,
1647  const Ts &...Args) {
1648  BoundTypeDiagnoser<Ts...> Diagnoser(DiagID, Args...);
1649  return RequireLiteralType(Loc, T, Diagnoser);
1650  }
1651 
1652  QualType getElaboratedType(ElaboratedTypeKeyword Keyword,
1653  const CXXScopeSpec &SS, QualType T,
1654  TagDecl *OwnedTagDecl = nullptr);
1655 
1656  QualType BuildTypeofExprType(Expr *E, SourceLocation Loc);
1657  /// If AsUnevaluated is false, E is treated as though it were an evaluated
1658  /// context, such as when building a type for decltype(auto).
1659  QualType BuildDecltypeType(Expr *E, SourceLocation Loc,
1660  bool AsUnevaluated = true);
1661  QualType BuildUnaryTransformType(QualType BaseType,
1663  SourceLocation Loc);
1664 
1665  //===--------------------------------------------------------------------===//
1666  // Symbol table / Decl tracking callbacks: SemaDecl.cpp.
1667  //
1668 
1669  struct SkipBodyInfo {
1671  : ShouldSkip(false), CheckSameAsPrevious(false), Previous(nullptr),
1672  New(nullptr) {}
1677  };
1678 
1679  DeclGroupPtrTy ConvertDeclToDeclGroup(Decl *Ptr, Decl *OwnedType = nullptr);
1680 
1681  void DiagnoseUseOfUnimplementedSelectors();
1682 
1683  bool isSimpleTypeSpecifier(tok::TokenKind Kind) const;
1684 
1686  Scope *S, CXXScopeSpec *SS = nullptr,
1687  bool isClassName = false, bool HasTrailingDot = false,
1688  ParsedType ObjectType = nullptr,
1689  bool IsCtorOrDtorName = false,
1690  bool WantNontrivialTypeSourceInfo = false,
1691  bool IsClassTemplateDeductionContext = true,
1692  IdentifierInfo **CorrectedII = nullptr);
1693  TypeSpecifierType isTagName(IdentifierInfo &II, Scope *S);
1694  bool isMicrosoftMissingTypename(const CXXScopeSpec *SS, Scope *S);
1695  void DiagnoseUnknownTypeName(IdentifierInfo *&II,
1696  SourceLocation IILoc,
1697  Scope *S,
1698  CXXScopeSpec *SS,
1699  ParsedType &SuggestedType,
1700  bool IsTemplateName = false);
1701 
1702  /// Attempt to behave like MSVC in situations where lookup of an unqualified
1703  /// type name has failed in a dependent context. In these situations, we
1704  /// automatically form a DependentTypeName that will retry lookup in a related
1705  /// scope during instantiation.
1706  ParsedType ActOnMSVCUnknownTypeName(const IdentifierInfo &II,
1707  SourceLocation NameLoc,
1708  bool IsTemplateTypeArg);
1709 
1710  /// Describes the result of the name lookup and resolution performed
1711  /// by \c ClassifyName().
1721  NC_FunctionTemplate
1722  };
1723 
1726  ExprResult Expr;
1727  TemplateName Template;
1728  ParsedType Type;
1729 
1730  explicit NameClassification(NameClassificationKind Kind) : Kind(Kind) {}
1731 
1732  public:
1733  NameClassification(ExprResult Expr) : Kind(NC_Expression), Expr(Expr) {}
1734 
1735  NameClassification(ParsedType Type) : Kind(NC_Type), Type(Type) {}
1736 
1737  NameClassification(const IdentifierInfo *Keyword) : Kind(NC_Keyword) {}
1738 
1740  return NameClassification(NC_Error);
1741  }
1742 
1744  return NameClassification(NC_Unknown);
1745  }
1746 
1748  return NameClassification(NC_NestedNameSpecifier);
1749  }
1750 
1752  NameClassification Result(NC_TypeTemplate);
1753  Result.Template = Name;
1754  return Result;
1755  }
1756 
1758  NameClassification Result(NC_VarTemplate);
1759  Result.Template = Name;
1760  return Result;
1761  }
1762 
1764  NameClassification Result(NC_FunctionTemplate);
1765  Result.Template = Name;
1766  return Result;
1767  }
1768 
1770 
1772  assert(Kind == NC_Type);
1773  return Type;
1774  }
1775 
1777  assert(Kind == NC_Expression);
1778  return Expr;
1779  }
1780 
1782  assert(Kind == NC_TypeTemplate || Kind == NC_FunctionTemplate ||
1783  Kind == NC_VarTemplate);
1784  return Template;
1785  }
1786 
1788  switch (Kind) {
1789  case NC_TypeTemplate:
1790  return TNK_Type_template;
1791  case NC_FunctionTemplate:
1792  return TNK_Function_template;
1793  case NC_VarTemplate:
1794  return TNK_Var_template;
1795  default:
1796  llvm_unreachable("unsupported name classification.");
1797  }
1798  }
1799  };
1800 
1801  /// Perform name lookup on the given name, classifying it based on
1802  /// the results of name lookup and the following token.
1803  ///
1804  /// This routine is used by the parser to resolve identifiers and help direct
1805  /// parsing. When the identifier cannot be found, this routine will attempt
1806  /// to correct the typo and classify based on the resulting name.
1807  ///
1808  /// \param S The scope in which we're performing name lookup.
1809  ///
1810  /// \param SS The nested-name-specifier that precedes the name.
1811  ///
1812  /// \param Name The identifier. If typo correction finds an alternative name,
1813  /// this pointer parameter will be updated accordingly.
1814  ///
1815  /// \param NameLoc The location of the identifier.
1816  ///
1817  /// \param NextToken The token following the identifier. Used to help
1818  /// disambiguate the name.
1819  ///
1820  /// \param IsAddressOfOperand True if this name is the operand of a unary
1821  /// address of ('&') expression, assuming it is classified as an
1822  /// expression.
1823  ///
1824  /// \param CCC The correction callback, if typo correction is desired.
1826  ClassifyName(Scope *S, CXXScopeSpec &SS, IdentifierInfo *&Name,
1827  SourceLocation NameLoc, const Token &NextToken,
1828  bool IsAddressOfOperand,
1829  std::unique_ptr<CorrectionCandidateCallback> CCC = nullptr);
1830 
1831  /// Describes the detailed kind of a template name. Used in diagnostics.
1833  ClassTemplate,
1834  FunctionTemplate,
1835  VarTemplate,
1836  AliasTemplate,
1837  TemplateTemplateParam,
1838  DependentTemplate
1839  };
1841  getTemplateNameKindForDiagnostics(TemplateName Name);
1842 
1843  /// Determine whether it's plausible that E was intended to be a
1844  /// template-name.
1845  bool mightBeIntendedToBeTemplateName(ExprResult E, bool &Dependent) {
1846  if (!getLangOpts().CPlusPlus || E.isInvalid())
1847  return false;
1848  Dependent = false;
1849  if (auto *DRE = dyn_cast<DeclRefExpr>(E.get()))
1850  return !DRE->hasExplicitTemplateArgs();
1851  if (auto *ME = dyn_cast<MemberExpr>(E.get()))
1852  return !ME->hasExplicitTemplateArgs();
1853  Dependent = true;
1854  if (auto *DSDRE = dyn_cast<DependentScopeDeclRefExpr>(E.get()))
1855  return !DSDRE->hasExplicitTemplateArgs();
1856  if (auto *DSME = dyn_cast<CXXDependentScopeMemberExpr>(E.get()))
1857  return !DSME->hasExplicitTemplateArgs();
1858  // Any additional cases recognized here should also be handled by
1859  // diagnoseExprIntendedAsTemplateName.
1860  return false;
1861  }
1862  void diagnoseExprIntendedAsTemplateName(Scope *S, ExprResult TemplateName,
1865 
1866  Decl *ActOnDeclarator(Scope *S, Declarator &D);
1867 
1868  NamedDecl *HandleDeclarator(Scope *S, Declarator &D,
1869  MultiTemplateParamsArg TemplateParameterLists);
1870  void RegisterLocallyScopedExternCDecl(NamedDecl *ND, Scope *S);
1871  bool DiagnoseClassNameShadow(DeclContext *DC, DeclarationNameInfo Info);
1872  bool diagnoseQualifiedDeclaration(CXXScopeSpec &SS, DeclContext *DC,
1873  DeclarationName Name, SourceLocation Loc,
1874  bool IsTemplateId);
1875  void
1876  diagnoseIgnoredQualifiers(unsigned DiagID, unsigned Quals,
1877  SourceLocation FallbackLoc,
1878  SourceLocation ConstQualLoc = SourceLocation(),
1879  SourceLocation VolatileQualLoc = SourceLocation(),
1880  SourceLocation RestrictQualLoc = SourceLocation(),
1881  SourceLocation AtomicQualLoc = SourceLocation(),
1882  SourceLocation UnalignedQualLoc = SourceLocation());
1883 
1884  static bool adjustContextForLocalExternDecl(DeclContext *&DC);
1885  void DiagnoseFunctionSpecifiers(const DeclSpec &DS);
1886  NamedDecl *getShadowedDeclaration(const TypedefNameDecl *D,
1887  const LookupResult &R);
1888  NamedDecl *getShadowedDeclaration(const VarDecl *D, const LookupResult &R);
1889  void CheckShadow(NamedDecl *D, NamedDecl *ShadowedDecl,
1890  const LookupResult &R);
1891  void CheckShadow(Scope *S, VarDecl *D);
1892 
1893  /// Warn if 'E', which is an expression that is about to be modified, refers
1894  /// to a shadowing declaration.
1895  void CheckShadowingDeclModification(Expr *E, SourceLocation Loc);
1896 
1897  void DiagnoseShadowingLambdaDecls(const sema::LambdaScopeInfo *LSI);
1898 
1899 private:
1900  /// Map of current shadowing declarations to shadowed declarations. Warn if
1901  /// it looks like the user is trying to modify the shadowing declaration.
1902  llvm::DenseMap<const NamedDecl *, const NamedDecl *> ShadowingDecls;
1903 
1904 public:
1905  void CheckCastAlign(Expr *Op, QualType T, SourceRange TRange);
1906  void handleTagNumbering(const TagDecl *Tag, Scope *TagScope);
1907  void setTagNameForLinkagePurposes(TagDecl *TagFromDeclSpec,
1908  TypedefNameDecl *NewTD);
1909  void CheckTypedefForVariablyModifiedType(Scope *S, TypedefNameDecl *D);
1910  NamedDecl* ActOnTypedefDeclarator(Scope* S, Declarator& D, DeclContext* DC,
1911  TypeSourceInfo *TInfo,
1913  NamedDecl* ActOnTypedefNameDecl(Scope* S, DeclContext* DC, TypedefNameDecl *D,
1914  LookupResult &Previous, bool &Redeclaration);
1915  NamedDecl *ActOnVariableDeclarator(Scope *S, Declarator &D, DeclContext *DC,
1916  TypeSourceInfo *TInfo,
1917  LookupResult &Previous,
1918  MultiTemplateParamsArg TemplateParamLists,
1919  bool &AddToScope,
1920  ArrayRef<BindingDecl *> Bindings = None);
1921  NamedDecl *
1922  ActOnDecompositionDeclarator(Scope *S, Declarator &D,
1923  MultiTemplateParamsArg TemplateParamLists);
1924  // Returns true if the variable declaration is a redeclaration
1925  bool CheckVariableDeclaration(VarDecl *NewVD, LookupResult &Previous);
1926  void CheckVariableDeclarationType(VarDecl *NewVD);
1927  bool DeduceVariableDeclarationType(VarDecl *VDecl, bool DirectInit,
1928  Expr *Init);
1929  void CheckCompleteVariableDeclaration(VarDecl *VD);
1930  void CheckCompleteDecompositionDeclaration(DecompositionDecl *DD);
1931  void MaybeSuggestAddingStaticToDecl(const FunctionDecl *D);
1932 
1933  NamedDecl* ActOnFunctionDeclarator(Scope* S, Declarator& D, DeclContext* DC,
1934  TypeSourceInfo *TInfo,
1935  LookupResult &Previous,
1936  MultiTemplateParamsArg TemplateParamLists,
1937  bool &AddToScope);
1938  bool AddOverriddenMethods(CXXRecordDecl *DC, CXXMethodDecl *MD);
1939 
1940  bool CheckConstexprFunctionDecl(const FunctionDecl *FD);
1941  bool CheckConstexprFunctionBody(const FunctionDecl *FD, Stmt *Body);
1942 
1943  void DiagnoseHiddenVirtualMethods(CXXMethodDecl *MD);
1944  void FindHiddenVirtualMethods(CXXMethodDecl *MD,
1945  SmallVectorImpl<CXXMethodDecl*> &OverloadedMethods);
1946  void NoteHiddenVirtualMethods(CXXMethodDecl *MD,
1947  SmallVectorImpl<CXXMethodDecl*> &OverloadedMethods);
1948  // Returns true if the function declaration is a redeclaration
1949  bool CheckFunctionDeclaration(Scope *S,
1950  FunctionDecl *NewFD, LookupResult &Previous,
1951  bool IsMemberSpecialization);
1952  bool shouldLinkDependentDeclWithPrevious(Decl *D, Decl *OldDecl);
1953  void CheckMain(FunctionDecl *FD, const DeclSpec &D);
1954  void CheckMSVCRTEntryPoint(FunctionDecl *FD);
1955  Attr *getImplicitCodeSegOrSectionAttrForFunction(const FunctionDecl *FD, bool IsDefinition);
1956  Decl *ActOnParamDeclarator(Scope *S, Declarator &D);
1957  ParmVarDecl *BuildParmVarDeclForTypedef(DeclContext *DC,
1958  SourceLocation Loc,
1959  QualType T);
1960  ParmVarDecl *CheckParameter(DeclContext *DC, SourceLocation StartLoc,
1961  SourceLocation NameLoc, IdentifierInfo *Name,
1962  QualType T, TypeSourceInfo *TSInfo,
1963  StorageClass SC);
1964  void ActOnParamDefaultArgument(Decl *param,
1965  SourceLocation EqualLoc,
1966  Expr *defarg);
1967  void ActOnParamUnparsedDefaultArgument(Decl *param,
1968  SourceLocation EqualLoc,
1969  SourceLocation ArgLoc);
1970  void ActOnParamDefaultArgumentError(Decl *param, SourceLocation EqualLoc);
1971  bool SetParamDefaultArgument(ParmVarDecl *Param, Expr *DefaultArg,
1972  SourceLocation EqualLoc);
1973 
1974  void AddInitializerToDecl(Decl *dcl, Expr *init, bool DirectInit);
1975  void ActOnUninitializedDecl(Decl *dcl);
1976  void ActOnInitializerError(Decl *Dcl);
1977 
1978  void ActOnPureSpecifier(Decl *D, SourceLocation PureSpecLoc);
1979  void ActOnCXXForRangeDecl(Decl *D);
1980  StmtResult ActOnCXXForRangeIdentifier(Scope *S, SourceLocation IdentLoc,
1981  IdentifierInfo *Ident,
1982  ParsedAttributes &Attrs,
1983  SourceLocation AttrEnd);
1984  void SetDeclDeleted(Decl *dcl, SourceLocation DelLoc);
1985  void SetDeclDefaulted(Decl *dcl, SourceLocation DefaultLoc);
1986  void FinalizeDeclaration(Decl *D);
1987  DeclGroupPtrTy FinalizeDeclaratorGroup(Scope *S, const DeclSpec &DS,
1988  ArrayRef<Decl *> Group);
1989  DeclGroupPtrTy BuildDeclaratorGroup(MutableArrayRef<Decl *> Group);
1990 
1991  /// Should be called on all declarations that might have attached
1992  /// documentation comments.
1993  void ActOnDocumentableDecl(Decl *D);
1994  void ActOnDocumentableDecls(ArrayRef<Decl *> Group);
1995 
1996  void ActOnFinishKNRParamDeclarations(Scope *S, Declarator &D,
1997  SourceLocation LocAfterDecls);
1998  void CheckForFunctionRedefinition(
1999  FunctionDecl *FD, const FunctionDecl *EffectiveDefinition = nullptr,
2000  SkipBodyInfo *SkipBody = nullptr);
2001  Decl *ActOnStartOfFunctionDef(Scope *S, Declarator &D,
2002  MultiTemplateParamsArg TemplateParamLists,
2003  SkipBodyInfo *SkipBody = nullptr);
2004  Decl *ActOnStartOfFunctionDef(Scope *S, Decl *D,
2005  SkipBodyInfo *SkipBody = nullptr);
2006  void ActOnStartOfObjCMethodDef(Scope *S, Decl *D);
2008  return D && isa<ObjCMethodDecl>(D);
2009  }
2010 
2011  /// Determine whether we can delay parsing the body of a function or
2012  /// function template until it is used, assuming we don't care about emitting
2013  /// code for that function.
2014  ///
2015  /// This will be \c false if we may need the body of the function in the
2016  /// middle of parsing an expression (where it's impractical to switch to
2017  /// parsing a different function), for instance, if it's constexpr in C++11
2018  /// or has an 'auto' return type in C++14. These cases are essentially bugs.
2019  bool canDelayFunctionBody(const Declarator &D);
2020 
2021  /// Determine whether we can skip parsing the body of a function
2022  /// definition, assuming we don't care about analyzing its body or emitting
2023  /// code for that function.
2024  ///
2025  /// This will be \c false only if we may need the body of the function in
2026  /// order to parse the rest of the program (for instance, if it is
2027  /// \c constexpr in C++11 or has an 'auto' return type in C++14).
2028  bool canSkipFunctionBody(Decl *D);
2029 
2030  void computeNRVO(Stmt *Body, sema::FunctionScopeInfo *Scope);
2031  Decl *ActOnFinishFunctionBody(Decl *Decl, Stmt *Body);
2032  Decl *ActOnFinishFunctionBody(Decl *Decl, Stmt *Body, bool IsInstantiation);
2033  Decl *ActOnSkippedFunctionBody(Decl *Decl);
2034  void ActOnFinishInlineFunctionDef(FunctionDecl *D);
2035 
2036  /// ActOnFinishDelayedAttribute - Invoked when we have finished parsing an
2037  /// attribute for which parsing is delayed.
2038  void ActOnFinishDelayedAttribute(Scope *S, Decl *D, ParsedAttributes &Attrs);
2039 
2040  /// Diagnose any unused parameters in the given sequence of
2041  /// ParmVarDecl pointers.
2042  void DiagnoseUnusedParameters(ArrayRef<ParmVarDecl *> Parameters);
2043 
2044  /// Diagnose whether the size of parameters or return value of a
2045  /// function or obj-c method definition is pass-by-value and larger than a
2046  /// specified threshold.
2047  void
2048  DiagnoseSizeOfParametersAndReturnValue(ArrayRef<ParmVarDecl *> Parameters,
2049  QualType ReturnTy, NamedDecl *D);
2050 
2051  void DiagnoseInvalidJumps(Stmt *Body);
2052  Decl *ActOnFileScopeAsmDecl(Expr *expr,
2053  SourceLocation AsmLoc,
2054  SourceLocation RParenLoc);
2055 
2056  /// Handle a C++11 empty-declaration and attribute-declaration.
2057  Decl *ActOnEmptyDeclaration(Scope *S, const ParsedAttributesView &AttrList,
2058  SourceLocation SemiLoc);
2059 
2060  enum class ModuleDeclKind {
2061  Interface, ///< 'export module X;'
2062  Implementation, ///< 'module X;'
2063  Partition, ///< 'module partition X;'
2064  };
2065 
2066  /// The parser has processed a module-declaration that begins the definition
2067  /// of a module interface or implementation.
2068  DeclGroupPtrTy ActOnModuleDecl(SourceLocation StartLoc,
2069  SourceLocation ModuleLoc, ModuleDeclKind MDK,
2070  ModuleIdPath Path);
2071 
2072  /// The parser has processed a module import declaration.
2073  ///
2074  /// \param AtLoc The location of the '@' symbol, if any.
2075  ///
2076  /// \param ImportLoc The location of the 'import' keyword.
2077  ///
2078  /// \param Path The module access path.
2079  DeclResult ActOnModuleImport(SourceLocation AtLoc, SourceLocation ImportLoc,
2080  ModuleIdPath Path);
2081 
2082  /// The parser has processed a module import translated from a
2083  /// #include or similar preprocessing directive.
2084  void ActOnModuleInclude(SourceLocation DirectiveLoc, Module *Mod);
2085  void BuildModuleInclude(SourceLocation DirectiveLoc, Module *Mod);
2086 
2087  /// The parsed has entered a submodule.
2088  void ActOnModuleBegin(SourceLocation DirectiveLoc, Module *Mod);
2089  /// The parser has left a submodule.
2090  void ActOnModuleEnd(SourceLocation DirectiveLoc, Module *Mod);
2091 
2092  /// Create an implicit import of the given module at the given
2093  /// source location, for error recovery, if possible.
2094  ///
2095  /// This routine is typically used when an entity found by name lookup
2096  /// is actually hidden within a module that we know about but the user
2097  /// has forgotten to import.
2098  void createImplicitModuleImportForErrorRecovery(SourceLocation Loc,
2099  Module *Mod);
2100 
2101  /// Kinds of missing import. Note, the values of these enumerators correspond
2102  /// to %select values in diagnostics.
2103  enum class MissingImportKind {
2104  Declaration,
2105  Definition,
2106  DefaultArgument,
2107  ExplicitSpecialization,
2108  PartialSpecialization
2109  };
2110 
2111  /// Diagnose that the specified declaration needs to be visible but
2112  /// isn't, and suggest a module import that would resolve the problem.
2113  void diagnoseMissingImport(SourceLocation Loc, NamedDecl *Decl,
2114  MissingImportKind MIK, bool Recover = true);
2115  void diagnoseMissingImport(SourceLocation Loc, NamedDecl *Decl,
2116  SourceLocation DeclLoc, ArrayRef<Module *> Modules,
2117  MissingImportKind MIK, bool Recover);
2118 
2119  Decl *ActOnStartExportDecl(Scope *S, SourceLocation ExportLoc,
2120  SourceLocation LBraceLoc);
2121  Decl *ActOnFinishExportDecl(Scope *S, Decl *ExportDecl,
2122  SourceLocation RBraceLoc);
2123 
2124  /// We've found a use of a templated declaration that would trigger an
2125  /// implicit instantiation. Check that any relevant explicit specializations
2126  /// and partial specializations are visible, and diagnose if not.
2127  void checkSpecializationVisibility(SourceLocation Loc, NamedDecl *Spec);
2128 
2129  /// We've found a use of a template specialization that would select a
2130  /// partial specialization. Check that the partial specialization is visible,
2131  /// and diagnose if not.
2132  void checkPartialSpecializationVisibility(SourceLocation Loc,
2133  NamedDecl *Spec);
2134 
2135  /// Retrieve a suitable printing policy for diagnostics.
2137  return getPrintingPolicy(Context, PP);
2138  }
2139 
2140  /// Retrieve a suitable printing policy for diagnostics.
2141  static PrintingPolicy getPrintingPolicy(const ASTContext &Ctx,
2142  const Preprocessor &PP);
2143 
2144  /// Scope actions.
2145  void ActOnPopScope(SourceLocation Loc, Scope *S);
2146  void ActOnTranslationUnitScope(Scope *S);
2147 
2148  Decl *ParsedFreeStandingDeclSpec(Scope *S, AccessSpecifier AS, DeclSpec &DS,
2149  RecordDecl *&AnonRecord);
2150  Decl *ParsedFreeStandingDeclSpec(Scope *S, AccessSpecifier AS, DeclSpec &DS,
2151  MultiTemplateParamsArg TemplateParams,
2152  bool IsExplicitInstantiation,
2153  RecordDecl *&AnonRecord);
2154 
2155  Decl *BuildAnonymousStructOrUnion(Scope *S, DeclSpec &DS,
2156  AccessSpecifier AS,
2157  RecordDecl *Record,
2158  const PrintingPolicy &Policy);
2159 
2160  Decl *BuildMicrosoftCAnonymousStruct(Scope *S, DeclSpec &DS,
2161  RecordDecl *Record);
2162 
2163  /// Common ways to introduce type names without a tag for use in diagnostics.
2164  /// Keep in sync with err_tag_reference_non_tag.
2165  enum NonTagKind {
2175  };
2176 
2177  /// Given a non-tag type declaration, returns an enum useful for indicating
2178  /// what kind of non-tag type this is.
2179  NonTagKind getNonTagTypeDeclKind(const Decl *D, TagTypeKind TTK);
2180 
2181  bool isAcceptableTagRedeclaration(const TagDecl *Previous,
2182  TagTypeKind NewTag, bool isDefinition,
2183  SourceLocation NewTagLoc,
2184  const IdentifierInfo *Name);
2185 
2186  enum TagUseKind {
2187  TUK_Reference, // Reference to a tag: 'struct foo *X;'
2188  TUK_Declaration, // Fwd decl of a tag: 'struct foo;'
2189  TUK_Definition, // Definition of a tag: 'struct foo { int X; } Y;'
2190  TUK_Friend // Friend declaration: 'friend struct foo;'
2191  };
2192 
2193  Decl *ActOnTag(Scope *S, unsigned TagSpec, TagUseKind TUK,
2194  SourceLocation KWLoc, CXXScopeSpec &SS, IdentifierInfo *Name,
2195  SourceLocation NameLoc, const ParsedAttributesView &Attr,
2196  AccessSpecifier AS, SourceLocation ModulePrivateLoc,
2197  MultiTemplateParamsArg TemplateParameterLists, bool &OwnedDecl,
2198  bool &IsDependent, SourceLocation ScopedEnumKWLoc,
2199  bool ScopedEnumUsesClassTag, TypeResult UnderlyingType,
2200  bool IsTypeSpecifier, bool IsTemplateParamOrArg,
2201  SkipBodyInfo *SkipBody = nullptr);
2202 
2203  Decl *ActOnTemplatedFriendTag(Scope *S, SourceLocation FriendLoc,
2204  unsigned TagSpec, SourceLocation TagLoc,
2205  CXXScopeSpec &SS, IdentifierInfo *Name,
2206  SourceLocation NameLoc,
2207  const ParsedAttributesView &Attr,
2208  MultiTemplateParamsArg TempParamLists);
2209 
2210  TypeResult ActOnDependentTag(Scope *S,
2211  unsigned TagSpec,
2212  TagUseKind TUK,
2213  const CXXScopeSpec &SS,
2214  IdentifierInfo *Name,
2215  SourceLocation TagLoc,
2216  SourceLocation NameLoc);
2217 
2218  void ActOnDefs(Scope *S, Decl *TagD, SourceLocation DeclStart,
2219  IdentifierInfo *ClassName,
2220  SmallVectorImpl<Decl *> &Decls);
2221  Decl *ActOnField(Scope *S, Decl *TagD, SourceLocation DeclStart,
2222  Declarator &D, Expr *BitfieldWidth);
2223 
2224  FieldDecl *HandleField(Scope *S, RecordDecl *TagD, SourceLocation DeclStart,
2225  Declarator &D, Expr *BitfieldWidth,
2226  InClassInitStyle InitStyle,
2227  AccessSpecifier AS);
2228  MSPropertyDecl *HandleMSProperty(Scope *S, RecordDecl *TagD,
2229  SourceLocation DeclStart, Declarator &D,
2230  Expr *BitfieldWidth,
2231  InClassInitStyle InitStyle,
2232  AccessSpecifier AS,
2233  const ParsedAttr &MSPropertyAttr);
2234 
2235  FieldDecl *CheckFieldDecl(DeclarationName Name, QualType T,
2236  TypeSourceInfo *TInfo,
2237  RecordDecl *Record, SourceLocation Loc,
2238  bool Mutable, Expr *BitfieldWidth,
2239  InClassInitStyle InitStyle,
2240  SourceLocation TSSL,
2241  AccessSpecifier AS, NamedDecl *PrevDecl,
2242  Declarator *D = nullptr);
2243 
2244  bool CheckNontrivialField(FieldDecl *FD);
2245  void DiagnoseNontrivial(const CXXRecordDecl *Record, CXXSpecialMember CSM);
2246 
2248  /// The triviality of a method unaffected by "trivial_abi".
2250 
2251  /// The triviality of a method affected by "trivial_abi".
2252  TAH_ConsiderTrivialABI
2253  };
2254 
2255  bool SpecialMemberIsTrivial(CXXMethodDecl *MD, CXXSpecialMember CSM,
2256  TrivialABIHandling TAH = TAH_IgnoreTrivialABI,
2257  bool Diagnose = false);
2258  CXXSpecialMember getSpecialMember(const CXXMethodDecl *MD);
2259  void ActOnLastBitfield(SourceLocation DeclStart,
2260  SmallVectorImpl<Decl *> &AllIvarDecls);
2261  Decl *ActOnIvar(Scope *S, SourceLocation DeclStart,
2262  Declarator &D, Expr *BitfieldWidth,
2263  tok::ObjCKeywordKind visibility);
2264 
2265  // This is used for both record definitions and ObjC interface declarations.
2266  void ActOnFields(Scope *S, SourceLocation RecLoc, Decl *TagDecl,
2267  ArrayRef<Decl *> Fields, SourceLocation LBrac,
2268  SourceLocation RBrac, const ParsedAttributesView &AttrList);
2269 
2270  /// ActOnTagStartDefinition - Invoked when we have entered the
2271  /// scope of a tag's definition (e.g., for an enumeration, class,
2272  /// struct, or union).
2273  void ActOnTagStartDefinition(Scope *S, Decl *TagDecl);
2274 
2275  /// Perform ODR-like check for C/ObjC when merging tag types from modules.
2276  /// Differently from C++, actually parse the body and reject / error out
2277  /// in case of a structural mismatch.
2278  bool ActOnDuplicateDefinition(DeclSpec &DS, Decl *Prev,
2279  SkipBodyInfo &SkipBody);
2280 
2282 
2283  /// Invoked when we enter a tag definition that we're skipping.
2284  SkippedDefinitionContext ActOnTagStartSkippedDefinition(Scope *S, Decl *TD);
2285 
2286  Decl *ActOnObjCContainerStartDefinition(Decl *IDecl);
2287 
2288  /// ActOnStartCXXMemberDeclarations - Invoked when we have parsed a
2289  /// C++ record definition's base-specifiers clause and are starting its
2290  /// member declarations.
2291  void ActOnStartCXXMemberDeclarations(Scope *S, Decl *TagDecl,
2292  SourceLocation FinalLoc,
2293  bool IsFinalSpelledSealed,
2294  SourceLocation LBraceLoc);
2295 
2296  /// ActOnTagFinishDefinition - Invoked once we have finished parsing
2297  /// the definition of a tag (enumeration, class, struct, or union).
2298  void ActOnTagFinishDefinition(Scope *S, Decl *TagDecl,
2299  SourceRange BraceRange);
2300 
2301  void ActOnTagFinishSkippedDefinition(SkippedDefinitionContext Context);
2302 
2303  void ActOnObjCContainerFinishDefinition();
2304 
2305  /// Invoked when we must temporarily exit the objective-c container
2306  /// scope for parsing/looking-up C constructs.
2307  ///
2308  /// Must be followed by a call to \see ActOnObjCReenterContainerContext
2309  void ActOnObjCTemporaryExitContainerContext(DeclContext *DC);
2310  void ActOnObjCReenterContainerContext(DeclContext *DC);
2311 
2312  /// ActOnTagDefinitionError - Invoked when there was an unrecoverable
2313  /// error parsing the definition of a tag.
2314  void ActOnTagDefinitionError(Scope *S, Decl *TagDecl);
2315 
2316  EnumConstantDecl *CheckEnumConstant(EnumDecl *Enum,
2317  EnumConstantDecl *LastEnumConst,
2318  SourceLocation IdLoc,
2319  IdentifierInfo *Id,
2320  Expr *val);
2321  bool CheckEnumUnderlyingType(TypeSourceInfo *TI);
2322  bool CheckEnumRedeclaration(SourceLocation EnumLoc, bool IsScoped,
2323  QualType EnumUnderlyingTy, bool IsFixed,
2324  const EnumDecl *Prev);
2325 
2326  /// Determine whether the body of an anonymous enumeration should be skipped.
2327  /// \param II The name of the first enumerator.
2328  SkipBodyInfo shouldSkipAnonEnumBody(Scope *S, IdentifierInfo *II,
2329  SourceLocation IILoc);
2330 
2331  Decl *ActOnEnumConstant(Scope *S, Decl *EnumDecl, Decl *LastEnumConstant,
2333  const ParsedAttributesView &Attrs,
2334  SourceLocation EqualLoc, Expr *Val);
2335  void ActOnEnumBody(SourceLocation EnumLoc, SourceRange BraceRange,
2336  Decl *EnumDecl, ArrayRef<Decl *> Elements, Scope *S,
2337  const ParsedAttributesView &Attr);
2338 
2339  DeclContext *getContainingDC(DeclContext *DC);
2340 
2341  /// Set the current declaration context until it gets popped.
2342  void PushDeclContext(Scope *S, DeclContext *DC);
2343  void PopDeclContext();
2344 
2345  /// EnterDeclaratorContext - Used when we must lookup names in the context
2346  /// of a declarator's nested name specifier.
2347  void EnterDeclaratorContext(Scope *S, DeclContext *DC);
2348  void ExitDeclaratorContext(Scope *S);
2349 
2350  /// Push the parameters of D, which must be a function, into scope.
2351  void ActOnReenterFunctionContext(Scope* S, Decl* D);
2352  void ActOnExitFunctionContext();
2353 
2354  DeclContext *getFunctionLevelDeclContext();
2355 
2356  /// getCurFunctionDecl - If inside of a function body, this returns a pointer
2357  /// to the function decl for the function being parsed. If we're currently
2358  /// in a 'block', this returns the containing context.
2359  FunctionDecl *getCurFunctionDecl();
2360 
2361  /// getCurMethodDecl - If inside of a method body, this returns a pointer to
2362  /// the method decl for the method being parsed. If we're currently
2363  /// in a 'block', this returns the containing context.
2364  ObjCMethodDecl *getCurMethodDecl();
2365 
2366  /// getCurFunctionOrMethodDecl - Return the Decl for the current ObjC method
2367  /// or C function we're in, otherwise return null. If we're currently
2368  /// in a 'block', this returns the containing context.
2369  NamedDecl *getCurFunctionOrMethodDecl();
2370 
2371  /// Add this decl to the scope shadowed decl chains.
2372  void PushOnScopeChains(NamedDecl *D, Scope *S, bool AddToContext = true);
2373 
2374  /// Make the given externally-produced declaration visible at the
2375  /// top level scope.
2376  ///
2377  /// \param D The externally-produced declaration to push.
2378  ///
2379  /// \param Name The name of the externally-produced declaration.
2380  void pushExternalDeclIntoScope(NamedDecl *D, DeclarationName Name);
2381 
2382  /// isDeclInScope - If 'Ctx' is a function/method, isDeclInScope returns true
2383  /// if 'D' is in Scope 'S', otherwise 'S' is ignored and isDeclInScope returns
2384  /// true if 'D' belongs to the given declaration context.
2385  ///
2386  /// \param AllowInlineNamespace If \c true, allow the declaration to be in the
2387  /// enclosing namespace set of the context, rather than contained
2388  /// directly within it.
2389  bool isDeclInScope(NamedDecl *D, DeclContext *Ctx, Scope *S = nullptr,
2390  bool AllowInlineNamespace = false);
2391 
2392  /// Finds the scope corresponding to the given decl context, if it
2393  /// happens to be an enclosing scope. Otherwise return NULL.
2394  static Scope *getScopeForDeclContext(Scope *S, DeclContext *DC);
2395 
2396  /// Subroutines of ActOnDeclarator().
2397  TypedefDecl *ParseTypedefDecl(Scope *S, Declarator &D, QualType T,
2398  TypeSourceInfo *TInfo);
2399  bool isIncompatibleTypedef(TypeDecl *Old, TypedefNameDecl *New);
2400 
2401  /// Describes the kind of merge to perform for availability
2402  /// attributes (including "deprecated", "unavailable", and "availability").
2404  /// Don't merge availability attributes at all.
2406  /// Merge availability attributes for a redeclaration, which requires
2407  /// an exact match.
2409  /// Merge availability attributes for an override, which requires
2410  /// an exact match or a weakening of constraints.
2412  /// Merge availability attributes for an implementation of
2413  /// a protocol requirement.
2415  };
2416 
2417  /// Attribute merging methods. Return true if a new attribute was added.
2418  AvailabilityAttr *mergeAvailabilityAttr(NamedDecl *D, SourceRange Range,
2419  IdentifierInfo *Platform,
2420  bool Implicit,
2421  VersionTuple Introduced,
2422  VersionTuple Deprecated,
2423  VersionTuple Obsoleted,
2424  bool IsUnavailable,
2425  StringRef Message,
2426  bool IsStrict, StringRef Replacement,
2428  unsigned AttrSpellingListIndex);
2429  TypeVisibilityAttr *mergeTypeVisibilityAttr(Decl *D, SourceRange Range,
2430  TypeVisibilityAttr::VisibilityType Vis,
2431  unsigned AttrSpellingListIndex);
2432  VisibilityAttr *mergeVisibilityAttr(Decl *D, SourceRange Range,
2433  VisibilityAttr::VisibilityType Vis,
2434  unsigned AttrSpellingListIndex);
2435  UuidAttr *mergeUuidAttr(Decl *D, SourceRange Range,
2436  unsigned AttrSpellingListIndex, StringRef Uuid);
2437  DLLImportAttr *mergeDLLImportAttr(Decl *D, SourceRange Range,
2438  unsigned AttrSpellingListIndex);
2439  DLLExportAttr *mergeDLLExportAttr(Decl *D, SourceRange Range,
2440  unsigned AttrSpellingListIndex);
2441  MSInheritanceAttr *
2442  mergeMSInheritanceAttr(Decl *D, SourceRange Range, bool BestCase,
2443  unsigned AttrSpellingListIndex,
2444  MSInheritanceAttr::Spelling SemanticSpelling);
2445  FormatAttr *mergeFormatAttr(Decl *D, SourceRange Range,
2446  IdentifierInfo *Format, int FormatIdx,
2447  int FirstArg, unsigned AttrSpellingListIndex);
2448  SectionAttr *mergeSectionAttr(Decl *D, SourceRange Range, StringRef Name,
2449  unsigned AttrSpellingListIndex);
2450  CodeSegAttr *mergeCodeSegAttr(Decl *D, SourceRange Range, StringRef Name,
2451  unsigned AttrSpellingListIndex);
2452  AlwaysInlineAttr *mergeAlwaysInlineAttr(Decl *D, SourceRange Range,
2453  IdentifierInfo *Ident,
2454  unsigned AttrSpellingListIndex);
2455  MinSizeAttr *mergeMinSizeAttr(Decl *D, SourceRange Range,
2456  unsigned AttrSpellingListIndex);
2457  OptimizeNoneAttr *mergeOptimizeNoneAttr(Decl *D, SourceRange Range,
2458  unsigned AttrSpellingListIndex);
2459  InternalLinkageAttr *mergeInternalLinkageAttr(Decl *D, SourceRange Range,
2460  IdentifierInfo *Ident,
2461  unsigned AttrSpellingListIndex);
2462  CommonAttr *mergeCommonAttr(Decl *D, SourceRange Range, IdentifierInfo *Ident,
2463  unsigned AttrSpellingListIndex);
2464 
2465  void mergeDeclAttributes(NamedDecl *New, Decl *Old,
2466  AvailabilityMergeKind AMK = AMK_Redeclaration);
2467  void MergeTypedefNameDecl(Scope *S, TypedefNameDecl *New,
2468  LookupResult &OldDecls);
2469  bool MergeFunctionDecl(FunctionDecl *New, NamedDecl *&Old, Scope *S,
2470  bool MergeTypeWithOld);
2471  bool MergeCompatibleFunctionDecls(FunctionDecl *New, FunctionDecl *Old,
2472  Scope *S, bool MergeTypeWithOld);
2473  void mergeObjCMethodDecls(ObjCMethodDecl *New, ObjCMethodDecl *Old);
2474  void MergeVarDecl(VarDecl *New, LookupResult &Previous);
2475  void MergeVarDeclTypes(VarDecl *New, VarDecl *Old, bool MergeTypeWithOld);
2476  void MergeVarDeclExceptionSpecs(VarDecl *New, VarDecl *Old);
2477  bool checkVarDeclRedefinition(VarDecl *OldDefn, VarDecl *NewDefn);
2478  void notePreviousDefinition(const NamedDecl *Old, SourceLocation New);
2479  bool MergeCXXFunctionDecl(FunctionDecl *New, FunctionDecl *Old, Scope *S);
2480 
2481  // AssignmentAction - This is used by all the assignment diagnostic functions
2482  // to represent what is actually causing the operation
2491  AA_Passing_CFAudited
2492  };
2493 
2494  /// C++ Overloading.
2496  /// This is a legitimate overload: the existing declarations are
2497  /// functions or function templates with different signatures.
2499 
2500  /// This is not an overload because the signature exactly matches
2501  /// an existing declaration.
2503 
2504  /// This is not an overload because the lookup results contain a
2505  /// non-function.
2506  Ovl_NonFunction
2507  };
2508  OverloadKind CheckOverload(Scope *S,
2509  FunctionDecl *New,
2510  const LookupResult &OldDecls,
2511  NamedDecl *&OldDecl,
2512  bool IsForUsingDecl);
2513  bool IsOverload(FunctionDecl *New, FunctionDecl *Old, bool IsForUsingDecl,
2514  bool ConsiderCudaAttrs = true);
2515 
2516  /// Checks availability of the function depending on the current
2517  /// function context.Inside an unavailable function,unavailability is ignored.
2518  ///
2519  /// \returns true if \p FD is unavailable and current context is inside
2520  /// an available function, false otherwise.
2521  bool isFunctionConsideredUnavailable(FunctionDecl *FD);
2522 
2524  TryImplicitConversion(Expr *From, QualType ToType,
2525  bool SuppressUserConversions,
2526  bool AllowExplicit,
2527  bool InOverloadResolution,
2528  bool CStyle,
2529  bool AllowObjCWritebackConversion);
2530 
2531  bool IsIntegralPromotion(Expr *From, QualType FromType, QualType ToType);
2532  bool IsFloatingPointPromotion(QualType FromType, QualType ToType);
2533  bool IsComplexPromotion(QualType FromType, QualType ToType);
2534  bool IsPointerConversion(Expr *From, QualType FromType, QualType ToType,
2535  bool InOverloadResolution,
2536  QualType& ConvertedType, bool &IncompatibleObjC);
2537  bool isObjCPointerConversion(QualType FromType, QualType ToType,
2538  QualType& ConvertedType, bool &IncompatibleObjC);
2539  bool isObjCWritebackConversion(QualType FromType, QualType ToType,
2540  QualType &ConvertedType);
2541  bool IsBlockPointerConversion(QualType FromType, QualType ToType,
2542  QualType& ConvertedType);
2543  bool FunctionParamTypesAreEqual(const FunctionProtoType *OldType,
2544  const FunctionProtoType *NewType,
2545  unsigned *ArgPos = nullptr);
2546  void HandleFunctionTypeMismatch(PartialDiagnostic &PDiag,
2547  QualType FromType, QualType ToType);
2548 
2549  void maybeExtendBlockObject(ExprResult &E);
2550  CastKind PrepareCastToObjCObjectPointer(ExprResult &E);
2551  bool CheckPointerConversion(Expr *From, QualType ToType,
2552  CastKind &Kind,
2553  CXXCastPath& BasePath,
2554  bool IgnoreBaseAccess,
2555  bool Diagnose = true);
2556  bool IsMemberPointerConversion(Expr *From, QualType FromType, QualType ToType,
2557  bool InOverloadResolution,
2558  QualType &ConvertedType);
2559  bool CheckMemberPointerConversion(Expr *From, QualType ToType,
2560  CastKind &Kind,
2561  CXXCastPath &BasePath,
2562  bool IgnoreBaseAccess);
2563  bool IsQualificationConversion(QualType FromType, QualType ToType,
2564  bool CStyle, bool &ObjCLifetimeConversion);
2565  bool IsFunctionConversion(QualType FromType, QualType ToType,
2566  QualType &ResultTy);
2567  bool DiagnoseMultipleUserDefinedConversion(Expr *From, QualType ToType);
2568  bool isSameOrCompatibleFunctionType(CanQualType Param, CanQualType Arg);
2569 
2570  ExprResult PerformMoveOrCopyInitialization(const InitializedEntity &Entity,
2571  const VarDecl *NRVOCandidate,
2572  QualType ResultType,
2573  Expr *Value,
2574  bool AllowNRVO = true);
2575 
2576  bool CanPerformCopyInitialization(const InitializedEntity &Entity,
2577  ExprResult Init);
2578  ExprResult PerformCopyInitialization(const InitializedEntity &Entity,
2579  SourceLocation EqualLoc,
2580  ExprResult Init,
2581  bool TopLevelOfInitList = false,
2582  bool AllowExplicit = false);
2583  ExprResult PerformObjectArgumentInitialization(Expr *From,
2584  NestedNameSpecifier *Qualifier,
2585  NamedDecl *FoundDecl,
2586  CXXMethodDecl *Method);
2587 
2588  /// Check that the lifetime of the initializer (and its subobjects) is
2589  /// sufficient for initializing the entity, and perform lifetime extension
2590  /// (when permitted) if not.
2591  void checkInitializerLifetime(const InitializedEntity &Entity, Expr *Init);
2592 
2593  ExprResult PerformContextuallyConvertToBool(Expr *From);
2594  ExprResult PerformContextuallyConvertToObjCPointer(Expr *From);
2595 
2596  /// Contexts in which a converted constant expression is required.
2597  enum CCEKind {
2598  CCEK_CaseValue, ///< Expression in a case label.
2599  CCEK_Enumerator, ///< Enumerator value with fixed underlying type.
2600  CCEK_TemplateArg, ///< Value of a non-type template parameter.
2601  CCEK_NewExpr, ///< Constant expression in a noptr-new-declarator.
2602  CCEK_ConstexprIf ///< Condition in a constexpr if statement.
2603  };
2605  llvm::APSInt &Value, CCEKind CCE);
2607  APValue &Value, CCEKind CCE);
2608 
2609  /// Abstract base class used to perform a contextual implicit
2610  /// conversion from an expression to any type passing a filter.
2612  public:
2613  bool Suppress;
2615 
2616  ContextualImplicitConverter(bool Suppress = false,
2617  bool SuppressConversion = false)
2618  : Suppress(Suppress), SuppressConversion(SuppressConversion) {}
2619 
2620  /// Determine whether the specified type is a valid destination type
2621  /// for this conversion.
2622  virtual bool match(QualType T) = 0;
2623 
2624  /// Emits a diagnostic complaining that the expression does not have
2625  /// integral or enumeration type.
2626  virtual SemaDiagnosticBuilder
2627  diagnoseNoMatch(Sema &S, SourceLocation Loc, QualType T) = 0;
2628 
2629  /// Emits a diagnostic when the expression has incomplete class type.
2630  virtual SemaDiagnosticBuilder
2631  diagnoseIncomplete(Sema &S, SourceLocation Loc, QualType T) = 0;
2632 
2633  /// Emits a diagnostic when the only matching conversion function
2634  /// is explicit.
2635  virtual SemaDiagnosticBuilder diagnoseExplicitConv(
2636  Sema &S, SourceLocation Loc, QualType T, QualType ConvTy) = 0;
2637 
2638  /// Emits a note for the explicit conversion function.
2639  virtual SemaDiagnosticBuilder
2640  noteExplicitConv(Sema &S, CXXConversionDecl *Conv, QualType ConvTy) = 0;
2641 
2642  /// Emits a diagnostic when there are multiple possible conversion
2643  /// functions.
2644  virtual SemaDiagnosticBuilder
2645  diagnoseAmbiguous(Sema &S, SourceLocation Loc, QualType T) = 0;
2646 
2647  /// Emits a note for one of the candidate conversions.
2648  virtual SemaDiagnosticBuilder
2649  noteAmbiguous(Sema &S, CXXConversionDecl *Conv, QualType ConvTy) = 0;
2650 
2651  /// Emits a diagnostic when we picked a conversion function
2652  /// (for cases when we are not allowed to pick a conversion function).
2653  virtual SemaDiagnosticBuilder diagnoseConversion(
2654  Sema &S, SourceLocation Loc, QualType T, QualType ConvTy) = 0;
2655 
2657  };
2658 
2660  bool AllowScopedEnumerations;
2661 
2662  public:
2663  ICEConvertDiagnoser(bool AllowScopedEnumerations,
2664  bool Suppress, bool SuppressConversion)
2665  : ContextualImplicitConverter(Suppress, SuppressConversion),
2666  AllowScopedEnumerations(AllowScopedEnumerations) {}
2667 
2668  /// Match an integral or (possibly scoped) enumeration type.
2669  bool match(QualType T) override;
2670 
2673  return diagnoseNotInt(S, Loc, T);
2674  }
2675 
2676  /// Emits a diagnostic complaining that the expression does not have
2677  /// integral or enumeration type.
2678  virtual SemaDiagnosticBuilder
2679  diagnoseNotInt(Sema &S, SourceLocation Loc, QualType T) = 0;
2680  };
2681 
2682  /// Perform a contextual implicit conversion.
2683  ExprResult PerformContextualImplicitConversion(
2684  SourceLocation Loc, Expr *FromE, ContextualImplicitConverter &Converter);
2685 
2686 
2690  OS_Error
2691  };
2692  ObjCSubscriptKind CheckSubscriptingKind(Expr *FromE);
2693 
2694  // Note that LK_String is intentionally after the other literals, as
2695  // this is used for diagnostics logic.
2703  LK_None
2704  };
2705  ObjCLiteralKind CheckLiteralKind(Expr *FromE);
2706 
2707  ExprResult PerformObjectMemberConversion(Expr *From,
2708  NestedNameSpecifier *Qualifier,
2709  NamedDecl *FoundDecl,
2710  NamedDecl *Member);
2711 
2712  // Members have to be NamespaceDecl* or TranslationUnitDecl*.
2713  // TODO: make this is a typesafe union.
2716 
2717  void AddOverloadCandidate(FunctionDecl *Function,
2718  DeclAccessPair FoundDecl,
2719  ArrayRef<Expr *> Args,
2720  OverloadCandidateSet &CandidateSet,
2721  bool SuppressUserConversions = false,
2722  bool PartialOverloading = false,
2723  bool AllowExplicit = false,
2724  ConversionSequenceList EarlyConversions = None);
2725  void AddFunctionCandidates(const UnresolvedSetImpl &Functions,
2726  ArrayRef<Expr *> Args,
2727  OverloadCandidateSet &CandidateSet,
2728  TemplateArgumentListInfo *ExplicitTemplateArgs = nullptr,
2729  bool SuppressUserConversions = false,
2730  bool PartialOverloading = false,
2731  bool FirstArgumentIsBase = false);
2732  void AddMethodCandidate(DeclAccessPair FoundDecl,
2733  QualType ObjectType,
2734  Expr::Classification ObjectClassification,
2735  ArrayRef<Expr *> Args,
2736  OverloadCandidateSet& CandidateSet,
2737  bool SuppressUserConversion = false);
2738  void AddMethodCandidate(CXXMethodDecl *Method,
2739  DeclAccessPair FoundDecl,
2740  CXXRecordDecl *ActingContext, QualType ObjectType,
2741  Expr::Classification ObjectClassification,
2742  ArrayRef<Expr *> Args,
2743  OverloadCandidateSet& CandidateSet,
2744  bool SuppressUserConversions = false,
2745  bool PartialOverloading = false,
2746  ConversionSequenceList EarlyConversions = None);
2747  void AddMethodTemplateCandidate(FunctionTemplateDecl *MethodTmpl,
2748  DeclAccessPair FoundDecl,
2749  CXXRecordDecl *ActingContext,
2750  TemplateArgumentListInfo *ExplicitTemplateArgs,
2751  QualType ObjectType,
2752  Expr::Classification ObjectClassification,
2753  ArrayRef<Expr *> Args,
2754  OverloadCandidateSet& CandidateSet,
2755  bool SuppressUserConversions = false,
2756  bool PartialOverloading = false);
2757  void AddTemplateOverloadCandidate(FunctionTemplateDecl *FunctionTemplate,
2758  DeclAccessPair FoundDecl,
2759  TemplateArgumentListInfo *ExplicitTemplateArgs,
2760  ArrayRef<Expr *> Args,
2761  OverloadCandidateSet& CandidateSet,
2762  bool SuppressUserConversions = false,
2763  bool PartialOverloading = false);
2764  bool CheckNonDependentConversions(FunctionTemplateDecl *FunctionTemplate,
2765  ArrayRef<QualType> ParamTypes,
2766  ArrayRef<Expr *> Args,
2767  OverloadCandidateSet &CandidateSet,
2768  ConversionSequenceList &Conversions,
2769  bool SuppressUserConversions,
2770  CXXRecordDecl *ActingContext = nullptr,
2771  QualType ObjectType = QualType(),
2773  ObjectClassification = {});
2774  void AddConversionCandidate(CXXConversionDecl *Conversion,
2775  DeclAccessPair FoundDecl,
2776  CXXRecordDecl *ActingContext,
2777  Expr *From, QualType ToType,
2778  OverloadCandidateSet& CandidateSet,
2779  bool AllowObjCConversionOnExplicit,
2780  bool AllowResultConversion = true);
2781  void AddTemplateConversionCandidate(FunctionTemplateDecl *FunctionTemplate,
2782  DeclAccessPair FoundDecl,
2783  CXXRecordDecl *ActingContext,
2784  Expr *From, QualType ToType,
2785  OverloadCandidateSet &CandidateSet,
2786  bool AllowObjCConversionOnExplicit,
2787  bool AllowResultConversion = true);
2788  void AddSurrogateCandidate(CXXConversionDecl *Conversion,
2789  DeclAccessPair FoundDecl,
2790  CXXRecordDecl *ActingContext,
2791  const FunctionProtoType *Proto,
2792  Expr *Object, ArrayRef<Expr *> Args,
2793  OverloadCandidateSet& CandidateSet);
2794  void AddMemberOperatorCandidates(OverloadedOperatorKind Op,
2795  SourceLocation OpLoc, ArrayRef<Expr *> Args,
2796  OverloadCandidateSet& CandidateSet,
2797  SourceRange OpRange = SourceRange());
2798  void AddBuiltinCandidate(QualType *ParamTys, ArrayRef<Expr *> Args,
2799  OverloadCandidateSet& CandidateSet,
2800  bool IsAssignmentOperator = false,
2801  unsigned NumContextualBoolArguments = 0);
2802  void AddBuiltinOperatorCandidates(OverloadedOperatorKind Op,
2803  SourceLocation OpLoc, ArrayRef<Expr *> Args,
2804  OverloadCandidateSet& CandidateSet);
2805  void AddArgumentDependentLookupCandidates(DeclarationName Name,
2806  SourceLocation Loc,
2807  ArrayRef<Expr *> Args,
2808  TemplateArgumentListInfo *ExplicitTemplateArgs,
2809  OverloadCandidateSet& CandidateSet,
2810  bool PartialOverloading = false);
2811 
2812  // Emit as a 'note' the specific overload candidate
2813  void NoteOverloadCandidate(NamedDecl *Found, FunctionDecl *Fn,
2814  QualType DestType = QualType(),
2815  bool TakingAddress = false);
2816 
2817  // Emit as a series of 'note's all template and non-templates identified by
2818  // the expression Expr
2819  void NoteAllOverloadCandidates(Expr *E, QualType DestType = QualType(),
2820  bool TakingAddress = false);
2821 
2822  /// Check the enable_if expressions on the given function. Returns the first
2823  /// failing attribute, or NULL if they were all successful.
2824  EnableIfAttr *CheckEnableIf(FunctionDecl *Function, ArrayRef<Expr *> Args,
2825  bool MissingImplicitThis = false);
2826 
2827  /// Find the failed Boolean condition within a given Boolean
2828  /// constant expression, and describe it with a string.
2829  ///
2830  /// \param AllowTopLevelCond Whether to allow the result to be the
2831  /// complete top-level condition.
2832  std::pair<Expr *, std::string>
2833  findFailedBooleanCondition(Expr *Cond, bool AllowTopLevelCond);
2834 
2835  /// Emit diagnostics for the diagnose_if attributes on Function, ignoring any
2836  /// non-ArgDependent DiagnoseIfAttrs.
2837  ///
2838  /// Argument-dependent diagnose_if attributes should be checked each time a
2839  /// function is used as a direct callee of a function call.
2840  ///
2841  /// Returns true if any errors were emitted.
2842  bool diagnoseArgDependentDiagnoseIfAttrs(const FunctionDecl *Function,
2843  const Expr *ThisArg,
2845  SourceLocation Loc);
2846 
2847  /// Emit diagnostics for the diagnose_if attributes on Function, ignoring any
2848  /// ArgDependent DiagnoseIfAttrs.
2849  ///
2850  /// Argument-independent diagnose_if attributes should be checked on every use
2851  /// of a function.
2852  ///
2853  /// Returns true if any errors were emitted.
2854  bool diagnoseArgIndependentDiagnoseIfAttrs(const NamedDecl *ND,
2855  SourceLocation Loc);
2856 
2857  /// Returns whether the given function's address can be taken or not,
2858  /// optionally emitting a diagnostic if the address can't be taken.
2859  ///
2860  /// Returns false if taking the address of the function is illegal.
2861  bool checkAddressOfFunctionIsAvailable(const FunctionDecl *Function,
2862  bool Complain = false,
2863  SourceLocation Loc = SourceLocation());
2864 
2865  // [PossiblyAFunctionType] --> [Return]
2866  // NonFunctionType --> NonFunctionType
2867  // R (A) --> R(A)
2868  // R (*)(A) --> R (A)
2869  // R (&)(A) --> R (A)
2870  // R (S::*)(A) --> R (A)
2871  QualType ExtractUnqualifiedFunctionType(QualType PossiblyAFunctionType);
2872 
2873  FunctionDecl *
2874  ResolveAddressOfOverloadedFunction(Expr *AddressOfExpr,
2875  QualType TargetType,
2876  bool Complain,
2877  DeclAccessPair &Found,
2878  bool *pHadMultipleCandidates = nullptr);
2879 
2880  FunctionDecl *
2881  resolveAddressOfOnlyViableOverloadCandidate(Expr *E,
2882  DeclAccessPair &FoundResult);
2883 
2884  bool resolveAndFixAddressOfOnlyViableOverloadCandidate(
2885  ExprResult &SrcExpr, bool DoFunctionPointerConversion = false);
2886 
2887  FunctionDecl *
2888  ResolveSingleFunctionTemplateSpecialization(OverloadExpr *ovl,
2889  bool Complain = false,
2890  DeclAccessPair *Found = nullptr);
2891 
2892  bool ResolveAndFixSingleFunctionTemplateSpecialization(
2893  ExprResult &SrcExpr,
2894  bool DoFunctionPointerConverion = false,
2895  bool Complain = false,
2896  SourceRange OpRangeForComplaining = SourceRange(),
2897  QualType DestTypeForComplaining = QualType(),
2898  unsigned DiagIDForComplaining = 0);
2899 
2900 
2901  Expr *FixOverloadedFunctionReference(Expr *E,
2902  DeclAccessPair FoundDecl,
2903  FunctionDecl *Fn);
2904  ExprResult FixOverloadedFunctionReference(ExprResult,
2905  DeclAccessPair FoundDecl,
2906  FunctionDecl *Fn);
2907 
2908  void AddOverloadedCallCandidates(UnresolvedLookupExpr *ULE,
2909  ArrayRef<Expr *> Args,
2910  OverloadCandidateSet &CandidateSet,
2911  bool PartialOverloading = false);
2912 
2913  // An enum used to represent the different possible results of building a
2914  // range-based for loop.
2918  FRS_DiagnosticIssued
2919  };
2920 
2921  ForRangeStatus BuildForRangeBeginEndCall(SourceLocation Loc,
2922  SourceLocation RangeLoc,
2923  const DeclarationNameInfo &NameInfo,
2924  LookupResult &MemberLookup,
2925  OverloadCandidateSet *CandidateSet,
2926  Expr *Range, ExprResult *CallExpr);
2927 
2928  ExprResult BuildOverloadedCallExpr(Scope *S, Expr *Fn,
2929  UnresolvedLookupExpr *ULE,
2930  SourceLocation LParenLoc,
2931  MultiExprArg Args,
2932  SourceLocation RParenLoc,
2933  Expr *ExecConfig,
2934  bool AllowTypoCorrection=true,
2935  bool CalleesAddressIsTaken=false);
2936 
2937  bool buildOverloadedCallSet(Scope *S, Expr *Fn, UnresolvedLookupExpr *ULE,
2938  MultiExprArg Args, SourceLocation RParenLoc,
2939  OverloadCandidateSet *CandidateSet,
2940  ExprResult *Result);
2941 
2942  ExprResult CreateOverloadedUnaryOp(SourceLocation OpLoc,
2943  UnaryOperatorKind Opc,
2944  const UnresolvedSetImpl &Fns,
2945  Expr *input, bool RequiresADL = true);
2946 
2947  ExprResult CreateOverloadedBinOp(SourceLocation OpLoc,
2948  BinaryOperatorKind Opc,
2949  const UnresolvedSetImpl &Fns,
2950  Expr *LHS, Expr *RHS,
2951  bool RequiresADL = true);
2952 
2953  ExprResult CreateOverloadedArraySubscriptExpr(SourceLocation LLoc,
2954  SourceLocation RLoc,
2955  Expr *Base,Expr *Idx);
2956 
2957  ExprResult
2958  BuildCallToMemberFunction(Scope *S, Expr *MemExpr,
2959  SourceLocation LParenLoc,
2960  MultiExprArg Args,
2961  SourceLocation RParenLoc);
2962  ExprResult
2963  BuildCallToObjectOfClassType(Scope *S, Expr *Object, SourceLocation LParenLoc,
2964  MultiExprArg Args,
2965  SourceLocation RParenLoc);
2966 
2967  ExprResult BuildOverloadedArrowExpr(Scope *S, Expr *Base,
2968  SourceLocation OpLoc,
2969  bool *NoArrowOperatorFound = nullptr);
2970 
2971  /// CheckCallReturnType - Checks that a call expression's return type is
2972  /// complete. Returns true on failure. The location passed in is the location
2973  /// that best represents the call.
2974  bool CheckCallReturnType(QualType ReturnType, SourceLocation Loc,
2975  CallExpr *CE, FunctionDecl *FD);
2976 
2977  /// Helpers for dealing with blocks and functions.
2978  bool CheckParmsForFunctionDef(ArrayRef<ParmVarDecl *> Parameters,
2979  bool CheckParameterNames);
2980  void CheckCXXDefaultArguments(FunctionDecl *FD);
2981  void CheckExtraCXXDefaultArguments(Declarator &D);
2982  Scope *getNonFieldDeclScope(Scope *S);
2983 
2984  /// \name Name lookup
2985  ///
2986  /// These routines provide name lookup that is used during semantic
2987  /// analysis to resolve the various kinds of names (identifiers,
2988  /// overloaded operator names, constructor names, etc.) into zero or
2989  /// more declarations within a particular scope. The major entry
2990  /// points are LookupName, which performs unqualified name lookup,
2991  /// and LookupQualifiedName, which performs qualified name lookup.
2992  ///
2993  /// All name lookup is performed based on some specific criteria,
2994  /// which specify what names will be visible to name lookup and how
2995  /// far name lookup should work. These criteria are important both
2996  /// for capturing language semantics (certain lookups will ignore
2997  /// certain names, for example) and for performance, since name
2998  /// lookup is often a bottleneck in the compilation of C++. Name
2999  /// lookup criteria is specified via the LookupCriteria enumeration.
3000  ///
3001  /// The results of name lookup can vary based on the kind of name
3002  /// lookup performed, the current language, and the translation
3003  /// unit. In C, for example, name lookup will either return nothing
3004  /// (no entity found) or a single declaration. In C++, name lookup
3005  /// can additionally refer to a set of overloaded functions or
3006  /// result in an ambiguity. All of the possible results of name
3007  /// lookup are captured by the LookupResult class, which provides
3008  /// the ability to distinguish among them.
3009  //@{
3010 
3011  /// Describes the kind of name lookup to perform.
3013  /// Ordinary name lookup, which finds ordinary names (functions,
3014  /// variables, typedefs, etc.) in C and most kinds of names
3015  /// (functions, variables, members, types, etc.) in C++.
3016  LookupOrdinaryName = 0,
3017  /// Tag name lookup, which finds the names of enums, classes,
3018  /// structs, and unions.
3020  /// Label name lookup.
3022  /// Member name lookup, which finds the names of
3023  /// class/struct/union members.
3025  /// Look up of an operator name (e.g., operator+) for use with
3026  /// operator overloading. This lookup is similar to ordinary name
3027  /// lookup, but will ignore any declarations that are class members.
3029  /// Look up of a name that precedes the '::' scope resolution
3030  /// operator in C++. This lookup completely ignores operator, object,
3031  /// function, and enumerator names (C++ [basic.lookup.qual]p1).
3033  /// Look up a namespace name within a C++ using directive or
3034  /// namespace alias definition, ignoring non-namespace names (C++
3035  /// [basic.lookup.udir]p1).
3037  /// Look up all declarations in a scope with the given name,
3038  /// including resolved using declarations. This is appropriate
3039  /// for checking redeclarations for a using declaration.
3041  /// Look up an ordinary name that is going to be redeclared as a
3042  /// name with linkage. This lookup ignores any declarations that
3043  /// are outside of the current scope unless they have linkage. See
3044  /// C99 6.2.2p4-5 and C++ [basic.link]p6.
3046  /// Look up a friend of a local class. This lookup does not look
3047  /// outside the innermost non-class scope. See C++11 [class.friend]p11.
3049  /// Look up the name of an Objective-C protocol.
3051  /// Look up implicit 'self' parameter of an objective-c method.
3053  /// Look up the name of an OpenMP user-defined reduction operation.
3055  /// Look up any declaration with any name.
3056  LookupAnyName
3057  };
3058 
3059  /// Specifies whether (or how) name lookup is being performed for a
3060  /// redeclaration (vs. a reference).
3062  /// The lookup is a reference to this name that is not for the
3063  /// purpose of redeclaring the name.
3064  NotForRedeclaration = 0,
3065  /// The lookup results will be used for redeclaration of a name,
3066  /// if an entity by that name already exists and is visible.
3068  /// The lookup results will be used for redeclaration of a name
3069  /// with external linkage; non-visible lookup results with external linkage
3070  /// may also be found.
3071  ForExternalRedeclaration
3072  };
3073 
3075  // A declaration with an owning module for linkage can never link against
3076  // anything that is not visible. We don't need to check linkage here; if
3077  // the context has internal linkage, redeclaration lookup won't find things
3078  // from other TUs, and we can't safely compute linkage yet in general.
3079  if (cast<Decl>(CurContext)
3080  ->getOwningModuleForLinkage(/*IgnoreLinkage*/true))
3081  return ForVisibleRedeclaration;
3082  return ForExternalRedeclaration;
3083  }
3084 
3085  /// The possible outcomes of name lookup for a literal operator.
3087  /// The lookup resulted in an error.
3089  /// The lookup found no match but no diagnostic was issued.
3091  /// The lookup found a single 'cooked' literal operator, which
3092  /// expects a normal literal to be built and passed to it.
3094  /// The lookup found a single 'raw' literal operator, which expects
3095  /// a string literal containing the spelling of the literal token.
3097  /// The lookup found an overload set of literal operator templates,
3098  /// which expect the characters of the spelling of the literal token to be
3099  /// passed as a non-type template argument pack.
3101  /// The lookup found an overload set of literal operator templates,
3102  /// which expect the character type and characters of the spelling of the
3103  /// string literal token to be passed as template arguments.
3104  LOLR_StringTemplate
3105  };
3106 
3107  SpecialMemberOverloadResult LookupSpecialMember(CXXRecordDecl *D,
3109  bool ConstArg,
3110  bool VolatileArg,
3111  bool RValueThis,
3112  bool ConstThis,
3113  bool VolatileThis);
3114 
3115  typedef std::function<void(const TypoCorrection &)> TypoDiagnosticGenerator;
3116  typedef std::function<ExprResult(Sema &, TypoExpr *, TypoCorrection)>
3118 
3119 private:
3120  bool CppLookupName(LookupResult &R, Scope *S);
3121 
3122  struct TypoExprState {
3123  std::unique_ptr<TypoCorrectionConsumer> Consumer;
3124  TypoDiagnosticGenerator DiagHandler;
3125  TypoRecoveryCallback RecoveryHandler;
3126  TypoExprState();
3127  TypoExprState(TypoExprState &&other) noexcept;
3128  TypoExprState &operator=(TypoExprState &&other) noexcept;
3129  };
3130 
3131  /// The set of unhandled TypoExprs and their associated state.
3132  llvm::MapVector<TypoExpr *, TypoExprState> DelayedTypos;
3133 
3134  /// Creates a new TypoExpr AST node.
3135  TypoExpr *createDelayedTypo(std::unique_ptr<TypoCorrectionConsumer> TCC,
3136  TypoDiagnosticGenerator TDG,
3137  TypoRecoveryCallback TRC);
3138 
3139  // The set of known/encountered (unique, canonicalized) NamespaceDecls.
3140  //
3141  // The boolean value will be true to indicate that the namespace was loaded
3142  // from an AST/PCH file, or false otherwise.
3143  llvm::MapVector<NamespaceDecl*, bool> KnownNamespaces;
3144 
3145  /// Whether we have already loaded known namespaces from an extenal
3146  /// source.
3147  bool LoadedExternalKnownNamespaces;
3148 
3149  /// Helper for CorrectTypo and CorrectTypoDelayed used to create and
3150  /// populate a new TypoCorrectionConsumer. Returns nullptr if typo correction
3151  /// should be skipped entirely.
3152  std::unique_ptr<TypoCorrectionConsumer>
3153  makeTypoCorrectionConsumer(const DeclarationNameInfo &Typo,
3154  Sema::LookupNameKind LookupKind, Scope *S,
3155  CXXScopeSpec *SS,
3156  std::unique_ptr<CorrectionCandidateCallback> CCC,
3157  DeclContext *MemberContext, bool EnteringContext,
3158  const ObjCObjectPointerType *OPT,
3159  bool ErrorRecovery);
3160 
3161 public:
3162  const TypoExprState &getTypoExprState(TypoExpr *TE) const;
3163 
3164  /// Clears the state of the given TypoExpr.
3165  void clearDelayedTypo(TypoExpr *TE);
3166 
3167  /// Look up a name, looking for a single declaration. Return
3168  /// null if the results were absent, ambiguous, or overloaded.
3169  ///
3170  /// It is preferable to use the elaborated form and explicitly handle
3171  /// ambiguity and overloaded.
3172  NamedDecl *LookupSingleName(Scope *S, DeclarationName Name,
3173  SourceLocation Loc,
3174  LookupNameKind NameKind,
3175  RedeclarationKind Redecl
3176  = NotForRedeclaration);
3177  bool LookupName(LookupResult &R, Scope *S,
3178  bool AllowBuiltinCreation = false);
3179  bool LookupQualifiedName(LookupResult &R, DeclContext *LookupCtx,
3180  bool InUnqualifiedLookup = false);
3181  bool LookupQualifiedName(LookupResult &R, DeclContext *LookupCtx,
3182  CXXScopeSpec &SS);
3183  bool LookupParsedName(LookupResult &R, Scope *S, CXXScopeSpec *SS,
3184  bool AllowBuiltinCreation = false,
3185  bool EnteringContext = false);
3186  ObjCProtocolDecl *LookupProtocol(IdentifierInfo *II, SourceLocation IdLoc,
3187  RedeclarationKind Redecl
3188  = NotForRedeclaration);
3189  bool LookupInSuper(LookupResult &R, CXXRecordDecl *Class);
3190 
3191  void LookupOverloadedOperatorName(OverloadedOperatorKind Op, Scope *S,
3192  QualType T1, QualType T2,
3193  UnresolvedSetImpl &Functions);
3194 
3195  LabelDecl *LookupOrCreateLabel(IdentifierInfo *II, SourceLocation IdentLoc,
3196  SourceLocation GnuLabelLoc = SourceLocation());
3197 
3198  DeclContextLookupResult LookupConstructors(CXXRecordDecl *Class);
3199  CXXConstructorDecl *LookupDefaultConstructor(CXXRecordDecl *Class);
3200  CXXConstructorDecl *LookupCopyingConstructor(CXXRecordDecl *Class,
3201  unsigned Quals);
3202  CXXMethodDecl *LookupCopyingAssignment(CXXRecordDecl *Class, unsigned Quals,
3203  bool RValueThis, unsigned ThisQuals);
3204  CXXConstructorDecl *LookupMovingConstructor(CXXRecordDecl *Class,
3205  unsigned Quals);
3206  CXXMethodDecl *LookupMovingAssignment(CXXRecordDecl *Class, unsigned Quals,
3207  bool RValueThis, unsigned ThisQuals);
3208  CXXDestructorDecl *LookupDestructor(CXXRecordDecl *Class);
3209 
3210  bool checkLiteralOperatorId(const CXXScopeSpec &SS, const UnqualifiedId &Id);
3211  LiteralOperatorLookupResult LookupLiteralOperator(Scope *S, LookupResult &R,
3212  ArrayRef<QualType> ArgTys,
3213  bool AllowRaw,
3214  bool AllowTemplate,
3215  bool AllowStringTemplate,
3216  bool DiagnoseMissing);
3217  bool isKnownName(StringRef name);
3218 
3219  void ArgumentDependentLookup(DeclarationName Name, SourceLocation Loc,
3220  ArrayRef<Expr *> Args, ADLResult &Functions);
3221 
3222  void LookupVisibleDecls(Scope *S, LookupNameKind Kind,
3223  VisibleDeclConsumer &Consumer,
3224  bool IncludeGlobalScope = true,
3225  bool LoadExternal = true);
3227  VisibleDeclConsumer &Consumer,
3228  bool IncludeGlobalScope = true,
3229  bool IncludeDependentBases = false,
3230  bool LoadExternal = true);
3231 
3233  CTK_NonError, // CorrectTypo used in a non error recovery situation.
3234  CTK_ErrorRecovery // CorrectTypo used in normal error recovery.
3235  };
3236 
3237  TypoCorrection CorrectTypo(const DeclarationNameInfo &Typo,
3238  Sema::LookupNameKind LookupKind,
3239  Scope *S, CXXScopeSpec *SS,
3240  std::unique_ptr<CorrectionCandidateCallback> CCC,
3241  CorrectTypoKind Mode,
3242  DeclContext *MemberContext = nullptr,
3243  bool EnteringContext = false,
3244  const ObjCObjectPointerType *OPT = nullptr,
3245  bool RecordFailure = true);
3246 
3247  TypoExpr *CorrectTypoDelayed(const DeclarationNameInfo &Typo,
3248  Sema::LookupNameKind LookupKind, Scope *S,
3249  CXXScopeSpec *SS,
3250  std::unique_ptr<CorrectionCandidateCallback> CCC,
3251  TypoDiagnosticGenerator TDG,
3253  DeclContext *MemberContext = nullptr,
3254  bool EnteringContext = false,
3255  const ObjCObjectPointerType *OPT = nullptr);
3256 
3257  /// Process any TypoExprs in the given Expr and its children,
3258  /// generating diagnostics as appropriate and returning a new Expr if there
3259  /// were typos that were all successfully corrected and ExprError if one or
3260  /// more typos could not be corrected.
3261  ///
3262  /// \param E The Expr to check for TypoExprs.
3263  ///
3264  /// \param InitDecl A VarDecl to avoid because the Expr being corrected is its
3265  /// initializer.
3266  ///
3267  /// \param Filter A function applied to a newly rebuilt Expr to determine if
3268  /// it is an acceptable/usable result from a single combination of typo
3269  /// corrections. As long as the filter returns ExprError, different
3270  /// combinations of corrections will be tried until all are exhausted.
3271  ExprResult
3272  CorrectDelayedTyposInExpr(Expr *E, VarDecl *InitDecl = nullptr,
3273  llvm::function_ref<ExprResult(Expr *)> Filter =
3274  [](Expr *E) -> ExprResult { return E; });
3275 
3276  ExprResult
3278  llvm::function_ref<ExprResult(Expr *)> Filter) {
3279  return CorrectDelayedTyposInExpr(E, nullptr, Filter);
3280  }
3281 
3282  ExprResult
3283  CorrectDelayedTyposInExpr(ExprResult ER, VarDecl *InitDecl = nullptr,
3284  llvm::function_ref<ExprResult(Expr *)> Filter =
3285  [](Expr *E) -> ExprResult { return E; }) {
3286  return ER.isInvalid() ? ER : CorrectDelayedTyposInExpr(ER.get(), Filter);
3287  }
3288 
3289  ExprResult
3291  llvm::function_ref<ExprResult(Expr *)> Filter) {
3292  return CorrectDelayedTyposInExpr(ER, nullptr, Filter);
3293  }
3294 
3295  void diagnoseTypo(const TypoCorrection &Correction,
3296  const PartialDiagnostic &TypoDiag,
3297  bool ErrorRecovery = true);
3298 
3299  void diagnoseTypo(const TypoCorrection &Correction,
3300  const PartialDiagnostic &TypoDiag,
3301  const PartialDiagnostic &PrevNote,
3302  bool ErrorRecovery = true);
3303 
3304  void MarkTypoCorrectedFunctionDefinition(const NamedDecl *F);
3305 
3306  void FindAssociatedClassesAndNamespaces(SourceLocation InstantiationLoc,
3307  ArrayRef<Expr *> Args,
3308  AssociatedNamespaceSet &AssociatedNamespaces,
3309  AssociatedClassSet &AssociatedClasses);
3310 
3311  void FilterLookupForScope(LookupResult &R, DeclContext *Ctx, Scope *S,
3312  bool ConsiderLinkage, bool AllowInlineNamespace);
3313 
3314  bool CheckRedeclarationModuleOwnership(NamedDecl *New, NamedDecl *Old);
3315 
3316  void DiagnoseAmbiguousLookup(LookupResult &Result);
3317  //@}
3318 
3319  ObjCInterfaceDecl *getObjCInterfaceDecl(IdentifierInfo *&Id,
3320  SourceLocation IdLoc,
3321  bool TypoCorrection = false);
3322  NamedDecl *LazilyCreateBuiltin(IdentifierInfo *II, unsigned ID,
3323  Scope *S, bool ForRedeclaration,
3324  SourceLocation Loc);
3325  NamedDecl *ImplicitlyDefineFunction(SourceLocation Loc, IdentifierInfo &II,
3326  Scope *S);
3327  void AddKnownFunctionAttributes(FunctionDecl *FD);
3328 
3329  // More parsing and symbol table subroutines.
3330 
3331  void ProcessPragmaWeak(Scope *S, Decl *D);
3332  // Decl attributes - this routine is the top level dispatcher.
3333  void ProcessDeclAttributes(Scope *S, Decl *D, const Declarator &PD);
3334  // Helper for delayed processing of attributes.
3335  void ProcessDeclAttributeDelayed(Decl *D,
3336  const ParsedAttributesView &AttrList);
3337  void ProcessDeclAttributeList(Scope *S, Decl *D, const ParsedAttributesView &AL,
3338  bool IncludeCXX11Attributes = true);
3339  bool ProcessAccessDeclAttributeList(AccessSpecDecl *ASDecl,
3340  const ParsedAttributesView &AttrList);
3341 
3343 
3344  /// Determine if type T is a valid subject for a nonnull and similar
3345  /// attributes. By default, we look through references (the behavior used by
3346  /// nonnull), but if the second parameter is true, then we treat a reference
3347  /// type as valid.
3348  bool isValidPointerAttrType(QualType T, bool RefOkay = false);
3349 
3350  bool CheckRegparmAttr(const ParsedAttr &attr, unsigned &value);
3351  bool CheckCallingConvAttr(const ParsedAttr &attr, CallingConv &CC,
3352  const FunctionDecl *FD = nullptr);
3353  bool CheckAttrTarget(const ParsedAttr &CurrAttr);
3354  bool CheckAttrNoArgs(const ParsedAttr &CurrAttr);
3355  bool checkStringLiteralArgumentAttr(const ParsedAttr &Attr, unsigned ArgNum,
3356  StringRef &Str,
3357  SourceLocation *ArgLocation = nullptr);
3358  bool checkSectionName(SourceLocation LiteralLoc, StringRef Str);
3359  bool checkTargetAttr(SourceLocation LiteralLoc, StringRef Str);
3360  bool checkMSInheritanceAttrOnDefinition(
3361  CXXRecordDecl *RD, SourceRange Range, bool BestCase,
3362  MSInheritanceAttr::Spelling SemanticSpelling);
3363 
3364  void CheckAlignasUnderalignment(Decl *D);
3365 
3366  /// Adjust the calling convention of a method to be the ABI default if it
3367  /// wasn't specified explicitly. This handles method types formed from
3368  /// function type typedefs and typename template arguments.
3369  void adjustMemberFunctionCC(QualType &T, bool IsStatic, bool IsCtorOrDtor,
3370  SourceLocation Loc);
3371 
3372  // Check if there is an explicit attribute, but only look through parens.
3373  // The intent is to look for an attribute on the current declarator, but not
3374  // one that came from a typedef.
3375  bool hasExplicitCallingConv(QualType &T);
3376 
3377  /// Get the outermost AttributedType node that sets a calling convention.
3378  /// Valid types should not have multiple attributes with different CCs.
3379  const AttributedType *getCallingConvAttributedType(QualType T) const;
3380 
3381  /// Check whether a nullability type specifier can be added to the given
3382  /// type.
3383  ///
3384  /// \param type The type to which the nullability specifier will be
3385  /// added. On success, this type will be updated appropriately.
3386  ///
3387  /// \param nullability The nullability specifier to add.
3388  ///
3389  /// \param nullabilityLoc The location of the nullability specifier.
3390  ///
3391  /// \param isContextSensitive Whether this nullability specifier was
3392  /// written as a context-sensitive keyword (in an Objective-C
3393  /// method) or an Objective-C property attribute, rather than as an
3394  /// underscored type specifier.
3395  ///
3396  /// \param allowArrayTypes Whether to accept nullability specifiers on an
3397  /// array type (e.g., because it will decay to a pointer).
3398  ///
3399  /// \returns true if nullability cannot be applied, false otherwise.
3400  bool checkNullabilityTypeSpecifier(QualType &type, NullabilityKind nullability,
3401  SourceLocation nullabilityLoc,
3402  bool isContextSensitive,
3403  bool allowArrayTypes);
3404 
3405  /// Stmt attributes - this routine is the top level dispatcher.
3406  StmtResult ProcessStmtAttributes(Stmt *Stmt,
3407  const ParsedAttributesView &Attrs,
3408  SourceRange Range);
3409 
3410  void WarnConflictingTypedMethods(ObjCMethodDecl *Method,
3411  ObjCMethodDecl *MethodDecl,
3412  bool IsProtocolMethodDecl);
3413 
3414  void CheckConflictingOverridingMethod(ObjCMethodDecl *Method,
3415  ObjCMethodDecl *Overridden,
3416  bool IsProtocolMethodDecl);
3417 
3418  /// WarnExactTypedMethods - This routine issues a warning if method
3419  /// implementation declaration matches exactly that of its declaration.
3420  void WarnExactTypedMethods(ObjCMethodDecl *Method,
3421  ObjCMethodDecl *MethodDecl,
3422  bool IsProtocolMethodDecl);
3423 
3424  typedef llvm::SmallPtrSet<Selector, 8> SelectorSet;
3425 
3426  /// CheckImplementationIvars - This routine checks if the instance variables
3427  /// listed in the implelementation match those listed in the interface.
3428  void CheckImplementationIvars(ObjCImplementationDecl *ImpDecl,
3429  ObjCIvarDecl **Fields, unsigned nIvars,
3430  SourceLocation Loc);
3431 
3432  /// ImplMethodsVsClassMethods - This is main routine to warn if any method
3433  /// remains unimplemented in the class or category \@implementation.
3434  void ImplMethodsVsClassMethods(Scope *S, ObjCImplDecl* IMPDecl,
3435  ObjCContainerDecl* IDecl,
3436  bool IncompleteImpl = false);
3437 
3438  /// DiagnoseUnimplementedProperties - This routine warns on those properties
3439  /// which must be implemented by this implementation.
3440  void DiagnoseUnimplementedProperties(Scope *S, ObjCImplDecl* IMPDecl,
3441  ObjCContainerDecl *CDecl,
3442  bool SynthesizeProperties);
3443 
3444  /// Diagnose any null-resettable synthesized setters.
3445  void diagnoseNullResettableSynthesizedSetters(const ObjCImplDecl *impDecl);
3446 
3447  /// DefaultSynthesizeProperties - This routine default synthesizes all
3448  /// properties which must be synthesized in the class's \@implementation.
3449  void DefaultSynthesizeProperties(Scope *S, ObjCImplDecl *IMPDecl,
3450  ObjCInterfaceDecl *IDecl,
3451  SourceLocation AtEnd);
3452  void DefaultSynthesizeProperties(Scope *S, Decl *D, SourceLocation AtEnd);
3453 
3454  /// IvarBacksCurrentMethodAccessor - This routine returns 'true' if 'IV' is
3455  /// an ivar synthesized for 'Method' and 'Method' is a property accessor
3456  /// declared in class 'IFace'.
3457  bool IvarBacksCurrentMethodAccessor(ObjCInterfaceDecl *IFace,
3458  ObjCMethodDecl *Method, ObjCIvarDecl *IV);
3459 
3460  /// DiagnoseUnusedBackingIvarInAccessor - Issue an 'unused' warning if ivar which
3461  /// backs the property is not used in the property's accessor.
3462  void DiagnoseUnusedBackingIvarInAccessor(Scope *S,
3463  const ObjCImplementationDecl *ImplD);
3464 
3465  /// GetIvarBackingPropertyAccessor - If method is a property setter/getter and
3466  /// it property has a backing ivar, returns this ivar; otherwise, returns NULL.
3467  /// It also returns ivar's property on success.
3468  ObjCIvarDecl *GetIvarBackingPropertyAccessor(const ObjCMethodDecl *Method,
3469  const ObjCPropertyDecl *&PDecl) const;
3470 
3471  /// Called by ActOnProperty to handle \@property declarations in
3472  /// class extensions.
3473  ObjCPropertyDecl *HandlePropertyInClassExtension(Scope *S,
3474  SourceLocation AtLoc,
3475  SourceLocation LParenLoc,
3476  FieldDeclarator &FD,
3477  Selector GetterSel,
3478  SourceLocation GetterNameLoc,
3479  Selector SetterSel,
3480  SourceLocation SetterNameLoc,
3481  const bool isReadWrite,
3482  unsigned &Attributes,
3483  const unsigned AttributesAsWritten,
3484  QualType T,
3485  TypeSourceInfo *TSI,
3486  tok::ObjCKeywordKind MethodImplKind);
3487 
3488  /// Called by ActOnProperty and HandlePropertyInClassExtension to
3489  /// handle creating the ObjcPropertyDecl for a category or \@interface.
3490  ObjCPropertyDecl *CreatePropertyDecl(Scope *S,
3491  ObjCContainerDecl *CDecl,
3492  SourceLocation AtLoc,
3493  SourceLocation LParenLoc,
3494  FieldDeclarator &FD,
3495  Selector GetterSel,
3496  SourceLocation GetterNameLoc,
3497  Selector SetterSel,
3498  SourceLocation SetterNameLoc,
3499  const bool isReadWrite,
3500  const unsigned Attributes,
3501  const unsigned AttributesAsWritten,
3502  QualType T,
3503  TypeSourceInfo *TSI,
3504  tok::ObjCKeywordKind MethodImplKind,
3505  DeclContext *lexicalDC = nullptr);
3506 
3507  /// AtomicPropertySetterGetterRules - This routine enforces the rule (via
3508  /// warning) when atomic property has one but not the other user-declared
3509  /// setter or getter.
3510  void AtomicPropertySetterGetterRules(ObjCImplDecl* IMPDecl,
3511  ObjCInterfaceDecl* IDecl);
3512 
3513  void DiagnoseOwningPropertyGetterSynthesis(const ObjCImplementationDecl *D);
3514 
3515  void DiagnoseMissingDesignatedInitOverrides(
3516  const ObjCImplementationDecl *ImplD,
3517  const ObjCInterfaceDecl *IFD);
3518 
3519  void DiagnoseDuplicateIvars(ObjCInterfaceDecl *ID, ObjCInterfaceDecl *SID);
3520 
3523  MMS_strict
3524  };
3525 
3526  /// MatchTwoMethodDeclarations - Checks if two methods' type match and returns
3527  /// true, or false, accordingly.
3528  bool MatchTwoMethodDeclarations(const ObjCMethodDecl *Method,
3529  const ObjCMethodDecl *PrevMethod,
3530  MethodMatchStrategy strategy = MMS_strict);
3531 
3532  /// MatchAllMethodDeclarations - Check methods declaraed in interface or
3533  /// or protocol against those declared in their implementations.
3534  void MatchAllMethodDeclarations(const SelectorSet &InsMap,
3535  const SelectorSet &ClsMap,
3536  SelectorSet &InsMapSeen,
3537  SelectorSet &ClsMapSeen,
3538  ObjCImplDecl* IMPDecl,
3539  ObjCContainerDecl* IDecl,
3540  bool &IncompleteImpl,
3541  bool ImmediateClass,
3542  bool WarnCategoryMethodImpl=false);
3543 
3544  /// CheckCategoryVsClassMethodMatches - Checks that methods implemented in
3545  /// category matches with those implemented in its primary class and
3546  /// warns each time an exact match is found.
3547  void CheckCategoryVsClassMethodMatches(ObjCCategoryImplDecl *CatIMP);
3548 
3549  /// Add the given method to the list of globally-known methods.
3550  void addMethodToGlobalList(ObjCMethodList *List, ObjCMethodDecl *Method);
3551 
3552 private:
3553  /// AddMethodToGlobalPool - Add an instance or factory method to the global
3554  /// pool. See descriptoin of AddInstanceMethodToGlobalPool.
3555  void AddMethodToGlobalPool(ObjCMethodDecl *Method, bool impl, bool instance);
3556 
3557  /// LookupMethodInGlobalPool - Returns the instance or factory method and
3558  /// optionally warns if there are multiple signatures.
3559  ObjCMethodDecl *LookupMethodInGlobalPool(Selector Sel, SourceRange R,
3560  bool receiverIdOrClass,
3561  bool instance);
3562 
3563 public:
3564  /// - Returns instance or factory methods in global method pool for
3565  /// given selector. It checks the desired kind first, if none is found, and
3566  /// parameter checkTheOther is set, it then checks the other kind. If no such
3567  /// method or only one method is found, function returns false; otherwise, it
3568  /// returns true.
3569  bool
3570  CollectMultipleMethodsInGlobalPool(Selector Sel,
3572  bool InstanceFirst, bool CheckTheOther,
3573  const ObjCObjectType *TypeBound = nullptr);
3574 
3575  bool
3576  AreMultipleMethodsInGlobalPool(Selector Sel, ObjCMethodDecl *BestMethod,
3577  SourceRange R, bool receiverIdOrClass,
3579 
3580  void
3581  DiagnoseMultipleMethodInGlobalPool(SmallVectorImpl<ObjCMethodDecl*> &Methods,
3582  Selector Sel, SourceRange R,
3583  bool receiverIdOrClass);
3584 
3585 private:
3586  /// - Returns a selector which best matches given argument list or
3587  /// nullptr if none could be found
3588  ObjCMethodDecl *SelectBestMethod(Selector Sel, MultiExprArg Args,
3589  bool IsInstance,
3591 
3592 
3593  /// Record the typo correction failure and return an empty correction.
3594  TypoCorrection FailedCorrection(IdentifierInfo *Typo, SourceLocation TypoLoc,
3595  bool RecordFailure = true) {
3596  if (RecordFailure)
3597  TypoCorrectionFailures[Typo].insert(TypoLoc);
3598  return TypoCorrection();
3599  }
3600 
3601 public:
3602  /// AddInstanceMethodToGlobalPool - All instance methods in a translation
3603  /// unit are added to a global pool. This allows us to efficiently associate
3604  /// a selector with a method declaraation for purposes of typechecking
3605  /// messages sent to "id" (where the class of the object is unknown).
3606  void AddInstanceMethodToGlobalPool(ObjCMethodDecl *Method, bool impl=false) {
3607  AddMethodToGlobalPool(Method, impl, /*instance*/true);
3608  }
3609 
3610  /// AddFactoryMethodToGlobalPool - Same as above, but for factory methods.
3611  void AddFactoryMethodToGlobalPool(ObjCMethodDecl *Method, bool impl=false) {
3612  AddMethodToGlobalPool(Method, impl, /*instance*/false);
3613  }
3614 
3615  /// AddAnyMethodToGlobalPool - Add any method, instance or factory to global
3616  /// pool.
3617  void AddAnyMethodToGlobalPool(Decl *D);
3618 
3619  /// LookupInstanceMethodInGlobalPool - Returns the method and warns if
3620  /// there are multiple signatures.
3622  bool receiverIdOrClass=false) {
3623  return LookupMethodInGlobalPool(Sel, R, receiverIdOrClass,
3624  /*instance*/true);
3625  }
3626 
3627  /// LookupFactoryMethodInGlobalPool - Returns the method and warns if
3628  /// there are multiple signatures.
3630  bool receiverIdOrClass=false) {
3631  return LookupMethodInGlobalPool(Sel, R, receiverIdOrClass,
3632  /*instance*/false);
3633  }
3634 
3635  const ObjCMethodDecl *SelectorsForTypoCorrection(Selector Sel,
3636  QualType ObjectType=QualType());
3637  /// LookupImplementedMethodInGlobalPool - Returns the method which has an
3638  /// implementation.
3639  ObjCMethodDecl *LookupImplementedMethodInGlobalPool(Selector Sel);
3640 
3641  /// CollectIvarsToConstructOrDestruct - Collect those ivars which require
3642  /// initialization.
3643  void CollectIvarsToConstructOrDestruct(ObjCInterfaceDecl *OI,
3645 
3646  //===--------------------------------------------------------------------===//
3647  // Statement Parsing Callbacks: SemaStmt.cpp.
3648 public:
3649  class FullExprArg {
3650  public:
3651  FullExprArg() : E(nullptr) { }
3652  FullExprArg(Sema &actions) : E(nullptr) { }
3653 
3655  return E;
3656  }
3657 
3658  Expr *get() const { return E; }
3659 
3661  return E;
3662  }
3663 
3664  private:
3665  // FIXME: No need to make the entire Sema class a friend when it's just
3666  // Sema::MakeFullExpr that needs access to the constructor below.
3667  friend class Sema;
3668 
3669  explicit FullExprArg(Expr *expr) : E(expr) {}
3670 
3671  Expr *E;
3672  };
3673 
3675  return MakeFullExpr(Arg, Arg ? Arg->getExprLoc() : SourceLocation());
3676  }
3678  return FullExprArg(ActOnFinishFullExpr(Arg, CC).get());
3679  }
3681  ExprResult FE =
3682  ActOnFinishFullExpr(Arg, Arg ? Arg->getExprLoc() : SourceLocation(),
3683  /*DiscardedValue*/ true);
3684  return FullExprArg(FE.get());
3685  }
3686 
3687  StmtResult ActOnExprStmt(ExprResult Arg);
3688  StmtResult ActOnExprStmtError();
3689 
3690  StmtResult ActOnNullStmt(SourceLocation SemiLoc,
3691  bool HasLeadingEmptyMacro = false);
3692 
3693  void ActOnStartOfCompoundStmt(bool IsStmtExpr);
3694  void ActOnFinishOfCompoundStmt();
3695  StmtResult ActOnCompoundStmt(SourceLocation L, SourceLocation R,
3696  ArrayRef<Stmt *> Elts, bool isStmtExpr);
3697 
3698  /// A RAII object to enter scope of a compound statement.
3700  public:
3701  CompoundScopeRAII(Sema &S, bool IsStmtExpr = false) : S(S) {
3702  S.ActOnStartOfCompoundStmt(IsStmtExpr);
3703  }
3704 
3706  S.ActOnFinishOfCompoundStmt();
3707  }
3708 
3709  private:
3710  Sema &S;
3711  };
3712 
3713  /// An RAII helper that pops function a function scope on exit.
3716  bool Active;
3717  FunctionScopeRAII(Sema &S) : S(S), Active(true) {}
3719  if (Active)
3721  }
3722  void disable() { Active = false; }
3723  };
3724 
3725  StmtResult ActOnDeclStmt(DeclGroupPtrTy Decl,
3726  SourceLocation StartLoc,
3727  SourceLocation EndLoc);
3728  void ActOnForEachDeclStmt(DeclGroupPtrTy Decl);
3729  StmtResult ActOnForEachLValueExpr(Expr *E);
3730  ExprResult ActOnCaseExpr(SourceLocation CaseLoc, ExprResult Val);
3731  StmtResult ActOnCaseStmt(SourceLocation CaseLoc, ExprResult LHS,
3732  SourceLocation DotDotDotLoc, ExprResult RHS,
3734  void ActOnCaseStmtBody(Stmt *CaseStmt, Stmt *SubStmt);
3735 
3736  StmtResult ActOnDefaultStmt(SourceLocation DefaultLoc,
3737  SourceLocation ColonLoc,
3738  Stmt *SubStmt, Scope *CurScope);
3739  StmtResult ActOnLabelStmt(SourceLocation IdentLoc, LabelDecl *TheDecl,
3740  SourceLocation ColonLoc, Stmt *SubStmt);
3741 
3742  StmtResult ActOnAttributedStmt(SourceLocation AttrLoc,
3743  ArrayRef<const Attr*> Attrs,
3744  Stmt *SubStmt);
3745 
3746  class ConditionResult;
3747  StmtResult ActOnIfStmt(SourceLocation IfLoc, bool IsConstexpr,
3748  Stmt *InitStmt,
3749  ConditionResult Cond, Stmt *ThenVal,
3750  SourceLocation ElseLoc, Stmt *ElseVal);
3751  StmtResult BuildIfStmt(SourceLocation IfLoc, bool IsConstexpr,
3752  Stmt *InitStmt,
3753  ConditionResult Cond, Stmt *ThenVal,
3754  SourceLocation ElseLoc, Stmt *ElseVal);
3755  StmtResult ActOnStartOfSwitchStmt(SourceLocation SwitchLoc,
3756  Stmt *InitStmt,
3757  ConditionResult Cond);
3758  StmtResult ActOnFinishSwitchStmt(SourceLocation SwitchLoc,
3759  Stmt *Switch, Stmt *Body);
3760  StmtResult ActOnWhileStmt(SourceLocation WhileLoc, ConditionResult Cond,
3761  Stmt *Body);
3762  StmtResult ActOnDoStmt(SourceLocation DoLoc, Stmt *Body,
3763  SourceLocation WhileLoc, SourceLocation CondLParen,
3764  Expr *Cond, SourceLocation CondRParen);
3765 
3766  StmtResult ActOnForStmt(SourceLocation ForLoc,
3767  SourceLocation LParenLoc,
3768  Stmt *First,
3769  ConditionResult Second,
3770  FullExprArg Third,
3771  SourceLocation RParenLoc,
3772  Stmt *Body);
3773  ExprResult CheckObjCForCollectionOperand(SourceLocation forLoc,
3774  Expr *collection);
3775  StmtResult ActOnObjCForCollectionStmt(SourceLocation ForColLoc,
3776  Stmt *First, Expr *collection,
3777  SourceLocation RParenLoc);
3778  StmtResult FinishObjCForCollectionStmt(Stmt *ForCollection, Stmt *Body);
3779 
3781  /// Initial building of a for-range statement.
3783  /// Instantiation or recovery rebuild of a for-range statement. Don't
3784  /// attempt any typo-correction.
3786  /// Determining whether a for-range statement could be built. Avoid any
3787  /// unnecessary or irreversible actions.
3788  BFRK_Check
3789  };
3790 
3791  StmtResult ActOnCXXForRangeStmt(Scope *S, SourceLocation ForLoc,
3792  SourceLocation CoawaitLoc,
3793  Stmt *LoopVar,
3794  SourceLocation ColonLoc, Expr *Collection,
3795  SourceLocation RParenLoc,
3797  StmtResult BuildCXXForRangeStmt(SourceLocation ForLoc,
3798  SourceLocation CoawaitLoc,
3799  SourceLocation ColonLoc,
3800  Stmt *RangeDecl, Stmt *Begin, Stmt *End,
3801  Expr *Cond, Expr *Inc,
3802  Stmt *LoopVarDecl,
3803  SourceLocation RParenLoc,
3805  StmtResult FinishCXXForRangeStmt(Stmt *ForRange, Stmt *Body);
3806 
3807  StmtResult ActOnGotoStmt(SourceLocation GotoLoc,
3808  SourceLocation LabelLoc,
3809  LabelDecl *TheDecl);
3810  StmtResult ActOnIndirectGotoStmt(SourceLocation GotoLoc,
3811  SourceLocation StarLoc,
3812  Expr *DestExp);
3813  StmtResult ActOnContinueStmt(SourceLocation ContinueLoc, Scope *CurScope);
3814  StmtResult ActOnBreakStmt(SourceLocation BreakLoc, Scope *CurScope);
3815 
3816  void ActOnCapturedRegionStart(SourceLocation Loc, Scope *CurScope,
3817  CapturedRegionKind Kind, unsigned NumParams);
3818  typedef std::pair<StringRef, QualType> CapturedParamNameType;
3819  void ActOnCapturedRegionStart(SourceLocation Loc, Scope *CurScope,
3822  StmtResult ActOnCapturedRegionEnd(Stmt *S);
3823  void ActOnCapturedRegionError();
3824  RecordDecl *CreateCapturedStmtRecordDecl(CapturedDecl *&CD,
3825  SourceLocation Loc,
3826  unsigned NumParams);
3827 
3829  CES_Strict = 0,
3830  CES_AllowParameters = 1,
3831  CES_AllowDifferentTypes = 2,
3832  CES_AllowExceptionVariables = 4,
3833  CES_FormerDefault = (CES_AllowParameters),
3834  CES_Default = (CES_AllowParameters | CES_AllowDifferentTypes),
3835  CES_AsIfByStdMove = (CES_AllowParameters | CES_AllowDifferentTypes |
3836  CES_AllowExceptionVariables),
3837  };
3838 
3839  VarDecl *getCopyElisionCandidate(QualType ReturnType, Expr *E,
3841  bool isCopyElisionCandidate(QualType ReturnType, const VarDecl *VD,
3843 
3844  StmtResult ActOnReturnStmt(SourceLocation ReturnLoc, Expr *RetValExp,
3845  Scope *CurScope);
3846  StmtResult BuildReturnStmt(SourceLocation ReturnLoc, Expr *RetValExp);
3847  StmtResult ActOnCapScopeReturnStmt(SourceLocation ReturnLoc, Expr *RetValExp);
3848 
3849  StmtResult ActOnGCCAsmStmt(SourceLocation AsmLoc, bool IsSimple,
3850  bool IsVolatile, unsigned NumOutputs,
3851  unsigned NumInputs, IdentifierInfo **Names,
3852  MultiExprArg Constraints, MultiExprArg Exprs,
3853  Expr *AsmString, MultiExprArg Clobbers,
3854  SourceLocation RParenLoc);
3855 
3856  void FillInlineAsmIdentifierInfo(Expr *Res,
3857  llvm::InlineAsmIdentifierInfo &Info);
3858  ExprResult LookupInlineAsmIdentifier(CXXScopeSpec &SS,
3859  SourceLocation TemplateKWLoc,
3860  UnqualifiedId &Id,
3861  bool IsUnevaluatedContext);
3862  bool LookupInlineAsmField(StringRef Base, StringRef Member,
3863  unsigned &Offset, SourceLocation AsmLoc);
3864  ExprResult LookupInlineAsmVarDeclField(Expr *RefExpr, StringRef Member,
3865  SourceLocation AsmLoc);
3866  StmtResult ActOnMSAsmStmt(SourceLocation AsmLoc, SourceLocation LBraceLoc,
3867  ArrayRef<Token> AsmToks,
3868  StringRef AsmString,
3869  unsigned NumOutputs, unsigned NumInputs,
3870  ArrayRef<StringRef> Constraints,
3871  ArrayRef<StringRef> Clobbers,
3872  ArrayRef<Expr*> Exprs,
3873  SourceLocation EndLoc);
3874  LabelDecl *GetOrCreateMSAsmLabel(StringRef ExternalLabelName,
3875  SourceLocation Location,
3876  bool AlwaysCreate);
3877 
3878  VarDecl *BuildObjCExceptionDecl(TypeSourceInfo *TInfo, QualType ExceptionType,
3879  SourceLocation StartLoc,
3880  SourceLocation IdLoc, IdentifierInfo *Id,
3881  bool Invalid = false);
3882 
3883  Decl *ActOnObjCExceptionDecl(Scope *S, Declarator &D);
3884 
3885  StmtResult ActOnObjCAtCatchStmt(SourceLocation AtLoc, SourceLocation RParen,
3886  Decl *Parm, Stmt *Body);
3887 
3888  StmtResult ActOnObjCAtFinallyStmt(SourceLocation AtLoc, Stmt *Body);
3889 
3890  StmtResult ActOnObjCAtTryStmt(SourceLocation AtLoc, Stmt *Try,
3891  MultiStmtArg Catch, Stmt *Finally);
3892 
3893  StmtResult BuildObjCAtThrowStmt(SourceLocation AtLoc, Expr *Throw);
3894  StmtResult ActOnObjCAtThrowStmt(SourceLocation AtLoc, Expr *Throw,
3895  Scope *CurScope);
3896  ExprResult ActOnObjCAtSynchronizedOperand(SourceLocation atLoc,
3897  Expr *operand);
3898  StmtResult ActOnObjCAtSynchronizedStmt(SourceLocation AtLoc,
3899  Expr *SynchExpr,
3900  Stmt *SynchBody);
3901 
3902  StmtResult ActOnObjCAutoreleasePoolStmt(SourceLocation AtLoc, Stmt *Body);
3903 
3904  VarDecl *BuildExceptionDeclaration(Scope *S, TypeSourceInfo *TInfo,
3905  SourceLocation StartLoc,
3906  SourceLocation IdLoc,
3907  IdentifierInfo *Id);
3908 
3909  Decl *ActOnExceptionDeclarator(Scope *S, Declarator &D);
3910 
3911  StmtResult ActOnCXXCatchBlock(SourceLocation CatchLoc,
3912  Decl *ExDecl, Stmt *HandlerBlock);
3913  StmtResult ActOnCXXTryBlock(SourceLocation TryLoc, Stmt *TryBlock,
3914  ArrayRef<Stmt *> Handlers);
3915 
3916  StmtResult ActOnSEHTryBlock(bool IsCXXTry, // try (true) or __try (false) ?
3917  SourceLocation TryLoc, Stmt *TryBlock,
3918  Stmt *Handler);
3919  StmtResult ActOnSEHExceptBlock(SourceLocation Loc,
3920  Expr *FilterExpr,
3921  Stmt *Block);
3922  void ActOnStartSEHFinallyBlock();
3923  void ActOnAbortSEHFinallyBlock();
3924  StmtResult ActOnFinishSEHFinallyBlock(SourceLocation Loc, Stmt *Block);
3925  StmtResult ActOnSEHLeaveStmt(SourceLocation Loc, Scope *CurScope);
3926 
3927  void DiagnoseReturnInConstructorExceptionHandler(CXXTryStmt *TryBlock);
3928 
3929  bool ShouldWarnIfUnusedFileScopedDecl(const DeclaratorDecl *D) const;
3930 
3931  /// If it's a file scoped decl that must warn if not used, keep track
3932  /// of it.
3933  void MarkUnusedFileScopedDecl(const DeclaratorDecl *D);
3934 
3935  /// DiagnoseUnusedExprResult - If the statement passed in is an expression
3936  /// whose result is unused, warn.
3937  void DiagnoseUnusedExprResult(const Stmt *S);
3938  void DiagnoseUnusedNestedTypedefs(const RecordDecl *D);
3939  void DiagnoseUnusedDecl(const NamedDecl *ND);
3940 
3941  /// Emit \p DiagID if statement located on \p StmtLoc has a suspicious null
3942  /// statement as a \p Body, and it is located on the same line.
3943  ///
3944  /// This helps prevent bugs due to typos, such as:
3945  /// if (condition);
3946  /// do_stuff();
3947  void DiagnoseEmptyStmtBody(SourceLocation StmtLoc,
3948  const Stmt *Body,
3949  unsigned DiagID);
3950 
3951  /// Warn if a for/while loop statement \p S, which is followed by
3952  /// \p PossibleBody, has a suspicious null statement as a body.
3953  void DiagnoseEmptyLoopBody(const Stmt *S,
3954  const Stmt *PossibleBody);
3955 
3956  /// Warn if a value is moved to itself.
3957  void DiagnoseSelfMove(const Expr *LHSExpr, const Expr *RHSExpr,
3958  SourceLocation OpLoc);
3959 
3960  /// Warn if we're implicitly casting from a _Nullable pointer type to a
3961  /// _Nonnull one.
3962  void diagnoseNullableToNonnullConversion(QualType DstType, QualType SrcType,
3963  SourceLocation Loc);
3964 
3965  /// Warn when implicitly casting 0 to nullptr.
3966  void diagnoseZeroToNullptrConversion(CastKind Kind, const Expr *E);
3967 
3969  return DelayedDiagnostics.push(pool);
3970  }
3971  void PopParsingDeclaration(ParsingDeclState state, Decl *decl);
3972 
3973  typedef ProcessingContextState ParsingClassState;
3974  ParsingClassState PushParsingClass() {
3976  }
3977  void PopParsingClass(ParsingClassState state) {
3979  }
3980 
3981  void redelayDiagnostics(sema::DelayedDiagnosticPool &pool);
3982 
3983  void DiagnoseAvailabilityOfDecl(NamedDecl *D, ArrayRef<SourceLocation> Locs,
3984  const ObjCInterfaceDecl *UnknownObjCClass,
3985  bool ObjCPropertyAccess,
3986  bool AvoidPartialAvailabilityChecks = false);
3987 
3988  bool makeUnavailableInSystemHeader(SourceLocation loc,
3989  UnavailableAttr::ImplicitReason reason);
3990 
3991  /// Issue any -Wunguarded-availability warnings in \c FD
3992  void DiagnoseUnguardedAvailabilityViolations(Decl *FD);
3993 
3994  //===--------------------------------------------------------------------===//
3995  // Expression Parsing Callbacks: SemaExpr.cpp.
3996 
3997  bool CanUseDecl(NamedDecl *D, bool TreatUnavailableAsInvalid);
3998  bool DiagnoseUseOfDecl(NamedDecl *D, ArrayRef<SourceLocation> Locs,
3999  const ObjCInterfaceDecl *UnknownObjCClass = nullptr,
4000  bool ObjCPropertyAccess = false,
4001  bool AvoidPartialAvailabilityChecks = false);
4002  void NoteDeletedFunction(FunctionDecl *FD);
4003  void NoteDeletedInheritingConstructor(CXXConstructorDecl *CD);
4004  std::string getDeletedOrUnavailableSuffix(const FunctionDecl *FD);
4005  bool DiagnosePropertyAccessorMismatch(ObjCPropertyDecl *PD,
4006  ObjCMethodDecl *Getter,
4007  SourceLocation Loc);
4008  void DiagnoseSentinelCalls(NamedDecl *D, SourceLocation Loc,
4009  ArrayRef<Expr *> Args);
4010 
4011  void PushExpressionEvaluationContext(
4012  ExpressionEvaluationContext NewContext, Decl *LambdaContextDecl = nullptr,
4014  ExpressionEvaluationContextRecord::EK_Other);
4015  enum ReuseLambdaContextDecl_t { ReuseLambdaContextDecl };
4016  void PushExpressionEvaluationContext(
4019  ExpressionEvaluationContextRecord::EK_Other);
4020  void PopExpressionEvaluationContext();
4021 
4022  void DiscardCleanupsInEvaluationContext();
4023 
4024  ExprResult TransformToPotentiallyEvaluated(Expr *E);
4025  ExprResult HandleExprEvaluationContextForTypeof(Expr *E);
4026 
4027  ExprResult ActOnConstantExpression(ExprResult Res);
4028 
4029  // Functions for marking a declaration referenced. These functions also
4030  // contain the relevant logic for marking if a reference to a function or
4031  // variable is an odr-use (in the C++11 sense). There are separate variants
4032  // for expressions referring to a decl; these exist because odr-use marking
4033  // needs to be delayed for some constant variables when we build one of the
4034  // named expressions.
4035  //
4036  // MightBeOdrUse indicates whether the use could possibly be an odr-use, and
4037  // should usually be true. This only needs to be set to false if the lack of
4038  // odr-use cannot be determined from the current context (for instance,
4039  // because the name denotes a virtual function and was written without an
4040  // explicit nested-name-specifier).
4041  void MarkAnyDeclReferenced(SourceLocation Loc, Decl *D, bool MightBeOdrUse);
4042  void MarkFunctionReferenced(SourceLocation Loc, FunctionDecl *Func,
4043  bool MightBeOdrUse = true);
4044  void MarkVariableReferenced(SourceLocation Loc, VarDecl *Var);
4045  void MarkDeclRefReferenced(DeclRefExpr *E, const Expr *Base = nullptr);
4046  void MarkMemberReferenced(MemberExpr *E);
4047 
4048  void UpdateMarkingForLValueToRValue(Expr *E);
4049  void CleanupVarDeclMarking();
4050 
4052  TryCapture_Implicit, TryCapture_ExplicitByVal, TryCapture_ExplicitByRef
4053  };
4054 
4055  /// Try to capture the given variable.
4056  ///
4057  /// \param Var The variable to capture.
4058  ///
4059  /// \param Loc The location at which the capture occurs.
4060  ///
4061  /// \param Kind The kind of capture, which may be implicit (for either a
4062  /// block or a lambda), or explicit by-value or by-reference (for a lambda).
4063  ///
4064  /// \param EllipsisLoc The location of the ellipsis, if one is provided in
4065  /// an explicit lambda capture.
4066  ///
4067  /// \param BuildAndDiagnose Whether we are actually supposed to add the
4068  /// captures or diagnose errors. If false, this routine merely check whether
4069  /// the capture can occur without performing the capture itself or complaining
4070  /// if the variable cannot be captured.
4071  ///
4072  /// \param CaptureType Will be set to the type of the field used to capture
4073  /// this variable in the innermost block or lambda. Only valid when the
4074  /// variable can be captured.
4075  ///
4076  /// \param DeclRefType Will be set to the type of a reference to the capture
4077  /// from within the current scope. Only valid when the variable can be
4078  /// captured.
4079  ///
4080  /// \param FunctionScopeIndexToStopAt If non-null, it points to the index
4081  /// of the FunctionScopeInfo stack beyond which we do not attempt to capture.
4082  /// This is useful when enclosing lambdas must speculatively capture
4083  /// variables that may or may not be used in certain specializations of
4084  /// a nested generic lambda.
4085  ///
4086  /// \returns true if an error occurred (i.e., the variable cannot be
4087  /// captured) and false if the capture succeeded.
4088  bool tryCaptureVariable(VarDecl *Var, SourceLocation Loc, TryCaptureKind Kind,
4089  SourceLocation EllipsisLoc, bool BuildAndDiagnose,
4090  QualType &CaptureType,
4091  QualType &DeclRefType,
4092  const unsigned *const FunctionScopeIndexToStopAt);
4093 
4094  /// Try to capture the given variable.
4095  bool tryCaptureVariable(VarDecl *Var, SourceLocation Loc,
4096  TryCaptureKind Kind = TryCapture_Implicit,
4097  SourceLocation EllipsisLoc = SourceLocation());
4098 
4099  /// Checks if the variable must be captured.
4100  bool NeedToCaptureVariable(VarDecl *Var, SourceLocation Loc);
4101 
4102  /// Given a variable, determine the type that a reference to that
4103  /// variable will have in the given scope.
4104  QualType getCapturedDeclRefType(VarDecl *Var, SourceLocation Loc);
4105 
4106  /// Mark all of the declarations referenced within a particular AST node as
4107  /// referenced. Used when template instantiation instantiates a non-dependent
4108  /// type -- entities referenced by the type are now referenced.
4109  void MarkDeclarationsReferencedInType(SourceLocation Loc, QualType T);
4110  void MarkDeclarationsReferencedInExpr(Expr *E,
4111  bool SkipLocalVariables = false);
4112 
4113  /// Try to recover by turning the given expression into a
4114  /// call. Returns true if recovery was attempted or an error was
4115  /// emitted; this may also leave the ExprResult invalid.
4116  bool tryToRecoverWithCall(ExprResult &E, const PartialDiagnostic &PD,
4117  bool ForceComplain = false,
4118  bool (*IsPlausibleResult)(QualType) = nullptr);
4119 
4120  /// Figure out if an expression could be turned into a call.
4121  bool tryExprAsCall(Expr &E, QualType &ZeroArgCallReturnTy,
4122  UnresolvedSetImpl &NonTemplateOverloads);
4123 
4124  /// Conditionally issue a diagnostic based on the current
4125  /// evaluation context.
4126  ///
4127  /// \param Statement If Statement is non-null, delay reporting the
4128  /// diagnostic until the function body is parsed, and then do a basic
4129  /// reachability analysis to determine if the statement is reachable.
4130  /// If it is unreachable, the diagnostic will not be emitted.
4131  bool DiagRuntimeBehavior(SourceLocation Loc, const Stmt *Statement,
4132  const PartialDiagnostic &PD);
4133 
4134  // Primary Expressions.
4135  SourceRange getExprRange(Expr *E) const;
4136 
4137  ExprResult ActOnIdExpression(
4138  Scope *S, CXXScopeSpec &SS, SourceLocation TemplateKWLoc,
4139  UnqualifiedId &Id, bool HasTrailingLParen, bool IsAddressOfOperand,
4140  std::unique_ptr<CorrectionCandidateCallback> CCC = nullptr,
4141  bool IsInlineAsmIdentifier = false, Token *KeywordReplacement = nullptr);
4142 
4143  void DecomposeUnqualifiedId(const UnqualifiedId &Id,
4144  TemplateArgumentListInfo &Buffer,
4145  DeclarationNameInfo &NameInfo,
4146  const TemplateArgumentListInfo *&TemplateArgs);
4147 
4148  bool
4149  DiagnoseEmptyLookup(Scope *S, CXXScopeSpec &SS, LookupResult &R,
4150  std::unique_ptr<CorrectionCandidateCallback> CCC,
4151  TemplateArgumentListInfo *ExplicitTemplateArgs = nullptr,
4152  ArrayRef<Expr *> Args = None, TypoExpr **Out = nullptr);
4153 
4154  ExprResult LookupInObjCMethod(LookupResult &LookUp, Scope *S,
4155  IdentifierInfo *II,
4156  bool AllowBuiltinCreation=false);
4157 
4158  ExprResult ActOnDependentIdExpression(const CXXScopeSpec &SS,
4159  SourceLocation TemplateKWLoc,
4160  const DeclarationNameInfo &NameInfo,
4161  bool isAddressOfOperand,
4162  const TemplateArgumentListInfo *TemplateArgs);
4163 
4164  ExprResult BuildDeclRefExpr(ValueDecl *D, QualType Ty,
4165  ExprValueKind VK,
4166  SourceLocation Loc,
4167  const CXXScopeSpec *SS = nullptr);
4168  ExprResult
4169  BuildDeclRefExpr(ValueDecl *D, QualType Ty, ExprValueKind VK,
4170  const DeclarationNameInfo &NameInfo,
4171  const CXXScopeSpec *SS = nullptr,
4172  NamedDecl *FoundD = nullptr,
4173  const TemplateArgumentListInfo *TemplateArgs = nullptr);
4174  ExprResult
4175  BuildAnonymousStructUnionMemberReference(
4176  const CXXScopeSpec &SS,
4177  SourceLocation nameLoc,
4178  IndirectFieldDecl *indirectField,
4179  DeclAccessPair FoundDecl = DeclAccessPair::make(nullptr, AS_none),
4180  Expr *baseObjectExpr = nullptr,
4181  SourceLocation opLoc = SourceLocation());
4182 
4183  ExprResult BuildPossibleImplicitMemberExpr(const CXXScopeSpec &SS,
4184  SourceLocation TemplateKWLoc,
4185  LookupResult &R,
4186  const TemplateArgumentListInfo *TemplateArgs,
4187  const Scope *S);
4188  ExprResult BuildImplicitMemberExpr(const CXXScopeSpec &SS,
4189  SourceLocation TemplateKWLoc,
4190  LookupResult &R,
4191  const TemplateArgumentListInfo *TemplateArgs,
4192  bool IsDefiniteInstance,
4193  const Scope *S);
4194  bool UseArgumentDependentLookup(const CXXScopeSpec &SS,
4195  const LookupResult &R,
4196  bool HasTrailingLParen);
4197 
4198  ExprResult
4199  BuildQualifiedDeclarationNameExpr(CXXScopeSpec &SS,
4200  const DeclarationNameInfo &NameInfo,
4201  bool IsAddressOfOperand, const Scope *S,
4202  TypeSourceInfo **RecoveryTSI = nullptr);
4203 
4204  ExprResult BuildDependentDeclRefExpr(const CXXScopeSpec &SS,
4205  SourceLocation TemplateKWLoc,
4206  const DeclarationNameInfo &NameInfo,
4207  const TemplateArgumentListInfo *TemplateArgs);
4208 
4209  ExprResult BuildDeclarationNameExpr(const CXXScopeSpec &SS,
4210  LookupResult &R,
4211  bool NeedsADL,
4212  bool AcceptInvalidDecl = false);
4213  ExprResult BuildDeclarationNameExpr(
4214  const CXXScopeSpec &SS, const DeclarationNameInfo &NameInfo, NamedDecl *D,
4215  NamedDecl *FoundD = nullptr,
4216  const TemplateArgumentListInfo *TemplateArgs = nullptr,
4217  bool AcceptInvalidDecl = false);
4218 
4219  ExprResult BuildLiteralOperatorCall(LookupResult &R,
4220  DeclarationNameInfo &SuffixInfo,
4221  ArrayRef<Expr *> Args,
4222  SourceLocation LitEndLoc,
4223  TemplateArgumentListInfo *ExplicitTemplateArgs = nullptr);
4224 
4225  ExprResult BuildPredefinedExpr(SourceLocation Loc,
4227  ExprResult ActOnPredefinedExpr(SourceLocation Loc, tok::TokenKind Kind);
4228  ExprResult ActOnIntegerConstant(SourceLocation Loc, uint64_t Val);
4229 
4230  bool CheckLoopHintExpr(Expr *E, SourceLocation Loc);
4231 
4232  ExprResult ActOnNumericConstant(const Token &Tok, Scope *UDLScope = nullptr);
4233  ExprResult ActOnCharacterConstant(const Token &Tok,
4234  Scope *UDLScope = nullptr);
4235  ExprResult ActOnParenExpr(SourceLocation L, SourceLocation R, Expr *E);
4236  ExprResult ActOnParenListExpr(SourceLocation L,
4237  SourceLocation R,
4238  MultiExprArg Val);
4239 
4240  /// ActOnStringLiteral - The specified tokens were lexed as pasted string
4241  /// fragments (e.g. "foo" "bar" L"baz").
4242  ExprResult ActOnStringLiteral(ArrayRef<Token> StringToks,
4243  Scope *UDLScope = nullptr);
4244 
4245  ExprResult ActOnGenericSelectionExpr(SourceLocation KeyLoc,
4246  SourceLocation DefaultLoc,
4247  SourceLocation RParenLoc,
4248  Expr *ControllingExpr,
4249  ArrayRef<ParsedType> ArgTypes,
4250  ArrayRef<Expr *> ArgExprs);
4251  ExprResult CreateGenericSelectionExpr(SourceLocation KeyLoc,
4252  SourceLocation DefaultLoc,
4253  SourceLocation RParenLoc,
4254  Expr *ControllingExpr,
4256  ArrayRef<Expr *> Exprs);
4257 
4258  // Binary/Unary Operators. 'Tok' is the token for the operator.
4259  ExprResult CreateBuiltinUnaryOp(SourceLocation OpLoc, UnaryOperatorKind Opc,
4260  Expr *InputExpr);
4261  ExprResult BuildUnaryOp(Scope *S, SourceLocation OpLoc,
4262  UnaryOperatorKind Opc, Expr *Input);
4263  ExprResult ActOnUnaryOp(Scope *S, SourceLocation OpLoc,
4264  tok::TokenKind Op, Expr *Input);
4265 
4266  bool isQualifiedMemberAccess(Expr *E);
4267  QualType CheckAddressOfOperand(ExprResult &Operand, SourceLocation OpLoc);
4268 
4269  ExprResult CreateUnaryExprOrTypeTraitExpr(TypeSourceInfo *TInfo,
4270  SourceLocation OpLoc,
4271  UnaryExprOrTypeTrait ExprKind,
4272  SourceRange R);
4273  ExprResult CreateUnaryExprOrTypeTraitExpr(Expr *E, SourceLocation OpLoc,
4274  UnaryExprOrTypeTrait ExprKind);
4275  ExprResult
4276  ActOnUnaryExprOrTypeTraitExpr(SourceLocation OpLoc,
4277  UnaryExprOrTypeTrait ExprKind,
4278  bool IsType, void *TyOrEx,
4279  SourceRange ArgRange);
4280 
4281  ExprResult CheckPlaceholderExpr(Expr *E);
4282  bool CheckVecStepExpr(Expr *E);
4283 
4284  bool CheckUnaryExprOrTypeTraitOperand(Expr *E, UnaryExprOrTypeTrait ExprKind);
4285  bool CheckUnaryExprOrTypeTraitOperand(QualType ExprType, SourceLocation OpLoc,
4286  SourceRange ExprRange,
4287  UnaryExprOrTypeTrait ExprKind);
4288  ExprResult ActOnSizeofParameterPackExpr(Scope *S,
4289  SourceLocation OpLoc,
4290  IdentifierInfo &Name,
4291  SourceLocation NameLoc,
4292  SourceLocation RParenLoc);
4293  ExprResult ActOnPostfixUnaryOp(Scope *S, SourceLocation OpLoc,
4294  tok::TokenKind Kind, Expr *Input);
4295 
4296  ExprResult ActOnArraySubscriptExpr(Scope *S, Expr *Base, SourceLocation LLoc,
4297  Expr *Idx, SourceLocation RLoc);
4298  ExprResult CreateBuiltinArraySubscriptExpr(Expr *Base, SourceLocation LLoc,
4299  Expr *Idx, SourceLocation RLoc);
4300  ExprResult ActOnOMPArraySectionExpr(Expr *Base, SourceLocation LBLoc,
4301  Expr *LowerBound, SourceLocation ColonLoc,
4302  Expr *Length, SourceLocation RBLoc);
4303 
4304  // This struct is for use by ActOnMemberAccess to allow
4305  // BuildMemberReferenceExpr to be able to reinvoke ActOnMemberAccess after
4306  // changing the access operator from a '.' to a '->' (to see if that is the
4307  // change needed to fix an error about an unknown member, e.g. when the class
4308  // defines a custom operator->).
4310  Scope *S;
4313  };
4314 
4315  ExprResult BuildMemberReferenceExpr(
4316  Expr *Base, QualType BaseType, SourceLocation OpLoc, bool IsArrow,
4317  CXXScopeSpec &SS, SourceLocation TemplateKWLoc,
4318  NamedDecl *FirstQualifierInScope, const DeclarationNameInfo &NameInfo,
4319  const TemplateArgumentListInfo *TemplateArgs,
4320  const Scope *S,
4321  ActOnMemberAccessExtraArgs *ExtraArgs = nullptr);
4322 
4323  ExprResult
4324  BuildMemberReferenceExpr(Expr *Base, QualType BaseType, SourceLocation OpLoc,
4325  bool IsArrow, const CXXScopeSpec &SS,
4326  SourceLocation TemplateKWLoc,
4327  NamedDecl *FirstQualifierInScope, LookupResult &R,
4328  const TemplateArgumentListInfo *TemplateArgs,
4329  const Scope *S,
4330  bool SuppressQualifierCheck = false,
4331  ActOnMemberAccessExtraArgs *ExtraArgs = nullptr);
4332 
4333  ExprResult BuildFieldReferenceExpr(Expr *BaseExpr, bool IsArrow,
4334  SourceLocation OpLoc,
4335  const CXXScopeSpec &SS, FieldDecl *Field,
4336  DeclAccessPair FoundDecl,
4337  const DeclarationNameInfo &MemberNameInfo);
4338 
4339  ExprResult PerformMemberExprBaseConversion(Expr *Base, bool IsArrow);
4340 
4341  bool CheckQualifiedMemberReference(Expr *BaseExpr, QualType BaseType,
4342  const CXXScopeSpec &SS,
4343  const LookupResult &R);
4344 
4345  ExprResult ActOnDependentMemberExpr(Expr *Base, QualType BaseType,
4346  bool IsArrow, SourceLocation OpLoc,
4347  const CXXScopeSpec &SS,
4348  SourceLocation TemplateKWLoc,
4349  NamedDecl *FirstQualifierInScope,
4350  const DeclarationNameInfo &NameInfo,
4351  const TemplateArgumentListInfo *TemplateArgs);
4352 
4353  ExprResult ActOnMemberAccessExpr(Scope *S, Expr *Base,
4354  SourceLocation OpLoc,
4355  tok::TokenKind OpKind,
4356  CXXScopeSpec &SS,
4357  SourceLocation TemplateKWLoc,
4358  UnqualifiedId &Member,
4359  Decl *ObjCImpDecl);
4360 
4361  void ActOnDefaultCtorInitializers(Decl *CDtorDecl);
4362  bool ConvertArgumentsForCall(CallExpr *Call, Expr *Fn,
4363  FunctionDecl *FDecl,
4364  const FunctionProtoType *Proto,
4365  ArrayRef<Expr *> Args,
4366  SourceLocation RParenLoc,
4367  bool ExecConfig = false);
4368  void CheckStaticArrayArgument(SourceLocation CallLoc,
4369  ParmVarDecl *Param,
4370  const Expr *ArgExpr);
4371 
4372  /// ActOnCallExpr - Handle a call to Fn with the specified array of arguments.
4373  /// This provides the location of the left/right parens and a list of comma
4374  /// locations.
4375  ExprResult ActOnCallExpr(Scope *S, Expr *Fn, SourceLocation LParenLoc,
4376  MultiExprArg ArgExprs, SourceLocation RParenLoc,
4377  Expr *ExecConfig = nullptr,
4378  bool IsExecConfig = false);
4379  ExprResult BuildResolvedCallExpr(Expr *Fn, NamedDecl *NDecl,
4380  SourceLocation LParenLoc,
4381  ArrayRef<Expr *> Arg,
4382  SourceLocation RParenLoc,
4383  Expr *Config = nullptr,
4384  bool IsExecConfig = false);
4385 
4386  ExprResult ActOnCUDAExecConfigExpr(Scope *S, SourceLocation LLLLoc,
4387  MultiExprArg ExecConfig,
4388  SourceLocation GGGLoc);
4389 
4390  ExprResult ActOnCastExpr(Scope *S, SourceLocation LParenLoc,
4391  Declarator &D, ParsedType &Ty,
4392  SourceLocation RParenLoc, Expr *CastExpr);
4393  ExprResult BuildCStyleCastExpr(SourceLocation LParenLoc,
4394  TypeSourceInfo *Ty,
4395  SourceLocation RParenLoc,
4396  Expr *Op);
4397  CastKind PrepareScalarCast(ExprResult &src, QualType destType);
4398 
4399  /// Build an altivec or OpenCL literal.
4400  ExprResult BuildVectorLiteral(SourceLocation LParenLoc,
4401  SourceLocation RParenLoc, Expr *E,
4402  TypeSourceInfo *TInfo);
4403 
4404  ExprResult MaybeConvertParenListExprToParenExpr(Scope *S, Expr *ME);
4405 
4406  ExprResult ActOnCompoundLiteral(SourceLocation LParenLoc,
4407  ParsedType Ty,
4408  SourceLocation RParenLoc,
4409  Expr *InitExpr);
4410 
4411  ExprResult BuildCompoundLiteralExpr(SourceLocation LParenLoc,
4412  TypeSourceInfo *TInfo,
4413  SourceLocation RParenLoc,
4414  Expr *LiteralExpr);
4415 
4416  ExprResult ActOnInitList(SourceLocation LBraceLoc,
4417  MultiExprArg InitArgList,
4418  SourceLocation RBraceLoc);
4419 
4420  ExprResult ActOnDesignatedInitializer(Designation &Desig,
4421  SourceLocation Loc,
4422  bool GNUSyntax,
4423  ExprResult Init);
4424 
4425 private:
4426  static BinaryOperatorKind ConvertTokenKindToBinaryOpcode(tok::TokenKind Kind);
4427 
4428 public:
4429  ExprResult ActOnBinOp(Scope *S, SourceLocation TokLoc,
4430  tok::TokenKind Kind, Expr *LHSExpr, Expr *RHSExpr);
4431  ExprResult BuildBinOp(Scope *S, SourceLocation OpLoc,
4432  BinaryOperatorKind Opc, Expr *LHSExpr, Expr *RHSExpr);
4433  ExprResult CreateBuiltinBinOp(SourceLocation OpLoc, BinaryOperatorKind Opc,
4434  Expr *LHSExpr, Expr *RHSExpr);
4435 
4436  void DiagnoseCommaOperator(const Expr *LHS, SourceLocation Loc);
4437 
4438  /// ActOnConditionalOp - Parse a ?: operation. Note that 'LHS' may be null
4439  /// in the case of a the GNU conditional expr extension.
4440  ExprResult ActOnConditionalOp(SourceLocation QuestionLoc,
4441  SourceLocation ColonLoc,
4442  Expr *CondExpr, Expr *LHSExpr, Expr *RHSExpr);
4443 
4444  /// ActOnAddrLabel - Parse the GNU address of label extension: "&&foo".
4445  ExprResult ActOnAddrLabel(SourceLocation OpLoc, SourceLocation LabLoc,
4446  LabelDecl *TheDecl);
4447 
4448  void ActOnStartStmtExpr();
4449  ExprResult ActOnStmtExpr(SourceLocation LPLoc, Stmt *SubStmt,
4450  SourceLocation RPLoc); // "({..})"
4451  void ActOnStmtExprError();
4452 
4453  // __builtin_offsetof(type, identifier(.identifier|[expr])*)
4456  bool isBrackets; // true if [expr], false if .ident
4457  union {
4460  } U;
4461  };
4462 
4463  /// __builtin_offsetof(type, a.b[123][456].c)
4464  ExprResult BuildBuiltinOffsetOf(SourceLocation BuiltinLoc,
4465  TypeSourceInfo *TInfo,
4466  ArrayRef<OffsetOfComponent> Components,
4467  SourceLocation RParenLoc);
4468  ExprResult ActOnBuiltinOffsetOf(Scope *S,
4469  SourceLocation BuiltinLoc,
4471  ParsedType ParsedArgTy,
4472  ArrayRef<OffsetOfComponent> Components,
4473  SourceLocation RParenLoc);
4474 
4475  // __builtin_choose_expr(constExpr, expr1, expr2)
4476  ExprResult ActOnChooseExpr(SourceLocation BuiltinLoc,
4477  Expr *CondExpr, Expr *LHSExpr,
4478  Expr *RHSExpr, SourceLocation RPLoc);
4479 
4480  // __builtin_va_arg(expr, type)
4481  ExprResult ActOnVAArg(SourceLocation BuiltinLoc, Expr *E, ParsedType Ty,
4482  SourceLocation RPLoc);
4483  ExprResult BuildVAArgExpr(SourceLocation BuiltinLoc, Expr *E,
4484  TypeSourceInfo *TInfo, SourceLocation RPLoc);
4485 
4486  // __null
4487  ExprResult ActOnGNUNullExpr(SourceLocation TokenLoc);
4488 
4489  bool CheckCaseExpression(Expr *E);
4490 
4491  /// Describes the result of an "if-exists" condition check.
4493  /// The symbol exists.
4495 
4496  /// The symbol does not exist.
4498 
4499  /// The name is a dependent name, so the results will differ
4500  /// from one instantiation to the next.
4502 
4503  /// An error occurred.
4504  IER_Error
4505  };
4506 
4508  CheckMicrosoftIfExistsSymbol(Scope *S, CXXScopeSpec &SS,
4509  const DeclarationNameInfo &TargetNameInfo);
4510 
4512  CheckMicrosoftIfExistsSymbol(Scope *S, SourceLocation KeywordLoc,
4513  bool IsIfExists, CXXScopeSpec &SS,
4514  UnqualifiedId &Name);
4515 
4516  StmtResult BuildMSDependentExistsStmt(SourceLocation KeywordLoc,
4517  bool IsIfExists,
4518  NestedNameSpecifierLoc QualifierLoc,
4519  DeclarationNameInfo NameInfo,
4520  Stmt *Nested);
4521  StmtResult ActOnMSDependentExistsStmt(SourceLocation KeywordLoc,
4522  bool IsIfExists,
4523  CXXScopeSpec &SS, UnqualifiedId &Name,
4524  Stmt *Nested);
4525 
4526  //===------------------------- "Block" Extension ------------------------===//
4527 
4528  /// ActOnBlockStart - This callback is invoked when a block literal is
4529  /// started.
4530  void ActOnBlockStart(SourceLocation CaretLoc, Scope *CurScope);
4531 
4532  /// ActOnBlockArguments - This callback allows processing of block arguments.
4533  /// If there are no arguments, this is still invoked.
4534  void ActOnBlockArguments(SourceLocation CaretLoc, Declarator &ParamInfo,
4535  Scope *CurScope);
4536 
4537  /// ActOnBlockError - If there is an error parsing a block, this callback
4538  /// is invoked to pop the information about the block from the action impl.
4539  void ActOnBlockError(SourceLocation CaretLoc, Scope *CurScope);
4540 
4541  /// ActOnBlockStmtExpr - This is called when the body of a block statement
4542  /// literal was successfully completed. ^(int x){...}
4543  ExprResult ActOnBlockStmtExpr(SourceLocation CaretLoc, Stmt *Body,
4544  Scope *CurScope);
4545 
4546  //===---------------------------- Clang Extensions ----------------------===//
4547 
4548  /// __builtin_convertvector(...)
4549  ExprResult ActOnConvertVectorExpr(Expr *E, ParsedType ParsedDestTy,
4550  SourceLocation BuiltinLoc,
4551  SourceLocation RParenLoc);
4552 
4553  //===---------------------------- OpenCL Features -----------------------===//
4554 
4555  /// __builtin_astype(...)
4556  ExprResult ActOnAsTypeExpr(Expr *E, ParsedType ParsedDestTy,
4557  SourceLocation BuiltinLoc,
4558  SourceLocation RParenLoc);
4559 
4560  //===---------------------------- C++ Features --------------------------===//
4561 
4562  // Act on C++ namespaces
4563  Decl *ActOnStartNamespaceDef(Scope *S, SourceLocation InlineLoc,
4564  SourceLocation NamespaceLoc,
4565  SourceLocation IdentLoc, IdentifierInfo *Ident,
4566  SourceLocation LBrace,
4567  const ParsedAttributesView &AttrList,
4569  void ActOnFinishNamespaceDef(Decl *Dcl, SourceLocation RBrace);
4570 
4571  NamespaceDecl *getStdNamespace() const;
4572  NamespaceDecl *getOrCreateStdNamespace();
4573 
4574  NamespaceDecl *lookupStdExperimentalNamespace();
4575 
4576  CXXRecordDecl *getStdBadAlloc() const;
4577  EnumDecl *getStdAlignValT() const;
4578 
4579 private:
4580  // A cache representing if we've fully checked the various comparison category
4581  // types stored in ASTContext. The bit-index corresponds to the integer value
4582  // of a ComparisonCategoryType enumerator.
4583  llvm::SmallBitVector FullyCheckedComparisonCategories;
4584 
4585 public:
4586  /// Lookup the specified comparison category types in the standard
4587  /// library, an check the VarDecls possibly returned by the operator<=>
4588  /// builtins for that type.
4589  ///
4590  /// \return The type of the comparison category type corresponding to the
4591  /// specified Kind, or a null type if an error occurs
4592  QualType CheckComparisonCategoryType(ComparisonCategoryType Kind,
4593  SourceLocation Loc);
4594 
4595  /// Tests whether Ty is an instance of std::initializer_list and, if
4596  /// it is and Element is not NULL, assigns the element type to Element.
4597  bool isStdInitializerList(QualType Ty, QualType *Element);
4598 
4599  /// Looks for the std::initializer_list template and instantiates it
4600  /// with Element, or emits an error if it's not found.
4601  ///
4602  /// \returns The instantiated template, or null on error.
4603  QualType BuildStdInitializerList(QualType Element, SourceLocation Loc);
4604 
4605  /// Determine whether Ctor is an initializer-list constructor, as
4606  /// defined in [dcl.init.list]p2.
4607  bool isInitListConstructor(const FunctionDecl *Ctor);
4608 
4609  Decl *ActOnUsingDirective(Scope *CurScope, SourceLocation UsingLoc,
4610  SourceLocation NamespcLoc, CXXScopeSpec &SS,
4611  SourceLocation IdentLoc,
4612  IdentifierInfo *NamespcName,
4613  const ParsedAttributesView &AttrList);
4614 
4615  void PushUsingDirective(Scope *S, UsingDirectiveDecl *UDir);
4616 
4617  Decl *ActOnNamespaceAliasDef(Scope *CurScope,
4618  SourceLocation NamespaceLoc,
4619  SourceLocation AliasLoc,
4620  IdentifierInfo *Alias,
4621  CXXScopeSpec &SS,
4622  SourceLocation IdentLoc,
4623  IdentifierInfo *Ident);
4624 
4625  void HideUsingShadowDecl(Scope *S, UsingShadowDecl *Shadow);
4626  bool CheckUsingShadowDecl(UsingDecl *UD, NamedDecl *Target,
4627  const LookupResult &PreviousDecls,
4628  UsingShadowDecl *&PrevShadow);
4629  UsingShadowDecl *BuildUsingShadowDecl(Scope *S, UsingDecl *UD,
4630  NamedDecl *Target,
4631  UsingShadowDecl *PrevDecl);
4632 
4633  bool CheckUsingDeclRedeclaration(SourceLocation UsingLoc,
4634  bool HasTypenameKeyword,
4635  const CXXScopeSpec &SS,
4636  SourceLocation NameLoc,
4637  const LookupResult &Previous);
4638  bool CheckUsingDeclQualifier(SourceLocation UsingLoc,
4639  bool HasTypename,
4640  const CXXScopeSpec &SS,
4641  const DeclarationNameInfo &NameInfo,
4642  SourceLocation NameLoc);
4643 
4644  NamedDecl *BuildUsingDeclaration(
4645  Scope *S, AccessSpecifier AS, SourceLocation UsingLoc,
4646  bool HasTypenameKeyword, SourceLocation TypenameLoc, CXXScopeSpec &SS,
4647  DeclarationNameInfo NameInfo, SourceLocation EllipsisLoc,
4648  const ParsedAttributesView &AttrList, bool IsInstantiation);
4649  NamedDecl *BuildUsingPackDecl(NamedDecl *InstantiatedFrom,
4650  ArrayRef<NamedDecl *> Expansions);
4651 
4652  bool CheckInheritingConstructorUsingDecl(UsingDecl *UD);
4653 
4654  /// Given a derived-class using shadow declaration for a constructor and the
4655  /// correspnding base class constructor, find or create the implicit
4656  /// synthesized derived class constructor to use for this initialization.
4657  CXXConstructorDecl *
4658  findInheritingConstructor(SourceLocation Loc, CXXConstructorDecl *BaseCtor,
4659  ConstructorUsingShadowDecl *DerivedShadow);
4660 
4661  Decl *ActOnUsingDeclaration(Scope *CurScope, AccessSpecifier AS,
4662  SourceLocation UsingLoc,
4663  SourceLocation TypenameLoc, CXXScopeSpec &SS,
4664  UnqualifiedId &Name, SourceLocation EllipsisLoc,
4665  const ParsedAttributesView &AttrList);
4666  Decl *ActOnAliasDeclaration(Scope *CurScope, AccessSpecifier AS,
4667  MultiTemplateParamsArg TemplateParams,
4668  SourceLocation UsingLoc, UnqualifiedId &Name,
4669  const ParsedAttributesView &AttrList,
4670  TypeResult Type, Decl *DeclFromDeclSpec);
4671 
4672  /// BuildCXXConstructExpr - Creates a complete call to a constructor,
4673  /// including handling of its default argument expressions.
4674  ///
4675  /// \param ConstructKind - a CXXConstructExpr::ConstructionKind
4676  ExprResult
4677  BuildCXXConstructExpr(SourceLocation ConstructLoc, QualType DeclInitType,
4678  NamedDecl *FoundDecl,
4679  CXXConstructorDecl *Constructor, MultiExprArg Exprs,
4680  bool HadMultipleCandidates, bool IsListInitialization,
4681  bool IsStdInitListInitialization,
4682  bool RequiresZeroInit, unsigned ConstructKind,
4683  SourceRange ParenRange);
4684 
4685  /// Build a CXXConstructExpr whose constructor has already been resolved if
4686  /// it denotes an inherited constructor.
4687  ExprResult
4688  BuildCXXConstructExpr(SourceLocation ConstructLoc, QualType DeclInitType,
4689  CXXConstructorDecl *Constructor, bool Elidable,
4690  MultiExprArg Exprs,
4691  bool HadMultipleCandidates, bool IsListInitialization,
4692  bool IsStdInitListInitialization,
4693  bool RequiresZeroInit, unsigned ConstructKind,
4694  SourceRange ParenRange);
4695 
4696  // FIXME: Can we remove this and have the above BuildCXXConstructExpr check if
4697  // the constructor can be elidable?
4698  ExprResult
4699  BuildCXXConstructExpr(SourceLocation ConstructLoc, QualType DeclInitType,
4700  NamedDecl *FoundDecl,
4701  CXXConstructorDecl *Constructor, bool Elidable,
4702  MultiExprArg Exprs, bool HadMultipleCandidates,
4703  bool IsListInitialization,
4704  bool IsStdInitListInitialization, bool RequiresZeroInit,
4705  unsigned ConstructKind, SourceRange ParenRange);
4706 
4707  ExprResult BuildCXXDefaultInitExpr(SourceLocation Loc, FieldDecl *Field);
4708 
4709 
4710  /// Instantiate or parse a C++ default argument expression as necessary.
4711  /// Return true on error.
4712  bool CheckCXXDefaultArgExpr(SourceLocation CallLoc, FunctionDecl *FD,
4713  ParmVarDecl *Param);
4714 
4715  /// BuildCXXDefaultArgExpr - Creates a CXXDefaultArgExpr, instantiating
4716  /// the default expr if needed.
4717  ExprResult BuildCXXDefaultArgExpr(SourceLocation CallLoc,
4718  FunctionDecl *FD,
4719  ParmVarDecl *Param);
4720 
4721  /// FinalizeVarWithDestructor - Prepare for calling destructor on the
4722  /// constructed variable.
4723  void FinalizeVarWithDestructor(VarDecl *VD, const RecordType *DeclInitType);
4724 
4725  /// Helper class that collects exception specifications for
4726  /// implicitly-declared special member functions.
4728  // Pointer to allow copying
4729  Sema *Self;
4730  // We order exception specifications thus:
4731  // noexcept is the most restrictive, but is only used in C++11.
4732  // throw() comes next.
4733  // Then a throw(collected exceptions)
4734  // Finally no specification, which is expressed as noexcept(false).
4735  // throw(...) is used instead if any called function uses it.
4736  ExceptionSpecificationType ComputedEST;
4737  llvm::SmallPtrSet<CanQualType, 4> ExceptionsSeen;
4738  SmallVector<QualType, 4> Exceptions;
4739 
4740  void ClearExceptions() {
4741  ExceptionsSeen.clear();
4742  Exceptions.clear();
4743  }
4744 
4745  public:
4747  : Self(&Self), ComputedEST(EST_BasicNoexcept) {
4748  if (!Self.getLangOpts().CPlusPlus11)
4749  ComputedEST = EST_DynamicNone;
4750  }
4751 
4752  /// Get the computed exception specification type.
4754  assert(!isComputedNoexcept(ComputedEST) &&
4755  "noexcept(expr) should not be a possible result");
4756  return ComputedEST;
4757  }
4758 
4759  /// The number of exceptions in the exception specification.
4760  unsigned size() const { return Exceptions.size(); }
4761 
4762  /// The set of exceptions in the exception specification.
4763  const QualType *data() const { return Exceptions.data(); }
4764 
4765  /// Integrate another called method into the collected data.
4766  void CalledDecl(SourceLocation CallLoc, const CXXMethodDecl *Method);
4767 
4768  /// Integrate an invoked expression into the collected data.
4769  void CalledExpr(Expr *E);
4770 
4771  /// Overwrite an EPI's exception specification with this
4772  /// computed exception specification.
4775  ESI.Type = getExceptionSpecType();
4776  if (ESI.Type == EST_Dynamic) {
4777  ESI.Exceptions = Exceptions;
4778  } else if (ESI.Type == EST_None) {
4779  /// C++11 [except.spec]p14:
4780  /// The exception-specification is noexcept(false) if the set of
4781  /// potential exceptions of the special member function contains "any"
4782  ESI.Type = EST_NoexceptFalse;
4784  tok::kw_false).get();
4785  }
4786  return ESI;
4787  }
4788  };
4789 
4790  /// Determine what sort of exception specification a defaulted
4791  /// copy constructor of a class will have.
4793  ComputeDefaultedDefaultCtorExceptionSpec(SourceLocation Loc,
4794  CXXMethodDecl *MD);
4795 
4796  /// Determine what sort of exception specification a defaulted
4797  /// default constructor of a class will have, and whether the parameter
4798  /// will be const.
4800  ComputeDefaultedCopyCtorExceptionSpec(CXXMethodDecl *MD);
4801 
4802  /// Determine what sort of exception specification a defautled
4803  /// copy assignment operator of a class will have, and whether the
4804  /// parameter will be const.
4806  ComputeDefaultedCopyAssignmentExceptionSpec(CXXMethodDecl *MD);
4807 
4808  /// Determine what sort of exception specification a defaulted move
4809  /// constructor of a class will have.
4811  ComputeDefaultedMoveCtorExceptionSpec(CXXMethodDecl *MD);
4812 
4813  /// Determine what sort of exception specification a defaulted move
4814  /// assignment operator of a class will have.
4816  ComputeDefaultedMoveAssignmentExceptionSpec(CXXMethodDecl *MD);
4817 
4818  /// Determine what sort of exception specification a defaulted
4819  /// destructor of a class will have.
4821  ComputeDefaultedDtorExceptionSpec(CXXMethodDecl *MD);
4822 
4823  /// Determine what sort of exception specification an inheriting
4824  /// constructor of a class will have.
4826  ComputeInheritingCtorExceptionSpec(SourceLocation Loc,
4827  CXXConstructorDecl *CD);
4828 
4829  /// Evaluate the implicit exception specification for a defaulted
4830  /// special member function.
4831  void EvaluateImplicitExceptionSpec(SourceLocation Loc, CXXMethodDecl *MD);
4832 
4833  /// Check the given noexcept-specifier, convert its expression, and compute
4834  /// the appropriate ExceptionSpecificationType.
4835  ExprResult ActOnNoexceptSpec(SourceLocation NoexceptLoc, Expr *NoexceptExpr,
4837 
4838  /// Check the given exception-specification and update the
4839  /// exception specification information with the results.
4840  void checkExceptionSpecification(bool IsTopLevel,
4842  ArrayRef<ParsedType> DynamicExceptions,
4843  ArrayRef<SourceRange> DynamicExceptionRanges,
4844  Expr *NoexceptExpr,
4845  SmallVectorImpl<QualType> &Exceptions,
4847 
4848  /// Determine if we're in a case where we need to (incorrectly) eagerly
4849  /// parse an exception specification to work around a libstdc++ bug.
4850  bool isLibstdcxxEagerExceptionSpecHack(const Declarator &D);
4851 
4852  /// Add an exception-specification to the given member function
4853  /// (or member function template). The exception-specification was parsed
4854  /// after the method itself was declared.
4855  void actOnDelayedExceptionSpecification(Decl *Method,
4857  SourceRange SpecificationRange,
4858  ArrayRef<ParsedType> DynamicExceptions,
4859  ArrayRef<SourceRange> DynamicExceptionRanges,
4860  Expr *NoexceptExpr);
4861 
4863 
4864  /// Determine if a special member function should have a deleted
4865  /// definition when it is defaulted.
4866  bool ShouldDeleteSpecialMember(CXXMethodDecl *MD, CXXSpecialMember CSM,
4867  InheritedConstructorInfo *ICI = nullptr,
4868  bool Diagnose = false);
4869 
4870  /// Declare the implicit default constructor for the given class.
4871  ///
4872  /// \param ClassDecl The class declaration into which the implicit
4873  /// default constructor will be added.
4874  ///
4875  /// \returns The implicitly-declared default constructor.
4876  CXXConstructorDecl *DeclareImplicitDefaultConstructor(
4877  CXXRecordDecl *ClassDecl);
4878 
4879  /// DefineImplicitDefaultConstructor - Checks for feasibility of
4880  /// defining this constructor as the default constructor.
4881  void DefineImplicitDefaultConstructor(SourceLocation CurrentLocation,
4882  CXXConstructorDecl *Constructor);
4883 
4884  /// Declare the implicit destructor for the given class.
4885  ///
4886  /// \param ClassDecl The class declaration into which the implicit
4887  /// destructor will be added.
4888  ///
4889  /// \returns The implicitly-declared destructor.
4890  CXXDestructorDecl *DeclareImplicitDestructor(CXXRecordDecl *ClassDecl);
4891 
4892  /// DefineImplicitDestructor - Checks for feasibility of
4893  /// defining this destructor as the default destructor.
4894  void DefineImplicitDestructor(SourceLocation CurrentLocation,
4895  CXXDestructorDecl *Destructor);
4896 
4897  /// Build an exception spec for destructors that don't have one.
4898  ///
4899  /// C++11 says that user-defined destructors with no exception spec get one
4900  /// that looks as if the destructor was implicitly declared.
4901  void AdjustDestructorExceptionSpec(CXXRecordDecl *ClassDecl,
4902  CXXDestructorDecl *Destructor);
4903 
4904  /// Define the specified inheriting constructor.
4905  void DefineInheritingConstructor(SourceLocation UseLoc,
4906  CXXConstructorDecl *Constructor);
4907 
4908  /// Declare the implicit copy constructor for the given class.
4909  ///
4910  /// \param ClassDecl The class declaration into which the implicit
4911  /// copy constructor will be added.
4912  ///
4913  /// \returns The implicitly-declared copy constructor.
4914  CXXConstructorDecl *DeclareImplicitCopyConstructor(CXXRecordDecl *ClassDecl);
4915 
4916  /// DefineImplicitCopyConstructor - Checks for feasibility of
4917  /// defining this constructor as the copy constructor.
4918  void DefineImplicitCopyConstructor(SourceLocation CurrentLocation,
4919  CXXConstructorDecl *Constructor);
4920 
4921  /// Declare the implicit move constructor for the given class.
4922  ///
4923  /// \param ClassDecl The Class declaration into which the implicit
4924  /// move constructor will be added.
4925  ///
4926  /// \returns The implicitly-declared move constructor, or NULL if it wasn't
4927  /// declared.
4928  CXXConstructorDecl *DeclareImplicitMoveConstructor(CXXRecordDecl *ClassDecl);
4929 
4930  /// DefineImplicitMoveConstructor - Checks for feasibility of
4931  /// defining this constructor as the move constructor.
4932  void DefineImplicitMoveConstructor(SourceLocation CurrentLocation,
4933  CXXConstructorDecl *Constructor);
4934 
4935  /// Declare the implicit copy assignment operator for the given class.
4936  ///
4937  /// \param ClassDecl The class declaration into which the implicit
4938  /// copy assignment operator will be added.
4939  ///
4940  /// \returns The implicitly-declared copy assignment operator.
4941  CXXMethodDecl *DeclareImplicitCopyAssignment(CXXRecordDecl *ClassDecl);
4942 
4943  /// Defines an implicitly-declared copy assignment operator.
4944  void DefineImplicitCopyAssignment(SourceLocation CurrentLocation,
4945  CXXMethodDecl *MethodDecl);
4946 
4947  /// Declare the implicit move assignment operator for the given class.
4948  ///
4949  /// \param ClassDecl The Class declaration into which the implicit
4950  /// move assignment operator will be added.
4951  ///
4952  /// \returns The implicitly-declared move assignment operator, or NULL if it
4953  /// wasn't declared.
4954  CXXMethodDecl *DeclareImplicitMoveAssignment(CXXRecordDecl *ClassDecl);
4955 
4956  /// Defines an implicitly-declared move assignment operator.
4957  void DefineImplicitMoveAssignment(SourceLocation CurrentLocation,
4958  CXXMethodDecl *MethodDecl);
4959 
4960  /// Force the declaration of any implicitly-declared members of this
4961  /// class.
4962  void ForceDeclarationOfImplicitMembers(CXXRecordDecl *Class);
4963 
4964  /// Check a completed declaration of an implicit special member.
4965  void CheckImplicitSpecialMemberDeclaration(Scope *S, FunctionDecl *FD);
4966 
4967  /// Determine whether the given function is an implicitly-deleted
4968  /// special member function.
4969  bool isImplicitlyDeleted(FunctionDecl *FD);
4970 
4971  /// Check whether 'this' shows up in the type of a static member
4972  /// function after the (naturally empty) cv-qualifier-seq would be.
4973  ///
4974  /// \returns true if an error occurred.
4975  bool checkThisInStaticMemberFunctionType(CXXMethodDecl *Method);
4976 
4977  /// Whether this' shows up in the exception specification of a static
4978  /// member function.
4979  bool checkThisInStaticMemberFunctionExceptionSpec(CXXMethodDecl *Method);
4980 
4981  /// Check whether 'this' shows up in the attributes of the given
4982  /// static member function.
4983  ///
4984  /// \returns true if an error occurred.
4985  bool checkThisInStaticMemberFunctionAttributes(CXXMethodDecl *Method);
4986 
4987  /// MaybeBindToTemporary - If the passed in expression has a record type with
4988  /// a non-trivial destructor, this will return CXXBindTemporaryExpr. Otherwise
4989  /// it simply returns the passed in expression.
4990  ExprResult MaybeBindToTemporary(Expr *E);
4991 
4992  bool CompleteConstructorCall(CXXConstructorDecl *Constructor,
4993  MultiExprArg ArgsPtr,
4994  SourceLocation Loc,
4995  SmallVectorImpl<Expr*> &ConvertedArgs,
4996  bool AllowExplicit = false,
4997  bool IsListInitialization = false);
4998 
4999  ParsedType getInheritingConstructorName(CXXScopeSpec &SS,
5000  SourceLocation NameLoc,
5001  IdentifierInfo &Name);
5002 
5003  ParsedType getConstructorName(IdentifierInfo &II, SourceLocation NameLoc,
5004  Scope *S, CXXScopeSpec &SS,
5005  bool EnteringContext);
5006  ParsedType getDestructorName(SourceLocation TildeLoc,
5007  IdentifierInfo &II, SourceLocation NameLoc,
5008  Scope *S, CXXScopeSpec &SS,
5009  ParsedType ObjectType,
5010  bool EnteringContext);
5011 
5012  ParsedType getDestructorTypeForDecltype(const DeclSpec &DS,
5013  ParsedType ObjectType);
5014 
5015  // Checks that reinterpret casts don't have undefined behavior.
5016  void CheckCompatibleReinterpretCast(QualType SrcType, QualType DestType,
5017  bool IsDereference, SourceRange Range);
5018 
5019  /// ActOnCXXNamedCast - Parse {dynamic,static,reinterpret,const}_cast's.
5020  ExprResult ActOnCXXNamedCast(SourceLocation OpLoc,
5022  SourceLocation LAngleBracketLoc,
5023  Declarator &D,
5024  SourceLocation RAngleBracketLoc,
5025  SourceLocation LParenLoc,
5026  Expr *E,
5027  SourceLocation RParenLoc);
5028 
5029  ExprResult BuildCXXNamedCast(SourceLocation OpLoc,
5030  tok::TokenKind Kind,
5031  TypeSourceInfo *Ty,
5032  Expr *E,
5033  SourceRange AngleBrackets,
5034  SourceRange Parens);
5035 
5036  ExprResult BuildCXXTypeId(QualType TypeInfoType,
5037  SourceLocation TypeidLoc,
5038  TypeSourceInfo *Operand,
5039  SourceLocation RParenLoc);
5040  ExprResult BuildCXXTypeId(QualType TypeInfoType,
5041  SourceLocation TypeidLoc,
5042  Expr *Operand,
5043  SourceLocation RParenLoc);
5044 
5045  /// ActOnCXXTypeid - Parse typeid( something ).
5046  ExprResult ActOnCXXTypeid(SourceLocation OpLoc,
5047  SourceLocation LParenLoc, bool isType,
5048  void *TyOrExpr,
5049  SourceLocation RParenLoc);
5050 
5051  ExprResult BuildCXXUuidof(QualType TypeInfoType,
5052  SourceLocation TypeidLoc,
5053  TypeSourceInfo *Operand,
5054  SourceLocation RParenLoc);
5055  ExprResult BuildCXXUuidof(QualType TypeInfoType,
5056  SourceLocation TypeidLoc,
5057  Expr *Operand,
5058  SourceLocation RParenLoc);
5059 
5060  /// ActOnCXXUuidof - Parse __uuidof( something ).
5061  ExprResult ActOnCXXUuidof(SourceLocation OpLoc,
5062  SourceLocation LParenLoc, bool isType,
5063  void *TyOrExpr,
5064  SourceLocation RParenLoc);
5065 
5066  /// Handle a C++1z fold-expression: ( expr op ... op expr ).
5067  ExprResult ActOnCXXFoldExpr(SourceLocation LParenLoc, Expr *LHS,
5068  tok::TokenKind Operator,
5069  SourceLocation EllipsisLoc, Expr *RHS,
5070  SourceLocation RParenLoc);
5071  ExprResult BuildCXXFoldExpr(SourceLocation LParenLoc, Expr *LHS,
5072  BinaryOperatorKind Operator,
5073  SourceLocation EllipsisLoc, Expr *RHS,
5074  SourceLocation RParenLoc);
5075  ExprResult BuildEmptyCXXFoldExpr(SourceLocation EllipsisLoc,
5076  BinaryOperatorKind Operator);
5077 
5078  //// ActOnCXXThis - Parse 'this' pointer.
5079  ExprResult ActOnCXXThis(SourceLocation loc);
5080 
5081  /// Try to retrieve the type of the 'this' pointer.
5082  ///
5083  /// \returns The type of 'this', if possible. Otherwise, returns a NULL type.
5084  QualType getCurrentThisType();
5085 
5086  /// When non-NULL, the C++ 'this' expression is allowed despite the
5087  /// current context not being a non-static member function. In such cases,
5088  /// this provides the type used for 'this'.
5090 
5091  /// RAII object used to temporarily allow the C++ 'this' expression
5092  /// to be used, with the given qualifiers on the current class type.
5094  Sema &S;
5095  QualType OldCXXThisTypeOverride;
5096  bool Enabled;
5097 
5098  public:
5099  /// Introduce a new scope where 'this' may be allowed (when enabled),
5100  /// using the given declaration (which is either a class template or a
5101  /// class) along with the given qualifiers.
5102  /// along with the qualifiers placed on '*this'.
5103  CXXThisScopeRAII(Sema &S, Decl *ContextDecl, unsigned CXXThisTypeQuals,
5104  bool Enabled = true);
5105 
5106  ~CXXThisScopeRAII();
5107  };
5108 
5109  /// Make sure the value of 'this' is actually available in the current
5110  /// context, if it is a potentially evaluated context.
5111  ///
5112  /// \param Loc The location at which the capture of 'this' occurs.
5113  ///
5114  /// \param Explicit Whether 'this' is explicitly captured in a lambda
5115  /// capture list.
5116  ///
5117  /// \param FunctionScopeIndexToStopAt If non-null, it points to the index
5118  /// of the FunctionScopeInfo stack beyond which we do not attempt to capture.
5119  /// This is useful when enclosing lambdas must speculatively capture
5120  /// 'this' that may or may not be used in certain specializations of
5121  /// a nested generic lambda (depending on whether the name resolves to
5122  /// a non-static member function or a static function).
5123  /// \return returns 'true' if failed, 'false' if success.
5124  bool CheckCXXThisCapture(SourceLocation Loc, bool Explicit = false,
5125  bool BuildAndDiagnose = true,
5126  const unsigned *const FunctionScopeIndexToStopAt = nullptr,
5127  bool ByCopy = false);
5128 
5129  /// Determine whether the given type is the type of *this that is used
5130  /// outside of the body of a member function for a type that is currently
5131  /// being defined.
5132  bool isThisOutsideMemberFunctionBody(QualType BaseType);
5133 
5134  /// ActOnCXXBoolLiteral - Parse {true,false} literals.
5135  ExprResult ActOnCXXBoolLiteral(SourceLocation OpLoc, tok::TokenKind Kind);
5136 
5137 
5138  /// ActOnObjCBoolLiteral - Parse {__objc_yes,__objc_no} literals.
5139  ExprResult ActOnObjCBoolLiteral(SourceLocation OpLoc, tok::TokenKind Kind);
5140 
5141  ExprResult
5142  ActOnObjCAvailabilityCheckExpr(llvm::ArrayRef<AvailabilitySpec> AvailSpecs,
5143  SourceLocation AtLoc, SourceLocation RParen);
5144 
5145  /// ActOnCXXNullPtrLiteral - Parse 'nullptr'.
5146  ExprResult ActOnCXXNullPtrLiteral(SourceLocation Loc);
5147 
5148  //// ActOnCXXThrow - Parse throw expressions.
5149  ExprResult ActOnCXXThrow(Scope *S, SourceLocation OpLoc, Expr *expr);
5150  ExprResult BuildCXXThrow(SourceLocation OpLoc, Expr *Ex,
5151  bool IsThrownVarInScope);
5152  bool CheckCXXThrowOperand(SourceLocation ThrowLoc, QualType ThrowTy, Expr *E);
5153 
5154  /// ActOnCXXTypeConstructExpr - Parse construction of a specified type.
5155  /// Can be interpreted either as function-style casting ("int(x)")
5156  /// or class type construction ("ClassType(x,y,z)")
5157  /// or creation of a value-initialized type ("int()").
5158  ExprResult ActOnCXXTypeConstructExpr(ParsedType TypeRep,
5159  SourceLocation LParenOrBraceLoc,
5160  MultiExprArg Exprs,
5161  SourceLocation RParenOrBraceLoc,
5162  bool ListInitialization);
5163 
5164  ExprResult BuildCXXTypeConstructExpr(TypeSourceInfo *Type,
5165  SourceLocation LParenLoc,
5166  MultiExprArg Exprs,
5167  SourceLocation RParenLoc,
5168  bool ListInitialization);
5169 
5170  /// ActOnCXXNew - Parsed a C++ 'new' expression.
5171  ExprResult ActOnCXXNew(SourceLocation StartLoc, bool UseGlobal,
5172  SourceLocation PlacementLParen,
5173  MultiExprArg PlacementArgs,
5174  SourceLocation PlacementRParen,
5175  SourceRange TypeIdParens, Declarator &D,
5176  Expr *Initializer);
5177  ExprResult BuildCXXNew(SourceRange Range, bool UseGlobal,
5178  SourceLocation PlacementLParen,
5179  MultiExprArg PlacementArgs,
5180  SourceLocation PlacementRParen,
5181  SourceRange TypeIdParens,
5182  QualType AllocType,
5183  TypeSourceInfo *AllocTypeInfo,
5184  Expr *ArraySize,
5185  SourceRange DirectInitRange,
5186  Expr *Initializer);
5187 
5188  bool CheckAllocatedType(QualType AllocType, SourceLocation Loc,
5189  SourceRange R);
5190 
5191  /// The scope in which to find allocation functions.
5193  /// Only look for allocation functions in the global scope.
5195  /// Only look for allocation functions in the scope of the
5196  /// allocated class.
5198  /// Look for allocation functions in both the global scope
5199  /// and in the scope of the allocated class.
5200  AFS_Both
5201  };
5202 
5203  /// Finds the overloads of operator new and delete that are appropriate
5204  /// for the allocation.
5205  bool FindAllocationFunctions(SourceLocation StartLoc, SourceRange Range,
5206  AllocationFunctionScope NewScope,
5207  AllocationFunctionScope DeleteScope,
5208  QualType AllocType, bool IsArray,
5209  bool &PassAlignment, MultiExprArg PlaceArgs,
5210  FunctionDecl *&OperatorNew,
5211  FunctionDecl *&OperatorDelete,
5212  bool Diagnose = true);
5213  void DeclareGlobalNewDelete();
5214  void DeclareGlobalAllocationFunction(DeclarationName Name, QualType Return,
5215  ArrayRef<QualType> Params);
5216 
5217  bool FindDeallocationFunction(SourceLocation StartLoc, CXXRecordDecl *RD,
5218  DeclarationName Name, FunctionDecl* &Operator,
5219  bool Diagnose = true);
5220  FunctionDecl *FindUsualDeallocationFunction(SourceLocation StartLoc,
5221  bool CanProvideSize,
5222  bool Overaligned,
5223  DeclarationName Name);
5224  FunctionDecl *FindDeallocationFunctionForDestructor(SourceLocation StartLoc,
5225  CXXRecordDecl *RD);
5226 
5227  /// ActOnCXXDelete - Parsed a C++ 'delete' expression
5228  ExprResult ActOnCXXDelete(SourceLocation StartLoc,
5229  bool UseGlobal, bool ArrayForm,
5230  Expr *Operand);
5231  void CheckVirtualDtorCall(CXXDestructorDecl *dtor, SourceLocation Loc,
5232  bool IsDelete, bool CallCanBeVirtual,
5233  bool WarnOnNonAbstractTypes,
5234  SourceLocation DtorLoc);
5235 
5236  ExprResult ActOnNoexceptExpr(SourceLocation KeyLoc, SourceLocation LParen,
5237  Expr *Operand, SourceLocation RParen);
5238  ExprResult BuildCXXNoexceptExpr(SourceLocation KeyLoc, Expr *Operand,
5239  SourceLocation RParen);
5240 
5241  /// Parsed one of the type trait support pseudo-functions.
5242  ExprResult ActOnTypeTrait(TypeTrait Kind, SourceLocation KWLoc,
5243  ArrayRef<ParsedType> Args,
5244  SourceLocation RParenLoc);
5245  ExprResult BuildTypeTrait(TypeTrait Kind, SourceLocation KWLoc,
5247  SourceLocation RParenLoc);
5248 
5249  /// ActOnArrayTypeTrait - Parsed one of the binary type trait support
5250  /// pseudo-functions.
5251  ExprResult ActOnArrayTypeTrait(ArrayTypeTrait ATT,
5252  SourceLocation KWLoc,
5253  ParsedType LhsTy,
5254  Expr *DimExpr,
5255  SourceLocation RParen);
5256 
5257  ExprResult BuildArrayTypeTrait(ArrayTypeTrait ATT,
5258  SourceLocation KWLoc,
5259  TypeSourceInfo *TSInfo,
5260  Expr *DimExpr,
5261  SourceLocation RParen);
5262 
5263  /// ActOnExpressionTrait - Parsed one of the unary type trait support
5264  /// pseudo-functions.
5265  ExprResult ActOnExpressionTrait(ExpressionTrait OET,
5266  SourceLocation KWLoc,
5267  Expr *Queried,
5268  SourceLocation RParen);
5269 
5270  ExprResult BuildExpressionTrait(ExpressionTrait OET,
5271  SourceLocation KWLoc,
5272  Expr *Queried,
5273  SourceLocation RParen);
5274 
5275  ExprResult ActOnStartCXXMemberReference(Scope *S,
5276  Expr *Base,
5277  SourceLocation OpLoc,
5278  tok::TokenKind OpKind,
5279  ParsedType &ObjectType,
5280  bool &MayBePseudoDestructor);
5281 
5282  ExprResult BuildPseudoDestructorExpr(Expr *Base,
5283  SourceLocation OpLoc,
5284  tok::TokenKind OpKind,
5285  const CXXScopeSpec &SS,
5286  TypeSourceInfo *ScopeType,
5287  SourceLocation CCLoc,
5288  SourceLocation TildeLoc,
5289  PseudoDestructorTypeStorage DestroyedType);
5290 
5291  ExprResult ActOnPseudoDestructorExpr(Scope *S, Expr *Base,
5292  SourceLocation OpLoc,
5293  tok::TokenKind OpKind,
5294  CXXScopeSpec &SS,
5295  UnqualifiedId &FirstTypeName,
5296  SourceLocation CCLoc,
5297  SourceLocation TildeLoc,
5298  UnqualifiedId &SecondTypeName);
5299 
5300  ExprResult ActOnPseudoDestructorExpr(Scope *S, Expr *Base,
5301  SourceLocation OpLoc,
5302  tok::TokenKind OpKind,
5303  SourceLocation TildeLoc,
5304  const DeclSpec& DS);
5305 
5306  /// MaybeCreateExprWithCleanups - If the current full-expression
5307  /// requires any cleanups, surround it with a ExprWithCleanups node.
5308  /// Otherwise, just returns the passed-in expression.
5309  Expr *MaybeCreateExprWithCleanups(Expr *SubExpr);
5310  Stmt *MaybeCreateStmtWithCleanups(Stmt *SubStmt);
5311  ExprResult MaybeCreateExprWithCleanups(ExprResult SubExpr);
5312 
5314  CreateMaterializeTemporaryExpr(QualType T, Expr *Temporary,
5315  bool BoundToLvalueReference);
5316 
5318  return ActOnFinishFullExpr(Expr, Expr ? Expr->getExprLoc()
5319  : SourceLocation());
5320  }
5321  ExprResult ActOnFinishFullExpr(Expr *Expr, SourceLocation CC,
5322  bool DiscardedValue = false,
5323  bool IsConstexpr = false,
5324  bool IsLambdaInitCaptureInitializer = false);
5325  StmtResult ActOnFinishFullStmt(Stmt *Stmt);
5326 
5327  // Marks SS invalid if it represents an incomplete type.
5328  bool RequireCompleteDeclContext(CXXScopeSpec &SS, DeclContext *DC);
5329 
5330  DeclContext *computeDeclContext(QualType T);
5331  DeclContext *computeDeclContext(const CXXScopeSpec &SS,
5332  bool EnteringContext = false);
5333  bool isDependentScopeSpecifier(const CXXScopeSpec &SS);
5335 
5336  /// The parser has parsed a global nested-name-specifier '::'.
5337  ///
5338  /// \param CCLoc The location of the '::'.
5339  ///
5340  /// \param SS The nested-name-specifier, which will be updated in-place
5341  /// to reflect the parsed nested-name-specifier.
5342  ///
5343  /// \returns true if an error occurred, false otherwise.
5344  bool ActOnCXXGlobalScopeSpecifier(SourceLocation CCLoc, CXXScopeSpec &SS);
5345 
5346  /// The parser has parsed a '__super' nested-name-specifier.
5347  ///
5348  /// \param SuperLoc The location of the '__super' keyword.
5349  ///
5350  /// \param ColonColonLoc The location of the '::'.
5351  ///
5352  /// \param SS The nested-name-specifier, which will be updated in-place
5353  /// to reflect the parsed nested-name-specifier.
5354  ///
5355  /// \returns true if an error occurred, false otherwise.
5356  bool ActOnSuperScopeSpecifier(SourceLocation SuperLoc,
5357  SourceLocation ColonColonLoc, CXXScopeSpec &SS);
5358 
5359  bool isAcceptableNestedNameSpecifier(const NamedDecl *SD,
5360  bool *CanCorrect = nullptr);
5361  NamedDecl *FindFirstQualifierInScope(Scope *S, NestedNameSpecifier *NNS);
5362 
5363  /// Keeps information about an identifier in a nested-name-spec.
5364  ///
5366  /// The type of the object, if we're parsing nested-name-specifier in
5367  /// a member access expression.
5369 
5370  /// The identifier preceding the '::'.
5372 
5373  /// The location of the identifier.
5375 
5376  /// The location of the '::'.
5378 
5379  /// Creates info object for the most typical case.
5381  SourceLocation ColonColonLoc, ParsedType ObjectType = ParsedType())
5382  : ObjectType(ObjectType), Identifier(II), IdentifierLoc(IdLoc),
5383  CCLoc(ColonColonLoc) {
5384  }
5385 
5387  SourceLocation ColonColonLoc, QualType ObjectType)
5388  : ObjectType(ParsedType::make(ObjectType)), Identifier(II),
5389  IdentifierLoc(IdLoc), CCLoc(ColonColonLoc) {
5390  }
5391  };
5392 
5393  bool isNonTypeNestedNameSpecifier(Scope *S, CXXScopeSpec &SS,
5394  NestedNameSpecInfo &IdInfo);
5395 
5396  bool BuildCXXNestedNameSpecifier(Scope *S,
5397  NestedNameSpecInfo &IdInfo,
5398  bool EnteringContext,
5399  CXXScopeSpec &SS,
5400  NamedDecl *ScopeLookupResult,
5401  bool ErrorRecoveryLookup,
5402  bool *IsCorrectedToColon = nullptr,
5403  bool OnlyNamespace = false);
5404 
5405  /// The parser has parsed a nested-name-specifier 'identifier::'.
5406  ///
5407  /// \param S The scope in which this nested-name-specifier occurs.
5408  ///
5409  /// \param IdInfo Parser information about an identifier in the
5410  /// nested-name-spec.
5411  ///
5412  /// \param EnteringContext Whether we're entering the context nominated by
5413  /// this nested-name-specifier.
5414  ///
5415  /// \param SS The nested-name-specifier, which is both an input
5416  /// parameter (the nested-name-specifier before this type) and an
5417  /// output parameter (containing the full nested-name-specifier,
5418  /// including this new type).
5419  ///
5420  /// \param ErrorRecoveryLookup If true, then this method is called to improve
5421  /// error recovery. In this case do not emit error message.
5422  ///
5423  /// \param IsCorrectedToColon If not null, suggestions to replace '::' -> ':'
5424  /// are allowed. The bool value pointed by this parameter is set to 'true'
5425  /// if the identifier is treated as if it was followed by ':', not '::'.
5426  ///
5427  /// \param OnlyNamespace If true, only considers namespaces in lookup.
5428  ///
5429  /// \returns true if an error occurred, false otherwise.
5430  bool ActOnCXXNestedNameSpecifier(Scope *S,
5431  NestedNameSpecInfo &IdInfo,
5432  bool EnteringContext,
5433  CXXScopeSpec &SS,
5434  bool ErrorRecoveryLookup = false,
5435  bool *IsCorrectedToColon = nullptr,
5436  bool OnlyNamespace = false);
5437 
5438  ExprResult ActOnDecltypeExpression(Expr *E);
5439 
5440  bool ActOnCXXNestedNameSpecifierDecltype(CXXScopeSpec &SS,
5441  const DeclSpec &DS,
5442  SourceLocation ColonColonLoc);
5443 
5444  bool IsInvalidUnlessNestedName(Scope *S, CXXScopeSpec &SS,
5445  NestedNameSpecInfo &IdInfo,
5446  bool EnteringContext);
5447 
5448  /// The parser has parsed a nested-name-specifier
5449  /// 'template[opt] template-name < template-args >::'.
5450  ///
5451  /// \param S The scope in which this nested-name-specifier occurs.
5452  ///
5453  /// \param SS The nested-name-specifier, which is both an input
5454  /// parameter (the nested-name-specifier before this type) and an
5455  /// output parameter (containing the full nested-name-specifier,
5456  /// including this new type).
5457  ///
5458  /// \param TemplateKWLoc the location of the 'template' keyword, if any.
5459  /// \param TemplateName the template name.
5460  /// \param TemplateNameLoc The location of the template name.
5461  /// \param LAngleLoc The location of the opening angle bracket ('<').
5462  /// \param TemplateArgs The template arguments.
5463  /// \param RAngleLoc The location of the closing angle bracket ('>').
5464  /// \param CCLoc The location of the '::'.
5465  ///
5466  /// \param EnteringContext Whether we're entering the context of the
5467  /// nested-name-specifier.
5468  ///
5469  ///
5470  /// \returns true if an error occurred, false otherwise.
5471  bool ActOnCXXNestedNameSpecifier(Scope *S,
5472  CXXScopeSpec &SS,
5473  SourceLocation TemplateKWLoc,
5474  TemplateTy TemplateName,
5475  SourceLocation TemplateNameLoc,
5476  SourceLocation LAngleLoc,
5477  ASTTemplateArgsPtr TemplateArgs,
5478  SourceLocation RAngleLoc,
5479  SourceLocation CCLoc,
5480  bool EnteringContext);
5481 
5482  /// Given a C++ nested-name-specifier, produce an annotation value
5483  /// that the parser can use later to reconstruct the given
5484  /// nested-name-specifier.
5485  ///
5486  /// \param SS A nested-name-specifier.
5487  ///
5488  /// \returns A pointer containing all of the information in the
5489  /// nested-name-specifier \p SS.
5490  void *SaveNestedNameSpecifierAnnotation(CXXScopeSpec &SS);
5491 
5492  /// Given an annotation pointer for a nested-name-specifier, restore
5493  /// the nested-name-specifier structure.
5494  ///
5495  /// \param Annotation The annotation pointer, produced by
5496  /// \c SaveNestedNameSpecifierAnnotation().
5497  ///
5498  /// \param AnnotationRange The source range corresponding to the annotation.
5499  ///
5500  /// \param SS The nested-name-specifier that will be updated with the contents
5501  /// of the annotation pointer.
5502  void RestoreNestedNameSpecifierAnnotation(void *Annotation,
5503  SourceRange AnnotationRange,
5504  CXXScopeSpec &SS);
5505 
5506  bool ShouldEnterDeclaratorScope(Scope *S, const CXXScopeSpec &SS);
5507 
5508  /// ActOnCXXEnterDeclaratorScope - Called when a C++ scope specifier (global
5509  /// scope or nested-name-specifier) is parsed, part of a declarator-id.
5510  /// After this method is called, according to [C++ 3.4.3p3], names should be
5511  /// looked up in the declarator-id's scope, until the declarator is parsed and
5512  /// ActOnCXXExitDeclaratorScope is called.
5513  /// The 'SS' should be a non-empty valid CXXScopeSpec.
5514  bool ActOnCXXEnterDeclaratorScope(Scope *S, CXXScopeSpec &SS);
5515 
5516  /// ActOnCXXExitDeclaratorScope - Called when a declarator that previously
5517  /// invoked ActOnCXXEnterDeclaratorScope(), is finished. 'SS' is the same
5518  /// CXXScopeSpec that was passed to ActOnCXXEnterDeclaratorScope as well.
5519  /// Used to indicate that names should revert to being looked up in the
5520  /// defining scope.
5521  void ActOnCXXExitDeclaratorScope(Scope *S, const CXXScopeSpec &SS);
5522 
5523  /// ActOnCXXEnterDeclInitializer - Invoked when we are about to parse an
5524  /// initializer for the declaration 'Dcl'.
5525  /// After this method is called, according to [C++ 3.4.1p13], if 'Dcl' is a
5526  /// static data member of class X, names should be looked up in the scope of
5527  /// class X.
5528  void ActOnCXXEnterDeclInitializer(Scope *S, Decl *Dcl);
5529 
5530  /// ActOnCXXExitDeclInitializer - Invoked after we are finished parsing an
5531  /// initializer for the declaration 'Dcl'.
5532  void ActOnCXXExitDeclInitializer(Scope *S, Decl *Dcl);
5533 
5534  /// Create a new lambda closure type.
5535  CXXRecordDecl *createLambdaClosureType(SourceRange IntroducerRange,
5536  TypeSourceInfo *Info,
5537  bool KnownDependent,
5538  LambdaCaptureDefault CaptureDefault);
5539 
5540  /// Start the definition of a lambda expression.
5541  CXXMethodDecl *startLambdaDefinition(CXXRecordDecl *Class,
5542  SourceRange IntroducerRange,
5543  TypeSourceInfo *MethodType,
5544  SourceLocation EndLoc,
5545  ArrayRef<ParmVarDecl *> Params,
5546  bool IsConstexprSpecified);
5547 
5548  /// Endow the lambda scope info with the relevant properties.
5549  void buildLambdaScope(sema::LambdaScopeInfo *LSI,
5550  CXXMethodDecl *CallOperator,
5551  SourceRange IntroducerRange,
5552  LambdaCaptureDefault CaptureDefault,
5553  SourceLocation CaptureDefaultLoc,
5554  bool ExplicitParams,
5555  bool ExplicitResultType,
5556  bool Mutable);
5557 
5558  /// Perform initialization analysis of the init-capture and perform
5559  /// any implicit conversions such as an lvalue-to-rvalue conversion if
5560  /// not being used to initialize a reference.
5562  SourceLocation Loc, bool ByRef, IdentifierInfo *Id,
5563  LambdaCaptureInitKind InitKind, Expr *&Init) {
5564  return ParsedType::make(buildLambdaInitCaptureInitialization(
5565  Loc, ByRef, Id, InitKind != LambdaCaptureInitKind::CopyInit, Init));
5566  }
5567  QualType buildLambdaInitCaptureInitialization(SourceLocation Loc, bool ByRef,
5568  IdentifierInfo *Id,
5569  bool DirectInit, Expr *&Init);
5570 
5571  /// Create a dummy variable within the declcontext of the lambda's
5572  /// call operator, for name lookup purposes for a lambda init capture.
5573  ///
5574  /// CodeGen handles emission of lambda captures, ignoring these dummy
5575  /// variables appropriately.
5576  VarDecl *createLambdaInitCaptureVarDecl(SourceLocation Loc,
5577  QualType InitCaptureType,
5578  IdentifierInfo *Id,
5579  unsigned InitStyle, Expr *Init);
5580 
5581  /// Build the implicit field for an init-capture.
5582  FieldDecl *buildInitCaptureField(sema::LambdaScopeInfo *LSI, VarDecl *Var);
5583 
5584  /// Note that we have finished the explicit captures for the
5585  /// given lambda.
5586  void finishLambdaExplicitCaptures(sema::LambdaScopeInfo *LSI);
5587 
5588  /// Introduce the lambda parameters into scope.
5589  void addLambdaParameters(CXXMethodDecl *CallOperator, Scope *CurScope);
5590 
5591  /// Deduce a block or lambda's return type based on the return
5592  /// statements present in the body.
5593  void deduceClosureReturnType(sema::CapturingScopeInfo &CSI);
5594 
5595  /// ActOnStartOfLambdaDefinition - This is called just before we start
5596  /// parsing the body of a lambda; it analyzes the explicit captures and
5597  /// arguments, and sets up various data-structures for the body of the
5598  /// lambda.
5599  void ActOnStartOfLambdaDefinition(LambdaIntroducer &Intro,
5600  Declarator &ParamInfo, Scope *CurScope);
5601 
5602  /// ActOnLambdaError - If there is an error parsing a lambda, this callback
5603  /// is invoked to pop the information about the lambda.
5604  void ActOnLambdaError(SourceLocation StartLoc, Scope *CurScope,
5605  bool IsInstantiation = false);
5606 
5607  /// ActOnLambdaExpr - This is called when the body of a lambda expression
5608  /// was successfully completed.
5609  ExprResult ActOnLambdaExpr(SourceLocation StartLoc, Stmt *Body,
5610  Scope *CurScope);
5611 
5612  /// Does copying/destroying the captured variable have side effects?
5613  bool CaptureHasSideEffects(const sema::Capture &From);
5614 
5615  /// Diagnose if an explicit lambda capture is unused. Returns true if a
5616  /// diagnostic is emitted.
5617  bool DiagnoseUnusedLambdaCapture(SourceRange CaptureRange,
5618  const sema::Capture &From);
5619 
5620  /// Complete a lambda-expression having processed and attached the
5621  /// lambda body.
5622  ExprResult BuildLambdaExpr(SourceLocation StartLoc, SourceLocation EndLoc,
5623  sema::LambdaScopeInfo *LSI);
5624 
5625  /// Get the return type to use for a lambda's conversion function(s) to
5626  /// function pointer type, given the type of the call operator.
5627  QualType
5628  getLambdaConversionFunctionResultType(const FunctionProtoType *CallOpType);
5629 
5630  /// Define the "body" of the conversion from a lambda object to a
5631  /// function pointer.
5632  ///
5633  /// This routine doesn't actually define a sensible body; rather, it fills
5634  /// in the initialization expression needed to copy the lambda object into
5635  /// the block, and IR generation actually generates the real body of the
5636  /// block pointer conversion.
5637  void DefineImplicitLambdaToFunctionPointerConversion(
5638  SourceLocation CurrentLoc, CXXConversionDecl *Conv);
5639 
5640  /// Define the "body" of the conversion from a lambda object to a
5641  /// block pointer.
5642  ///
5643  /// This routine doesn't actually define a sensible body; rather, it fills
5644  /// in the initialization expression needed to copy the lambda object into
5645  /// the block, and IR generation actually generates the real body of the
5646  /// block pointer conversion.
5647  void DefineImplicitLambdaToBlockPointerConversion(SourceLocation CurrentLoc,
5648  CXXConversionDecl *Conv);
5649 
5650  ExprResult BuildBlockForLambdaConversion(SourceLocation CurrentLocation,
5651  SourceLocation ConvLocation,
5652  CXXConversionDecl *Conv,
5653  Expr *Src);
5654 
5655  // ParseObjCStringLiteral - Parse Objective-C string literals.
5656  ExprResult ParseObjCStringLiteral(SourceLocation *AtLocs,
5657  ArrayRef<Expr *> Strings);
5658 
5659  ExprResult BuildObjCStringLiteral(SourceLocation AtLoc, StringLiteral *S);
5660 
5661  /// BuildObjCNumericLiteral - builds an ObjCBoxedExpr AST node for the
5662  /// numeric literal expression. Type of the expression will be "NSNumber *"
5663  /// or "id" if NSNumber is unavailable.
5664  ExprResult BuildObjCNumericLiteral(SourceLocation AtLoc, Expr *Number);
5665  ExprResult ActOnObjCBoolLiteral(SourceLocation AtLoc, SourceLocation ValueLoc,
5666  bool Value);
5667  ExprResult BuildObjCArrayLiteral(SourceRange SR, MultiExprArg Elements);
5668 
5669  /// BuildObjCBoxedExpr - builds an ObjCBoxedExpr AST node for the
5670  /// '@' prefixed parenthesized expression. The type of the expression will
5671  /// either be "NSNumber *", "NSString *" or "NSValue *" depending on the type
5672  /// of ValueType, which is allowed to be a built-in numeric type, "char *",
5673  /// "const char *" or C structure with attribute 'objc_boxable'.
5674  ExprResult BuildObjCBoxedExpr(SourceRange SR, Expr *ValueExpr);
5675 
5676  ExprResult BuildObjCSubscriptExpression(SourceLocation RB, Expr *BaseExpr,
5677  Expr *IndexExpr,
5678  ObjCMethodDecl *getterMethod,
5679  ObjCMethodDecl *setterMethod);
5680 
5681  ExprResult BuildObjCDictionaryLiteral(SourceRange SR,
5683 
5684  ExprResult BuildObjCEncodeExpression(SourceLocation AtLoc,
5685  TypeSourceInfo *EncodedTypeInfo,
5686  SourceLocation RParenLoc);
5687  ExprResult BuildCXXMemberCallExpr(Expr *Exp, NamedDecl *FoundDecl,
5688  CXXConversionDecl *Method,
5689  bool HadMultipleCandidates);
5690 
5691  ExprResult ParseObjCEncodeExpression(SourceLocation AtLoc,
5692  SourceLocation EncodeLoc,
5693  SourceLocation LParenLoc,
5694  ParsedType Ty,
5695  SourceLocation RParenLoc);
5696 
5697  /// ParseObjCSelectorExpression - Build selector expression for \@selector
5698  ExprResult ParseObjCSelectorExpression(Selector Sel,
5699  SourceLocation AtLoc,
5700  SourceLocation SelLoc,
5701  SourceLocation LParenLoc,
5702  SourceLocation RParenLoc,
5703  bool WarnMultipleSelectors);
5704 
5705  /// ParseObjCProtocolExpression - Build protocol expression for \@protocol
5706  ExprResult ParseObjCProtocolExpression(IdentifierInfo * ProtocolName,
5707  SourceLocation AtLoc,
5708  SourceLocation ProtoLoc,
5709  SourceLocation LParenLoc,
5710  SourceLocation ProtoIdLoc,
5711  SourceLocation RParenLoc);
5712 
5713  //===--------------------------------------------------------------------===//
5714  // C++ Declarations
5715  //
5716  Decl *ActOnStartLinkageSpecification(Scope *S,
5717  SourceLocation ExternLoc,
5718  Expr *LangStr,
5719  SourceLocation LBraceLoc);
5720  Decl *ActOnFinishLinkageSpecification(Scope *S,
5721  Decl *LinkageSpec,
5722  SourceLocation RBraceLoc);
5723 
5724 
5725  //===--------------------------------------------------------------------===//
5726  // C++ Classes
5727  //
5728  CXXRecordDecl *getCurrentClass(Scope *S, const CXXScopeSpec *SS);
5729  bool isCurrentClassName(const IdentifierInfo &II, Scope *S,
5730  const CXXScopeSpec *SS = nullptr);
5731  bool isCurrentClassNameTypo(IdentifierInfo *&II, const CXXScopeSpec *SS);
5732 
5733  bool ActOnAccessSpecifier(AccessSpecifier Access, SourceLocation ASLoc,
5734  SourceLocation ColonLoc,
5735  const ParsedAttributesView &Attrs);
5736 
5737  NamedDecl *ActOnCXXMemberDeclarator(Scope *S, AccessSpecifier AS,
5738  Declarator &D,
5739  MultiTemplateParamsArg TemplateParameterLists,
5740  Expr *BitfieldWidth, const VirtSpecifiers &VS,
5741  InClassInitStyle InitStyle);
5742 
5743  void ActOnStartCXXInClassMemberInitializer();
5744  void ActOnFinishCXXInClassMemberInitializer(Decl *VarDecl,
5745  SourceLocation EqualLoc,
5746  Expr *Init);
5747 
5748  MemInitResult ActOnMemInitializer(Decl *ConstructorD,
5749  Scope *S,
5750  CXXScopeSpec &SS,
5751  IdentifierInfo *MemberOrBase,
5752  ParsedType TemplateTypeTy,
5753  const DeclSpec &DS,
5754  SourceLocation IdLoc,
5755  SourceLocation LParenLoc,
5756  ArrayRef<Expr *> Args,
5757  SourceLocation RParenLoc,
5758  SourceLocation EllipsisLoc);
5759 
5760  MemInitResult ActOnMemInitializer(Decl *ConstructorD,
5761  Scope *S,
5762  CXXScopeSpec &SS,
5763  IdentifierInfo *MemberOrBase,
5764  ParsedType TemplateTypeTy,
5765  const DeclSpec &DS,
5766  SourceLocation IdLoc,
5767  Expr *InitList,
5768  SourceLocation EllipsisLoc);
5769 
5770  MemInitResult BuildMemInitializer(Decl *ConstructorD,
5771  Scope *S,
5772  CXXScopeSpec &SS,
5773  IdentifierInfo *MemberOrBase,
5774  ParsedType TemplateTypeTy,
5775  const DeclSpec &DS,
5776  SourceLocation IdLoc,
5777  Expr *Init,
5778  SourceLocation EllipsisLoc);
5779 
5780  MemInitResult BuildMemberInitializer(ValueDecl *Member,
5781  Expr *Init,
5782  SourceLocation IdLoc);
5783 
5784  MemInitResult BuildBaseInitializer(QualType BaseType,
5785  TypeSourceInfo *BaseTInfo,
5786  Expr *Init,
5787  CXXRecordDecl *ClassDecl,
5788  SourceLocation EllipsisLoc);
5789 
5790  MemInitResult BuildDelegatingInitializer(TypeSourceInfo *TInfo,
5791  Expr *Init,
5792  CXXRecordDecl *ClassDecl);
5793 
5794  bool SetDelegatingInitializer(CXXConstructorDecl *Constructor,
5795  CXXCtorInitializer *Initializer);
5796 
5797  bool SetCtorInitializers(CXXConstructorDecl *Constructor, bool AnyErrors,
5798  ArrayRef<CXXCtorInitializer *> Initializers = None);
5799 
5800  void SetIvarInitializers(ObjCImplementationDecl *ObjCImplementation);
5801 
5802 
5803  /// MarkBaseAndMemberDestructorsReferenced - Given a record decl,
5804  /// mark all the non-trivial destructors of its members and bases as
5805  /// referenced.
5806  void MarkBaseAndMemberDestructorsReferenced(SourceLocation Loc,
5807  CXXRecordDecl *Record);
5808 
5809  /// The list of classes whose vtables have been used within
5810  /// this translation unit, and the source locations at which the
5811  /// first use occurred.
5812  typedef std::pair<CXXRecordDecl*, SourceLocation> VTableUse;
5813 
5814  /// The list of vtables that are required but have not yet been
5815  /// materialized.
5817 
5818  /// The set of classes whose vtables have been used within
5819  /// this translation unit, and a bit that will be true if the vtable is
5820  /// required to be emitted (otherwise, it should be emitted only if needed
5821  /// by code generation).
5822  llvm::DenseMap<CXXRecordDecl *, bool> VTablesUsed;
5823 
5824  /// Load any externally-stored vtable uses.
5825  void LoadExternalVTableUses();
5826 
5827  /// Note that the vtable for the given class was used at the
5828  /// given location.
5829  void MarkVTableUsed(SourceLocation Loc, CXXRecordDecl *Class,
5830  bool DefinitionRequired = false);
5831 
5832  /// Mark the exception specifications of all virtual member functions
5833  /// in the given class as needed.
5834  void MarkVirtualMemberExceptionSpecsNeeded(SourceLocation Loc,
5835  const CXXRecordDecl *RD);
5836 
5837  /// MarkVirtualMembersReferenced - Will mark all members of the given
5838  /// CXXRecordDecl referenced.
5839  void MarkVirtualMembersReferenced(SourceLocation Loc,
5840  const CXXRecordDecl *RD);
5841 
5842  /// Define all of the vtables that have been used in this
5843  /// translation unit and reference any virtual members used by those
5844  /// vtables.
5845  ///
5846  /// \returns true if any work was done, false otherwise.
5847  bool DefineUsedVTables();
5848 
5849  void AddImplicitlyDeclaredMembersToClass(CXXRecordDecl *ClassDecl);
5850 
5851  void ActOnMemInitializers(Decl *ConstructorDecl,
5852  SourceLocation ColonLoc,
5854  bool AnyErrors);
5855 
5856  /// Check class-level dllimport/dllexport attribute. The caller must
5857  /// ensure that referenceDLLExportedClassMethods is called some point later
5858  /// when all outer classes of Class are complete.
5859  void checkClassLevelDLLAttribute(CXXRecordDecl *Class);
5860  void checkClassLevelCodeSegAttribute(CXXRecordDecl *Class);
5861 
5862  void referenceDLLExportedClassMethods();
5863 
5864  void propagateDLLAttrToBaseClassTemplate(
5865  CXXRecordDecl *Class, Attr *ClassAttr,
5866  ClassTemplateSpecializationDecl *BaseTemplateSpec,
5867  SourceLocation BaseLoc);
5868 
5869  void CheckCompletedCXXClass(CXXRecordDecl *Record);
5870 
5871  /// Check that the C++ class annoated with "trivial_abi" satisfies all the
5872  /// conditions that are needed for the attribute to have an effect.
5873  void checkIllFormedTrivialABIStruct(CXXRecordDecl &RD);
5874 
5875  void ActOnFinishCXXMemberSpecification(Scope *S, SourceLocation RLoc,
5876  Decl *TagDecl, SourceLocation LBrac,
5877  SourceLocation RBrac,
5878  const ParsedAttributesView &AttrList);
5879  void ActOnFinishCXXMemberDecls();
5880  void ActOnFinishCXXNonNestedClass(Decl *D);
5881 
5882  void ActOnReenterCXXMethodParameter(Scope *S, ParmVarDecl *Param);
5883  unsigned ActOnReenterTemplateScope(Scope *S, Decl *Template);
5884  void ActOnStartDelayedMemberDeclarations(Scope *S, Decl *Record);
5885  void ActOnStartDelayedCXXMethodDeclaration(Scope *S, Decl *Method);
5886  void ActOnDelayedCXXMethodParameter(Scope *S, Decl *Param);
5887  void ActOnFinishDelayedMemberDeclarations(Scope *S, Decl *Record);
5888  void ActOnFinishDelayedCXXMethodDeclaration(Scope *S, Decl *Method);
5889  void ActOnFinishDelayedMemberInitializers(Decl *Record);
5890  void MarkAsLateParsedTemplate(FunctionDecl *FD, Decl *FnD,
5891  CachedTokens &Toks);
5892  void UnmarkAsLateParsedTemplate(FunctionDecl *FD);
5893  bool IsInsideALocalClassWithinATemplateFunction();
5894 
5895  Decl *ActOnStaticAssertDeclaration(SourceLocation StaticAssertLoc,
5896  Expr *AssertExpr,
5897  Expr *AssertMessageExpr,
5898  SourceLocation RParenLoc);
5899  Decl *BuildStaticAssertDeclaration(SourceLocation StaticAssertLoc,
5900  Expr *AssertExpr,
5901  StringLiteral *AssertMessageExpr,
5902  SourceLocation RParenLoc,
5903  bool Failed);
5904 
5905  FriendDecl *CheckFriendTypeDecl(SourceLocation LocStart,
5906  SourceLocation FriendLoc,
5907  TypeSourceInfo *TSInfo);
5908  Decl *ActOnFriendTypeDecl(Scope *S, const DeclSpec &DS,
5909  MultiTemplateParamsArg TemplateParams);
5910  NamedDecl *ActOnFriendFunctionDecl(Scope *S, Declarator &D,
5911  MultiTemplateParamsArg TemplateParams);
5912 
5913  QualType CheckConstructorDeclarator(Declarator &D, QualType R,
5914  StorageClass& SC);
5915  void CheckConstructor(CXXConstructorDecl *Constructor);
5916  QualType CheckDestructorDeclarator(Declarator &D, QualType R,
5917  StorageClass& SC);
5918  bool CheckDestructor(CXXDestructorDecl *Destructor);
5919  void CheckConversionDeclarator(Declarator &D, QualType &R,
5920  StorageClass& SC);
5921  Decl *ActOnConversionDeclarator(CXXConversionDecl *Conversion);
5922  void CheckDeductionGuideDeclarator(Declarator &D, QualType &R,
5923  StorageClass &SC);
5924  void CheckDeductionGuideTemplate(FunctionTemplateDecl *TD);
5925 
5926  void CheckExplicitlyDefaultedSpecialMember(CXXMethodDecl *MD);
5927  void CheckExplicitlyDefaultedMemberExceptionSpec(CXXMethodDecl *MD,
5928  const FunctionProtoType *T);
5929  void CheckDelayedMemberExceptionSpecs();
5930 
5931  //===--------------------------------------------------------------------===//
5932  // C++ Derived Classes
5933  //
5934 
5935  /// ActOnBaseSpecifier - Parsed a base specifier
5936  CXXBaseSpecifier *CheckBaseSpecifier(CXXRecordDecl *Class,
5937  SourceRange SpecifierRange,
5938  bool Virtual, AccessSpecifier Access,
5939  TypeSourceInfo *TInfo,
5940  SourceLocation EllipsisLoc);
5941 
5942  BaseResult ActOnBaseSpecifier(Decl *classdecl,
5943  SourceRange SpecifierRange,
5944  ParsedAttributes &Attrs,
5945  bool Virtual, AccessSpecifier Access,
5946  ParsedType basetype,
5947  SourceLocation BaseLoc,
5948  SourceLocation EllipsisLoc);
5949 
5950  bool AttachBaseSpecifiers(CXXRecordDecl *Class,
5952  void ActOnBaseSpecifiers(Decl *ClassDecl,
5954 
5955  bool IsDerivedFrom(SourceLocation Loc, QualType Derived, QualType Base);
5956  bool IsDerivedFrom(SourceLocation Loc, QualType Derived, QualType Base,
5957  CXXBasePaths &Paths);
5958 
5959  // FIXME: I don't like this name.
5960  void BuildBasePathArray(const CXXBasePaths &Paths, CXXCastPath &BasePath);
5961 
5962  bool CheckDerivedToBaseConversion(QualType Derived, QualType Base,
5963  SourceLocation Loc, SourceRange Range,
5964  CXXCastPath *BasePath = nullptr,
5965  bool IgnoreAccess = false);
5966  bool CheckDerivedToBaseConversion(QualType Derived, QualType Base,
5967  unsigned InaccessibleBaseID,
5968  unsigned AmbigiousBaseConvID,
5969  SourceLocation Loc, SourceRange Range,
5970  DeclarationName Name,
5971  CXXCastPath *BasePath,
5972  bool IgnoreAccess = false);
5973 
5974  std::string getAmbiguousPathsDisplayString(CXXBasePaths &Paths);
5975 
5976  bool CheckOverridingFunctionAttributes(const CXXMethodDecl *New,
5977  const CXXMethodDecl *Old);
5978 
5979  /// CheckOverridingFunctionReturnType - Checks whether the return types are
5980  /// covariant, according to C++ [class.virtual]p5.
5981  bool CheckOverridingFunctionReturnType(const CXXMethodDecl *New,
5982  const CXXMethodDecl *Old);
5983 
5984  /// CheckOverridingFunctionExceptionSpec - Checks whether the exception
5985  /// spec is a subset of base spec.
5986  bool CheckOverridingFunctionExceptionSpec(const CXXMethodDecl *New,
5987  const CXXMethodDecl *Old);
5988 
5989  bool CheckPureMethod(CXXMethodDecl *Method, SourceRange InitRange);
5990 
5991  /// CheckOverrideControl - Check C++11 override control semantics.
5992  void CheckOverrideControl(NamedDecl *D);
5993 
5994  /// DiagnoseAbsenceOfOverrideControl - Diagnose if 'override' keyword was
5995  /// not used in the declaration of an overriding method.
5996  void DiagnoseAbsenceOfOverrideControl(NamedDecl *D);
5997 
5998  /// CheckForFunctionMarkedFinal - Checks whether a virtual member function
5999  /// overrides a virtual member function marked 'final', according to
6000  /// C++11 [class.virtual]p4.
6001  bool CheckIfOverriddenFunctionIsMarkedFinal(const CXXMethodDecl *New,
6002  const CXXMethodDecl *Old);
6003 
6004 
6005  //===--------------------------------------------------------------------===//
6006  // C++ Access Control
6007  //
6008 
6013  AR_delayed
6014  };
6015 
6016  bool SetMemberAccessSpecifier(NamedDecl *MemberDecl,
6017  NamedDecl *PrevMemberDecl,
6018  AccessSpecifier LexicalAS);
6019 
6020  AccessResult CheckUnresolvedMemberAccess(UnresolvedMemberExpr *E,
6021  DeclAccessPair FoundDecl);
6022  AccessResult CheckUnresolvedLookupAccess(UnresolvedLookupExpr *E,
6023  DeclAccessPair FoundDecl);
6024  AccessResult CheckAllocationAccess(SourceLocation OperatorLoc,
6025  SourceRange PlacementRange,
6026  CXXRecordDecl *NamingClass,
6027  DeclAccessPair FoundDecl,
6028  bool Diagnose = true);
6029  AccessResult CheckConstructorAccess(SourceLocation Loc,
6030  CXXConstructorDecl *D,
6031  DeclAccessPair FoundDecl,
6032  const InitializedEntity &Entity,
6033  bool IsCopyBindingRefToTemp = false);
6034  AccessResult CheckConstructorAccess(SourceLocation Loc,
6035  CXXConstructorDecl *D,
6036  DeclAccessPair FoundDecl,
6037  const InitializedEntity &Entity,
6038  const PartialDiagnostic &PDiag);
6039  AccessResult CheckDestructorAccess(SourceLocation Loc,
6040  CXXDestructorDecl *Dtor,
6041  const PartialDiagnostic &PDiag,
6042  QualType objectType = QualType());
6043  AccessResult CheckFriendAccess(NamedDecl *D);
6044  AccessResult CheckMemberAccess(SourceLocation UseLoc,
6045  CXXRecordDecl *NamingClass,
6046  DeclAccessPair Found);
6047  AccessResult CheckMemberOperatorAccess(SourceLocation Loc,
6048  Expr *ObjectExpr,
6049  Expr *ArgExpr,
6050  DeclAccessPair FoundDecl);
6051  AccessResult CheckAddressOfMemberAccess(Expr *OvlExpr,
6052  DeclAccessPair FoundDecl);
6053  AccessResult CheckBaseClassAccess(SourceLocation AccessLoc,
6054  QualType Base, QualType Derived,
6055  const CXXBasePath &Path,
6056  unsigned DiagID,
6057  bool ForceCheck = false,
6058  bool ForceUnprivileged = false);
6059  void CheckLookupAccess(const LookupResult &R);
6060  bool IsSimplyAccessible(NamedDecl *decl, DeclContext *Ctx);
6061  bool isSpecialMemberAccessibleForDeletion(CXXMethodDecl *decl,
6062  AccessSpecifier access,
6063  QualType objectType);
6064 
6065  void HandleDependentAccessCheck(const DependentDiagnostic &DD,
6066  const MultiLevelTemplateArgumentList &TemplateArgs);
6067  void PerformDependentDiagnostics(const DeclContext *Pattern,
6068  const MultiLevelTemplateArgumentList &TemplateArgs);
6069 
6070  void HandleDelayedAccessCheck(sema::DelayedDiagnostic &DD, Decl *Ctx);
6071 
6072  /// When true, access checking violations are treated as SFINAE
6073  /// failures rather than hard errors.
6075 
6077  AbstractNone = -1,
6084  AbstractArrayType
6085  };
6086 
6087  bool isAbstractType(SourceLocation Loc, QualType T);
6088  bool RequireNonAbstractType(SourceLocation Loc, QualType T,
6089  TypeDiagnoser &Diagnoser);
6090  template <typename... Ts>
6091  bool RequireNonAbstractType(SourceLocation Loc, QualType T, unsigned DiagID,
6092  const Ts &...Args) {
6093  BoundTypeDiagnoser<Ts...> Diagnoser(DiagID, Args...);
6094  return RequireNonAbstractType(Loc, T, Diagnoser);
6095  }
6096 
6097  void DiagnoseAbstractType(const CXXRecordDecl *RD);
6098 
6099  //===--------------------------------------------------------------------===//
6100  // C++ Overloaded Operators [C++ 13.5]
6101  //
6102 
6103  bool CheckOverloadedOperatorDeclaration(FunctionDecl *FnDecl);
6104 
6105  bool CheckLiteralOperatorDeclaration(FunctionDecl *FnDecl);
6106 
6107  //===--------------------------------------------------------------------===//
6108  // C++ Templates [C++ 14]
6109  //
6110  void FilterAcceptableTemplateNames(LookupResult &R,
6111  bool AllowFunctionTemplates = true);
6112  bool hasAnyAcceptableTemplateNames(LookupResult &R,
6113  bool AllowFunctionTemplates = true);
6114 
6115  bool LookupTemplateName(LookupResult &R, Scope *S, CXXScopeSpec &SS,
6116  QualType ObjectType, bool EnteringContext,
6117  bool &MemberOfUnknownSpecialization,
6118  SourceLocation TemplateKWLoc = SourceLocation());
6119 
6120  TemplateNameKind isTemplateName(Scope *S,
6121  CXXScopeSpec &SS,
6122  bool hasTemplateKeyword,
6123  const UnqualifiedId &Name,
6124  ParsedType ObjectType,
6125  bool EnteringContext,
6126  TemplateTy &Template,
6127  bool &MemberOfUnknownSpecialization);
6128 
6129  /// Determine whether a particular identifier might be the name in a C++1z
6130  /// deduction-guide declaration.
6131  bool isDeductionGuideName(Scope *S, const IdentifierInfo &Name,
6132  SourceLocation NameLoc,
6133  ParsedTemplateTy *Template = nullptr);
6134 
6135  bool DiagnoseUnknownTemplateName(const IdentifierInfo &II,
6136  SourceLocation IILoc,
6137  Scope *S,
6138  const CXXScopeSpec *SS,
6139  TemplateTy &SuggestedTemplate,
6140  TemplateNameKind &SuggestedKind);
6141 
6142  bool DiagnoseUninstantiableTemplate(SourceLocation PointOfInstantiation,
6143  NamedDecl *Instantiation,
6144  bool InstantiatedFromMember,
6145  const NamedDecl *Pattern,
6146  const NamedDecl *PatternDef,
6148  bool Complain = true);
6149 
6150  void DiagnoseTemplateParameterShadow(SourceLocation Loc, Decl *PrevDecl);
6151  TemplateDecl *AdjustDeclIfTemplate(Decl *&Decl);
6152 
6153  NamedDecl *ActOnTypeParameter(Scope *S, bool Typename,
6154  SourceLocation EllipsisLoc,
6155  SourceLocation KeyLoc,
6156  IdentifierInfo *ParamName,
6157  SourceLocation ParamNameLoc,
6158  unsigned Depth, unsigned Position,
6159  SourceLocation EqualLoc,
6160  ParsedType DefaultArg);
6161 
6162  QualType CheckNonTypeTemplateParameterType(TypeSourceInfo *&TSI,
6163  SourceLocation Loc);
6164  QualType CheckNonTypeTemplateParameterType(QualType T, SourceLocation Loc);
6165 
6166  NamedDecl *ActOnNonTypeTemplateParameter(Scope *S, Declarator &D,
6167  unsigned Depth,
6168  unsigned Position,
6169  SourceLocation EqualLoc,
6170  Expr *DefaultArg);
6171  NamedDecl *ActOnTemplateTemplateParameter(Scope *S,
6172  SourceLocation TmpLoc,
6173  TemplateParameterList *Params,
6174  SourceLocation EllipsisLoc,
6175  IdentifierInfo *ParamName,
6176  SourceLocation ParamNameLoc,
6177  unsigned Depth,
6178  unsigned Position,
6179  SourceLocation EqualLoc,
6180  ParsedTemplateArgument DefaultArg);
6181 
6183  ActOnTemplateParameterList(unsigned Depth,
6184  SourceLocation ExportLoc,
6185  SourceLocation TemplateLoc,
6186  SourceLocation LAngleLoc,
6187  ArrayRef<NamedDecl *> Params,
6188  SourceLocation RAngleLoc,
6189  Expr *RequiresClause);
6190 
6191  /// The context in which we are checking a template parameter list.
6200  TPC_TypeAliasTemplate
6201  };
6202 
6203  bool CheckTemplateParameterList(TemplateParameterList *NewParams,
6204  TemplateParameterList *OldParams,
6206  TemplateParameterList *MatchTemplateParametersToScopeSpecifier(
6207  SourceLocation DeclStartLoc, SourceLocation DeclLoc,
6208  const CXXScopeSpec &SS, TemplateIdAnnotation *TemplateId,
6210  bool IsFriend, bool &IsMemberSpecialization, bool &Invalid);
6211 
6212  DeclResult CheckClassTemplate(
6213  Scope *S, unsigned TagSpec, TagUseKind TUK, SourceLocation KWLoc,
6214  CXXScopeSpec &SS, IdentifierInfo *Name, SourceLocation NameLoc,
6215  const ParsedAttributesView &Attr, TemplateParameterList *TemplateParams,
6216  AccessSpecifier AS, SourceLocation ModulePrivateLoc,
6217  SourceLocation FriendLoc, unsigned NumOuterTemplateParamLists,
6218  TemplateParameterList **OuterTemplateParamLists,
6219  SkipBodyInfo *SkipBody = nullptr);
6220 
6221  TemplateArgumentLoc getTrivialTemplateArgumentLoc(const TemplateArgument &Arg,
6222  QualType NTTPType,
6223  SourceLocation Loc);
6224 
6225  void translateTemplateArguments(const ASTTemplateArgsPtr &In,
6227 
6228  ParsedTemplateArgument ActOnTemplateTypeArgument(TypeResult ParsedType);
6229 
6230  void NoteAllFoundTemplates(TemplateName Name);
6231 
6232  QualType CheckTemplateIdType(TemplateName Template,
6233  SourceLocation TemplateLoc,
6234  TemplateArgumentListInfo &TemplateArgs);
6235 
6236  TypeResult
6237  ActOnTemplateIdType(CXXScopeSpec &SS, SourceLocation TemplateKWLoc,
6238  TemplateTy Template, IdentifierInfo *TemplateII,
6239  SourceLocation TemplateIILoc,
6240  SourceLocation LAngleLoc,
6241  ASTTemplateArgsPtr TemplateArgs,
6242  SourceLocation RAngleLoc,
6243  bool IsCtorOrDtorName = false,
6244  bool IsClassName = false);
6245 
6246  /// Parsed an elaborated-type-specifier that refers to a template-id,
6247  /// such as \c class T::template apply<U>.
6248  TypeResult ActOnTagTemplateIdType(TagUseKind TUK,
6249  TypeSpecifierType TagSpec,
6250  SourceLocation TagLoc,
6251  CXXScopeSpec &SS,
6252  SourceLocation TemplateKWLoc,
6253  TemplateTy TemplateD,
6254  SourceLocation TemplateLoc,
6255  SourceLocation LAngleLoc,
6256  ASTTemplateArgsPtr TemplateArgsIn,
6257  SourceLocation RAngleLoc);
6258 
6259  DeclResult ActOnVarTemplateSpecialization(
6260  Scope *S, Declarator &D, TypeSourceInfo *DI,
6261  SourceLocation TemplateKWLoc, TemplateParameterList *TemplateParams,
6263 
6264  DeclResult CheckVarTemplateId(VarTemplateDecl *Template,
6265  SourceLocation TemplateLoc,
6266  SourceLocation TemplateNameLoc,
6267  const TemplateArgumentListInfo &TemplateArgs);
6268 
6269  ExprResult CheckVarTemplateId(const CXXScopeSpec &SS,
6270  const DeclarationNameInfo &NameInfo,
6271  VarTemplateDecl *Template,
6272  SourceLocation TemplateLoc,
6273  const TemplateArgumentListInfo *TemplateArgs);
6274 
6275  void diagnoseMissingTemplateArguments(TemplateName Name, SourceLocation Loc);
6276 
6277  ExprResult BuildTemplateIdExpr(const CXXScopeSpec &SS,
6278  SourceLocation TemplateKWLoc,
6279  LookupResult &R,
6280  bool RequiresADL,
6281  const TemplateArgumentListInfo *TemplateArgs);
6282 
6283  ExprResult BuildQualifiedTemplateIdExpr(CXXScopeSpec &SS,
6284  SourceLocation TemplateKWLoc,
6285  const DeclarationNameInfo &NameInfo,
6286  const TemplateArgumentListInfo *TemplateArgs);
6287 
6288  TemplateNameKind ActOnDependentTemplateName(
6289  Scope *S, CXXScopeSpec &SS, SourceLocation TemplateKWLoc,
6290  const UnqualifiedId &Name, ParsedType ObjectType, bool EnteringContext,
6291  TemplateTy &Template, bool AllowInjectedClassName = false);
6292 
6293  DeclResult ActOnClassTemplateSpecialization(
6294  Scope *S, unsigned TagSpec, TagUseKind TUK, SourceLocation KWLoc,
6295  SourceLocation ModulePrivateLoc, TemplateIdAnnotation &TemplateId,
6296  const ParsedAttributesView &Attr,
6297  MultiTemplateParamsArg TemplateParameterLists,
6298  SkipBodyInfo *SkipBody = nullptr);
6299 
6300  bool CheckTemplatePartialSpecializationArgs(SourceLocation Loc,
6301  TemplateDecl *PrimaryTemplate,
6302  unsigned NumExplicitArgs,
6304  void CheckTemplatePartialSpecialization(
6306  void CheckTemplatePartialSpecialization(
6308 
6309  Decl *ActOnTemplateDeclarator(Scope *S,
6310  MultiTemplateParamsArg TemplateParameterLists,
6311  Declarator &D);
6312 
6313  bool
6314  CheckSpecializationInstantiationRedecl(SourceLocation NewLoc,
6316  NamedDecl *PrevDecl,
6318  SourceLocation PrevPtOfInstantiation,
6319  bool &SuppressNew);
6320 
6321  bool CheckDependentFunctionTemplateSpecialization(FunctionDecl *FD,
6322  const TemplateArgumentListInfo &ExplicitTemplateArgs,
6323  LookupResult &Previous);
6324 
6325  bool CheckFunctionTemplateSpecialization(FunctionDecl *FD,
6326  TemplateArgumentListInfo *ExplicitTemplateArgs,
6327  LookupResult &Previous);
6328  bool CheckMemberSpecialization(NamedDecl *Member, LookupResult &Previous);
6329  void CompleteMemberSpecialization(NamedDecl *Member, LookupResult &Previous);
6330 
6331  DeclResult ActOnExplicitInstantiation(
6332  Scope *S, SourceLocation ExternLoc, SourceLocation TemplateLoc,
6333  unsigned TagSpec, SourceLocation KWLoc, const CXXScopeSpec &SS,
6334  TemplateTy Template, SourceLocation TemplateNameLoc,
6335  SourceLocation LAngleLoc, ASTTemplateArgsPtr TemplateArgs,
6336  SourceLocation RAngleLoc, const ParsedAttributesView &Attr);
6337 
6338  DeclResult ActOnExplicitInstantiation(Scope *S, SourceLocation ExternLoc,
6339  SourceLocation TemplateLoc,
6340  unsigned TagSpec, SourceLocation KWLoc,
6341  CXXScopeSpec &SS, IdentifierInfo *Name,
6342  SourceLocation NameLoc,
6343  const ParsedAttributesView &Attr);
6344 
6345  DeclResult ActOnExplicitInstantiation(Scope *S,
6346  SourceLocation ExternLoc,
6347  SourceLocation TemplateLoc,
6348  Declarator &D);
6349 
6351  SubstDefaultTemplateArgumentIfAvailable(TemplateDecl *Template,
6352  SourceLocation TemplateLoc,
6353  SourceLocation RAngleLoc,
6354  Decl *Param,
6356  &Converted,
6357  bool &HasDefaultArg);
6358 
6359  /// Specifies the context in which a particular template
6360  /// argument is being checked.
6362  /// The template argument was specified in the code or was
6363  /// instantiated with some deduced template arguments.
6365 
6366  /// The template argument was deduced via template argument
6367  /// deduction.
6369 
6370  /// The template argument was deduced from an array bound
6371  /// via template argument deduction.
6372  CTAK_DeducedFromArrayBound
6373  };
6374 
6375  bool CheckTemplateArgument(NamedDecl *Param,
6376  TemplateArgumentLoc &Arg,
6377  NamedDecl *Template,
6378  SourceLocation TemplateLoc,
6379  SourceLocation RAngleLoc,
6380  unsigned ArgumentPackIndex,
6382  CheckTemplateArgumentKind CTAK = CTAK_Specified);
6383 
6384  /// Check that the given template arguments can be be provided to
6385  /// the given template, converting the arguments along the way.
6386  ///
6387  /// \param Template The template to which the template arguments are being
6388  /// provided.
6389  ///
6390  /// \param TemplateLoc The location of the template name in the source.
6391  ///
6392  /// \param TemplateArgs The list of template arguments. If the template is
6393  /// a template template parameter, this function may extend the set of
6394  /// template arguments to also include substituted, defaulted template
6395  /// arguments.
6396  ///
6397  /// \param PartialTemplateArgs True if the list of template arguments is
6398  /// intentionally partial, e.g., because we're checking just the initial
6399  /// set of template arguments.
6400  ///
6401  /// \param Converted Will receive the converted, canonicalized template
6402  /// arguments.
6403  ///
6404  /// \param UpdateArgsWithConversions If \c true, update \p TemplateArgs to
6405  /// contain the converted forms of the template arguments as written.
6406  /// Otherwise, \p TemplateArgs will not be modified.
6407  ///
6408  /// \returns true if an error occurred, false otherwise.
6409  bool CheckTemplateArgumentList(TemplateDecl *Template,
6410  SourceLocation TemplateLoc,
6411  TemplateArgumentListInfo &TemplateArgs,
6412  bool PartialTemplateArgs,
6414  bool UpdateArgsWithConversions = true);
6415 
6416  bool CheckTemplateTypeArgument(TemplateTypeParmDecl *Param,
6417  TemplateArgumentLoc &Arg,
6419 
6420  bool CheckTemplateArgument(TemplateTypeParmDecl *Param,
6421  TypeSourceInfo *Arg);
6422  ExprResult CheckTemplateArgument(NonTypeTemplateParmDecl *Param,
6423  QualType InstantiatedParamType, Expr *Arg,
6424  TemplateArgument &Converted,
6425  CheckTemplateArgumentKind CTAK = CTAK_Specified);
6426  bool CheckTemplateTemplateArgument(TemplateParameterList *Params,
6427  TemplateArgumentLoc &Arg);
6428 
6429  ExprResult
6430  BuildExpressionFromDeclTemplateArgument(const TemplateArgument &Arg,
6431  QualType ParamType,
6432  SourceLocation Loc);
6433  ExprResult
6434  BuildExpressionFromIntegralTemplateArgument(const TemplateArgument &Arg,
6435  SourceLocation Loc);
6436 
6437  /// Enumeration describing how template parameter lists are compared
6438  /// for equality.
6440  /// We are matching the template parameter lists of two templates
6441  /// that might be redeclarations.
6442  ///
6443  /// \code
6444  /// template<typename T> struct X;
6445  /// template<typename T> struct X;
6446  /// \endcode
6448 
6449  /// We are matching the template parameter lists of two template
6450  /// template parameters as part of matching the template parameter lists
6451  /// of two templates that might be redeclarations.
6452  ///
6453  /// \code
6454  /// template<template<int I> class TT> struct X;
6455  /// template<template<int Value> class Other> struct X;
6456  /// \endcode
6458 
6459  /// We are matching the template parameter lists of a template
6460  /// template argument against the template parameter lists of a template
6461  /// template parameter.
6462  ///
6463  /// \code
6464  /// template<template<int Value> class Metafun> struct X;
6465  /// template<int Value> struct integer_c;
6466  /// X<integer_c> xic;
6467  /// \endcode
6468  TPL_TemplateTemplateArgumentMatch
6469  };
6470 
6471  bool TemplateParameterListsAreEqual(TemplateParameterList *New,
6472  TemplateParameterList *Old,
6473  bool Complain,
6475  SourceLocation TemplateArgLoc
6476  = SourceLocation());
6477 
6478  bool CheckTemplateDeclScope(Scope *S, TemplateParameterList *TemplateParams);
6479 
6480  /// Called when the parser has parsed a C++ typename
6481  /// specifier, e.g., "typename T::type".
6482  ///
6483  /// \param S The scope in which this typename type occurs.
6484  /// \param TypenameLoc the location of the 'typename' keyword
6485  /// \param SS the nested-name-specifier following the typename (e.g., 'T::').
6486  /// \param II the identifier we're retrieving (e.g., 'type' in the example).
6487  /// \param IdLoc the location of the identifier.
6488  TypeResult
6489  ActOnTypenameType(Scope *S, SourceLocation TypenameLoc,
6490  const CXXScopeSpec &SS, const IdentifierInfo &II,
6491  SourceLocation IdLoc);
6492 
6493  /// Called when the parser has parsed a C++ typename
6494  /// specifier that ends in a template-id, e.g.,
6495  /// "typename MetaFun::template apply<T1, T2>".
6496  ///
6497  /// \param S The scope in which this typename type occurs.
6498  /// \param TypenameLoc the location of the 'typename' keyword
6499  /// \param SS the nested-name-specifier following the typename (e.g., 'T::').
6500  /// \param TemplateLoc the location of the 'template' keyword, if any.
6501  /// \param TemplateName The template name.
6502  /// \param TemplateII The identifier used to name the template.
6503  /// \param TemplateIILoc The location of the template name.
6504  /// \param LAngleLoc The location of the opening angle bracket ('<').
6505  /// \param TemplateArgs The template arguments.
6506  /// \param RAngleLoc The location of the closing angle bracket ('>').
6507  TypeResult
6508  ActOnTypenameType(Scope *S, SourceLocation TypenameLoc,
6509  const CXXScopeSpec &SS,
6510  SourceLocation TemplateLoc,
6511  TemplateTy TemplateName,
6512  IdentifierInfo *TemplateII,
6513  SourceLocation TemplateIILoc,
6514  SourceLocation LAngleLoc,
6515  ASTTemplateArgsPtr TemplateArgs,
6516  SourceLocation RAngleLoc);
6517 
6518  QualType CheckTypenameType(ElaboratedTypeKeyword Keyword,
6519  SourceLocation KeywordLoc,
6520  NestedNameSpecifierLoc QualifierLoc,
6521  const IdentifierInfo &II,
6522  SourceLocation IILoc);
6523 
6524  TypeSourceInfo *RebuildTypeInCurrentInstantiation(TypeSourceInfo *T,
6525  SourceLocation Loc,
6526  DeclarationName Name);
6527  bool RebuildNestedNameSpecifierInCurrentInstantiation(CXXScopeSpec &SS);
6528 
6529  ExprResult RebuildExprInCurrentInstantiation(Expr *E);
6530  bool RebuildTemplateParamsInCurrentInstantiation(
6531  TemplateParameterList *Params);
6532 
6533  std::string
6534  getTemplateArgumentBindingsText(const TemplateParameterList *Params,
6535  const TemplateArgumentList &Args);
6536 
6537  std::string
6538  getTemplateArgumentBindingsText(const TemplateParameterList *Params,
6539  const TemplateArgument *Args,
6540  unsigned NumArgs);
6541 
6542  //===--------------------------------------------------------------------===//
6543  // C++ Variadic Templates (C++0x [temp.variadic])
6544  //===--------------------------------------------------------------------===//
6545 
6546  /// Determine whether an unexpanded parameter pack might be permitted in this
6547  /// location. Useful for error recovery.
6548  bool isUnexpandedParameterPackPermitted();
6549 
6550  /// The context in which an unexpanded parameter pack is
6551  /// being diagnosed.
6552  ///
6553  /// Note that the values of this enumeration line up with the first
6554  /// argument to the \c err_unexpanded_parameter_pack diagnostic.
6556  /// An arbitrary expression.
6557  UPPC_Expression = 0,
6558 
6559  /// The base type of a class type.
6561 
6562  /// The type of an arbitrary declaration.
6564 
6565  /// The type of a data member.
6567 
6568  /// The size of a bit-field.
6570 
6571  /// The expression in a static assertion.
6573 
6574  /// The fixed underlying type of an enumeration.
6576 
6577  /// The enumerator value.
6579 
6580  /// A using declaration.
6582 
6583  /// A friend declaration.
6585 
6586  /// A declaration qualifier.
6588 
6589  /// An initializer.
6591 
6592  /// A default argument.
6594 
6595  /// The type of a non-type template parameter.
6597 
6598  /// The type of an exception.
6600 
6601  /// Partial specialization.
6603 
6604  /// Microsoft __if_exists.
6606 
6607  /// Microsoft __if_not_exists.
6609 
6610  /// Lambda expression.
6612 
6613  /// Block expression,
6614  UPPC_Block
6615  };
6616 
6617  /// Diagnose unexpanded parameter packs.
6618  ///
6619  /// \param Loc The location at which we should emit the diagnostic.
6620  ///
6621  /// \param UPPC The context in which we are diagnosing unexpanded
6622  /// parameter packs.
6623  ///
6624  /// \param Unexpanded the set of unexpanded parameter packs.
6625  ///
6626  /// \returns true if an error occurred, false otherwise.
6630 
6631  /// If the given type contains an unexpanded parameter pack,
6632  /// diagnose the error.
6633  ///
6634  /// \param Loc The source location where a diagnostc should be emitted.
6635  ///
6636  /// \param T The type that is being checked for unexpanded parameter
6637  /// packs.
6638  ///
6639  /// \returns true if an error occurred, false otherwise.
6640  bool DiagnoseUnexpandedParameterPack(SourceLocation Loc, TypeSourceInfo *T,
6642 
6643  /// If the given expression contains an unexpanded parameter
6644  /// pack, diagnose the error.
6645  ///
6646  /// \param E The expression that is being checked for unexpanded
6647  /// parameter packs.
6648  ///
6649  /// \returns true if an error occurred, false otherwise.
6650  bool DiagnoseUnexpandedParameterPack(Expr *E,
6651  UnexpandedParameterPackContext UPPC = UPPC_Expression);
6652 
6653  /// If the given nested-name-specifier contains an unexpanded
6654  /// parameter pack, diagnose the error.
6655  ///
6656  /// \param SS The nested-name-specifier that is being checked for
6657  /// unexpanded parameter packs.
6658  ///
6659  /// \returns true if an error occurred, false otherwise.
6660  bool DiagnoseUnexpandedParameterPack(const CXXScopeSpec &SS,
6662 
6663  /// If the given name contains an unexpanded parameter pack,
6664  /// diagnose the error.
6665  ///
6666  /// \param NameInfo The name (with source location information) that
6667  /// is being checked for unexpanded parameter packs.
6668  ///
6669  /// \returns true if an error occurred, false otherwise.
6670  bool DiagnoseUnexpandedParameterPack(const DeclarationNameInfo &NameInfo,
6672 
6673  /// If the given template name contains an unexpanded parameter pack,
6674  /// diagnose the error.
6675  ///
6676  /// \param Loc The location of the template name.
6677  ///
6678  /// \param Template The template name that is being checked for unexpanded
6679  /// parameter packs.
6680  ///
6681  /// \returns true if an error occurred, false otherwise.
6682  bool DiagnoseUnexpandedParameterPack(SourceLocation Loc,
6683  TemplateName Template,
6685 
6686  /// If the given template argument contains an unexpanded parameter
6687  /// pack, diagnose the error.
6688  ///
6689  /// \param Arg The template argument that is being checked for unexpanded
6690  /// parameter packs.
6691  ///
6692  /// \returns true if an error occurred, false otherwise.
6693  bool DiagnoseUnexpandedParameterPack(TemplateArgumentLoc Arg,
6695 
6696  /// Collect the set of unexpanded parameter packs within the given
6697  /// template argument.
6698  ///
6699  /// \param Arg The template argument that will be traversed to find
6700  /// unexpanded parameter packs.
6703 
6704  /// Collect the set of unexpanded parameter packs within the given
6705  /// template argument.
6706  ///
6707  /// \param Arg The template argument that will be traversed to find
6708  /// unexpanded parameter packs.
6711 
6712  /// Collect the set of unexpanded parameter packs within the given
6713  /// type.
6714  ///
6715  /// \param T The type that will be traversed to find
6716  /// unexpanded parameter packs.
6719 
6720  /// Collect the set of unexpanded parameter packs within the given
6721  /// type.
6722  ///
6723  /// \param TL The type that will be traversed to find
6724  /// unexpanded parameter packs.
6727 
6728  /// Collect the set of unexpanded parameter packs within the given
6729  /// nested-name-specifier.
6730  ///
6731  /// \param NNS The nested-name-specifier that will be traversed to find
6732  /// unexpanded parameter packs.
6735 
6736  /// Collect the set of unexpanded parameter packs within the given
6737  /// name.
6738  ///
6739  /// \param NameInfo The name that will be traversed to find
6740  /// unexpanded parameter packs.
6743 
6744  /// Invoked when parsing a template argument followed by an
6745  /// ellipsis, which creates a pack expansion.
6746  ///
6747  /// \param Arg The template argument preceding the ellipsis, which
6748  /// may already be invalid.
6749  ///
6750  /// \param EllipsisLoc The location of the ellipsis.
6751  ParsedTemplateArgument ActOnPackExpansion(const ParsedTemplateArgument &Arg,
6752  SourceLocation EllipsisLoc);
6753 
6754  /// Invoked when parsing a type followed by an ellipsis, which
6755  /// creates a pack expansion.
6756  ///
6757  /// \param Type The type preceding the ellipsis, which will become
6758  /// the pattern of the pack expansion.
6759  ///
6760  /// \param EllipsisLoc The location of the ellipsis.
6761  TypeResult ActOnPackExpansion(ParsedType Type, SourceLocation EllipsisLoc);
6762 
6763  /// Construct a pack expansion type from the pattern of the pack
6764  /// expansion.
6765  TypeSourceInfo *CheckPackExpansion(TypeSourceInfo *Pattern,
6766  SourceLocation EllipsisLoc,
6767  Optional<unsigned> NumExpansions);
6768 
6769  /// Construct a pack expansion type from the pattern of the pack
6770  /// expansion.
6771  QualType CheckPackExpansion(QualType Pattern,
6772  SourceRange PatternRange,
6773  SourceLocation EllipsisLoc,
6774  Optional<unsigned> NumExpansions);
6775 
6776  /// Invoked when parsing an expression followed by an ellipsis, which
6777  /// creates a pack expansion.
6778  ///
6779  /// \param Pattern The expression preceding the ellipsis, which will become
6780  /// the pattern of the pack expansion.
6781  ///
6782  /// \param EllipsisLoc The location of the ellipsis.
6783  ExprResult ActOnPackExpansion(Expr *Pattern, SourceLocation EllipsisLoc);
6784 
6785  /// Invoked when parsing an expression followed by an ellipsis, which
6786  /// creates a pack expansion.
6787  ///
6788  /// \param Pattern The expression preceding the ellipsis, which will become
6789  /// the pattern of the pack expansion.
6790  ///
6791  /// \param EllipsisLoc The location of the ellipsis.
6792  ExprResult CheckPackExpansion(Expr *Pattern, SourceLocation EllipsisLoc,
6793  Optional<unsigned> NumExpansions);
6794 
6795  /// Determine whether we could expand a pack expansion with the
6796  /// given set of parameter packs into separate arguments by repeatedly
6797  /// transforming the pattern.
6798  ///
6799  /// \param EllipsisLoc The location of the ellipsis that identifies the
6800  /// pack expansion.
6801  ///
6802  /// \param PatternRange The source range that covers the entire pattern of
6803  /// the pack expansion.
6804  ///
6805  /// \param Unexpanded The set of unexpanded parameter packs within the
6806  /// pattern.
6807  ///
6808  /// \param ShouldExpand Will be set to \c true if the transformer should
6809  /// expand the corresponding pack expansions into separate arguments. When
6810  /// set, \c NumExpansions must also be set.
6811  ///
6812  /// \param RetainExpansion Whether the caller should add an unexpanded
6813  /// pack expansion after all of the expanded arguments. This is used
6814  /// when extending explicitly-specified template argument packs per
6815  /// C++0x [temp.arg.explicit]p9.
6816  ///
6817  /// \param NumExpansions The number of separate arguments that will be in
6818  /// the expanded form of the corresponding pack expansion. This is both an
6819  /// input and an output parameter, which can be set by the caller if the
6820  /// number of expansions is known a priori (e.g., due to a prior substitution)
6821  /// and will be set by the callee when the number of expansions is known.
6822  /// The callee must set this value when \c ShouldExpand is \c true; it may
6823  /// set this value in other cases.
6824  ///
6825  /// \returns true if an error occurred (e.g., because the parameter packs
6826  /// are to be instantiated with arguments of different lengths), false
6827  /// otherwise. If false, \c ShouldExpand (and possibly \c NumExpansions)
6828  /// must be set.
6829  bool CheckParameterPacksForExpansion(SourceLocation EllipsisLoc,
6830  SourceRange PatternRange,
6832  const MultiLevelTemplateArgumentList &TemplateArgs,
6833  bool &ShouldExpand,
6834  bool &RetainExpansion,
6835  Optional<unsigned> &NumExpansions);
6836 
6837  /// Determine the number of arguments in the given pack expansion
6838  /// type.
6839  ///
6840  /// This routine assumes that the number of arguments in the expansion is
6841  /// consistent across all of the unexpanded parameter packs in its pattern.
6842  ///
6843  /// Returns an empty Optional if the type can't be expanded.
6844  Optional<unsigned> getNumArgumentsInExpansion(QualType T,
6845  const MultiLevelTemplateArgumentList &TemplateArgs);
6846 
6847  /// Determine whether the given declarator contains any unexpanded
6848  /// parameter packs.
6849  ///
6850  /// This routine is used by the parser to disambiguate function declarators
6851  /// with an ellipsis prior to the ')', e.g.,
6852  ///
6853  /// \code
6854  /// void f(T...);
6855  /// \endcode
6856  ///
6857  /// To determine whether we have an (unnamed) function parameter pack or
6858  /// a variadic function.
6859  ///
6860  /// \returns true if the declarator contains any unexpanded parameter packs,
6861  /// false otherwise.
6862  bool containsUnexpandedParameterPacks(Declarator &D);
6863 
6864  /// Returns the pattern of the pack expansion for a template argument.
6865  ///
6866  /// \param OrigLoc The template argument to expand.
6867  ///
6868  /// \param Ellipsis Will be set to the location of the ellipsis.
6869  ///
6870  /// \param NumExpansions Will be set to the number of expansions that will
6871  /// be generated from this pack expansion, if known a priori.
6872  TemplateArgumentLoc getTemplateArgumentPackExpansionPattern(
6873  TemplateArgumentLoc OrigLoc,
6874  SourceLocation &Ellipsis,
6875  Optional<unsigned> &NumExpansions) const;
6876 
6877  /// Given a template argument that contains an unexpanded parameter pack, but
6878  /// which has already been substituted, attempt to determine the number of
6879  /// elements that will be produced once this argument is fully-expanded.
6880  ///
6881  /// This is intended for use when transforming 'sizeof...(Arg)' in order to
6882  /// avoid actually expanding the pack where possible.
6883  Optional<unsigned> getFullyPackExpandedSize(TemplateArgument Arg);
6884 
6885  //===--------------------------------------------------------------------===//
6886  // C++ Template Argument Deduction (C++ [temp.deduct])
6887  //===--------------------------------------------------------------------===//
6888 
6889  /// Adjust the type \p ArgFunctionType to match the calling convention,
6890  /// noreturn, and optionally the exception specification of \p FunctionType.
6891  /// Deduction often wants to ignore these properties when matching function
6892  /// types.
6893  QualType adjustCCAndNoReturn(QualType ArgFunctionType, QualType FunctionType,
6894  bool AdjustExceptionSpec = false);
6895 
6896  /// Describes the result of template argument deduction.
6897  ///
6898  /// The TemplateDeductionResult enumeration describes the result of
6899  /// template argument deduction, as returned from
6900  /// DeduceTemplateArguments(). The separate TemplateDeductionInfo
6901  /// structure provides additional information about the results of
6902  /// template argument deduction, e.g., the deduced template argument
6903  /// list (if successful) or the specific template parameters or
6904  /// deduced arguments that were involved in the failure.
6906  /// Template argument deduction was successful.
6907  TDK_Success = 0,
6908  /// The declaration was invalid; do nothing.
6910  /// Template argument deduction exceeded the maximum template
6911  /// instantiation depth (which has already been diagnosed).
6913  /// Template argument deduction did not deduce a value
6914  /// for every template parameter.
6916  /// Template argument deduction did not deduce a value for every
6917  /// expansion of an expanded template parameter pack.
6919  /// Template argument deduction produced inconsistent
6920  /// deduced values for the given template parameter.
6922  /// Template argument deduction failed due to inconsistent
6923  /// cv-qualifiers on a template parameter type that would
6924  /// otherwise be deduced, e.g., we tried to deduce T in "const T"
6925  /// but were given a non-const "X".
6927  /// Substitution of the deduced template argument values
6928  /// resulted in an error.
6930  /// After substituting deduced template arguments, a dependent
6931  /// parameter type did not match the corresponding argument.
6933  /// After substituting deduced template arguments, an element of
6934  /// a dependent parameter type did not match the corresponding element
6935  /// of the corresponding argument (when deducing from an initializer list).
6937  /// A non-depnedent component of the parameter did not match the
6938  /// corresponding component of the argument.
6940  /// When performing template argument deduction for a function
6941  /// template, there were too many call arguments.
6943  /// When performing template argument deduction for a function
6944  /// template, there were too few call arguments.
6946  /// The explicitly-specified template arguments were not valid
6947  /// template arguments for the given template.
6949  /// Checking non-dependent argument conversions failed.
6951  /// Deduction failed; that's all we know.
6953  /// CUDA Target attributes do not match.
6954  TDK_CUDATargetMismatch
6955  };
6956 
6959  const TemplateArgumentList &TemplateArgs,
6961 
6964  const TemplateArgumentList &TemplateArgs,
6966 
6967  TemplateDeductionResult SubstituteExplicitTemplateArguments(
6968  FunctionTemplateDecl *FunctionTemplate,
6969  TemplateArgumentListInfo &ExplicitTemplateArgs,
6973 
6974  /// brief A function argument from which we performed template argument
6975  // deduction for a call.
6977  OriginalCallArg(QualType OriginalParamType, bool DecomposedParam,
6978  unsigned ArgIdx, QualType OriginalArgType)
6979  : OriginalParamType(OriginalParamType),
6980  DecomposedParam(DecomposedParam), ArgIdx(ArgIdx),
6981  OriginalArgType(OriginalArgType) {}
6982 
6985  unsigned ArgIdx;
6987  };
6988 
6990  FunctionTemplateDecl *FunctionTemplate,
6992  unsigned NumExplicitlySpecified, FunctionDecl *&Specialization,
6994  SmallVectorImpl<OriginalCallArg> const *OriginalCallArgs = nullptr,
6995  bool PartialOverloading = false,
6996  llvm::function_ref<bool()> CheckNonDependent = []{ return false; });
6997 
6999  FunctionTemplateDecl *FunctionTemplate,
7000  TemplateArgumentListInfo *ExplicitTemplateArgs, ArrayRef<Expr *> Args,
7001  FunctionDecl *&Specialization, sema::TemplateDeductionInfo &Info,
7002  bool PartialOverloading,
7003  llvm::function_ref<bool(ArrayRef<QualType>)> CheckNonDependent);
7004 
7007  TemplateArgumentListInfo *ExplicitTemplateArgs,
7008  QualType ArgFunctionType,
7009  FunctionDecl *&Specialization,
7011  bool IsAddressOfFunction = false);
7012 
7015  QualType ToType,
7016  CXXConversionDecl *&Specialization,
7018 
7021  TemplateArgumentListInfo *ExplicitTemplateArgs,
7022  FunctionDecl *&Specialization,
7024  bool IsAddressOfFunction = false);
7025 
7026  /// Substitute Replacement for \p auto in \p TypeWithAuto
7027  QualType SubstAutoType(QualType TypeWithAuto, QualType Replacement);
7028  /// Substitute Replacement for auto in TypeWithAuto
7029  TypeSourceInfo* SubstAutoTypeSourceInfo(TypeSourceInfo *TypeWithAuto,
7030  QualType Replacement);
7031  /// Completely replace the \c auto in \p TypeWithAuto by
7032  /// \p Replacement. This does not retain any \c auto type sugar.
7033  QualType ReplaceAutoType(QualType TypeWithAuto, QualType Replacement);
7034 
7035  /// Result type of DeduceAutoType.
7039  DAR_FailedAlreadyDiagnosed
7040  };
7041 
7043  DeduceAutoType(TypeSourceInfo *AutoType, Expr *&Initializer, QualType &Result,
7044  Optional<unsigned> DependentDeductionDepth = None);
7046  DeduceAutoType(TypeLoc AutoTypeLoc, Expr *&Initializer, QualType &Result,
7047  Optional<unsigned> DependentDeductionDepth = None);
7048  void DiagnoseAutoDeductionFailure(VarDecl *VDecl, Expr *Init);
7049  bool DeduceReturnType(FunctionDecl *FD, SourceLocation Loc,
7050  bool Diagnose = true);
7051 
7052  /// Declare implicit deduction guides for a class template if we've
7053  /// not already done so.
7054  void DeclareImplicitDeductionGuides(TemplateDecl *Template,
7055  SourceLocation Loc);
7056 
7057  QualType DeduceTemplateSpecializationFromInitializer(
7058  TypeSourceInfo *TInfo, const InitializedEntity &Entity,
7059  const InitializationKind &Kind, MultiExprArg Init);
7060 
7061  QualType deduceVarTypeFromInitializer(VarDecl *VDecl, DeclarationName Name,
7062  QualType Type, TypeSourceInfo *TSI,
7063  SourceRange Range, bool DirectInit,
7064  Expr *Init);
7065 
7066  TypeLoc getReturnTypeLoc(FunctionDecl *FD) const;
7067 
7068  bool DeduceFunctionTypeFromReturnExpr(FunctionDecl *FD,
7069  SourceLocation ReturnLoc,
7070  Expr *&RetExpr, AutoType *AT);
7071 
7072  FunctionTemplateDecl *getMoreSpecializedTemplate(FunctionTemplateDecl *FT1,
7073  FunctionTemplateDecl *FT2,
7074  SourceLocation Loc,
7076  unsigned NumCallArguments1,
7077  unsigned NumCallArguments2);
7079  getMostSpecialized(UnresolvedSetIterator SBegin, UnresolvedSetIterator SEnd,
7080  TemplateSpecCandidateSet &FailedCandidates,
7081  SourceLocation Loc,
7082  const PartialDiagnostic &NoneDiag,
7083  const PartialDiagnostic &AmbigDiag,
7084  const PartialDiagnostic &CandidateDiag,
7085  bool Complain = true, QualType TargetType = QualType());
7086 
7088  getMoreSpecializedPartialSpecialization(
7091  SourceLocation Loc);
7092 
7093  bool isMoreSpecializedThanPrimary(ClassTemplatePartialSpecializationDecl *T,
7095 
7096  VarTemplatePartialSpecializationDecl *getMoreSpecializedPartialSpecialization(
7099 
7100  bool isMoreSpecializedThanPrimary(VarTemplatePartialSpecializationDecl *T,
7102 
7103  bool isTemplateTemplateParameterAtLeastAsSpecializedAs(
7105 
7106  void MarkUsedTemplateParameters(const TemplateArgumentList &TemplateArgs,
7107  bool OnlyDeduced,
7108  unsigned Depth,
7109  llvm::SmallBitVector &Used);
7111  const FunctionTemplateDecl *FunctionTemplate,
7112  llvm::SmallBitVector &Deduced) {
7113  return MarkDeducedTemplateParameters(Context, FunctionTemplate, Deduced);
7114  }
7115  static void MarkDeducedTemplateParameters(ASTContext &Ctx,
7116  const FunctionTemplateDecl *FunctionTemplate,
7117  llvm::SmallBitVector &Deduced);
7118 
7119  //===--------------------------------------------------------------------===//
7120  // C++ Template Instantiation
7121  //
7122 
7124  getTemplateInstantiationArgs(NamedDecl *D,
7125  const TemplateArgumentList *Innermost = nullptr,
7126  bool RelativeToPrimary = false,
7127  const FunctionDecl *Pattern = nullptr);
7128 
7129  /// A context in which code is being synthesized (where a source location
7130  /// alone is not sufficient to identify the context). This covers template
7131  /// instantiation and various forms of implicitly-generated functions.
7133  /// The kind of template instantiation we are performing
7135  /// We are instantiating a template declaration. The entity is
7136  /// the declaration we're instantiating (e.g., a CXXRecordDecl).
7138 
7139  /// We are instantiating a default argument for a template
7140  /// parameter. The Entity is the template parameter whose argument is
7141  /// being instantiated, the Template is the template, and the
7142  /// TemplateArgs/NumTemplateArguments provide the template arguments as
7143  /// specified.
7145 
7146  /// We are instantiating a default argument for a function.
7147  /// The Entity is the ParmVarDecl, and TemplateArgs/NumTemplateArgs
7148  /// provides the template arguments as specified.
7150 
7151  /// We are substituting explicit template arguments provided for
7152  /// a function template. The entity is a FunctionTemplateDecl.
7154 
7155  /// We are substituting template argument determined as part of
7156  /// template argument deduction for either a class template
7157  /// partial specialization or a function template. The
7158  /// Entity is either a {Class|Var}TemplatePartialSpecializationDecl or
7159  /// a TemplateDecl.
7161 
7162  /// We are substituting prior template arguments into a new
7163  /// template parameter. The template parameter itself is either a
7164  /// NonTypeTemplateParmDecl or a TemplateTemplateParmDecl.
7166 
7167  /// We are checking the validity of a default template argument that
7168  /// has been used when naming a template-id.
7170 
7171  /// We are instantiating the exception specification for a function
7172  /// template which was deferred until it was needed.
7174 
7175  /// We are declaring an implicit special member function.
7177 
7178  /// We are defining a synthesized function (such as a defaulted special
7179  /// member).
7181 
7182  /// Added for Template instantiation observation.
7183  /// Memoization means we are _not_ instantiating a template because
7184  /// it is already instantiated (but we entered a context where we
7185  /// would have had to if it was not already instantiated).
7186  Memoization
7187  } Kind;
7188 
7189  /// Was the enclosing context a non-instantiation SFINAE context?
7191 
7192  /// The point of instantiation or synthesis within the source code.
7194 
7195  /// The entity that is being synthesized.
7196  Decl *Entity;
7197 
7198  /// The template (or partial specialization) in which we are
7199  /// performing the instantiation, for substitutions of prior template
7200  /// arguments.
7202 
7203  /// The list of template arguments we are substituting, if they
7204  /// are not part of the entity.
7206 
7207  // FIXME: Wrap this union around more members, or perhaps store the
7208  // kind-specific members in the RAII object owning the context.
7209  union {
7210  /// The number of template arguments in TemplateArgs.
7212 
7213  /// The special member being declared or defined.
7215  };
7216 
7218  assert(Kind != DeclaringSpecialMember);
7219  return {TemplateArgs, NumTemplateArgs};
7220  }
7221 
7222  /// The template deduction info object associated with the
7223  /// substitution or checking of explicit or deduced template arguments.
7225 
7226  /// The source range that covers the construct that cause
7227  /// the instantiation, e.g., the template-id that causes a class
7228  /// template instantiation.
7230 
7232  : Kind(TemplateInstantiation), Entity(nullptr), Template(nullptr),
7233  TemplateArgs(nullptr), NumTemplateArgs(0), DeductionInfo(nullptr) {}
7234 
7235  /// Determines whether this template is an actual instantiation
7236  /// that should be counted toward the maximum instantiation depth.
7237  bool isInstantiationRecord() const;
7238  };
7239 
7240  /// List of active code synthesis contexts.
7241  ///
7242  /// This vector is treated as a stack. As synthesis of one entity requires
7243  /// synthesis of another, additional contexts are pushed onto the stack.
7245 
7246  /// Specializations whose definitions are currently being instantiated.
7248 
7249  /// Non-dependent types used in templates that have already been instantiated
7250  /// by some template instantiation.
7252 
7253  /// Extra modules inspected when performing a lookup during a template
7254  /// instantiation. Computed lazily.
7256 
7257  /// Cache of additional modules that should be used for name lookup
7258  /// within the current template instantiation. Computed lazily; use
7259  /// getLookupModules() to get a complete set.
7261 
7262  /// Get the set of additional modules that should be checked during
7263  /// name lookup. A module and its imports become visible when instanting a
7264  /// template defined within it.
7265  llvm::DenseSet<Module*> &getLookupModules();
7266 
7267  /// Map from the most recent declaration of a namespace to the most
7268  /// recent visible declaration of that namespace.
7269  llvm::DenseMap<NamedDecl*, NamedDecl*> VisibleNamespaceCache;
7270 
7271  /// Whether we are in a SFINAE context that is not associated with
7272  /// template instantiation.
7273  ///
7274  /// This is used when setting up a SFINAE trap (\c see SFINAETrap) outside
7275  /// of a template instantiation or template argument deduction.
7277 
7278  /// The number of \p CodeSynthesisContexts that are not template
7279  /// instantiations and, therefore, should not be counted as part of the
7280  /// instantiation depth.
7281  ///
7282  /// When the instantiation depth reaches the user-configurable limit
7283  /// \p LangOptions::InstantiationDepth we will abort instantiation.
7284  // FIXME: Should we have a similar limit for other forms of synthesis?
7286 
7287  /// The depth of the context stack at the point when the most recent
7288  /// error or warning was produced.
7289  ///
7290  /// This value is used to suppress printing of redundant context stacks
7291  /// when there are multiple errors or warnings in the same instantiation.
7292  // FIXME: Does this belong in Sema? It's tough to implement it anywhere else.
7293  unsigned LastEmittedCodeSynthesisContextDepth = 0;
7294 
7295  /// The template instantiation callbacks to trace or track
7296  /// instantiations (objects can be chained).
7297  ///
7298  /// This callbacks is used to print, trace or track template
7299  /// instantiations as they are being constructed.
7300  std::vector<std::unique_ptr<TemplateInstantiationCallback>>
7302 
7303  /// The current index into pack expansion arguments that will be
7304  /// used for substitution of parameter packs.
7305  ///
7306  /// The pack expansion index will be -1 to indicate that parameter packs
7307  /// should be instantiated as themselves. Otherwise, the index specifies
7308  /// which argument within the parameter pack will be used for substitution.
7310 
7311  /// RAII object used to change the argument pack substitution index
7312  /// within a \c Sema object.
7313  ///
7314  /// See \c ArgumentPackSubstitutionIndex for more information.
7316  Sema &Self;
7317  int OldSubstitutionIndex;
7318 
7319  public:
7320  ArgumentPackSubstitutionIndexRAII(Sema &Self, int NewSubstitutionIndex)
7321  : Self(Self), OldSubstitutionIndex(Self.ArgumentPackSubstitutionIndex) {
7322  Self.ArgumentPackSubstitutionIndex = NewSubstitutionIndex;
7323  }
7324 
7326  Self.ArgumentPackSubstitutionIndex = OldSubstitutionIndex;
7327  }
7328  };
7329 
7330  friend class ArgumentPackSubstitutionRAII;
7331 
7332  /// For each declaration that involved template argument deduction, the
7333  /// set of diagnostics that were suppressed during that template argument
7334  /// deduction.
7335  ///
7336  /// FIXME: Serialize this structure to the AST file.
7337  typedef llvm::DenseMap<Decl *, SmallVector<PartialDiagnosticAt, 1> >
7340 
7341  /// A stack object to be created when performing template
7342  /// instantiation.
7343  ///
7344  /// Construction of an object of type \c InstantiatingTemplate
7345  /// pushes the current instantiation onto the stack of active
7346  /// instantiations. If the size of this stack exceeds the maximum
7347  /// number of recursive template instantiations, construction
7348  /// produces an error and evaluates true.
7349  ///
7350  /// Destruction of this object will pop the named instantiation off
7351  /// the stack.
7353  /// Note that we are instantiating a class template,
7354  /// function template, variable template, alias template,
7355  /// or a member thereof.
7356  InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
7357  Decl *Entity,
7358  SourceRange InstantiationRange = SourceRange());
7359 
7361  /// Note that we are instantiating an exception specification
7362  /// of a function template.
7363  InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
7364  FunctionDecl *Entity, ExceptionSpecification,
7365  SourceRange InstantiationRange = SourceRange());
7366 
7367  /// Note that we are instantiating a default argument in a
7368  /// template-id.
7369  InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
7370  TemplateParameter Param, TemplateDecl *Template,
7371  ArrayRef<TemplateArgument> TemplateArgs,
7372  SourceRange InstantiationRange = SourceRange());
7373 
7374  /// Note that we are substituting either explicitly-specified or
7375  /// deduced template arguments during function template argument deduction.
7376  InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
7377  FunctionTemplateDecl *FunctionTemplate,
7378  ArrayRef<TemplateArgument> TemplateArgs,
7380  sema::TemplateDeductionInfo &DeductionInfo,
7381  SourceRange InstantiationRange = SourceRange());
7382 
7383  /// Note that we are instantiating as part of template
7384  /// argument deduction for a class template declaration.
7385  InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
7386  TemplateDecl *Template,
7387  ArrayRef<TemplateArgument> TemplateArgs,
7388  sema::TemplateDeductionInfo &DeductionInfo,
7389  SourceRange InstantiationRange = SourceRange());
7390 
7391  /// Note that we are instantiating as part of template
7392  /// argument deduction for a class template partial
7393  /// specialization.
7394  InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
7396  ArrayRef<TemplateArgument> TemplateArgs,
7397  sema::TemplateDeductionInfo &DeductionInfo,
7398  SourceRange InstantiationRange = SourceRange());
7399 
7400  /// Note that we are instantiating as part of template
7401  /// argument deduction for a variable template partial
7402  /// specialization.
7403  InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
7405  ArrayRef<TemplateArgument> TemplateArgs,
7406  sema::TemplateDeductionInfo &DeductionInfo,
7407  SourceRange InstantiationRange = SourceRange());
7408 
7409  /// Note that we are instantiating a default argument for a function
7410  /// parameter.
7411  InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
7412  ParmVarDecl *Param,
7413  ArrayRef<TemplateArgument> TemplateArgs,
7414  SourceRange InstantiationRange = SourceRange());
7415 
7416  /// Note that we are substituting prior template arguments into a
7417  /// non-type parameter.
7418  InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
7419  NamedDecl *Template,
7420  NonTypeTemplateParmDecl *Param,
7421  ArrayRef<TemplateArgument> TemplateArgs,
7422  SourceRange InstantiationRange);
7423 
7424  /// Note that we are substituting prior template arguments into a
7425  /// template template parameter.
7426  InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
7427  NamedDecl *Template,
7428  TemplateTemplateParmDecl *Param,
7429  ArrayRef<TemplateArgument> TemplateArgs,
7430  SourceRange InstantiationRange);
7431 
7432  /// Note that we are checking the default template argument
7433  /// against the template parameter for a given template-id.
7434  InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
7435  TemplateDecl *Template,
7436  NamedDecl *Param,
7437  ArrayRef<TemplateArgument> TemplateArgs,
7438  SourceRange InstantiationRange);
7439 
7440 
7441  /// Note that we have finished instantiating this template.
7442  void Clear();
7443 
7444  ~InstantiatingTemplate() { Clear(); }
7445 
7446  /// Determines whether we have exceeded the maximum
7447  /// recursive template instantiations.
7448  bool isInvalid() const { return Invalid; }
7449 
7450  /// Determine whether we are already instantiating this
7451  /// specialization in some surrounding active instantiation.
7452  bool isAlreadyInstantiating() const { return AlreadyInstantiating; }
7453 
7454  private:
7455  Sema &SemaRef;
7456  bool Invalid;
7457  bool AlreadyInstantiating;
7458  bool CheckInstantiationDepth(SourceLocation PointOfInstantiation,
7459  SourceRange InstantiationRange);
7460 
7463  SourceLocation PointOfInstantiation, SourceRange InstantiationRange,
7464  Decl *Entity, NamedDecl *Template = nullptr,
7465  ArrayRef<TemplateArgument> TemplateArgs = None,
7466  sema::TemplateDeductionInfo *DeductionInfo = nullptr);
7467 
7469 
7471  operator=(const InstantiatingTemplate&) = delete;
7472  };
7473 
7474  void pushCodeSynthesisContext(CodeSynthesisContext Ctx);
7475  void popCodeSynthesisContext();
7476 
7477  /// Determine whether we are currently performing template instantiation.
7479  return CodeSynthesisContexts.size() > NonInstantiationEntries;
7480  }
7481 
7483  if (!CodeSynthesisContexts.empty() &&
7484  CodeSynthesisContexts.size() != LastEmittedCodeSynthesisContextDepth) {
7485  PrintInstantiationStack();
7486  LastEmittedCodeSynthesisContextDepth = CodeSynthesisContexts.size();
7487  }
7488  if (PragmaAttributeCurrentTargetDecl)
7489  PrintPragmaAttributeInstantiationPoint();
7490  }
7491  void PrintInstantiationStack();
7492 
7493  void PrintPragmaAttributeInstantiationPoint();
7494 
7495  /// Determines whether we are currently in a context where
7496  /// template argument substitution failures are not considered
7497  /// errors.
7498  ///
7499  /// \returns An empty \c Optional if we're not in a SFINAE context.
7500  /// Otherwise, contains a pointer that, if non-NULL, contains the nearest
7501  /// template-deduction context object, which can be used to capture
7502  /// diagnostics that will be suppressed.
7503  Optional<sema::TemplateDeductionInfo *> isSFINAEContext() const;
7504 
7505  /// Determines whether we are currently in a context that
7506  /// is not evaluated as per C++ [expr] p5.
7507  bool isUnevaluatedContext() const {
7508  assert(!ExprEvalContexts.empty() &&
7509  "Must be in an expression evaluation context");
7510  return ExprEvalContexts.back().isUnevaluated();
7511  }
7512 
7513  /// RAII class used to determine whether SFINAE has
7514  /// trapped any errors that occur during template argument
7515  /// deduction.
7516  class SFINAETrap {
7517  Sema &SemaRef;
7518  unsigned PrevSFINAEErrors;
7519  bool PrevInNonInstantiationSFINAEContext;
7520  bool PrevAccessCheckingSFINAE;
7521  bool PrevLastDiagnosticIgnored;
7522 
7523  public:
7524  explicit SFINAETrap(Sema &SemaRef, bool AccessCheckingSFINAE = false)
7525  : SemaRef(SemaRef), PrevSFINAEErrors(SemaRef.NumSFINAEErrors),
7526  PrevInNonInstantiationSFINAEContext(
7527  SemaRef.InNonInstantiationSFINAEContext),
7528  PrevAccessCheckingSFINAE(SemaRef.AccessCheckingSFINAE),
7529  PrevLastDiagnosticIgnored(
7530  SemaRef.getDiagnostics().isLastDiagnosticIgnored())
7531  {
7532  if (!SemaRef.isSFINAEContext())
7533  SemaRef.InNonInstantiationSFINAEContext = true;
7534  SemaRef.AccessCheckingSFINAE = AccessCheckingSFINAE;
7535  }
7536 
7538  SemaRef.NumSFINAEErrors = PrevSFINAEErrors;
7540  = PrevInNonInstantiationSFINAEContext;
7541  SemaRef.AccessCheckingSFINAE = PrevAccessCheckingSFINAE;
7543  PrevLastDiagnosticIgnored);
7544  }
7545 
7546  /// Determine whether any SFINAE errors have been trapped.
7547  bool hasErrorOccurred() const {
7548  return SemaRef.NumSFINAEErrors > PrevSFINAEErrors;
7549  }
7550  };
7551 
7552  /// RAII class used to indicate that we are performing provisional
7553  /// semantic analysis to determine the validity of a construct, so
7554  /// typo-correction and diagnostics in the immediate context (not within
7555  /// implicitly-instantiated templates) should be suppressed.
7557  Sema &SemaRef;
7558  // FIXME: Using a SFINAETrap for this is a hack.
7559  SFINAETrap Trap;
7560  bool PrevDisableTypoCorrection;
7561  public:
7562  explicit TentativeAnalysisScope(Sema &SemaRef)
7563  : SemaRef(SemaRef), Trap(SemaRef, true),
7564  PrevDisableTypoCorrection(SemaRef.DisableTypoCorrection) {
7565  SemaRef.DisableTypoCorrection = true;
7566  }
7568  SemaRef.DisableTypoCorrection = PrevDisableTypoCorrection;
7569  }
7570  };
7571 
7572  /// The current instantiation scope used to store local
7573  /// variables.
7575 
7576  /// Tracks whether we are in a context where typo correction is
7577  /// disabled.
7579 
7580  /// The number of typos corrected by CorrectTypo.
7581  unsigned TyposCorrected;
7582 
7583  typedef llvm::SmallSet<SourceLocation, 2> SrcLocSet;
7584  typedef llvm::DenseMap<IdentifierInfo *, SrcLocSet> IdentifierSourceLocations;
7585 
7586  /// A cache containing identifiers for which typo correction failed and
7587  /// their locations, so that repeated attempts to correct an identifier in a
7588  /// given location are ignored if typo correction already failed for it.
7589  IdentifierSourceLocations TypoCorrectionFailures;
7590 
7591  /// Worker object for performing CFG-based warnings.
7594 
7595  /// An entity for which implicit template instantiation is required.
7596  ///
7597  /// The source location associated with the declaration is the first place in
7598  /// the source code where the declaration was "used". It is not necessarily
7599  /// the point of instantiation (which will be either before or after the
7600  /// namespace-scope declaration that triggered this implicit instantiation),
7601  /// However, it is the location that diagnostics should generally refer to,
7602  /// because users will need to know what code triggered the instantiation.
7603  typedef std::pair<ValueDecl *, SourceLocation> PendingImplicitInstantiation;
7604 
7605  /// The queue of implicit template instantiations that are required
7606  /// but have not yet been performed.
7607  std::deque<PendingImplicitInstantiation> PendingInstantiations;
7608 
7609  /// Queue of implicit template instantiations that cannot be performed
7610  /// eagerly.
7612 
7614  public:
7616  : S(S), Enabled(Enabled) {
7617  if (!Enabled) return;
7618 
7619  SavedPendingInstantiations.swap(S.PendingInstantiations);
7620  SavedVTableUses.swap(S.VTableUses);
7621  }
7622 
7623  void perform() {
7624  if (Enabled) {
7625  S.DefineUsedVTables();
7626  S.PerformPendingInstantiations();
7627  }
7628  }
7629 
7631  if (!Enabled) return;
7632 
7633  // Restore the set of pending vtables.
7634  assert(S.VTableUses.empty() &&
7635  "VTableUses should be empty before it is discarded.");
7636  S.VTableUses.swap(SavedVTableUses);
7637 
7638  // Restore the set of pending implicit instantiations.
7639  assert(S.PendingInstantiations.empty() &&
7640  "PendingInstantiations should be empty before it is discarded.");
7641  S.PendingInstantiations.swap(SavedPendingInstantiations);
7642  }
7643 
7644  private:
7645  Sema &S;
7646  SmallVector<VTableUse, 16> SavedVTableUses;
7647  std::deque<PendingImplicitInstantiation> SavedPendingInstantiations;
7648  bool Enabled;
7649  };
7650 
7651  /// The queue of implicit template instantiations that are required
7652  /// and must be performed within the current local scope.
7653  ///
7654  /// This queue is only used for member functions of local classes in
7655  /// templates, which must be instantiated in the same scope as their
7656  /// enclosing function, so that they can reference function-local
7657  /// types, static variables, enumerators, etc.
7658  std::deque<PendingImplicitInstantiation> PendingLocalImplicitInstantiations;
7659 
7661  public:
7663  SavedPendingLocalImplicitInstantiations.swap(
7665  }
7666 
7667  void perform() { S.PerformPendingInstantiations(/*LocalOnly=*/true); }
7668 
7670  assert(S.PendingLocalImplicitInstantiations.empty() &&
7671  "there shouldn't be any pending local implicit instantiations");
7672  SavedPendingLocalImplicitInstantiations.swap(
7673  S.PendingLocalImplicitInstantiations);
7674  }
7675 
7676  private:
7677  Sema &S;
7678  std::deque<PendingImplicitInstantiation>
7679  SavedPendingLocalImplicitInstantiations;
7680  };
7681 
7682  /// A helper class for building up ExtParameterInfos.
7685  bool HasInteresting = false;
7686 
7687  public:
7688  /// Set the ExtParameterInfo for the parameter at the given index,
7689  ///
7690  void set(unsigned index, FunctionProtoType::ExtParameterInfo info) {
7691  assert(Infos.size() <= index);
7692  Infos.resize(index);
7693  Infos.push_back(info);
7694 
7695  if (!HasInteresting)
7696  HasInteresting = (info != FunctionProtoType::ExtParameterInfo());
7697  }
7698 
7699  /// Return a pointer (suitable for setting in an ExtProtoInfo) to the
7700  /// ExtParameterInfo array we've built up.
7702  getPointerOrNull(unsigned numParams) {
7703  if (!HasInteresting) return nullptr;
7704  Infos.resize(numParams);
7705  return Infos.data();
7706  }
7707  };
7708 
7709  void PerformPendingInstantiations(bool LocalOnly = false);
7710 
7711  TypeSourceInfo *SubstType(TypeSourceInfo *T,
7712  const MultiLevelTemplateArgumentList &TemplateArgs,
7713  SourceLocation Loc, DeclarationName Entity,
7714  bool AllowDeducedTST = false);
7715 
7716  QualType SubstType(QualType T,
7717  const MultiLevelTemplateArgumentList &TemplateArgs,
7718  SourceLocation Loc, DeclarationName Entity);
7719 
7720  TypeSourceInfo *SubstType(TypeLoc TL,
7721  const MultiLevelTemplateArgumentList &TemplateArgs,
7722  SourceLocation Loc, DeclarationName Entity);
7723 
7724  TypeSourceInfo *SubstFunctionDeclType(TypeSourceInfo *T,
7725  const MultiLevelTemplateArgumentList &TemplateArgs,
7726  SourceLocation Loc,
7727  DeclarationName Entity,
7728  CXXRecordDecl *ThisContext,
7729  unsigned ThisTypeQuals);
7730  void SubstExceptionSpec(FunctionDecl *New, const FunctionProtoType *Proto,
7731  const MultiLevelTemplateArgumentList &Args);
7732  bool SubstExceptionSpec(SourceLocation Loc,
7734  SmallVectorImpl<QualType> &ExceptionStorage,
7735  const MultiLevelTemplateArgumentList &Args);
7736  ParmVarDecl *SubstParmVarDecl(ParmVarDecl *D,
7737  const MultiLevelTemplateArgumentList &TemplateArgs,
7738  int indexAdjustment,
7739  Optional<unsigned> NumExpansions,
7740  bool ExpectParameterPack);
7741  bool SubstParmTypes(SourceLocation Loc, ArrayRef<ParmVarDecl *> Params,
7742  const FunctionProtoType::ExtParameterInfo *ExtParamInfos,
7743  const MultiLevelTemplateArgumentList &TemplateArgs,
7744  SmallVectorImpl<QualType> &ParamTypes,
7745  SmallVectorImpl<ParmVarDecl *> *OutParams,
7746  ExtParameterInfoBuilder &ParamInfos);
7747  ExprResult SubstExpr(Expr *E,
7748  const MultiLevelTemplateArgumentList &TemplateArgs);
7749 
7750  /// Substitute the given template arguments into a list of
7751  /// expressions, expanding pack expansions if required.
7752  ///
7753  /// \param Exprs The list of expressions to substitute into.
7754  ///
7755  /// \param IsCall Whether this is some form of call, in which case
7756  /// default arguments will be dropped.
7757  ///
7758  /// \param TemplateArgs The set of template arguments to substitute.
7759  ///
7760  /// \param Outputs Will receive all of the substituted arguments.
7761  ///
7762  /// \returns true if an error occurred, false otherwise.
7763  bool SubstExprs(ArrayRef<Expr *> Exprs, bool IsCall,
7764  const MultiLevelTemplateArgumentList &TemplateArgs,
7765  SmallVectorImpl<Expr *> &Outputs);
7766 
7767  StmtResult SubstStmt(Stmt *S,
7768  const MultiLevelTemplateArgumentList &TemplateArgs);
7769 
7771  SubstTemplateParams(TemplateParameterList *Params, DeclContext *Owner,
7772  const MultiLevelTemplateArgumentList &TemplateArgs);
7773 
7774  Decl *SubstDecl(Decl *D, DeclContext *Owner,
7775  const MultiLevelTemplateArgumentList &TemplateArgs);
7776 
7777  ExprResult SubstInitializer(Expr *E,
7778  const MultiLevelTemplateArgumentList &TemplateArgs,
7779  bool CXXDirectInit);
7780 
7781  bool
7782  SubstBaseSpecifiers(CXXRecordDecl *Instantiation,
7783  CXXRecordDecl *Pattern,
7784  const MultiLevelTemplateArgumentList &TemplateArgs);
7785 
7786  bool
7787  InstantiateClass(SourceLocation PointOfInstantiation,
7788  CXXRecordDecl *Instantiation, CXXRecordDecl *Pattern,
7789  const MultiLevelTemplateArgumentList &TemplateArgs,
7791  bool Complain = true);
7792 
7793  bool InstantiateEnum(SourceLocation PointOfInstantiation,
7794  EnumDecl *Instantiation, EnumDecl *Pattern,
7795  const MultiLevelTemplateArgumentList &TemplateArgs,
7797 
7798  bool InstantiateInClassInitializer(
7799  SourceLocation PointOfInstantiation, FieldDecl *Instantiation,
7800  FieldDecl *Pattern, const MultiLevelTemplateArgumentList &TemplateArgs);
7801 
7803  const Attr *TmplAttr;
7805  Decl *NewDecl;
7806 
7808  Decl *D)
7809  : TmplAttr(A), Scope(S), NewDecl(D)
7810  { }
7811  };
7813 
7814  void InstantiateAttrs(const MultiLevelTemplateArgumentList &TemplateArgs,
7815  const Decl *Pattern, Decl *Inst,
7816  LateInstantiatedAttrVec *LateAttrs = nullptr,
7817  LocalInstantiationScope *OuterMostScope = nullptr);
7818 
7819  void
7820  InstantiateAttrsForDecl(const MultiLevelTemplateArgumentList &TemplateArgs,
7821  const Decl *Pattern, Decl *Inst,
7822  LateInstantiatedAttrVec *LateAttrs = nullptr,
7823  LocalInstantiationScope *OuterMostScope = nullptr);
7824 
7825  bool usesPartialOrExplicitSpecialization(
7826  SourceLocation Loc, ClassTemplateSpecializationDecl *ClassTemplateSpec);
7827 
7828  bool
7829  InstantiateClassTemplateSpecialization(SourceLocation PointOfInstantiation,
7830  ClassTemplateSpecializationDecl *ClassTemplateSpec,
7832  bool Complain = true);
7833 
7834  void InstantiateClassMembers(SourceLocation PointOfInstantiation,
7835  CXXRecordDecl *Instantiation,
7836  const MultiLevelTemplateArgumentList &TemplateArgs,
7838 
7839  void InstantiateClassTemplateSpecializationMembers(
7840  SourceLocation PointOfInstantiation,
7841  ClassTemplateSpecializationDecl *ClassTemplateSpec,
7843 
7845  SubstNestedNameSpecifierLoc(NestedNameSpecifierLoc NNS,
7846  const MultiLevelTemplateArgumentList &TemplateArgs);
7847 
7849  SubstDeclarationNameInfo(const DeclarationNameInfo &NameInfo,
7850  const MultiLevelTemplateArgumentList &TemplateArgs);
7851  TemplateName
7852  SubstTemplateName(NestedNameSpecifierLoc QualifierLoc, TemplateName Name,
7853  SourceLocation Loc,
7854  const MultiLevelTemplateArgumentList &TemplateArgs);
7855  bool Subst(const TemplateArgumentLoc *Args, unsigned NumArgs,
7856  TemplateArgumentListInfo &Result,
7857  const MultiLevelTemplateArgumentList &TemplateArgs);
7858 
7859  void InstantiateExceptionSpec(SourceLocation PointOfInstantiation,
7860  FunctionDecl *Function);
7861  FunctionDecl *InstantiateFunctionDeclaration(FunctionTemplateDecl *FTD,
7862  const TemplateArgumentList *Args,
7863  SourceLocation Loc);
7864  void InstantiateFunctionDefinition(SourceLocation PointOfInstantiation,
7865  FunctionDecl *Function,
7866  bool Recursive = false,
7867  bool DefinitionRequired = false,
7868  bool AtEndOfTU = false);
7869  VarTemplateSpecializationDecl *BuildVarTemplateInstantiation(
7870  VarTemplateDecl *VarTemplate, VarDecl *FromVar,
7871  const TemplateArgumentList &TemplateArgList,
7872  const TemplateArgumentListInfo &TemplateArgsInfo,
7874  SourceLocation PointOfInstantiation, void *InsertPos,
7875  LateInstantiatedAttrVec *LateAttrs = nullptr,
7876  LocalInstantiationScope *StartingScope = nullptr);
7877  VarTemplateSpecializationDecl *CompleteVarTemplateSpecializationDecl(
7878  VarTemplateSpecializationDecl *VarSpec, VarDecl *PatternDecl,
7879  const MultiLevelTemplateArgumentList &TemplateArgs);
7880  void
7881  BuildVariableInstantiation(VarDecl *NewVar, VarDecl *OldVar,
7882  const MultiLevelTemplateArgumentList &TemplateArgs,
7883  LateInstantiatedAttrVec *LateAttrs,
7884  DeclContext *Owner,
7885  LocalInstantiationScope *StartingScope,
7886  bool InstantiatingVarTemplate = false);
7887  void InstantiateVariableInitializer(
7888  VarDecl *Var, VarDecl *OldVar,
7889  const MultiLevelTemplateArgumentList &TemplateArgs);
7890  void InstantiateVariableDefinition(SourceLocation PointOfInstantiation,
7891  VarDecl *Var, bool Recursive = false,
7892  bool DefinitionRequired = false,
7893  bool AtEndOfTU = false);
7894 
7895  void InstantiateMemInitializers(CXXConstructorDecl *New,
7896  const CXXConstructorDecl *Tmpl,
7897  const MultiLevelTemplateArgumentList &TemplateArgs);
7898 
7899  NamedDecl *FindInstantiatedDecl(SourceLocation Loc, NamedDecl *D,
7900  const MultiLevelTemplateArgumentList &TemplateArgs,
7901  bool FindingInstantiatedContext = false);
7902  DeclContext *FindInstantiatedContext(SourceLocation Loc, DeclContext *DC,
7903  const MultiLevelTemplateArgumentList &TemplateArgs);
7904 
7905  // Objective-C declarations.
7907  OCK_None = -1,
7908  OCK_Interface = 0,
7913  OCK_CategoryImplementation
7914  };
7915  ObjCContainerKind getObjCContainerKind() const;
7916 
7917  DeclResult actOnObjCTypeParam(Scope *S,
7918  ObjCTypeParamVariance variance,
7919  SourceLocation varianceLoc,
7920  unsigned index,
7921  IdentifierInfo *paramName,
7922  SourceLocation paramLoc,
7923  SourceLocation colonLoc,
7924  ParsedType typeBound);
7925 
7926  ObjCTypeParamList *actOnObjCTypeParamList(Scope *S, SourceLocation lAngleLoc,
7927  ArrayRef<Decl *> typeParams,
7928  SourceLocation rAngleLoc);
7929  void popObjCTypeParamList(Scope *S, ObjCTypeParamList *typeParamList);
7930 
7931  Decl *ActOnStartClassInterface(
7932  Scope *S, SourceLocation AtInterfaceLoc, IdentifierInfo *ClassName,
7933  SourceLocation ClassLoc, ObjCTypeParamList *typeParamList,
7934  IdentifierInfo *SuperName, SourceLocation SuperLoc,
7935  ArrayRef<ParsedType> SuperTypeArgs, SourceRange SuperTypeArgsRange,
7936  Decl *const *ProtoRefs, unsigned NumProtoRefs,
7937  const SourceLocation *ProtoLocs, SourceLocation EndProtoLoc,
7938  const ParsedAttributesView &AttrList);
7939 
7940  void ActOnSuperClassOfClassInterface(Scope *S,
7941  SourceLocation AtInterfaceLoc,
7942  ObjCInterfaceDecl *IDecl,
7943  IdentifierInfo *ClassName,
7944  SourceLocation ClassLoc,
7945  IdentifierInfo *SuperName,
7946  SourceLocation SuperLoc,
7947  ArrayRef<ParsedType> SuperTypeArgs,
7948  SourceRange SuperTypeArgsRange);
7949 
7950  void ActOnTypedefedProtocols(SmallVectorImpl<Decl *> &ProtocolRefs,
7951  SmallVectorImpl<SourceLocation> &ProtocolLocs,
7952  IdentifierInfo *SuperName,
7953  SourceLocation SuperLoc);
7954 
7955  Decl *ActOnCompatibilityAlias(
7956  SourceLocation AtCompatibilityAliasLoc,
7957  IdentifierInfo *AliasName, SourceLocation AliasLocation,
7958  IdentifierInfo *ClassName, SourceLocation ClassLocation);
7959 
7960  bool CheckForwardProtocolDeclarationForCircularDependency(
7961  IdentifierInfo *PName,
7962  SourceLocation &PLoc, SourceLocation PrevLoc,
7963  const ObjCList<ObjCProtocolDecl> &PList);
7964 
7965  Decl *ActOnStartProtocolInterface(
7966  SourceLocation AtProtoInterfaceLoc, IdentifierInfo *ProtocolName,
7967  SourceLocation ProtocolLoc, Decl *const *ProtoRefNames,
7968  unsigned NumProtoRefs, const SourceLocation *ProtoLocs,
7969  SourceLocation EndProtoLoc, const ParsedAttributesView &AttrList);
7970 
7971  Decl *ActOnStartCategoryInterface(
7972  SourceLocation AtInterfaceLoc, IdentifierInfo *ClassName,
7973  SourceLocation ClassLoc, ObjCTypeParamList *typeParamList,
7974  IdentifierInfo *CategoryName, SourceLocation CategoryLoc,
7975  Decl *const *ProtoRefs, unsigned NumProtoRefs,
7976  const SourceLocation *ProtoLocs, SourceLocation EndProtoLoc,
7977  const ParsedAttributesView &AttrList);
7978 
7979  Decl *ActOnStartClassImplementation(
7980  SourceLocation AtClassImplLoc,
7981  IdentifierInfo *ClassName, SourceLocation ClassLoc,
7982  IdentifierInfo *SuperClassname,
7983  SourceLocation SuperClassLoc);
7984 
7985  Decl *ActOnStartCategoryImplementation(SourceLocation AtCatImplLoc,
7986  IdentifierInfo *ClassName,
7987  SourceLocation ClassLoc,
7988  IdentifierInfo *CatName,
7989  SourceLocation CatLoc);
7990 
7991  DeclGroupPtrTy ActOnFinishObjCImplementation(Decl *ObjCImpDecl,
7992  ArrayRef<Decl *> Decls);
7993 
7994  DeclGroupPtrTy ActOnForwardClassDeclaration(SourceLocation Loc,
7995  IdentifierInfo **IdentList,
7996  SourceLocation *IdentLocs,
7997  ArrayRef<ObjCTypeParamList *> TypeParamLists,
7998  unsigned NumElts);
7999 
8000  DeclGroupPtrTy
8001  ActOnForwardProtocolDeclaration(SourceLocation AtProtoclLoc,
8002  ArrayRef<IdentifierLocPair> IdentList,
8003  const ParsedAttributesView &attrList);
8004 
8005  void FindProtocolDeclaration(bool WarnOnDeclarations, bool ForObjCContainer,
8006  ArrayRef<IdentifierLocPair> ProtocolId,
8007  SmallVectorImpl<Decl *> &Protocols);
8008 
8009  void DiagnoseTypeArgsAndProtocols(IdentifierInfo *ProtocolId,
8010  SourceLocation ProtocolLoc,
8011  IdentifierInfo *TypeArgId,
8012  SourceLocation TypeArgLoc,
8013  bool SelectProtocolFirst = false);
8014 
8015  /// Given a list of identifiers (and their locations), resolve the
8016  /// names to either Objective-C protocol qualifiers or type
8017  /// arguments, as appropriate.
8018  void actOnObjCTypeArgsOrProtocolQualifiers(
8019  Scope *S,
8020  ParsedType baseType,
8021  SourceLocation lAngleLoc,
8022  ArrayRef<IdentifierInfo *> identifiers,
8023  ArrayRef<SourceLocation> identifierLocs,
8024  SourceLocation rAngleLoc,
8025  SourceLocation &typeArgsLAngleLoc,
8026  SmallVectorImpl<ParsedType> &typeArgs,
8027  SourceLocation &typeArgsRAngleLoc,
8028  SourceLocation &protocolLAngleLoc,
8029  SmallVectorImpl<Decl *> &protocols,
8030  SourceLocation &protocolRAngleLoc,
8031  bool warnOnIncompleteProtocols);
8032 
8033  /// Build a an Objective-C protocol-qualified 'id' type where no
8034  /// base type was specified.
8035  TypeResult actOnObjCProtocolQualifierType(
8036  SourceLocation lAngleLoc,
8037  ArrayRef<Decl *> protocols,
8038  ArrayRef<SourceLocation> protocolLocs,
8039  SourceLocation rAngleLoc);
8040 
8041  /// Build a specialized and/or protocol-qualified Objective-C type.
8042  TypeResult actOnObjCTypeArgsAndProtocolQualifiers(
8043  Scope *S,
8044  SourceLocation Loc,
8045  ParsedType BaseType,
8046  SourceLocation TypeArgsLAngleLoc,
8047  ArrayRef<ParsedType> TypeArgs,
8048  SourceLocation TypeArgsRAngleLoc,
8049  SourceLocation ProtocolLAngleLoc,
8050  ArrayRef<Decl *> Protocols,
8051  ArrayRef<SourceLocation> ProtocolLocs,
8052  SourceLocation ProtocolRAngleLoc);
8053 
8054  /// Build an Objective-C type parameter type.
8055  QualType BuildObjCTypeParamType(const ObjCTypeParamDecl *Decl,
8056  SourceLocation ProtocolLAngleLoc,
8057  ArrayRef<ObjCProtocolDecl *> Protocols,
8058  ArrayRef<SourceLocation> ProtocolLocs,
8059  SourceLocation ProtocolRAngleLoc,
8060  bool FailOnError = false);
8061 
8062  /// Build an Objective-C object pointer type.
8063  QualType BuildObjCObjectType(QualType BaseType,
8064  SourceLocation Loc,
8065  SourceLocation TypeArgsLAngleLoc,
8066  ArrayRef<TypeSourceInfo *> TypeArgs,
8067  SourceLocation TypeArgsRAngleLoc,
8068  SourceLocation ProtocolLAngleLoc,
8069  ArrayRef<ObjCProtocolDecl *> Protocols,
8070  ArrayRef<SourceLocation> ProtocolLocs,
8071  SourceLocation ProtocolRAngleLoc,
8072  bool FailOnError = false);
8073 
8074  /// Check the application of the Objective-C '__kindof' qualifier to
8075  /// the given type.
8076  bool checkObjCKindOfType(QualType &type, SourceLocation loc);
8077 
8078  /// Ensure attributes are consistent with type.
8079  /// \param [in, out] Attributes The attributes to check; they will
8080  /// be modified to be consistent with \p PropertyTy.
8081  void CheckObjCPropertyAttributes(Decl *PropertyPtrTy,
8082  SourceLocation Loc,
8083  unsigned &Attributes,
8084  bool propertyInPrimaryClass);
8085 
8086  /// Process the specified property declaration and create decls for the
8087  /// setters and getters as needed.
8088  /// \param property The property declaration being processed
8089  void ProcessPropertyDecl(ObjCPropertyDecl *property);
8090 
8091 
8092  void DiagnosePropertyMismatch(ObjCPropertyDecl *Property,
8093  ObjCPropertyDecl *SuperProperty,
8094  const IdentifierInfo *Name,
8095  bool OverridingProtocolProperty);
8096 
8097  void DiagnoseClassExtensionDupMethods(ObjCCategoryDecl *CAT,
8098  ObjCInterfaceDecl *ID);
8099 
8100  Decl *ActOnAtEnd(Scope *S, SourceRange AtEnd,
8101  ArrayRef<Decl *> allMethods = None,
8102  ArrayRef<DeclGroupPtrTy> allTUVars = None);
8103 
8104  Decl *ActOnProperty(Scope *S, SourceLocation AtLoc,
8105  SourceLocation LParenLoc,
8106  FieldDeclarator &FD, ObjCDeclSpec &ODS,
8107  Selector GetterSel, Selector SetterSel,
8108  tok::ObjCKeywordKind MethodImplKind,
8109  DeclContext *lexicalDC = nullptr);
8110 
8111  Decl *ActOnPropertyImplDecl(Scope *S,
8112  SourceLocation AtLoc,
8113  SourceLocation PropertyLoc,
8114  bool ImplKind,
8115  IdentifierInfo *PropertyId,
8116  IdentifierInfo *PropertyIvar,
8117  SourceLocation PropertyIvarLoc,
8118  ObjCPropertyQueryKind QueryKind);
8119 
8126  OSMK_NonRetainingInit
8127  };
8128 
8129  struct ObjCArgInfo {
8132  // The Type is null if no type was specified, and the DeclSpec is invalid
8133  // in this case.
8136 
8137  /// ArgAttrs - Attribute list for this argument.
8139  };
8140 
8141  Decl *ActOnMethodDeclaration(
8142  Scope *S,
8143  SourceLocation BeginLoc, // location of the + or -.
8144  SourceLocation EndLoc, // location of the ; or {.
8145  tok::TokenKind MethodType, ObjCDeclSpec &ReturnQT, ParsedType ReturnType,
8146  ArrayRef<SourceLocation> SelectorLocs, Selector Sel,
8147  // optional arguments. The number of types/arguments is obtained
8148  // from the Sel.getNumArgs().
8149  ObjCArgInfo *ArgInfo, DeclaratorChunk::ParamInfo *CParamInfo,
8150  unsigned CNumArgs, // c-style args
8151  const ParsedAttributesView &AttrList, tok::ObjCKeywordKind MethodImplKind,
8152  bool isVariadic, bool MethodDefinition);
8153 
8154  ObjCMethodDecl *LookupMethodInQualifiedType(Selector Sel,
8155  const ObjCObjectPointerType *OPT,
8156  bool IsInstance);
8157  ObjCMethodDecl *LookupMethodInObjectType(Selector Sel, QualType Ty,
8158  bool IsInstance);
8159 
8160  bool CheckARCMethodDecl(ObjCMethodDecl *method);
8161  bool inferObjCARCLifetime(ValueDecl *decl);
8162 
8163  ExprResult
8164  HandleExprPropertyRefExpr(const ObjCObjectPointerType *OPT,
8165  Expr *BaseExpr,
8166  SourceLocation OpLoc,
8167  DeclarationName MemberName,
8168  SourceLocation MemberLoc,
8169  SourceLocation SuperLoc, QualType SuperType,
8170  bool Super);
8171 
8172  ExprResult
8173  ActOnClassPropertyRefExpr(IdentifierInfo &receiverName,
8174  IdentifierInfo &propertyName,
8175  SourceLocation receiverNameLoc,
8176  SourceLocation propertyNameLoc);
8177 
8178  ObjCMethodDecl *tryCaptureObjCSelf(SourceLocation Loc);
8179 
8180  /// Describes the kind of message expression indicated by a message
8181  /// send that starts with an identifier.
8183  /// The message is sent to 'super'.
8185  /// The message is an instance message.
8187  /// The message is a class message, and the identifier is a type
8188  /// name.
8189  ObjCClassMessage
8190  };
8191 
8192  ObjCMessageKind getObjCMessageKind(Scope *S,
8193  IdentifierInfo *Name,
8194  SourceLocation NameLoc,
8195  bool IsSuper,
8196  bool HasTrailingDot,
8197  ParsedType &ReceiverType);
8198 
8199  ExprResult ActOnSuperMessage(Scope *S, SourceLocation SuperLoc,
8200  Selector Sel,
8201  SourceLocation LBracLoc,
8202  ArrayRef<SourceLocation> SelectorLocs,
8203  SourceLocation RBracLoc,
8204  MultiExprArg Args);
8205 
8206  ExprResult BuildClassMessage(TypeSourceInfo *ReceiverTypeInfo,
8207  QualType ReceiverType,
8208  SourceLocation SuperLoc,
8209  Selector Sel,
8210  ObjCMethodDecl *Method,
8211  SourceLocation LBracLoc,
8212  ArrayRef<SourceLocation> SelectorLocs,
8213  SourceLocation RBracLoc,
8214  MultiExprArg Args,
8215  bool isImplicit = false);
8216 
8217  ExprResult BuildClassMessageImplicit(QualType ReceiverType,
8218  bool isSuperReceiver,
8219  SourceLocation Loc,
8220  Selector Sel,
8221  ObjCMethodDecl *Method,
8222  MultiExprArg Args);
8223 
8224  ExprResult ActOnClassMessage(Scope *S,
8225  ParsedType Receiver,
8226  Selector Sel,
8227  SourceLocation LBracLoc,
8228  ArrayRef<SourceLocation> SelectorLocs,
8229  SourceLocation RBracLoc,
8230  MultiExprArg Args);
8231 
8232  ExprResult BuildInstanceMessage(Expr *Receiver,
8233  QualType ReceiverType,
8234  SourceLocation SuperLoc,
8235  Selector Sel,
8236  ObjCMethodDecl *Method,
8237  SourceLocation LBracLoc,
8238  ArrayRef<SourceLocation> SelectorLocs,
8239  SourceLocation RBracLoc,
8240  MultiExprArg Args,
8241  bool isImplicit = false);
8242 
8243  ExprResult BuildInstanceMessageImplicit(Expr *Receiver,
8244  QualType ReceiverType,
8245  SourceLocation Loc,
8246  Selector Sel,
8247  ObjCMethodDecl *Method,
8248  MultiExprArg Args);
8249 
8250  ExprResult ActOnInstanceMessage(Scope *S,
8251  Expr *Receiver,
8252  Selector Sel,
8253  SourceLocation LBracLoc,
8254  ArrayRef<SourceLocation> SelectorLocs,
8255  SourceLocation RBracLoc,
8256  MultiExprArg Args);
8257 
8258  ExprResult BuildObjCBridgedCast(SourceLocation LParenLoc,
8259  ObjCBridgeCastKind Kind,
8260  SourceLocation BridgeKeywordLoc,
8261  TypeSourceInfo *TSInfo,
8262  Expr *SubExpr);
8263 
8264  ExprResult ActOnObjCBridgedCast(Scope *S,
8265  SourceLocation LParenLoc,
8266  ObjCBridgeCastKind Kind,
8267  SourceLocation BridgeKeywordLoc,
8268  ParsedType Type,
8269  SourceLocation RParenLoc,
8270  Expr *SubExpr);
8271 
8272  void CheckTollFreeBridgeCast(QualType castType, Expr *castExpr);
8273 
8274  void CheckObjCBridgeRelatedCast(QualType castType, Expr *castExpr);
8275 
8276  bool CheckTollFreeBridgeStaticCast(QualType castType, Expr *castExpr,
8277  CastKind &Kind);
8278 
8279  bool checkObjCBridgeRelatedComponents(SourceLocation Loc,
8280  QualType DestType, QualType SrcType,
8281  ObjCInterfaceDecl *&RelatedClass,
8282  ObjCMethodDecl *&ClassMethod,
8283  ObjCMethodDecl *&InstanceMethod,
8284  TypedefNameDecl *&TDNDecl,
8285  bool CfToNs, bool Diagnose = true);
8286 
8287  bool CheckObjCBridgeRelatedConversions(SourceLocation Loc,
8288  QualType DestType, QualType SrcType,
8289  Expr *&SrcExpr, bool Diagnose = true);
8290 
8291  bool ConversionToObjCStringLiteralCheck(QualType DstType, Expr *&SrcExpr,
8292  bool Diagnose = true);
8293 
8294  bool checkInitMethod(ObjCMethodDecl *method, QualType receiverTypeIfCall);
8295 
8296  /// Check whether the given new method is a valid override of the
8297  /// given overridden method, and set any properties that should be inherited.
8298  void CheckObjCMethodOverride(ObjCMethodDecl *NewMethod,
8299  const ObjCMethodDecl *Overridden);
8300 
8301  /// Describes the compatibility of a result type with its method.
8305  RTC_Unknown
8306  };
8307 
8308  void CheckObjCMethodOverrides(ObjCMethodDecl *ObjCMethod,
8309  ObjCInterfaceDecl *CurrentClass,
8311 
8313  POAK_Native, // #pragma options align=native
8314  POAK_Natural, // #pragma options align=natural
8315  POAK_Packed, // #pragma options align=packed
8316  POAK_Power, // #pragma options align=power
8317  POAK_Mac68k, // #pragma options align=mac68k
8318  POAK_Reset // #pragma options align=reset
8319  };
8320 
8321  /// ActOnPragmaClangSection - Called on well formed \#pragma clang section
8322  void ActOnPragmaClangSection(SourceLocation PragmaLoc,
8323  PragmaClangSectionAction Action,
8324  PragmaClangSectionKind SecKind, StringRef SecName);
8325 
8326  /// ActOnPragmaOptionsAlign - Called on well formed \#pragma options align.
8327  void ActOnPragmaOptionsAlign(PragmaOptionsAlignKind Kind,
8328  SourceLocation PragmaLoc);
8329 
8330  /// ActOnPragmaPack - Called on well formed \#pragma pack(...).
8331  void ActOnPragmaPack(SourceLocation PragmaLoc, PragmaMsStackAction Action,
8332  StringRef SlotLabel, Expr *Alignment);
8333 
8335  NonDefaultStateAtInclude,
8336  ChangedStateAtExit
8337  };
8338 
8339  void DiagnoseNonDefaultPragmaPack(PragmaPackDiagnoseKind Kind,
8340  SourceLocation IncludeLoc);
8341  void DiagnoseUnterminatedPragmaPack();
8342 
8343  /// ActOnPragmaMSStruct - Called on well formed \#pragma ms_struct [on|off].
8344  void ActOnPragmaMSStruct(PragmaMSStructKind Kind);
8345 
8346  /// ActOnPragmaMSComment - Called on well formed
8347  /// \#pragma comment(kind, "arg").
8348  void ActOnPragmaMSComment(SourceLocation CommentLoc, PragmaMSCommentKind Kind,
8349  StringRef Arg);
8350 
8351  /// ActOnPragmaMSPointersToMembers - called on well formed \#pragma
8352  /// pointers_to_members(representation method[, general purpose
8353  /// representation]).
8354  void ActOnPragmaMSPointersToMembers(
8356  SourceLocation PragmaLoc);
8357 
8358  /// Called on well formed \#pragma vtordisp().
8359  void ActOnPragmaMSVtorDisp(PragmaMsStackAction Action,
8360  SourceLocation PragmaLoc,
8361  MSVtorDispAttr::Mode Value);
8362 
8368  };
8369 
8370  bool UnifySection(StringRef SectionName,
8371  int SectionFlags,
8372  DeclaratorDecl *TheDecl);
8373  bool UnifySection(StringRef SectionName,
8374  int SectionFlags,
8375  SourceLocation PragmaSectionLocation);
8376 
8377  /// Called on well formed \#pragma bss_seg/data_seg/const_seg/code_seg.
8378  void ActOnPragmaMSSeg(SourceLocation PragmaLocation,
8379  PragmaMsStackAction Action,
8380  llvm::StringRef StackSlotLabel,
8381  StringLiteral *SegmentName,
8382  llvm::StringRef PragmaName);
8383 
8384  /// Called on well formed \#pragma section().
8385  void ActOnPragmaMSSection(SourceLocation PragmaLocation,
8386  int SectionFlags, StringLiteral *SegmentName);
8387 
8388  /// Called on well-formed \#pragma init_seg().
8389  void ActOnPragmaMSInitSeg(SourceLocation PragmaLocation,
8390  StringLiteral *SegmentName);
8391 
8392  /// Called on #pragma clang __debug dump II
8393  void ActOnPragmaDump(Scope *S, SourceLocation Loc, IdentifierInfo *II);
8394 
8395  /// ActOnPragmaDetectMismatch - Call on well-formed \#pragma detect_mismatch
8396  void ActOnPragmaDetectMismatch(SourceLocation Loc, StringRef Name,
8397  StringRef Value);
8398 
8399  /// ActOnPragmaUnused - Called on well-formed '\#pragma unused'.
8400  void ActOnPragmaUnused(const Token &Identifier,
8401  Scope *curScope,
8402  SourceLocation PragmaLoc);
8403 
8404  /// ActOnPragmaVisibility - Called on well formed \#pragma GCC visibility... .
8405  void ActOnPragmaVisibility(const IdentifierInfo* VisType,
8406  SourceLocation PragmaLoc);
8407 
8408  NamedDecl *DeclClonePragmaWeak(NamedDecl *ND, IdentifierInfo *II,
8409  SourceLocation Loc);
8410  void DeclApplyPragmaWeak(Scope *S, NamedDecl *ND, WeakInfo &W);
8411 
8412  /// ActOnPragmaWeakID - Called on well formed \#pragma weak ident.
8413  void ActOnPragmaWeakID(IdentifierInfo* WeakName,
8414  SourceLocation PragmaLoc,
8415  SourceLocation WeakNameLoc);
8416 
8417  /// ActOnPragmaRedefineExtname - Called on well formed
8418  /// \#pragma redefine_extname oldname newname.
8419  void ActOnPragmaRedefineExtname(IdentifierInfo* WeakName,
8420  IdentifierInfo* AliasName,
8421  SourceLocation PragmaLoc,
8422  SourceLocation WeakNameLoc,
8423  SourceLocation AliasNameLoc);
8424 
8425  /// ActOnPragmaWeakAlias - Called on well formed \#pragma weak ident = ident.
8426  void ActOnPragmaWeakAlias(IdentifierInfo* WeakName,
8427  IdentifierInfo* AliasName,
8428  SourceLocation PragmaLoc,
8429  SourceLocation WeakNameLoc,
8430  SourceLocation AliasNameLoc);
8431 
8432  /// ActOnPragmaFPContract - Called on well formed
8433  /// \#pragma {STDC,OPENCL} FP_CONTRACT and
8434  /// \#pragma clang fp contract
8435  void ActOnPragmaFPContract(LangOptions::FPContractModeKind FPC);
8436 
8437  /// AddAlignmentAttributesForRecord - Adds any needed alignment attributes to
8438  /// a the record decl, to handle '\#pragma pack' and '\#pragma options align'.
8439  void AddAlignmentAttributesForRecord(RecordDecl *RD);
8440 
8441  /// AddMsStructLayoutForRecord - Adds ms_struct layout attribute to record.
8442  void AddMsStructLayoutForRecord(RecordDecl *RD);
8443 
8444  /// FreePackedContext - Deallocate and null out PackContext.
8445  void FreePackedContext();
8446 
8447  /// PushNamespaceVisibilityAttr - Note that we've entered a
8448  /// namespace with a visibility attribute.
8449  void PushNamespaceVisibilityAttr(const VisibilityAttr *Attr,
8450  SourceLocation Loc);
8451 
8452  /// AddPushedVisibilityAttribute - If '\#pragma GCC visibility' was used,
8453  /// add an appropriate visibility attribute.
8454  void AddPushedVisibilityAttribute(Decl *RD);
8455 
8456  /// PopPragmaVisibility - Pop the top element of the visibility stack; used
8457  /// for '\#pragma GCC visibility' and visibility attributes on namespaces.
8458  void PopPragmaVisibility(bool IsNamespaceEnd, SourceLocation EndLoc);
8459 
8460  /// FreeVisContext - Deallocate and null out VisContext.
8461  void FreeVisContext();
8462 
8463  /// AddCFAuditedAttribute - Check whether we're currently within
8464  /// '\#pragma clang arc_cf_code_audited' and, if so, consider adding
8465  /// the appropriate attribute.
8466  void AddCFAuditedAttribute(Decl *D);
8467 
8468  /// Called on well-formed '\#pragma clang attribute push'.
8469  void ActOnPragmaAttributePush(ParsedAttr &Attribute, SourceLocation PragmaLoc,
8471 
8472  /// Called on well-formed '\#pragma clang attribute pop'.
8473  void ActOnPragmaAttributePop(SourceLocation PragmaLoc);
8474 
8475  /// Adds the attributes that have been specified using the
8476  /// '\#pragma clang attribute push' directives to the given declaration.
8477  void AddPragmaAttributes(Scope *S, Decl *D);
8478 
8479  void DiagnoseUnterminatedPragmaAttribute();
8480 
8481  /// Called on well formed \#pragma clang optimize.
8482  void ActOnPragmaOptimize(bool On, SourceLocation PragmaLoc);
8483 
8484  /// Get the location for the currently active "\#pragma clang optimize
8485  /// off". If this location is invalid, then the state of the pragma is "on".
8487  return OptimizeOffPragmaLocation;
8488  }
8489 
8490  /// Only called on function definitions; if there is a pragma in scope
8491  /// with the effect of a range-based optnone, consider marking the function
8492  /// with attribute optnone.
8493  void AddRangeBasedOptnone(FunctionDecl *FD);
8494 
8495  /// Adds the 'optnone' attribute to the function declaration if there
8496  /// are no conflicts; Loc represents the location causing the 'optnone'
8497  /// attribute to be added (usually because of a pragma).
8498  void AddOptnoneAttributeIfNoConflicts(FunctionDecl *FD, SourceLocation Loc);
8499 
8500  /// AddAlignedAttr - Adds an aligned attribute to a particular declaration.
8501  void AddAlignedAttr(SourceRange AttrRange, Decl *D, Expr *E,
8502  unsigned SpellingListIndex, bool IsPackExpansion);
8503  void AddAlignedAttr(SourceRange AttrRange, Decl *D, TypeSourceInfo *T,
8504  unsigned SpellingListIndex, bool IsPackExpansion);
8505 
8506  /// AddAssumeAlignedAttr - Adds an assume_aligned attribute to a particular
8507  /// declaration.
8508  void AddAssumeAlignedAttr(SourceRange AttrRange, Decl *D, Expr *E, Expr *OE,
8509  unsigned SpellingListIndex);
8510 
8511  /// AddAllocAlignAttr - Adds an alloc_align attribute to a particular
8512  /// declaration.
8513  void AddAllocAlignAttr(SourceRange AttrRange, Decl *D, Expr *ParamExpr,
8514  unsigned SpellingListIndex);
8515 
8516  /// AddAlignValueAttr - Adds an align_value attribute to a particular
8517  /// declaration.
8518  void AddAlignValueAttr(SourceRange AttrRange, Decl *D, Expr *E,
8519  unsigned SpellingListIndex);
8520 
8521  /// AddLaunchBoundsAttr - Adds a launch_bounds attribute to a particular
8522  /// declaration.
8523  void AddLaunchBoundsAttr(SourceRange AttrRange, Decl *D, Expr *MaxThreads,
8524  Expr *MinBlocks, unsigned SpellingListIndex);
8525 
8526  /// AddModeAttr - Adds a mode attribute to a particular declaration.
8527  void AddModeAttr(SourceRange AttrRange, Decl *D, IdentifierInfo *Name,
8528  unsigned SpellingListIndex, bool InInstantiation = false);
8529 
8530  void AddParameterABIAttr(SourceRange AttrRange, Decl *D,
8531  ParameterABI ABI, unsigned SpellingListIndex);
8532 
8533  void AddNSConsumedAttr(SourceRange AttrRange, Decl *D,
8534  unsigned SpellingListIndex, bool isNSConsumed,
8536 
8537  bool checkNSReturnsRetainedReturnType(SourceLocation loc, QualType type);
8538 
8539  //===--------------------------------------------------------------------===//
8540  // C++ Coroutines TS
8541  //
8542  bool ActOnCoroutineBodyStart(Scope *S, SourceLocation KwLoc,
8543  StringRef Keyword);
8544  ExprResult ActOnCoawaitExpr(Scope *S, SourceLocation KwLoc, Expr *E);
8545  ExprResult ActOnCoyieldExpr(Scope *S, SourceLocation KwLoc, Expr *E);
8546  StmtResult ActOnCoreturnStmt(Scope *S, SourceLocation KwLoc, Expr *E);
8547 
8548  ExprResult BuildResolvedCoawaitExpr(SourceLocation KwLoc, Expr *E,
8549  bool IsImplicit = false);
8550  ExprResult BuildUnresolvedCoawaitExpr(SourceLocation KwLoc, Expr *E,
8551  UnresolvedLookupExpr* Lookup);
8552  ExprResult BuildCoyieldExpr(SourceLocation KwLoc, Expr *E);
8553  StmtResult BuildCoreturnStmt(SourceLocation KwLoc, Expr *E,
8554  bool IsImplicit = false);
8555  StmtResult BuildCoroutineBodyStmt(CoroutineBodyStmt::CtorArgs);
8556  bool buildCoroutineParameterMoves(SourceLocation Loc);
8557  VarDecl *buildCoroutinePromise(SourceLocation Loc);
8558  void CheckCompletedCoroutineBody(FunctionDecl *FD, Stmt *&Body);
8559  ClassTemplateDecl *lookupCoroutineTraits(SourceLocation KwLoc,
8560  SourceLocation FuncLoc);
8561 
8562  //===--------------------------------------------------------------------===//
8563  // OpenCL extensions.
8564  //
8565 private:
8566  std::string CurrOpenCLExtension;
8567  /// Extensions required by an OpenCL type.
8568  llvm::DenseMap<const Type*, std::set<std::string>> OpenCLTypeExtMap;
8569  /// Extensions required by an OpenCL declaration.
8570  llvm::DenseMap<const Decl*, std::set<std::string>> OpenCLDeclExtMap;
8571 public:
8572  llvm::StringRef getCurrentOpenCLExtension() const {
8573  return CurrOpenCLExtension;
8574  }
8575  void setCurrentOpenCLExtension(llvm::StringRef Ext) {
8576  CurrOpenCLExtension = Ext;
8577  }
8578 
8579  /// Set OpenCL extensions for a type which can only be used when these
8580  /// OpenCL extensions are enabled. If \p Exts is empty, do nothing.
8581  /// \param Exts A space separated list of OpenCL extensions.
8582  void setOpenCLExtensionForType(QualType T, llvm::StringRef Exts);
8583 
8584  /// Set OpenCL extensions for a declaration which can only be
8585  /// used when these OpenCL extensions are enabled. If \p Exts is empty, do
8586  /// nothing.
8587  /// \param Exts A space separated list of OpenCL extensions.
8588  void setOpenCLExtensionForDecl(Decl *FD, llvm::StringRef Exts);
8589 
8590  /// Set current OpenCL extensions for a type which can only be used
8591  /// when these OpenCL extensions are enabled. If current OpenCL extension is
8592  /// empty, do nothing.
8593  void setCurrentOpenCLExtensionForType(QualType T);
8594 
8595  /// Set current OpenCL extensions for a declaration which
8596  /// can only be used when these OpenCL extensions are enabled. If current
8597  /// OpenCL extension is empty, do nothing.
8598  void setCurrentOpenCLExtensionForDecl(Decl *FD);
8599 
8600  bool isOpenCLDisabledDecl(Decl *FD);
8601 
8602  /// Check if type \p T corresponding to declaration specifier \p DS
8603  /// is disabled due to required OpenCL extensions being disabled. If so,
8604  /// emit diagnostics.
8605  /// \return true if type is disabled.
8606  bool checkOpenCLDisabledTypeDeclSpec(const DeclSpec &DS, QualType T);
8607 
8608  /// Check if declaration \p D used by expression \p E
8609  /// is disabled due to required OpenCL extensions being disabled. If so,
8610  /// emit diagnostics.
8611  /// \return true if type is disabled.
8612  bool checkOpenCLDisabledDecl(const NamedDecl &D, const Expr &E);
8613 
8614  //===--------------------------------------------------------------------===//
8615  // OpenMP directives and clauses.
8616  //
8617 private:
8618  void *VarDataSharingAttributesStack;
8619  /// Set to true inside '#pragma omp declare target' region.
8620  bool IsInOpenMPDeclareTargetContext = false;
8621  /// Initialization of data-sharing attributes stack.
8622  void InitDataSharingAttributesStack();
8623  void DestroyDataSharingAttributesStack();
8624  ExprResult
8625  VerifyPositiveIntegerConstantInClause(Expr *Op, OpenMPClauseKind CKind,
8626  bool StrictlyPositive = true);
8627  /// Returns OpenMP nesting level for current directive.
8628  unsigned getOpenMPNestingLevel() const;
8629 
8630  /// Adjusts the function scopes index for the target-based regions.
8631  void adjustOpenMPTargetScopeIndex(unsigned &FunctionScopesIndex,
8632  unsigned Level) const;
8633 
8634  /// Push new OpenMP function region for non-capturing function.
8635  void pushOpenMPFunctionRegion();
8636 
8637  /// Pop OpenMP function region for non-capturing function.
8638  void popOpenMPFunctionRegion(const sema::FunctionScopeInfo *OldFSI);
8639 
8640  /// Checks if a type or a declaration is disabled due to the owning extension
8641  /// being disabled, and emits diagnostic messages if it is disabled.
8642  /// \param D type or declaration to be checked.
8643  /// \param DiagLoc source location for the diagnostic message.
8644  /// \param DiagInfo information to be emitted for the diagnostic message.
8645  /// \param SrcRange source range of the declaration.
8646  /// \param Map maps type or declaration to the extensions.
8647  /// \param Selector selects diagnostic message: 0 for type and 1 for
8648  /// declaration.
8649  /// \return true if the type or declaration is disabled.
8650  template <typename T, typename DiagLocT, typename DiagInfoT, typename MapT>
8651  bool checkOpenCLDisabledTypeOrDecl(T D, DiagLocT DiagLoc, DiagInfoT DiagInfo,
8652  MapT &Map, unsigned Selector = 0,
8653  SourceRange SrcRange = SourceRange());
8654 
8655 public:
8656  /// Return true if the provided declaration \a VD should be captured by
8657  /// reference.
8658  /// \param Level Relative level of nested OpenMP construct for that the check
8659  /// is performed.
8660  bool isOpenMPCapturedByRef(const ValueDecl *D, unsigned Level) const;
8661 
8662  /// Check if the specified variable is used in one of the private
8663  /// clauses (private, firstprivate, lastprivate, reduction etc.) in OpenMP
8664  /// constructs.
8665  VarDecl *isOpenMPCapturedDecl(ValueDecl *D) const;
8666  ExprResult getOpenMPCapturedExpr(VarDecl *Capture, ExprValueKind VK,
8667  ExprObjectKind OK, SourceLocation Loc);
8668 
8669  /// Check if the specified variable is used in 'private' clause.
8670  /// \param Level Relative level of nested OpenMP construct for that the check
8671  /// is performed.
8672  bool isOpenMPPrivateDecl(const ValueDecl *D, unsigned Level) const;
8673 
8674  /// Sets OpenMP capture kind (OMPC_private, OMPC_firstprivate, OMPC_map etc.)
8675  /// for \p FD based on DSA for the provided corresponding captured declaration
8676  /// \p D.
8677  void setOpenMPCaptureKind(FieldDecl *FD, const ValueDecl *D, unsigned Level);
8678 
8679  /// Check if the specified variable is captured by 'target' directive.
8680  /// \param Level Relative level of nested OpenMP construct for that the check
8681  /// is performed.
8682  bool isOpenMPTargetCapturedDecl(const ValueDecl *D, unsigned Level) const;
8683 
8684  ExprResult PerformOpenMPImplicitIntegerConversion(SourceLocation OpLoc,
8685  Expr *Op);
8686  /// Called on start of new data sharing attribute block.
8687  void StartOpenMPDSABlock(OpenMPDirectiveKind K,
8688  const DeclarationNameInfo &DirName, Scope *CurScope,
8689  SourceLocation Loc);
8690  /// Start analysis of clauses.
8691  void StartOpenMPClause(OpenMPClauseKind K);
8692  /// End analysis of clauses.
8693  void EndOpenMPClause();
8694  /// Called on end of data sharing attribute block.
8695  void EndOpenMPDSABlock(Stmt *CurDirective);
8696 
8697  /// Check if the current region is an OpenMP loop region and if it is,
8698  /// mark loop control variable, used in \p Init for loop initialization, as
8699  /// private by default.
8700  /// \param Init First part of the for loop.
8701  void ActOnOpenMPLoopInitialization(SourceLocation ForLoc, Stmt *Init);
8702 
8703  // OpenMP directives and clauses.
8704  /// Called on correct id-expression from the '#pragma omp
8705  /// threadprivate'.
8706  ExprResult ActOnOpenMPIdExpression(Scope *CurScope,
8707  CXXScopeSpec &ScopeSpec,
8708  const DeclarationNameInfo &Id);
8709  /// Called on well-formed '#pragma omp threadprivate'.
8710  DeclGroupPtrTy ActOnOpenMPThreadprivateDirective(
8711  SourceLocation Loc,
8712  ArrayRef<Expr *> VarList);
8713  /// Builds a new OpenMPThreadPrivateDecl and checks its correctness.
8714  OMPThreadPrivateDecl *CheckOMPThreadPrivateDecl(SourceLocation Loc,
8715  ArrayRef<Expr *> VarList);
8716  /// Check if the specified type is allowed to be used in 'omp declare
8717  /// reduction' construct.
8718  QualType ActOnOpenMPDeclareReductionType(SourceLocation TyLoc,
8720  /// Called on start of '#pragma omp declare reduction'.
8721  DeclGroupPtrTy ActOnOpenMPDeclareReductionDirectiveStart(
8722  Scope *S, DeclContext *DC, DeclarationName Name,
8723  ArrayRef<std::pair<QualType, SourceLocation>> ReductionTypes,
8724  AccessSpecifier AS, Decl *PrevDeclInScope = nullptr);
8725  /// Initialize declare reduction construct initializer.
8726  void ActOnOpenMPDeclareReductionCombinerStart(Scope *S, Decl *D);
8727  /// Finish current declare reduction construct initializer.
8728  void ActOnOpenMPDeclareReductionCombinerEnd(Decl *D, Expr *Combiner);
8729  /// Initialize declare reduction construct initializer.
8730  /// \return omp_priv variable.
8731  VarDecl *ActOnOpenMPDeclareReductionInitializerStart(Scope *S, Decl *D);
8732  /// Finish current declare reduction construct initializer.
8733  void ActOnOpenMPDeclareReductionInitializerEnd(Decl *D, Expr *Initializer,
8734  VarDecl *OmpPrivParm);
8735  /// Called at the end of '#pragma omp declare reduction'.
8736  DeclGroupPtrTy ActOnOpenMPDeclareReductionDirectiveEnd(
8737  Scope *S, DeclGroupPtrTy DeclReductions, bool IsValid);
8738 
8739  /// Called on the start of target region i.e. '#pragma omp declare target'.
8740  bool ActOnStartOpenMPDeclareTargetDirective(SourceLocation Loc);
8741  /// Called at the end of target region i.e. '#pragme omp end declare target'.
8742  void ActOnFinishOpenMPDeclareTargetDirective();
8743  /// Called on correct id-expression from the '#pragma omp declare target'.
8744  void ActOnOpenMPDeclareTargetName(Scope *CurScope, CXXScopeSpec &ScopeSpec,
8745  const DeclarationNameInfo &Id,
8746  OMPDeclareTargetDeclAttr::MapTypeTy MT,
8747  NamedDeclSetType &SameDirectiveDecls);
8748  /// Check declaration inside target region.
8749  void checkDeclIsAllowedInOpenMPTarget(Expr *E, Decl *D,
8750  SourceLocation IdLoc = SourceLocation());
8751  /// Return true inside OpenMP declare target region.
8753  return IsInOpenMPDeclareTargetContext;
8754  }
8755  /// Return true inside OpenMP target region.
8756  bool isInOpenMPTargetExecutionDirective() const;
8757  /// Return true if (un)supported features for the current target should be
8758  /// diagnosed if OpenMP (offloading) is enabled.
8760  return !getLangOpts().OpenMPIsDevice || isInOpenMPDeclareTargetContext() ||
8761  isInOpenMPTargetExecutionDirective();
8762  }
8763 
8764  /// Return the number of captured regions created for an OpenMP directive.
8765  static int getOpenMPCaptureLevels(OpenMPDirectiveKind Kind);
8766 
8767  /// Initialization of captured region for OpenMP region.
8768  void ActOnOpenMPRegionStart(OpenMPDirectiveKind DKind, Scope *CurScope);
8769  /// End of OpenMP region.
8770  ///
8771  /// \param S Statement associated with the current OpenMP region.
8772  /// \param Clauses List of clauses for the current OpenMP region.
8773  ///
8774  /// \returns Statement for finished OpenMP region.
8775  StmtResult ActOnOpenMPRegionEnd(StmtResult S, ArrayRef<OMPClause *> Clauses);
8776  StmtResult ActOnOpenMPExecutableDirective(
8777  OpenMPDirectiveKind Kind, const DeclarationNameInfo &DirName,
8778  OpenMPDirectiveKind CancelRegion, ArrayRef<OMPClause *> Clauses,
8779  Stmt *AStmt, SourceLocation StartLoc, SourceLocation EndLoc);
8780  /// Called on well-formed '\#pragma omp parallel' after parsing
8781  /// of the associated statement.
8782  StmtResult ActOnOpenMPParallelDirective(ArrayRef<OMPClause *> Clauses,
8783  Stmt *AStmt,
8784  SourceLocation StartLoc,
8785  SourceLocation EndLoc);
8786  using VarsWithInheritedDSAType =
8787  llvm::SmallDenseMap<const ValueDecl *, const Expr *, 4>;
8788  /// Called on well-formed '\#pragma omp simd' after parsing
8789  /// of the associated statement.
8790  StmtResult
8791  ActOnOpenMPSimdDirective(ArrayRef<OMPClause *> Clauses, Stmt *AStmt,
8792  SourceLocation StartLoc, SourceLocation EndLoc,
8793  VarsWithInheritedDSAType &VarsWithImplicitDSA);
8794  /// Called on well-formed '\#pragma omp for' after parsing
8795  /// of the associated statement.
8796  StmtResult
8797  ActOnOpenMPForDirective(ArrayRef<OMPClause *> Clauses, Stmt *AStmt,
8798  SourceLocation StartLoc, SourceLocation EndLoc,
8799  VarsWithInheritedDSAType &VarsWithImplicitDSA);
8800  /// Called on well-formed '\#pragma omp for simd' after parsing
8801  /// of the associated statement.
8802  StmtResult
8803  ActOnOpenMPForSimdDirective(ArrayRef<OMPClause *> Clauses, Stmt *AStmt,
8804  SourceLocation StartLoc, SourceLocation EndLoc,
8805  VarsWithInheritedDSAType &VarsWithImplicitDSA);
8806  /// Called on well-formed '\#pragma omp sections' after parsing
8807  /// of the associated statement.
8808  StmtResult ActOnOpenMPSectionsDirective(ArrayRef<OMPClause *> Clauses,
8809  Stmt *AStmt, SourceLocation StartLoc,
8810  SourceLocation EndLoc);
8811  /// Called on well-formed '\#pragma omp section' after parsing of the
8812  /// associated statement.
8813  StmtResult ActOnOpenMPSectionDirective(Stmt *AStmt, SourceLocation StartLoc,
8814  SourceLocation EndLoc);
8815  /// Called on well-formed '\#pragma omp single' after parsing of the
8816  /// associated statement.
8817  StmtResult ActOnOpenMPSingleDirective(ArrayRef<OMPClause *> Clauses,
8818  Stmt *AStmt, SourceLocation StartLoc,
8819  SourceLocation EndLoc);
8820  /// Called on well-formed '\#pragma omp master' after parsing of the
8821  /// associated statement.
8822  StmtResult ActOnOpenMPMasterDirective(Stmt *AStmt, SourceLocation StartLoc,
8823  SourceLocation EndLoc);
8824  /// Called on well-formed '\#pragma omp critical' after parsing of the
8825  /// associated statement.
8826  StmtResult ActOnOpenMPCriticalDirective(const DeclarationNameInfo &DirName,
8827  ArrayRef<OMPClause *> Clauses,
8828  Stmt *AStmt, SourceLocation StartLoc,
8829  SourceLocation EndLoc);
8830  /// Called on well-formed '\#pragma omp parallel for' after parsing
8831  /// of the associated statement.
8832  StmtResult ActOnOpenMPParallelForDirective(
8833  ArrayRef<OMPClause *> Clauses, Stmt *AStmt, SourceLocation StartLoc,
8834  SourceLocation EndLoc, VarsWithInheritedDSAType &VarsWithImplicitDSA);
8835  /// Called on well-formed '\#pragma omp parallel for simd' after
8836  /// parsing of the associated statement.
8837  StmtResult ActOnOpenMPParallelForSimdDirective(
8838  ArrayRef<OMPClause *> Clauses, Stmt *AStmt, SourceLocation StartLoc,
8839  SourceLocation EndLoc, VarsWithInheritedDSAType &VarsWithImplicitDSA);
8840  /// Called on well-formed '\#pragma omp parallel sections' after
8841  /// parsing of the associated statement.
8842  StmtResult ActOnOpenMPParallelSectionsDirective(ArrayRef<OMPClause *> Clauses,
8843  Stmt *AStmt,
8844  SourceLocation StartLoc,
8845  SourceLocation EndLoc);
8846  /// Called on well-formed '\#pragma omp task' after parsing of the
8847  /// associated statement.
8848  StmtResult ActOnOpenMPTaskDirective(ArrayRef<OMPClause *> Clauses,
8849  Stmt *AStmt, SourceLocation StartLoc,
8850  SourceLocation EndLoc);
8851  /// Called on well-formed '\#pragma omp taskyield'.
8852  StmtResult ActOnOpenMPTaskyieldDirective(SourceLocation StartLoc,
8853  SourceLocation EndLoc);
8854  /// Called on well-formed '\#pragma omp barrier'.
8855  StmtResult ActOnOpenMPBarrierDirective(SourceLocation StartLoc,
8856  SourceLocation EndLoc);
8857  /// Called on well-formed '\#pragma omp taskwait'.
8858  StmtResult ActOnOpenMPTaskwaitDirective(SourceLocation StartLoc,
8859  SourceLocation EndLoc);
8860  /// Called on well-formed '\#pragma omp taskgroup'.
8861  StmtResult ActOnOpenMPTaskgroupDirective(ArrayRef<OMPClause *> Clauses,
8862  Stmt *AStmt, SourceLocation StartLoc,
8863  SourceLocation EndLoc);
8864  /// Called on well-formed '\#pragma omp flush'.
8865  StmtResult ActOnOpenMPFlushDirective(ArrayRef<OMPClause *> Clauses,
8866  SourceLocation StartLoc,
8867  SourceLocation EndLoc);
8868  /// Called on well-formed '\#pragma omp ordered' after parsing of the
8869  /// associated statement.
8870  StmtResult ActOnOpenMPOrderedDirective(ArrayRef<OMPClause *> Clauses,
8871  Stmt *AStmt, SourceLocation StartLoc,
8872  SourceLocation EndLoc);
8873  /// Called on well-formed '\#pragma omp atomic' after parsing of the
8874  /// associated statement.
8875  StmtResult ActOnOpenMPAtomicDirective(ArrayRef<OMPClause *> Clauses,
8876  Stmt *AStmt, SourceLocation StartLoc,
8877  SourceLocation EndLoc);
8878  /// Called on well-formed '\#pragma omp target' after parsing of the
8879  /// associated statement.
8880  StmtResult ActOnOpenMPTargetDirective(ArrayRef<OMPClause *> Clauses,
8881  Stmt *AStmt, SourceLocation StartLoc,
8882  SourceLocation EndLoc);
8883  /// Called on well-formed '\#pragma omp target data' after parsing of
8884  /// the associated statement.
8885  StmtResult ActOnOpenMPTargetDataDirective(ArrayRef<OMPClause *> Clauses,
8886  Stmt *AStmt, SourceLocation StartLoc,
8887  SourceLocation EndLoc);
8888  /// Called on well-formed '\#pragma omp target enter data' after
8889  /// parsing of the associated statement.
8890  StmtResult ActOnOpenMPTargetEnterDataDirective(ArrayRef<OMPClause *> Clauses,
8891  SourceLocation StartLoc,
8892  SourceLocation EndLoc,
8893  Stmt *AStmt);
8894  /// Called on well-formed '\#pragma omp target exit data' after
8895  /// parsing of the associated statement.
8896  StmtResult ActOnOpenMPTargetExitDataDirective(ArrayRef<OMPClause *> Clauses,
8897  SourceLocation StartLoc,
8898  SourceLocation EndLoc,
8899  Stmt *AStmt);
8900  /// Called on well-formed '\#pragma omp target parallel' after
8901  /// parsing of the associated statement.
8902  StmtResult ActOnOpenMPTargetParallelDirective(ArrayRef<OMPClause *> Clauses,
8903  Stmt *AStmt,
8904  SourceLocation StartLoc,
8905  SourceLocation EndLoc);
8906  /// Called on well-formed '\#pragma omp target parallel for' after
8907  /// parsing of the associated statement.
8908  StmtResult ActOnOpenMPTargetParallelForDirective(
8909  ArrayRef<OMPClause *> Clauses, Stmt *AStmt, SourceLocation StartLoc,
8910  SourceLocation EndLoc, VarsWithInheritedDSAType &VarsWithImplicitDSA);
8911  /// Called on well-formed '\#pragma omp teams' after parsing of the
8912  /// associated statement.
8913  StmtResult ActOnOpenMPTeamsDirective(ArrayRef<OMPClause *> Clauses,
8914  Stmt *AStmt, SourceLocation StartLoc,
8915  SourceLocation EndLoc);
8916  /// Called on well-formed '\#pragma omp cancellation point'.
8917  StmtResult
8918  ActOnOpenMPCancellationPointDirective(SourceLocation StartLoc,
8919  SourceLocation EndLoc,
8920  OpenMPDirectiveKind CancelRegion);
8921  /// Called on well-formed '\#pragma omp cancel'.
8922  StmtResult ActOnOpenMPCancelDirective(ArrayRef<OMPClause *> Clauses,
8923  SourceLocation StartLoc,
8924  SourceLocation EndLoc,
8925  OpenMPDirectiveKind CancelRegion);
8926  /// Called on well-formed '\#pragma omp taskloop' after parsing of the
8927  /// associated statement.
8928  StmtResult
8929  ActOnOpenMPTaskLoopDirective(ArrayRef<OMPClause *> Clauses, Stmt *AStmt,
8930  SourceLocation StartLoc, SourceLocation EndLoc,
8931  VarsWithInheritedDSAType &VarsWithImplicitDSA);
8932  /// Called on well-formed '\#pragma omp taskloop simd' after parsing of
8933  /// the associated statement.
8934  StmtResult ActOnOpenMPTaskLoopSimdDirective(
8935  ArrayRef<OMPClause *> Clauses, Stmt *AStmt, SourceLocation StartLoc,
8936  SourceLocation EndLoc, VarsWithInheritedDSAType &VarsWithImplicitDSA);
8937  /// Called on well-formed '\#pragma omp distribute' after parsing
8938  /// of the associated statement.
8939  StmtResult
8940  ActOnOpenMPDistributeDirective(ArrayRef<OMPClause *> Clauses, Stmt *AStmt,
8941  SourceLocation StartLoc, SourceLocation EndLoc,
8942  VarsWithInheritedDSAType &VarsWithImplicitDSA);
8943  /// Called on well-formed '\#pragma omp target update'.
8944  StmtResult ActOnOpenMPTargetUpdateDirective(ArrayRef<OMPClause *> Clauses,
8945  SourceLocation StartLoc,
8946  SourceLocation EndLoc,
8947  Stmt *AStmt);
8948  /// Called on well-formed '\#pragma omp distribute parallel for' after
8949  /// parsing of the associated statement.
8950  StmtResult ActOnOpenMPDistributeParallelForDirective(
8951  ArrayRef<OMPClause *> Clauses, Stmt *AStmt, SourceLocation StartLoc,
8952  SourceLocation EndLoc, VarsWithInheritedDSAType &VarsWithImplicitDSA);
8953  /// Called on well-formed '\#pragma omp distribute parallel for simd'
8954  /// after parsing of the associated statement.
8955  StmtResult ActOnOpenMPDistributeParallelForSimdDirective(
8956  ArrayRef<OMPClause *> Clauses, Stmt *AStmt, SourceLocation StartLoc,
8957  SourceLocation EndLoc, VarsWithInheritedDSAType &VarsWithImplicitDSA);
8958  /// Called on well-formed '\#pragma omp distribute simd' after
8959  /// parsing of the associated statement.
8960  StmtResult ActOnOpenMPDistributeSimdDirective(
8961  ArrayRef<OMPClause *> Clauses, Stmt *AStmt, SourceLocation StartLoc,
8962  SourceLocation EndLoc, VarsWithInheritedDSAType &VarsWithImplicitDSA);
8963  /// Called on well-formed '\#pragma omp target parallel for simd' after
8964  /// parsing of the associated statement.
8965  StmtResult ActOnOpenMPTargetParallelForSimdDirective(
8966  ArrayRef<OMPClause *> Clauses, Stmt *AStmt, SourceLocation StartLoc,
8967  SourceLocation EndLoc, VarsWithInheritedDSAType &VarsWithImplicitDSA);
8968  /// Called on well-formed '\#pragma omp target simd' after parsing of
8969  /// the associated statement.
8970  StmtResult
8971  ActOnOpenMPTargetSimdDirective(ArrayRef<OMPClause *> Clauses, Stmt *AStmt,
8972  SourceLocation StartLoc, SourceLocation EndLoc,
8973  VarsWithInheritedDSAType &VarsWithImplicitDSA);
8974  /// Called on well-formed '\#pragma omp teams distribute' after parsing of
8975  /// the associated statement.
8976  StmtResult ActOnOpenMPTeamsDistributeDirective(
8977  ArrayRef<OMPClause *> Clauses, Stmt *AStmt, SourceLocation StartLoc,
8978  SourceLocation EndLoc, VarsWithInheritedDSAType &VarsWithImplicitDSA);
8979  /// Called on well-formed '\#pragma omp teams distribute simd' after parsing
8980  /// of the associated statement.
8981  StmtResult ActOnOpenMPTeamsDistributeSimdDirective(
8982  ArrayRef<OMPClause *> Clauses, Stmt *AStmt, SourceLocation StartLoc,
8983  SourceLocation EndLoc, VarsWithInheritedDSAType &VarsWithImplicitDSA);
8984  /// Called on well-formed '\#pragma omp teams distribute parallel for simd'
8985  /// after parsing of the associated statement.
8986  StmtResult ActOnOpenMPTeamsDistributeParallelForSimdDirective(
8987  ArrayRef<OMPClause *> Clauses, Stmt *AStmt, SourceLocation StartLoc,
8988  SourceLocation EndLoc, VarsWithInheritedDSAType &VarsWithImplicitDSA);
8989  /// Called on well-formed '\#pragma omp teams distribute parallel for'
8990  /// after parsing of the associated statement.
8991  StmtResult ActOnOpenMPTeamsDistributeParallelForDirective(
8992  ArrayRef<OMPClause *> Clauses, Stmt *AStmt, SourceLocation StartLoc,
8993  SourceLocation EndLoc, VarsWithInheritedDSAType &VarsWithImplicitDSA);
8994  /// Called on well-formed '\#pragma omp target teams' after parsing of the
8995  /// associated statement.
8996  StmtResult ActOnOpenMPTargetTeamsDirective(ArrayRef<OMPClause *> Clauses,
8997  Stmt *AStmt,
8998  SourceLocation StartLoc,
8999  SourceLocation EndLoc);
9000  /// Called on well-formed '\#pragma omp target teams distribute' after parsing
9001  /// of the associated statement.
9002  StmtResult ActOnOpenMPTargetTeamsDistributeDirective(
9003  ArrayRef<OMPClause *> Clauses, Stmt *AStmt, SourceLocation StartLoc,
9004  SourceLocation EndLoc, VarsWithInheritedDSAType &VarsWithImplicitDSA);
9005  /// Called on well-formed '\#pragma omp target teams distribute parallel for'
9006  /// after parsing of the associated statement.
9007  StmtResult ActOnOpenMPTargetTeamsDistributeParallelForDirective(
9008  ArrayRef<OMPClause *> Clauses, Stmt *AStmt, SourceLocation StartLoc,
9009  SourceLocation EndLoc, VarsWithInheritedDSAType &VarsWithImplicitDSA);
9010  /// Called on well-formed '\#pragma omp target teams distribute parallel for
9011  /// simd' after parsing of the associated statement.
9012  StmtResult ActOnOpenMPTargetTeamsDistributeParallelForSimdDirective(
9013  ArrayRef<OMPClause *> Clauses, Stmt *AStmt, SourceLocation StartLoc,
9014  SourceLocation EndLoc, VarsWithInheritedDSAType &VarsWithImplicitDSA);
9015  /// Called on well-formed '\#pragma omp target teams distribute simd' after
9016  /// parsing of the associated statement.
9017  StmtResult ActOnOpenMPTargetTeamsDistributeSimdDirective(
9018  ArrayRef<OMPClause *> Clauses, Stmt *AStmt, SourceLocation StartLoc,
9019  SourceLocation EndLoc, VarsWithInheritedDSAType &VarsWithImplicitDSA);
9020 
9021  /// Checks correctness of linear modifiers.
9022  bool CheckOpenMPLinearModifier(OpenMPLinearClauseKind LinKind,
9023  SourceLocation LinLoc);
9024  /// Checks that the specified declaration matches requirements for the linear
9025  /// decls.
9026  bool CheckOpenMPLinearDecl(const ValueDecl *D, SourceLocation ELoc,
9027  OpenMPLinearClauseKind LinKind, QualType Type);
9028 
9029  /// Called on well-formed '\#pragma omp declare simd' after parsing of
9030  /// the associated method/function.
9031  DeclGroupPtrTy ActOnOpenMPDeclareSimdDirective(
9032  DeclGroupPtrTy DG, OMPDeclareSimdDeclAttr::BranchStateTy BS,
9033  Expr *Simdlen, ArrayRef<Expr *> Uniforms, ArrayRef<Expr *> Aligneds,
9034  ArrayRef<Expr *> Alignments, ArrayRef<Expr *> Linears,
9035  ArrayRef<unsigned> LinModifiers, ArrayRef<Expr *> Steps, SourceRange SR);
9036 
9037  OMPClause *ActOnOpenMPSingleExprClause(OpenMPClauseKind Kind,
9038  Expr *Expr,
9039  SourceLocation StartLoc,
9040  SourceLocation LParenLoc,
9041  SourceLocation EndLoc);
9042  /// Called on well-formed 'if' clause.
9043  OMPClause *ActOnOpenMPIfClause(OpenMPDirectiveKind NameModifier,
9044  Expr *Condition, SourceLocation StartLoc,
9045  SourceLocation LParenLoc,
9046  SourceLocation NameModifierLoc,
9047  SourceLocation ColonLoc,
9048  SourceLocation EndLoc);
9049  /// Called on well-formed 'final' clause.
9050  OMPClause *ActOnOpenMPFinalClause(Expr *Condition, SourceLocation StartLoc,
9051  SourceLocation LParenLoc,
9052  SourceLocation EndLoc);
9053  /// Called on well-formed 'num_threads' clause.
9054  OMPClause *ActOnOpenMPNumThreadsClause(Expr *NumThreads,
9055  SourceLocation StartLoc,
9056  SourceLocation LParenLoc,
9057  SourceLocation EndLoc);
9058  /// Called on well-formed 'safelen' clause.
9059  OMPClause *ActOnOpenMPSafelenClause(Expr *Length,
9060  SourceLocation StartLoc,
9061  SourceLocation LParenLoc,
9062  SourceLocation EndLoc);
9063  /// Called on well-formed 'simdlen' clause.
9064  OMPClause *ActOnOpenMPSimdlenClause(Expr *Length, SourceLocation StartLoc,
9065  SourceLocation LParenLoc,
9066  SourceLocation EndLoc);
9067  /// Called on well-formed 'collapse' clause.
9068  OMPClause *ActOnOpenMPCollapseClause(Expr *NumForLoops,
9069  SourceLocation StartLoc,
9070  SourceLocation LParenLoc,
9071  SourceLocation EndLoc);
9072  /// Called on well-formed 'ordered' clause.
9073  OMPClause *
9074  ActOnOpenMPOrderedClause(SourceLocation StartLoc, SourceLocation EndLoc,
9075  SourceLocation LParenLoc = SourceLocation(),
9076  Expr *NumForLoops = nullptr);
9077  /// Called on well-formed 'grainsize' clause.
9078  OMPClause *ActOnOpenMPGrainsizeClause(Expr *Size, SourceLocation StartLoc,
9079  SourceLocation LParenLoc,
9080  SourceLocation EndLoc);
9081  /// Called on well-formed 'num_tasks' clause.
9082  OMPClause *ActOnOpenMPNumTasksClause(Expr *NumTasks, SourceLocation StartLoc,
9083  SourceLocation LParenLoc,
9084  SourceLocation EndLoc);
9085  /// Called on well-formed 'hint' clause.
9086  OMPClause *ActOnOpenMPHintClause(Expr *Hint, SourceLocation StartLoc,
9087  SourceLocation LParenLoc,
9088  SourceLocation EndLoc);
9089 
9090  OMPClause *ActOnOpenMPSimpleClause(OpenMPClauseKind Kind,
9091  unsigned Argument,
9092  SourceLocation ArgumentLoc,
9093  SourceLocation StartLoc,
9094  SourceLocation LParenLoc,
9095  SourceLocation EndLoc);
9096  /// Called on well-formed 'default' clause.
9097  OMPClause *ActOnOpenMPDefaultClause(OpenMPDefaultClauseKind Kind,
9098  SourceLocation KindLoc,
9099  SourceLocation StartLoc,
9100  SourceLocation LParenLoc,
9101  SourceLocation EndLoc);
9102  /// Called on well-formed 'proc_bind' clause.
9103  OMPClause *ActOnOpenMPProcBindClause(OpenMPProcBindClauseKind Kind,
9104  SourceLocation KindLoc,
9105  SourceLocation StartLoc,
9106  SourceLocation LParenLoc,
9107  SourceLocation EndLoc);
9108 
9109  OMPClause *ActOnOpenMPSingleExprWithArgClause(
9110  OpenMPClauseKind Kind, ArrayRef<unsigned> Arguments, Expr *Expr,
9111  SourceLocation StartLoc, SourceLocation LParenLoc,
9112  ArrayRef<SourceLocation> ArgumentsLoc, SourceLocation DelimLoc,
9113  SourceLocation EndLoc);
9114  /// Called on well-formed 'schedule' clause.
9115  OMPClause *ActOnOpenMPScheduleClause(
9117  OpenMPScheduleClauseKind Kind, Expr *ChunkSize, SourceLocation StartLoc,
9118  SourceLocation LParenLoc, SourceLocation M1Loc, SourceLocation M2Loc,
9119  SourceLocation KindLoc, SourceLocation CommaLoc, SourceLocation EndLoc);
9120 
9121  OMPClause *ActOnOpenMPClause(OpenMPClauseKind Kind, SourceLocation StartLoc,
9122  SourceLocation EndLoc);
9123  /// Called on well-formed 'nowait' clause.
9124  OMPClause *ActOnOpenMPNowaitClause(SourceLocation StartLoc,
9125  SourceLocation EndLoc);
9126  /// Called on well-formed 'untied' clause.
9127  OMPClause *ActOnOpenMPUntiedClause(SourceLocation StartLoc,
9128  SourceLocation EndLoc);
9129  /// Called on well-formed 'mergeable' clause.
9130  OMPClause *ActOnOpenMPMergeableClause(SourceLocation StartLoc,
9131  SourceLocation EndLoc);
9132  /// Called on well-formed 'read' clause.
9133  OMPClause *ActOnOpenMPReadClause(SourceLocation StartLoc,
9134  SourceLocation EndLoc);
9135  /// Called on well-formed 'write' clause.
9136  OMPClause *ActOnOpenMPWriteClause(SourceLocation StartLoc,
9137  SourceLocation EndLoc);
9138  /// Called on well-formed 'update' clause.
9139  OMPClause *ActOnOpenMPUpdateClause(SourceLocation StartLoc,
9140  SourceLocation EndLoc);
9141  /// Called on well-formed 'capture' clause.
9142  OMPClause *ActOnOpenMPCaptureClause(SourceLocation StartLoc,
9143  SourceLocation EndLoc);
9144  /// Called on well-formed 'seq_cst' clause.
9145  OMPClause *ActOnOpenMPSeqCstClause(SourceLocation StartLoc,
9146  SourceLocation EndLoc);
9147  /// Called on well-formed 'threads' clause.
9148  OMPClause *ActOnOpenMPThreadsClause(SourceLocation StartLoc,
9149  SourceLocation EndLoc);
9150  /// Called on well-formed 'simd' clause.
9151  OMPClause *ActOnOpenMPSIMDClause(SourceLocation StartLoc,
9152  SourceLocation EndLoc);
9153  /// Called on well-formed 'nogroup' clause.
9154  OMPClause *ActOnOpenMPNogroupClause(SourceLocation StartLoc,
9155  SourceLocation EndLoc);
9156 
9157  OMPClause *ActOnOpenMPVarListClause(
9158  OpenMPClauseKind Kind, ArrayRef<Expr *> Vars, Expr *TailExpr,
9159  SourceLocation StartLoc, SourceLocation LParenLoc,
9160  SourceLocation ColonLoc, SourceLocation EndLoc,
9161  CXXScopeSpec &ReductionIdScopeSpec,
9162  const DeclarationNameInfo &ReductionId, OpenMPDependClauseKind DepKind,
9163  OpenMPLinearClauseKind LinKind, OpenMPMapClauseKind MapTypeModifier,
9164  OpenMPMapClauseKind MapType, bool IsMapTypeImplicit,
9165  SourceLocation DepLinMapLoc);
9166  /// Called on well-formed 'private' clause.
9167  OMPClause *ActOnOpenMPPrivateClause(ArrayRef<Expr *> VarList,
9168  SourceLocation StartLoc,
9169  SourceLocation LParenLoc,
9170  SourceLocation EndLoc);
9171  /// Called on well-formed 'firstprivate' clause.
9172  OMPClause *ActOnOpenMPFirstprivateClause(ArrayRef<Expr *> VarList,
9173  SourceLocation StartLoc,
9174  SourceLocation LParenLoc,
9175  SourceLocation EndLoc);
9176  /// Called on well-formed 'lastprivate' clause.
9177  OMPClause *ActOnOpenMPLastprivateClause(ArrayRef<Expr *> VarList,
9178  SourceLocation StartLoc,
9179  SourceLocation LParenLoc,
9180  SourceLocation EndLoc);
9181  /// Called on well-formed 'shared' clause.
9182  OMPClause *ActOnOpenMPSharedClause(ArrayRef<Expr *> VarList,
9183  SourceLocation StartLoc,
9184  SourceLocation LParenLoc,
9185  SourceLocation EndLoc);
9186  /// Called on well-formed 'reduction' clause.
9187  OMPClause *ActOnOpenMPReductionClause(
9188  ArrayRef<Expr *> VarList, SourceLocation StartLoc,
9189  SourceLocation LParenLoc, SourceLocation ColonLoc, SourceLocation EndLoc,
9190  CXXScopeSpec &ReductionIdScopeSpec,
9191  const DeclarationNameInfo &ReductionId,
9192  ArrayRef<Expr *> UnresolvedReductions = llvm::None);
9193  /// Called on well-formed 'task_reduction' clause.
9194  OMPClause *ActOnOpenMPTaskReductionClause(
9195  ArrayRef<Expr *> VarList, SourceLocation StartLoc,
9196  SourceLocation LParenLoc, SourceLocation ColonLoc, SourceLocation EndLoc,
9197  CXXScopeSpec &ReductionIdScopeSpec,
9198  const DeclarationNameInfo &ReductionId,
9199  ArrayRef<Expr *> UnresolvedReductions = llvm::None);
9200  /// Called on well-formed 'in_reduction' clause.
9201  OMPClause *ActOnOpenMPInReductionClause(
9202  ArrayRef<Expr *> VarList, SourceLocation StartLoc,
9203  SourceLocation LParenLoc, SourceLocation ColonLoc, SourceLocation EndLoc,
9204  CXXScopeSpec &ReductionIdScopeSpec,
9205  const DeclarationNameInfo &ReductionId,
9206  ArrayRef<Expr *> UnresolvedReductions = llvm::None);
9207  /// Called on well-formed 'linear' clause.
9208  OMPClause *
9209  ActOnOpenMPLinearClause(ArrayRef<Expr *> VarList, Expr *Step,
9210  SourceLocation StartLoc, SourceLocation LParenLoc,
9211  OpenMPLinearClauseKind LinKind, SourceLocation LinLoc,
9212  SourceLocation ColonLoc, SourceLocation EndLoc);
9213  /// Called on well-formed 'aligned' clause.
9214  OMPClause *ActOnOpenMPAlignedClause(ArrayRef<Expr *> VarList,
9215  Expr *Alignment,
9216  SourceLocation StartLoc,
9217  SourceLocation LParenLoc,
9218  SourceLocation ColonLoc,
9219  SourceLocation EndLoc);
9220  /// Called on well-formed 'copyin' clause.
9221  OMPClause *ActOnOpenMPCopyinClause(ArrayRef<Expr *> VarList,
9222  SourceLocation StartLoc,
9223  SourceLocation LParenLoc,
9224  SourceLocation EndLoc);
9225  /// Called on well-formed 'copyprivate' clause.
9226  OMPClause *ActOnOpenMPCopyprivateClause(ArrayRef<Expr *> VarList,
9227  SourceLocation StartLoc,
9228  SourceLocation LParenLoc,
9229  SourceLocation EndLoc);
9230  /// Called on well-formed 'flush' pseudo clause.
9231  OMPClause *ActOnOpenMPFlushClause(ArrayRef<Expr *> VarList,
9232  SourceLocation StartLoc,
9233  SourceLocation LParenLoc,
9234  SourceLocation EndLoc);
9235  /// Called on well-formed 'depend' clause.
9236  OMPClause *
9237  ActOnOpenMPDependClause(OpenMPDependClauseKind DepKind, SourceLocation DepLoc,
9238  SourceLocation ColonLoc, ArrayRef<Expr *> VarList,
9239  SourceLocation StartLoc, SourceLocation LParenLoc,
9240  SourceLocation EndLoc);
9241  /// Called on well-formed 'device' clause.
9242  OMPClause *ActOnOpenMPDeviceClause(Expr *Device, SourceLocation StartLoc,
9243  SourceLocation LParenLoc,
9244  SourceLocation EndLoc);
9245  /// Called on well-formed 'map' clause.
9246  OMPClause *
9247  ActOnOpenMPMapClause(OpenMPMapClauseKind MapTypeModifier,
9248  OpenMPMapClauseKind MapType, bool IsMapTypeImplicit,
9249  SourceLocation MapLoc, SourceLocation ColonLoc,
9250  ArrayRef<Expr *> VarList, SourceLocation StartLoc,
9251  SourceLocation LParenLoc, SourceLocation EndLoc);
9252  /// Called on well-formed 'num_teams' clause.
9253  OMPClause *ActOnOpenMPNumTeamsClause(Expr *NumTeams, SourceLocation StartLoc,
9254  SourceLocation LParenLoc,
9255  SourceLocation EndLoc);
9256  /// Called on well-formed 'thread_limit' clause.
9257  OMPClause *ActOnOpenMPThreadLimitClause(Expr *ThreadLimit,
9258  SourceLocation StartLoc,
9259  SourceLocation LParenLoc,
9260  SourceLocation EndLoc);
9261  /// Called on well-formed 'priority' clause.
9262  OMPClause *ActOnOpenMPPriorityClause(Expr *Priority, SourceLocation StartLoc,
9263  SourceLocation LParenLoc,
9264  SourceLocation EndLoc);
9265  /// Called on well-formed 'dist_schedule' clause.
9266  OMPClause *ActOnOpenMPDistScheduleClause(
9267  OpenMPDistScheduleClauseKind Kind, Expr *ChunkSize,
9268  SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation KindLoc,
9269  SourceLocation CommaLoc, SourceLocation EndLoc);
9270  /// Called on well-formed 'defaultmap' clause.
9271  OMPClause *ActOnOpenMPDefaultmapClause(
9273  SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation MLoc,
9274  SourceLocation KindLoc, SourceLocation EndLoc);
9275  /// Called on well-formed 'to' clause.
9276  OMPClause *ActOnOpenMPToClause(ArrayRef<Expr *> VarList,
9277  SourceLocation StartLoc,
9278  SourceLocation LParenLoc,
9279  SourceLocation EndLoc);
9280  /// Called on well-formed 'from' clause.
9281  OMPClause *ActOnOpenMPFromClause(ArrayRef<Expr *> VarList,
9282  SourceLocation StartLoc,
9283  SourceLocation LParenLoc,
9284  SourceLocation EndLoc);
9285  /// Called on well-formed 'use_device_ptr' clause.
9286  OMPClause *ActOnOpenMPUseDevicePtrClause(ArrayRef<Expr *> VarList,
9287  SourceLocation StartLoc,
9288  SourceLocation LParenLoc,
9289  SourceLocation EndLoc);
9290  /// Called on well-formed 'is_device_ptr' clause.
9291  OMPClause *ActOnOpenMPIsDevicePtrClause(ArrayRef<Expr *> VarList,
9292  SourceLocation StartLoc,
9293  SourceLocation LParenLoc,
9294  SourceLocation EndLoc);
9295 
9296  /// The kind of conversion being performed.
9298  /// An implicit conversion.
9300  /// A C-style cast.
9302  /// A functional-style cast.
9304  /// A cast other than a C-style cast.
9306  /// A conversion for an operand of a builtin overloaded operator.
9307  CCK_ForBuiltinOverloadedOp
9308  };
9309 
9310  static bool isCast(CheckedConversionKind CCK) {
9311  return CCK == CCK_CStyleCast || CCK == CCK_FunctionalCast ||
9312  CCK == CCK_OtherCast;
9313  }
9314 
9315  /// ImpCastExprToType - If Expr is not of type 'Type', insert an implicit
9316  /// cast. If there is already an implicit cast, merge into the existing one.
9317  /// If isLvalue, the result of the cast is an lvalue.
9318  ExprResult ImpCastExprToType(Expr *E, QualType Type, CastKind CK,
9319  ExprValueKind VK = VK_RValue,
9320  const CXXCastPath *BasePath = nullptr,
9322  = CCK_ImplicitConversion);
9323 
9324  /// ScalarTypeToBooleanCastKind - Returns the cast kind corresponding
9325  /// to the conversion from scalar type ScalarTy to the Boolean type.
9326  static CastKind ScalarTypeToBooleanCastKind(QualType ScalarTy);
9327 
9328  /// IgnoredValueConversions - Given that an expression's result is
9329  /// syntactically ignored, perform any conversions that are
9330  /// required.
9331  ExprResult IgnoredValueConversions(Expr *E);
9332 
9333  // UsualUnaryConversions - promotes integers (C99 6.3.1.1p2) and converts
9334  // functions and arrays to their respective pointers (C99 6.3.2.1).
9335  ExprResult UsualUnaryConversions(Expr *E);
9336 
9337  /// CallExprUnaryConversions - a special case of an unary conversion
9338  /// performed on a function designator of a call expression.
9339  ExprResult CallExprUnaryConversions(Expr *E);
9340 
9341  // DefaultFunctionArrayConversion - converts functions and arrays
9342  // to their respective pointers (C99 6.3.2.1).
9343  ExprResult DefaultFunctionArrayConversion(Expr *E, bool Diagnose = true);
9344 
9345  // DefaultFunctionArrayLvalueConversion - converts functions and
9346  // arrays to their respective pointers and performs the
9347  // lvalue-to-rvalue conversion.
9348  ExprResult DefaultFunctionArrayLvalueConversion(Expr *E,
9349  bool Diagnose = true);
9350 
9351  // DefaultLvalueConversion - performs lvalue-to-rvalue conversion on
9352  // the operand. This is DefaultFunctionArrayLvalueConversion,
9353  // except that it assumes the operand isn't of function or array
9354  // type.
9355  ExprResult DefaultLvalueConversion(Expr *E);
9356 
9357  // DefaultArgumentPromotion (C99 6.5.2.2p6). Used for function calls that
9358  // do not have a prototype. Integer promotions are performed on each
9359  // argument, and arguments that have type float are promoted to double.
9360  ExprResult DefaultArgumentPromotion(Expr *E);
9361 
9362  /// If \p E is a prvalue denoting an unmaterialized temporary, materialize
9363  /// it as an xvalue. In C++98, the result will still be a prvalue, because
9364  /// we don't have xvalues there.
9365  ExprResult TemporaryMaterializationConversion(Expr *E);
9366 
9367  // Used for emitting the right warning by DefaultVariadicArgumentPromotion
9373  VariadicDoesNotApply
9374  };
9375 
9376  VariadicCallType getVariadicCallType(FunctionDecl *FDecl,
9377  const FunctionProtoType *Proto,
9378  Expr *Fn);
9379 
9380  // Used for determining in which context a type is allowed to be passed to a
9381  // vararg function.
9382  enum VarArgKind {
9387  VAK_Invalid
9388  };
9389 
9390  // Determines which VarArgKind fits an expression.
9391  VarArgKind isValidVarArgType(const QualType &Ty);
9392 
9393  /// Check to see if the given expression is a valid argument to a variadic
9394  /// function, issuing a diagnostic if not.
9395  void checkVariadicArgument(const Expr *E, VariadicCallType CT);
9396 
9397  /// Check to see if a given expression could have '.c_str()' called on it.
9398  bool hasCStrMethod(const Expr *E);
9399 
9400  /// GatherArgumentsForCall - Collector argument expressions for various
9401  /// form of call prototypes.
9402  bool GatherArgumentsForCall(SourceLocation CallLoc, FunctionDecl *FDecl,
9403  const FunctionProtoType *Proto,
9404  unsigned FirstParam, ArrayRef<Expr *> Args,
9405  SmallVectorImpl<Expr *> &AllArgs,
9406  VariadicCallType CallType = VariadicDoesNotApply,
9407  bool AllowExplicit = false,
9408  bool IsListInitialization = false);
9409 
9410  // DefaultVariadicArgumentPromotion - Like DefaultArgumentPromotion, but
9411  // will create a runtime trap if the resulting type is not a POD type.
9412  ExprResult DefaultVariadicArgumentPromotion(Expr *E, VariadicCallType CT,
9413  FunctionDecl *FDecl);
9414 
9415  // UsualArithmeticConversions - performs the UsualUnaryConversions on it's
9416  // operands and then handles various conversions that are common to binary
9417  // operators (C99 6.3.1.8). If both operands aren't arithmetic, this
9418  // routine returns the first non-arithmetic type found. The client is
9419  // responsible for emitting appropriate error diagnostics.
9420  QualType UsualArithmeticConversions(ExprResult &LHS, ExprResult &RHS,
9421  bool IsCompAssign = false);
9422 
9423  /// AssignConvertType - All of the 'assignment' semantic checks return this
9424  /// enum to indicate whether the assignment was allowed. These checks are
9425  /// done for simple assignments, as well as initialization, return from
9426  /// function, argument passing, etc. The query is phrased in terms of a
9427  /// source and destination type.
9429  /// Compatible - the types are compatible according to the standard.
9431 
9432  /// PointerToInt - The assignment converts a pointer to an int, which we
9433  /// accept as an extension.
9435 
9436  /// IntToPointer - The assignment converts an int to a pointer, which we
9437  /// accept as an extension.
9439 
9440  /// FunctionVoidPointer - The assignment is between a function pointer and
9441  /// void*, which the standard doesn't allow, but we accept as an extension.
9443 
9444  /// IncompatiblePointer - The assignment is between two pointers types that
9445  /// are not compatible, but we accept them as an extension.
9447 
9448  /// IncompatiblePointerSign - The assignment is between two pointers types
9449  /// which point to integers which have a different sign, but are otherwise
9450  /// identical. This is a subset of the above, but broken out because it's by
9451  /// far the most common case of incompatible pointers.
9453 
9454  /// CompatiblePointerDiscardsQualifiers - The assignment discards
9455  /// c/v/r qualifiers, which we accept as an extension.
9457 
9458  /// IncompatiblePointerDiscardsQualifiers - The assignment
9459  /// discards qualifiers that we don't permit to be discarded,
9460  /// like address spaces.
9462 
9463  /// IncompatibleNestedPointerQualifiers - The assignment is between two
9464  /// nested pointer types, and the qualifiers other than the first two
9465  /// levels differ e.g. char ** -> const char **, but we accept them as an
9466  /// extension.
9468 
9469  /// IncompatibleVectors - The assignment is between two vector types that
9470  /// have the same size, which we accept as an extension.
9472 
9473  /// IntToBlockPointer - The assignment converts an int to a block
9474  /// pointer. We disallow this.
9476 
9477  /// IncompatibleBlockPointer - The assignment is between two block
9478  /// pointers types that are not compatible.
9480 
9481  /// IncompatibleObjCQualifiedId - The assignment is between a qualified
9482  /// id type and something else (that is incompatible with it). For example,
9483  /// "id <XXX>" = "Foo *", where "Foo *" doesn't implement the XXX protocol.
9485 
9486  /// IncompatibleObjCWeakRef - Assigning a weak-unavailable object to an
9487  /// object with __weak qualifier.
9489 
9490  /// Incompatible - We reject this conversion outright, it is invalid to
9491  /// represent it in the AST.
9492  Incompatible
9493  };
9494 
9495  /// DiagnoseAssignmentResult - Emit a diagnostic, if required, for the
9496  /// assignment conversion type specified by ConvTy. This returns true if the
9497  /// conversion was invalid or false if the conversion was accepted.
9498  bool DiagnoseAssignmentResult(AssignConvertType ConvTy,
9499  SourceLocation Loc,
9500  QualType DstType, QualType SrcType,
9501  Expr *SrcExpr, AssignmentAction Action,
9502  bool *Complained = nullptr);
9503 
9504  /// IsValueInFlagEnum - Determine if a value is allowed as part of a flag
9505  /// enum. If AllowMask is true, then we also allow the complement of a valid
9506  /// value, to be used as a mask.
9507  bool IsValueInFlagEnum(const EnumDecl *ED, const llvm::APInt &Val,
9508  bool AllowMask) const;
9509 
9510  /// DiagnoseAssignmentEnum - Warn if assignment to enum is a constant
9511  /// integer not in the range of enum values.
9512  void DiagnoseAssignmentEnum(QualType DstType, QualType SrcType,
9513  Expr *SrcExpr);
9514 
9515  /// CheckAssignmentConstraints - Perform type checking for assignment,
9516  /// argument passing, variable initialization, and function return values.
9517  /// C99 6.5.16.
9518  AssignConvertType CheckAssignmentConstraints(SourceLocation Loc,
9519  QualType LHSType,
9520  QualType RHSType);
9521 
9522  /// Check assignment constraints and optionally prepare for a conversion of
9523  /// the RHS to the LHS type. The conversion is prepared for if ConvertRHS
9524  /// is true.
9525  AssignConvertType CheckAssignmentConstraints(QualType LHSType,
9526  ExprResult &RHS,
9527  CastKind &Kind,
9528  bool ConvertRHS = true);
9529 
9530  /// Check assignment constraints for an assignment of RHS to LHSType.
9531  ///
9532  /// \param LHSType The destination type for the assignment.
9533  /// \param RHS The source expression for the assignment.
9534  /// \param Diagnose If \c true, diagnostics may be produced when checking
9535  /// for assignability. If a diagnostic is produced, \p RHS will be
9536  /// set to ExprError(). Note that this function may still return
9537  /// without producing a diagnostic, even for an invalid assignment.
9538  /// \param DiagnoseCFAudited If \c true, the target is a function parameter
9539  /// in an audited Core Foundation API and does not need to be checked
9540  /// for ARC retain issues.
9541  /// \param ConvertRHS If \c true, \p RHS will be updated to model the
9542  /// conversions necessary to perform the assignment. If \c false,
9543  /// \p Diagnose must also be \c false.
9544  AssignConvertType CheckSingleAssignmentConstraints(
9545  QualType LHSType, ExprResult &RHS, bool Diagnose = true,
9546  bool DiagnoseCFAudited = false, bool ConvertRHS = true);
9547 
9548  // If the lhs type is a transparent union, check whether we
9549  // can initialize the transparent union with the given expression.
9550  AssignConvertType CheckTransparentUnionArgumentConstraints(QualType ArgType,
9551  ExprResult &RHS);
9552 
9553  bool IsStringLiteralToNonConstPointerConversion(Expr *From, QualType ToType);
9554 
9555  bool CheckExceptionSpecCompatibility(Expr *From, QualType ToType);
9556 
9557  ExprResult PerformImplicitConversion(Expr *From, QualType ToType,
9558  AssignmentAction Action,
9559  bool AllowExplicit = false);
9560  ExprResult PerformImplicitConversion(Expr *From, QualType ToType,
9561  AssignmentAction Action,
9562  bool AllowExplicit,
9564  ExprResult PerformImplicitConversion(Expr *From, QualType ToType,
9565  const ImplicitConversionSequence& ICS,
9566  AssignmentAction Action,
9568  = CCK_ImplicitConversion);
9569  ExprResult PerformImplicitConversion(Expr *From, QualType ToType,
9570  const StandardConversionSequence& SCS,
9571  AssignmentAction Action,
9572  CheckedConversionKind CCK);
9573 
9574  /// the following "Check" methods will return a valid/converted QualType
9575  /// or a null QualType (indicating an error diagnostic was issued).
9576 
9577  /// type checking binary operators (subroutines of CreateBuiltinBinOp).
9578  QualType InvalidOperands(SourceLocation Loc, ExprResult &LHS,
9579  ExprResult &RHS);
9580  QualType InvalidLogicalVectorOperands(SourceLocation Loc, ExprResult &LHS,
9581  ExprResult &RHS);
9582  QualType CheckPointerToMemberOperands( // C++ 5.5
9583  ExprResult &LHS, ExprResult &RHS, ExprValueKind &VK,
9584  SourceLocation OpLoc, bool isIndirect);
9585  QualType CheckMultiplyDivideOperands( // C99 6.5.5
9586  ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, bool IsCompAssign,
9587  bool IsDivide);
9588  QualType CheckRemainderOperands( // C99 6.5.5
9589  ExprResult &LHS, ExprResult &RHS, SourceLocation Loc,
9590  bool IsCompAssign = false);
9591  QualType CheckAdditionOperands( // C99 6.5.6
9592  ExprResult &LHS, ExprResult &RHS, SourceLocation Loc,
9593  BinaryOperatorKind Opc, QualType* CompLHSTy = nullptr);
9594  QualType CheckSubtractionOperands( // C99 6.5.6
9595  ExprResult &LHS, ExprResult &RHS, SourceLocation Loc,
9596  QualType* CompLHSTy = nullptr);
9597  QualType CheckShiftOperands( // C99 6.5.7
9598  ExprResult &LHS, ExprResult &RHS, SourceLocation Loc,
9599  BinaryOperatorKind Opc, bool IsCompAssign = false);
9600  QualType CheckCompareOperands( // C99 6.5.8/9
9601  ExprResult &LHS, ExprResult &RHS, SourceLocation Loc,
9602  BinaryOperatorKind Opc);
9603  QualType CheckBitwiseOperands( // C99 6.5.[10...12]
9604  ExprResult &LHS, ExprResult &RHS, SourceLocation Loc,
9605  BinaryOperatorKind Opc);
9606  QualType CheckLogicalOperands( // C99 6.5.[13,14]
9607  ExprResult &LHS, ExprResult &RHS, SourceLocation Loc,
9608  BinaryOperatorKind Opc);
9609  // CheckAssignmentOperands is used for both simple and compound assignment.
9610  // For simple assignment, pass both expressions and a null converted type.
9611  // For compound assignment, pass both expressions and the converted type.
9612  QualType CheckAssignmentOperands( // C99 6.5.16.[1,2]
9613  Expr *LHSExpr, ExprResult &RHS, SourceLocation Loc, QualType CompoundType);
9614 
9615  ExprResult checkPseudoObjectIncDec(Scope *S, SourceLocation OpLoc,
9616  UnaryOperatorKind Opcode, Expr *Op);
9617  ExprResult checkPseudoObjectAssignment(Scope *S, SourceLocation OpLoc,
9618  BinaryOperatorKind Opcode,
9619  Expr *LHS, Expr *RHS);
9620  ExprResult checkPseudoObjectRValue(Expr *E);
9621  Expr *recreateSyntacticForm(PseudoObjectExpr *E);
9622 
9623  QualType CheckConditionalOperands( // C99 6.5.15
9624  ExprResult &Cond, ExprResult &LHS, ExprResult &RHS,
9625  ExprValueKind &VK, ExprObjectKind &OK, SourceLocation QuestionLoc);
9626  QualType CXXCheckConditionalOperands( // C++ 5.16
9627  ExprResult &cond, ExprResult &lhs, ExprResult &rhs,
9628  ExprValueKind &VK, ExprObjectKind &OK, SourceLocation questionLoc);
9629  QualType FindCompositePointerType(SourceLocation Loc, Expr *&E1, Expr *&E2,
9630  bool ConvertArgs = true);
9632  ExprResult &E1, ExprResult &E2,
9633  bool ConvertArgs = true) {
9634  Expr *E1Tmp = E1.get(), *E2Tmp = E2.get();
9635  QualType Composite =
9636  FindCompositePointerType(Loc, E1Tmp, E2Tmp, ConvertArgs);
9637  E1 = E1Tmp;
9638  E2 = E2Tmp;
9639  return Composite;
9640  }
9641 
9642  QualType FindCompositeObjCPointerType(ExprResult &LHS, ExprResult &RHS,
9643  SourceLocation QuestionLoc);
9644 
9645  bool DiagnoseConditionalForNull(Expr *LHSExpr, Expr *RHSExpr,
9646  SourceLocation QuestionLoc);
9647 
9648  void DiagnoseAlwaysNonNullPointer(Expr *E,
9650  bool IsEqual, SourceRange Range);
9651 
9652  /// type checking for vector binary operators.
9653  QualType CheckVectorOperands(ExprResult &LHS, ExprResult &RHS,
9654  SourceLocation Loc, bool IsCompAssign,
9655  bool AllowBothBool, bool AllowBoolConversion);
9656  QualType GetSignedVectorType(QualType V);
9657  QualType CheckVectorCompareOperands(ExprResult &LHS, ExprResult &RHS,
9658  SourceLocation Loc,
9659  BinaryOperatorKind Opc);
9660  QualType CheckVectorLogicalOperands(ExprResult &LHS, ExprResult &RHS,
9661  SourceLocation Loc);
9662 
9663  bool areLaxCompatibleVectorTypes(QualType srcType, QualType destType);
9664  bool isLaxVectorConversion(QualType srcType, QualType destType);
9665 
9666  /// type checking declaration initializers (C99 6.7.8)
9667  bool CheckForConstantInitializer(Expr *e, QualType t);
9668 
9669  // type checking C++ declaration initializers (C++ [dcl.init]).
9670 
9671  /// ReferenceCompareResult - Expresses the result of comparing two
9672  /// types (cv1 T1 and cv2 T2) to determine their compatibility for the
9673  /// purposes of initialization by reference (C++ [dcl.init.ref]p4).
9675  /// Ref_Incompatible - The two types are incompatible, so direct
9676  /// reference binding is not possible.
9677  Ref_Incompatible = 0,
9678  /// Ref_Related - The two types are reference-related, which means
9679  /// that their unqualified forms (T1 and T2) are either the same
9680  /// or T1 is a base class of T2.
9682  /// Ref_Compatible - The two types are reference-compatible.
9683  Ref_Compatible
9684  };
9685 
9686  ReferenceCompareResult CompareReferenceRelationship(SourceLocation Loc,
9687  QualType T1, QualType T2,
9688  bool &DerivedToBase,
9689  bool &ObjCConversion,
9690  bool &ObjCLifetimeConversion);
9691 
9692  ExprResult checkUnknownAnyCast(SourceRange TypeRange, QualType CastType,
9693  Expr *CastExpr, CastKind &CastKind,
9694  ExprValueKind &VK, CXXCastPath &Path);
9695 
9696  /// Force an expression with unknown-type to an expression of the
9697  /// given type.
9698  ExprResult forceUnknownAnyToType(Expr *E, QualType ToType);
9699 
9700  /// Type-check an expression that's being passed to an
9701  /// __unknown_anytype parameter.
9702  ExprResult checkUnknownAnyArg(SourceLocation callLoc,
9703  Expr *result, QualType &paramType);
9704 
9705  // CheckVectorCast - check type constraints for vectors.
9706  // Since vectors are an extension, there are no C standard reference for this.
9707  // We allow casting between vectors and integer datatypes of the same size.
9708  // returns true if the cast is invalid
9709  bool CheckVectorCast(SourceRange R, QualType VectorTy, QualType Ty,
9710  CastKind &Kind);
9711 
9712  /// Prepare `SplattedExpr` for a vector splat operation, adding
9713  /// implicit casts if necessary.
9714  ExprResult prepareVectorSplat(QualType VectorTy, Expr *SplattedExpr);
9715 
9716  // CheckExtVectorCast - check type constraints for extended vectors.
9717  // Since vectors are an extension, there are no C standard reference for this.
9718  // We allow casting between vectors and integer datatypes of the same size,
9719  // or vectors and the element type of that vector.
9720  // returns the cast expr
9721  ExprResult CheckExtVectorCast(SourceRange R, QualType DestTy, Expr *CastExpr,
9722  CastKind &Kind);
9723 
9724  ExprResult BuildCXXFunctionalCastExpr(TypeSourceInfo *TInfo, QualType Type,
9725  SourceLocation LParenLoc,
9726  Expr *CastExpr,
9727  SourceLocation RParenLoc);
9728 
9729  enum ARCConversionResult { ACR_okay, ACR_unbridged, ACR_error };
9730 
9731  /// Checks for invalid conversions and casts between
9732  /// retainable pointers and other pointer kinds for ARC and Weak.
9733  ARCConversionResult CheckObjCConversion(SourceRange castRange,
9734  QualType castType, Expr *&op,
9736  bool Diagnose = true,
9737  bool DiagnoseCFAudited = false,
9738  BinaryOperatorKind Opc = BO_PtrMemD
9739  );
9740 
9741  Expr *stripARCUnbridgedCast(Expr *e);
9742  void diagnoseARCUnbridgedCast(Expr *e);
9743 
9744  bool CheckObjCARCUnavailableWeakConversion(QualType castType,
9745  QualType ExprType);
9746 
9747  /// checkRetainCycles - Check whether an Objective-C message send
9748  /// might create an obvious retain cycle.
9749  void checkRetainCycles(ObjCMessageExpr *msg);
9750  void checkRetainCycles(Expr *receiver, Expr *argument);
9751  void checkRetainCycles(VarDecl *Var, Expr *Init);
9752 
9753  /// checkUnsafeAssigns - Check whether +1 expr is being assigned
9754  /// to weak/__unsafe_unretained type.
9755  bool checkUnsafeAssigns(SourceLocation Loc, QualType LHS, Expr *RHS);
9756 
9757  /// checkUnsafeExprAssigns - Check whether +1 expr is being assigned
9758  /// to weak/__unsafe_unretained expression.
9759  void checkUnsafeExprAssigns(SourceLocation Loc, Expr *LHS, Expr *RHS);
9760 
9761  /// CheckMessageArgumentTypes - Check types in an Obj-C message send.
9762  /// \param Method - May be null.
9763  /// \param [out] ReturnType - The return type of the send.
9764  /// \return true iff there were any incompatible types.
9765  bool CheckMessageArgumentTypes(QualType ReceiverType,
9766  MultiExprArg Args, Selector Sel,
9767  ArrayRef<SourceLocation> SelectorLocs,
9768  ObjCMethodDecl *Method, bool isClassMessage,
9769  bool isSuperMessage,
9770  SourceLocation lbrac, SourceLocation rbrac,
9771  SourceRange RecRange,
9772  QualType &ReturnType, ExprValueKind &VK);
9773 
9774  /// Determine the result of a message send expression based on
9775  /// the type of the receiver, the method expected to receive the message,
9776  /// and the form of the message send.
9777  QualType getMessageSendResultType(QualType ReceiverType,
9778  ObjCMethodDecl *Method,
9779  bool isClassMessage, bool isSuperMessage);
9780 
9781  /// If the given expression involves a message send to a method
9782  /// with a related result type, emit a note describing what happened.
9783  void EmitRelatedResultTypeNote(const Expr *E);
9784 
9785  /// Given that we had incompatible pointer types in a return
9786  /// statement, check whether we're in a method with a related result
9787  /// type, and if so, emit a note describing what happened.
9788  void EmitRelatedResultTypeNoteForReturn(QualType destType);
9789 
9791  Decl *ConditionVar;
9792  FullExprArg Condition;
9793  bool Invalid;
9794  bool HasKnownValue;
9795  bool KnownValue;
9796 
9797  friend class Sema;
9798  ConditionResult(Sema &S, Decl *ConditionVar, FullExprArg Condition,
9799  bool IsConstexpr)
9800  : ConditionVar(ConditionVar), Condition(Condition), Invalid(false),
9801  HasKnownValue(IsConstexpr && Condition.get() &&
9802  !Condition.get()->isValueDependent()),
9803  KnownValue(HasKnownValue &&
9804  !!Condition.get()->EvaluateKnownConstInt(S.Context)) {}
9805  explicit ConditionResult(bool Invalid)
9806  : ConditionVar(nullptr), Condition(nullptr), Invalid(Invalid),
9807  HasKnownValue(false), KnownValue(false) {}
9808 
9809  public:
9811  bool isInvalid() const { return Invalid; }
9812  std::pair<VarDecl *, Expr *> get() const {
9813  return std::make_pair(cast_or_null<VarDecl>(ConditionVar),
9814  Condition.get());
9815  }
9817  if (!HasKnownValue)
9818  return None;
9819  return KnownValue;
9820  }
9821  };
9823 
9824  enum class ConditionKind {
9825  Boolean, ///< A boolean condition, from 'if', 'while', 'for', or 'do'.
9826  ConstexprIf, ///< A constant boolean condition from 'if constexpr'.
9827  Switch ///< An integral condition for a 'switch' statement.
9828  };
9829 
9830  ConditionResult ActOnCondition(Scope *S, SourceLocation Loc,
9831  Expr *SubExpr, ConditionKind CK);
9832 
9833  ConditionResult ActOnConditionVariable(Decl *ConditionVar,
9834  SourceLocation StmtLoc,
9835  ConditionKind CK);
9836 
9837  DeclResult ActOnCXXConditionDeclaration(Scope *S, Declarator &D);
9838 
9839  ExprResult CheckConditionVariable(VarDecl *ConditionVar,
9840  SourceLocation StmtLoc,
9841  ConditionKind CK);
9842  ExprResult CheckSwitchCondition(SourceLocation SwitchLoc, Expr *Cond);
9843 
9844  /// CheckBooleanCondition - Diagnose problems involving the use of
9845  /// the given expression as a boolean condition (e.g. in an if
9846  /// statement). Also performs the standard function and array
9847  /// decays, possibly changing the input variable.
9848  ///
9849  /// \param Loc - A location associated with the condition, e.g. the
9850  /// 'if' keyword.
9851  /// \return true iff there were any errors
9852  ExprResult CheckBooleanCondition(SourceLocation Loc, Expr *E,
9853  bool IsConstexpr = false);
9854 
9855  /// DiagnoseAssignmentAsCondition - Given that an expression is
9856  /// being used as a boolean condition, warn if it's an assignment.
9857  void DiagnoseAssignmentAsCondition(Expr *E);
9858 
9859  /// Redundant parentheses over an equality comparison can indicate
9860  /// that the user intended an assignment used as condition.
9861  void DiagnoseEqualityWithExtraParens(ParenExpr *ParenE);
9862 
9863  /// CheckCXXBooleanCondition - Returns true if conversion to bool is invalid.
9864  ExprResult CheckCXXBooleanCondition(Expr *CondExpr, bool IsConstexpr = false);
9865 
9866  /// ConvertIntegerToTypeWarnOnOverflow - Convert the specified APInt to have
9867  /// the specified width and sign. If an overflow occurs, detect it and emit
9868  /// the specified diagnostic.
9869  void ConvertIntegerToTypeWarnOnOverflow(llvm::APSInt &OldVal,
9870  unsigned NewWidth, bool NewSign,
9871  SourceLocation Loc, unsigned DiagID);
9872 
9873  /// Checks that the Objective-C declaration is declared in the global scope.
9874  /// Emits an error and marks the declaration as invalid if it's not declared
9875  /// in the global scope.
9876  bool CheckObjCDeclScope(Decl *D);
9877 
9878  /// Abstract base class used for diagnosing integer constant
9879  /// expression violations.
9881  public:
9882  bool Suppress;
9883 
9884  VerifyICEDiagnoser(bool Suppress = false) : Suppress(Suppress) { }
9885 
9886  virtual void diagnoseNotICE(Sema &S, SourceLocation Loc, SourceRange SR) =0;
9887  virtual void diagnoseFold(Sema &S, SourceLocation Loc, SourceRange SR);
9888  virtual ~VerifyICEDiagnoser() { }
9889  };
9890 
9891  /// VerifyIntegerConstantExpression - Verifies that an expression is an ICE,
9892  /// and reports the appropriate diagnostics. Returns false on success.
9893  /// Can optionally return the value of the expression.
9894  ExprResult VerifyIntegerConstantExpression(Expr *E, llvm::APSInt *Result,
9895  VerifyICEDiagnoser &Diagnoser,
9896  bool AllowFold = true);
9897  ExprResult VerifyIntegerConstantExpression(Expr *E, llvm::APSInt *Result,
9898  unsigned DiagID,
9899  bool AllowFold = true);
9900  ExprResult VerifyIntegerConstantExpression(Expr *E,
9901  llvm::APSInt *Result = nullptr);
9902 
9903  /// VerifyBitField - verifies that a bit field expression is an ICE and has
9904  /// the correct width, and that the field type is valid.
9905  /// Returns false on success.
9906  /// Can optionally return whether the bit-field is of width 0
9907  ExprResult VerifyBitField(SourceLocation FieldLoc, IdentifierInfo *FieldName,
9908  QualType FieldTy, bool IsMsStruct,
9909  Expr *BitWidth, bool *ZeroWidth = nullptr);
9910 
9911 private:
9912  unsigned ForceCUDAHostDeviceDepth = 0;
9913 
9914 public:
9915  /// Increments our count of the number of times we've seen a pragma forcing
9916  /// functions to be __host__ __device__. So long as this count is greater
9917  /// than zero, all functions encountered will be __host__ __device__.
9918  void PushForceCUDAHostDevice();
9919 
9920  /// Decrements our count of the number of times we've seen a pragma forcing
9921  /// functions to be __host__ __device__. Returns false if the count is 0
9922  /// before incrementing, so you can emit an error.
9923  bool PopForceCUDAHostDevice();
9924 
9925  /// Diagnostics that are emitted only if we discover that the given function
9926  /// must be codegen'ed. Because handling these correctly adds overhead to
9927  /// compilation, this is currently only enabled for CUDA compilations.
9928  llvm::DenseMap<CanonicalDeclPtr<FunctionDecl>,
9929  std::vector<PartialDiagnosticAt>>
9931 
9932  /// A pair of a canonical FunctionDecl and a SourceLocation. When used as the
9933  /// key in a hashtable, both the FD and location are hashed.
9937  };
9938 
9939  /// FunctionDecls and SourceLocations for which CheckCUDACall has emitted a
9940  /// (maybe deferred) "bad call" diagnostic. We use this to avoid emitting the
9941  /// same deferred diag twice.
9943 
9944  /// An inverse call graph, mapping known-emitted functions to one of their
9945  /// known-emitted callers (plus the location of the call).
9946  ///
9947  /// Functions that we can tell a priori must be emitted aren't added to this
9948  /// map.
9949  llvm::DenseMap</* Callee = */ CanonicalDeclPtr<FunctionDecl>,
9950  /* Caller = */ FunctionDeclAndLoc>
9952 
9953  /// A partial call graph maintained during CUDA compilation to support
9954  /// deferred diagnostics.
9955  ///
9956  /// Functions are only added here if, at the time they're considered, they are
9957  /// not known-emitted. As soon as we discover that a function is
9958  /// known-emitted, we remove it and everything it transitively calls from this
9959  /// set and add those functions to CUDAKnownEmittedFns.
9960  llvm::DenseMap</* Caller = */ CanonicalDeclPtr<FunctionDecl>,
9961  /* Callees = */ llvm::MapVector<CanonicalDeclPtr<FunctionDecl>,
9962  SourceLocation>>
9964 
9965  /// Diagnostic builder for CUDA errors which may or may not be deferred.
9966  ///
9967  /// In CUDA, there exist constructs (e.g. variable-length arrays, try/catch)
9968  /// which are not allowed to appear inside __device__ functions and are
9969  /// allowed to appear in __host__ __device__ functions only if the host+device
9970  /// function is never codegen'ed.
9971  ///
9972  /// To handle this, we use the notion of "deferred diagnostics", where we
9973  /// attach a diagnostic to a FunctionDecl that's emitted iff it's codegen'ed.
9974  ///
9975  /// This class lets you emit either a regular diagnostic, a deferred
9976  /// diagnostic, or no diagnostic at all, according to an argument you pass to
9977  /// its constructor, thus simplifying the process of creating these "maybe
9978  /// deferred" diagnostics.
9980  public:
9981  enum Kind {
9982  /// Emit no diagnostics.
9984  /// Emit the diagnostic immediately (i.e., behave like Sema::Diag()).
9986  /// Emit the diagnostic immediately, and, if it's a warning or error, also
9987  /// emit a call stack showing how this function can be reached by an a
9988  /// priori known-emitted function.
9990  /// Create a deferred diagnostic, which is emitted only if the function
9991  /// it's attached to is codegen'ed. Also emit a call stack as with
9992  /// K_ImmediateWithCallStack.
9993  K_Deferred
9994  };
9995 
9996  CUDADiagBuilder(Kind K, SourceLocation Loc, unsigned DiagID,
9997  FunctionDecl *Fn, Sema &S);
9998  ~CUDADiagBuilder();
9999 
10000  /// Convertible to bool: True if we immediately emitted an error, false if
10001  /// we didn't emit an error or we created a deferred error.
10002  ///
10003  /// Example usage:
10004  ///
10005  /// if (CUDADiagBuilder(...) << foo << bar)
10006  /// return ExprError();
10007  ///
10008  /// But see CUDADiagIfDeviceCode() and CUDADiagIfHostCode() -- you probably
10009  /// want to use these instead of creating a CUDADiagBuilder yourself.
10010  operator bool() const { return ImmediateDiag.hasValue(); }
10011 
10012  template <typename T>
10013  friend const CUDADiagBuilder &operator<<(const CUDADiagBuilder &Diag,
10014  const T &Value) {
10015  if (Diag.ImmediateDiag.hasValue())
10016  *Diag.ImmediateDiag << Value;
10017  else if (Diag.PartialDiag.hasValue())
10018  *Diag.PartialDiag << Value;
10019  return Diag;
10020  }
10021 
10022  private:
10023  Sema &S;
10024  SourceLocation Loc;
10025  unsigned DiagID;
10026  FunctionDecl *Fn;
10027  bool ShowCallStack;
10028 
10029  // Invariant: At most one of these Optionals has a value.
10030  // FIXME: Switch these to a Variant once that exists.
10033  };
10034 
10035  /// Creates a CUDADiagBuilder that emits the diagnostic if the current context
10036  /// is "used as device code".
10037  ///
10038  /// - If CurContext is a __host__ function, does not emit any diagnostics.
10039  /// - If CurContext is a __device__ or __global__ function, emits the
10040  /// diagnostics immediately.
10041  /// - If CurContext is a __host__ __device__ function and we are compiling for
10042  /// the device, creates a diagnostic which is emitted if and when we realize
10043  /// that the function will be codegen'ed.
10044  ///
10045  /// Example usage:
10046  ///
10047  /// // Variable-length arrays are not allowed in CUDA device code.
10048  /// if (CUDADiagIfDeviceCode(Loc, diag::err_cuda_vla) << CurrentCUDATarget())
10049  /// return ExprError();
10050  /// // Otherwise, continue parsing as normal.
10051  CUDADiagBuilder CUDADiagIfDeviceCode(SourceLocation Loc, unsigned DiagID);
10052 
10053  /// Creates a CUDADiagBuilder that emits the diagnostic if the current context
10054  /// is "used as host code".
10055  ///
10056  /// Same as CUDADiagIfDeviceCode, with "host" and "device" switched.
10057  CUDADiagBuilder CUDADiagIfHostCode(SourceLocation Loc, unsigned DiagID);
10058 
10064  CFT_InvalidTarget
10065  };
10066 
10067  /// Determines whether the given function is a CUDA device/host/kernel/etc.
10068  /// function.
10069  ///
10070  /// Use this rather than examining the function's attributes yourself -- you
10071  /// will get it wrong. Returns CFT_Host if D is null.
10072  CUDAFunctionTarget IdentifyCUDATarget(const FunctionDecl *D,
10073  bool IgnoreImplicitHDAttr = false);
10074  CUDAFunctionTarget IdentifyCUDATarget(const ParsedAttributesView &Attrs);
10075 
10076  /// Gets the CUDA target for the current context.
10078  return IdentifyCUDATarget(dyn_cast<FunctionDecl>(CurContext));
10079  }
10080 
10081  // CUDA function call preference. Must be ordered numerically from
10082  // worst to best.
10084  CFP_Never, // Invalid caller/callee combination.
10085  CFP_WrongSide, // Calls from host-device to host or device
10086  // function that do not match current compilation
10087  // mode.
10088  CFP_HostDevice, // Any calls to host/device functions.
10089  CFP_SameSide, // Calls from host-device to host or device
10090  // function matching current compilation mode.
10091  CFP_Native, // host-to-host or device-to-device calls.
10092  };
10093 
10094  /// Identifies relative preference of a given Caller/Callee
10095  /// combination, based on their host/device attributes.
10096  /// \param Caller function which needs address of \p Callee.
10097  /// nullptr in case of global context.
10098  /// \param Callee target function
10099  ///
10100  /// \returns preference value for particular Caller/Callee combination.
10101  CUDAFunctionPreference IdentifyCUDAPreference(const FunctionDecl *Caller,
10102  const FunctionDecl *Callee);
10103 
10104  /// Determines whether Caller may invoke Callee, based on their CUDA
10105  /// host/device attributes. Returns false if the call is not allowed.
10106  ///
10107  /// Note: Will return true for CFP_WrongSide calls. These may appear in
10108  /// semantically correct CUDA programs, but only if they're never codegen'ed.
10109  bool IsAllowedCUDACall(const FunctionDecl *Caller,
10110  const FunctionDecl *Callee) {
10111  return IdentifyCUDAPreference(Caller, Callee) != CFP_Never;
10112  }
10113 
10114  /// May add implicit CUDAHostAttr and CUDADeviceAttr attributes to FD,
10115  /// depending on FD and the current compilation settings.
10116  void maybeAddCUDAHostDeviceAttrs(FunctionDecl *FD,
10117  const LookupResult &Previous);
10118 
10119 public:
10120  /// Check whether we're allowed to call Callee from the current context.
10121  ///
10122  /// - If the call is never allowed in a semantically-correct program
10123  /// (CFP_Never), emits an error and returns false.
10124  ///
10125  /// - If the call is allowed in semantically-correct programs, but only if
10126  /// it's never codegen'ed (CFP_WrongSide), creates a deferred diagnostic to
10127  /// be emitted if and when the caller is codegen'ed, and returns true.
10128  ///
10129  /// Will only create deferred diagnostics for a given SourceLocation once,
10130  /// so you can safely call this multiple times without generating duplicate
10131  /// deferred errors.
10132  ///
10133  /// - Otherwise, returns true without emitting any diagnostics.
10134  bool CheckCUDACall(SourceLocation Loc, FunctionDecl *Callee);
10135 
10136  /// Set __device__ or __host__ __device__ attributes on the given lambda
10137  /// operator() method.
10138  ///
10139  /// CUDA lambdas declared inside __device__ or __global__ functions inherit
10140  /// the __device__ attribute. Similarly, lambdas inside __host__ __device__
10141  /// functions become __host__ __device__ themselves.
10142  void CUDASetLambdaAttrs(CXXMethodDecl *Method);
10143 
10144  /// Finds a function in \p Matches with highest calling priority
10145  /// from \p Caller context and erases all functions with lower
10146  /// calling priority.
10147  void EraseUnwantedCUDAMatches(
10148  const FunctionDecl *Caller,
10149  SmallVectorImpl<std::pair<DeclAccessPair, FunctionDecl *>> &Matches);
10150 
10151  /// Given a implicit special member, infer its CUDA target from the
10152  /// calls it needs to make to underlying base/field special members.
10153  /// \param ClassDecl the class for which the member is being created.
10154  /// \param CSM the kind of special member.
10155  /// \param MemberDecl the special member itself.
10156  /// \param ConstRHS true if this is a copy operation with a const object on
10157  /// its RHS.
10158  /// \param Diagnose true if this call should emit diagnostics.
10159  /// \return true if there was an error inferring.
10160  /// The result of this call is implicit CUDA target attribute(s) attached to
10161  /// the member declaration.
10162  bool inferCUDATargetForImplicitSpecialMember(CXXRecordDecl *ClassDecl,
10163  CXXSpecialMember CSM,
10164  CXXMethodDecl *MemberDecl,
10165  bool ConstRHS,
10166  bool Diagnose);
10167 
10168  /// \return true if \p CD can be considered empty according to CUDA
10169  /// (E.2.3.1 in CUDA 7.5 Programming guide).
10170  bool isEmptyCudaConstructor(SourceLocation Loc, CXXConstructorDecl *CD);
10171  bool isEmptyCudaDestructor(SourceLocation Loc, CXXDestructorDecl *CD);
10172 
10173  // \brief Checks that initializers of \p Var satisfy CUDA restrictions. In
10174  // case of error emits appropriate diagnostic and invalidates \p Var.
10175  //
10176  // \details CUDA allows only empty constructors as initializers for global
10177  // variables (see E.2.3.1, CUDA 7.5). The same restriction also applies to all
10178  // __shared__ variables whether they are local or not (they all are implicitly
10179  // static in CUDA). One exception is that CUDA allows constant initializers
10180  // for __constant__ and __device__ variables.
10181  void checkAllowedCUDAInitializer(VarDecl *VD);
10182 
10183  /// Check whether NewFD is a valid overload for CUDA. Emits
10184  /// diagnostics and invalidates NewFD if not.
10185  void checkCUDATargetOverload(FunctionDecl *NewFD,
10186  const LookupResult &Previous);
10187  /// Copies target attributes from the template TD to the function FD.
10188  void inheritCUDATargetAttrs(FunctionDecl *FD, const FunctionTemplateDecl &TD);
10189 
10190  /// \name Code completion
10191  //@{
10192  /// Describes the context in which code completion occurs.
10194  /// Code completion occurs at top-level or namespace context.
10196  /// Code completion occurs within a class, struct, or union.
10198  /// Code completion occurs within an Objective-C interface, protocol,
10199  /// or category.
10201  /// Code completion occurs within an Objective-C implementation or
10202  /// category implementation
10204  /// Code completion occurs within the list of instance variables
10205  /// in an Objective-C interface, protocol, category, or implementation.
10207  /// Code completion occurs following one or more template
10208  /// headers.
10210  /// Code completion occurs following one or more template
10211  /// headers within a class.
10213  /// Code completion occurs within an expression.
10215  /// Code completion occurs within a statement, which may
10216  /// also be an expression or a declaration.
10218  /// Code completion occurs at the beginning of the
10219  /// initialization statement (or expression) in a for loop.
10221  /// Code completion occurs within the condition of an if,
10222  /// while, switch, or for statement.
10224  /// Code completion occurs within the body of a function on a
10225  /// recovery path, where we do not have a specific handle on our position
10226  /// in the grammar.
10228  /// Code completion occurs where only a type is permitted.
10230  /// Code completion occurs in a parenthesized expression, which
10231  /// might also be a type cast.
10233  /// Code completion occurs within a sequence of declaration
10234  /// specifiers within a function, method, or block.
10235  PCC_LocalDeclarationSpecifiers
10236  };
10237 
10238  void CodeCompleteModuleImport(SourceLocation ImportLoc, ModuleIdPath Path);
10239  void CodeCompleteOrdinaryName(Scope *S,
10240  ParserCompletionContext CompletionContext);
10241  void CodeCompleteDeclSpec(Scope *S, DeclSpec &DS,
10242  bool AllowNonIdentifiers,
10243  bool AllowNestedNameSpecifiers);
10244 
10246  void CodeCompleteExpression(Scope *S,
10247  const CodeCompleteExpressionData &Data);
10248  void CodeCompleteMemberReferenceExpr(Scope *S, Expr *Base, Expr *OtherOpBase,
10249  SourceLocation OpLoc, bool IsArrow,
10250  bool IsBaseExprStatement);
10251  void CodeCompletePostfixExpression(Scope *S, ExprResult LHS);
10252  void CodeCompleteTag(Scope *S, unsigned TagSpec);
10253  void CodeCompleteTypeQualifiers(DeclSpec &DS);
10254  void CodeCompleteFunctionQualifiers(DeclSpec &DS, Declarator &D,
10255  const VirtSpecifiers *VS = nullptr);
10256  void CodeCompleteBracketDeclarator(Scope *S);
10257  void CodeCompleteCase(Scope *S);
10258  void CodeCompleteCall(Scope *S, Expr *Fn, ArrayRef<Expr *> Args);
10259  void CodeCompleteConstructor(Scope *S, QualType Type, SourceLocation Loc,
10260  ArrayRef<Expr *> Args);
10261  void CodeCompleteInitializer(Scope *S, Decl *D);
10262  void CodeCompleteReturn(Scope *S);
10263  void CodeCompleteAfterIf(Scope *S);
10264  void CodeCompleteAssignmentRHS(Scope *S, Expr *LHS);
10265 
10266  void CodeCompleteQualifiedId(Scope *S, CXXScopeSpec &SS,
10267  bool EnteringContext);
10268  void CodeCompleteUsing(Scope *S);
10269  void CodeCompleteUsingDirective(Scope *S);
10270  void CodeCompleteNamespaceDecl(Scope *S);
10271  void CodeCompleteNamespaceAliasDecl(Scope *S);
10272  void CodeCompleteOperatorName(Scope *S);
10273  void CodeCompleteConstructorInitializer(
10274  Decl *Constructor,
10275  ArrayRef<CXXCtorInitializer *> Initializers);
10276 
10277  void CodeCompleteLambdaIntroducer(Scope *S, LambdaIntroducer &Intro,
10278  bool AfterAmpersand);
10279 
10280  void CodeCompleteObjCAtDirective(Scope *S);
10281  void CodeCompleteObjCAtVisibility(Scope *S);
10282  void CodeCompleteObjCAtStatement(Scope *S);
10283  void CodeCompleteObjCAtExpression(Scope *S);
10284  void CodeCompleteObjCPropertyFlags(Scope *S, ObjCDeclSpec &ODS);
10285  void CodeCompleteObjCPropertyGetter(Scope *S);
10286  void CodeCompleteObjCPropertySetter(Scope *S);
10287  void CodeCompleteObjCPassingType(Scope *S, ObjCDeclSpec &DS,
10288  bool IsParameter);
10289  void CodeCompleteObjCMessageReceiver(Scope *S);
10290  void CodeCompleteObjCSuperMessage(Scope *S, SourceLocation SuperLoc,
10291  ArrayRef<IdentifierInfo *> SelIdents,
10292  bool AtArgumentExpression);
10293  void CodeCompleteObjCClassMessage(Scope *S, ParsedType Receiver,
10294  ArrayRef<IdentifierInfo *> SelIdents,
10295  bool AtArgumentExpression,
10296  bool IsSuper = false);
10297  void CodeCompleteObjCInstanceMessage(Scope *S, Expr *Receiver,
10298  ArrayRef<IdentifierInfo *> SelIdents,
10299  bool AtArgumentExpression,
10300  ObjCInterfaceDecl *Super = nullptr);
10301  void CodeCompleteObjCForCollection(Scope *S,
10302  DeclGroupPtrTy IterationVar);
10303  void CodeCompleteObjCSelector(Scope *S,
10304  ArrayRef<IdentifierInfo *> SelIdents);
10305  void CodeCompleteObjCProtocolReferences(
10306  ArrayRef<IdentifierLocPair> Protocols);
10307  void CodeCompleteObjCProtocolDecl(Scope *S);
10308  void CodeCompleteObjCInterfaceDecl(Scope *S);
10309  void CodeCompleteObjCSuperclass(Scope *S,
10310  IdentifierInfo *ClassName,
10311  SourceLocation ClassNameLoc);
10312  void CodeCompleteObjCImplementationDecl(Scope *S);
10313  void CodeCompleteObjCInterfaceCategory(Scope *S,
10314  IdentifierInfo *ClassName,
10315  SourceLocation ClassNameLoc);
10316  void CodeCompleteObjCImplementationCategory(Scope *S,
10317  IdentifierInfo *ClassName,
10318  SourceLocation ClassNameLoc);
10319  void CodeCompleteObjCPropertyDefinition(Scope *S);
10320  void CodeCompleteObjCPropertySynthesizeIvar(Scope *S,
10321  IdentifierInfo *PropertyName);
10322  void CodeCompleteObjCMethodDecl(Scope *S, Optional<bool> IsInstanceMethod,
10323  ParsedType ReturnType);
10324  void CodeCompleteObjCMethodDeclSelector(Scope *S,
10325  bool IsInstanceMethod,
10326  bool AtParameterName,
10327  ParsedType ReturnType,
10328  ArrayRef<IdentifierInfo *> SelIdents);
10329  void CodeCompleteObjCClassPropertyRefExpr(Scope *S, IdentifierInfo &ClassName,
10330  SourceLocation ClassNameLoc,
10331  bool IsBaseExprStatement);
10332  void CodeCompletePreprocessorDirective(bool InConditional);
10333  void CodeCompleteInPreprocessorConditionalExclusion(Scope *S);
10334  void CodeCompletePreprocessorMacroName(bool IsDefinition);
10335  void CodeCompletePreprocessorExpression();
10336  void CodeCompletePreprocessorMacroArgument(Scope *S,
10337  IdentifierInfo *Macro,
10339  unsigned Argument);
10340  void CodeCompleteNaturalLanguage();
10341  void CodeCompleteAvailabilityPlatformName();
10342  void GatherGlobalCodeCompletions(CodeCompletionAllocator &Allocator,
10343  CodeCompletionTUInfo &CCTUInfo,
10345  //@}
10346 
10347  //===--------------------------------------------------------------------===//
10348  // Extra semantic analysis beyond the C type system
10349 
10350 public:
10351  SourceLocation getLocationOfStringLiteralByte(const StringLiteral *SL,
10352  unsigned ByteNo) const;
10353 
10354 private:
10355  void CheckArrayAccess(const Expr *BaseExpr, const Expr *IndexExpr,
10356  const ArraySubscriptExpr *ASE=nullptr,
10357  bool AllowOnePastEnd=true, bool IndexNegated=false);
10358  void CheckArrayAccess(const Expr *E);
10359  // Used to grab the relevant information from a FormatAttr and a
10360  // FunctionDeclaration.
10361  struct FormatStringInfo {
10362  unsigned FormatIdx;
10363  unsigned FirstDataArg;
10364  bool HasVAListArg;
10365  };
10366 
10367  static bool getFormatStringInfo(const FormatAttr *Format, bool IsCXXMember,
10368  FormatStringInfo *FSI);
10369  bool CheckFunctionCall(FunctionDecl *FDecl, CallExpr *TheCall,
10370  const FunctionProtoType *Proto);
10371  bool CheckObjCMethodCall(ObjCMethodDecl *Method, SourceLocation loc,
10372  ArrayRef<const Expr *> Args);
10373  bool CheckPointerCall(NamedDecl *NDecl, CallExpr *TheCall,
10374  const FunctionProtoType *Proto);
10375  bool CheckOtherCall(CallExpr *TheCall, const FunctionProtoType *Proto);
10376  void CheckConstructorCall(FunctionDecl *FDecl,
10378  const FunctionProtoType *Proto,
10379  SourceLocation Loc);
10380 
10381  void checkCall(NamedDecl *FDecl, const FunctionProtoType *Proto,
10382  const Expr *ThisArg, ArrayRef<const Expr *> Args,
10383  bool IsMemberFunction, SourceLocation Loc, SourceRange Range,
10384  VariadicCallType CallType);
10385 
10386  bool CheckObjCString(Expr *Arg);
10387  ExprResult CheckOSLogFormatStringArg(Expr *Arg);
10388 
10389  ExprResult CheckBuiltinFunctionCall(FunctionDecl *FDecl,
10390  unsigned BuiltinID, CallExpr *TheCall);
10391 
10392  bool CheckARMBuiltinExclusiveCall(unsigned BuiltinID, CallExpr *TheCall,
10393  unsigned MaxWidth);
10394  bool CheckNeonBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall);
10395  bool CheckARMBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall);
10396 
10397  bool CheckAArch64BuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall);
10398  bool CheckHexagonBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall);
10399  bool CheckHexagonBuiltinCpu(unsigned BuiltinID, CallExpr *TheCall);
10400  bool CheckHexagonBuiltinArgument(unsigned BuiltinID, CallExpr *TheCall);
10401  bool CheckMipsBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall);
10402  bool CheckSystemZBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall);
10403  bool CheckX86BuiltinRoundingOrSAE(unsigned BuiltinID, CallExpr *TheCall);
10404  bool CheckX86BuiltinGatherScatterScale(unsigned BuiltinID, CallExpr *TheCall);
10405  bool CheckX86BuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall);
10406  bool CheckPPCBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall);
10407 
10408  bool SemaBuiltinVAStart(unsigned BuiltinID, CallExpr *TheCall);
10409  bool SemaBuiltinVAStartARMMicrosoft(CallExpr *Call);
10410  bool SemaBuiltinUnorderedCompare(CallExpr *TheCall);
10411  bool SemaBuiltinFPClassification(CallExpr *TheCall, unsigned NumArgs);
10412  bool SemaBuiltinVSX(CallExpr *TheCall);
10413  bool SemaBuiltinOSLogFormat(CallExpr *TheCall);
10414 
10415 public:
10416  // Used by C++ template instantiation.
10417  ExprResult SemaBuiltinShuffleVector(CallExpr *TheCall);
10418  ExprResult SemaConvertVectorExpr(Expr *E, TypeSourceInfo *TInfo,
10419  SourceLocation BuiltinLoc,
10420  SourceLocation RParenLoc);
10421 
10422 private:
10423  bool SemaBuiltinPrefetch(CallExpr *TheCall);
10424  bool SemaBuiltinAllocaWithAlign(CallExpr *TheCall);
10425  bool SemaBuiltinAssume(CallExpr *TheCall);
10426  bool SemaBuiltinAssumeAligned(CallExpr *TheCall);
10427  bool SemaBuiltinLongjmp(CallExpr *TheCall);
10428  bool SemaBuiltinSetjmp(CallExpr *TheCall);
10429  ExprResult SemaBuiltinAtomicOverloaded(ExprResult TheCallResult);
10430  ExprResult SemaBuiltinNontemporalOverloaded(ExprResult TheCallResult);
10431  ExprResult SemaAtomicOpsOverloaded(ExprResult TheCallResult,
10433  ExprResult SemaBuiltinOperatorNewDeleteOverloaded(ExprResult TheCallResult,
10434  bool IsDelete);
10435  bool SemaBuiltinConstantArg(CallExpr *TheCall, int ArgNum,
10436  llvm::APSInt &Result);
10437  bool SemaBuiltinConstantArgRange(CallExpr *TheCall, int ArgNum, int Low,
10438  int High, bool RangeIsError = true);
10439  bool SemaBuiltinConstantArgMultiple(CallExpr *TheCall, int ArgNum,
10440  unsigned Multiple);
10441  bool SemaBuiltinARMSpecialReg(unsigned BuiltinID, CallExpr *TheCall,
10442  int ArgNum, unsigned ExpectedFieldNum,
10443  bool AllowName);
10444 public:
10455  FST_Unknown
10456  };
10457  static FormatStringType GetFormatStringType(const FormatAttr *Format);
10458 
10459  bool FormatStringHasSArg(const StringLiteral *FExpr);
10460 
10461  static bool GetFormatNSStringIdx(const FormatAttr *Format, unsigned &Idx);
10462 
10463 private:
10464  bool CheckFormatArguments(const FormatAttr *Format,
10466  bool IsCXXMember,
10467  VariadicCallType CallType,
10468  SourceLocation Loc, SourceRange Range,
10469  llvm::SmallBitVector &CheckedVarArgs);
10470  bool CheckFormatArguments(ArrayRef<const Expr *> Args,
10471  bool HasVAListArg, unsigned format_idx,
10472  unsigned firstDataArg, FormatStringType Type,
10473  VariadicCallType CallType,
10474  SourceLocation Loc, SourceRange range,
10475  llvm::SmallBitVector &CheckedVarArgs);
10476 
10477  void CheckAbsoluteValueFunction(const CallExpr *Call,
10478  const FunctionDecl *FDecl);
10479 
10480  void CheckMaxUnsignedZero(const CallExpr *Call, const FunctionDecl *FDecl);
10481 
10482  void CheckMemaccessArguments(const CallExpr *Call,
10483  unsigned BId,
10484  IdentifierInfo *FnName);
10485 
10486  void CheckStrlcpycatArguments(const CallExpr *Call,
10487  IdentifierInfo *FnName);
10488 
10489  void CheckStrncatArguments(const CallExpr *Call,
10490  IdentifierInfo *FnName);
10491 
10492  void CheckReturnValExpr(Expr *RetValExp, QualType lhsType,
10493  SourceLocation ReturnLoc,
10494  bool isObjCMethod = false,
10495  const AttrVec *Attrs = nullptr,
10496  const FunctionDecl *FD = nullptr);
10497 
10498 public:
10499  void CheckFloatComparison(SourceLocation Loc, Expr *LHS, Expr *RHS);
10500 
10501 private:
10502  void CheckImplicitConversions(Expr *E, SourceLocation CC = SourceLocation());
10503  void CheckBoolLikeConversion(Expr *E, SourceLocation CC);
10504  void CheckForIntOverflow(Expr *E);
10505  void CheckUnsequencedOperations(Expr *E);
10506 
10507  /// Perform semantic checks on a completed expression. This will either
10508  /// be a full-expression or a default argument expression.
10509  void CheckCompletedExpr(Expr *E, SourceLocation CheckLoc = SourceLocation(),
10510  bool IsConstexpr = false);
10511 
10512  void CheckBitFieldInitialization(SourceLocation InitLoc, FieldDecl *Field,
10513  Expr *Init);
10514 
10515  /// Check if there is a field shadowing.
10516  void CheckShadowInheritedFields(const SourceLocation &Loc,
10517  DeclarationName FieldName,
10518  const CXXRecordDecl *RD);
10519 
10520  /// Check if the given expression contains 'break' or 'continue'
10521  /// statement that produces control flow different from GCC.
10522  void CheckBreakContinueBinding(Expr *E);
10523 
10524  /// Check whether receiver is mutable ObjC container which
10525  /// attempts to add itself into the container
10526  void CheckObjCCircularContainer(ObjCMessageExpr *Message);
10527 
10528  void AnalyzeDeleteExprMismatch(const CXXDeleteExpr *DE);
10529  void AnalyzeDeleteExprMismatch(FieldDecl *Field, SourceLocation DeleteLoc,
10530  bool DeleteWasArrayForm);
10531 public:
10532  /// Register a magic integral constant to be used as a type tag.
10533  void RegisterTypeTagForDatatype(const IdentifierInfo *ArgumentKind,
10534  uint64_t MagicValue, QualType Type,
10535  bool LayoutCompatible, bool MustBeNull);
10536 
10537  struct TypeTagData {
10539 
10540  TypeTagData(QualType Type, bool LayoutCompatible, bool MustBeNull) :
10541  Type(Type), LayoutCompatible(LayoutCompatible),
10542  MustBeNull(MustBeNull)
10543  {}
10544 
10546 
10547  /// If true, \c Type should be compared with other expression's types for
10548  /// layout-compatibility.
10549  unsigned LayoutCompatible : 1;
10550  unsigned MustBeNull : 1;
10551  };
10552 
10553  /// A pair of ArgumentKind identifier and magic value. This uniquely
10554  /// identifies the magic value.
10555  typedef std::pair<const IdentifierInfo *, uint64_t> TypeTagMagicValue;
10556 
10557 private:
10558  /// A map from magic value to type information.
10559  std::unique_ptr<llvm::DenseMap<TypeTagMagicValue, TypeTagData>>
10560  TypeTagForDatatypeMagicValues;
10561 
10562  /// Peform checks on a call of a function with argument_with_type_tag
10563  /// or pointer_with_type_tag attributes.
10564  void CheckArgumentWithTypeTag(const ArgumentWithTypeTagAttr *Attr,
10565  const ArrayRef<const Expr *> ExprArgs,
10566  SourceLocation CallSiteLoc);
10567 
10568  /// Check if we are taking the address of a packed field
10569  /// as this may be a problem if the pointer value is dereferenced.
10570  void CheckAddressOfPackedMember(Expr *rhs);
10571 
10572  /// The parser's current scope.
10573  ///
10574  /// The parser maintains this state here.
10575  Scope *CurScope;
10576 
10577  mutable IdentifierInfo *Ident_super;
10578  mutable IdentifierInfo *Ident___float128;
10579 
10580  /// Nullability type specifiers.
10581  IdentifierInfo *Ident__Nonnull = nullptr;
10582  IdentifierInfo *Ident__Nullable = nullptr;
10583  IdentifierInfo *Ident__Null_unspecified = nullptr;
10584 
10585  IdentifierInfo *Ident_NSError = nullptr;
10586 
10587  /// The handler for the FileChanged preprocessor events.
10588  ///
10589  /// Used for diagnostics that implement custom semantic analysis for #include
10590  /// directives, like -Wpragma-pack.
10591  sema::SemaPPCallbacks *SemaPPCallbackHandler;
10592 
10593 protected:
10594  friend class Parser;
10596  friend class ASTReader;
10597  friend class ASTDeclReader;
10598  friend class ASTWriter;
10599 
10600 public:
10601  /// Retrieve the keyword associated
10602  IdentifierInfo *getNullabilityKeyword(NullabilityKind nullability);
10603 
10604  /// The struct behind the CFErrorRef pointer.
10605  RecordDecl *CFError = nullptr;
10606 
10607  /// Retrieve the identifier "NSError".
10608  IdentifierInfo *getNSErrorIdent();
10609 
10610  /// Retrieve the parser's current scope.
10611  ///
10612  /// This routine must only be used when it is certain that semantic analysis
10613  /// and the parser are in precisely the same context, which is not the case
10614  /// when, e.g., we are performing any kind of template instantiation.
10615  /// Therefore, the only safe places to use this scope are in the parser
10616  /// itself and in routines directly invoked from the parser and *never* from
10617  /// template substitution or instantiation.
10618  Scope *getCurScope() const { return CurScope; }
10619 
10621  return CurScope->incrementMSManglingNumber();
10622  }
10623 
10624  IdentifierInfo *getSuperIdentifier() const;
10625  IdentifierInfo *getFloat128Identifier() const;
10626 
10627  Decl *getObjCDeclContext() const;
10628 
10630  return OriginalLexicalContext ? OriginalLexicalContext : CurContext;
10631  }
10632 
10634  const DeclContext *DC = getCurLexicalContext();
10635  // A category implicitly has the attribute of the interface.
10636  if (const ObjCCategoryDecl *CatD = dyn_cast<ObjCCategoryDecl>(DC))
10637  DC = CatD->getClassInterface();
10638  return DC;
10639  }
10640 
10641  /// To be used for checking whether the arguments being passed to
10642  /// function exceeds the number of parameters expected for it.
10643  static bool TooManyArguments(size_t NumParams, size_t NumArgs,
10644  bool PartialOverloading = false) {
10645  // We check whether we're just after a comma in code-completion.
10646  if (NumArgs > 0 && PartialOverloading)
10647  return NumArgs + 1 > NumParams; // If so, we view as an extra argument.
10648  return NumArgs > NumParams;
10649  }
10650 
10651  // Emitting members of dllexported classes is delayed until the class
10652  // (including field initializers) is fully parsed.
10654 
10655 private:
10656  class SavePendingParsedClassStateRAII {
10657  public:
10658  SavePendingParsedClassStateRAII(Sema &S) : S(S) { swapSavedState(); }
10659 
10660  ~SavePendingParsedClassStateRAII() {
10661  assert(S.DelayedExceptionSpecChecks.empty() &&
10662  "there shouldn't be any pending delayed exception spec checks");
10663  assert(S.DelayedDefaultedMemberExceptionSpecs.empty() &&
10664  "there shouldn't be any pending delayed defaulted member "
10665  "exception specs");
10666  assert(S.DelayedDllExportClasses.empty() &&
10667  "there shouldn't be any pending delayed DLL export classes");
10668  swapSavedState();
10669  }
10670 
10671  private:
10672  Sema &S;
10673  decltype(DelayedExceptionSpecChecks) SavedExceptionSpecChecks;
10674  decltype(DelayedDefaultedMemberExceptionSpecs)
10675  SavedDefaultedMemberExceptionSpecs;
10676  decltype(DelayedDllExportClasses) SavedDllExportClasses;
10677 
10678  void swapSavedState() {
10679  SavedExceptionSpecChecks.swap(S.DelayedExceptionSpecChecks);
10680  SavedDefaultedMemberExceptionSpecs.swap(
10682  SavedDllExportClasses.swap(S.DelayedDllExportClasses);
10683  }
10684  };
10685 
10686  /// Helper class that collects misaligned member designations and
10687  /// their location info for delayed diagnostics.
10688  struct MisalignedMember {
10689  Expr *E;
10690  RecordDecl *RD;
10691  ValueDecl *MD;
10692  CharUnits Alignment;
10693 
10694  MisalignedMember() : E(), RD(), MD(), Alignment() {}
10695  MisalignedMember(Expr *E, RecordDecl *RD, ValueDecl *MD,
10696  CharUnits Alignment)
10697  : E(E), RD(RD), MD(MD), Alignment(Alignment) {}
10698  explicit MisalignedMember(Expr *E)
10699  : MisalignedMember(E, nullptr, nullptr, CharUnits()) {}
10700 
10701  bool operator==(const MisalignedMember &m) { return this->E == m.E; }
10702  };
10703  /// Small set of gathered accesses to potentially misaligned members
10704  /// due to the packed attribute.
10705  SmallVector<MisalignedMember, 4> MisalignedMembers;
10706 
10707  /// Adds an expression to the set of gathered misaligned members.
10708  void AddPotentialMisalignedMembers(Expr *E, RecordDecl *RD, ValueDecl *MD,
10709  CharUnits Alignment);
10710 
10711 public:
10712  /// Diagnoses the current set of gathered accesses. This typically
10713  /// happens at full expression level. The set is cleared after emitting the
10714  /// diagnostics.
10715  void DiagnoseMisalignedMembers();
10716 
10717  /// This function checks if the expression is in the sef of potentially
10718  /// misaligned members and it is converted to some pointer type T with lower
10719  /// or equal alignment requirements. If so it removes it. This is used when
10720  /// we do not want to diagnose such misaligned access (e.g. in conversions to
10721  /// void*).
10722  void DiscardMisalignedMemberAddress(const Type *T, Expr *E);
10723 
10724  /// This function calls Action when it determines that E designates a
10725  /// misaligned member due to the packed attribute. This is used to emit
10726  /// local diagnostics like in reference binding.
10727  void RefersToMemberWithReducedAlignment(
10728  Expr *E,
10729  llvm::function_ref<void(Expr *, RecordDecl *, FieldDecl *, CharUnits)>
10730  Action);
10731 };
10732 
10733 /// RAII object that enters a new expression evaluation context.
10735  Sema &Actions;
10736  bool Entered = true;
10737 
10738 public:
10740  Sema &Actions, Sema::ExpressionEvaluationContext NewContext,
10741  Decl *LambdaContextDecl = nullptr,
10743  Sema::ExpressionEvaluationContextRecord::EK_Other,
10744  bool ShouldEnter = true)
10745  : Actions(Actions), Entered(ShouldEnter) {
10746  if (Entered)
10747  Actions.PushExpressionEvaluationContext(NewContext, LambdaContextDecl,
10748  ExprContext);
10749  }
10751  Sema &Actions, Sema::ExpressionEvaluationContext NewContext,
10754  Sema::ExpressionEvaluationContextRecord::EK_Other)
10755  : Actions(Actions) {
10757  NewContext, Sema::ReuseLambdaContextDecl, ExprContext);
10758  }
10759 
10760  enum InitListTag { InitList };
10762  bool ShouldEnter = true)
10763  : Actions(Actions), Entered(false) {
10764  // In C++11 onwards, narrowing checks are performed on the contents of
10765  // braced-init-lists, even when they occur within unevaluated operands.
10766  // Therefore we still need to instantiate constexpr functions used in such
10767  // a context.
10768  if (ShouldEnter && Actions.isUnevaluatedContext() &&
10769  Actions.getLangOpts().CPlusPlus11) {
10771  Sema::ExpressionEvaluationContext::UnevaluatedList);
10772  Entered = true;
10773  }
10774  }
10775 
10777  if (Entered)
10779  }
10780 };
10781 
10785 
10786 /// Contains a late templated function.
10787 /// Will be parsed at the end of the translation unit, used by Sema & Parser.
10790  /// The template function declaration to be late parsed.
10791  Decl *D;
10792 };
10793 
10794 } // end namespace clang
10795 
10796 namespace llvm {
10797 // Hash a FunctionDeclAndLoc by looking at both its FunctionDecl and its
10798 // SourceLocation.
10799 template <> struct DenseMapInfo<clang::Sema::FunctionDeclAndLoc> {
10802 
10804  return {FDBaseInfo::getEmptyKey(), clang::SourceLocation()};
10805  }
10806 
10808  return {FDBaseInfo::getTombstoneKey(), clang::SourceLocation()};
10809  }
10810 
10811  static unsigned getHashValue(const FunctionDeclAndLoc &FDL) {
10812  return hash_combine(FDBaseInfo::getHashValue(FDL.FD),
10813  FDL.Loc.getRawEncoding());
10814  }
10815 
10816  static bool isEqual(const FunctionDeclAndLoc &LHS,
10817  const FunctionDeclAndLoc &RHS) {
10818  return LHS.FD == RHS.FD && LHS.Loc == RHS.Loc;
10819  }
10820 };
10821 } // namespace llvm
10822 
10823 #endif
FileNullabilityMap NullabilityMap
A mapping that describes the nullability we&#39;ve seen in each header file.
Definition: Sema.h:484
Abstract class used to diagnose incomplete types.
Definition: Sema.h:1484
VariadicCallType
Definition: Sema.h:9368
ObjCInterfaceDecl * NSStringDecl
The declaration of the Objective-C NSString class.
Definition: Sema.h:856
PragmaStack< StringLiteral * > CodeSegStack
Definition: Sema.h:468
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:597
We are defining a synthesized function (such as a defaulted special member).
Definition: Sema.h:7180
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:3067
Represents a function declaration or definition.
Definition: Decl.h:1716
bool RequireCompleteExprType(Expr *E, unsigned DiagID, const Ts &...Args)
Definition: Sema.h:1636
llvm::SmallSetVector< const TypedefNameDecl *, 4 > UnusedLocalTypedefNameCandidates
Set containing all typedefs that are likely unused.
Definition: Sema.h:559
A set of visible modules.
Definition: Module.h:589
UnexpandedParameterPackContext
The context in which an unexpanded parameter pack is being diagnosed.
Definition: Sema.h:6555
std::pair< llvm::PointerUnion< const TemplateTypeParmType *, NamedDecl * >, SourceLocation > UnexpandedParameterPack
Definition: Sema.h:226
SourceLocation getOptimizeOffPragmaLocation() const
Get the location for the currently active "\#pragma clang optimize off". If this location is invalid...
Definition: Sema.h:8486
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:547
NestedNameSpecInfo(IdentifierInfo *II, SourceLocation IdLoc, SourceLocation ColonColonLoc, ParsedType ObjectType=ParsedType())
Creates info object for the most typical case.
Definition: Sema.h:5380
ExternalSemaSource * getExternalSource() const
Definition: Sema.h:1214
SuppressedDiagnosticsMap SuppressedDiagnostics
Definition: Sema.h:7339
CXXMethodDecl * getMethod() const
Definition: Sema.h:1052
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:14150
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...
llvm::DenseMap< CanonicalDeclPtr< FunctionDecl >, llvm::MapVector< CanonicalDeclPtr< FunctionDecl >, SourceLocation > > CUDACallGraph
A partial call graph maintained during CUDA compilation to support deferred diagnostics.
Definition: Sema.h:9963
PointerToInt - The assignment converts a pointer to an int, which we accept as an extension...
Definition: Sema.h:9434
Stores the type being destroyed by a pseudo-destructor expression.
Definition: ExprCXX.h:2224
A (possibly-)qualified type.
Definition: Type.h:655
ASTConsumer & Consumer
Definition: Sema.h:320
Keeps information about an identifier in a nested-name-spec.
Definition: Sema.h:5365
GlobalEagerInstantiationScope(Sema &S, bool Enabled)
Definition: Sema.h:7615
Simple class containing the result of Sema::CorrectTypo.
TemplateDeductionResult
Describes the result of template argument deduction.
Definition: Sema.h:6905
LateTemplateParserCB * LateTemplateParser
Definition: Sema.h:631
SmallVectorImpl< Decl * > & WeakTopLevelDecls()
WeakTopLevelDeclDecls - access to #pragma weak-generated Decls.
Definition: Sema.h:1365
Instantiation or recovery rebuild of a for-range statement.
Definition: Sema.h:3785
NameClassification(const IdentifierInfo *Keyword)
Definition: Sema.h:1737
llvm::PointerUnion3< TemplateTypeParmDecl *, NonTypeTemplateParmDecl *, TemplateTemplateParmDecl * > TemplateParameter
Stores a template parameter of any kind.
Definition: DeclTemplate.h:62
void SentinelAction(PragmaMsStackAction Action, StringRef Label)
Definition: Sema.h:424
ASTConsumer - This is an abstract interface that should be implemented by clients that read ASTs...
Definition: ASTConsumer.h:34
Defines enumerations for the type traits support.
A cast other than a C-style cast.
Definition: Sema.h:9305
LateParsedTemplateMapT LateParsedTemplateMap
Definition: Sema.h:626
SmallVector< PackIncludeState, 8 > PackIncludeStack
Definition: Sema.h:463
A stack-allocated class that identifies which local variable declaration instantiations are present i...
Definition: Template.h:228
llvm::MutableArrayRef< ImplicitConversionSequence > ConversionSequenceList
A list of implicit conversion sequences for the arguments of an OverloadCandidate.
Definition: Overload.h:727
FormatStringType
Definition: Sema.h:10445
CorrectTypoKind
Definition: Sema.h:3232
static bool getPrintable(bool B)
Definition: Sema.h:1493
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:10197
__SIZE_TYPE__ size_t
The unsigned integer type of the result of the sizeof operator.
Definition: opencl-c.h:60
RecordDecl * MSVCGuidDecl
The MSVC "_GUID" struct, which is defined in MSVC header files.
Definition: Sema.h:835
std::vector< std::unique_ptr< TemplateInstantiationCallback > > TemplateInstCallbacks
The template instantiation callbacks to trace or track instantiations (objects can be chained)...
Definition: Sema.h:7301
OpenCL supported extensions and optional core features.
Definition: OpenCLOptions.h:23
PragmaStack< StringLiteral * > DataSegStack
Definition: Sema.h:465
Represents a lazily-loaded vector of data.
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:575
A class which encapsulates the logic for delaying diagnostics during parsing and other processing...
Definition: Sema.h:654
OpenMPDefaultmapClauseKind
OpenMP attributes for &#39;defaultmap&#39; clause.
Definition: OpenMPKinds.h:107
DominatorTree GraphTraits specialization so the DominatorTree can be iterable by generic graph iterat...
Definition: Dominators.h:30
Emit the diagnostic immediately (i.e., behave like Sema::Diag()).
Definition: Sema.h:9985
A structure used to record information about a failed template argument deduction, for diagnosis.
static ConditionResult ConditionError()
Definition: Sema.h:9822
Checking non-dependent argument conversions failed.
Definition: Sema.h:6950
An initializer.
Definition: Sema.h:6590
TypePropertyCache< Private > Cache
Definition: Type.cpp:3510
ObjCMessageKind
Describes the kind of message expression indicated by a message send that starts with an identifier...
Definition: Sema.h:8182
Look up the name of an Objective-C protocol.
Definition: Sema.h:3050
Decl * Entity
The entity that is being synthesized.
Definition: Sema.h:7196
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:5089
OpenCLOptions OpenCLFeatures
Definition: Sema.h:314
Stmt - This represents one statement.
Definition: Stmt.h:66
NullabilityKind
Describes the nullability of a particular type.
Definition: Specifiers.h:285
We are matching the template parameter lists of two templates that might be redeclarations.
Definition: Sema.h:6447
FunctionType - C99 6.7.5.3 - Function Declarators.
Definition: Type.h:3211
FullExprArg MakeFullExpr(Expr *Arg)
Definition: Sema.h:3674
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:2411
Microsoft __if_not_exists.
Definition: Sema.h:6608
An instance of this object exists for each enum constant that is defined.
Definition: Decl.h:2741
LazyVector< CXXConstructorDecl *, ExternalSemaSource, &ExternalSemaSource::ReadDelegatingConstructors, 2, 2 > DelegatingCtorDeclsType
Definition: Sema.h:601
bool hasValue() const
Definition: Sema.h:434
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:2974
ObjCSubscriptKind
Definition: Sema.h:2687
llvm::StringRef StackSlotLabel
Definition: Sema.h:395
SmallVector< Scope *, 2 > CurrentSEHFinally
Stack of active SEH __finally scopes. Can be empty.
Definition: Sema.h:348
void setCurrentOpenCLExtension(llvm::StringRef Ext)
Definition: Sema.h:8575
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:6977
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID)
Emit a diagnostic.
Definition: Sema.h:1281
Decl - This represents one declaration (or definition), e.g.
Definition: DeclBase.h:86
Captures information about "declaration specifiers" specific to Objective-C.
Definition: DeclSpec.h:777
LambdaCaptureDefault
The default, if any, capture method for a lambda expression.
Definition: Lambda.h:23
std::deque< PendingImplicitInstantiation > PendingInstantiations
The queue of implicit template instantiations that are required but have not yet been performed...
Definition: Sema.h:7607
AssignConvertType
AssignConvertType - All of the &#39;assignment&#39; semantic checks return this enum to indicate whether the ...
Definition: Sema.h:9428
A reference to a name which we were able to look up during parsing but could not resolve to a specifi...
Definition: ExprCXX.h:2824
Microsoft __if_exists.
Definition: Sema.h:6605
PragmaOptionsAlignKind
Definition: Sema.h:8312
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:806
Represents a C++11 auto or C++14 decltype(auto) type.
Definition: Type.h:4562
DeclContext * OriginalLexicalContext
Generally null except when we temporarily switch decl contexts, like in.
Definition: Sema.h:335
friend const CUDADiagBuilder & operator<<(const CUDADiagBuilder &Diag, const T &Value)
Definition: Sema.h:10013
ParenExpr - This represents a parethesized expression, e.g.
Definition: Expr.h:1751
SmallVector< CodeSynthesisContext, 16 > CodeSynthesisContexts
List of active code synthesis contexts.
Definition: Sema.h:7244
The size of a bit-field.
Definition: Sema.h:6569
SmallVector< Module *, 16 > CodeSynthesisContextLookupModules
Extra modules inspected when performing a lookup during a template instantiation. ...
Definition: Sema.h:7255
The base class of the type hierarchy.
Definition: Type.h:1428
std::deque< PendingImplicitInstantiation > PendingLocalImplicitInstantiations
The queue of implicit template instantiations that are required and must be performed within the curr...
Definition: Sema.h:7658
void AddFactoryMethodToGlobalPool(ObjCMethodDecl *Method, bool impl=false)
AddFactoryMethodToGlobalPool - Same as above, but for factory methods.
Definition: Sema.h:3611
llvm::MapVector< const FunctionDecl *, std::unique_ptr< LateParsedTemplate > > LateParsedTemplateMapT
Definition: Sema.h:625
MissingImportKind
Kinds of missing import.
Definition: Sema.h:2103
DiagnosticBuilder Report(SourceLocation Loc, unsigned DiagID)
Issue the message to the client.
Definition: Diagnostic.h:1294
Declaration of a variable template.
ForRangeStatus
Definition: Sema.h:2915
TemplateParamListContext
The context in which we are checking a template parameter list.
Definition: Sema.h:6192
Represent a C++ namespace.
Definition: Decl.h:514
Template argument deduction produced inconsistent deduced values for the given template parameter...
Definition: Sema.h:6921
RedeclarationKind
Specifies whether (or how) name lookup is being performed for a redeclaration (vs.
Definition: Sema.h:3061
AccessSpecifier
A C++ access specifier (public, private, protected), plus the special value "none" which means differ...
Definition: Specifiers.h:98
LazyVector< const DeclaratorDecl *, ExternalSemaSource, &ExternalSemaSource::ReadUnusedFileScopedDecls, 2, 2 > UnusedFileScopedDeclsType
Definition: Sema.h:593
A container of type source information.
Definition: Decl.h:86
static const IdentifierInfo * getPrintable(const IdentifierInfo *II)
Definition: Sema.h:1497
Wrapper for void* pointer.
Definition: Ownership.h:51
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:3032
std::pair< ValueDecl *, SourceLocation > PendingImplicitInstantiation
An entity for which implicit template instantiation is required.
Definition: Sema.h:7603
bool hasVisibleDeclaration(const NamedDecl *D, llvm::SmallVectorImpl< Module *> *Modules=nullptr)
Determine whether any declaration of an entity is visible.
Definition: Sema.h:1568
Floating point control options.
Definition: LangOptions.h:263
We are instantiating a default argument for a template parameter.
Definition: Sema.h:7144
DelayedDiagnosticsState pushUndelayed()
Enter a new scope where access and deprecation diagnostics are not delayed.
Definition: Sema.h:691
Abstract base class used for diagnosing integer constant expression violations.
Definition: Sema.h:9880
FileNullability Nullability
Definition: Sema.h:255
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:3086
Represents a C++ constructor within a class.
Definition: DeclCXX.h:2477
Represents a prvalue temporary that is written into memory so that a reference can bind to it...
Definition: ExprCXX.h:4150
OpenMPDefaultmapClauseModifier
OpenMP modifiers for &#39;defaultmap&#39; clause.
Definition: OpenMPKinds.h:115
SpecialMemberOverloadResultEntry(const llvm::FoldingSetNodeID &ID)
Definition: Sema.h:1063
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:7285
NameClassificationKind getKind() const
Definition: Sema.h:1769
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:9884
EnterExpressionEvaluationContext(Sema &Actions, Sema::ExpressionEvaluationContext NewContext, Sema::ReuseLambdaContextDecl_t, Sema::ExpressionEvaluationContextRecord::ExpressionKind ExprContext=Sema::ExpressionEvaluationContextRecord::EK_Other)
Definition: Sema.h:10750
RAII object to handle the state changes required to synthesize a function body.
Definition: Sema.h:740
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:3036
Consumes visible declarations found when searching for all visible names within a given scope or cont...
Definition: Lookup.h:749
bool DisableTypoCorrection
Tracks whether we are in a context where typo correction is disabled.
Definition: Sema.h:7578
Retains information about a function, method, or block that is currently being parsed.
Definition: ScopeInfo.h:96
FriendDecl - Represents the declaration of a friend entity, which can be a function, a type, or a templated function or type.
Definition: DeclFriend.h:54
RAII object that enters a new expression evaluation context.
Definition: Sema.h:10734
Represents a variable declaration or definition.
Definition: Decl.h:814
IfExistsResult
Describes the result of an "if-exists" condition check.
Definition: Sema.h:4492
ExpressionKind
Describes whether we are in an expression constext which we have to handle differently.
Definition: Sema.h:988
CleanupInfo Cleanup
Used to control the generation of ExprWithCleanups.
Definition: Sema.h:519
Information about one declarator, including the parsed type information and the identifier.
Definition: DeclSpec.h:1752
DiagnosticsEngine & Diags
Definition: Sema.h:321
llvm::SmallSetVector< DeclContext *, 16 > AssociatedNamespaceSet
Definition: Sema.h:2714
const internal::VariadicDynCastAllOfMatcher< Stmt, Expr > expr
Matches expressions.
PrintingPolicy getPrintingPolicy() const
Retrieve a suitable printing policy for diagnostics.
Definition: Sema.h:2136
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:1162
Records and restores the FP_CONTRACT state on entry/exit of compound statements.
Definition: Sema.h:1182
Extra information about a function prototype.
Definition: Type.h:3551
ExpressionEvaluationContextRecord(ExpressionEvaluationContext Context, unsigned NumCleanupObjects, CleanupInfo ParentCleanup, Decl *ManglingContextDecl, ExpressionKind ExprContext)
Definition: Sema.h:992
TypeSpecifierType
Specifies the kind of type.
Definition: Specifiers.h:45
CUDAFunctionPreference
Definition: Sema.h:10083
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:139
SmallVector< CXXRecordDecl *, 4 > DelayedDllExportClasses
Definition: Sema.h:10653
void diagnose(Sema &S, SourceLocation Loc, QualType T) override
Definition: Sema.h:1525
RAII object used to temporarily allow the C++ &#39;this&#39; expression to be used, with the given qualifiers...
Definition: Sema.h:5093
llvm::MapVector< NamedDecl *, SourceLocation > UndefinedButUsed
UndefinedInternals - all the used, undefined objects which require a definition in this translation u...
Definition: Sema.h:1108
The lookup found a single &#39;cooked&#39; literal operator, which expects a normal literal to be built and p...
Definition: Sema.h:3093
PragmaClangSection PragmaClangBSSSection
Definition: Sema.h:377
BoundTypeDiagnoser(unsigned DiagID, const Ts &...Args)
Definition: Sema.h:1520
Stores a list of template parameters for a TemplateDecl and its derived classes.
Definition: DeclTemplate.h:68
Describes how types, statements, expressions, and declarations should be printed. ...
Definition: PrettyPrinter.h:38
A context in which code is being synthesized (where a source location alone is not sufficient to iden...
Definition: Sema.h:7132
Code completion occurs within an Objective-C implementation or category implementation.
Definition: Sema.h:10203
ObjCMethodDecl * ValueWithBytesObjCTypeMethod
The declaration of the valueWithBytes:objCType: method.
Definition: Sema.h:865
llvm::MapVector< Selector, SourceLocation > ReferencedSelectors
Method selectors used in a @selector expression.
Definition: Sema.h:1137
bool IsDecltype
Whether we are in a decltype expression.
Definition: Sema.h:950
NestedNameSpecInfo(IdentifierInfo *II, SourceLocation IdLoc, SourceLocation ColonColonLoc, QualType ObjectType)
Definition: Sema.h:5386
static NameClassification NestedNameSpecifier()
Definition: Sema.h:1747
SourceLocation PragmaLocation
Definition: Sema.h:397
Look up an ordinary name that is going to be redeclared as a name with linkage.
Definition: Sema.h:3045
FunctionProtoType::ExceptionSpecInfo getExceptionSpec() const
Overwrite an EPI&#39;s exception specification with this computed exception specification.
Definition: Sema.h:4773
Represents a parameter to a function.
Definition: Decl.h:1535
OpenCLOptions & getOpenCLOptions()
Definition: Sema.h:1205
Defines the clang::Expr interface and subclasses for C++ expressions.
ObjCInterfaceDecl * NSDictionaryDecl
The declaration of the Objective-C NSDictionary class.
Definition: Sema.h:874
FPOptions & getFPOptions()
Definition: Sema.h:1206
const TemplateArgument * TemplateArgs
The list of template arguments we are substituting, if they are not part of the entity.
Definition: Sema.h:7205
The collection of all-type qualifiers we support.
Definition: Type.h:154
MethodMatchStrategy
Definition: Sema.h:3521
Information about a template-id annotation token.
static SourceRange getPrintable(TypeLoc TL)
Definition: Sema.h:1505
void setMethod(CXXMethodDecl *MD)
Definition: Sema.h:1053
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:3570
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:1272
ContextualImplicitConverter(bool Suppress=false, bool SuppressConversion=false)
Definition: Sema.h:2616
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:838
LocalInstantiationScope * CurrentInstantiationScope
The current instantiation scope used to store local variables.
Definition: Sema.h:7574
The lookup found a single &#39;raw&#39; literal operator, which expects a string literal containing the spell...
Definition: Sema.h:3096
IntToPointer - The assignment converts an int to a pointer, which we accept as an extension...
Definition: Sema.h:9438
CompoundScopeRAII(Sema &S, bool IsStmtExpr=false)
Definition: Sema.h:3701
Step
Definition: OpenMPClause.h:146
IncompatibleObjCWeakRef - Assigning a weak-unavailable object to an object with __weak qualifier...
Definition: Sema.h:9488
Enumerator value with fixed underlying type.
Definition: Sema.h:2599
Value of a non-type template parameter.
Definition: Sema.h:2600
Represents a class type in Objective C.
Definition: Type.h:5355
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition: ASTContext.h:150
A C++ nested-name-specifier augmented with source location information.
bool inTemplateInstantiation() const
Determine whether we are currently performing template instantiation.
Definition: Sema.h:7478
The results of name lookup within a DeclContext.
Definition: DeclBase.h:1190
A C-style cast.
Definition: Sema.h:9301
FileNullability & operator[](FileID file)
Definition: Sema.h:259
OpenMPLinearClauseKind
OpenMP attributes for &#39;linear&#39; clause.
Definition: OpenMPKinds.h:84
Represents a member of a struct/union/class.
Definition: Decl.h:2534
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:7589
threadSafety::BeforeSet * ThreadSafetyDeclCache
Definition: Sema.h:7593
ObjCInterfaceDecl * NSValueDecl
The declaration of the Objective-C NSValue class.
Definition: Sema.h:844
UnaryExprOrTypeTrait
Names for the "expression or type" traits.
Definition: TypeTraits.h:97
NamedDecl * Template
The template (or partial specialization) in which we are performing the instantiation, for substitutions of prior template arguments.
Definition: Sema.h:7201
Code completion occurs following one or more template headers within a class.
Definition: Sema.h:10212
This is not an overload because the signature exactly matches an existing declaration.
Definition: Sema.h:2502
Interesting information about a specific parameter that can&#39;t simply be reflected in parameter&#39;s type...
Definition: Type.h:3453
The iterator over UnresolvedSets.
Definition: UnresolvedSet.h:32
CachedTokens Toks
Definition: Sema.h:10789
Token - This structure provides full information about a lexed token.
Definition: Token.h:35
bool isVisible(const Module *M) const
Determine whether a module is visible.
Definition: Module.h:613
CompatiblePointerDiscardsQualifiers - The assignment discards c/v/r qualifiers, which we accept as an...
Definition: Sema.h:9456
bool isInvalid() const
Definition: Sema.h:9811
ParsingDeclState PushParsingDeclaration(sema::DelayedDiagnosticPool &pool)
Definition: Sema.h:3968
The fixed underlying type of an enumeration.
Definition: Sema.h:6575
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:3539
TemplateName getTemplateName() const
Definition: Sema.h:1781
LazyVector< VarDecl *, ExternalSemaSource, &ExternalSemaSource::ReadTentativeDefinitions, 2, 2 > TentativeDefinitionsType
Definition: Sema.h:586
Defines some OpenMP-specific enums and functions.
OpaquePtr< QualType > ParsedType
An opaque type for threading parsed type information through the parser.
Definition: Ownership.h:248
Represents an access specifier followed by colon &#39;:&#39;.
Definition: DeclCXX.h:132
The type of a non-type template parameter.
Definition: Sema.h:6596
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
Definition: LangOptions.h:50
Diagnostic builder for CUDA errors which may or may not be deferred.
Definition: Sema.h:9979
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:33
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:14168
OverloadKind
C++ Overloading.
Definition: Sema.h:2495
Code completion occurs where only a type is permitted.
Definition: Sema.h:10229
Describes a module or submodule.
Definition: Module.h:65
llvm::BumpPtrAllocator BumpAlloc
Definition: Sema.h:1085
ObjCMethodDecl * LookupFactoryMethodInGlobalPool(Selector Sel, SourceRange R, bool receiverIdOrClass=false)
LookupFactoryMethodInGlobalPool - Returns the method and warns if there are multiple signatures...
Definition: Sema.h:3629
This little struct is used to capture information about structure field declarators, which is basically just a bitfield size.
Definition: DeclSpec.h:2479
SpecialMemberOverloadResult - The overloading result for a special member function.
Definition: Sema.h:1036
bool AccessCheckingSFINAE
When true, access checking violations are treated as SFINAE failures rather than hard errors...
Definition: Sema.h:6074
An r-value expression (a pr-value in the C++11 taxonomy) produces a temporary value.
Definition: Specifiers.h:110
The type of an exception.
Definition: Sema.h:6599
Code completion occurs at top-level or namespace context.
Definition: Sema.h:10195
A pair of a canonical FunctionDecl and a SourceLocation.
Definition: Sema.h:9934
We are instantiating the exception specification for a function template which was deferred until it ...
Definition: Sema.h:7173
bool isModuleVisible(const Module *M)
Definition: Sema.h:1559
SemaDiagnosticBuilder(DiagnosticBuilder &DB, Sema &SemaRef, unsigned DiagID)
Definition: Sema.h:1239
OpenMPDistScheduleClauseKind
OpenMP attributes for &#39;dist_schedule&#39; clause.
Definition: OpenMPKinds.h:100
An allocator used specifically for the purpose of code completion.
unsigned TyposCorrected
The number of typos corrected by CorrectTypo.
Definition: Sema.h:7581
Represents a C++ using-declaration.
Definition: DeclCXX.h:3360
Code completion occurs within the body of a function on a recovery path, where we do not have a speci...
Definition: Sema.h:10227
llvm::SmallVector< QualType, 4 > CurrentParameterCopyTypes
Stack of types that correspond to the parameter entities that are currently being copy-initialized...
Definition: Sema.h:1166
BinaryOperatorKind
Represents a C++ unqualified-id that has been parsed.
Definition: DeclSpec.h:922
bool isCompleteType(SourceLocation Loc, QualType T)
Definition: Sema.h:1616
ParsedAttributesView ArgAttrs
ArgAttrs - Attribute list for this argument.
Definition: Sema.h:8138
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:3052
Represents the results of name lookup.
Definition: Lookup.h:47
PtrTy get() const
Definition: Ownership.h:174
static const std::string & getPrintable(const std::string &S)
Definition: Sema.h:1496
RAII class used to indicate that we are performing provisional semantic analysis to determine the val...
Definition: Sema.h:7556
ObjCContainerDecl - Represents a container for method declarations.
Definition: DeclObjC.h:988
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:38
TemplateSpecCandidateSet - A set of generalized overload candidates, used in template specializations...
A convenient class for passing around template argument information.
Definition: TemplateBase.h:552
bool AllowAbstractFieldReference
A flag to indicate that we&#39;re in a context that permits abstract references to fields.
Definition: Sema.h:891
uint32_t Offset
Definition: CacheTokens.cpp:43
const FormatToken & Tok
Module * getOwningModule(Decl *Entity)
Get the module owning an entity.
Definition: Sema.h:1553
bool isObjCMethodDecl(Decl *D)
Definition: Sema.h:2007
ICEConvertDiagnoser(bool AllowScopedEnumerations, bool Suppress, bool SuppressConversion)
Definition: Sema.h:2663
Code completion occurs following one or more template headers.
Definition: Sema.h:10209
The base type of a class type.
Definition: Sema.h:6560
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:3040
Code completion occurs within an expression.
Definition: Sema.h:10214
PragmaStack(const ValueType &Default)
Definition: Sema.h:431
std::pair< SourceLocation, bool > DeleteExprLoc
Delete-expressions to be analyzed at the end of translation unit.
Definition: Sema.h:566
ObjCContainerKind
Definition: Sema.h:7906
unsigned LayoutCompatible
If true, Type should be compared with other expression&#39;s types for layout-compatibility.
Definition: Sema.h:10549
ExprResult getExpression() const
Definition: Sema.h:1776
Concrete class used by the front-end to report problems and issues.
Definition: Diagnostic.h:149
void incrementMSManglingNumber() const
Definition: Sema.h:10620
llvm::DenseSet< Module * > LookupModulesCache
Cache of additional modules that should be used for name lookup within the current template instantia...
Definition: Sema.h:7260
GlobalMethodPool MethodPool
Method Pool - allows efficient lookup when typechecking messages to "id".
Definition: Sema.h:1133
Represents a declaration of a type.
Definition: Decl.h:2829
Substitution of the deduced template argument values resulted in an error.
Definition: Sema.h:6929
A set of unresolved declarations.
Definition: UnresolvedSet.h:61
SourceLocation PointOfInstantiation
The point of instantiation or synthesis within the source code.
Definition: Sema.h:7193
Look up the name of an OpenMP user-defined reduction operation.
Definition: Sema.h:3054
Template argument deduction exceeded the maximum template instantiation depth (which has already been...
Definition: Sema.h:6912
void MarkDeducedTemplateParameters(const FunctionTemplateDecl *FunctionTemplate, llvm::SmallBitVector &Deduced)
Definition: Sema.h:7110
CheckedConversionKind
The kind of conversion being performed.
Definition: Sema.h:9297
EnterExpressionEvaluationContext(Sema &Actions, InitListTag, bool ShouldEnter=true)
Definition: Sema.h:10761
std::pair< StringRef, QualType > CapturedParamNameType
Definition: Sema.h:3818
std::function< ExprResult(Sema &, TypoExpr *, TypoCorrection)> TypoRecoveryCallback
Definition: Sema.h:3117
LazyDeclPtr StdBadAlloc
The C++ "std::bad_alloc" class, which is defined by the C++ standard library.
Definition: Sema.h:813
llvm::DenseMap< CanonicalDeclPtr< FunctionDecl >, std::vector< PartialDiagnosticAt > > CUDADeferredDiags
Diagnostics that are emitted only if we discover that the given function must be codegen&#39;ed.
Definition: Sema.h:9930
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:6566
NonTagKind
Common ways to introduce type names without a tag for use in diagnostics.
Definition: Sema.h:2165
TypoExpr - Internal placeholder for expressions where typo correction still needs to be performed and...
Definition: Expr.h:5444
void popUndelayed(DelayedDiagnosticsState state)
Undo a previous pushUndelayed().
Definition: Sema.h:699
PragmaPackDiagnoseKind
Definition: Sema.h:8334
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:2827
Represents an Objective-C protocol declaration.
Definition: DeclObjC.h:2085
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:7338
AccessResult
Definition: Sema.h:6009
ArrayTypeTrait
Names for the array type traits.
Definition: TypeTraits.h:91
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:294
Preprocessor & PP
Definition: Sema.h:318
ObjCInterfaceDecl * NSNumberDecl
The declaration of the Objective-C NSNumber class.
Definition: Sema.h:841
const LangOptions & getLangOpts() const
Definition: Sema.h:1204
LambdaCaptureInitKind
Definition: DeclSpec.h:2530
sema::AnalysisBasedWarnings AnalysisWarnings
Worker object for performing CFG-based warnings.
Definition: Sema.h:7592
SmallVector< BoundNodes, 1 > match(MatcherT Matcher, const NodeT &Node, ASTContext &Context)
Returns the results of matching Matcher on Node.
Represents the body of a CapturedStmt, and serves as its DeclContext.
Definition: Decl.h:4037
bool isUnevaluatedContext() const
Determines whether we are currently in a context that is not evaluated as per C++ [expr] p5...
Definition: Sema.h:7507
Represents an ObjC class declaration.
Definition: DeclObjC.h:1193
SmallVector< LambdaExpr *, 2 > Lambdas
The lambdas that are present within this context, if it is indeed an unevaluated context.
Definition: Sema.h:964
Member name lookup, which finds the names of class/struct/union members.
Definition: Sema.h:3024
IncompatiblePointerSign - The assignment is between two pointers types which point to integers which ...
Definition: Sema.h:9452
NamespaceDecl * StdExperimentalNamespaceCache
The C++ "std::experimental" namespace, where the experimental parts of the standard library resides...
Definition: Sema.h:821
llvm::DenseMap< IdentifierInfo *, AsmLabelAttr * > ExtnameUndeclaredIdentifiers
ExtnameUndeclaredIdentifiers - Identifiers contained in #pragma redefine_extname before declared...
Definition: Sema.h:788
bool mightBeIntendedToBeTemplateName(ExprResult E, bool &Dependent)
Determine whether it&#39;s plausible that E was intended to be a template-name.
Definition: Sema.h:1845
FullExprArg(Sema &actions)
Definition: Sema.h:3652
ObjCMethodDecl * StringWithUTF8StringMethod
The declaration of the stringWithUTF8String: method.
Definition: Sema.h:862
const LangOptions & LangOpts
Definition: Sema.h:317
static NameClassification TypeTemplate(TemplateName Name)
Definition: Sema.h:1751
RAII object used to change the argument pack substitution index within a Sema object.
Definition: Sema.h:7315
uint8_t PointerKind
Which kind of pointer declarator we saw.
Definition: Sema.h:240
Contains information about the compound statement currently being parsed.
Definition: ScopeInfo.h:66
TemplateNameKindForDiagnostics
Describes the detailed kind of a template name. Used in diagnostics.
Definition: Sema.h:1832
ParsingClassState PushParsingClass()
Definition: Sema.h:3974
unsigned NumCleanupObjects
The number of active cleanup objects when we entered this expression evaluation context.
Definition: Sema.h:954
llvm::SmallVector< DeleteExprLoc, 4 > DeleteLocs
Definition: Sema.h:567
A helper class for building up ExtParameterInfos.
Definition: Sema.h:7683
void AddInstanceMethodToGlobalPool(ObjCMethodDecl *Method, bool impl=false)
AddInstanceMethodToGlobalPool - All instance methods in a translation unit are added to a global pool...
Definition: Sema.h:3606
TypeTrait
Names for traits that operate specifically on types.
Definition: TypeTraits.h:21
bool MSStructPragmaOn
Definition: Sema.h:341
We are matching the template parameter lists of two template template parameters as part of matching ...
Definition: Sema.h:6457
DiagnosticsEngine & getDiagnostics() const
Definition: Sema.h:1208
RAII class used to determine whether SFINAE has trapped any errors that occur during template argumen...
Definition: Sema.h:7516
Defines the clang::TemplateNameKind enum.
ArgumentPackSubstitutionIndexRAII(Sema &Self, int NewSubstitutionIndex)
Definition: Sema.h:7320
CXXSpecialMember
Kinds of C++ special members.
Definition: Sema.h:1140
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:9816
virtual ~TypeDiagnoser()
Definition: Sema.h:1488
We are substituting explicit template arguments provided for a function template. ...
Definition: Sema.h:7153
IdentifierInfo * IdentInfo
Definition: Sema.h:4458
Sema - This implements semantic analysis and AST building for C.
Definition: Sema.h:277
Merge availability attributes for an implementation of a protocol requirement.
Definition: Sema.h:2414
A little helper class used to produce diagnostics.
Definition: Diagnostic.h:1042
Represents a prototype with parameter type info, e.g.
Definition: Type.h:3432
A functional-style cast.
Definition: Sema.h:9303
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:980
TentativeDefinitionsType TentativeDefinitions
All the tentative definitions encountered in the TU.
Definition: Sema.h:589
ResultTypeCompatibilityKind
Describes the compatibility of a result type with its method.
Definition: Sema.h:8302
llvm::DenseMap< Selector, GlobalMethods > GlobalMethodPool
Definition: Sema.h:1125
static bool isEqual(const FunctionDeclAndLoc &LHS, const FunctionDeclAndLoc &RHS)
Definition: Sema.h:10816
Retains information about a captured region.
Definition: ScopeInfo.h:720
llvm::SmallPtrSet< Selector, 8 > SelectorSet
Definition: Sema.h:3424
A RAII object to enter scope of a compound statement.
Definition: Sema.h:3699
Represents a ValueDecl that came out of a declarator.
Definition: Decl.h:689
CastKind
CastKind - The kind of operation required for a conversion.
The return type of classify().
Definition: Expr.h:302
Template argument deduction did not deduce a value for every template parameter.
Definition: Sema.h:6915
static FunctionDeclAndLoc getTombstoneKey()
Definition: Sema.h:10807
FunctionVoidPointer - The assignment is between a function pointer and void*, which the standard does...
Definition: Sema.h:9442
llvm::FoldingSet< SpecialMemberOverloadResultEntry > SpecialMemberCache
A cache of special member function overload resolution results for C++ records.
Definition: Sema.h:1070
ArraySizeModifier
Capture whether this is a normal array (e.g.
Definition: Type.h:2674
const Decl * PragmaAttributeCurrentTargetDecl
The declaration that is currently receiving an attribute from the #pragma attribute stack...
Definition: Sema.h:505
TemplateParameterListEqualKind
Enumeration describing how template parameter lists are compared for equality.
Definition: Sema.h:6439
DelayedDiagnosticsState ParsingDeclState
Definition: Sema.h:649
We are instantiating a template declaration.
Definition: Sema.h:7137
SourceLocation NameLoc
Definition: Sema.h:8131
Captures information about a #pragma weak directive.
Definition: Weak.h:25
std::function< void(const TypoCorrection &)> TypoDiagnosticGenerator
Definition: Sema.h:3115
SmallVector< PragmaAttributeEntry, 2 > PragmaAttributeStack
Definition: Sema.h:501
Scope * getCurScope() const
Retrieve the parser&#39;s current scope.
Definition: Sema.h:10618
llvm::PointerIntPair< CXXRecordDecl *, 3, CXXSpecialMember > SpecialMemberDecl
Definition: Sema.h:1151
SourceLocation IdentifierLoc
The location of the identifier.
Definition: Sema.h:5374
Allows QualTypes to be sorted and hence used in maps and sets.
NameClassification(ParsedType Type)
Definition: Sema.h:1735
SmallVector< PendingImplicitInstantiation, 1 > LateParsedInstantiations
Queue of implicit template instantiations that cannot be performed eagerly.
Definition: Sema.h:7611
Retains information about a block that is currently being parsed.
Definition: ScopeInfo.h:694
void popWithoutEmitting(DelayedDiagnosticsState state)
Leave a delayed-diagnostic state that was previously pushed.
Definition: Sema.h:685
const char * getTypeName(ID Id)
getTypeName - Return the name of the type for Id.
Definition: Types.cpp:39
llvm::DenseSet< FunctionDeclAndLoc > LocsWithCUDACallDiags
FunctionDecls and SourceLocations for which CheckCUDACall has emitted a (maybe deferred) "bad call" d...
Definition: Sema.h:9942
Represents a shadow constructor declaration introduced into a class by a C++11 using-declaration that...
Definition: DeclCXX.h:3248
Pepresents a block literal declaration, which is like an unnamed FunctionDecl.
Definition: Decl.h:3860
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
Definition: Decl.h:637
Expr - This represents one expression.
Definition: Expr.h:106
Emit no diagnostics.
Definition: Sema.h:9983
LookupNameKind
Describes the kind of name lookup to perform.
Definition: Sema.h:3012
SourceLocation End
SmallVector< Decl *, 2 > WeakTopLevelDecl
WeakTopLevelDecl - Translation-unit scoped declarations generated by #pragma weak during processing o...
Definition: Sema.h:799
DelayedDiagnosticsState push(sema::DelayedDiagnosticPool &pool)
Enter a new scope.
Definition: Sema.h:675
ExprValueKind
The categorization of expression values, currently following the C++11 scheme.
Definition: Specifiers.h:107
Slot(llvm::StringRef StackSlotLabel, ValueType Value, SourceLocation PragmaLocation, SourceLocation PragmaPushLocation)
Definition: Sema.h:399
std::string Label
ModuleDeclKind
Definition: Sema.h:2060
Helper class that collects exception specifications for implicitly-declared special member functions...
Definition: Sema.h:4727
int Id
Definition: ASTDiff.cpp:191
When performing template argument deduction for a function template, there were too many call argumen...
Definition: Sema.h:6942
llvm::SmallPtrSet< const Decl *, 4 > ParsingInitForAutoVars
ParsingInitForAutoVars - a set of declarations with auto types for which we are currently parsing the...
Definition: Sema.h:579
StateNode * Previous
Declaration of a template type parameter.
The message is an instance message.
Definition: Sema.h:8186
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:7448
We are substituting template argument determined as part of template argument deduction for either a ...
Definition: Sema.h:7160
ElaboratedTypeKeyword
The elaboration keyword that precedes a qualified type name or introduces an elaborated-type-specifie...
Definition: Type.h:4866
BlockExpr - Adaptor class for mixing a BlockDecl with expressions.
Definition: Expr.h:5051
Represents a C++ destructor within a class.
Definition: DeclCXX.h:2700
LazyDeclPtr StdNamespace
The C++ "std" namespace, where the standard library resides.
Definition: Sema.h:809
const internal::VariadicAllOfMatcher< Decl > decl
Matches declarations.
Code completion occurs within an Objective-C interface, protocol, or category.
Definition: Sema.h:10200
bool InNonInstantiationSFINAEContext
Whether we are in a SFINAE context that is not associated with template instantiation.
Definition: Sema.h:7276
IncompatibleVectors - The assignment is between two vector types that have the same size...
Definition: Sema.h:9471
llvm::MapVector< IdentifierInfo *, WeakInfo > WeakUndeclaredIdentifiers
WeakUndeclaredIdentifiers - Identifiers contained in #pragma weak before declared.
Definition: Sema.h:782
#define bool
Definition: stdbool.h:31
OpenMPClauseKind
OpenMP clauses.
Definition: OpenMPKinds.h:33
QualType FindCompositePointerType(SourceLocation Loc, ExprResult &E1, ExprResult &E2, bool ConvertArgs=true)
Definition: Sema.h:9631
void PopFunctionScopeInfo(const sema::AnalysisBasedWarnings::Policy *WP=nullptr, const Decl *D=nullptr, const BlockExpr *blkExpr=nullptr)
Definition: Sema.cpp:1402
PragmaStack< StringLiteral * > BSSSegStack
Definition: Sema.h:466
SourceLocation LocStart
Definition: Sema.h:4455
Initial building of a for-range statement.
Definition: Sema.h:3782
SourceLocation Begin
When performing template argument deduction for a function template, there were too few call argument...
Definition: Sema.h:6945
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:362
CXXTryStmt - A C++ try block, including all handlers.
Definition: StmtCXX.h:67
IncompatiblePointerDiscardsQualifiers - The assignment discards qualifiers that we don&#39;t permit to be...
Definition: Sema.h:9461
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:9681
Represents a C++ template name within the type system.
Definition: TemplateName.h:178
QualType NSNumberPointer
Pointer to NSNumber type (NSNumber *).
Definition: Sema.h:847
ReferenceCompareResult
ReferenceCompareResult - Expresses the result of comparing two types (cv1 T1 and cv2 T2) to determine...
Definition: Sema.h:9674
Defines the clang::TypeLoc interface and its subclasses.
int Depth
Definition: ASTDiff.cpp:191
bool isVisible(const NamedDecl *D)
Determine whether a declaration is visible to name lookup.
Definition: Sema.h:1562
Code completion occurs within a statement, which may also be an expression or a declaration.
Definition: Sema.h:10217
std::unique_ptr< MangleNumberingContext > MangleNumbering
The context information used to mangle lambda expressions and block literals within this context...
Definition: Sema.h:976
TemplateNameKind
Specifies the kind of template name that an identifier refers to.
Definition: TemplateKinds.h:21
SmallVector< LateInstantiatedAttribute, 16 > LateInstantiatedAttrVec
Definition: Sema.h:7812
SmallVector< VTableUse, 16 > VTableUses
The list of vtables that are required but have not yet been materialized.
Definition: Sema.h:5816
An RAII helper that pops function a function scope on exit.
Definition: Sema.h:3714
StorageClass
Storage classes.
Definition: Specifiers.h:206
CleanupInfo ParentCleanup
Whether the enclosing context needed a cleanup.
Definition: Sema.h:947
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:10643
SmallVector< sema::FunctionScopeInfo *, 4 > FunctionScopes
Stack containing information about each of the nested function, block, and method scopes that are cur...
Definition: Sema.h:538
PragmaMSCommentKind
Definition: PragmaKinds.h:15
InClassInitStyle
In-class initialization styles for non-static data members.
Definition: Specifiers.h:229
Partial specialization.
Definition: Sema.h:6602
NameClassification(ExprResult Expr)
Definition: Sema.h:1733
An expression that sends a message to the given Objective-C object or class.
Definition: ExprObjC.h:925
A mapping from file IDs to a record of whether we&#39;ve seen nullability information in that file...
Definition: Sema.h:248
Data structure that captures multiple levels of template argument lists for use in template instantia...
Definition: Template.h:65
ConditionKind
Definition: Sema.h:9824
bool isInvalid() const
Definition: Ownership.h:170
Preprocessor & getPreprocessor() const
Definition: Sema.h:1210
IdentifierInfo * Identifier
The identifier preceding the &#39;::&#39;.
Definition: Sema.h:5371
bool RequireCompleteType(SourceLocation Loc, QualType T, unsigned DiagID, const Ts &...Args)
Definition: Sema.h:1625
TemplateTemplateParmDecl - Declares a template template parameter, e.g., "T" in.
ObjCMethodDecl * ArrayWithObjectsMethod
The declaration of the arrayWithObjects:count: method.
Definition: Sema.h:871
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:7702
void addContextNote(SourceLocation UseLoc)
Definition: Sema.h:757
The symbol exists.
Definition: Sema.h:4494
SmallVector< attr::SubjectMatchRule, 4 > MatchRules
Definition: Sema.h:498
After substituting deduced template arguments, a dependent parameter type did not match the correspon...
Definition: Sema.h:6932
Represents a C++ conversion function within a class.
Definition: DeclCXX.h:2762
Code completion occurs within the list of instance variables in an Objective-C interface, protocol, category, or implementation.
Definition: Sema.h:10206
OpenMPProcBindClauseKind
OpenMP attributes for &#39;proc_bind&#39; clause.
Definition: OpenMPKinds.h:51
ObjCTypeParamVariance
Describes the variance of a given generic parameter.
Definition: DeclObjC.h:553
bool isTemplateInstantiation(TemplateSpecializationKind Kind)
Determine whether this template specialization kind refers to an instantiation of an entity (as oppos...
Definition: Specifiers.h:170
PragmaClangSectionKind
pragma clang section kind
Definition: Sema.h:354
const SourceManager & SM
Definition: Format.cpp:1475
ObjCKeywordKind
Provides a namespace for Objective-C keywords which start with an &#39;@&#39;.
Definition: TokenKinds.h:41
CallingConv
CallingConv - Specifies the calling convention that a function uses.
Definition: Specifiers.h:236
SourceLocation PointerLoc
The first pointer declarator (of any pointer kind) in the file that does not have a corresponding nul...
Definition: Sema.h:233
unsigned NumSFINAEErrors
The number of SFINAE diagnostics that have been trapped.
Definition: Sema.h:1088
This is a legitimate overload: the existing declarations are functions or function templates with dif...
Definition: Sema.h:2498
ExprResult ActOnFinishFullExpr(Expr *Expr)
Definition: Sema.h:5317
llvm::DenseMap< CanonicalDeclPtr< FunctionDecl >, FunctionDeclAndLoc > CUDAKnownEmittedFns
An inverse call graph, mapping known-emitted functions to one of their known-emitted callers (plus th...
Definition: Sema.h:9951
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:3290
CanonicalDeclPtr< FunctionDecl > FD
Definition: Sema.h:9935
static StringRef getPrintable(StringRef S)
Definition: Sema.h:1495
BuildForRangeKind
Definition: Sema.h:3780
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:605
A declaration qualifier.
Definition: Sema.h:6587
std::pair< const IdentifierInfo *, uint64_t > TypeTagMagicValue
A pair of ArgumentKind identifier and magic value.
Definition: Sema.h:10555
noexcept(expression), evals to &#39;false&#39;
LazyVector< TypedefNameDecl *, ExternalSemaSource, &ExternalSemaSource::ReadExtVectorDecls, 2, 2 > ExtVectorDeclsType
Definition: Sema.h:542
bool hasVisibleDefinition(const NamedDecl *D)
Definition: Sema.h:1586
StringLiteral * CurInitSeg
Last section used with #pragma init_seg.
Definition: Sema.h:487
CanThrowResult
Possible results from evaluation of a noexcept expression.
bool isComputedNoexcept(ExceptionSpecificationType ESpecType)
static unsigned getPrintable(unsigned I)
Definition: Sema.h:1492
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:4207
NameClassificationKind
Describes the result of the name lookup and resolution performed by ClassifyName().
Definition: Sema.h:1712
void pushCodeSynthesisContext(CodeSynthesisContext Ctx)
We are declaring an implicit special member function.
Definition: Sema.h:7176
ARCConversionResult
Definition: Sema.h:9729
CXXSpecialMember SpecialMember
The special member being declared or defined.
Definition: Sema.h:7214
#define false
Definition: stdbool.h:33
Tag name lookup, which finds the names of enums, classes, structs, and unions.
Definition: Sema.h:3019
RecordDecl * CXXTypeInfoDecl
The C++ "type_info" declaration, which is defined in <typeinfo>.
Definition: Sema.h:832
Kind
A reference to an overloaded function set, either an UnresolvedLookupExpr or an UnresolvedMemberExpr...
Definition: ExprCXX.h:2636
ImplicitConversionSequence - Represents an implicit conversion sequence, which may be a standard conv...
Definition: Overload.h:487
PragmaSectionKind
Definition: Sema.h:8363
ActionResult - This structure is used while parsing/acting on expressions, stmts, etc...
Definition: Ownership.h:157
ExceptionSpecificationType Type
The kind of exception specification this is.
Definition: Type.h:3529
PseudoObjectExpr - An expression which accesses a pseudo-object l-value.
Definition: Expr.h:5177
SmallVector< CXXBaseSpecifier *, 4 > CXXCastPath
A simple array of base specifiers.
Definition: Expr.h:53
Represents the parsed form of a C++ template argument.
A stack object to be created when performing template instantiation.
Definition: Sema.h:7352
TypeTagData(QualType Type, bool LayoutCompatible, bool MustBeNull)
Definition: Sema.h:10540
ASTContext & getASTContext() const
Definition: Sema.h:1211
LazyDeclPtr StdAlignValT
The C++ "std::align_val_t" enum class, which is defined by the C++ standard library.
Definition: Sema.h:817
llvm::SmallDenseMap< const ValueDecl *, const Expr *, 4 > VarsWithInheritedDSAType
Definition: Sema.h:8787
DeduceAutoResult
Result type of DeduceAutoType.
Definition: Sema.h:7036
Encodes a location in the source.
llvm::SmallPtrSet< Expr *, 2 > MaybeODRUseExprs
Store a list of either DeclRefExprs or MemberExprs that contain a reference to a variable (constant) ...
Definition: Sema.h:532
OpenMPDependClauseKind
OpenMP attributes for &#39;depend&#39; clause.
Definition: OpenMPKinds.h:76
Defines enumerations for expression traits intrinsics.
SourceLocation CurrentPragmaLocation
Definition: Sema.h:439
llvm::SmallPtrSet< Expr *, 2 > SavedMaybeODRUseExprs
Definition: Sema.h:960
ObjCPropertyQueryKind
Definition: DeclObjC.h:736
static unsigned getHashValue(const FunctionDeclAndLoc &FDL)
Definition: Sema.h:10811
static const char * getPrintable(const char *S)
Definition: Sema.h:1494
sema::TemplateDeductionInfo * DeductionInfo
The template deduction info object associated with the substitution or checking of explicit or deduce...
Definition: Sema.h:7224
static SourceRange getPrintable(const Expr *E)
Definition: Sema.h:1504
Template argument deduction failed due to inconsistent cv-qualifiers on a template parameter type tha...
Definition: Sema.h:6926
Represents the declaration of a struct/union/class/enum.
Definition: Decl.h:3020
OpenMPDirectiveKind
OpenMP directives.
Definition: OpenMPKinds.h:23
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:9446
ParsedAttr - Represents a syntactic attribute.
Definition: ParsedAttr.h:105
Template argument deduction did not deduce a value for every expansion of an expanded template parame...
Definition: Sema.h:6918
SynthesisKind
The kind of template instantiation we are performing.
Definition: Sema.h:7134
DelayedDiagnosticsState ProcessingContextState
Definition: Sema.h:650
Decl * ManglingContextDecl
The declaration that provides context for lambda expressions and block literals if the normal declara...
Definition: Sema.h:969
ExprObjectKind
A further classification of the kind of object referenced by an l-value or x-value.
Definition: Specifiers.h:124
ClassTemplateDecl * StdInitializerList
The C++ "std::initializer_list" template, which is defined in <initializer_list>. ...
Definition: Sema.h:825
ObjCSpecialMethodKind
Definition: Sema.h:8120
Represents a static or instance method of a struct/union/class.
Definition: DeclCXX.h:2045
ParsedType getType() const
Definition: Sema.h:1771
SourceLocation CCLoc
The location of the &#39;::&#39;.
Definition: Sema.h:5377
bool shouldDelayDiagnostics()
Determines whether diagnostics should be delayed.
Definition: Sema.h:666
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:5197
TemplateNameKind getTemplateNameKind() const
Definition: Sema.h:1787
llvm::SmallPtrSet< const CXXRecordDecl *, 8 > RecordDeclSetTy
Definition: Sema.h:570
static T * mergeVisibilityAttr(Sema &S, Decl *D, SourceRange range, typename T::VisibilityType value, unsigned attrSpellingListIndex)
SFINAETrap(Sema &SemaRef, bool AccessCheckingSFINAE=false)
Definition: Sema.h:7524
We are checking the validity of a default template argument that has been used when naming a template...
Definition: Sema.h:7169
The declaration was invalid; do nothing.
Definition: Sema.h:6909
static DeclarationName getPrintable(DeclarationName N)
Definition: Sema.h:1500
ObjCCategoryDecl - Represents a category declaration.
Definition: DeclObjC.h:2301
This is a basic class for representing single OpenMP clause.
Definition: OpenMPClause.h:51
The message is sent to &#39;super&#39;.
Definition: Sema.h:8184
static bool hasVisibleDefaultArgument(Sema &S, const ParmDecl *D, llvm::SmallVectorImpl< Module *> *Modules)
static bool isCast(CheckedConversionKind CCK)
Definition: Sema.h:9310
bool CollectStats
Flag indicating whether or not to collect detailed statistics.
Definition: Sema.h:325
static void CheckBoolLikeConversion(Sema &S, Expr *E, SourceLocation CC)
CheckBoolLikeConversion - Check conversion of given expression to boolean.
TokenKind
Provides a simple uniform namespace for tokens from all C languages.
Definition: TokenKinds.h:25
SourceLocation PragmaLocation
Definition: Sema.h:370
bool RequireNonAbstractType(SourceLocation Loc, QualType T, unsigned DiagID, const Ts &...Args)
Definition: Sema.h:6091
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:452
A friend declaration.
Definition: Sema.h:6584
AbstractDiagSelID
Definition: Sema.h:6076
void EmitCurrentDiagnostic(unsigned DiagID)
Cause the active diagnostic on the DiagosticsEngine to be emitted.
Definition: Sema.cpp:1213
SourceLocation OptimizeOffPragmaLocation
This represents the last location of a "#pragma clang optimize off" directive if such a directive has...
Definition: Sema.h:510
Represents a C++11 virt-specifier-seq.
Definition: DeclSpec.h:2488
CodeCompleteConsumer * CodeCompleter
Code-completion consumer.
Definition: Sema.h:328
unsigned NumTypos
The number of typos encountered during this expression evaluation context (i.e.
Definition: Sema.h:958
Represents one property declaration in an Objective-C interface.
Definition: DeclObjC.h:748
void SetLateTemplateParser(LateTemplateParserCB *LTP, LateTemplateParserCleanupCB *LTPCleanup, void *P)
Definition: Sema.h:635
OpaquePtr< TemplateName > TemplateTy
Definition: Sema.h:311
llvm::DenseSet< std::pair< Decl *, unsigned > > InstantiatingSpecializations
Specializations whose definitions are currently being instantiated.
Definition: Sema.h:7247
A default argument.
Definition: Sema.h:6593
llvm::SmallSetVector< CXXRecordDecl *, 16 > AssociatedClassSet
Definition: Sema.h:2715
std::unique_ptr< CXXFieldCollector > FieldCollector
FieldCollector - Collects CXXFieldDecls during parsing of C++ classes.
Definition: Sema.h:550
static NameClassification FunctionTemplate(TemplateName Name)
Definition: Sema.h:1763
The name is a dependent name, so the results will differ from one instantiation to the next...
Definition: Sema.h:4501
bool IsBuildingRecoveryCallExpr
Flag indicating if Sema is building a recovery call expression.
Definition: Sema.h:516
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:830
Constant expression in a noptr-new-declarator.
Definition: Sema.h:2601
ParameterABI
Kinds of parameter ABI.
Definition: Specifiers.h:308
llvm::DenseMap< ParmVarDecl *, llvm::TinyPtrVector< ParmVarDecl * > > UnparsedDefaultArgInstantiationsMap
Definition: Sema.h:1091
TentativeAnalysisScope(Sema &SemaRef)
Definition: Sema.h:7562
ASTConsumer & getASTConsumer() const
Definition: Sema.h:1212
CUDAFunctionTarget CurrentCUDATarget()
Gets the CUDA target for the current context.
Definition: Sema.h:10077
SourceLocation getExprLoc() const LLVM_READONLY
getExprLoc - Return the preferred location for the arrow when diagnosing a problem with a generic exp...
Definition: Expr.cpp:216
SynthesizedFunctionScope(Sema &S, DeclContext *DC)
Definition: Sema.h:746
void setLastDiagnosticIgnored(bool Ignored=true)
Pretend that the last diagnostic issued was ignored, so any subsequent notes will be suppressed...
Definition: Diagnostic.h:667
QualType NSValuePointer
Pointer to NSValue type (NSValue *).
Definition: Sema.h:850
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:6572
Expression in a case label.
Definition: Sema.h:2598
ReuseLambdaContextDecl_t
Definition: Sema.h:4015
A class for storing results from argument-dependent lookup.
Definition: Lookup.h:782
OpaquePtr< QualType > TypeTy
Definition: Sema.h:312
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:2872
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 template argument.
Definition: TemplateBase.h:51
ParserCompletionContext
Describes the context in which code completion occurs.
Definition: Sema.h:10193
ObjCDeclSpec DeclSpec
Definition: Sema.h:8135
TagTypeKind
The kind of a tag type.
Definition: Type.h:4847
OpenMPScheduleClauseModifier
OpenMP modifiers for &#39;schedule&#39; clause.
Definition: OpenMPKinds.h:67
Abstract base class used to perform a contextual implicit conversion from an expression to any type p...
Definition: Sema.h:2611
Dataflow Directional Tag Classes.
llvm::DenseMap< IdentifierInfo *, SrcLocSet > IdentifierSourceLocations
Definition: Sema.h:7584
LateTemplateParserCleanupCB * LateTemplateParserCleanup
Definition: Sema.h:632
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:984
SourceLocation ImplicitMSInheritanceAttrLoc
Source location for newly created implicit MSInheritanceAttrs.
Definition: Sema.h:351
int ArgumentPackSubstitutionIndex
The current index into pack expansion arguments that will be used for substitution of parameter packs...
Definition: Sema.h:7309
Don&#39;t merge availability attributes at all.
Definition: Sema.h:2405
unsigned NumTemplateArgs
The number of template arguments in TemplateArgs.
Definition: Sema.h:7211
UnaryOperatorKind
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
Definition: DeclBase.h:1264
const DeclContext * getCurObjCLexicalContext() const
Definition: Sema.h:10633
Represents a delete expression for memory deallocation and destructor calls, e.g. ...
Definition: ExprCXX.h:2145
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:399
OverloadedOperatorKind
Enumeration specifying the different kinds of C++ overloaded operators.
Definition: OperatorKinds.h:22
We are instantiating a default argument for a function.
Definition: Sema.h:7149
bool RequireLiteralType(SourceLocation Loc, QualType T, unsigned DiagID, const Ts &...Args)
Definition: Sema.h:1646
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:2780
bool IsAllowedCUDACall(const FunctionDecl *Caller, const FunctionDecl *Callee)
Determines whether Caller may invoke Callee, based on their CUDA host/device attributes.
Definition: Sema.h:10109
static NameClassification VarTemplate(TemplateName Name)
Definition: Sema.h:1757
SourceLocation PointerEndLoc
The end location for the first pointer declarator in the file.
Definition: Sema.h:237
LateInstantiatedAttribute(const Attr *A, LocalInstantiationScope *S, Decl *D)
Definition: Sema.h:7807
A decomposition declaration.
Definition: DeclCXX.h:3851
ClassTemplateDecl * StdCoroutineTraitsCache
The C++ "std::coroutine_traits" template, which is defined in <coroutine_traits>
Definition: Sema.h:829
llvm::SmallSet< SourceLocation, 2 > SrcLocSet
Definition: Sema.h:7583
A non-depnedent component of the parameter did not match the corresponding component of the argument...
Definition: Sema.h:6939
bool GlobalNewDeleteDeclared
A flag to remember whether the implicit forms of operator new and delete have been declared...
Definition: Sema.h:887
DeclarationName - The name of a declaration.
Represents the declaration of an Objective-C type parameter.
Definition: DeclObjC.h:578
unsigned size() const
The number of exceptions in the exception specification.
Definition: Sema.h:4760
SourceRange InstantiationRange
The source range that covers the construct that cause the instantiation, e.g., the template-id that c...
Definition: Sema.h:7229
Label name lookup.
Definition: Sema.h:3021
bool shouldDiagnoseTargetSupportFromOpenMP() const
Return true if (un)supported features for the current target should be diagnosed if OpenMP (offloadin...
Definition: Sema.h:8759
llvm::SmallPtrSet< SpecialMemberDecl, 4 > SpecialMembersBeingDeclared
The C++ special members which we are currently in the process of declaring.
Definition: Sema.h:1156
PragmaClangSection PragmaClangRodataSection
Definition: Sema.h:379
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:5812
ExpressionEvaluationContext Context
The expression evaluation context.
Definition: Sema.h:944
AllocationFunctionScope
The scope in which to find allocation functions.
Definition: Sema.h:5192
Represents an enum.
Definition: Decl.h:3313
IncompatibleBlockPointer - The assignment is between two block pointers types that are not compatible...
Definition: Sema.h:9479
The lookup found an overload set of literal operator templates, which expect the characters of the sp...
Definition: Sema.h:3100
TemplateSpecializationKind
Describes the kind of template specialization that a particular template specialization declaration r...
Definition: Specifiers.h:146
IdentifierResolver IdResolver
Definition: Sema.h:801
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:3658
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspnd...
SpecialMemberOverloadResult(CXXMethodDecl *MD)
Definition: Sema.h:1049
Abstract interface for a module loader.
Definition: ModuleLoader.h:74
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:714
bool isHidden() const
Determine whether this declaration might be hidden from name lookup.
Definition: DeclBase.h:774
const Expr * Replacement
Definition: ParsedAttr.h:67
llvm::MapVector< FieldDecl *, DeleteLocs > DeleteExprs
Definition: Sema.h:568
A dependently-generated diagnostic.
PragmaMsStackAction
Definition: Sema.h:382
Represents a pointer to an Objective C object.
Definition: Type.h:5611
AvailabilityMergeKind
Describes the kind of merge to perform for availability attributes (including "deprecated", "unavailable", and "availability").
Definition: Sema.h:2403
PragmaClangSection PragmaClangDataSection
Definition: Sema.h:378
void LateTemplateParserCB(void *P, LateParsedTemplate &LPT)
Callback to the parser to parse templated functions when needed.
Definition: Sema.h:629
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:40
ObjCMethodDecl * LookupInstanceMethodInGlobalPool(Selector Sel, SourceRange R, bool receiverIdOrClass=false)
LookupInstanceMethodInGlobalPool - Returns the method and warns if there are multiple signatures...
Definition: Sema.h:3621
llvm::DenseSet< QualType > InstantiatedNonDependentTypes
Non-dependent types used in templates that have already been instantiated by some template instantiat...
Definition: Sema.h:7251
ObjCImplementationDecl - Represents a class definition - this is where method definitions are specifi...
Definition: DeclObjC.h:2573
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
Definition: Type.h:4135
DeclarationName VAListTagName
VAListTagName - The declaration name corresponding to __va_list_tag.
Definition: Sema.h:339
EnterExpressionEvaluationContext(Sema &Actions, Sema::ExpressionEvaluationContext NewContext, Decl *LambdaContextDecl=nullptr, Sema::ExpressionEvaluationContextRecord::ExpressionKind ExprContext=Sema::ExpressionEvaluationContextRecord::EK_Other, bool ShouldEnter=true)
Definition: Sema.h:10739
Location wrapper for a TemplateArgument.
Definition: TemplateBase.h:450
The template argument was specified in the code or was instantiated with some deduced template argume...
Definition: Sema.h:6364
ArraySubscriptExpr - [C99 6.5.2.1] Array Subscripting.
Definition: Expr.h:2226
CheckTemplateArgumentKind
Specifies the context in which a particular template argument is being checked.
Definition: Sema.h:6361
ObjCLiteralKind
Definition: Sema.h:2696
ValueType CurrentValue
Definition: Sema.h:438
LocalInstantiationScope * Scope
Definition: Sema.h:7804
IntToBlockPointer - The assignment converts an int to a block pointer.
Definition: Sema.h:9475
Represents a C++ base or member initializer.
Definition: DeclCXX.h:2252
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:4763
DeclContext * getCurLexicalContext() const
Definition: Sema.h:10629
void * OpaqueParser
Definition: Sema.h:633
UnparsedDefaultArgInstantiationsMap UnparsedDefaultArgInstantiations
A mapping from parameters with unparsed default arguments to the set of instantiations of each parame...
Definition: Sema.h:1100
OpenMPScheduleClauseKind
OpenMP attributes for &#39;schedule&#39; clause.
Definition: OpenMPKinds.h:59
SmallVector< ExpressionEvaluationContextRecord, 8 > ExprEvalContexts
A stack of expression evaluation contexts.
Definition: Sema.h:1017
llvm::StringRef getCurrentOpenCLExtension() const
Definition: Sema.h:8572
bool isInOpenMPDeclareTargetContext() const
Return true inside OpenMP declare target region.
Definition: Sema.h:8752
static NameClassification Error()
Definition: Sema.h:1739
llvm::SmallSetVector< NamedDecl *, 16 > NamedDeclSetType
Definition: Sema.h:552
ExceptionSpecificationType
The various types of exception specifications that exist in C++11.
PragmaMSStructKind
Definition: PragmaKinds.h:24
OpenMPDefaultClauseKind
OpenMP attributes for &#39;default&#39; clause.
Definition: OpenMPKinds.h:43
ArrayRef< TemplateArgument > template_arguments() const
Definition: Sema.h:7217
Deduction failed; that&#39;s all we know.
Definition: Sema.h:6952
static NameClassification Unknown()
Definition: Sema.h:1743
ObjCInterfaceDecl * NSArrayDecl
The declaration of the Objective-C NSArray class.
Definition: Sema.h:868
SmallVector< BlockDecl *, 8 > ExprCleanupObjects
ExprCleanupObjects - This is the stack of objects requiring cleanup that are created by the current f...
Definition: Sema.h:524
APValue - This class implements a discriminated union of [uninitialized] [APSInt] [APFloat]...
Definition: APValue.h:38
static SourceRange getPrintable(SourceLocation L)
Definition: Sema.h:1503
Represents a base class of a C++ class.
Definition: DeclCXX.h:192
std::unique_ptr< sema::FunctionScopeInfo > PreallocatedFunctionScope
Definition: Sema.h:534
bool SavedInNonInstantiationSFINAEContext
Was the enclosing context a non-instantiation SFINAE context?
Definition: Sema.h:7190
void ActOnStartOfCompoundStmt(bool IsStmtExpr)
Definition: SemaStmt.cpp:340
PragmaStack< StringLiteral * > ConstSegStack
Definition: Sema.h:467
ArrayRef< QualType > Exceptions
Explicitly-specified list of exception types.
Definition: Type.h:3532
ProcessingContextState ParsingClassState
Definition: Sema.h:3973
PragmaClangSection PragmaClangTextSection
Definition: Sema.h:380
ParsedType ObjectType
The type of the object, if we&#39;re parsing nested-name-specifier in a member access expression...
Definition: Sema.h:5368
void * SkippedDefinitionContext
Definition: Sema.h:2281
Describes whether we&#39;ve seen any nullability information for the given file.
Definition: Sema.h:230
QualType QIDNSCopying
id<NSCopying> type.
Definition: Sema.h:880
RedeclarationKind forRedeclarationInCurContext()
Definition: Sema.h:3074
An implicit conversion.
Definition: Sema.h:9299
TrivialABIHandling
Definition: Sema.h:2247
bool isAlreadyInstantiating() const
Determine whether we are already instantiating this specialization in some surrounding active instant...
Definition: Sema.h:7452
A template argument list.
Definition: DeclTemplate.h:210
Merge availability attributes for a redeclaration, which requires an exact match. ...
Definition: Sema.h:2408
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:2672
Expr * NoexceptExpr
Noexcept expression, if this is a computed noexcept specification.
Definition: Type.h:3535
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:7269
An attributed type is a type to which a type attribute has been applied.
Definition: Type.h:4190
CCEKind
Contexts in which a converted constant expression is required.
Definition: Sema.h:2597
static void BuildBasePathArray(const CXXBasePath &Path, CXXCastPath &BasePathArray)
OpaquePtr< DeclGroupRef > DeclGroupPtrTy
Definition: Sema.h:310
MemberExpr - [C99 6.5.2.3] Structure and Union Members.
Definition: Expr.h:2500
ExprResult CorrectDelayedTyposInExpr(Expr *E, llvm::function_ref< ExprResult(Expr *)> Filter)
Definition: Sema.h:3277
Data structure used to record current or nested expression evaluation contexts.
Definition: Sema.h:942
void * VisContext
VisContext - Manages the stack for #pragma GCC visibility.
Definition: Sema.h:491
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:3090
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:10220
void LateTemplateParserCleanupCB(void *P)
Definition: Sema.h:630
ActionResult< Expr * > ExprResult
Definition: Ownership.h:267
Only look for allocation functions in the global scope.
Definition: Sema.h:5194
SourceLocation PragmaPushLocation
Definition: Sema.h:398
sema::DelayedDiagnosticPool * getCurrentPool() const
Returns the current delayed-diagnostics pool.
Definition: Sema.h:669
Represents a C++ struct/union/class.
Definition: DeclCXX.h:302
Compatible - the types are compatible according to the standard.
Definition: Sema.h:9430
Decl * D
The template function declaration to be late parsed.
Definition: Sema.h:10791
CUDAFunctionTarget
Definition: Sema.h:10059
sema::FunctionScopeInfo * getCurFunction() const
Definition: Sema.h:1331
Look up a friend of a local class.
Definition: Sema.h:3048
void PopParsingClass(ParsingClassState state)
Definition: Sema.h:3977
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:92
ObjCIvarDecl - Represents an ObjC instance variable.
Definition: DeclObjC.h:1966
LangOptions::PragmaMSPointersToMembersKind MSPointerToMemberRepresentationMethod
Controls member pointer representation format under the MS ABI.
Definition: Sema.h:345
TryCaptureKind
Definition: Sema.h:4051
llvm::DenseMap< int, SourceRange > ParsedSubjectMatchRuleSet
Selector RespondsToSelectorSel
will hold &#39;respondsToSelector:&#39;
Definition: Sema.h:883
TPOC
The context in which partial ordering of function templates occurs.
Definition: Template.h:161
DeclContext * CurContext
CurContext - This is the current declaration context of parsing.
Definition: Sema.h:331
TranslationUnitKind
Describes the kind of translation unit being processed.
Definition: LangOptions.h:301
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:656
The enumerator value.
Definition: Sema.h:6578
Writes an AST file containing the contents of a translation unit.
Definition: ASTWriter.h:103
SourceManager & getSourceManager() const
Definition: Sema.h:1209
After substituting deduced template arguments, an element of a dependent parameter type did not match...
Definition: Sema.h:6936
static void checkUnusedDeclAttributes(Sema &S, const ParsedAttributesView &A)
checkUnusedDeclAttributes - Check a list of attributes to see if it contains any decl attributes that...
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation tokens are not useful in isolation - they are low level value objects created/interpre...
Definition: Stmt.cpp:266
TranslationUnitKind TUKind
The kind of translation unit we are processing.
Definition: Sema.h:1083
ExpressionEvaluationContext
Describes how the expressions currently being parsed are evaluated at run-time, if at all...
Definition: Sema.h:895
StringLiteral - This represents a string literal expression, e.g.
Definition: Expr.h:1585
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
Definition: Expr.h:2316
Represents a complete lambda introducer.
Definition: DeclSpec.h:2538
We are substituting prior template arguments into a new template parameter.
Definition: Sema.h:7165
a linked list of methods with the same selector name but different signatures.
std::pair< ObjCMethodList, ObjCMethodList > GlobalMethods
Definition: Sema.h:1124
The translation unit is a complete translation unit.
Definition: LangOptions.h:303
ExprResult CorrectDelayedTyposInExpr(ExprResult ER, VarDecl *InitDecl=nullptr, llvm::function_ref< ExprResult(Expr *)> Filter=[](Expr *E) -> ExprResult { return E;})
Definition: Sema.h:3283
ExceptionSpecificationType getExceptionSpecType() const
Get the computed exception specification type.
Definition: Sema.h:4753
A using declaration.
Definition: Sema.h:6581
Designation - Represent a full designation, which is a sequence of designators.
Definition: Designator.h:181
FPOptions FPFeatures
Definition: Sema.h:315
FullExprArg MakeFullExpr(Expr *Arg, SourceLocation CC)
Definition: Sema.h:3677
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:974
static SourceRange getPrintable(SourceRange R)
Definition: Sema.h:1502
Code completion occurs within the condition of an if, while, switch, or for statement.
Definition: Sema.h:10223
Lambda expression.
Definition: Sema.h:6611
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:5822
SourceManager & SourceMgr
Definition: Sema.h:322
CapturedRegionKind
The different kinds of captured statement.
Definition: CapturedStmt.h:17
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:10788
ParamInfo - An array of paraminfo objects is allocated whenever a function declarator is parsed...
Definition: DeclSpec.h:1214
static int getPrintable(int I)
Definition: Sema.h:1491
class clang::Sema::DelayedDiagnostics DelayedDiagnostics
PragmaStack< unsigned > PackStack
Definition: Sema.h:456
A collection of diagnostics which were delayed.
Emit the diagnostic immediately, and, if it&#39;s a warning or error, also emit a call stack showing how ...
Definition: Sema.h:9989
An instance of this class represents the declaration of a property member.
Definition: DeclCXX.h:3920
#define true
Definition: stdbool.h:32
A wrapper class around a pointer that always points to its canonical declaration. ...
Definition: Redeclarable.h:348
A trivial tuple used to represent a source range.
ASTContext & Context
Definition: Sema.h:319
IncompatibleObjCQualifiedId - The assignment is between a qualified id type and something else (that ...
Definition: Sema.h:9484
This represents a decl that may have a name.
Definition: Decl.h:248
QualType NSStringPointer
Pointer to NSString type (NSString *).
Definition: Sema.h:859
FullExprArg MakeFullDiscardedValueExpr(Expr *Arg)
Definition: Sema.h:3680
Represents C++ using-directive.
Definition: DeclCXX.h:2924
SmallVector< std::pair< const CXXMethodDecl *, const CXXMethodDecl * >, 2 > DelayedExceptionSpecChecks
All the overriding functions seen during a class definition that had their exception spec checks dela...
Definition: Sema.h:611
The template argument was deduced via template argument deduction.
Definition: Sema.h:6368
SourceLocation CurrentPragmaLocation
Definition: Sema.h:460
Look up of an operator name (e.g., operator+) for use with operator overloading.
Definition: Sema.h:3028
Describes an entity that is being initialized.
static QualType getPrintable(QualType T)
Definition: Sema.h:1501
ComparisonCategoryType
An enumeration representing the different comparison categories types.
ExprResult release()
Definition: Sema.h:3654
NamedDecl * Previous
Definition: Sema.h:1675
The type of an arbitrary declaration.
Definition: Sema.h:6563
AssignmentAction
Definition: Sema.h:2483
ParsedAttributes - A collection of parsed attributes.
Definition: ParsedAttr.h:803
SourceLocation ColonLoc
Location of &#39;:&#39;.
Definition: OpenMPClause.h:102
SmallVector< Slot, 2 > Stack
Definition: Sema.h:436
brief A function argument from which we performed template argument
Definition: Sema.h:6976
CopyElisionSemanticsKind
Definition: Sema.h:3828
This represents &#39;#pragma omp threadprivate ...&#39; directive.
Definition: DeclOpenMP.h:39
ObjCCategoryImplDecl - An object of this class encapsulates a category @implementation declaration...
Definition: DeclObjC.h:2520
The explicitly-specified template arguments were not valid template arguments for the given template...
Definition: Sema.h:6948
The lookup resulted in an error.
Definition: Sema.h:3088
SmallVector< std::pair< CXXMethodDecl *, const FunctionProtoType * >, 2 > DelayedDefaultedMemberExceptionSpecs
All the members seen during a class definition which were both explicitly defaulted and had explicitl...
Definition: Sema.h:621
This class handles loading and caching of source files into memory.
void PrintContextStack()
Definition: Sema.h:7482
IncompatibleNestedPointerQualifiers - The assignment is between two nested pointer types...
Definition: Sema.h:9467
The symbol does not exist.
Definition: Sema.h:4497
Declaration of a template function.
Definition: DeclTemplate.h:968
llvm::DenseMap< const EnumDecl *, llvm::APInt > FlagBitsCache
A cache of the flags available in enumerations with the flag_bits attribute.
Definition: Sema.h:1074
Code completion occurs in a parenthesized expression, which might also be a type cast.
Definition: Sema.h:10232
void PushFunctionScope()
Enter a new function scope.
Definition: Sema.cpp:1370
NullPointerConstantKind
Enumeration used to describe the kind of Null pointer constant returned from isNullPointerConstant()...
Definition: Expr.h:680
NamedDeclSetType UnusedPrivateFields
Set containing all declared private fields that are not used.
Definition: Sema.h:555
Attr - This represents one attribute.
Definition: Attr.h:43
IdentifierInfo * Name
Definition: Sema.h:8130
CastType
Definition: SemaCast.cpp:46
This represents the stack of attributes that were pushed by #pragma clang attribute.
Definition: Sema.h:495
Represents a shadow declaration introduced into a scope by a (resolved) using declaration.
Definition: DeclCXX.h:3147
ParsedType actOnLambdaInitCaptureInitialization(SourceLocation Loc, bool ByRef, 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:5561
ObjCMethodDecl * DictionaryWithObjectsMethod
The declaration of the dictionaryWithObjects:forKeys:count: method.
Definition: Sema.h:877
Helper class that creates diagnostics with optional template instantiation stacks.
Definition: Sema.h:1234
Engages in a tight little dance with the lexer to efficiently preprocess tokens.
Definition: Preprocessor.h:127
The triviality of a method unaffected by "trivial_abi".
Definition: Sema.h:2249
bool hasErrorOccurred() const
Determine whether any SFINAE errors have been trapped.
Definition: Sema.h:7547
llvm::DenseMap< ParmVarDecl *, SourceLocation > UnparsedDefaultArgLocs
Definition: Sema.h:1104
A RAII object to temporarily push a declaration context.
Definition: Sema.h:706
ValueType DefaultValue
Definition: Sema.h:437
StandardConversionSequence - represents a standard conversion sequence (C++ 13.3.3.1.1).
Definition: Overload.h:230
SourceLocation CurInitSegLoc
Definition: Sema.h:488