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