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