Coverage Report

Created: 2019-07-24 05:18

/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/tools/clang/include/clang/Sema/Sema.h
Line
Count
Source (jump to first uncovered line)
1
//===--- Sema.h - Semantic Analysis & AST Building --------------*- C++ -*-===//
2
//
3
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4
// See https://llvm.org/LICENSE.txt for license information.
5
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6
//
7
//===----------------------------------------------------------------------===//
8
//
9
// This file defines the Sema class, which performs semantic analysis and
10
// builds ASTs.
11
//
12
//===----------------------------------------------------------------------===//
13
14
#ifndef LLVM_CLANG_SEMA_SEMA_H
15
#define LLVM_CLANG_SEMA_SEMA_H
16
17
#include "clang/AST/Attr.h"
18
#include "clang/AST/Availability.h"
19
#include "clang/AST/ComparisonCategories.h"
20
#include "clang/AST/DeclTemplate.h"
21
#include "clang/AST/DeclarationName.h"
22
#include "clang/AST/Expr.h"
23
#include "clang/AST/ExprCXX.h"
24
#include "clang/AST/ExprObjC.h"
25
#include "clang/AST/ExternalASTSource.h"
26
#include "clang/AST/LocInfoType.h"
27
#include "clang/AST/MangleNumberingContext.h"
28
#include "clang/AST/NSAPI.h"
29
#include "clang/AST/PrettyPrinter.h"
30
#include "clang/AST/StmtCXX.h"
31
#include "clang/AST/TypeLoc.h"
32
#include "clang/AST/TypeOrdering.h"
33
#include "clang/Basic/ExpressionTraits.h"
34
#include "clang/Basic/Module.h"
35
#include "clang/Basic/OpenMPKinds.h"
36
#include "clang/Basic/PragmaKinds.h"
37
#include "clang/Basic/Specifiers.h"
38
#include "clang/Basic/TemplateKinds.h"
39
#include "clang/Basic/TypeTraits.h"
40
#include "clang/Sema/AnalysisBasedWarnings.h"
41
#include "clang/Sema/CleanupInfo.h"
42
#include "clang/Sema/DeclSpec.h"
43
#include "clang/Sema/ExternalSemaSource.h"
44
#include "clang/Sema/IdentifierResolver.h"
45
#include "clang/Sema/ObjCMethodList.h"
46
#include "clang/Sema/Ownership.h"
47
#include "clang/Sema/Scope.h"
48
#include "clang/Sema/TypoCorrection.h"
49
#include "clang/Sema/Weak.h"
50
#include "llvm/ADT/ArrayRef.h"
51
#include "llvm/ADT/Optional.h"
52
#include "llvm/ADT/SetVector.h"
53
#include "llvm/ADT/SmallBitVector.h"
54
#include "llvm/ADT/SmallPtrSet.h"
55
#include "llvm/ADT/SmallVector.h"
56
#include "llvm/ADT/TinyPtrVector.h"
57
#include <deque>
58
#include <memory>
59
#include <string>
60
#include <vector>
61
62
namespace llvm {
63
  class APSInt;
64
  template <typename ValueT> struct DenseMapInfo;
65
  template <typename ValueT, typename ValueInfoT> class DenseSet;
66
  class SmallBitVector;
67
  struct InlineAsmIdentifierInfo;
68
}
69
70
namespace clang {
71
  class ADLResult;
72
  class ASTConsumer;
73
  class ASTContext;
74
  class ASTMutationListener;
75
  class ASTReader;
76
  class ASTWriter;
77
  class ArrayType;
78
  class ParsedAttr;
79
  class BindingDecl;
80
  class BlockDecl;
81
  class CapturedDecl;
82
  class CXXBasePath;
83
  class CXXBasePaths;
84
  class CXXBindTemporaryExpr;
85
  typedef SmallVector<CXXBaseSpecifier*, 4> CXXCastPath;
86
  class CXXConstructorDecl;
87
  class CXXConversionDecl;
88
  class CXXDeleteExpr;
89
  class CXXDestructorDecl;
90
  class CXXFieldCollector;
91
  class CXXMemberCallExpr;
92
  class CXXMethodDecl;
93
  class CXXScopeSpec;
94
  class CXXTemporary;
95
  class CXXTryStmt;
96
  class CallExpr;
97
  class ClassTemplateDecl;
98
  class ClassTemplatePartialSpecializationDecl;
99
  class ClassTemplateSpecializationDecl;
100
  class VarTemplatePartialSpecializationDecl;
101
  class CodeCompleteConsumer;
102
  class CodeCompletionAllocator;
103
  class CodeCompletionTUInfo;
104
  class CodeCompletionResult;
105
  class CoroutineBodyStmt;
106
  class Decl;
107
  class DeclAccessPair;
108
  class DeclContext;
109
  class DeclRefExpr;
110
  class DeclaratorDecl;
111
  class DeducedTemplateArgument;
112
  class DependentDiagnostic;
113
  class DesignatedInitExpr;
114
  class Designation;
115
  class EnableIfAttr;
116
  class EnumConstantDecl;
117
  class Expr;
118
  class ExtVectorType;
119
  class FormatAttr;
120
  class FriendDecl;
121
  class FunctionDecl;
122
  class FunctionProtoType;
123
  class FunctionTemplateDecl;
124
  class ImplicitConversionSequence;
125
  typedef MutableArrayRef<ImplicitConversionSequence> ConversionSequenceList;
126
  class InitListExpr;
127
  class InitializationKind;
128
  class InitializationSequence;
129
  class InitializedEntity;
130
  class IntegerLiteral;
131
  class LabelStmt;
132
  class LambdaExpr;
133
  class LangOptions;
134
  class LocalInstantiationScope;
135
  class LookupResult;
136
  class MacroInfo;
137
  typedef ArrayRef<std::pair<IdentifierInfo *, SourceLocation>> ModuleIdPath;
138
  class ModuleLoader;
139
  class MultiLevelTemplateArgumentList;
140
  class NamedDecl;
141
  class ObjCCategoryDecl;
142
  class ObjCCategoryImplDecl;
143
  class ObjCCompatibleAliasDecl;
144
  class ObjCContainerDecl;
145
  class ObjCImplDecl;
146
  class ObjCImplementationDecl;
147
  class ObjCInterfaceDecl;
148
  class ObjCIvarDecl;
149
  template <class T> class ObjCList;
150
  class ObjCMessageExpr;
151
  class ObjCMethodDecl;
152
  class ObjCPropertyDecl;
153
  class ObjCProtocolDecl;
154
  class OMPThreadPrivateDecl;
155
  class OMPRequiresDecl;
156
  class OMPDeclareReductionDecl;
157
  class OMPDeclareSimdDecl;
158
  class OMPClause;
159
  struct OMPVarListLocTy;
160
  struct OverloadCandidate;
161
  class OverloadCandidateSet;
162
  class OverloadExpr;
163
  class ParenListExpr;
164
  class ParmVarDecl;
165
  class Preprocessor;
166
  class PseudoDestructorTypeStorage;
167
  class PseudoObjectExpr;
168
  class QualType;
169
  class StandardConversionSequence;
170
  class Stmt;
171
  class StringLiteral;
172
  class SwitchStmt;
173
  class TemplateArgument;
174
  class TemplateArgumentList;
175
  class TemplateArgumentLoc;
176
  class TemplateDecl;
177
  class TemplateInstantiationCallback;
178
  class TemplateParameterList;
179
  class TemplatePartialOrderingContext;
180
  class TemplateTemplateParmDecl;
181
  class Token;
182
  class TypeAliasDecl;
183
  class TypedefDecl;
184
  class TypedefNameDecl;
185
  class TypeLoc;
186
  class TypoCorrectionConsumer;
187
  class UnqualifiedId;
188
  class UnresolvedLookupExpr;
189
  class UnresolvedMemberExpr;
190
  class UnresolvedSetImpl;
191
  class UnresolvedSetIterator;
192
  class UsingDecl;
193
  class UsingShadowDecl;
194
  class ValueDecl;
195
  class VarDecl;
196
  class VarTemplateSpecializationDecl;
197
  class VisibilityAttr;
198
  class VisibleDeclConsumer;
199
  class IndirectFieldDecl;
200
  struct DeductionFailureInfo;
201
  class TemplateSpecCandidateSet;
202
203
namespace sema {
204
  class AccessedEntity;
205
  class BlockScopeInfo;
206
  class Capture;
207
  class CapturedRegionScopeInfo;
208
  class CapturingScopeInfo;
209
  class CompoundScopeInfo;
210
  class DelayedDiagnostic;
211
  class DelayedDiagnosticPool;
212
  class FunctionScopeInfo;
213
  class LambdaScopeInfo;
214
  class PossiblyUnreachableDiag;
215
  class SemaPPCallbacks;
216
  class TemplateDeductionInfo;
217
}
218
219
namespace threadSafety {
220
  class BeforeSet;
221
  void threadSafetyCleanup(BeforeSet* Cache);
222
}
223
224
// FIXME: No way to easily map from TemplateTypeParmTypes to
225
// TemplateTypeParmDecls, so we have this horrible PointerUnion.
226
typedef std::pair<llvm::PointerUnion<const TemplateTypeParmType*, NamedDecl*>,
227
                  SourceLocation> UnexpandedParameterPack;
228
229
/// Describes whether we've seen any nullability information for the given
230
/// file.
231
struct FileNullability {
232
  /// The first pointer declarator (of any pointer kind) in the file that does
233
  /// not have a corresponding nullability annotation.
234
  SourceLocation PointerLoc;
235
236
  /// The end location for the first pointer declarator in the file. Used for
237
  /// placing fix-its.
238
  SourceLocation PointerEndLoc;
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.
249
class FileNullabilityMap {
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 {
255
    FileID File;
256
    FileNullability Nullability;
257
  } Cache;
258
259
public:
260
1.47M
  FileNullability &operator[](FileID file) {
261
1.47M
    // Check the single-element cache.
262
1.47M
    if (file == Cache.File)
263
1.42M
      return Cache.Nullability;
264
58.6k
265
58.6k
    // It's not in the single-element cache; flush the cache if we have one.
266
58.6k
    if (!Cache.File.isInvalid()) {
267
51.3k
      Map[Cache.File] = Cache.Nullability;
268
51.3k
    }
269
58.6k
270
58.6k
    // Pull this entry into the cache.
271
58.6k
    Cache.File = file;
272
58.6k
    Cache.Nullability = Map[file];
273
58.6k
    return Cache.Nullability;
274
58.6k
  }
275
};
276
277
/// Keeps track of expected type during expression parsing. The type is tied to
278
/// a particular token, all functions that update or consume the type take a
279
/// start location of the token they are looking at as a parameter. This allows
280
/// to avoid updating the type on hot paths in the parser.
281
class PreferredTypeBuilder {
282
public:
283
4.07M
  PreferredTypeBuilder() = default;
284
0
  explicit PreferredTypeBuilder(QualType Type) : Type(Type) {}
285
286
  void enterCondition(Sema &S, SourceLocation Tok);
287
  void enterReturn(Sema &S, SourceLocation Tok);
288
  void enterVariableInit(SourceLocation Tok, Decl *D);
289
  /// Computing a type for the function argument may require running
290
  /// overloading, so we postpone its computation until it is actually needed.
291
  ///
292
  /// Clients should be very careful when using this funciton, as it stores a
293
  /// function_ref, clients should make sure all calls to get() with the same
294
  /// location happen while function_ref is alive.
295
  void enterFunctionArgument(SourceLocation Tok,
296
                             llvm::function_ref<QualType()> ComputeType);
297
298
  void enterParenExpr(SourceLocation Tok, SourceLocation LParLoc);
299
  void enterUnary(Sema &S, SourceLocation Tok, tok::TokenKind OpKind,
300
                  SourceLocation OpLoc);
301
  void enterBinary(Sema &S, SourceLocation Tok, Expr *LHS, tok::TokenKind Op);
302
  void enterMemAccess(Sema &S, SourceLocation Tok, Expr *Base);
303
  void enterSubscript(Sema &S, SourceLocation Tok, Expr *LHS);
304
  /// Handles all type casts, including C-style cast, C++ casts, etc.
305
  void enterTypeCast(SourceLocation Tok, QualType CastType);
306
307
2.11M
  QualType get(SourceLocation Tok) const {
308
2.11M
    if (Tok != ExpectedLoc)
309
529k
      return QualType();
310
1.58M
    if (!Type.isNull())
311
788k
      return Type;
312
794k
    if (ComputeType)
313
185
      return ComputeType();
314
794k
    return QualType();
315
794k
  }
316
317
private:
318
  /// Start position of a token for which we store expected type.
319
  SourceLocation ExpectedLoc;
320
  /// Expected type for a token starting at ExpectedLoc.
321
  QualType Type;
322
  /// A function to compute expected type at ExpectedLoc. It is only considered
323
  /// if Type is null.
324
  llvm::function_ref<QualType()> ComputeType;
325
};
326
327
/// Sema - This implements semantic analysis and AST building for C.
328
class Sema {
329
  Sema(const Sema &) = delete;
330
  void operator=(const Sema &) = delete;
331
332
  ///Source of additional semantic information.
333
  ExternalSemaSource *ExternalSource;
334
335
  ///Whether Sema has generated a multiplexer and has to delete it.
336
  bool isMultiplexExternalSource;
337
338
  static bool mightHaveNonExternalLinkage(const DeclaratorDecl *FD);
339
340
  bool isVisibleSlow(const NamedDecl *D);
341
342
  /// Determine whether two declarations should be linked together, given that
343
  /// the old declaration might not be visible and the new declaration might
344
  /// not have external linkage.
345
  bool shouldLinkPossiblyHiddenDecl(const NamedDecl *Old,
346
482k
                                    const NamedDecl *New) {
347
482k
    if (isVisible(Old))
348
482k
     return true;
349
106
    // See comment in below overload for why it's safe to compute the linkage
350
106
    // of the new declaration here.
351
106
    if (New->isExternallyDeclarable()) {
352
105
      assert(Old->isExternallyDeclarable() &&
353
105
             "should not have found a non-externally-declarable previous decl");
354
105
      return true;
355
105
    }
356
1
    return false;
357
1
  }
358
  bool shouldLinkPossiblyHiddenDecl(LookupResult &Old, const NamedDecl *New);
359
360
  void setupImplicitSpecialMemberType(CXXMethodDecl *SpecialMem,
361
                                      QualType ResultTy,
362
                                      ArrayRef<QualType> Args);
363
364
public:
365
  typedef OpaquePtr<DeclGroupRef> DeclGroupPtrTy;
366
  typedef OpaquePtr<TemplateName> TemplateTy;
367
  typedef OpaquePtr<QualType> TypeTy;
368
369
  OpenCLOptions OpenCLFeatures;
370
  FPOptions FPFeatures;
371
372
  const LangOptions &LangOpts;
373
  Preprocessor &PP;
374
  ASTContext &Context;
375
  ASTConsumer &Consumer;
376
  DiagnosticsEngine &Diags;
377
  SourceManager &SourceMgr;
378
379
  /// Flag indicating whether or not to collect detailed statistics.
380
  bool CollectStats;
381
382
  /// Code-completion consumer.
383
  CodeCompleteConsumer *CodeCompleter;
384
385
  /// CurContext - This is the current declaration context of parsing.
386
  DeclContext *CurContext;
387
388
  /// Generally null except when we temporarily switch decl contexts,
389
  /// like in \see ActOnObjCTemporaryExitContainerContext.
390
  DeclContext *OriginalLexicalContext;
391
392
  /// VAListTagName - The declaration name corresponding to __va_list_tag.
393
  /// This is used as part of a hack to omit that class from ADL results.
394
  DeclarationName VAListTagName;
395
396
  bool MSStructPragmaOn; // True when \#pragma ms_struct on
397
398
  /// Controls member pointer representation format under the MS ABI.
399
  LangOptions::PragmaMSPointersToMembersKind
400
      MSPointerToMemberRepresentationMethod;
401
402
  /// Stack of active SEH __finally scopes.  Can be empty.
403
  SmallVector<Scope*, 2> CurrentSEHFinally;
404
405
  /// Source location for newly created implicit MSInheritanceAttrs
406
  SourceLocation ImplicitMSInheritanceAttrLoc;
407
408
  /// pragma clang section kind
409
  enum PragmaClangSectionKind {
410
    PCSK_Invalid      = 0,
411
    PCSK_BSS          = 1,
412
    PCSK_Data         = 2,
413
    PCSK_Rodata       = 3,
414
    PCSK_Text         = 4
415
   };
416
417
  enum PragmaClangSectionAction {
418
    PCSA_Set     = 0,
419
    PCSA_Clear   = 1
420
  };
421
422
  struct PragmaClangSection {
423
    std::string SectionName;
424
    bool Valid = false;
425
    SourceLocation PragmaLocation;
426
427
    void Act(SourceLocation PragmaLocation,
428
             PragmaClangSectionAction Action,
429
             StringLiteral* Name);
430
   };
431
432
   PragmaClangSection PragmaClangBSSSection;
433
   PragmaClangSection PragmaClangDataSection;
434
   PragmaClangSection PragmaClangRodataSection;
435
   PragmaClangSection PragmaClangTextSection;
436
437
  enum PragmaMsStackAction {
438
    PSK_Reset     = 0x0,                // #pragma ()
439
    PSK_Set       = 0x1,                // #pragma (value)
440
    PSK_Push      = 0x2,                // #pragma (push[, id])
441
    PSK_Pop       = 0x4,                // #pragma (pop[, id])
442
    PSK_Show      = 0x8,                // #pragma (show) -- only for "pack"!
443
    PSK_Push_Set  = PSK_Push | PSK_Set, // #pragma (push[, id], value)
444
    PSK_Pop_Set   = PSK_Pop | PSK_Set,  // #pragma (pop[, id], value)
445
  };
446
447
  template<typename ValueType>
448
  struct PragmaStack {
449
    struct Slot {
450
      llvm::StringRef StackSlotLabel;
451
      ValueType Value;
452
      SourceLocation PragmaLocation;
453
      SourceLocation PragmaPushLocation;
454
      Slot(llvm::StringRef StackSlotLabel, ValueType Value,
455
           SourceLocation PragmaLocation, SourceLocation PragmaPushLocation)
456
          : StackSlotLabel(StackSlotLabel), Value(Value),
457
            PragmaLocation(PragmaLocation),
458
5.65M
            PragmaPushLocation(PragmaPushLocation) {}
clang::Sema::PragmaStack<unsigned int>::Slot::Slot(llvm::StringRef, unsigned int, clang::SourceLocation, clang::SourceLocation)
Line
Count
Source
458
215
            PragmaPushLocation(PragmaPushLocation) {}
clang::Sema::PragmaStack<clang::MSVtorDispAttr::Mode>::Slot::Slot(llvm::StringRef, clang::MSVtorDispAttr::Mode, clang::SourceLocation, clang::SourceLocation)
Line
Count
Source
458
1.13M
            PragmaPushLocation(PragmaPushLocation) {}
clang::Sema::PragmaStack<clang::StringLiteral*>::Slot::Slot(llvm::StringRef, clang::StringLiteral*, clang::SourceLocation, clang::SourceLocation)
Line
Count
Source
458
4.52M
            PragmaPushLocation(PragmaPushLocation) {}
459
    };
460
    void Act(SourceLocation PragmaLocation,
461
             PragmaMsStackAction Action,
462
             llvm::StringRef StackSlotLabel,
463
             ValueType Value);
464
465
    // MSVC seems to add artificial slots to #pragma stacks on entering a C++
466
    // method body to restore the stacks on exit, so it works like this:
467
    //
468
    //   struct S {
469
    //     #pragma <name>(push, InternalPragmaSlot, <current_pragma_value>)
470
    //     void Method {}
471
    //     #pragma <name>(pop, InternalPragmaSlot)
472
    //   };
473
    //
474
    // It works even with #pragma vtordisp, although MSVC doesn't support
475
    //   #pragma vtordisp(push [, id], n)
476
    // syntax.
477
    //
478
    // Push / pop a named sentinel slot.
479
11.3M
    void SentinelAction(PragmaMsStackAction Action, StringRef Label) {
480
11.3M
      assert((Action == PSK_Push || Action == PSK_Pop) &&
481
11.3M
             "Can only push / pop #pragma stack sentinels!");
482
11.3M
      Act(CurrentPragmaLocation, Action, Label, CurrentValue);
483
11.3M
    }
clang::Sema::PragmaStack<clang::MSVtorDispAttr::Mode>::SentinelAction(clang::Sema::PragmaMsStackAction, llvm::StringRef)
Line
Count
Source
479
2.26M
    void SentinelAction(PragmaMsStackAction Action, StringRef Label) {
480
2.26M
      assert((Action == PSK_Push || Action == PSK_Pop) &&
481
2.26M
             "Can only push / pop #pragma stack sentinels!");
482
2.26M
      Act(CurrentPragmaLocation, Action, Label, CurrentValue);
483
2.26M
    }
clang::Sema::PragmaStack<clang::StringLiteral*>::SentinelAction(clang::Sema::PragmaMsStackAction, llvm::StringRef)
Line
Count
Source
479
9.04M
    void SentinelAction(PragmaMsStackAction Action, StringRef Label) {
480
9.04M
      assert((Action == PSK_Push || Action == PSK_Pop) &&
481
9.04M
             "Can only push / pop #pragma stack sentinels!");
482
9.04M
      Act(CurrentPragmaLocation, Action, Label, CurrentValue);
483
9.04M
    }
484
485
    // Constructors.
486
    explicit PragmaStack(const ValueType &Default)
487
249k
        : DefaultValue(Default), CurrentValue(Default) {}
clang::Sema::PragmaStack<clang::MSVtorDispAttr::Mode>::PragmaStack(clang::MSVtorDispAttr::Mode const&)
Line
Count
Source
487
41.5k
        : DefaultValue(Default), CurrentValue(Default) {}
clang::Sema::PragmaStack<unsigned int>::PragmaStack(unsigned int const&)
Line
Count
Source
487
41.5k
        : DefaultValue(Default), CurrentValue(Default) {}
clang::Sema::PragmaStack<clang::StringLiteral*>::PragmaStack(clang::StringLiteral* const&)
Line
Count
Source
487
166k
        : DefaultValue(Default), CurrentValue(Default) {}
488
489
954k
    bool hasValue() const { return CurrentValue != DefaultValue; }
490
491
    SmallVector<Slot, 2> Stack;
492
    ValueType DefaultValue; // Value used for PSK_Reset action.
493
    ValueType CurrentValue;
494
    SourceLocation CurrentPragmaLocation;
495
  };
496
  // FIXME: We should serialize / deserialize these if they occur in a PCH (but
497
  // we shouldn't do so if they're in a module).
498
499
  /// Whether to insert vtordisps prior to virtual bases in the Microsoft
500
  /// C++ ABI.  Possible values are 0, 1, and 2, which mean:
501
  ///
502
  /// 0: Suppress all vtordisps
503
  /// 1: Insert vtordisps in the presence of vbase overrides and non-trivial
504
  ///    structors
505
  /// 2: Always insert vtordisps to support RTTI on partially constructed
506
  ///    objects
507
  PragmaStack<MSVtorDispAttr::Mode> VtorDispStack;
508
  // #pragma pack.
509
  // Sentinel to represent when the stack is set to mac68k alignment.
510
  static const unsigned kMac68kAlignmentSentinel = ~0U;
511
  PragmaStack<unsigned> PackStack;
512
  // The current #pragma pack values and locations at each #include.
513
  struct PackIncludeState {
514
    unsigned CurrentValue;
515
    SourceLocation CurrentPragmaLocation;
516
    bool HasNonDefaultValue, ShouldWarnOnInclude;
517
  };
518
  SmallVector<PackIncludeState, 8> PackIncludeStack;
519
  // Segment #pragmas.
520
  PragmaStack<StringLiteral *> DataSegStack;
521
  PragmaStack<StringLiteral *> BSSSegStack;
522
  PragmaStack<StringLiteral *> ConstSegStack;
523
  PragmaStack<StringLiteral *> CodeSegStack;
524
525
  // RAII object to push / pop sentinel slots for all MS #pragma stacks.
526
  // Actions should be performed only if we enter / exit a C++ method body.
527
  class PragmaStackSentinelRAII {
528
  public:
529
    PragmaStackSentinelRAII(Sema &S, StringRef SlotLabel, bool ShouldAct);
530
    ~PragmaStackSentinelRAII();
531
532
  private:
533
    Sema &S;
534
    StringRef SlotLabel;
535
    bool ShouldAct;
536
  };
537
538
  /// A mapping that describes the nullability we've seen in each header file.
539
  FileNullabilityMap NullabilityMap;
540
541
  /// Last section used with #pragma init_seg.
542
  StringLiteral *CurInitSeg;
543
  SourceLocation CurInitSegLoc;
544
545
  /// VisContext - Manages the stack for \#pragma GCC visibility.
546
  void *VisContext; // Really a "PragmaVisStack*"
547
548
  /// This an attribute introduced by \#pragma clang attribute.
549
  struct PragmaAttributeEntry {
550
    SourceLocation Loc;
551
    ParsedAttr *Attribute;
552
    SmallVector<attr::SubjectMatchRule, 4> MatchRules;
553
    bool IsUsed;
554
  };
555
556
  /// A push'd group of PragmaAttributeEntries.
557
  struct PragmaAttributeGroup {
558
    /// The location of the push attribute.
559
    SourceLocation Loc;
560
    /// The namespace of this push group.
561
    const IdentifierInfo *Namespace;
562
    SmallVector<PragmaAttributeEntry, 2> Entries;
563
  };
564
565
  SmallVector<PragmaAttributeGroup, 2> PragmaAttributeStack;
566
567
  /// The declaration that is currently receiving an attribute from the
568
  /// #pragma attribute stack.
569
  const Decl *PragmaAttributeCurrentTargetDecl;
570
571
  /// This represents the last location of a "#pragma clang optimize off"
572
  /// directive if such a directive has not been closed by an "on" yet. If
573
  /// optimizations are currently "on", this is set to an invalid location.
574
  SourceLocation OptimizeOffPragmaLocation;
575
576
  /// Flag indicating if Sema is building a recovery call expression.
577
  ///
578
  /// This flag is used to avoid building recovery call expressions
579
  /// if Sema is already doing so, which would cause infinite recursions.
580
  bool IsBuildingRecoveryCallExpr;
581
582
  /// Used to control the generation of ExprWithCleanups.
583
  CleanupInfo Cleanup;
584
585
  /// ExprCleanupObjects - This is the stack of objects requiring
586
  /// cleanup that are created by the current full expression.  The
587
  /// element type here is ExprWithCleanups::Object.
588
  SmallVector<BlockDecl*, 8> ExprCleanupObjects;
589
590
  /// Store a set of either DeclRefExprs or MemberExprs that contain a reference
591
  /// to a variable (constant) that may or may not be odr-used in this Expr, and
592
  /// we won't know until all lvalue-to-rvalue and discarded value conversions
593
  /// have been applied to all subexpressions of the enclosing full expression.
594
  /// This is cleared at the end of each full expression.
595
  using MaybeODRUseExprSet = llvm::SmallPtrSet<Expr *, 2>;
596
  MaybeODRUseExprSet MaybeODRUseExprs;
597
598
  std::unique_ptr<sema::FunctionScopeInfo> CachedFunctionScope;
599
600
  /// Stack containing information about each of the nested
601
  /// function, block, and method scopes that are currently active.
602
  SmallVector<sema::FunctionScopeInfo *, 4> FunctionScopes;
603
604
  typedef LazyVector<TypedefNameDecl *, ExternalSemaSource,
605
                     &ExternalSemaSource::ReadExtVectorDecls, 2, 2>
606
    ExtVectorDeclsType;
607
608
  /// ExtVectorDecls - This is a list all the extended vector types. This allows
609
  /// us to associate a raw vector type with one of the ext_vector type names.
610
  /// This is only necessary for issuing pretty diagnostics.
611
  ExtVectorDeclsType ExtVectorDecls;
612
613
  /// FieldCollector - Collects CXXFieldDecls during parsing of C++ classes.
614
  std::unique_ptr<CXXFieldCollector> FieldCollector;
615
616
  typedef llvm::SmallSetVector<NamedDecl *, 16> NamedDeclSetType;
617
618
  /// Set containing all declared private fields that are not used.
619
  NamedDeclSetType UnusedPrivateFields;
620
621
  /// Set containing all typedefs that are likely unused.
622
  llvm::SmallSetVector<const TypedefNameDecl *, 4>
623
      UnusedLocalTypedefNameCandidates;
624
625
  /// Delete-expressions to be analyzed at the end of translation unit
626
  ///
627
  /// This list contains class members, and locations of delete-expressions
628
  /// that could not be proven as to whether they mismatch with new-expression
629
  /// used in initializer of the field.
630
  typedef std::pair<SourceLocation, bool> DeleteExprLoc;
631
  typedef llvm::SmallVector<DeleteExprLoc, 4> DeleteLocs;
632
  llvm::MapVector<FieldDecl *, DeleteLocs> DeleteExprs;
633
634
  typedef llvm::SmallPtrSet<const CXXRecordDecl*, 8> RecordDeclSetTy;
635
636
  /// PureVirtualClassDiagSet - a set of class declarations which we have
637
  /// emitted a list of pure virtual functions. Used to prevent emitting the
638
  /// same list more than once.
639
  std::unique_ptr<RecordDeclSetTy> PureVirtualClassDiagSet;
640
641
  /// ParsingInitForAutoVars - a set of declarations with auto types for which
642
  /// we are currently parsing the initializer.
643
  llvm::SmallPtrSet<const Decl*, 4> ParsingInitForAutoVars;
644
645
  /// Look for a locally scoped extern "C" declaration by the given name.
646
  NamedDecl *findLocallyScopedExternCDecl(DeclarationName Name);
647
648
  typedef LazyVector<VarDecl *, ExternalSemaSource,
649
                     &ExternalSemaSource::ReadTentativeDefinitions, 2, 2>
650
    TentativeDefinitionsType;
651
652
  /// All the tentative definitions encountered in the TU.
653
  TentativeDefinitionsType TentativeDefinitions;
654
655
  typedef LazyVector<const DeclaratorDecl *, ExternalSemaSource,
656
                     &ExternalSemaSource::ReadUnusedFileScopedDecls, 2, 2>
657
    UnusedFileScopedDeclsType;
658
659
  /// The set of file scoped decls seen so far that have not been used
660
  /// and must warn if not used. Only contains the first declaration.
661
  UnusedFileScopedDeclsType UnusedFileScopedDecls;
662
663
  typedef LazyVector<CXXConstructorDecl *, ExternalSemaSource,
664
                     &ExternalSemaSource::ReadDelegatingConstructors, 2, 2>
665
    DelegatingCtorDeclsType;
666
667
  /// All the delegating constructors seen so far in the file, used for
668
  /// cycle detection at the end of the TU.
669
  DelegatingCtorDeclsType DelegatingCtorDecls;
670
671
  /// All the overriding functions seen during a class definition
672
  /// that had their exception spec checks delayed, plus the overridden
673
  /// function.
674
  SmallVector<std::pair<const CXXMethodDecl*, const CXXMethodDecl*>, 2>
675
    DelayedOverridingExceptionSpecChecks;
676
677
  /// All the function redeclarations seen during a class definition that had
678
  /// their exception spec checks delayed, plus the prior declaration they
679
  /// should be checked against. Except during error recovery, the new decl
680
  /// should always be a friend declaration, as that's the only valid way to
681
  /// redeclare a special member before its class is complete.
682
  SmallVector<std::pair<FunctionDecl*, FunctionDecl*>, 2>
683
    DelayedEquivalentExceptionSpecChecks;
684
685
  typedef llvm::MapVector<const FunctionDecl *,
686
                          std::unique_ptr<LateParsedTemplate>>
687
      LateParsedTemplateMapT;
688
  LateParsedTemplateMapT LateParsedTemplateMap;
689
690
  /// Callback to the parser to parse templated functions when needed.
691
  typedef void LateTemplateParserCB(void *P, LateParsedTemplate &LPT);
692
  typedef void LateTemplateParserCleanupCB(void *P);
693
  LateTemplateParserCB *LateTemplateParser;
694
  LateTemplateParserCleanupCB *LateTemplateParserCleanup;
695
  void *OpaqueParser;
696
697
  void SetLateTemplateParser(LateTemplateParserCB *LTP,
698
                             LateTemplateParserCleanupCB *LTPCleanup,
699
1.55k
                             void *P) {
700
1.55k
    LateTemplateParser = LTP;
701
1.55k
    LateTemplateParserCleanup = LTPCleanup;
702
1.55k
    OpaqueParser = P;
703
1.55k
  }
704
705
  class DelayedDiagnostics;
706
707
  class DelayedDiagnosticsState {
708
    sema::DelayedDiagnosticPool *SavedPool;
709
    friend class Sema::DelayedDiagnostics;
710
  };
711
  typedef DelayedDiagnosticsState ParsingDeclState;
712
  typedef DelayedDiagnosticsState ProcessingContextState;
713
714
  /// A class which encapsulates the logic for delaying diagnostics
715
  /// during parsing and other processing.
716
  class DelayedDiagnostics {
717
    /// The current pool of diagnostics into which delayed
718
    /// diagnostics should go.
719
    sema::DelayedDiagnosticPool *CurPool;
720
721
  public:
722
41.5k
    DelayedDiagnostics() : CurPool(nullptr) {}
723
724
    /// Adds a delayed diagnostic.
725
    void add(const sema::DelayedDiagnostic &diag); // in DelayedDiagnostic.h
726
727
    /// Determines whether diagnostics should be delayed.
728
2.06M
    bool shouldDelayDiagnostics() { return CurPool != nullptr; }
729
730
    /// Returns the current delayed-diagnostics pool.
731
27.6M
    sema::DelayedDiagnosticPool *getCurrentPool() const {
732
27.6M
      return CurPool;
733
27.6M
    }
734
735
    /// Enter a new scope.  Access and deprecation diagnostics will be
736
    /// collected in this pool.
737
27.6M
    DelayedDiagnosticsState push(sema::DelayedDiagnosticPool &pool) {
738
27.6M
      DelayedDiagnosticsState state;
739
27.6M
      state.SavedPool = CurPool;
740
27.6M
      CurPool = &pool;
741
27.6M
      return state;
742
27.6M
    }
743
744
    /// Leave a delayed-diagnostic state that was previously pushed.
745
    /// Do not emit any of the diagnostics.  This is performed as part
746
    /// of the bookkeeping of popping a pool "properly".
747
27.6M
    void popWithoutEmitting(DelayedDiagnosticsState state) {
748
27.6M
      CurPool = state.SavedPool;
749
27.6M
    }
750
751
    /// Enter a new scope where access and deprecation diagnostics are
752
    /// not delayed.
753
7.52M
    DelayedDiagnosticsState pushUndelayed() {
754
7.52M
      DelayedDiagnosticsState state;
755
7.52M
      state.SavedPool = CurPool;
756
7.52M
      CurPool = nullptr;
757
7.52M
      return state;
758
7.52M
    }
759
760
    /// Undo a previous pushUndelayed().
761
7.52M
    void popUndelayed(DelayedDiagnosticsState state) {
762
7.52M
      assert(CurPool == nullptr);
763
7.52M
      CurPool = state.SavedPool;
764
7.52M
    }
765
  } DelayedDiagnostics;
766
767
  /// A RAII object to temporarily push a declaration context.
768
  class ContextRAII {
769
  private:
770
    Sema &S;
771
    DeclContext *SavedContext;
772
    ProcessingContextState SavedContextState;
773
    QualType SavedCXXThisTypeOverride;
774
775
  public:
776
    ContextRAII(Sema &S, DeclContext *ContextToPush, bool NewThisContext = true)
777
      : S(S), SavedContext(S.CurContext),
778
        SavedContextState(S.DelayedDiagnostics.pushUndelayed()),
779
        SavedCXXThisTypeOverride(S.CXXThisTypeOverride)
780
6.68M
    {
781
6.68M
      assert(ContextToPush && "pushing null context");
782
6.68M
      S.CurContext = ContextToPush;
783
6.68M
      if (NewThisContext)
784
6.66M
        S.CXXThisTypeOverride = QualType();
785
6.68M
    }
786
787
8.11M
    void pop() {
788
8.11M
      if (!SavedContext) 
return1.43M
;
789
6.68M
      S.CurContext = SavedContext;
790
6.68M
      S.DelayedDiagnostics.popUndelayed(SavedContextState);
791
6.68M
      S.CXXThisTypeOverride = SavedCXXThisTypeOverride;
792
6.68M
      SavedContext = nullptr;
793
6.68M
    }
794
795
6.68M
    ~ContextRAII() {
796
6.68M
      pop();
797
6.68M
    }
798
  };
799
800
  /// Used to change context to isConstantEvaluated without pushing a heavy
801
  /// ExpressionEvaluationContextRecord object.
802
  bool isConstantEvaluatedOverride;
803
804
10.1M
  bool isConstantEvaluated() {
805
10.1M
    return ExprEvalContexts.back().isConstantEvaluated() ||
806
10.1M
           
isConstantEvaluatedOverride9.97M
;
807
10.1M
  }
808
809
  /// RAII object to handle the state changes required to synthesize
810
  /// a function body.
811
  class SynthesizedFunctionScope {
812
    Sema &S;
813
    Sema::ContextRAII SavedContext;
814
    bool PushedCodeSynthesisContext = false;
815
816
  public:
817
    SynthesizedFunctionScope(Sema &S, DeclContext *DC)
818
90.7k
        : S(S), SavedContext(S, DC) {
819
90.7k
      S.PushFunctionScope();
820
90.7k
      S.PushExpressionEvaluationContext(
821
90.7k
          Sema::ExpressionEvaluationContext::PotentiallyEvaluated);
822
90.7k
      if (auto *FD = dyn_cast<FunctionDecl>(DC))
823
90.6k
        FD->setWillHaveBody(true);
824
90.7k
      else
825
90.7k
        assert(isa<ObjCMethodDecl>(DC));
826
90.7k
    }
827
828
90.2k
    void addContextNote(SourceLocation UseLoc) {
829
90.2k
      assert(!PushedCodeSynthesisContext);
830
90.2k
831
90.2k
      Sema::CodeSynthesisContext Ctx;
832
90.2k
      Ctx.Kind = Sema::CodeSynthesisContext::DefiningSynthesizedFunction;
833
90.2k
      Ctx.PointOfInstantiation = UseLoc;
834
90.2k
      Ctx.Entity = cast<Decl>(S.CurContext);
835
90.2k
      S.pushCodeSynthesisContext(Ctx);
836
90.2k
837
90.2k
      PushedCodeSynthesisContext = true;
838
90.2k
    }
839
840
90.7k
    ~SynthesizedFunctionScope() {
841
90.7k
      if (PushedCodeSynthesisContext)
842
90.2k
        S.popCodeSynthesisContext();
843
90.7k
      if (auto *FD = dyn_cast<FunctionDecl>(S.CurContext))
844
90.6k
        FD->setWillHaveBody(false);
845
90.7k
      S.PopExpressionEvaluationContext();
846
90.7k
      S.PopFunctionScopeInfo();
847
90.7k
    }
848
  };
849
850
  /// WeakUndeclaredIdentifiers - Identifiers contained in
851
  /// \#pragma weak before declared. rare. may alias another
852
  /// identifier, declared or undeclared
853
  llvm::MapVector<IdentifierInfo *, WeakInfo> WeakUndeclaredIdentifiers;
854
855
  /// ExtnameUndeclaredIdentifiers - Identifiers contained in
856
  /// \#pragma redefine_extname before declared.  Used in Solaris system headers
857
  /// to define functions that occur in multiple standards to call the version
858
  /// in the currently selected standard.
859
  llvm::DenseMap<IdentifierInfo*,AsmLabelAttr*> ExtnameUndeclaredIdentifiers;
860
861
862
  /// Load weak undeclared identifiers from the external source.
863
  void LoadExternalWeakUndeclaredIdentifiers();
864
865
  /// WeakTopLevelDecl - Translation-unit scoped declarations generated by
866
  /// \#pragma weak during processing of other Decls.
867
  /// I couldn't figure out a clean way to generate these in-line, so
868
  /// we store them here and handle separately -- which is a hack.
869
  /// It would be best to refactor this.
870
  SmallVector<Decl*,2> WeakTopLevelDecl;
871
872
  IdentifierResolver IdResolver;
873
874
  /// Translation Unit Scope - useful to Objective-C actions that need
875
  /// to lookup file scope declarations in the "ordinary" C decl namespace.
876
  /// For example, user-defined classes, built-in "id" type, etc.
877
  Scope *TUScope;
878
879
  /// The C++ "std" namespace, where the standard library resides.
880
  LazyDeclPtr StdNamespace;
881
882
  /// The C++ "std::bad_alloc" class, which is defined by the C++
883
  /// standard library.
884
  LazyDeclPtr StdBadAlloc;
885
886
  /// The C++ "std::align_val_t" enum class, which is defined by the C++
887
  /// standard library.
888
  LazyDeclPtr StdAlignValT;
889
890
  /// The C++ "std::experimental" namespace, where the experimental parts
891
  /// of the standard library resides.
892
  NamespaceDecl *StdExperimentalNamespaceCache;
893
894
  /// The C++ "std::initializer_list" template, which is defined in
895
  /// \<initializer_list>.
896
  ClassTemplateDecl *StdInitializerList;
897
898
  /// The C++ "std::coroutine_traits" template, which is defined in
899
  /// \<coroutine_traits>
900
  ClassTemplateDecl *StdCoroutineTraitsCache;
901
902
  /// The C++ "type_info" declaration, which is defined in \<typeinfo>.
903
  RecordDecl *CXXTypeInfoDecl;
904
905
  /// The MSVC "_GUID" struct, which is defined in MSVC header files.
906
  RecordDecl *MSVCGuidDecl;
907
908
  /// Caches identifiers/selectors for NSFoundation APIs.
909
  std::unique_ptr<NSAPI> NSAPIObj;
910
911
  /// The declaration of the Objective-C NSNumber class.
912
  ObjCInterfaceDecl *NSNumberDecl;
913
914
  /// The declaration of the Objective-C NSValue class.
915
  ObjCInterfaceDecl *NSValueDecl;
916
917
  /// Pointer to NSNumber type (NSNumber *).
918
  QualType NSNumberPointer;
919
920
  /// Pointer to NSValue type (NSValue *).
921
  QualType NSValuePointer;
922
923
  /// The Objective-C NSNumber methods used to create NSNumber literals.
924
  ObjCMethodDecl *NSNumberLiteralMethods[NSAPI::NumNSNumberLiteralMethods];
925
926
  /// The declaration of the Objective-C NSString class.
927
  ObjCInterfaceDecl *NSStringDecl;
928
929
  /// Pointer to NSString type (NSString *).
930
  QualType NSStringPointer;
931
932
  /// The declaration of the stringWithUTF8String: method.
933
  ObjCMethodDecl *StringWithUTF8StringMethod;
934
935
  /// The declaration of the valueWithBytes:objCType: method.
936
  ObjCMethodDecl *ValueWithBytesObjCTypeMethod;
937
938
  /// The declaration of the Objective-C NSArray class.
939
  ObjCInterfaceDecl *NSArrayDecl;
940
941
  /// The declaration of the arrayWithObjects:count: method.
942
  ObjCMethodDecl *ArrayWithObjectsMethod;
943
944
  /// The declaration of the Objective-C NSDictionary class.
945
  ObjCInterfaceDecl *NSDictionaryDecl;
946
947
  /// The declaration of the dictionaryWithObjects:forKeys:count: method.
948
  ObjCMethodDecl *DictionaryWithObjectsMethod;
949
950
  /// id<NSCopying> type.
951
  QualType QIDNSCopying;
952
953
  /// will hold 'respondsToSelector:'
954
  Selector RespondsToSelectorSel;
955
956
  /// A flag to remember whether the implicit forms of operator new and delete
957
  /// have been declared.
958
  bool GlobalNewDeleteDeclared;
959
960
  /// A flag to indicate that we're in a context that permits abstract
961
  /// references to fields.  This is really a
962
  bool AllowAbstractFieldReference;
963
964
  /// Describes how the expressions currently being parsed are
965
  /// evaluated at run-time, if at all.
966
  enum class ExpressionEvaluationContext {
967
    /// The current expression and its subexpressions occur within an
968
    /// unevaluated operand (C++11 [expr]p7), such as the subexpression of
969
    /// \c sizeof, where the type of the expression may be significant but
970
    /// no code will be generated to evaluate the value of the expression at
971
    /// run time.
972
    Unevaluated,
973
974
    /// The current expression occurs within a braced-init-list within
975
    /// an unevaluated operand. This is mostly like a regular unevaluated
976
    /// context, except that we still instantiate constexpr functions that are
977
    /// referenced here so that we can perform narrowing checks correctly.
978
    UnevaluatedList,
979
980
    /// The current expression occurs within a discarded statement.
981
    /// This behaves largely similarly to an unevaluated operand in preventing
982
    /// definitions from being required, but not in other ways.
983
    DiscardedStatement,
984
985
    /// The current expression occurs within an unevaluated
986
    /// operand that unconditionally permits abstract references to
987
    /// fields, such as a SIZE operator in MS-style inline assembly.
988
    UnevaluatedAbstract,
989
990
    /// The current context is "potentially evaluated" in C++11 terms,
991
    /// but the expression is evaluated at compile-time (like the values of
992
    /// cases in a switch statement).
993
    ConstantEvaluated,
994
995
    /// The current expression is potentially evaluated at run time,
996
    /// which means that code may be generated to evaluate the value of the
997
    /// expression at run time.
998
    PotentiallyEvaluated,
999
1000
    /// The current expression is potentially evaluated, but any
1001
    /// declarations referenced inside that expression are only used if
1002
    /// in fact the current expression is used.
1003
    ///
1004
    /// This value is used when parsing default function arguments, for which
1005
    /// we would like to provide diagnostics (e.g., passing non-POD arguments
1006
    /// through varargs) but do not want to mark declarations as "referenced"
1007
    /// until the default argument is used.
1008
    PotentiallyEvaluatedIfUsed
1009
  };
1010
1011
  /// Data structure used to record current or nested
1012
  /// expression evaluation contexts.
1013
  struct ExpressionEvaluationContextRecord {
1014
    /// The expression evaluation context.
1015
    ExpressionEvaluationContext Context;
1016
1017
    /// Whether the enclosing context needed a cleanup.
1018
    CleanupInfo ParentCleanup;
1019
1020
    /// Whether we are in a decltype expression.
1021
    bool IsDecltype;
1022
1023
    /// The number of active cleanup objects when we entered
1024
    /// this expression evaluation context.
1025
    unsigned NumCleanupObjects;
1026
1027
    /// The number of typos encountered during this expression evaluation
1028
    /// context (i.e. the number of TypoExprs created).
1029
    unsigned NumTypos;
1030
1031
    MaybeODRUseExprSet SavedMaybeODRUseExprs;
1032
1033
    /// The lambdas that are present within this context, if it
1034
    /// is indeed an unevaluated context.
1035
    SmallVector<LambdaExpr *, 2> Lambdas;
1036
1037
    /// The declaration that provides context for lambda expressions
1038
    /// and block literals if the normal declaration context does not
1039
    /// suffice, e.g., in a default function argument.
1040
    Decl *ManglingContextDecl;
1041
1042
    /// The context information used to mangle lambda expressions
1043
    /// and block literals within this context.
1044
    ///
1045
    /// This mangling information is allocated lazily, since most contexts
1046
    /// do not have lambda expressions or block literals.
1047
    std::unique_ptr<MangleNumberingContext> MangleNumbering;
1048
1049
    /// If we are processing a decltype type, a set of call expressions
1050
    /// for which we have deferred checking the completeness of the return type.
1051
    SmallVector<CallExpr *, 8> DelayedDecltypeCalls;
1052
1053
    /// If we are processing a decltype type, a set of temporary binding
1054
    /// expressions for which we have deferred checking the destructor.
1055
    SmallVector<CXXBindTemporaryExpr *, 8> DelayedDecltypeBinds;
1056
1057
    llvm::SmallPtrSet<const Expr *, 8> PossibleDerefs;
1058
1059
    /// \brief Describes whether we are in an expression constext which we have
1060
    /// to handle differently.
1061
    enum ExpressionKind {
1062
      EK_Decltype, EK_TemplateArgument, EK_Other
1063
    } ExprContext;
1064
1065
    ExpressionEvaluationContextRecord(ExpressionEvaluationContext Context,
1066
                                      unsigned NumCleanupObjects,
1067
                                      CleanupInfo ParentCleanup,
1068
                                      Decl *ManglingContextDecl,
1069
                                      ExpressionKind ExprContext)
1070
        : Context(Context), ParentCleanup(ParentCleanup),
1071
          NumCleanupObjects(NumCleanupObjects), NumTypos(0),
1072
          ManglingContextDecl(ManglingContextDecl), MangleNumbering(),
1073
45.0M
          ExprContext(ExprContext) {}
1074
1075
    /// Retrieve the mangling numbering context, used to consistently
1076
    /// number constructs like lambdas for mangling.
1077
    MangleNumberingContext &getMangleNumberingContext(ASTContext &Ctx);
1078
1079
105M
    bool isUnevaluated() const {
1080
105M
      return Context == ExpressionEvaluationContext::Unevaluated ||
1081
105M
             
Context == ExpressionEvaluationContext::UnevaluatedAbstract79.4M
||
1082
105M
             
Context == ExpressionEvaluationContext::UnevaluatedList79.4M
;
1083
105M
    }
1084
29.5M
    bool isConstantEvaluated() const {
1085
29.5M
      return Context == ExpressionEvaluationContext::ConstantEvaluated;
1086
29.5M
    }
1087
  };
1088
1089
  /// A stack of expression evaluation contexts.
1090
  SmallVector<ExpressionEvaluationContextRecord, 8> ExprEvalContexts;
1091
1092
  /// Emit a warning for all pending noderef expressions that we recorded.
1093
  void WarnOnPendingNoDerefs(ExpressionEvaluationContextRecord &Rec);
1094
1095
  /// Compute the mangling number context for a lambda expression or
1096
  /// block literal.
1097
  ///
1098
  /// \param DC - The DeclContext containing the lambda expression or
1099
  /// block literal.
1100
  /// \param[out] ManglingContextDecl - Returns the ManglingContextDecl
1101
  /// associated with the context, if relevant.
1102
  MangleNumberingContext *getCurrentMangleNumberContext(
1103
    const DeclContext *DC,
1104
    Decl *&ManglingContextDecl);
1105
1106
1107
  /// SpecialMemberOverloadResult - The overloading result for a special member
1108
  /// function.
1109
  ///
1110
  /// This is basically a wrapper around PointerIntPair. The lowest bits of the
1111
  /// integer are used to determine whether overload resolution succeeded.
1112
  class SpecialMemberOverloadResult {
1113
  public:
1114
    enum Kind {
1115
      NoMemberOrDeleted,
1116
      Ambiguous,
1117
      Success
1118
    };
1119
1120
  private:
1121
    llvm::PointerIntPair<CXXMethodDecl*, 2> Pair;
1122
1123
  public:
1124
703k
    SpecialMemberOverloadResult() : Pair() {}
1125
    SpecialMemberOverloadResult(CXXMethodDecl *MD)
1126
670
        : Pair(MD, MD->isDeleted() ? NoMemberOrDeleted : Success) {}
1127
1128
2.08M
    CXXMethodDecl *getMethod() const { return Pair.getPointer(); }
1129
399k
    void setMethod(CXXMethodDecl *MD) { Pair.setPointer(MD); }
1130
1131
1.30M
    Kind getKind() const { return static_cast<Kind>(Pair.getInt()); }
1132
399k
    void setKind(Kind K) { Pair.setInt(K); }
1133
  };
1134
1135
  class SpecialMemberOverloadResultEntry
1136
      : public llvm::FastFoldingSetNode,
1137
        public SpecialMemberOverloadResult {
1138
  public:
1139
    SpecialMemberOverloadResultEntry(const llvm::FoldingSetNodeID &ID)
1140
      : FastFoldingSetNode(ID)
1141
399k
    {}
1142
  };
1143
1144
  /// A cache of special member function overload resolution results
1145
  /// for C++ records.
1146
  llvm::FoldingSet<SpecialMemberOverloadResultEntry> SpecialMemberCache;
1147
1148
  /// A cache of the flags available in enumerations with the flag_bits
1149
  /// attribute.
1150
  mutable llvm::DenseMap<const EnumDecl*, llvm::APInt> FlagBitsCache;
1151
1152
  /// The kind of translation unit we are processing.
1153
  ///
1154
  /// When we're processing a complete translation unit, Sema will perform
1155
  /// end-of-translation-unit semantic tasks (such as creating
1156
  /// initializers for tentative definitions in C) once parsing has
1157
  /// completed. Modules and precompiled headers perform different kinds of
1158
  /// checks.
1159
  TranslationUnitKind TUKind;
1160
1161
  llvm::BumpPtrAllocator BumpAlloc;
1162
1163
  /// The number of SFINAE diagnostics that have been trapped.
1164
  unsigned NumSFINAEErrors;
1165
1166
  typedef llvm::DenseMap<ParmVarDecl *, llvm::TinyPtrVector<ParmVarDecl *>>
1167
    UnparsedDefaultArgInstantiationsMap;
1168
1169
  /// A mapping from parameters with unparsed default arguments to the
1170
  /// set of instantiations of each parameter.
1171
  ///
1172
  /// This mapping is a temporary data structure used when parsing
1173
  /// nested class templates or nested classes of class templates,
1174
  /// where we might end up instantiating an inner class before the
1175
  /// default arguments of its methods have been parsed.
1176
  UnparsedDefaultArgInstantiationsMap UnparsedDefaultArgInstantiations;
1177
1178
  // Contains the locations of the beginning of unparsed default
1179
  // argument locations.
1180
  llvm::DenseMap<ParmVarDecl *, SourceLocation> UnparsedDefaultArgLocs;
1181
1182
  /// UndefinedInternals - all the used, undefined objects which require a
1183
  /// definition in this translation unit.
1184
  llvm::MapVector<NamedDecl *, SourceLocation> UndefinedButUsed;
1185
1186
  /// Determine if VD, which must be a variable or function, is an external
1187
  /// symbol that nonetheless can't be referenced from outside this translation
1188
  /// unit because its type has no linkage and it's not extern "C".
1189
  bool isExternalWithNoLinkageType(ValueDecl *VD);
1190
1191
  /// Obtain a sorted list of functions that are undefined but ODR-used.
1192
  void getUndefinedButUsed(
1193
      SmallVectorImpl<std::pair<NamedDecl *, SourceLocation> > &Undefined);
1194
1195
  /// Retrieves list of suspicious delete-expressions that will be checked at
1196
  /// the end of translation unit.
1197
  const llvm::MapVector<FieldDecl *, DeleteLocs> &
1198
  getMismatchingDeleteExpressions() const;
1199
1200
  typedef std::pair<ObjCMethodList, ObjCMethodList> GlobalMethods;
1201
  typedef llvm::DenseMap<Selector, GlobalMethods> GlobalMethodPool;
1202
1203
  /// Method Pool - allows efficient lookup when typechecking messages to "id".
1204
  /// We need to maintain a list, since selectors can have differing signatures
1205
  /// across classes. In Cocoa, this happens to be extremely uncommon (only 1%
1206
  /// of selectors are "overloaded").
1207
  /// At the head of the list it is recorded whether there were 0, 1, or >= 2
1208
  /// methods inside categories with a particular selector.
1209
  GlobalMethodPool MethodPool;
1210
1211
  /// Method selectors used in a \@selector expression. Used for implementation
1212
  /// of -Wselector.
1213
  llvm::MapVector<Selector, SourceLocation> ReferencedSelectors;
1214
1215
  /// List of SourceLocations where 'self' is implicitly retained inside a
1216
  /// block.
1217
  llvm::SmallVector<std::pair<SourceLocation, const BlockDecl *>, 1>
1218
      ImplicitlyRetainedSelfLocs;
1219
1220
  /// Kinds of C++ special members.
1221
  enum CXXSpecialMember {
1222
    CXXDefaultConstructor,
1223
    CXXCopyConstructor,
1224
    CXXMoveConstructor,
1225
    CXXCopyAssignment,
1226
    CXXMoveAssignment,
1227
    CXXDestructor,
1228
    CXXInvalid
1229
  };
1230
1231
  typedef llvm::PointerIntPair<CXXRecordDecl *, 3, CXXSpecialMember>
1232
      SpecialMemberDecl;
1233
1234
  /// The C++ special members which we are currently in the process of
1235
  /// declaring. If this process recursively triggers the declaration of the
1236
  /// same special member, we should act as if it is not yet declared.
1237
  llvm::SmallPtrSet<SpecialMemberDecl, 4> SpecialMembersBeingDeclared;
1238
1239
  /// The function definitions which were renamed as part of typo-correction
1240
  /// to match their respective declarations. We want to keep track of them
1241
  /// to ensure that we don't emit a "redefinition" error if we encounter a
1242
  /// correctly named definition after the renamed definition.
1243
  llvm::SmallPtrSet<const NamedDecl *, 4> TypoCorrectedFunctionDefinitions;
1244
1245
  /// Stack of types that correspond to the parameter entities that are
1246
  /// currently being copy-initialized. Can be empty.
1247
  llvm::SmallVector<QualType, 4> CurrentParameterCopyTypes;
1248
1249
  void ReadMethodPool(Selector Sel);
1250
  void updateOutOfDateSelector(Selector Sel);
1251
1252
  /// Private Helper predicate to check for 'self'.
1253
  bool isSelfExpr(Expr *RExpr);
1254
  bool isSelfExpr(Expr *RExpr, const ObjCMethodDecl *Method);
1255
1256
  /// Cause the active diagnostic on the DiagosticsEngine to be
1257
  /// emitted. This is closely coupled to the SemaDiagnosticBuilder class and
1258
  /// should not be used elsewhere.
1259
  void EmitCurrentDiagnostic(unsigned DiagID);
1260
1261
  /// Records and restores the FP_CONTRACT state on entry/exit of compound
1262
  /// statements.
1263
  class FPContractStateRAII {
1264
  public:
1265
5.28M
    FPContractStateRAII(Sema &S) : S(S), OldFPFeaturesState(S.FPFeatures) {}
1266
5.28M
    ~FPContractStateRAII() { S.FPFeatures = OldFPFeaturesState; }
1267
1268
  private:
1269
    Sema& S;
1270
    FPOptions OldFPFeaturesState;
1271
  };
1272
1273
  void addImplicitTypedef(StringRef Name, QualType T);
1274
1275
public:
1276
  Sema(Preprocessor &pp, ASTContext &ctxt, ASTConsumer &consumer,
1277
       TranslationUnitKind TUKind = TU_Complete,
1278
       CodeCompleteConsumer *CompletionConsumer = nullptr);
1279
  ~Sema();
1280
1281
  /// Perform initialization that occurs after the parser has been
1282
  /// initialized but before it parses anything.
1283
  void Initialize();
1284
1285
2.05G
  const LangOptions &getLangOpts() const { return LangOpts; }
1286
96.1k
  OpenCLOptions &getOpenCLOptions() { return OpenCLFeatures; }
1287
3.61k
  FPOptions     &getFPOptions() { return FPFeatures; }
1288
1289
26.9M
  DiagnosticsEngine &getDiagnostics() const { return Diags; }
1290
1.39M
  SourceManager &getSourceManager() const { return SourceMgr; }
1291
125k
  Preprocessor &getPreprocessor() const { return PP; }
1292
55.0M
  ASTContext &getASTContext() const { return Context; }
1293
1.12M
  ASTConsumer &getASTConsumer() const { return Consumer; }
1294
  ASTMutationListener *getASTMutationListener() const;
1295
44.9k
  ExternalSemaSource* getExternalSource() const { return ExternalSource; }
1296
1297
  ///Registers an external source. If an external source already exists,
1298
  /// creates a multiplex external source and appends to it.
1299
  ///
1300
  ///\param[in] E - A non-null external sema source.
1301
  ///
1302
  void addExternalSource(ExternalSemaSource *E);
1303
1304
  void PrintStats() const;
1305
1306
  /// Helper class that creates diagnostics with optional
1307
  /// template instantiation stacks.
1308
  ///
1309
  /// This class provides a wrapper around the basic DiagnosticBuilder
1310
  /// class that emits diagnostics. SemaDiagnosticBuilder is
1311
  /// responsible for emitting the diagnostic (as DiagnosticBuilder
1312
  /// does) and, if the diagnostic comes from inside a template
1313
  /// instantiation, printing the template instantiation stack as
1314
  /// well.
1315
  class SemaDiagnosticBuilder : public DiagnosticBuilder {
1316
    Sema &SemaRef;
1317
    unsigned DiagID;
1318
1319
  public:
1320
    SemaDiagnosticBuilder(DiagnosticBuilder &DB, Sema &SemaRef, unsigned DiagID)
1321
2.39M
      : DiagnosticBuilder(DB), SemaRef(SemaRef), DiagID(DiagID) { }
1322
1323
    // This is a cunning lie. DiagnosticBuilder actually performs move
1324
    // construction in its copy constructor (but due to varied uses, it's not
1325
    // possible to conveniently express this as actual move construction). So
1326
    // the default copy ctor here is fine, because the base class disables the
1327
    // source anyway, so the user-defined ~SemaDiagnosticBuilder is a safe no-op
1328
    // in that case anwyay.
1329
2.43k
    SemaDiagnosticBuilder(const SemaDiagnosticBuilder&) = default;
1330
1331
2.40M
    ~SemaDiagnosticBuilder() {
1332
2.40M
      // If we aren't active, there is nothing to do.
1333
2.40M
      if (!isActive()) 
return4.11k
;
1334
2.39M
1335
2.39M
      // Otherwise, we need to emit the diagnostic. First flush the underlying
1336
2.39M
      // DiagnosticBuilder data, and clear the diagnostic builder itself so it
1337
2.39M
      // won't emit the diagnostic in its own destructor.
1338
2.39M
      //
1339
2.39M
      // This seems wasteful, in that as written the DiagnosticBuilder dtor will
1340
2.39M
      // do its own needless checks to see if the diagnostic needs to be
1341
2.39M
      // emitted. However, because we take care to ensure that the builder
1342
2.39M
      // objects never escape, a sufficiently smart compiler will be able to
1343
2.39M
      // eliminate that code.
1344
2.39M
      FlushCounts();
1345
2.39M
      Clear();
1346
2.39M
1347
2.39M
      // Dispatch to Sema to emit the diagnostic.
1348
2.39M
      SemaRef.EmitCurrentDiagnostic(DiagID);
1349
2.39M
    }
1350
1351
    /// Teach operator<< to produce an object of the correct type.
1352
    template<typename T>
1353
    friend const SemaDiagnosticBuilder &operator<<(
1354
2.53M
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
2.53M
      const DiagnosticBuilder &BaseDiag = Diag;
1356
2.53M
      BaseDiag << Value;
1357
2.53M
      return Diag;
1358
2.53M
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<clang::QualType>(clang::Sema::SemaDiagnosticBuilder const&, clang::QualType const&)
Line
Count
Source
1354
302k
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
302k
      const DiagnosticBuilder &BaseDiag = Diag;
1356
302k
      BaseDiag << Value;
1357
302k
      return Diag;
1358
302k
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<clang::FunctionDecl const*>(clang::Sema::SemaDiagnosticBuilder const&, clang::FunctionDecl const* const&)
Line
Count
Source
1354
935
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
935
      const DiagnosticBuilder &BaseDiag = Diag;
1356
935
      BaseDiag << Value;
1357
935
      return Diag;
1358
935
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<int>(clang::Sema::SemaDiagnosticBuilder const&, int const&)
Line
Count
Source
1354
151k
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
151k
      const DiagnosticBuilder &BaseDiag = Diag;
1356
151k
      BaseDiag << Value;
1357
151k
      return Diag;
1358
151k
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<clang::ObjCMethodDecl const*>(clang::Sema::SemaDiagnosticBuilder const&, clang::ObjCMethodDecl const* const&)
Line
Count
Source
1354
3
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
3
      const DiagnosticBuilder &BaseDiag = Diag;
1356
3
      BaseDiag << Value;
1357
3
      return Diag;
1358
3
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<clang::SourceRange>(clang::Sema::SemaDiagnosticBuilder const&, clang::SourceRange const&)
Line
Count
Source
1354
1.23M
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
1.23M
      const DiagnosticBuilder &BaseDiag = Diag;
1356
1.23M
      BaseDiag << Value;
1357
1.23M
      return Diag;
1358
1.23M
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<clang::FixItHint>(clang::Sema::SemaDiagnosticBuilder const&, clang::FixItHint const&)
Line
Count
Source
1354
161k
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
161k
      const DiagnosticBuilder &BaseDiag = Diag;
1356
161k
      BaseDiag << Value;
1357
161k
      return Diag;
1358
161k
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<clang::SourceLocation>(clang::Sema::SemaDiagnosticBuilder const&, clang::SourceLocation const&)
Line
Count
Source
1354
834
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
834
      const DiagnosticBuilder &BaseDiag = Diag;
1356
834
      BaseDiag << Value;
1357
834
      return Diag;
1358
834
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<clang::DeclarationName>(clang::Sema::SemaDiagnosticBuilder const&, clang::DeclarationName const&)
Line
Count
Source
1354
130k
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
130k
      const DiagnosticBuilder &BaseDiag = Diag;
1356
130k
      BaseDiag << Value;
1357
130k
      return Diag;
1358
130k
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<clang::DeclContext*>(clang::Sema::SemaDiagnosticBuilder const&, clang::DeclContext* const&)
Line
Count
Source
1354
32.1k
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
32.1k
      const DiagnosticBuilder &BaseDiag = Diag;
1356
32.1k
      BaseDiag << Value;
1357
32.1k
      return Diag;
1358
32.1k
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<unsigned int>(clang::Sema::SemaDiagnosticBuilder const&, unsigned int const&)
Line
Count
Source
1354
35.3k
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
35.3k
      const DiagnosticBuilder &BaseDiag = Diag;
1356
35.3k
      BaseDiag << Value;
1357
35.3k
      return Diag;
1358
35.3k
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<llvm::StringRef>(clang::Sema::SemaDiagnosticBuilder const&, llvm::StringRef const&)
Line
Count
Source
1354
8.98k
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
8.98k
      const DiagnosticBuilder &BaseDiag = Diag;
1356
8.98k
      BaseDiag << Value;
1357
8.98k
      return Diag;
1358
8.98k
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<bool>(clang::Sema::SemaDiagnosticBuilder const&, bool const&)
Line
Count
Source
1354
79.1k
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
79.1k
      const DiagnosticBuilder &BaseDiag = Diag;
1356
79.1k
      BaseDiag << Value;
1357
79.1k
      return Diag;
1358
79.1k
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<clang::NamedDecl const*>(clang::Sema::SemaDiagnosticBuilder const&, clang::NamedDecl const* const&)
Line
Count
Source
1354
35.5k
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
35.5k
      const DiagnosticBuilder &BaseDiag = Diag;
1356
35.5k
      BaseDiag << Value;
1357
35.5k
      return Diag;
1358
35.5k
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<char const*>(clang::Sema::SemaDiagnosticBuilder const&, char const* const&)
Line
Count
Source
1354
31.9k
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
31.9k
      const DiagnosticBuilder &BaseDiag = Diag;
1356
31.9k
      BaseDiag << Value;
1357
31.9k
      return Diag;
1358
31.9k
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<char [9]>(clang::Sema::SemaDiagnosticBuilder const&, char const (&) [9])
Line
Count
Source
1354
21.9k
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
21.9k
      const DiagnosticBuilder &BaseDiag = Diag;
1356
21.9k
      BaseDiag << Value;
1357
21.9k
      return Diag;
1358
21.9k
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<llvm::SmallString<32u> >(clang::Sema::SemaDiagnosticBuilder const&, llvm::SmallString<32u> const&)
Line
Count
Source
1354
212
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
212
      const DiagnosticBuilder &BaseDiag = Diag;
1356
212
      BaseDiag << Value;
1357
212
      return Diag;
1358
212
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<clang::IdentifierInfo*>(clang::Sema::SemaDiagnosticBuilder const&, clang::IdentifierInfo* const&)
Line
Count
Source
1354
5.66k
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
5.66k
      const DiagnosticBuilder &BaseDiag = Diag;
1356
5.66k
      BaseDiag << Value;
1357
5.66k
      return Diag;
1358
5.66k
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<char [17]>(clang::Sema::SemaDiagnosticBuilder const&, char const (&) [17])
Line
Count
Source
1354
26
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
26
      const DiagnosticBuilder &BaseDiag = Diag;
1356
26
      BaseDiag << Value;
1357
26
      return Diag;
1358
26
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<clang::ParsedAttr>(clang::Sema::SemaDiagnosticBuilder const&, clang::ParsedAttr const&)
Line
Count
Source
1354
2.49k
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
2.49k
      const DiagnosticBuilder &BaseDiag = Diag;
1356
2.49k
      BaseDiag << Value;
1357
2.49k
      return Diag;
1358
2.49k
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<char [10]>(clang::Sema::SemaDiagnosticBuilder const&, char const (&) [10])
Line
Count
Source
1354
276
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
276
      const DiagnosticBuilder &BaseDiag = Diag;
1356
276
      BaseDiag << Value;
1357
276
      return Diag;
1358
276
    }
Unexecuted instantiation: clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<char [46]>(clang::Sema::SemaDiagnosticBuilder const&, char const (&) [46])
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<char [45]>(clang::Sema::SemaDiagnosticBuilder const&, char const (&) [45])
Line
Count
Source
1354
90
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
90
      const DiagnosticBuilder &BaseDiag = Diag;
1356
90
      BaseDiag << Value;
1357
90
      return Diag;
1358
90
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<char [31]>(clang::Sema::SemaDiagnosticBuilder const&, char const (&) [31])
Line
Count
Source
1354
12
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
12
      const DiagnosticBuilder &BaseDiag = Diag;
1356
12
      BaseDiag << Value;
1357
12
      return Diag;
1358
12
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<char [23]>(clang::Sema::SemaDiagnosticBuilder const&, char const (&) [23])
Line
Count
Source
1354
18
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
18
      const DiagnosticBuilder &BaseDiag = Diag;
1356
18
      BaseDiag << Value;
1357
18
      return Diag;
1358
18
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<char [24]>(clang::Sema::SemaDiagnosticBuilder const&, char const (&) [24])
Line
Count
Source
1354
9
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
9
      const DiagnosticBuilder &BaseDiag = Diag;
1356
9
      BaseDiag << Value;
1357
9
      return Diag;
1358
9
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<char [32]>(clang::Sema::SemaDiagnosticBuilder const&, char const (&) [32])
Line
Count
Source
1354
3
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
3
      const DiagnosticBuilder &BaseDiag = Diag;
1356
3
      BaseDiag << Value;
1357
3
      return Diag;
1358
3
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<char [34]>(clang::Sema::SemaDiagnosticBuilder const&, char const (&) [34])
Line
Count
Source
1354
37
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
37
      const DiagnosticBuilder &BaseDiag = Diag;
1356
37
      BaseDiag << Value;
1357
37
      return Diag;
1358
37
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<char [19]>(clang::Sema::SemaDiagnosticBuilder const&, char const (&) [19])
Line
Count
Source
1354
44
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
44
      const DiagnosticBuilder &BaseDiag = Diag;
1356
44
      BaseDiag << Value;
1357
44
      return Diag;
1358
44
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<char [11]>(clang::Sema::SemaDiagnosticBuilder const&, char const (&) [11])
Line
Count
Source
1354
21
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
21
      const DiagnosticBuilder &BaseDiag = Diag;
1356
21
      BaseDiag << Value;
1357
21
      return Diag;
1358
21
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<char [54]>(clang::Sema::SemaDiagnosticBuilder const&, char const (&) [54])
Line
Count
Source
1354
3
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
3
      const DiagnosticBuilder &BaseDiag = Diag;
1356
3
      BaseDiag << Value;
1357
3
      return Diag;
1358
3
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<char [39]>(clang::Sema::SemaDiagnosticBuilder const&, char const (&) [39])
Line
Count
Source
1354
4
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
4
      const DiagnosticBuilder &BaseDiag = Diag;
1356
4
      BaseDiag << Value;
1357
4
      return Diag;
1358
4
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<char [47]>(clang::Sema::SemaDiagnosticBuilder const&, char const (&) [47])
Line
Count
Source
1354
5
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
5
      const DiagnosticBuilder &BaseDiag = Diag;
1356
5
      BaseDiag << Value;
1357
5
      return Diag;
1358
5
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<char [16]>(clang::Sema::SemaDiagnosticBuilder const&, char const (&) [16])
Line
Count
Source
1354
21
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
21
      const DiagnosticBuilder &BaseDiag = Diag;
1356
21
      BaseDiag << Value;
1357
21
      return Diag;
1358
21
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<char [22]>(clang::Sema::SemaDiagnosticBuilder const&, char const (&) [22])
Line
Count
Source
1354
7
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
7
      const DiagnosticBuilder &BaseDiag = Diag;
1356
7
      BaseDiag << Value;
1357
7
      return Diag;
1358
7
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<char [8]>(clang::Sema::SemaDiagnosticBuilder const&, char const (&) [8])
Line
Count
Source
1354
41
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
41
      const DiagnosticBuilder &BaseDiag = Diag;
1356
41
      BaseDiag << Value;
1357
41
      return Diag;
1358
41
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<char [58]>(clang::Sema::SemaDiagnosticBuilder const&, char const (&) [58])
Line
Count
Source
1354
142
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
142
      const DiagnosticBuilder &BaseDiag = Diag;
1356
142
      BaseDiag << Value;
1357
142
      return Diag;
1358
142
    }
Unexecuted instantiation: clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<char [59]>(clang::Sema::SemaDiagnosticBuilder const&, char const (&) [59])
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<char [6]>(clang::Sema::SemaDiagnosticBuilder const&, char const (&) [6])
Line
Count
Source
1354
4.48k
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
4.48k
      const DiagnosticBuilder &BaseDiag = Diag;
1356
4.48k
      BaseDiag << Value;
1357
4.48k
      return Diag;
1358
4.48k
    }
Unexecuted instantiation: clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<char [57]>(clang::Sema::SemaDiagnosticBuilder const&, char const (&) [57])
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<char [48]>(clang::Sema::SemaDiagnosticBuilder const&, char const (&) [48])
Line
Count
Source
1354
3
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
3
      const DiagnosticBuilder &BaseDiag = Diag;
1356
3
      BaseDiag << Value;
1357
3
      return Diag;
1358
3
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<char [29]>(clang::Sema::SemaDiagnosticBuilder const&, char const (&) [29])
Line
Count
Source
1354
58
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
58
      const DiagnosticBuilder &BaseDiag = Diag;
1356
58
      BaseDiag << Value;
1357
58
      return Diag;
1358
58
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<char [42]>(clang::Sema::SemaDiagnosticBuilder const&, char const (&) [42])
Line
Count
Source
1354
1
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
1
      const DiagnosticBuilder &BaseDiag = Diag;
1356
1
      BaseDiag << Value;
1357
1
      return Diag;
1358
1
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<char [43]>(clang::Sema::SemaDiagnosticBuilder const&, char const (&) [43])
Line
Count
Source
1354
1
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
1
      const DiagnosticBuilder &BaseDiag = Diag;
1356
1
      BaseDiag << Value;
1357
1
      return Diag;
1358
1
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<char [56]>(clang::Sema::SemaDiagnosticBuilder const&, char const (&) [56])
Line
Count
Source
1354
15
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
15
      const DiagnosticBuilder &BaseDiag = Diag;
1356
15
      BaseDiag << Value;
1357
15
      return Diag;
1358
15
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<char [20]>(clang::Sema::SemaDiagnosticBuilder const&, char const (&) [20])
Line
Count
Source
1354
1
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
1
      const DiagnosticBuilder &BaseDiag = Diag;
1356
1
      BaseDiag << Value;
1357
1
      return Diag;
1358
1
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<char [75]>(clang::Sema::SemaDiagnosticBuilder const&, char const (&) [75])
Line
Count
Source
1354
1
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
1
      const DiagnosticBuilder &BaseDiag = Diag;
1356
1
      BaseDiag << Value;
1357
1
      return Diag;
1358
1
    }
Unexecuted instantiation: clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<char [53]>(clang::Sema::SemaDiagnosticBuilder const&, char const (&) [53])
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<char [38]>(clang::Sema::SemaDiagnosticBuilder const&, char const (&) [38])
Line
Count
Source
1354
12
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
12
      const DiagnosticBuilder &BaseDiag = Diag;
1356
12
      BaseDiag << Value;
1357
12
      return Diag;
1358
12
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<char [35]>(clang::Sema::SemaDiagnosticBuilder const&, char const (&) [35])
Line
Count
Source
1354
2
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
2
      const DiagnosticBuilder &BaseDiag = Diag;
1356
2
      BaseDiag << Value;
1357
2
      return Diag;
1358
2
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<char [28]>(clang::Sema::SemaDiagnosticBuilder const&, char const (&) [28])
Line
Count
Source
1354
2
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
2
      const DiagnosticBuilder &BaseDiag = Diag;
1356
2
      BaseDiag << Value;
1357
2
      return Diag;
1358
2
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<char [71]>(clang::Sema::SemaDiagnosticBuilder const&, char const (&) [71])
Line
Count
Source
1354
4
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
4
      const DiagnosticBuilder &BaseDiag = Diag;
1356
4
      BaseDiag << Value;
1357
4
      return Diag;
1358
4
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<char [67]>(clang::Sema::SemaDiagnosticBuilder const&, char const (&) [67])
Line
Count
Source
1354
3
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
3
      const DiagnosticBuilder &BaseDiag = Diag;
1356
3
      BaseDiag << Value;
1357
3
      return Diag;
1358
3
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<char [49]>(clang::Sema::SemaDiagnosticBuilder const&, char const (&) [49])
Line
Count
Source
1354
5
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
5
      const DiagnosticBuilder &BaseDiag = Diag;
1356
5
      BaseDiag << Value;
1357
5
      return Diag;
1358
5
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<char [25]>(clang::Sema::SemaDiagnosticBuilder const&, char const (&) [25])
Line
Count
Source
1354
1
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
1
      const DiagnosticBuilder &BaseDiag = Diag;
1356
1
      BaseDiag << Value;
1357
1
      return Diag;
1358
1
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<char [77]>(clang::Sema::SemaDiagnosticBuilder const&, char const (&) [77])
Line
Count
Source
1354
4
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
4
      const DiagnosticBuilder &BaseDiag = Diag;
1356
4
      BaseDiag << Value;
1357
4
      return Diag;
1358
4
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<char [150]>(clang::Sema::SemaDiagnosticBuilder const&, char const (&) [150])
Line
Count
Source
1354
1
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
1
      const DiagnosticBuilder &BaseDiag = Diag;
1356
1
      BaseDiag << Value;
1357
1
      return Diag;
1358
1
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<char [69]>(clang::Sema::SemaDiagnosticBuilder const&, char const (&) [69])
Line
Count
Source
1354
2
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
2
      const DiagnosticBuilder &BaseDiag = Diag;
1356
2
      BaseDiag << Value;
1357
2
      return Diag;
1358
2
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<char [36]>(clang::Sema::SemaDiagnosticBuilder const&, char const (&) [36])
Line
Count
Source
1354
8
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
8
      const DiagnosticBuilder &BaseDiag = Diag;
1356
8
      BaseDiag << Value;
1357
8
      return Diag;
1358
8
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<char [87]>(clang::Sema::SemaDiagnosticBuilder const&, char const (&) [87])
Line
Count
Source
1354
3
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
3
      const DiagnosticBuilder &BaseDiag = Diag;
1356
3
      BaseDiag << Value;
1357
3
      return Diag;
1358
3
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<clang::ValueDecl*>(clang::Sema::SemaDiagnosticBuilder const&, clang::ValueDecl* const&)
Line
Count
Source
1354
4.12k
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
4.12k
      const DiagnosticBuilder &BaseDiag = Diag;
1356
4.12k
      BaseDiag << Value;
1357
4.12k
      return Diag;
1358
4.12k
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<char [7]>(clang::Sema::SemaDiagnosticBuilder const&, char const (&) [7])
Line
Count
Source
1354
155
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
155
      const DiagnosticBuilder &BaseDiag = Diag;
1356
155
      BaseDiag << Value;
1357
155
      return Diag;
1358
155
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<clang::AttributeDeclKind>(clang::Sema::SemaDiagnosticBuilder const&, clang::AttributeDeclKind const&)
Line
Count
Source
1354
68
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
68
      const DiagnosticBuilder &BaseDiag = Diag;
1356
68
      BaseDiag << Value;
1357
68
      return Diag;
1358
68
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >(clang::Sema::SemaDiagnosticBuilder const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)
Line
Count
Source
1354
126k
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
126k
      const DiagnosticBuilder &BaseDiag = Diag;
1356
126k
      BaseDiag << Value;
1357
126k
      return Diag;
1358
126k
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<clang::NamedDecl*>(clang::Sema::SemaDiagnosticBuilder const&, clang::NamedDecl* const&)
Line
Count
Source
1354
5.41k
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
5.41k
      const DiagnosticBuilder &BaseDiag = Diag;
1356
5.41k
      BaseDiag << Value;
1357
5.41k
      return Diag;
1358
5.41k
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<clang::AccessSpecifier>(clang::Sema::SemaDiagnosticBuilder const&, clang::AccessSpecifier const&)
Line
Count
Source
1354
16
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
16
      const DiagnosticBuilder &BaseDiag = Diag;
1356
16
      BaseDiag << Value;
1357
16
      return Diag;
1358
16
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<char [12]>(clang::Sema::SemaDiagnosticBuilder const&, char const (&) [12])
Line
Count
Source
1354
202
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
202
      const DiagnosticBuilder &BaseDiag = Diag;
1356
202
      BaseDiag << Value;
1357
202
      return Diag;
1358
202
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<char [5]>(clang::Sema::SemaDiagnosticBuilder const&, char const (&) [5])
Line
Count
Source
1354
100
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
100
      const DiagnosticBuilder &BaseDiag = Diag;
1356
100
      BaseDiag << Value;
1357
100
      return Diag;
1358
100
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<clang::DeclaratorDecl*>(clang::Sema::SemaDiagnosticBuilder const&, clang::DeclaratorDecl* const&)
Line
Count
Source
1354
6
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
6
      const DiagnosticBuilder &BaseDiag = Diag;
1356
6
      BaseDiag << Value;
1357
6
      return Diag;
1358
6
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<clang::IdentifierInfo const*>(clang::Sema::SemaDiagnosticBuilder const&, clang::IdentifierInfo const* const&)
Line
Count
Source
1354
321
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
321
      const DiagnosticBuilder &BaseDiag = Diag;
1356
321
      BaseDiag << Value;
1357
321
      return Diag;
1358
321
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<clang::CXXRecordDecl*>(clang::Sema::SemaDiagnosticBuilder const&, clang::CXXRecordDecl* const&)
Line
Count
Source
1354
10.1k
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
10.1k
      const DiagnosticBuilder &BaseDiag = Diag;
1356
10.1k
      BaseDiag << Value;
1357
10.1k
      return Diag;
1358
10.1k
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<clang::TemplateName>(clang::Sema::SemaDiagnosticBuilder const&, clang::TemplateName const&)
Line
Count
Source
1354
226
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
226
      const DiagnosticBuilder &BaseDiag = Diag;
1356
226
      BaseDiag << Value;
1357
226
      return Diag;
1358
226
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<CastType>(clang::Sema::SemaDiagnosticBuilder const&, CastType const&)
Line
Count
Source
1354
387
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
387
      const DiagnosticBuilder &BaseDiag = Diag;
1356
387
      BaseDiag << Value;
1357
387
      return Diag;
1358
387
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<clang::FunctionDecl*>(clang::Sema::SemaDiagnosticBuilder const&, clang::FunctionDecl* const&)
Line
Count
Source
1354
108k
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
108k
      const DiagnosticBuilder &BaseDiag = Diag;
1356
108k
      BaseDiag << Value;
1357
108k
      return Diag;
1358
108k
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<clang::Sema::AssignmentAction>(clang::Sema::SemaDiagnosticBuilder const&, clang::Sema::AssignmentAction const&)
Line
Count
Source
1354
84
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
84
      const DiagnosticBuilder &BaseDiag = Diag;
1356
84
      BaseDiag << Value;
1357
84
      return Diag;
1358
84
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<char [13]>(clang::Sema::SemaDiagnosticBuilder const&, char const (&) [13])
Line
Count
Source
1354
2
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
2
      const DiagnosticBuilder &BaseDiag = Diag;
1356
2
      BaseDiag << Value;
1357
2
      return Diag;
1358
2
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<clang::CanQual<clang::Type> >(clang::Sema::SemaDiagnosticBuilder const&, clang::CanQual<clang::Type> const&)
Line
Count
Source
1354
59
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
59
      const DiagnosticBuilder &BaseDiag = Diag;
1356
59
      BaseDiag << Value;
1357
59
      return Diag;
1358
59
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<clang::Expr*>(clang::Sema::SemaDiagnosticBuilder const&, clang::Expr* const&)
Line
Count
Source
1354
44
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
44
      const DiagnosticBuilder &BaseDiag = Diag;
1356
44
      BaseDiag << Value;
1357
44
      return Diag;
1358
44
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<char [37]>(clang::Sema::SemaDiagnosticBuilder const&, char const (&) [37])
Line
Count
Source
1354
4
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
4
      const DiagnosticBuilder &BaseDiag = Diag;
1356
4
      BaseDiag << Value;
1357
4
      return Diag;
1358
4
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<llvm::SmallString<16u> >(clang::Sema::SemaDiagnosticBuilder const&, llvm::SmallString<16u> const&)
Line
Count
Source
1354
179
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
179
      const DiagnosticBuilder &BaseDiag = Diag;
1356
179
      BaseDiag << Value;
1357
179
      return Diag;
1358
179
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<char [3]>(clang::Sema::SemaDiagnosticBuilder const&, char const (&) [3])
Line
Count
Source
1354
156
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
156
      const DiagnosticBuilder &BaseDiag = Diag;
1356
156
      BaseDiag << Value;
1357
156
      return Diag;
1358
156
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<llvm::ArrayRef<clang::FixItHint> >(clang::Sema::SemaDiagnosticBuilder const&, llvm::ArrayRef<clang::FixItHint> const&)
Line
Count
Source
1354
2.20k
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
2.20k
      const DiagnosticBuilder &BaseDiag = Diag;
1356
2.20k
      BaseDiag << Value;
1357
2.20k
      return Diag;
1358
2.20k
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<clang::CharSourceRange>(clang::Sema::SemaDiagnosticBuilder const&, clang::CharSourceRange const&)
Line
Count
Source
1354
2.09k
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
2.09k
      const DiagnosticBuilder &BaseDiag = Diag;
1356
2.09k
      BaseDiag << Value;
1357
2.09k
      return Diag;
1358
2.09k
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<clang::Sema::VariadicCallType>(clang::Sema::SemaDiagnosticBuilder const&, clang::Sema::VariadicCallType const&)
Line
Count
Source
1354
6
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
6
      const DiagnosticBuilder &BaseDiag = Diag;
1356
6
      BaseDiag << Value;
1357
6
      return Diag;
1358
6
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<clang::EnumDecl*>(clang::Sema::SemaDiagnosticBuilder const&, clang::EnumDecl* const&)
Line
Count
Source
1354
33
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
33
      const DiagnosticBuilder &BaseDiag = Diag;
1356
33
      BaseDiag << Value;
1357
33
      return Diag;
1358
33
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<clang::FieldDecl*>(clang::Sema::SemaDiagnosticBuilder const&, clang::FieldDecl* const&)
Line
Count
Source
1354
687
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
687
      const DiagnosticBuilder &BaseDiag = Diag;
1356
687
      BaseDiag << Value;
1357
687
      return Diag;
1358
687
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<clang::VarDecl*>(clang::Sema::SemaDiagnosticBuilder const&, clang::VarDecl* const&)
Line
Count
Source
1354
3.65k
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
3.65k
      const DiagnosticBuilder &BaseDiag = Diag;
1356
3.65k
      BaseDiag << Value;
1357
3.65k
      return Diag;
1358
3.65k
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<char [18]>(clang::Sema::SemaDiagnosticBuilder const&, char const (&) [18])
Line
Count
Source
1354
13
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
13
      const DiagnosticBuilder &BaseDiag = Diag;
1356
13
      BaseDiag << Value;
1357
13
      return Diag;
1358
13
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<AbsoluteValueKind>(clang::Sema::SemaDiagnosticBuilder const&, AbsoluteValueKind const&)
Line
Count
Source
1354
792
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
792
      const DiagnosticBuilder &BaseDiag = Diag;
1356
792
      BaseDiag << Value;
1357
792
      return Diag;
1358
792
    }
SemaChecking.cpp:clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<clang::Sema::DiagnoseAlwaysNonNullPointer(clang::Expr*, clang::Expr::NullPointerConstantKind, bool, clang::SourceRange)::$_10>(clang::Sema::SemaDiagnosticBuilder const&, clang::Sema::DiagnoseAlwaysNonNullPointer(clang::Expr*, clang::Expr::NullPointerConstantKind, bool, clang::SourceRange)::$_10 const&)
Line
Count
Source
1354
213
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
213
      const DiagnosticBuilder &BaseDiag = Diag;
1356
213
      BaseDiag << Value;
1357
213
      return Diag;
1358
213
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<clang::ObjCIvarDecl*>(clang::Sema::SemaDiagnosticBuilder const&, clang::ObjCIvarDecl* const&)
Line
Count
Source
1354
46
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
46
      const DiagnosticBuilder &BaseDiag = Diag;
1356
46
      BaseDiag << Value;
1357
46
      return Diag;
1358
46
    }
SemaCoroutine.cpp:clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<isValidCoroutineContext(clang::Sema&, clang::SourceLocation, llvm::StringRef)::InvalidFuncDiag>(clang::Sema::SemaDiagnosticBuilder const&, isValidCoroutineContext(clang::Sema&, clang::SourceLocation, llvm::StringRef)::InvalidFuncDiag const&)
Line
Count
Source
1354
9
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
9
      const DiagnosticBuilder &BaseDiag = Diag;
1356
9
      BaseDiag << Value;
1357
9
      return Diag;
1358
9
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<clang::CXXMethodDecl*>(clang::Sema::SemaDiagnosticBuilder const&, clang::CXXMethodDecl* const&)
Line
Count
Source
1354
10
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
10
      const DiagnosticBuilder &BaseDiag = Diag;
1356
10
      BaseDiag << Value;
1357
10
      return Diag;
1358
10
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<clang::Sema::CUDAFunctionTarget>(clang::Sema::SemaDiagnosticBuilder const&, clang::Sema::CUDAFunctionTarget const&)
Line
Count
Source
1354
442
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
442
      const DiagnosticBuilder &BaseDiag = Diag;
1356
442
      BaseDiag << Value;
1357
442
      return Diag;
1358
442
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<clang::AlignedAttr const*>(clang::Sema::SemaDiagnosticBuilder const&, clang::AlignedAttr const* const&)
Line
Count
Source
1354
8
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
8
      const DiagnosticBuilder &BaseDiag = Diag;
1356
8
      BaseDiag << Value;
1357
8
      return Diag;
1358
8
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<clang::AlignedAttr*>(clang::Sema::SemaDiagnosticBuilder const&, clang::AlignedAttr* const&)
Line
Count
Source
1354
23
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
23
      const DiagnosticBuilder &BaseDiag = Diag;
1356
23
      BaseDiag << Value;
1357
23
      return Diag;
1358
23
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<std::__1::pair<clang::NullabilityKind, bool> >(clang::Sema::SemaDiagnosticBuilder const&, std::__1::pair<clang::NullabilityKind, bool> const&)
Line
Count
Source
1354
117
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
117
      const DiagnosticBuilder &BaseDiag = Diag;
1356
117
      BaseDiag << Value;
1357
117
      return Diag;
1358
117
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<clang::Attr const*>(clang::Sema::SemaDiagnosticBuilder const&, clang::Attr const* const&)
Line
Count
Source
1354
429
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
429
      const DiagnosticBuilder &BaseDiag = Diag;
1356
429
      BaseDiag << Value;
1357
429
      return Diag;
1358
429
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<clang::DLLImportAttr const*>(clang::Sema::SemaDiagnosticBuilder const&, clang::DLLImportAttr const* const&)
Line
Count
Source
1354
366
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
366
      const DiagnosticBuilder &BaseDiag = Diag;
1356
366
      BaseDiag << Value;
1357
366
      return Diag;
1358
366
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<clang::NotTailCalledAttr*>(clang::Sema::SemaDiagnosticBuilder const&, clang::NotTailCalledAttr* const&)
Line
Count
Source
1354
2
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
2
      const DiagnosticBuilder &BaseDiag = Diag;
1356
2
      BaseDiag << Value;
1357
2
      return Diag;
1358
2
    }
SemaDecl.cpp:clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<CheckMultiVersionValue(clang::Sema&, clang::FunctionDecl const*)::ErrType>(clang::Sema::SemaDiagnosticBuilder const&, CheckMultiVersionValue(clang::Sema&, clang::FunctionDecl const*)::ErrType const&)
Line
Count
Source
1354
1
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
1
      const DiagnosticBuilder &BaseDiag = Diag;
1356
1
      BaseDiag << Value;
1357
1
      return Diag;
1358
1
    }
SemaDecl.cpp:clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<CheckMultiVersionAdditionalRules(clang::Sema&, clang::FunctionDecl const*, clang::FunctionDecl const*, bool, clang::MultiVersionKind)::DoesntSupport>(clang::Sema::SemaDiagnosticBuilder const&, CheckMultiVersionAdditionalRules(clang::Sema&, clang::FunctionDecl const*, clang::FunctionDecl const*, bool, clang::MultiVersionKind)::DoesntSupport const&)
Line
Count
Source
1354
21
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
21
      const DiagnosticBuilder &BaseDiag = Diag;
1356
21
      BaseDiag << Value;
1357
21
      return Diag;
1358
21
    }
SemaDecl.cpp:clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<CheckMultiVersionAdditionalRules(clang::Sema&, clang::FunctionDecl const*, clang::FunctionDecl const*, bool, clang::MultiVersionKind)::Different>(clang::Sema::SemaDiagnosticBuilder const&, CheckMultiVersionAdditionalRules(clang::Sema&, clang::FunctionDecl const*, clang::FunctionDecl const*, bool, clang::MultiVersionKind)::Different const&)
Line
Count
Source
1354
19
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
19
      const DiagnosticBuilder &BaseDiag = Diag;
1356
19
      BaseDiag << Value;
1357
19
      return Diag;
1358
19
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<clang::CXXRecordDecl const*>(clang::Sema::SemaDiagnosticBuilder const&, clang::CXXRecordDecl const* const&)
Line
Count
Source
1354
182
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
182
      const DiagnosticBuilder &BaseDiag = Diag;
1356
182
      BaseDiag << Value;
1357
182
      return Diag;
1358
182
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<clang::NestedNameSpecifier*>(clang::Sema::SemaDiagnosticBuilder const&, clang::NestedNameSpecifier* const&)
Line
Count
Source
1354
361
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
361
      const DiagnosticBuilder &BaseDiag = Diag;
1356
361
      BaseDiag << Value;
1357
361
      return Diag;
1358
361
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<clang::FieldDecl const*>(clang::Sema::SemaDiagnosticBuilder const&, clang::FieldDecl const* const&)
Line
Count
Source
1354
126
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
126
      const DiagnosticBuilder &BaseDiag = Diag;
1356
126
      BaseDiag << Value;
1357
126
      return Diag;
1358
126
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<clang::RecordDecl const*>(clang::Sema::SemaDiagnosticBuilder const&, clang::RecordDecl const* const&)
Line
Count
Source
1354
4
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
4
      const DiagnosticBuilder &BaseDiag = Diag;
1356
4
      BaseDiag << Value;
1357
4
      return Diag;
1358
4
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<clang::AnyX86NoCallerSavedRegistersAttr*>(clang::Sema::SemaDiagnosticBuilder const&, clang::AnyX86NoCallerSavedRegistersAttr* const&)
Line
Count
Source
1354
1
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
1
      const DiagnosticBuilder &BaseDiag = Diag;
1356
1
      BaseDiag << Value;
1357
1
      return Diag;
1358
1
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<clang::Sema::CXXSpecialMember>(clang::Sema::SemaDiagnosticBuilder const&, clang::Sema::CXXSpecialMember const&)
Line
Count
Source
1354
1.14k
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
1.14k
      const DiagnosticBuilder &BaseDiag = Diag;
1356
1.14k
      BaseDiag << Value;
1357
1.14k
      return Diag;
1358
1.14k
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<clang::TagTypeKind>(clang::Sema::SemaDiagnosticBuilder const&, clang::TagTypeKind const&)
Line
Count
Source
1354
331
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
331
      const DiagnosticBuilder &BaseDiag = Diag;
1356
331
      BaseDiag << Value;
1357
331
      return Diag;
1358
331
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<clang::InheritableAttr const*>(clang::Sema::SemaDiagnosticBuilder const&, clang::InheritableAttr const* const&)
Line
Count
Source
1354
225
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
225
      const DiagnosticBuilder &BaseDiag = Diag;
1356
225
      BaseDiag << Value;
1357
225
      return Diag;
1358
225
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<ShadowedDeclKind>(clang::Sema::SemaDiagnosticBuilder const&, ShadowedDeclKind const&)
Line
Count
Source
1354
185
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
185
      const DiagnosticBuilder &BaseDiag = Diag;
1356
185
      BaseDiag << Value;
1357
185
      return Diag;
1358
185
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<clang::DeclContext const*>(clang::Sema::SemaDiagnosticBuilder const&, clang::DeclContext const* const&)
Line
Count
Source
1354
52
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
52
      const DiagnosticBuilder &BaseDiag = Diag;
1356
52
      BaseDiag << Value;
1357
52
      return Diag;
1358
52
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<clang::VarDecl const*>(clang::Sema::SemaDiagnosticBuilder const&, clang::VarDecl const* const&)
Line
Count
Source
1354
87
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
87
      const DiagnosticBuilder &BaseDiag = Diag;
1356
87
      BaseDiag << Value;
1357
87
      return Diag;
1358
87
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<clang::StorageClass>(clang::Sema::SemaDiagnosticBuilder const&, clang::StorageClass const&)
Line
Count
Source
1354
1
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
1
      const DiagnosticBuilder &BaseDiag = Diag;
1356
1
      BaseDiag << Value;
1357
1
      return Diag;
1358
1
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<clang::Sema::NonTrivialCUnionContext>(clang::Sema::SemaDiagnosticBuilder const&, clang::Sema::NonTrivialCUnionContext const&)
Line
Count
Source
1354
79
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
79
      const DiagnosticBuilder &BaseDiag = Diag;
1356
79
      BaseDiag << Value;
1357
79
      return Diag;
1358
79
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<char [1]>(clang::Sema::SemaDiagnosticBuilder const&, char const (&) [1])
Line
Count
Source
1354
102
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
102
      const DiagnosticBuilder &BaseDiag = Diag;
1356
102
      BaseDiag << Value;
1357
102
      return Diag;
1358
102
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<clang::UsedAttr*>(clang::Sema::SemaDiagnosticBuilder const&, clang::UsedAttr* const&)
Line
Count
Source
1354
4
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
4
      const DiagnosticBuilder &BaseDiag = Diag;
1356
4
      BaseDiag << Value;
1357
4
      return Diag;
1358
4
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<clang::Sema::NonTagKind>(clang::Sema::SemaDiagnosticBuilder const&, clang::Sema::NonTagKind const&)
Line
Count
Source
1354
35
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
35
      const DiagnosticBuilder &BaseDiag = Diag;
1356
35
      BaseDiag << Value;
1357
35
      return Diag;
1358
35
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<clang::TagDecl*>(clang::Sema::SemaDiagnosticBuilder const&, clang::TagDecl* const&)
Line
Count
Source
1354
9
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
9
      const DiagnosticBuilder &BaseDiag = Diag;
1356
9
      BaseDiag << Value;
1357
9
      return Diag;
1358
9
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<clang::RecordDecl*>(clang::Sema::SemaDiagnosticBuilder const&, clang::RecordDecl* const&)
Line
Count
Source
1354
21
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
21
      const DiagnosticBuilder &BaseDiag = Diag;
1356
21
      BaseDiag << Value;
1357
21
      return Diag;
1358
21
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<clang::EnumConstantDecl*>(clang::Sema::SemaDiagnosticBuilder const&, clang::EnumConstantDecl* const&)
Line
Count
Source
1354
24
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
24
      const DiagnosticBuilder &BaseDiag = Diag;
1356
24
      BaseDiag << Value;
1357
24
      return Diag;
1358
24
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<clang::CUDALaunchBoundsAttr const*>(clang::Sema::SemaDiagnosticBuilder const&, clang::CUDALaunchBoundsAttr const* const&)
Line
Count
Source
1354
7
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
7
      const DiagnosticBuilder &BaseDiag = Diag;
1356
7
      BaseDiag << Value;
1357
7
      return Diag;
1358
7
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<clang::Mips16Attr const*>(clang::Sema::SemaDiagnosticBuilder const&, clang::Mips16Attr const* const&)
Line
Count
Source
1354
4
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
4
      const DiagnosticBuilder &BaseDiag = Diag;
1356
4
      BaseDiag << Value;
1357
4
      return Diag;
1358
4
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<clang::MicroMipsAttr const*>(clang::Sema::SemaDiagnosticBuilder const&, clang::MicroMipsAttr const* const&)
Line
Count
Source
1354
1
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
1
      const DiagnosticBuilder &BaseDiag = Diag;
1356
1
      BaseDiag << Value;
1357
1
      return Diag;
1358
1
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<clang::MipsInterruptAttr const*>(clang::Sema::SemaDiagnosticBuilder const&, clang::MipsInterruptAttr const* const&)
Line
Count
Source
1354
2
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
2
      const DiagnosticBuilder &BaseDiag = Diag;
1356
2
      BaseDiag << Value;
1357
2
      return Diag;
1358
2
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<clang::MipsShortCallAttr const*>(clang::Sema::SemaDiagnosticBuilder const&, clang::MipsShortCallAttr const* const&)
Line
Count
Source
1354
2
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
2
      const DiagnosticBuilder &BaseDiag = Diag;
1356
2
      BaseDiag << Value;
1357
2
      return Diag;
1358
2
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<clang::MipsLongCallAttr const*>(clang::Sema::SemaDiagnosticBuilder const&, clang::MipsLongCallAttr const* const&)
Line
Count
Source
1354
2
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
2
      const DiagnosticBuilder &BaseDiag = Diag;
1356
2
      BaseDiag << Value;
1357
2
      return Diag;
1358
2
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<char [14]>(clang::Sema::SemaDiagnosticBuilder const&, char const (&) [14])
Line
Count
Source
1354
10
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
10
      const DiagnosticBuilder &BaseDiag = Diag;
1356
10
      BaseDiag << Value;
1357
10
      return Diag;
1358
10
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<clang::ParsedAttr const*>(clang::Sema::SemaDiagnosticBuilder const&, clang::ParsedAttr const* const&)
Line
Count
Source
1354
69
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
69
      const DiagnosticBuilder &BaseDiag = Diag;
1356
69
      BaseDiag << Value;
1357
69
      return Diag;
1358
69
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<clang::NotTailCalledAttr const*>(clang::Sema::SemaDiagnosticBuilder const&, clang::NotTailCalledAttr const* const&)
Line
Count
Source
1354
1
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
1
      const DiagnosticBuilder &BaseDiag = Diag;
1356
1
      BaseDiag << Value;
1357
1
      return Diag;
1358
1
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<AttributeLangSupport::LANG>(clang::Sema::SemaDiagnosticBuilder const&, AttributeLangSupport::LANG const&)
Line
Count
Source
1354
3
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
3
      const DiagnosticBuilder &BaseDiag = Diag;
1356
3
      BaseDiag << Value;
1357
3
      return Diag;
1358
3
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<clang::CUDASharedAttr const*>(clang::Sema::SemaDiagnosticBuilder const&, clang::CUDASharedAttr const* const&)
Line
Count
Source
1354
2
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
2
      const DiagnosticBuilder &BaseDiag = Diag;
1356
2
      BaseDiag << Value;
1357
2
      return Diag;
1358
2
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<clang::CUDADeviceAttr const*>(clang::Sema::SemaDiagnosticBuilder const&, clang::CUDADeviceAttr const* const&)
Line
Count
Source
1354
4
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
4
      const DiagnosticBuilder &BaseDiag = Diag;
1356
4
      BaseDiag << Value;
1357
4
      return Diag;
1358
4
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<clang::CUDAHostAttr const*>(clang::Sema::SemaDiagnosticBuilder const&, clang::CUDAHostAttr const* const&)
Line
Count
Source
1354
2
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
2
      const DiagnosticBuilder &BaseDiag = Diag;
1356
2
      BaseDiag << Value;
1357
2
      return Diag;
1358
2
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<clang::CXXMethodDecl const*>(clang::Sema::SemaDiagnosticBuilder const&, clang::CXXMethodDecl const* const&)
Line
Count
Source
1354
34
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
34
      const DiagnosticBuilder &BaseDiag = Diag;
1356
34
      BaseDiag << Value;
1357
34
      return Diag;
1358
34
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<clang::CUDAGlobalAttr const*>(clang::Sema::SemaDiagnosticBuilder const&, clang::CUDAGlobalAttr const* const&)
Line
Count
Source
1354
4
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
4
      const DiagnosticBuilder &BaseDiag = Diag;
1356
4
      BaseDiag << Value;
1357
4
      return Diag;
1358
4
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<clang::CUDAConstantAttr const*>(clang::Sema::SemaDiagnosticBuilder const&, clang::CUDAConstantAttr const* const&)
Line
Count
Source
1354
6
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
6
      const DiagnosticBuilder &BaseDiag = Diag;
1356
6
      BaseDiag << Value;
1357
6
      return Diag;
1358
6
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<clang::OwnershipAttr const*>(clang::Sema::SemaDiagnosticBuilder const&, clang::OwnershipAttr const* const&)
Line
Count
Source
1354
1
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
1
      const DiagnosticBuilder &BaseDiag = Diag;
1356
1
      BaseDiag << Value;
1357
1
      return Diag;
1358
1
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<clang::HotAttr const*>(clang::Sema::SemaDiagnosticBuilder const&, clang::HotAttr const* const&)
Line
Count
Source
1354
1
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
1
      const DiagnosticBuilder &BaseDiag = Diag;
1356
1
      BaseDiag << Value;
1357
1
      return Diag;
1358
1
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<clang::ColdAttr const*>(clang::Sema::SemaDiagnosticBuilder const&, clang::ColdAttr const* const&)
Line
Count
Source
1354
1
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
1
      const DiagnosticBuilder &BaseDiag = Diag;
1356
1
      BaseDiag << Value;
1357
1
      return Diag;
1358
1
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<clang::DisableTailCallsAttr const*>(clang::Sema::SemaDiagnosticBuilder const&, clang::DisableTailCallsAttr const* const&)
Line
Count
Source
1354
1
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
1
      const DiagnosticBuilder &BaseDiag = Diag;
1356
1
      BaseDiag << Value;
1357
1
      return Diag;
1358
1
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<clang::VecReturnAttr*>(clang::Sema::SemaDiagnosticBuilder const&, clang::VecReturnAttr* const&)
Line
Count
Source
1354
1
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
1
      const DiagnosticBuilder &BaseDiag = Diag;
1356
1
      BaseDiag << Value;
1357
1
      return Diag;
1358
1
    }
Unexecuted instantiation: clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<clang::CFUnknownTransferAttr const*>(clang::Sema::SemaDiagnosticBuilder const&, clang::CFUnknownTransferAttr const* const&)
Unexecuted instantiation: clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<clang::CFAuditedTransferAttr const*>(clang::Sema::SemaDiagnosticBuilder const&, clang::CFAuditedTransferAttr const* const&)
SemaDeclAttr.cpp:clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<handleXReturnsXRetainedAttr(clang::Sema&, clang::Decl*, clang::ParsedAttr const&)::$_0>(clang::Sema::SemaDiagnosticBuilder const&, handleXReturnsXRetainedAttr(clang::Sema&, clang::Decl*, clang::ParsedAttr const&)::$_0 const&)
Line
Count
Source
1354
13
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
13
      const DiagnosticBuilder &BaseDiag = Diag;
1356
13
      BaseDiag << Value;
1357
13
      return Diag;
1358
13
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<clang::NoSpeculativeLoadHardeningAttr const*>(clang::Sema::SemaDiagnosticBuilder const&, clang::NoSpeculativeLoadHardeningAttr const* const&)
Line
Count
Source
1354
3
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
3
      const DiagnosticBuilder &BaseDiag = Diag;
1356
3
      BaseDiag << Value;
1357
3
      return Diag;
1358
3
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<clang::SpeculativeLoadHardeningAttr const*>(clang::Sema::SemaDiagnosticBuilder const&, clang::SpeculativeLoadHardeningAttr const* const&)
Line
Count
Source
1354
3
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
3
      const DiagnosticBuilder &BaseDiag = Diag;
1356
3
      BaseDiag << Value;
1357
3
      return Diag;
1358
3
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<clang::AlwaysInlineAttr const*>(clang::Sema::SemaDiagnosticBuilder const&, clang::AlwaysInlineAttr const* const&)
Line
Count
Source
1354
1
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
1
      const DiagnosticBuilder &BaseDiag = Diag;
1356
1
      BaseDiag << Value;
1357
1
      return Diag;
1358
1
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<clang::NakedAttr const*>(clang::Sema::SemaDiagnosticBuilder const&, clang::NakedAttr const* const&)
Line
Count
Source
1354
1
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
1
      const DiagnosticBuilder &BaseDiag = Diag;
1356
1
      BaseDiag << Value;
1357
1
      return Diag;
1358
1
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<char [4]>(clang::Sema::SemaDiagnosticBuilder const&, char const (&) [4])
Line
Count
Source
1354
39
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
39
      const DiagnosticBuilder &BaseDiag = Diag;
1356
39
      BaseDiag << Value;
1357
39
      return Diag;
1358
39
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<clang::NoDestroyAttr const*>(clang::Sema::SemaDiagnosticBuilder const&, clang::NoDestroyAttr const* const&)
Line
Count
Source
1354
4
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
4
      const DiagnosticBuilder &BaseDiag = Diag;
1356
4
      BaseDiag << Value;
1357
4
      return Diag;
1358
4
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<clang::AlwaysDestroyAttr const*>(clang::Sema::SemaDiagnosticBuilder const&, clang::AlwaysDestroyAttr const* const&)
Line
Count
Source
1354
4
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
4
      const DiagnosticBuilder &BaseDiag = Diag;
1356
4
      BaseDiag << Value;
1357
4
      return Diag;
1358
4
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<llvm::SmallVector<clang::FixItHint, 12u> >(clang::Sema::SemaDiagnosticBuilder const&, llvm::SmallVector<clang::FixItHint, 12u> const&)
Line
Count
Source
1354
3.49k
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
3.49k
      const DiagnosticBuilder &BaseDiag = Diag;
1356
3.49k
      BaseDiag << Value;
1357
3.49k
      return Diag;
1358
3.49k
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<clang::AttributeArgumentNType>(clang::Sema::SemaDiagnosticBuilder const&, clang::AttributeArgumentNType const&)
Line
Count
Source
1354
131
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
131
      const DiagnosticBuilder &BaseDiag = Diag;
1356
131
      BaseDiag << Value;
1357
131
      return Diag;
1358
131
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<clang::AssumeAlignedAttr*>(clang::Sema::SemaDiagnosticBuilder const&, clang::AssumeAlignedAttr* const&)
Line
Count
Source
1354
3
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
3
      const DiagnosticBuilder &BaseDiag = Diag;
1356
3
      BaseDiag << Value;
1357
3
      return Diag;
1358
3
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<clang::AllocAlignAttr*>(clang::Sema::SemaDiagnosticBuilder const&, clang::AllocAlignAttr* const&)
Line
Count
Source
1354
5
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
5
      const DiagnosticBuilder &BaseDiag = Diag;
1356
5
      BaseDiag << Value;
1357
5
      return Diag;
1358
5
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<clang::AllocAlignAttr const*>(clang::Sema::SemaDiagnosticBuilder const&, clang::AllocAlignAttr const* const&)
Line
Count
Source
1354
5
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
5
      const DiagnosticBuilder &BaseDiag = Diag;
1356
5
      BaseDiag << Value;
1357
5
      return Diag;
1358
5
    }
SemaDeclAttr.cpp:clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<clang::Sema::checkTargetAttr(clang::SourceLocation, llvm::StringRef)::FirstParam>(clang::Sema::SemaDiagnosticBuilder const&, clang::Sema::checkTargetAttr(clang::SourceLocation, llvm::StringRef)::FirstParam const&)
Line
Count
Source
1354
12
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
12
      const DiagnosticBuilder &BaseDiag = Diag;
1356
12
      BaseDiag << Value;
1357
12
      return Diag;
1358
12
    }
SemaDeclAttr.cpp:clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<clang::Sema::checkTargetAttr(clang::SourceLocation, llvm::StringRef)::SecondParam>(clang::Sema::SemaDiagnosticBuilder const&, clang::Sema::checkTargetAttr(clang::SourceLocation, llvm::StringRef)::SecondParam const&)
Line
Count
Source
1354
12
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
12
      const DiagnosticBuilder &BaseDiag = Diag;
1356
12
      BaseDiag << Value;
1357
12
      return Diag;
1358
12
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<clang::AlignValueAttr*>(clang::Sema::SemaDiagnosticBuilder const&, clang::AlignValueAttr* const&)
Line
Count
Source
1354
1
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
1
      const DiagnosticBuilder &BaseDiag = Diag;
1356
1
      BaseDiag << Value;
1357
1
      return Diag;
1358
1
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<clang::CommonAttr const*>(clang::Sema::SemaDiagnosticBuilder const&, clang::CommonAttr const* const&)
Line
Count
Source
1354
4
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
4
      const DiagnosticBuilder &BaseDiag = Diag;
1356
4
      BaseDiag << Value;
1357
4
      return Diag;
1358
4
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<clang::InternalLinkageAttr const*>(clang::Sema::SemaDiagnosticBuilder const&, clang::InternalLinkageAttr const* const&)
Line
Count
Source
1354
2
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
2
      const DiagnosticBuilder &BaseDiag = Diag;
1356
2
      BaseDiag << Value;
1357
2
      return Diag;
1358
2
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<clang::AlwaysInlineAttr*>(clang::Sema::SemaDiagnosticBuilder const&, clang::AlwaysInlineAttr* const&)
Line
Count
Source
1354
7
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
7
      const DiagnosticBuilder &BaseDiag = Diag;
1356
7
      BaseDiag << Value;
1357
7
      return Diag;
1358
7
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<clang::MinSizeAttr*>(clang::Sema::SemaDiagnosticBuilder const&, clang::MinSizeAttr* const&)
Line
Count
Source
1354
3
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
3
      const DiagnosticBuilder &BaseDiag = Diag;
1356
3
      BaseDiag << Value;
1357
3
      return Diag;
1358
3
    }
Unexecuted instantiation: clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<clang::ParameterABIAttr*>(clang::Sema::SemaDiagnosticBuilder const&, clang::ParameterABIAttr* const&)
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<clang::AMDGPUFlatWorkGroupSizeAttr const*>(clang::Sema::SemaDiagnosticBuilder const&, clang::AMDGPUFlatWorkGroupSizeAttr const* const&)
Line
Count
Source
1354
12
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
12
      const DiagnosticBuilder &BaseDiag = Diag;
1356
12
      BaseDiag << Value;
1357
12
      return Diag;
1358
12
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<clang::AMDGPUWavesPerEUAttr const*>(clang::Sema::SemaDiagnosticBuilder const&, clang::AMDGPUWavesPerEUAttr const* const&)
Line
Count
Source
1354
13
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
13
      const DiagnosticBuilder &BaseDiag = Diag;
1356
13
      BaseDiag << Value;
1357
13
      return Diag;
1358
13
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<clang::DLLImportAttr*>(clang::Sema::SemaDiagnosticBuilder const&, clang::DLLImportAttr* const&)
Line
Count
Source
1354
142
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
142
      const DiagnosticBuilder &BaseDiag = Diag;
1356
142
      BaseDiag << Value;
1357
142
      return Diag;
1358
142
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<clang::ReqdWorkGroupSizeAttr const*>(clang::Sema::SemaDiagnosticBuilder const&, clang::ReqdWorkGroupSizeAttr const* const&)
Line
Count
Source
1354
2
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
2
      const DiagnosticBuilder &BaseDiag = Diag;
1356
2
      BaseDiag << Value;
1357
2
      return Diag;
1358
2
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<clang::WorkGroupSizeHintAttr const*>(clang::Sema::SemaDiagnosticBuilder const&, clang::WorkGroupSizeHintAttr const* const&)
Line
Count
Source
1354
2
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
2
      const DiagnosticBuilder &BaseDiag = Diag;
1356
2
      BaseDiag << Value;
1357
2
      return Diag;
1358
2
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<clang::VecTypeHintAttr const*>(clang::Sema::SemaDiagnosticBuilder const&, clang::VecTypeHintAttr const* const&)
Line
Count
Source
1354
2
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
2
      const DiagnosticBuilder &BaseDiag = Diag;
1356
2
      BaseDiag << Value;
1357
2
      return Diag;
1358
2
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<clang::OpenCLIntelReqdSubGroupSizeAttr const*>(clang::Sema::SemaDiagnosticBuilder const&, clang::OpenCLIntelReqdSubGroupSizeAttr const* const&)
Line
Count
Source
1354
2
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
2
      const DiagnosticBuilder &BaseDiag = Diag;
1356
2
      BaseDiag << Value;
1357
2
      return Diag;
1358
2
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<clang::AMDGPUNumSGPRAttr const*>(clang::Sema::SemaDiagnosticBuilder const&, clang::AMDGPUNumSGPRAttr const* const&)
Line
Count
Source
1354
1
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
1
      const DiagnosticBuilder &BaseDiag = Diag;
1356
1
      BaseDiag << Value;
1357
1
      return Diag;
1358
1
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<clang::AMDGPUNumVGPRAttr const*>(clang::Sema::SemaDiagnosticBuilder const&, clang::AMDGPUNumVGPRAttr const* const&)
Line
Count
Source
1354
1
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
1
      const DiagnosticBuilder &BaseDiag = Diag;
1356
1
      BaseDiag << Value;
1357
1
      return Diag;
1358
1
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<clang::BindingDecl*>(clang::Sema::SemaDiagnosticBuilder const&, clang::BindingDecl* const&)
Line
Count
Source
1354
10
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
10
      const DiagnosticBuilder &BaseDiag = Diag;
1356
10
      BaseDiag << Value;
1357
10
      return Diag;
1358
10
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<clang::Sema::AbstractDiagSelID>(clang::Sema::SemaDiagnosticBuilder const&, clang::Sema::AbstractDiagSelID const&)
Line
Count
Source
1354
11
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
11
      const DiagnosticBuilder &BaseDiag = Diag;
1356
11
      BaseDiag << Value;
1357
11
      return Diag;
1358
11
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<TrivialSubobjectKind>(clang::Sema::SemaDiagnosticBuilder const&, TrivialSubobjectKind const&)
Line
Count
Source
1354
159
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
159
      const DiagnosticBuilder &BaseDiag = Diag;
1356
159
      BaseDiag << Value;
1357
159
      return Diag;
1358
159
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<clang::Qualifiers::ObjCLifetime>(clang::Sema::SemaDiagnosticBuilder const&, clang::Qualifiers::ObjCLifetime const&)
Line
Count
Source
1354
281
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
281
      const DiagnosticBuilder &BaseDiag = Diag;
1356
281
      BaseDiag << Value;
1357
281
      return Diag;
1358
281
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<clang::CXXConstructorDecl*>(clang::Sema::SemaDiagnosticBuilder const&, clang::CXXConstructorDecl* const&)
Line
Count
Source
1354
7
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
7
      const DiagnosticBuilder &BaseDiag = Diag;
1356
7
      BaseDiag << Value;
1357
7
      return Diag;
1358
7
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<clang::ConstexprSpecKind>(clang::Sema::SemaDiagnosticBuilder const&, clang::ConstexprSpecKind const&)
Line
Count
Source
1354
88
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
88
      const DiagnosticBuilder &BaseDiag = Diag;
1356
88
      BaseDiag << Value;
1357
88
      return Diag;
1358
88
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<clang::DecompositionDecl*>(clang::Sema::SemaDiagnosticBuilder const&, clang::DecompositionDecl* const&)
Line
Count
Source
1354
4
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
4
      const DiagnosticBuilder &BaseDiag = Diag;
1356
4
      BaseDiag << Value;
1357
4
      return Diag;
1358
4
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<clang::Attr*>(clang::Sema::SemaDiagnosticBuilder const&, clang::Attr* const&)
Line
Count
Source
1354
16
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
16
      const DiagnosticBuilder &BaseDiag = Diag;
1356
16
      BaseDiag << Value;
1357
16
      return Diag;
1358
16
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<clang::InheritableAttr*>(clang::Sema::SemaDiagnosticBuilder const&, clang::InheritableAttr* const&)
Line
Count
Source
1354
8
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
8
      const DiagnosticBuilder &BaseDiag = Diag;
1356
8
      BaseDiag << Value;
1357
8
      return Diag;
1358
8
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<clang::ClassTemplateSpecializationDecl*>(clang::Sema::SemaDiagnosticBuilder const&, clang::ClassTemplateSpecializationDecl* const&)
Line
Count
Source
1354
71
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
71
      const DiagnosticBuilder &BaseDiag = Diag;
1356
71
      BaseDiag << Value;
1357
71
      return Diag;
1358
71
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<clang::TemplateDecl*>(clang::Sema::SemaDiagnosticBuilder const&, clang::TemplateDecl* const&)
Line
Count
Source
1354
962
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
962
      const DiagnosticBuilder &BaseDiag = Diag;
1356
962
      BaseDiag << Value;
1357
962
      return Diag;
1358
962
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<clang::NamespaceDecl*>(clang::Sema::SemaDiagnosticBuilder const&, clang::NamespaceDecl* const&)
Line
Count
Source
1354
40
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
40
      const DiagnosticBuilder &BaseDiag = Diag;
1356
40
      BaseDiag << Value;
1357
40
      return Diag;
1358
40
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<char [15]>(clang::Sema::SemaDiagnosticBuilder const&, char const (&) [15])
Line
Count
Source
1354
14
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
14
      const DiagnosticBuilder &BaseDiag = Diag;
1356
14
      BaseDiag << Value;
1357
14
      return Diag;
1358
14
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<clang::ObjCMethodDecl*>(clang::Sema::SemaDiagnosticBuilder const&, clang::ObjCMethodDecl* const&)
Line
Count
Source
1354
2.36k
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
2.36k
      const DiagnosticBuilder &BaseDiag = Diag;
1356
2.36k
      BaseDiag << Value;
1357
2.36k
      return Diag;
1358
2.36k
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<clang::ObjCProtocolDecl const*>(clang::Sema::SemaDiagnosticBuilder const&, clang::ObjCProtocolDecl const* const&)
Line
Count
Source
1354
5
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
5
      const DiagnosticBuilder &BaseDiag = Diag;
1356
5
      BaseDiag << Value;
1357
5
      return Diag;
1358
5
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<clang::ObjCMethodFamily>(clang::Sema::SemaDiagnosticBuilder const&, clang::ObjCMethodFamily const&)
Line
Count
Source
1354
48
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
48
      const DiagnosticBuilder &BaseDiag = Diag;
1356
48
      BaseDiag << Value;
1357
48
      return Diag;
1358
48
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<clang::Selector>(clang::Sema::SemaDiagnosticBuilder const&, clang::Selector const&)
Line
Count
Source
1354
1.45k
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
1.45k
      const DiagnosticBuilder &BaseDiag = Diag;
1356
1.45k
      BaseDiag << Value;
1357
1.45k
      return Diag;
1358
1.45k
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<clang::ObjCProtocolDecl*>(clang::Sema::SemaDiagnosticBuilder const&, clang::ObjCProtocolDecl* const&)
Line
Count
Source
1354
33
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
33
      const DiagnosticBuilder &BaseDiag = Diag;
1356
33
      BaseDiag << Value;
1357
33
      return Diag;
1358
33
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<clang::ObjCIvarDecl const*>(clang::Sema::SemaDiagnosticBuilder const&, clang::ObjCIvarDecl const* const&)
Line
Count
Source
1354
10
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
10
      const DiagnosticBuilder &BaseDiag = Diag;
1356
10
      BaseDiag << Value;
1357
10
      return Diag;
1358
10
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<llvm::SmallString<40u> >(clang::Sema::SemaDiagnosticBuilder const&, llvm::SmallString<40u> const&)
Line
Count
Source
1354
5.61k
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
5.61k
      const DiagnosticBuilder &BaseDiag = Diag;
1356
5.61k
      BaseDiag << Value;
1357
5.61k
      return Diag;
1358
5.61k
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<clang::Sema::ObjCLiteralKind>(clang::Sema::SemaDiagnosticBuilder const&, clang::Sema::ObjCLiteralKind const&)
Line
Count
Source
1354
79
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
79
      const DiagnosticBuilder &BaseDiag = Diag;
1356
79
      BaseDiag << Value;
1357
79
      return Diag;
1358
79
    }
SemaExpr.cpp:clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<$_4>(clang::Sema::SemaDiagnosticBuilder const&, $_4 const&)
Line
Count
Source
1354
420
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
420
      const DiagnosticBuilder &BaseDiag = Diag;
1356
420
      BaseDiag << Value;
1357
420
      return Diag;
1358
420
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<clang::ValueDecl const*>(clang::Sema::SemaDiagnosticBuilder const&, clang::ValueDecl const* const&)
Line
Count
Source
1354
5.17k
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
5.17k
      const DiagnosticBuilder &BaseDiag = Diag;
1356
5.17k
      BaseDiag << Value;
1357
5.17k
      return Diag;
1358
5.17k
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<OriginalExprKind>(clang::Sema::SemaDiagnosticBuilder const&, OriginalExprKind const&)
Line
Count
Source
1354
11
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
11
      const DiagnosticBuilder &BaseDiag = Diag;
1356
11
      BaseDiag << Value;
1357
11
      return Diag;
1358
11
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<clang::UnaryExprOrTypeTrait>(clang::Sema::SemaDiagnosticBuilder const&, clang::UnaryExprOrTypeTrait const&)
Line
Count
Source
1354
34
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
34
      const DiagnosticBuilder &BaseDiag = Diag;
1356
34
      BaseDiag << Value;
1357
34
      return Diag;
1358
34
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<clang::ParmVarDecl*>(clang::Sema::SemaDiagnosticBuilder const&, clang::ParmVarDecl* const&)
Line
Count
Source
1354
196
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
196
      const DiagnosticBuilder &BaseDiag = Diag;
1356
196
      BaseDiag << Value;
1357
196
      return Diag;
1358
196
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<char [2]>(clang::Sema::SemaDiagnosticBuilder const&, char const (&) [2])
Line
Count
Source
1354
99
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
99
      const DiagnosticBuilder &BaseDiag = Diag;
1356
99
      BaseDiag << Value;
1357
99
      return Diag;
1358
99
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<clang::ObjCInterfaceDecl const*>(clang::Sema::SemaDiagnosticBuilder const&, clang::ObjCInterfaceDecl const* const&)
Line
Count
Source
1354
3
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
3
      const DiagnosticBuilder &BaseDiag = Diag;
1356
3
      BaseDiag << Value;
1357
3
      return Diag;
1358
3
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<clang::UsingPackDecl*>(clang::Sema::SemaDiagnosticBuilder const&, clang::UsingPackDecl* const&)
Line
Count
Source
1354
2
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
2
      const DiagnosticBuilder &BaseDiag = Diag;
1356
2
      BaseDiag << Value;
1357
2
      return Diag;
1358
2
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<clang::TypeAliasTemplateDecl*>(clang::Sema::SemaDiagnosticBuilder const&, clang::TypeAliasTemplateDecl* const&)
Line
Count
Source
1354
7
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
7
      const DiagnosticBuilder &BaseDiag = Diag;
1356
7
      BaseDiag << Value;
1357
7
      return Diag;
1358
7
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<clang::tok::TokenKind>(clang::Sema::SemaDiagnosticBuilder const&, clang::tok::TokenKind const&)
Line
Count
Source
1354
2
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
2
      const DiagnosticBuilder &BaseDiag = Diag;
1356
2
      BaseDiag << Value;
1357
2
      return Diag;
1358
2
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<clang::ObjCBridgeCastKind>(clang::Sema::SemaDiagnosticBuilder const&, clang::ObjCBridgeCastKind const&)
Line
Count
Source
1354
3
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
3
      const DiagnosticBuilder &BaseDiag = Diag;
1356
3
      BaseDiag << Value;
1357
3
      return Diag;
1358
3
    }
SemaInit.cpp:clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<(anonymous namespace)::ReferenceKind>(clang::Sema::SemaDiagnosticBuilder const&, (anonymous namespace)::ReferenceKind const&)
Line
Count
Source
1354
106
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
106
      const DiagnosticBuilder &BaseDiag = Diag;
1356
106
      BaseDiag << Value;
1357
106
      return Diag;
1358
106
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<clang::Qualifiers>(clang::Sema::SemaDiagnosticBuilder const&, clang::Qualifiers const&)
Line
Count
Source
1354
77
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
77
      const DiagnosticBuilder &BaseDiag = Diag;
1356
77
      BaseDiag << Value;
1357
77
      return Diag;
1358
77
    }
SemaObjCProperty.cpp:clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<SelectPropertyForSynthesisFromProtocols(clang::Sema&, clang::SourceLocation, clang::ObjCInterfaceDecl*, clang::ObjCPropertyDecl*)::MismatchKind>(clang::Sema::SemaDiagnosticBuilder const&, SelectPropertyForSynthesisFromProtocols(clang::Sema&, clang::SourceLocation, clang::ObjCInterfaceDecl*, clang::ObjCPropertyDecl*)::MismatchKind const&)
Line
Count
Source
1354
24
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
24
      const DiagnosticBuilder &BaseDiag = Diag;
1356
24
      BaseDiag << Value;
1357
24
      return Diag;
1358
24
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<clang::ObjCPropertyDecl*>(clang::Sema::SemaDiagnosticBuilder const&, clang::ObjCPropertyDecl* const&)
Line
Count
Source
1354
31
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
31
      const DiagnosticBuilder &BaseDiag = Diag;
1356
31
      BaseDiag << Value;
1357
31
      return Diag;
1358
31
    }
SemaOpenMP.cpp:clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<checkNestingOfRegions(clang::Sema&, (anonymous namespace)::DSAStackTy const*, clang::OpenMPDirectiveKind, clang::DeclarationNameInfo const&, clang::OpenMPDirectiveKind, clang::SourceLocation)::$_12>(clang::Sema::SemaDiagnosticBuilder const&, checkNestingOfRegions(clang::Sema&, (anonymous namespace)::DSAStackTy const*, clang::OpenMPDirectiveKind, clang::DeclarationNameInfo const&, clang::OpenMPDirectiveKind, clang::SourceLocation)::$_12 const&)
Line
Count
Source
1354
1.96k
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
1.96k
      const DiagnosticBuilder &BaseDiag = Diag;
1356
1.96k
      BaseDiag << Value;
1357
1.96k
      return Diag;
1358
1.96k
    }
SemaOpenMP.cpp:clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<reportOriginalDsa(clang::Sema&, (anonymous namespace)::DSAStackTy const*, clang::ValueDecl const*, (anonymous namespace)::DSAStackTy::DSAVarData const&, bool)::$_11>(clang::Sema::SemaDiagnosticBuilder const&, reportOriginalDsa(clang::Sema&, (anonymous namespace)::DSAStackTy const*, clang::ValueDecl const*, (anonymous namespace)::DSAStackTy::DSAVarData const&, bool)::$_11 const&)
Line
Count
Source
1354
506
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
506
      const DiagnosticBuilder &BaseDiag = Diag;
1356
506
      BaseDiag << Value;
1357
506
      return Diag;
1358
506
    }
SemaOpenMP.cpp:clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<(anonymous namespace)::OpenMPAtomicUpdateChecker::ExprAnalysisErrorCode>(clang::Sema::SemaDiagnosticBuilder const&, (anonymous namespace)::OpenMPAtomicUpdateChecker::ExprAnalysisErrorCode const&)
Line
Count
Source
1354
284
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
284
      const DiagnosticBuilder &BaseDiag = Diag;
1356
284
      BaseDiag << Value;
1357
284
      return Diag;
1358
284
    }
SemaOpenMP.cpp:clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<getPrivateItem(clang::Sema&, clang::Expr*&, clang::SourceLocation&, clang::SourceRange&, bool)::$_13>(clang::Sema::SemaDiagnosticBuilder const&, getPrivateItem(clang::Sema&, clang::Expr*&, clang::SourceLocation&, clang::SourceRange&, bool)::$_13 const&)
Line
Count
Source
1354
12
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
12
      const DiagnosticBuilder &BaseDiag = Diag;
1356
12
      BaseDiag << Value;
1357
12
      return Diag;
1358
12
    }
Unexecuted instantiation: clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<clang::ParmVarDecl const*>(clang::Sema::SemaDiagnosticBuilder const&, clang::ParmVarDecl const* const&)
SemaOpenMP.cpp:clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<clang::Sema::ActOnOpenMPAtomicDirective(llvm::ArrayRef<clang::OMPClause*>, clang::Stmt*, clang::SourceLocation, clang::SourceLocation)::$_14>(clang::Sema::SemaDiagnosticBuilder const&, clang::Sema::ActOnOpenMPAtomicDirective(llvm::ArrayRef<clang::OMPClause*>, clang::Stmt*, clang::SourceLocation, clang::SourceLocation)::$_14 const&)
Line
Count
Source
1354
32
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
32
      const DiagnosticBuilder &BaseDiag = Diag;
1356
32
      BaseDiag << Value;
1357
32
      return Diag;
1358
32
    }
SemaOpenMP.cpp:clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<clang::Sema::ActOnOpenMPAtomicDirective(llvm::ArrayRef<clang::OMPClause*>, clang::Stmt*, clang::SourceLocation, clang::SourceLocation)::$_15>(clang::Sema::SemaDiagnosticBuilder const&, clang::Sema::ActOnOpenMPAtomicDirective(llvm::ArrayRef<clang::OMPClause*>, clang::Stmt*, clang::SourceLocation, clang::SourceLocation)::$_15 const&)
Line
Count
Source
1354
20
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
20
      const DiagnosticBuilder &BaseDiag = Diag;
1356
20
      BaseDiag << Value;
1357
20
      return Diag;
1358
20
    }
SemaOpenMP.cpp:clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<clang::Sema::ActOnOpenMPAtomicDirective(llvm::ArrayRef<clang::OMPClause*>, clang::Stmt*, clang::SourceLocation, clang::SourceLocation)::$_16>(clang::Sema::SemaDiagnosticBuilder const&, clang::Sema::ActOnOpenMPAtomicDirective(llvm::ArrayRef<clang::OMPClause*>, clang::Stmt*, clang::SourceLocation, clang::SourceLocation)::$_16 const&)
Line
Count
Source
1354
36
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
36
      const DiagnosticBuilder &BaseDiag = Diag;
1356
36
      BaseDiag << Value;
1357
36
      return Diag;
1358
36
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<char [26]>(clang::Sema::SemaDiagnosticBuilder const&, char const (&) [26])
Line
Count
Source
1354
6
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
6
      const DiagnosticBuilder &BaseDiag = Diag;
1356
6
      BaseDiag << Value;
1357
6
      return Diag;
1358
6
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<char [50]>(clang::Sema::SemaDiagnosticBuilder const&, char const (&) [50])
Line
Count
Source
1354
16
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
16
      const DiagnosticBuilder &BaseDiag = Diag;
1356
16
      BaseDiag << Value;
1357
16
      return Diag;
1358
16
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<clang::Sema::CCEKind>(clang::Sema::SemaDiagnosticBuilder const&, clang::Sema::CCEKind const&)
Line
Count
Source
1354
80
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
80
      const DiagnosticBuilder &BaseDiag = Diag;
1356
80
      BaseDiag << Value;
1357
80
      return Diag;
1358
80
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<clang::Qualifiers::GC>(clang::Sema::SemaDiagnosticBuilder const&, clang::Qualifiers::GC const&)
Line
Count
Source
1354
4
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
4
      const DiagnosticBuilder &BaseDiag = Diag;
1356
4
      BaseDiag << Value;
1357
4
      return Diag;
1358
4
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<clang::TemplateArgument>(clang::Sema::SemaDiagnosticBuilder const&, clang::TemplateArgument const&)
Line
Count
Source
1354
456
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
456
      const DiagnosticBuilder &BaseDiag = Diag;
1356
456
      BaseDiag << Value;
1357
456
      return Diag;
1358
456
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<llvm::SmallString<128u> >(clang::Sema::SemaDiagnosticBuilder const&, llvm::SmallString<128u> const&)
Line
Count
Source
1354
458
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
458
      const DiagnosticBuilder &BaseDiag = Diag;
1356
458
      BaseDiag << Value;
1357
458
      return Diag;
1358
458
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<clang::RefQualifierKind>(clang::Sema::SemaDiagnosticBuilder const&, clang::RefQualifierKind const&)
Line
Count
Source
1354
22
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
22
      const DiagnosticBuilder &BaseDiag = Diag;
1356
22
      BaseDiag << Value;
1357
22
      return Diag;
1358
22
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<clang::MSPropertyDecl*>(clang::Sema::SemaDiagnosticBuilder const&, clang::MSPropertyDecl* const&)
Line
Count
Source
1354
25
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
25
      const DiagnosticBuilder &BaseDiag = Diag;
1356
25
      BaseDiag << Value;
1357
25
      return Diag;
1358
25
    }
SemaStmt.cpp:clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<(anonymous namespace)::BeginEndFunction>(clang::Sema::SemaDiagnosticBuilder const&, (anonymous namespace)::BeginEndFunction const&)
Line
Count
Source
1354
46
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
46
      const DiagnosticBuilder &BaseDiag = Diag;
1356
46
      BaseDiag << Value;
1357
46
      return Diag;
1358
46
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<clang::WarnUnusedResultAttr const*>(clang::Sema::SemaDiagnosticBuilder const&, clang::WarnUnusedResultAttr const* const&)
Line
Count
Source
1354
87
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
87
      const DiagnosticBuilder &BaseDiag = Diag;
1356
87
      BaseDiag << Value;
1357
87
      return Diag;
1358
87
    }
SemaStmtAsm.cpp:clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<checkExprMemoryConstraintCompat(clang::Sema&, clang::Expr*, clang::TargetInfo::ConstraintInfo&, bool)::$_0>(clang::Sema::SemaDiagnosticBuilder const&, checkExprMemoryConstraintCompat(clang::Sema&, clang::Expr*, clang::TargetInfo::ConstraintInfo&, bool)::$_0 const&)
Line
Count
Source
1354
6
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
6
      const DiagnosticBuilder &BaseDiag = Diag;
1356
6
      BaseDiag << Value;
1357
6
      return Diag;
1358
6
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<clang::VarTemplateSpecializationDecl*>(clang::Sema::SemaDiagnosticBuilder const&, clang::VarTemplateSpecializationDecl* const&)
Line
Count
Source
1354
3
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
3
      const DiagnosticBuilder &BaseDiag = Diag;
1356
3
      BaseDiag << Value;
1357
3
      return Diag;
1358
3
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<clang::ClassTemplateDecl*>(clang::Sema::SemaDiagnosticBuilder const&, clang::ClassTemplateDecl* const&)
Line
Count
Source
1354
5
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
5
      const DiagnosticBuilder &BaseDiag = Diag;
1356
5
      BaseDiag << Value;
1357
5
      return Diag;
1358
5
    }
SemaTemplate.cpp:clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<clang::Sema::CheckDependentFunctionTemplateSpecialization(clang::FunctionDecl*, clang::TemplateArgumentListInfo const&, clang::LookupResult&)::DiscardReason>(clang::Sema::SemaDiagnosticBuilder const&, clang::Sema::CheckDependentFunctionTemplateSpecialization(clang::FunctionDecl*, clang::TemplateArgumentListInfo const&, clang::LookupResult&)::DiscardReason const&)
Line
Count
Source
1354
4
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
4
      const DiagnosticBuilder &BaseDiag = Diag;
1356
4
      BaseDiag << Value;
1357
4
      return Diag;
1358
4
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<clang::VarTemplateDecl*>(clang::Sema::SemaDiagnosticBuilder const&, clang::VarTemplateDecl* const&)
Line
Count
Source
1354
21
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
21
      const DiagnosticBuilder &BaseDiag = Diag;
1356
21
      BaseDiag << Value;
1357
21
      return Diag;
1358
21
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<clang::DeducedTemplateArgument>(clang::Sema::SemaDiagnosticBuilder const&, clang::DeducedTemplateArgument const&)
Line
Count
Source
1354
8
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
8
      const DiagnosticBuilder &BaseDiag = Diag;
1356
8
      BaseDiag << Value;
1357
8
      return Diag;
1358
8
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<clang::ObjCInterfaceDecl*>(clang::Sema::SemaDiagnosticBuilder const&, clang::ObjCInterfaceDecl* const&)
Line
Count
Source
1354
5
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
5
      const DiagnosticBuilder &BaseDiag = Diag;
1356
5
      BaseDiag << Value;
1357
5
      return Diag;
1358
5
    }
SemaType.cpp:clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<(anonymous namespace)::QualifiedFunctionKind>(clang::Sema::SemaDiagnosticBuilder const&, (anonymous namespace)::QualifiedFunctionKind const&)
Line
Count
Source
1354
22
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
22
      const DiagnosticBuilder &BaseDiag = Diag;
1356
22
      BaseDiag << Value;
1357
22
      return Diag;
1358
22
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<TypeDiagSelector>(clang::Sema::SemaDiagnosticBuilder const&, TypeDiagSelector const&)
Line
Count
Source
1354
53
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
53
      const DiagnosticBuilder &BaseDiag = Diag;
1356
53
      BaseDiag << Value;
1357
53
      return Diag;
1358
53
    }
SemaType.cpp:clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<GetFullTypeForDeclarator((anonymous namespace)::TypeProcessingState&, clang::QualType, clang::TypeSourceInfo*)::$_1>(clang::Sema::SemaDiagnosticBuilder const&, GetFullTypeForDeclarator((anonymous namespace)::TypeProcessingState&, clang::QualType, clang::TypeSourceInfo*)::$_1 const&)
Line
Count
Source
1354
50
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
50
      const DiagnosticBuilder &BaseDiag = Diag;
1356
50
      BaseDiag << Value;
1357
50
      return Diag;
1358
50
    }
clang::Sema::SemaDiagnosticBuilder const& clang::operator<<<clang::ArrayType::ArraySizeModifier>(clang::Sema::SemaDiagnosticBuilder const&, clang::ArrayType::ArraySizeModifier const&)
Line
Count
Source
1354
4
        const SemaDiagnosticBuilder &Diag, const T &Value) {
1355
4
      const DiagnosticBuilder &BaseDiag = Diag;
1356
4
      BaseDiag << Value;
1357
4
      return Diag;
1358
4
    }
1359
  };
1360
1361
  /// Emit a diagnostic.
1362
2.39M
  SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID) {
1363
2.39M
    DiagnosticBuilder DB = Diags.Report(Loc, DiagID);
1364
2.39M
    return SemaDiagnosticBuilder(DB, *this, DiagID);
1365
2.39M
  }
1366
1367
  /// Emit a partial diagnostic.
1368
  SemaDiagnosticBuilder Diag(SourceLocation Loc, const PartialDiagnostic& PD);
1369
1370
  /// Build a partial diagnostic.
1371
  PartialDiagnostic PDiag(unsigned DiagID = 0); // in SemaInternal.h
1372
1373
  bool findMacroSpelling(SourceLocation &loc, StringRef name);
1374
1375
  /// Get a string to suggest for zero-initialization of a type.
1376
  std::string
1377
  getFixItZeroInitializerForType(QualType T, SourceLocation Loc) const;
1378
  std::string getFixItZeroLiteralForType(QualType T, SourceLocation Loc) const;
1379
1380
  /// Calls \c Lexer::getLocForEndOfToken()
1381
  SourceLocation getLocForEndOfToken(SourceLocation Loc, unsigned Offset = 0);
1382
1383
  /// Retrieve the module loader associated with the preprocessor.
1384
  ModuleLoader &getModuleLoader() const;
1385
1386
  void emitAndClearUnusedLocalTypedefWarnings();
1387
1388
  enum TUFragmentKind {
1389
    /// The global module fragment, between 'module;' and a module-declaration.
1390
    Global,
1391
    /// A normal translation unit fragment. For a non-module unit, this is the
1392
    /// entire translation unit. Otherwise, it runs from the module-declaration
1393
    /// to the private-module-fragment (if any) or the end of the TU (if not).
1394
    Normal,
1395
    /// The private module fragment, between 'module :private;' and the end of
1396
    /// the translation unit.
1397
    Private
1398
  };
1399
1400
  void ActOnStartOfTranslationUnit();
1401
  void ActOnEndOfTranslationUnit();
1402
  void ActOnEndOfTranslationUnitFragment(TUFragmentKind Kind);
1403
1404
  void CheckDelegatingCtorCycles();
1405
1406
  Scope *getScopeForContext(DeclContext *Ctx);
1407
1408
  void PushFunctionScope();
1409
  void PushBlockScope(Scope *BlockScope, BlockDecl *Block);
1410
  sema::LambdaScopeInfo *PushLambdaScope();
1411
1412
  /// This is used to inform Sema what the current TemplateParameterDepth
1413
  /// is during Parsing.  Currently it is used to pass on the depth
1414
  /// when parsing generic lambda 'auto' parameters.
1415
  void RecordParsingTemplateParameterDepth(unsigned Depth);
1416
1417
  void PushCapturedRegionScope(Scope *RegionScope, CapturedDecl *CD,
1418
                               RecordDecl *RD,
1419
                               CapturedRegionKind K);
1420
1421
  /// Custom deleter to allow FunctionScopeInfos to be kept alive for a short
1422
  /// time after they've been popped.
1423
  class PoppedFunctionScopeDeleter {
1424
    Sema *Self;
1425
1426
  public:
1427
3.94M
    explicit PoppedFunctionScopeDeleter(Sema *Self) : Self(Self) {}
1428
    void operator()(sema::FunctionScopeInfo *Scope) const;
1429
  };
1430
1431
  using PoppedFunctionScopePtr =
1432
      std::unique_ptr<sema::FunctionScopeInfo, PoppedFunctionScopeDeleter>;
1433
1434
  PoppedFunctionScopePtr
1435
  PopFunctionScopeInfo(const sema::AnalysisBasedWarnings::Policy *WP = nullptr,
1436
                       const Decl *D = nullptr,
1437
                       QualType BlockType = QualType());
1438
1439
26.4M
  sema::FunctionScopeInfo *getCurFunction() const {
1440
26.4M
    return FunctionScopes.empty() ? 
nullptr449k
:
FunctionScopes.back()25.9M
;
1441
26.4M
  }
1442
1443
  sema::FunctionScopeInfo *getEnclosingFunction() const;
1444
1445
  void setFunctionHasBranchIntoScope();
1446
  void setFunctionHasBranchProtectedScope();
1447
  void setFunctionHasIndirectGoto();
1448
1449
  void PushCompoundScope(bool IsStmtExpr);
1450
  void PopCompoundScope();
1451
1452
  sema::CompoundScopeInfo &getCurCompoundScope() const;
1453
1454
  bool hasAnyUnrecoverableErrorsInThisFunction() const;
1455
1456
  /// Retrieve the current block, if any.
1457
  sema::BlockScopeInfo *getCurBlock();
1458
1459
  /// Retrieve the current lambda scope info, if any.
1460
  /// \param IgnoreNonLambdaCapturingScope true if should find the top-most
1461
  /// lambda scope info ignoring all inner capturing scopes that are not
1462
  /// lambda scopes.
1463
  sema::LambdaScopeInfo *
1464
  getCurLambda(bool IgnoreNonLambdaCapturingScope = false);
1465
1466
  /// Retrieve the current generic lambda info, if any.
1467
  sema::LambdaScopeInfo *getCurGenericLambda();
1468
1469
  /// Retrieve the current captured region, if any.
1470
  sema::CapturedRegionScopeInfo *getCurCapturedRegion();
1471
1472
  /// WeakTopLevelDeclDecls - access to \#pragma weak-generated Decls
1473
41.4k
  SmallVectorImpl<Decl *> &WeakTopLevelDecls() { return WeakTopLevelDecl; }
1474
1475
  void ActOnComment(SourceRange Comment);
1476
1477
  //===--------------------------------------------------------------------===//
1478
  // Type Analysis / Processing: SemaType.cpp.
1479
  //
1480
1481
  QualType BuildQualifiedType(QualType T, SourceLocation Loc, Qualifiers Qs,
1482
                              const DeclSpec *DS = nullptr);
1483
  QualType BuildQualifiedType(QualType T, SourceLocation Loc, unsigned CVRA,
1484
                              const DeclSpec *DS = nullptr);
1485
  QualType BuildPointerType(QualType T,
1486
                            SourceLocation Loc, DeclarationName Entity);
1487
  QualType BuildReferenceType(QualType T, bool LValueRef,
1488
                              SourceLocation Loc, DeclarationName Entity);
1489
  QualType BuildArrayType(QualType T, ArrayType::ArraySizeModifier ASM,
1490
                          Expr *ArraySize, unsigned Quals,
1491
                          SourceRange Brackets, DeclarationName Entity);
1492
  QualType BuildVectorType(QualType T, Expr *VecSize, SourceLocation AttrLoc);
1493
  QualType BuildExtVectorType(QualType T, Expr *ArraySize,
1494
                              SourceLocation AttrLoc);
1495
  QualType BuildAddressSpaceAttr(QualType &T, LangAS ASIdx, Expr *AddrSpace,
1496
                                 SourceLocation AttrLoc);
1497
1498
  /// Same as above, but constructs the AddressSpace index if not provided.
1499
  QualType BuildAddressSpaceAttr(QualType &T, Expr *AddrSpace,
1500
                                 SourceLocation AttrLoc);
1501
1502
  bool CheckFunctionReturnType(QualType T, SourceLocation Loc);
1503
1504
  /// Build a function type.
1505
  ///
1506
  /// This routine checks the function type according to C++ rules and
1507
  /// under the assumption that the result type and parameter types have
1508
  /// just been instantiated from a template. It therefore duplicates
1509
  /// some of the behavior of GetTypeForDeclarator, but in a much
1510
  /// simpler form that is only suitable for this narrow use case.
1511
  ///
1512
  /// \param T The return type of the function.
1513
  ///
1514
  /// \param ParamTypes The parameter types of the function. This array
1515
  /// will be modified to account for adjustments to the types of the
1516
  /// function parameters.
1517
  ///
1518
  /// \param Loc The location of the entity whose type involves this
1519
  /// function type or, if there is no such entity, the location of the
1520
  /// type that will have function type.
1521
  ///
1522
  /// \param Entity The name of the entity that involves the function
1523
  /// type, if known.
1524
  ///
1525
  /// \param EPI Extra information about the function type. Usually this will
1526
  /// be taken from an existing function with the same prototype.
1527
  ///
1528
  /// \returns A suitable function type, if there are no errors. The
1529
  /// unqualified type will always be a FunctionProtoType.
1530
  /// Otherwise, returns a NULL type.
1531
  QualType BuildFunctionType(QualType T,
1532
                             MutableArrayRef<QualType> ParamTypes,
1533
                             SourceLocation Loc, DeclarationName Entity,
1534
                             const FunctionProtoType::ExtProtoInfo &EPI);
1535
1536
  QualType BuildMemberPointerType(QualType T, QualType Class,
1537
                                  SourceLocation Loc,
1538
                                  DeclarationName Entity);
1539
  QualType BuildBlockPointerType(QualType T,
1540
                                 SourceLocation Loc, DeclarationName Entity);
1541
  QualType BuildParenType(QualType T);
1542
  QualType BuildAtomicType(QualType T, SourceLocation Loc);
1543
  QualType BuildReadPipeType(QualType T,
1544
                         SourceLocation Loc);
1545
  QualType BuildWritePipeType(QualType T,
1546
                         SourceLocation Loc);
1547
1548
  TypeSourceInfo *GetTypeForDeclarator(Declarator &D, Scope *S);
1549
  TypeSourceInfo *GetTypeForDeclaratorCast(Declarator &D, QualType FromTy);
1550
1551
  /// Package the given type and TSI into a ParsedType.
1552
  ParsedType CreateParsedType(QualType T, TypeSourceInfo *TInfo);
1553
  DeclarationNameInfo GetNameForDeclarator(Declarator &D);
1554
  DeclarationNameInfo GetNameFromUnqualifiedId(const UnqualifiedId &Name);
1555
  static QualType GetTypeFromParser(ParsedType Ty,
1556
                                    TypeSourceInfo **TInfo = nullptr);
1557
  CanThrowResult canThrow(const Expr *E);
1558
  const FunctionProtoType *ResolveExceptionSpec(SourceLocation Loc,
1559
                                                const FunctionProtoType *FPT);
1560
  void UpdateExceptionSpec(FunctionDecl *FD,
1561
                           const FunctionProtoType::ExceptionSpecInfo &ESI);
1562
  bool CheckSpecifiedExceptionType(QualType &T, SourceRange Range);
1563
  bool CheckDistantExceptionSpec(QualType T);
1564
  bool CheckEquivalentExceptionSpec(FunctionDecl *Old, FunctionDecl *New);
1565
  bool CheckEquivalentExceptionSpec(
1566
      const FunctionProtoType *Old, SourceLocation OldLoc,
1567
      const FunctionProtoType *New, SourceLocation NewLoc);
1568
  bool CheckEquivalentExceptionSpec(
1569
      const PartialDiagnostic &DiagID, const PartialDiagnostic & NoteID,
1570
      const FunctionProtoType *Old, SourceLocation OldLoc,
1571
      const FunctionProtoType *New, SourceLocation NewLoc);
1572
  bool handlerCanCatch(QualType HandlerType, QualType ExceptionType);
1573
  bool CheckExceptionSpecSubset(const PartialDiagnostic &DiagID,
1574
                                const PartialDiagnostic &NestedDiagID,
1575
                                const PartialDiagnostic &NoteID,
1576
                                const PartialDiagnostic &NoThrowDiagID,
1577
                                const FunctionProtoType *Superset,
1578
                                SourceLocation SuperLoc,
1579
                                const FunctionProtoType *Subset,
1580
                                SourceLocation SubLoc);
1581
  bool CheckParamExceptionSpec(const PartialDiagnostic &NestedDiagID,
1582
                               const PartialDiagnostic &NoteID,
1583
                               const FunctionProtoType *Target,
1584
                               SourceLocation TargetLoc,
1585
                               const FunctionProtoType *Source,
1586
                               SourceLocation SourceLoc);
1587
1588
  TypeResult ActOnTypeName(Scope *S, Declarator &D);
1589
1590
  /// The parser has parsed the context-sensitive type 'instancetype'
1591
  /// in an Objective-C message declaration. Return the appropriate type.
1592
  ParsedType ActOnObjCInstanceType(SourceLocation Loc);
1593
1594
  /// Abstract class used to diagnose incomplete types.
1595
  struct TypeDiagnoser {
1596
49.3M
    TypeDiagnoser() {}
1597
1598
    virtual void diagnose(Sema &S, SourceLocation Loc, QualType T) = 0;
1599
49.3M
    virtual ~TypeDiagnoser() {}
1600
  };
1601
1602
1.85k
  static int getPrintable(int I) { return I; }
1603
48
  static unsigned getPrintable(unsigned I) { return I; }
1604
128
  static bool getPrintable(bool B) { return B; }
1605
3
  static const char * getPrintable(const char *S) { return S; }
1606
0
  static StringRef getPrintable(StringRef S) { return S; }
1607
0
  static const std::string &getPrintable(const std::string &S) { return S; }
1608
5
  static const IdentifierInfo *getPrintable(const IdentifierInfo *II) {
1609
5
    return II;
1610
5
  }
1611
16
  static DeclarationName getPrintable(DeclarationName N) { return N; }
1612
23
  static QualType getPrintable(QualType T) { return T; }
1613
375
  static SourceRange getPrintable(SourceRange R) { return R; }
1614
0
  static SourceRange getPrintable(SourceLocation L) { return L; }
1615
39
  static SourceRange getPrintable(const Expr *E) { return E->getSourceRange(); }
1616
12
  static SourceRange getPrintable(TypeLoc TL) { return TL.getSourceRange();}
1617
1618
  template <typename... Ts> class BoundTypeDiagnoser : public TypeDiagnoser {
1619
    unsigned DiagID;
1620
    std::tuple<const Ts &...> Args;
1621
1622
    template <std::size_t... Is>
1623
    void emit(const SemaDiagnosticBuilder &DB,
1624
3.90k
              llvm::index_sequence<Is...>) const {
1625
3.90k
      // Apply all tuple elements to the builder in order.
1626
3.90k
      bool Dummy[] = {false, (DB << getPrintable(std::get<Is>(Args)))...};
1627
3.90k
      (void)Dummy;
1628
3.90k
    }
void clang::Sema::BoundTypeDiagnoser<clang::SourceRange>::emit<0ul>(clang::Sema::SemaDiagnosticBuilder const&, llvm::index_sequence<0ul>) const
Line
Count
Source
1624
217
              llvm::index_sequence<Is...>) const {
1625
217
      // Apply all tuple elements to the builder in order.
1626
217
      bool Dummy[] = {false, (DB << getPrintable(std::get<Is>(Args)))...};
1627
217
      (void)Dummy;
1628
217
    }
void clang::Sema::BoundTypeDiagnoser<clang::Expr*>::emit<0ul>(clang::Sema::SemaDiagnosticBuilder const&, llvm::index_sequence<0ul>) const
Line
Count
Source
1624
38
              llvm::index_sequence<Is...>) const {
1625
38
      // Apply all tuple elements to the builder in order.
1626
38
      bool Dummy[] = {false, (DB << getPrintable(std::get<Is>(Args)))...};
1627
38
      (void)Dummy;
1628
38
    }
void clang::Sema::BoundTypeDiagnoser<>::emit<>(clang::Sema::SemaDiagnosticBuilder const&, llvm::index_sequence<>) const
Line
Count
Source
1624
1.65k
              llvm::index_sequence<Is...>) const {
1625
1.65k
      // Apply all tuple elements to the builder in order.
1626
1.65k
      bool Dummy[] = {false, (DB << getPrintable(std::get<Is>(Args)))...};
1627
1.65k
      (void)Dummy;
1628
1.65k
    }
void clang::Sema::BoundTypeDiagnoser<clang::Sema::AbstractDiagSelID>::emit<0ul>(clang::Sema::SemaDiagnosticBuilder const&, llvm::index_sequence<0ul>) const
Line
Count
Source
1624
1.76k
              llvm::index_sequence<Is...>) const {
1625
1.76k
      // Apply all tuple elements to the builder in order.
1626
1.76k
      bool Dummy[] = {false, (DB << getPrintable(std::get<Is>(Args)))...};
1627
1.76k
      (void)Dummy;
1628
1.76k
    }
Unexecuted instantiation: void clang::Sema::BoundTypeDiagnoser<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >::emit<0ul>(clang::Sema::SemaDiagnosticBuilder const&, llvm::index_sequence<0ul>) const
void clang::Sema::BoundTypeDiagnoser<unsigned int, clang::SourceRange, bool, bool>::emit<0ul, 1ul, 2ul, 3ul>(clang::Sema::SemaDiagnosticBuilder const&, llvm::index_sequence<0ul, 1ul, 2ul, 3ul>) const
Line
Count
Source
1624
48
              llvm::index_sequence<Is...>) const {
1625
48
      // Apply all tuple elements to the builder in order.
1626
48
      bool Dummy[] = {false, (DB << getPrintable(std::get<Is>(Args)))...};
1627
48
      (void)Dummy;
1628
48
    }
void clang::Sema::BoundTypeDiagnoser<bool>::emit<0ul>(clang::Sema::SemaDiagnosticBuilder const&, llvm::index_sequence<0ul>) const
Line
Count
Source
1624
32
              llvm::index_sequence<Is...>) const {
1625
32
      // Apply all tuple elements to the builder in order.
1626
32
      bool Dummy[] = {false, (DB << getPrintable(std::get<Is>(Args)))...};
1627
32
      (void)Dummy;
1628
32
    }
void clang::Sema::BoundTypeDiagnoser<clang::DeclarationName>::emit<0ul>(clang::Sema::SemaDiagnosticBuilder const&, llvm::index_sequence<0ul>) const
Line
Count
Source
1624
9
              llvm::index_sequence<Is...>) const {
1625
9
      // Apply all tuple elements to the builder in order.
1626
9
      bool Dummy[] = {false, (DB << getPrintable(std::get<Is>(Args)))...};
1627
9
      (void)Dummy;
1628
9
    }
void clang::Sema::BoundTypeDiagnoser<clang::DeclarationName, clang::IdentifierInfo*, clang::SourceRange>::emit<0ul, 1ul, 2ul>(clang::Sema::SemaDiagnosticBuilder const&, llvm::index_sequence<0ul, 1ul, 2ul>) const
Line
Count
Source
1624
5
              llvm::index_sequence<Is...>) const {
1625
5
      // Apply all tuple elements to the builder in order.
1626
5
      bool Dummy[] = {false, (DB << getPrintable(std::get<Is>(Args)))...};
1627
5
      (void)Dummy;
1628
5
    }
void clang::Sema::BoundTypeDiagnoser<int, clang::SourceRange>::emit<0ul, 1ul>(clang::Sema::SemaDiagnosticBuilder const&, llvm::index_sequence<0ul, 1ul>) const
Line
Count
Source
1624
15
              llvm::index_sequence<Is...>) const {
1625
15
      // Apply all tuple elements to the builder in order.
1626
15
      bool Dummy[] = {false, (DB << getPrintable(std::get<Is>(Args)))...};
1627
15
      (void)Dummy;
1628
15
    }
void clang::Sema::BoundTypeDiagnoser<clang::QualType, clang::SourceRange>::emit<0ul, 1ul>(clang::Sema::SemaDiagnosticBuilder const&, llvm::index_sequence<0ul, 1ul>) const
Line
Count
Source
1624
19
              llvm::index_sequence<Is...>) const {
1625
19
      // Apply all tuple elements to the builder in order.
1626
19
      bool Dummy[] = {false, (DB << getPrintable(std::get<Is>(Args)))...};
1627
19
      (void)Dummy;
1628
19
    }
void clang::Sema::BoundTypeDiagnoser<clang::UnaryExprOrTypeTrait, clang::SourceRange>::emit<0ul, 1ul>(clang::Sema::SemaDiagnosticBuilder const&, llvm::index_sequence<0ul, 1ul>) const
Line
Count
Source
1624
70
              llvm::index_sequence<Is...>) const {
1625
70
      // Apply all tuple elements to the builder in order.
1626
70
      bool Dummy[] = {false, (DB << getPrintable(std::get<Is>(Args)))...};
1627
70
      (void)Dummy;
1628
70
    }
void clang::Sema::BoundTypeDiagnoser<clang::TypeLoc>::emit<0ul>(clang::Sema::SemaDiagnosticBuilder const&, llvm::index_sequence<0ul>) const
Line
Count
Source
1624
12
              llvm::index_sequence<Is...>) const {
1625
12
      // Apply all tuple elements to the builder in order.
1626
12
      bool Dummy[] = {false, (DB << getPrintable(std::get<Is>(Args)))...};
1627
12
      (void)Dummy;
1628
12
    }
void clang::Sema::BoundTypeDiagnoser<char const*, int>::emit<0ul, 1ul>(clang::Sema::SemaDiagnosticBuilder const&, llvm::index_sequence<0ul, 1ul>) const
Line
Count
Source
1624
3
              llvm::index_sequence<Is...>) const {
1625
3
      // Apply all tuple elements to the builder in order.
1626
3
      bool Dummy[] = {false, (DB << getPrintable(std::get<Is>(Args)))...};
1627
3
      (void)Dummy;
1628
3
    }
void clang::Sema::BoundTypeDiagnoser<clang::DeclarationName, clang::SourceRange>::emit<0ul, 1ul>(clang::Sema::SemaDiagnosticBuilder const&, llvm::index_sequence<0ul, 1ul>) const
Line
Count
Source
1624
1
              llvm::index_sequence<Is...>) const {
1625
1
      // Apply all tuple elements to the builder in order.
1626
1
      bool Dummy[] = {false, (DB << getPrintable(std::get<Is>(Args)))...};
1627
1
      (void)Dummy;
1628
1
    }
void clang::Sema::BoundTypeDiagnoser<clang::DeclarationName, clang::Expr*>::emit<0ul, 1ul>(clang::Sema::SemaDiagnosticBuilder const&, llvm::index_sequence<0ul, 1ul>) const
Line
Count
Source
1624
1
              llvm::index_sequence<Is...>) const {
1625
1
      // Apply all tuple elements to the builder in order.
1626
1
      bool Dummy[] = {false, (DB << getPrintable(std::get<Is>(Args)))...};
1627
1
      (void)Dummy;
1628
1
    }
void clang::Sema::BoundTypeDiagnoser<clang::QualType>::emit<0ul>(clang::Sema::SemaDiagnosticBuilder const&, llvm::index_sequence<0ul>) const
Line
Count
Source
1624
4
              llvm::index_sequence<Is...>) const {
1625
4
      // Apply all tuple elements to the builder in order.
1626
4
      bool Dummy[] = {false, (DB << getPrintable(std::get<Is>(Args)))...};
1627
4
      (void)Dummy;
1628
4
    }
void clang::Sema::BoundTypeDiagnoser<int>::emit<0ul>(clang::Sema::SemaDiagnosticBuilder const&, llvm::index_sequence<0ul>) const
Line
Count
Source
1624
1
              llvm::index_sequence<Is...>) const {
1625
1
      // Apply all tuple elements to the builder in order.
1626
1
      bool Dummy[] = {false, (DB << getPrintable(std::get<Is>(Args)))...};
1627
1
      (void)Dummy;
1628
1
    }
1629
1630
  public:
1631
    BoundTypeDiagnoser(unsigned DiagID, const Ts &...Args)
1632
49.3M
        : TypeDiagnoser(), DiagID(DiagID), Args(Args...) {
1633
49.3M
      assert(DiagID != 0 && "no diagnostic for type diagnoser");
1634
49.3M
    }
clang::Sema::BoundTypeDiagnoser<clang::SourceRange>::BoundTypeDiagnoser(unsigned int, clang::SourceRange const&)
Line
Count
Source
1632
4.80M
        : TypeDiagnoser(), DiagID(DiagID), Args(Args...) {
1633
4.80M
      assert(DiagID != 0 && "no diagnostic for type diagnoser");
1634
4.80M
    }
clang::Sema::BoundTypeDiagnoser<clang::Expr*>::BoundTypeDiagnoser(unsigned int, clang::Expr* const&)
Line
Count
Source
1632
7.14M
        : TypeDiagnoser(), DiagID(DiagID), Args(Args...) {
1633
7.14M
      assert(DiagID != 0 && "no diagnostic for type diagnoser");
1634
7.14M
    }
clang::Sema::BoundTypeDiagnoser<>::BoundTypeDiagnoser(unsigned int)
Line
Count
Source
1632
20.7M
        : TypeDiagnoser(), DiagID(DiagID), Args(Args...) {
1633
20.7M
      assert(DiagID != 0 && "no diagnostic for type diagnoser");
1634
20.7M
    }
clang::Sema::BoundTypeDiagnoser<clang::Sema::AbstractDiagSelID>::BoundTypeDiagnoser(unsigned int, clang::Sema::AbstractDiagSelID const&)
Line
Count
Source
1632
16.1M
        : TypeDiagnoser(), DiagID(DiagID), Args(Args...) {
1633
16.1M
      assert(DiagID != 0 && "no diagnostic for type diagnoser");
1634
16.1M
    }
clang::Sema::BoundTypeDiagnoser<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >::BoundTypeDiagnoser(unsigned int, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)
Line
Count
Source
1632
2
        : TypeDiagnoser(), DiagID(DiagID), Args(Args...) {
1633
2
      assert(DiagID != 0 && "no diagnostic for type diagnoser");
1634
2
    }
clang::Sema::BoundTypeDiagnoser<unsigned int, clang::SourceRange, bool, bool>::BoundTypeDiagnoser(unsigned int, unsigned int const&, clang::SourceRange const&, bool const&, bool const&)
Line
Count
Source
1632
40.7k
        : TypeDiagnoser(), DiagID(DiagID), Args(Args...) {
1633
40.7k
      assert(DiagID != 0 && "no diagnostic for type diagnoser");
1634
40.7k
    }
clang::Sema::BoundTypeDiagnoser<bool>::BoundTypeDiagnoser(unsigned int, bool const&)
Line
Count
Source
1632
78.2k
        : TypeDiagnoser(), DiagID(DiagID), Args(Args...) {
1633
78.2k
      assert(DiagID != 0 && "no diagnostic for type diagnoser");
1634
78.2k
    }
clang::Sema::BoundTypeDiagnoser<clang::DeclarationName>::BoundTypeDiagnoser(unsigned int, clang::DeclarationName const&)
Line
Count
Source
1632
3.34k
        : TypeDiagnoser(), DiagID(DiagID), Args(Args...) {
1633
3.34k
      assert(DiagID != 0 && "no diagnostic for type diagnoser");
1634
3.34k
    }
clang::Sema::BoundTypeDiagnoser<clang::DeclarationName, clang::IdentifierInfo*, clang::SourceRange>::BoundTypeDiagnoser(unsigned int, clang::DeclarationName const&, clang::IdentifierInfo* const&, clang::SourceRange const&)
Line
Count
Source
1632
6.34k
        : TypeDiagnoser(), DiagID(DiagID), Args(Args...) {
1633
6.34k
      assert(DiagID != 0 && "no diagnostic for type diagnoser");
1634
6.34k
    }
clang::Sema::BoundTypeDiagnoser<int, clang::SourceRange>::BoundTypeDiagnoser(unsigned int, int const&, clang::SourceRange const&)
Line
Count
Source
1632
1.03k
        : TypeDiagnoser(), DiagID(DiagID), Args(Args...) {
1633
1.03k
      assert(DiagID != 0 && "no diagnostic for type diagnoser");
1634
1.03k
    }
clang::Sema::BoundTypeDiagnoser<clang::QualType, clang::SourceRange>::BoundTypeDiagnoser(unsigned int, clang::QualType const&, clang::SourceRange const&)
Line
Count
Source
1632
143k
        : TypeDiagnoser(), DiagID(DiagID), Args(Args...) {
1633
143k
      assert(DiagID != 0 && "no diagnostic for type diagnoser");
1634
143k
    }
clang::Sema::BoundTypeDiagnoser<clang::UnaryExprOrTypeTrait, clang::SourceRange>::BoundTypeDiagnoser(unsigned int, clang::UnaryExprOrTypeTrait const&, clang::SourceRange const&)
Line
Count
Source
1632
175k
        : TypeDiagnoser(), DiagID(DiagID), Args(Args...) {
1633
175k
      assert(DiagID != 0 && "no diagnostic for type diagnoser");
1634
175k
    }
clang::Sema::BoundTypeDiagnoser<clang::TypeLoc>::BoundTypeDiagnoser(unsigned int, clang::TypeLoc const&)
Line
Count
Source
1632
3.04k
        : TypeDiagnoser(), DiagID(DiagID), Args(Args...) {
1633
3.04k
      assert(DiagID != 0 && "no diagnostic for type diagnoser");
1634
3.04k
    }
clang::Sema::BoundTypeDiagnoser<char const*, int>::BoundTypeDiagnoser(unsigned int, char const* const&, int const&)
Line
Count
Source
1632
65
        : TypeDiagnoser(), DiagID(DiagID), Args(Args...) {
1633
65
      assert(DiagID != 0 && "no diagnostic for type diagnoser");
1634
65
    }
clang::Sema::BoundTypeDiagnoser<clang::DeclarationName, clang::SourceRange>::BoundTypeDiagnoser(unsigned int, clang::DeclarationName const&, clang::SourceRange const&)
Line
Count
Source
1632
1.97k
        : TypeDiagnoser(), DiagID(DiagID), Args(Args...) {
1633
1.97k
      assert(DiagID != 0 && "no diagnostic for type diagnoser");
1634
1.97k
    }
clang::Sema::BoundTypeDiagnoser<clang::DeclarationName, clang::Expr*>::BoundTypeDiagnoser(unsigned int, clang::DeclarationName const&, clang::Expr* const&)
Line
Count
Source
1632
1
        : TypeDiagnoser(), DiagID(DiagID), Args(Args...) {
1633
1
      assert(DiagID != 0 && "no diagnostic for type diagnoser");
1634
1
    }
clang::Sema::BoundTypeDiagnoser<clang::QualType>::BoundTypeDiagnoser(unsigned int, clang::QualType const&)
Line
Count
Source
1632
108
        : TypeDiagnoser(), DiagID(DiagID), Args(Args...) {
1633
108
      assert(DiagID != 0 && "no diagnostic for type diagnoser");
1634
108
    }
clang::Sema::BoundTypeDiagnoser<int>::BoundTypeDiagnoser(unsigned int, int const&)
Line
Count
Source
1632
7.53k
        : TypeDiagnoser(), DiagID(DiagID), Args(Args...) {
1633
7.53k
      assert(DiagID != 0 && "no diagnostic for type diagnoser");
1634
7.53k
    }
1635
1636
3.90k
    void diagnose(Sema &S, SourceLocation Loc, QualType T) override {
1637
3.90k
      const SemaDiagnosticBuilder &DB = S.Diag(Loc, DiagID);
1638
3.90k
      emit(DB, llvm::index_sequence_for<Ts...>());
1639
3.90k
      DB << T;
1640
3.90k
    }
clang::Sema::BoundTypeDiagnoser<clang::SourceRange>::diagnose(clang::Sema&, clang::SourceLocation, clang::QualType)
Line
Count
Source
1636
217
    void diagnose(Sema &S, SourceLocation Loc, QualType T) override {
1637
217
      const SemaDiagnosticBuilder &DB = S.Diag(Loc, DiagID);
1638
217
      emit(DB, llvm::index_sequence_for<Ts...>());
1639
217
      DB << T;
1640
217
    }
clang::Sema::BoundTypeDiagnoser<clang::Expr*>::diagnose(clang::Sema&, clang::SourceLocation, clang::QualType)
Line
Count
Source
1636
38
    void diagnose(Sema &S, SourceLocation Loc, QualType T) override {
1637
38
      const SemaDiagnosticBuilder &DB = S.Diag(Loc, DiagID);
1638
38
      emit(DB, llvm::index_sequence_for<Ts...>());
1639
38
      DB << T;
1640
38
    }
clang::Sema::BoundTypeDiagnoser<>::diagnose(clang::Sema&, clang::SourceLocation, clang::QualType)
Line
Count
Source
1636
1.65k
    void diagnose(Sema &S, SourceLocation Loc, QualType T) override {
1637
1.65k
      const SemaDiagnosticBuilder &DB = S.Diag(Loc, DiagID);
1638
1.65k
      emit(DB, llvm::index_sequence_for<Ts...>());
1639
1.65k
      DB << T;
1640
1.65k
    }
clang::Sema::BoundTypeDiagnoser<clang::Sema::AbstractDiagSelID>::diagnose(clang::Sema&, clang::SourceLocation, clang::QualType)
Line
Count
Source
1636
1.76k
    void diagnose(Sema &S, SourceLocation Loc, QualType T) override {
1637
1.76k
      const SemaDiagnosticBuilder &DB = S.Diag(Loc, DiagID);
1638
1.76k
      emit(DB, llvm::index_sequence_for<Ts...>());
1639
1.76k
      DB << T;
1640
1.76k
    }
Unexecuted instantiation: clang::Sema::BoundTypeDiagnoser<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >::diagnose(clang::Sema&, clang::SourceLocation, clang::QualType)
clang::Sema::BoundTypeDiagnoser<unsigned int, clang::SourceRange, bool, bool>::diagnose(clang::Sema&, clang::SourceLocation, clang::QualType)
Line
Count
Source
1636
48
    void diagnose(Sema &S, SourceLocation Loc, QualType T) override {
1637
48
      const SemaDiagnosticBuilder &DB = S.Diag(Loc, DiagID);
1638
48
      emit(DB, llvm::index_sequence_for<Ts...>());
1639
48
      DB << T;
1640
48
    }
clang::Sema::BoundTypeDiagnoser<bool>::diagnose(clang::Sema&, clang::SourceLocation, clang::QualType)
Line
Count
Source
1636
32
    void diagnose(Sema &S, SourceLocation Loc, QualType T) override {
1637
32
      const SemaDiagnosticBuilder &DB = S.Diag(Loc, DiagID);
1638
32
      emit(DB, llvm::index_sequence_for<Ts...>());
1639
32
      DB << T;
1640
32
    }
clang::Sema::BoundTypeDiagnoser<clang::DeclarationName>::diagnose(clang::Sema&, clang::SourceLocation, clang::QualType)
Line
Count
Source
1636
9
    void diagnose(Sema &S, SourceLocation Loc, QualType T) override {
1637
9
      const SemaDiagnosticBuilder &DB = S.Diag(Loc, DiagID);
1638
9
      emit(DB, llvm::index_sequence_for<Ts...>());
1639
9
      DB << T;
1640
9
    }
clang::Sema::BoundTypeDiagnoser<clang::DeclarationName, clang::IdentifierInfo*, clang::SourceRange>::diagnose(clang::Sema&, clang::SourceLocation, clang::QualType)
Line
Count
Source
1636
5
    void diagnose(Sema &S, SourceLocation Loc, QualType T) override {
1637
5
      const SemaDiagnosticBuilder &DB = S.Diag(Loc, DiagID);
1638
5
      emit(DB, llvm::index_sequence_for<Ts...>());
1639
5
      DB << T;
1640
5
    }
clang::Sema::BoundTypeDiagnoser<int, clang::SourceRange>::diagnose(clang::Sema&, clang::SourceLocation, clang::QualType)
Line
Count
Source
1636
15
    void diagnose(Sema &S, SourceLocation Loc, QualType T) override {
1637
15
      const SemaDiagnosticBuilder &DB = S.Diag(Loc, DiagID);
1638
15
      emit(DB, llvm::index_sequence_for<Ts...>());
1639
15
      DB << T;
1640
15
    }
clang::Sema::BoundTypeDiagnoser<clang::QualType, clang::SourceRange>::diagnose(clang::Sema&, clang::SourceLocation, clang::QualType)
Line
Count
Source
1636
19
    void diagnose(Sema &S, SourceLocation Loc, QualType T) override {
1637
19
      const SemaDiagnosticBuilder &DB = S.Diag(Loc, DiagID);
1638
19
      emit(DB, llvm::index_sequence_for<Ts...>());
1639
19
      DB << T;
1640
19
    }
clang::Sema::BoundTypeDiagnoser<clang::UnaryExprOrTypeTrait, clang::SourceRange>::diagnose(clang::Sema&, clang::SourceLocation, clang::QualType)
Line
Count
Source
1636
70
    void diagnose(Sema &S, SourceLocation Loc, QualType T) override {
1637
70
      const SemaDiagnosticBuilder &DB = S.Diag(Loc, DiagID);
1638
70
      emit(DB, llvm::index_sequence_for<Ts...>());
1639
70
      DB << T;
1640
70
    }
clang::Sema::BoundTypeDiagnoser<clang::TypeLoc>::diagnose(clang::Sema&, clang::SourceLocation, clang::QualType)
Line
Count
Source
1636
12
    void diagnose(Sema &S, SourceLocation Loc, QualType T) override {
1637
12
      const SemaDiagnosticBuilder &DB = S.Diag(Loc, DiagID);
1638
12
      emit(DB, llvm::index_sequence_for<Ts...>());
1639
12
      DB << T;
1640
12
    }
clang::Sema::BoundTypeDiagnoser<char const*, int>::diagnose(clang::Sema&, clang::SourceLocation, clang::QualType)
Line
Count
Source
1636
3
    void diagnose(Sema &S, SourceLocation Loc, QualType T) override {
1637
3
      const SemaDiagnosticBuilder &DB = S.Diag(Loc, DiagID);
1638
3
      emit(DB, llvm::index_sequence_for<Ts...>());
1639
3
      DB << T;
1640
3
    }
clang::Sema::BoundTypeDiagnoser<clang::DeclarationName, clang::SourceRange>::diagnose(clang::Sema&, clang::SourceLocation, clang::QualType)
Line
Count
Source
1636
1
    void diagnose(Sema &S, SourceLocation Loc, QualType T) override {
1637
1
      const SemaDiagnosticBuilder &DB = S.Diag(Loc, DiagID);
1638
1
      emit(DB, llvm::index_sequence_for<Ts...>());
1639
1
      DB << T;
1640
1
    }
clang::Sema::BoundTypeDiagnoser<clang::DeclarationName, clang::Expr*>::diagnose(clang::Sema&, clang::SourceLocation, clang::QualType)
Line
Count
Source
1636
1
    void diagnose(Sema &S, SourceLocation Loc, QualType T) override {
1637
1
      const SemaDiagnosticBuilder &DB = S.Diag(Loc, DiagID);
1638
1
      emit(DB, llvm::index_sequence_for<Ts...>());
1639
1
      DB << T;
1640
1
    }
clang::Sema::BoundTypeDiagnoser<clang::QualType>::diagnose(clang::Sema&, clang::SourceLocation, clang::QualType)
Line
Count
Source
1636
4
    void diagnose(Sema &S, SourceLocation Loc, QualType T) override {
1637
4
      const SemaDiagnosticBuilder &DB = S.Diag(Loc, DiagID);
1638
4
      emit(DB, llvm::index_sequence_for<Ts...>());
1639
4
      DB << T;
1640
4
    }
clang::Sema::BoundTypeDiagnoser<int>::diagnose(clang::Sema&, clang::SourceLocation, clang::QualType)
Line
Count
Source
1636
1
    void diagnose(Sema &S, SourceLocation Loc, QualType T) override {
1637
1
      const SemaDiagnosticBuilder &DB = S.Diag(Loc, DiagID);
1638
1
      emit(DB, llvm::index_sequence_for<Ts...>());
1639
1
      DB << T;
1640
1
    }
1641
  };
1642
1643
private:
1644
  /// Methods for marking which expressions involve dereferencing a pointer
1645
  /// marked with the 'noderef' attribute. Expressions are checked bottom up as
1646
  /// they are parsed, meaning that a noderef pointer may not be accessed. For
1647
  /// example, in `&*p` where `p` is a noderef pointer, we will first parse the
1648
  /// `*p`, but need to check that `address of` is called on it. This requires
1649
  /// keeping a container of all pending expressions and checking if the address
1650
  /// of them are eventually taken.
1651
  void CheckSubscriptAccessOfNoDeref(const ArraySubscriptExpr *E);
1652
  void CheckAddressOfNoDeref(const Expr *E);
1653
  void CheckMemberAccessOfNoDeref(const MemberExpr *E);
1654
1655
  bool RequireCompleteTypeImpl(SourceLocation Loc, QualType T,
1656
                               TypeDiagnoser *Diagnoser);
1657
1658
  struct ModuleScope {
1659
    SourceLocation BeginLoc;
1660
    clang::Module *Module = nullptr;
1661
    bool ModuleInterface = false;
1662
    bool ImplicitGlobalModuleFragment = false;
1663
    VisibleModuleSet OuterVisibleModules;
1664
  };
1665
  /// The modules we're currently parsing.
1666
  llvm::SmallVector<ModuleScope, 16> ModuleScopes;
1667
1668
  /// Namespace definitions that we will export when they finish.
1669
  llvm::SmallPtrSet<const NamespaceDecl*, 8> DeferredExportedNamespaces;
1670
1671
  /// Get the module whose scope we are currently within.
1672
315k
  Module *getCurrentModule() const {
1673
315k
    return ModuleScopes.empty() ? 
nullptr313k
:
ModuleScopes.back().Module2.14k
;
1674
315k
  }
1675
1676
  VisibleModuleSet VisibleModules;
1677
1678
public:
1679
  /// Get the module owning an entity.
1680
40.1k
  Module *getOwningModule(Decl *Entity) { return Entity->getOwningModule(); }
1681
1682
  /// Make a merged definition of an existing hidden definition \p ND
1683
  /// visible at the specified location.
1684
  void makeMergedDefinitionVisible(NamedDecl *ND);
1685
1686
  bool isModuleVisible(const Module *M, bool ModulePrivate = false);
1687
1688
  /// Determine whether a declaration is visible to name lookup.
1689
33.6M
  bool isVisible(const NamedDecl *D) {
1690
33.6M
    return !D->isHidden() || 
isVisibleSlow(D)8.69k
;
1691
33.6M
  }
1692
1693
  /// Determine whether any declaration of an entity is visible.
1694
  bool
1695
  hasVisibleDeclaration(const NamedDecl *D,
1696
84.6k
                        llvm::SmallVectorImpl<Module *> *Modules = nullptr) {
1697
84.6k
    return isVisible(D) || 
hasVisibleDeclarationSlow(D, Modules)71
;
1698
84.6k
  }
1699
  bool hasVisibleDeclarationSlow(const NamedDecl *D,
1700
                                 llvm::SmallVectorImpl<Module *> *Modules);
1701
1702
  bool hasVisibleMergedDefinition(NamedDecl *Def);
1703
  bool hasMergedDefinitionInCurrentModule(NamedDecl *Def);
1704
1705
  /// Determine if \p D and \p Suggested have a structurally compatible
1706
  /// layout as described in C11 6.2.7/1.
1707
  bool hasStructuralCompatLayout(Decl *D, Decl *Suggested);
1708
1709
  /// Determine if \p D has a visible definition. If not, suggest a declaration
1710
  /// that should be made visible to expose the definition.
1711
  bool hasVisibleDefinition(NamedDecl *D, NamedDecl **Suggested,
1712
                            bool OnlyNeedComplete = false);
1713
1.47k
  bool hasVisibleDefinition(const NamedDecl *D) {
1714
1.47k
    NamedDecl *Hidden;
1715
1.47k
    return hasVisibleDefinition(const_cast<NamedDecl*>(D), &Hidden);
1716
1.47k
  }
1717
1718
  /// Determine if the template parameter \p D has a visible default argument.
1719
  bool
1720
  hasVisibleDefaultArgument(const NamedDecl *D,
1721
                            llvm::SmallVectorImpl<Module *> *Modules = nullptr);
1722
1723
  /// Determine if there is a visible declaration of \p D that is an explicit
1724
  /// specialization declaration for a specialization of a template. (For a
1725
  /// member specialization, use hasVisibleMemberSpecialization.)
1726
  bool hasVisibleExplicitSpecialization(
1727
      const NamedDecl *D, llvm::SmallVectorImpl<Module *> *Modules = nullptr);
1728
1729
  /// Determine if there is a visible declaration of \p D that is a member
1730
  /// specialization declaration (as opposed to an instantiated declaration).
1731
  bool hasVisibleMemberSpecialization(
1732
      const NamedDecl *D, llvm::SmallVectorImpl<Module *> *Modules = nullptr);
1733
1734
  /// Determine if \p A and \p B are equivalent internal linkage declarations
1735
  /// from different modules, and thus an ambiguity error can be downgraded to
1736
  /// an extension warning.
1737
  bool isEquivalentInternalLinkageDeclaration(const NamedDecl *A,
1738
                                              const NamedDecl *B);
1739
  void diagnoseEquivalentInternalLinkageDeclarations(
1740
      SourceLocation Loc, const NamedDecl *D,
1741
      ArrayRef<const NamedDecl *> Equiv);
1742
1743
  bool isUsualDeallocationFunction(const CXXMethodDecl *FD);
1744
1745
25.7M
  bool isCompleteType(SourceLocation Loc, QualType T) {
1746
25.7M
    return !RequireCompleteTypeImpl(Loc, T, nullptr);
1747
25.7M
  }
1748
  bool RequireCompleteType(SourceLocation Loc, QualType T,
1749
                           TypeDiagnoser &Diagnoser);
1750
  bool RequireCompleteType(SourceLocation Loc, QualType T,
1751
                           unsigned DiagID);
1752
1753
  template <typename... Ts>
1754
  bool RequireCompleteType(SourceLocation Loc, QualType T, unsigned DiagID,
1755
12.2M
                           const Ts &...Args) {
1756
12.2M
    BoundTypeDiagnoser<Ts...> Diagnoser(DiagID, Args...);
1757
12.2M
    return RequireCompleteType(Loc, T, Diagnoser);
1758
12.2M
  }
bool clang::Sema::RequireCompleteType<clang::SourceRange>(clang::SourceLocation, clang::QualType, unsigned int, clang::SourceRange const&)
Line
Count
Source
1755
4.80M
                           const Ts &...Args) {
1756
4.80M
    BoundTypeDiagnoser<Ts...> Diagnoser(DiagID, Args...);
1757
4.80M
    return RequireCompleteType(Loc, T, Diagnoser);
1758
4.80M
  }
bool clang::Sema::RequireCompleteType<clang::Expr*>(clang::SourceLocation, clang::QualType, unsigned int, clang::Expr* const&)
Line
Count
Source
1755
7.14M
                           const Ts &...Args) {
1756
7.14M
    BoundTypeDiagnoser<Ts...> Diagnoser(DiagID, Args...);
1757
7.14M
    return RequireCompleteType(Loc, T, Diagnoser);
1758
7.14M
  }
bool clang::Sema::RequireCompleteType<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >(clang::SourceLocation, clang::QualType, unsigned int, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)
Line
Count
Source
1755
2
                           const Ts &...Args) {
1756
2
    BoundTypeDiagnoser<Ts...> Diagnoser(DiagID, Args...);
1757
2
    return RequireCompleteType(Loc, T, Diagnoser);
1758
2
  }
bool clang::Sema::RequireCompleteType<clang::DeclarationName>(clang::SourceLocation, clang::QualType, unsigned int, clang::DeclarationName const&)
Line
Count
Source
1755
3.34k
                           const Ts &...Args) {
1756
3.34k
    BoundTypeDiagnoser<Ts...> Diagnoser(DiagID, Args...);
1757
3.34k
    return RequireCompleteType(Loc, T, Diagnoser);
1758
3.34k
  }
bool clang::Sema::RequireCompleteType<clang::DeclarationName, clang::IdentifierInfo*, clang::SourceRange>(clang::SourceLocation, clang::QualType, unsigned int, clang::DeclarationName const&, clang::IdentifierInfo* const&, clang::SourceRange const&)
Line
Count
Source
1755
6.34k
                           const Ts &...Args) {
1756
6.34k
    BoundTypeDiagnoser<Ts...> Diagnoser(DiagID, Args...);
1757
6.34k
    return RequireCompleteType(Loc, T, Diagnoser);
1758
6.34k
  }
bool clang::Sema::RequireCompleteType<bool>(clang::SourceLocation, clang::QualType, unsigned int, bool const&)
Line
Count
Source
1755
3.75k
                           const Ts &...Args) {
1756
3.75k
    BoundTypeDiagnoser<Ts...> Diagnoser(DiagID, Args...);
1757
3.75k
    return RequireCompleteType(Loc, T, Diagnoser);
1758
3.75k
  }
bool clang::Sema::RequireCompleteType<int, clang::SourceRange>(clang::SourceLocation, clang::QualType, unsigned int, int const&, clang::SourceRange const&)
Line
Count
Source
1755
1.03k
                           const Ts &...Args) {
1756
1.03k
    BoundTypeDiagnoser<Ts...> Diagnoser(DiagID, Args...);
1757
1.03k
    return RequireCompleteType(Loc, T, Diagnoser);
1758
1.03k
  }
bool clang::Sema::RequireCompleteType<clang::QualType, clang::SourceRange>(clang::SourceLocation, clang::QualType, unsigned int, clang::QualType const&, clang::SourceRange const&)
Line
Count
Source
1755
143k
                           const Ts &...Args) {
1756
143k
    BoundTypeDiagnoser<Ts...> Diagnoser(DiagID, Args...);
1757
143k
    return RequireCompleteType(Loc, T, Diagnoser);
1758
143k
  }
bool clang::Sema::RequireCompleteType<clang::UnaryExprOrTypeTrait, clang::SourceRange>(clang::SourceLocation, clang::QualType, unsigned int, clang::UnaryExprOrTypeTrait const&, clang::SourceRange const&)
Line
Count
Source
1755
126k
                           const Ts &...Args) {
1756
126k
    BoundTypeDiagnoser<Ts...> Diagnoser(DiagID, Args...);
1757
126k
    return RequireCompleteType(Loc, T, Diagnoser);
1758
126k
  }
bool clang::Sema::RequireCompleteType<clang::TypeLoc>(clang::SourceLocation, clang::QualType, unsigned int, clang::TypeLoc const&)
Line
Count
Source
1755
1.57k
                           const Ts &...Args) {
1756
1.57k
    BoundTypeDiagnoser<Ts...> Diagnoser(DiagID, Args...);
1757
1.57k
    return RequireCompleteType(Loc, T, Diagnoser);
1758
1.57k
  }
bool clang::Sema::RequireCompleteType<char const*, int>(clang::SourceLocation, clang::QualType, unsigned int, char const* const&, int const&)
Line
Count
Source
1755
65
                           const Ts &...Args) {
1756
65
    BoundTypeDiagnoser<Ts...> Diagnoser(DiagID, Args...);
1757
65
    return RequireCompleteType(Loc, T, Diagnoser);
1758
65
  }
bool clang::Sema::RequireCompleteType<clang::DeclarationName, clang::SourceRange>(clang::SourceLocation, clang::QualType, unsigned int, clang::DeclarationName const&, clang::SourceRange const&)
Line
Count
Source
1755
1.97k
                           const Ts &...Args) {
1756
1.97k
    BoundTypeDiagnoser<Ts...> Diagnoser(DiagID, Args...);
1757
1.97k
    return RequireCompleteType(Loc, T, Diagnoser);
1758
1.97k
  }
bool clang::Sema::RequireCompleteType<clang::DeclarationName, clang::Expr*>(clang::SourceLocation, clang::QualType, unsigned int, clang::DeclarationName const&, clang::Expr* const&)
Line
Count
Source
1755
1
                           const Ts &...Args) {
1756
1
    BoundTypeDiagnoser<Ts...> Diagnoser(DiagID, Args...);
1757
1
    return RequireCompleteType(Loc, T, Diagnoser);
1758
1
  }
bool clang::Sema::RequireCompleteType<clang::QualType>(clang::SourceLocation, clang::QualType, unsigned int, clang::QualType const&)
Line
Count
Source
1755
108
                           const Ts &...Args) {
1756
108
    BoundTypeDiagnoser<Ts...> Diagnoser(DiagID, Args...);
1757
108
    return RequireCompleteType(Loc, T, Diagnoser);
1758
108
  }
bool clang::Sema::RequireCompleteType<int>(clang::SourceLocation, clang::QualType, unsigned int, int const&)
Line
Count
Source
1755
7.53k
                           const Ts &...Args) {
1756
7.53k
    BoundTypeDiagnoser<Ts...> Diagnoser(DiagID, Args...);
1757
7.53k
    return RequireCompleteType(Loc, T, Diagnoser);
1758
7.53k
  }
1759
1760
  void completeExprArrayBound(Expr *E);
1761
  bool RequireCompleteExprType(Expr *E, TypeDiagnoser &Diagnoser);
1762
  bool RequireCompleteExprType(Expr *E, unsigned DiagID);
1763
1764
  template <typename... Ts>
1765
48.8k
  bool RequireCompleteExprType(Expr *E, unsigned DiagID, const Ts &...Args) {
1766
48.8k
    BoundTypeDiagnoser<Ts...> Diagnoser(DiagID, Args...);
1767
48.8k
    return RequireCompleteExprType(E, Diagnoser);
1768
48.8k
  }
1769
1770
  bool RequireLiteralType(SourceLocation Loc, QualType T,
1771
                          TypeDiagnoser &Diagnoser);
1772
  bool RequireLiteralType(SourceLocation Loc, QualType T, unsigned DiagID);
1773
1774
  template <typename... Ts>
1775
  bool RequireLiteralType(SourceLocation Loc, QualType T, unsigned DiagID,
1776
115k
                          const Ts &...Args) {
1777
115k
    BoundTypeDiagnoser<Ts...> Diagnoser(DiagID, Args...);
1778
115k
    return RequireLiteralType(Loc, T, Diagnoser);
1779
115k
  }
bool clang::Sema::RequireLiteralType<unsigned int, clang::SourceRange, bool, bool>(clang::SourceLocation, clang::QualType, unsigned int, unsigned int const&, clang::SourceRange const&, bool const&, bool const&)
Line
Count
Source
1776
40.7k
                          const Ts &...Args) {
1777
40.7k
    BoundTypeDiagnoser<Ts...> Diagnoser(DiagID, Args...);
1778
40.7k
    return RequireLiteralType(Loc, T, Diagnoser);
1779
40.7k
  }
bool clang::Sema::RequireLiteralType<bool>(clang::SourceLocation, clang::QualType, unsigned int, bool const&)
Line
Count
Source
1776
74.4k
                          const Ts &...Args) {
1777
74.4k
    BoundTypeDiagnoser<Ts...> Diagnoser(DiagID, Args...);
1778
74.4k
    return RequireLiteralType(Loc, T, Diagnoser);
1779
74.4k
  }
1780
1781
  QualType getElaboratedType(ElaboratedTypeKeyword Keyword,
1782
                             const CXXScopeSpec &SS, QualType T,
1783
                             TagDecl *OwnedTagDecl = nullptr);
1784
1785
  QualType BuildTypeofExprType(Expr *E, SourceLocation Loc);
1786
  /// If AsUnevaluated is false, E is treated as though it were an evaluated
1787
  /// context, such as when building a type for decltype(auto).
1788
  QualType BuildDecltypeType(Expr *E, SourceLocation Loc,
1789
                             bool AsUnevaluated = true);
1790
  QualType BuildUnaryTransformType(QualType BaseType,
1791
                                   UnaryTransformType::UTTKind UKind,
1792
                                   SourceLocation Loc);
1793
1794
  //===--------------------------------------------------------------------===//
1795
  // Symbol table / Decl tracking callbacks: SemaDecl.cpp.
1796
  //
1797
1798
  struct SkipBodyInfo {
1799
    SkipBodyInfo()
1800
        : ShouldSkip(false), CheckSameAsPrevious(false), Previous(nullptr),
1801
3.68M
          New(nullptr) {}
1802
    bool ShouldSkip;
1803
    bool CheckSameAsPrevious;
1804
    NamedDecl *Previous;
1805
    NamedDecl *New;
1806
  };
1807
1808
  DeclGroupPtrTy ConvertDeclToDeclGroup(Decl *Ptr, Decl *OwnedType = nullptr);
1809
1810
  void DiagnoseUseOfUnimplementedSelectors();
1811
1812
  bool isSimpleTypeSpecifier(tok::TokenKind Kind) const;
1813
1814
  ParsedType getTypeName(const IdentifierInfo &II, SourceLocation NameLoc,
1815
                         Scope *S, CXXScopeSpec *SS = nullptr,
1816
                         bool isClassName = false, bool HasTrailingDot = false,
1817
                         ParsedType ObjectType = nullptr,
1818
                         bool IsCtorOrDtorName = false,
1819
                         bool WantNontrivialTypeSourceInfo = false,
1820
                         bool IsClassTemplateDeductionContext = true,
1821
                         IdentifierInfo **CorrectedII = nullptr);
1822
  TypeSpecifierType isTagName(IdentifierInfo &II, Scope *S);
1823
  bool isMicrosoftMissingTypename(const CXXScopeSpec *SS, Scope *S);
1824
  void DiagnoseUnknownTypeName(IdentifierInfo *&II,
1825
                               SourceLocation IILoc,
1826
                               Scope *S,
1827
                               CXXScopeSpec *SS,
1828
                               ParsedType &SuggestedType,
1829
                               bool IsTemplateName = false);
1830
1831
  /// Attempt to behave like MSVC in situations where lookup of an unqualified
1832
  /// type name has failed in a dependent context. In these situations, we
1833
  /// automatically form a DependentTypeName that will retry lookup in a related
1834
  /// scope during instantiation.
1835
  ParsedType ActOnMSVCUnknownTypeName(const IdentifierInfo &II,
1836
                                      SourceLocation NameLoc,
1837
                                      bool IsTemplateTypeArg);
1838
1839
  /// Describes the result of the name lookup and resolution performed
1840
  /// by \c ClassifyName().
1841
  enum NameClassificationKind {
1842
    NC_Unknown,
1843
    NC_Error,
1844
    NC_Keyword,
1845
    NC_Type,
1846
    NC_Expression,
1847
    NC_NestedNameSpecifier,
1848
    NC_TypeTemplate,
1849
    NC_VarTemplate,
1850
    NC_FunctionTemplate,
1851
    NC_UndeclaredTemplate,
1852
  };
1853
1854
  class NameClassification {
1855
    NameClassificationKind Kind;
1856
    ExprResult Expr;
1857
    TemplateName Template;
1858
    ParsedType Type;
1859
1860
9.81k
    explicit NameClassification(NameClassificationKind Kind) : Kind(Kind) {}
1861
1862
  public:
1863
4.24M
    NameClassification(ExprResult Expr) : Kind(NC_Expression), Expr(Expr) {}
1864
1865
4.85M
    NameClassification(ParsedType Type) : Kind(NC_Type), Type(Type) {}
1866
1867
16
    NameClassification(const IdentifierInfo *Keyword) : Kind(NC_Keyword) {}
1868
1869
29
    static NameClassification Error() {
1870
29
      return NameClassification(NC_Error);
1871
29
    }
1872
1873
6.67k
    static NameClassification Unknown() {
1874
6.67k
      return NameClassification(NC_Unknown);
1875
6.67k
    }
1876
1877
0
    static NameClassification NestedNameSpecifier() {
1878
0
      return NameClassification(NC_NestedNameSpecifier);
1879
0
    }
1880
1881
3.11k
    static NameClassification TypeTemplate(TemplateName Name) {
1882
3.11k
      NameClassification Result(NC_TypeTemplate);
1883
3.11k
      Result.Template = Name;
1884
3.11k
      return Result;
1885
3.11k
    }
1886
1887
0
    static NameClassification VarTemplate(TemplateName Name) {
1888
0
      NameClassification Result(NC_VarTemplate);
1889
0
      Result.Template = Name;
1890
0
      return Result;
1891
0
    }
1892
1893
0
    static NameClassification FunctionTemplate(TemplateName Name) {
1894
0
      NameClassification Result(NC_FunctionTemplate);
1895
0
      Result.Template = Name;
1896
0
      return Result;
1897
0
    }
1898
1899
2
    static NameClassification UndeclaredTemplate(TemplateName Name) {
1900
2
      NameClassification Result(NC_UndeclaredTemplate);
1901
2
      Result.Template = Name;
1902
2
      return Result;
1903
2
    }
1904
1905
18.2M
    NameClassificationKind getKind() const { return Kind; }
1906
1907
4.85M
    ParsedType getType() const {
1908
4.85M
      assert(Kind == NC_Type);
1909
4.85M
      return Type;
1910
4.85M
    }
1911
1912
4.24M
    ExprResult getExpression() const {
1913
4.24M
      assert(Kind == NC_Expression);
1914
4.24M
      return Expr;
1915
4.24M
    }
1916
1917
0
    TemplateName getTemplateName() const {
1918
0
      assert(Kind == NC_TypeTemplate || Kind == NC_FunctionTemplate ||
1919
0
             Kind == NC_VarTemplate || Kind == NC_UndeclaredTemplate);
1920
0
      return Template;
1921
0
    }
1922
1923
0
    TemplateNameKind getTemplateNameKind() const {
1924
0
      switch (Kind) {
1925
0
      case NC_TypeTemplate:
1926
0
        return TNK_Type_template;
1927
0
      case NC_FunctionTemplate:
1928
0
        return TNK_Function_template;
1929
0
      case NC_VarTemplate:
1930
0
        return TNK_Var_template;
1931
0
      case NC_UndeclaredTemplate:
1932
0
        return TNK_Undeclared_template;
1933
0
      default:
1934
0
        llvm_unreachable("unsupported name classification.");
1935
0
      }
1936
0
    }
1937
  };
1938
1939
  /// Perform name lookup on the given name, classifying it based on
1940
  /// the results of name lookup and the following token.
1941
  ///
1942
  /// This routine is used by the parser to resolve identifiers and help direct
1943
  /// parsing. When the identifier cannot be found, this routine will attempt
1944
  /// to correct the typo and classify based on the resulting name.
1945
  ///
1946
  /// \param S The scope in which we're performing name lookup.
1947
  ///
1948
  /// \param SS The nested-name-specifier that precedes the name.
1949
  ///
1950
  /// \param Name The identifier. If typo correction finds an alternative name,
1951
  /// this pointer parameter will be updated accordingly.
1952
  ///
1953
  /// \param NameLoc The location of the identifier.
1954
  ///
1955
  /// \param NextToken The token following the identifier. Used to help
1956
  /// disambiguate the name.
1957
  ///
1958
  /// \param IsAddressOfOperand True if this name is the operand of a unary
1959
  ///        address of ('&') expression, assuming it is classified as an
1960
  ///        expression.
1961
  ///
1962
  /// \param CCC The correction callback, if typo correction is desired.
1963
  NameClassification ClassifyName(Scope *S, CXXScopeSpec &SS,
1964
                                  IdentifierInfo *&Name, SourceLocation NameLoc,
1965
                                  const Token &NextToken,
1966
                                  bool IsAddressOfOperand,
1967
                                  CorrectionCandidateCallback *CCC = nullptr);
1968
1969
  /// Describes the detailed kind of a template name. Used in diagnostics.
1970
  enum class TemplateNameKindForDiagnostics {
1971
    ClassTemplate,
1972
    FunctionTemplate,
1973
    VarTemplate,
1974
    AliasTemplate,
1975
    TemplateTemplateParam,
1976
    Concept,
1977
    DependentTemplate
1978
  };
1979
  TemplateNameKindForDiagnostics
1980
  getTemplateNameKindForDiagnostics(TemplateName Name);
1981
1982
  /// Determine whether it's plausible that E was intended to be a
1983
  /// template-name.
1984
267k
  bool mightBeIntendedToBeTemplateName(ExprResult E, bool &Dependent) {
1985
267k
    if (!getLangOpts().CPlusPlus || 
E.isInvalid()237k
)
1986
30.7k
      return false;
1987
237k
    Dependent = false;
1988
237k
    if (auto *DRE = dyn_cast<DeclRefExpr>(E.get()))
1989
225k
      return !DRE->hasExplicitTemplateArgs();
1990
11.4k
    if (auto *ME = dyn_cast<MemberExpr>(E.get()))
1991
6.59k
      return !ME->hasExplicitTemplateArgs();
1992
4.87k
    Dependent = true;
1993
4.87k
    if (auto *DSDRE = dyn_cast<DependentScopeDeclRefExpr>(E.get()))
1994
14
      return !DSDRE->hasExplicitTemplateArgs();
1995
4.86k
    if (auto *DSME = dyn_cast<CXXDependentScopeMemberExpr>(E.get()))
1996
4.84k
      return !DSME->hasExplicitTemplateArgs();
1997
14
    // Any additional cases recognized here should also be handled by
1998
14
    // diagnoseExprIntendedAsTemplateName.
1999
14
    return false;
2000
14
  }
2001
  void diagnoseExprIntendedAsTemplateName(Scope *S, ExprResult TemplateName,
2002
                                          SourceLocation Less,
2003
                                          SourceLocation Greater);
2004
2005
  Decl *ActOnDeclarator(Scope *S, Declarator &D);
2006
2007
  NamedDecl *HandleDeclarator(Scope *S, Declarator &D,
2008
                              MultiTemplateParamsArg TemplateParameterLists);
2009
  void RegisterLocallyScopedExternCDecl(NamedDecl *ND, Scope *S);
2010
  bool DiagnoseClassNameShadow(DeclContext *DC, DeclarationNameInfo Info);
2011
  bool diagnoseQualifiedDeclaration(CXXScopeSpec &SS, DeclContext *DC,
2012
                                    DeclarationName Name, SourceLocation Loc,
2013
                                    bool IsTemplateId);
2014
  void
2015
  diagnoseIgnoredQualifiers(unsigned DiagID, unsigned Quals,
2016
                            SourceLocation FallbackLoc,
2017
                            SourceLocation ConstQualLoc = SourceLocation(),
2018
                            SourceLocation VolatileQualLoc = SourceLocation(),
2019
                            SourceLocation RestrictQualLoc = SourceLocation(),
2020
                            SourceLocation AtomicQualLoc = SourceLocation(),
2021
                            SourceLocation UnalignedQualLoc = SourceLocation());
2022
2023
  static bool adjustContextForLocalExternDecl(DeclContext *&DC);
2024
  void DiagnoseFunctionSpecifiers(const DeclSpec &DS);
2025
  NamedDecl *getShadowedDeclaration(const TypedefNameDecl *D,
2026
                                    const LookupResult &R);
2027
  NamedDecl *getShadowedDeclaration(const VarDecl *D, const LookupResult &R);
2028
  void CheckShadow(NamedDecl *D, NamedDecl *ShadowedDecl,
2029
                   const LookupResult &R);
2030
  void CheckShadow(Scope *S, VarDecl *D);
2031
2032
  /// Warn if 'E', which is an expression that is about to be modified, refers
2033
  /// to a shadowing declaration.
2034
  void CheckShadowingDeclModification(Expr *E, SourceLocation Loc);
2035
2036
  void DiagnoseShadowingLambdaDecls(const sema::LambdaScopeInfo *LSI);
2037
2038
private:
2039
  /// Map of current shadowing declarations to shadowed declarations. Warn if
2040
  /// it looks like the user is trying to modify the shadowing declaration.
2041
  llvm::DenseMap<const NamedDecl *, const NamedDecl *> ShadowingDecls;
2042
2043
public:
2044
  void CheckCastAlign(Expr *Op, QualType T, SourceRange TRange);
2045
  void handleTagNumbering(const TagDecl *Tag, Scope *TagScope);
2046
  void setTagNameForLinkagePurposes(TagDecl *TagFromDeclSpec,
2047
                                    TypedefNameDecl *NewTD);
2048
  void CheckTypedefForVariablyModifiedType(Scope *S, TypedefNameDecl *D);
2049
  NamedDecl* ActOnTypedefDeclarator(Scope* S, Declarator& D, DeclContext* DC,
2050
                                    TypeSourceInfo *TInfo,
2051
                                    LookupResult &Previous);
2052
  NamedDecl* ActOnTypedefNameDecl(Scope* S, DeclContext* DC, TypedefNameDecl *D,
2053
                                  LookupResult &Previous, bool &Redeclaration);
2054
  NamedDecl *ActOnVariableDeclarator(Scope *S, Declarator &D, DeclContext *DC,
2055
                                     TypeSourceInfo *TInfo,
2056
                                     LookupResult &Previous,
2057
                                     MultiTemplateParamsArg TemplateParamLists,
2058
                                     bool &AddToScope,
2059
                                     ArrayRef<BindingDecl *> Bindings = None);
2060
  NamedDecl *
2061
  ActOnDecompositionDeclarator(Scope *S, Declarator &D,
2062
                               MultiTemplateParamsArg TemplateParamLists);
2063
  // Returns true if the variable declaration is a redeclaration
2064
  bool CheckVariableDeclaration(VarDecl *NewVD, LookupResult &Previous);
2065
  void CheckVariableDeclarationType(VarDecl *NewVD);
2066
  bool DeduceVariableDeclarationType(VarDecl *VDecl, bool DirectInit,
2067
                                     Expr *Init);
2068
  void CheckCompleteVariableDeclaration(VarDecl *VD);
2069
  void CheckCompleteDecompositionDeclaration(DecompositionDecl *DD);
2070
  void MaybeSuggestAddingStaticToDecl(const FunctionDecl *D);
2071
2072
  NamedDecl* ActOnFunctionDeclarator(Scope* S, Declarator& D, DeclContext* DC,
2073
                                     TypeSourceInfo *TInfo,
2074
                                     LookupResult &Previous,
2075
                                     MultiTemplateParamsArg TemplateParamLists,
2076
                                     bool &AddToScope);
2077
  bool AddOverriddenMethods(CXXRecordDecl *DC, CXXMethodDecl *MD);
2078
2079
  bool CheckConstexprFunctionDecl(const FunctionDecl *FD);
2080
  bool CheckConstexprFunctionBody(const FunctionDecl *FD, Stmt *Body);
2081
2082
  void DiagnoseHiddenVirtualMethods(CXXMethodDecl *MD);
2083
  void FindHiddenVirtualMethods(CXXMethodDecl *MD,
2084
                          SmallVectorImpl<CXXMethodDecl*> &OverloadedMethods);
2085
  void NoteHiddenVirtualMethods(CXXMethodDecl *MD,
2086
                          SmallVectorImpl<CXXMethodDecl*> &OverloadedMethods);
2087
  // Returns true if the function declaration is a redeclaration
2088
  bool CheckFunctionDeclaration(Scope *S,
2089
                                FunctionDecl *NewFD, LookupResult &Previous,
2090
                                bool IsMemberSpecialization);
2091
  bool shouldLinkDependentDeclWithPrevious(Decl *D, Decl *OldDecl);
2092
  bool canFullyTypeCheckRedeclaration(ValueDecl *NewD, ValueDecl *OldD,
2093
                                      QualType NewT, QualType OldT);
2094
  void CheckMain(FunctionDecl *FD, const DeclSpec &D);
2095
  void CheckMSVCRTEntryPoint(FunctionDecl *FD);
2096
  Attr *getImplicitCodeSegOrSectionAttrForFunction(const FunctionDecl *FD,
2097
                                                   bool IsDefinition);
2098
  void CheckFunctionOrTemplateParamDeclarator(Scope *S, Declarator &D);
2099
  Decl *ActOnParamDeclarator(Scope *S, Declarator &D);
2100
  ParmVarDecl *BuildParmVarDeclForTypedef(DeclContext *DC,
2101
                                          SourceLocation Loc,
2102
                                          QualType T);
2103
  ParmVarDecl *CheckParameter(DeclContext *DC, SourceLocation StartLoc,
2104
                              SourceLocation NameLoc, IdentifierInfo *Name,
2105
                              QualType T, TypeSourceInfo *TSInfo,
2106
                              StorageClass SC);
2107
  void ActOnParamDefaultArgument(Decl *param,
2108
                                 SourceLocation EqualLoc,
2109
                                 Expr *defarg);
2110
  void ActOnParamUnparsedDefaultArgument(Decl *param,
2111
                                         SourceLocation EqualLoc,
2112
                                         SourceLocation ArgLoc);
2113
  void ActOnParamDefaultArgumentError(Decl *param, SourceLocation EqualLoc);
2114
  bool SetParamDefaultArgument(ParmVarDecl *Param, Expr *DefaultArg,
2115
                               SourceLocation EqualLoc);
2116
2117
  // Contexts where using non-trivial C union types can be disallowed. This is
2118
  // passed to err_non_trivial_c_union_in_invalid_context.
2119
  enum NonTrivialCUnionContext {
2120
    // Function parameter.
2121
    NTCUC_FunctionParam,
2122
    // Function return.
2123
    NTCUC_FunctionReturn,
2124
    // Default-initialized object.
2125
    NTCUC_DefaultInitializedObject,
2126
    // Variable with automatic storage duration.
2127
    NTCUC_AutoVar,
2128
    // Initializer expression that might copy from another object.
2129
    NTCUC_CopyInit,
2130
    // Assignment.
2131
    NTCUC_Assignment,
2132
    // Compound literal.
2133
    NTCUC_CompoundLiteral,
2134
    // Block capture.
2135
    NTCUC_BlockCapture,
2136
    // lvalue-to-rvalue conversion of volatile type.
2137
    NTCUC_LValueToRValueVolatile,
2138
  };
2139
2140
  /// Emit diagnostics if the initializer or any of its explicit or
2141
  /// implicitly-generated subexpressions require copying or
2142
  /// default-initializing a type that is or contains a C union type that is
2143
  /// non-trivial to copy or default-initialize.
2144
  void checkNonTrivialCUnionInInitializer(const Expr *Init, SourceLocation Loc);
2145
2146
  // These flags are passed to checkNonTrivialCUnion.
2147
  enum NonTrivialCUnionKind {
2148
    NTCUK_Init = 0x1,
2149
    NTCUK_Destruct = 0x2,
2150
    NTCUK_Copy = 0x4,
2151
  };
2152
2153
  /// Emit diagnostics if a non-trivial C union type or a struct that contains
2154
  /// a non-trivial C union is used in an invalid context.
2155
  void checkNonTrivialCUnion(QualType QT, SourceLocation Loc,
2156
                             NonTrivialCUnionContext UseContext,
2157
                             unsigned NonTrivialKind);
2158
2159
  void AddInitializerToDecl(Decl *dcl, Expr *init, bool DirectInit);
2160
  void ActOnUninitializedDecl(Decl *dcl);
2161
  void ActOnInitializerError(Decl *Dcl);
2162
2163
  void ActOnPureSpecifier(Decl *D, SourceLocation PureSpecLoc);
2164
  void ActOnCXXForRangeDecl(Decl *D);
2165
  StmtResult ActOnCXXForRangeIdentifier(Scope *S, SourceLocation IdentLoc,
2166
                                        IdentifierInfo *Ident,
2167
                                        ParsedAttributes &Attrs,
2168
                                        SourceLocation AttrEnd);
2169
  void SetDeclDeleted(Decl *dcl, SourceLocation DelLoc);
2170
  void SetDeclDefaulted(Decl *dcl, SourceLocation DefaultLoc);
2171
  void CheckStaticLocalForDllExport(VarDecl *VD);
2172
  void FinalizeDeclaration(Decl *D);
2173
  DeclGroupPtrTy FinalizeDeclaratorGroup(Scope *S, const DeclSpec &DS,
2174
                                         ArrayRef<Decl *> Group);
2175
  DeclGroupPtrTy BuildDeclaratorGroup(MutableArrayRef<Decl *> Group);
2176
2177
  /// Should be called on all declarations that might have attached
2178
  /// documentation comments.
2179
  void ActOnDocumentableDecl(Decl *D);
2180
  void ActOnDocumentableDecls(ArrayRef<Decl *> Group);
2181
2182
  void ActOnFinishKNRParamDeclarations(Scope *S, Declarator &D,
2183
                                       SourceLocation LocAfterDecls);
2184
  void CheckForFunctionRedefinition(
2185
      FunctionDecl *FD, const FunctionDecl *EffectiveDefinition = nullptr,
2186
      SkipBodyInfo *SkipBody = nullptr);
2187
  Decl *ActOnStartOfFunctionDef(Scope *S, Declarator &D,
2188
                                MultiTemplateParamsArg TemplateParamLists,
2189
                                SkipBodyInfo *SkipBody = nullptr);
2190
  Decl *ActOnStartOfFunctionDef(Scope *S, Decl *D,
2191
                                SkipBodyInfo *SkipBody = nullptr);
2192
  void ActOnStartOfObjCMethodDef(Scope *S, Decl *D);
2193
6.33k
  bool isObjCMethodDecl(Decl *D) {
2194
6.33k
    return D && isa<ObjCMethodDecl>(D);
2195
6.33k
  }
2196
2197
  /// Determine whether we can delay parsing the body of a function or
2198
  /// function template until it is used, assuming we don't care about emitting
2199
  /// code for that function.
2200
  ///
2201
  /// This will be \c false if we may need the body of the function in the
2202
  /// middle of parsing an expression (where it's impractical to switch to
2203
  /// parsing a different function), for instance, if it's constexpr in C++11
2204
  /// or has an 'auto' return type in C++14. These cases are essentially bugs.
2205
  bool canDelayFunctionBody(const Declarator &D);
2206
2207
  /// Determine whether we can skip parsing the body of a function
2208
  /// definition, assuming we don't care about analyzing its body or emitting
2209
  /// code for that function.
2210
  ///
2211
  /// This will be \c false only if we may need the body of the function in
2212
  /// order to parse the rest of the program (for instance, if it is
2213
  /// \c constexpr in C++11 or has an 'auto' return type in C++14).
2214
  bool canSkipFunctionBody(Decl *D);
2215
2216
  void computeNRVO(Stmt *Body, sema::FunctionScopeInfo *Scope);
2217
  Decl *ActOnFinishFunctionBody(Decl *Decl, Stmt *Body);
2218
  Decl *ActOnFinishFunctionBody(Decl *Decl, Stmt *Body, bool IsInstantiation);
2219
  Decl *ActOnSkippedFunctionBody(Decl *Decl);
2220
  void ActOnFinishInlineFunctionDef(FunctionDecl *D);
2221
2222
  /// ActOnFinishDelayedAttribute - Invoked when we have finished parsing an
2223
  /// attribute for which parsing is delayed.
2224
  void ActOnFinishDelayedAttribute(Scope *S, Decl *D, ParsedAttributes &Attrs);
2225
2226
  /// Diagnose any unused parameters in the given sequence of
2227
  /// ParmVarDecl pointers.
2228
  void DiagnoseUnusedParameters(ArrayRef<ParmVarDecl *> Parameters);
2229
2230
  /// Diagnose whether the size of parameters or return value of a
2231
  /// function or obj-c method definition is pass-by-value and larger than a
2232
  /// specified threshold.
2233
  void
2234
  DiagnoseSizeOfParametersAndReturnValue(ArrayRef<ParmVarDecl *> Parameters,
2235
                                         QualType ReturnTy, NamedDecl *D);
2236
2237
  void DiagnoseInvalidJumps(Stmt *Body);
2238
  Decl *ActOnFileScopeAsmDecl(Expr *expr,
2239
                              SourceLocation AsmLoc,
2240
                              SourceLocation RParenLoc);
2241
2242
  /// Handle a C++11 empty-declaration and attribute-declaration.
2243
  Decl *ActOnEmptyDeclaration(Scope *S, const ParsedAttributesView &AttrList,
2244
                              SourceLocation SemiLoc);
2245
2246
  enum class ModuleDeclKind {
2247
    Interface,      ///< 'export module X;'
2248
    Implementation, ///< 'module X;'
2249
  };
2250
2251
  /// The parser has processed a module-declaration that begins the definition
2252
  /// of a module interface or implementation.
2253
  DeclGroupPtrTy ActOnModuleDecl(SourceLocation StartLoc,
2254
                                 SourceLocation ModuleLoc, ModuleDeclKind MDK,
2255
                                 ModuleIdPath Path, bool IsFirstDecl);
2256
2257
  /// The parser has processed a global-module-fragment declaration that begins
2258
  /// the definition of the global module fragment of the current module unit.
2259
  /// \param ModuleLoc The location of the 'module' keyword.
2260
  DeclGroupPtrTy ActOnGlobalModuleFragmentDecl(SourceLocation ModuleLoc);
2261
2262
  /// The parser has processed a private-module-fragment declaration that begins
2263
  /// the definition of the private module fragment of the current module unit.
2264
  /// \param ModuleLoc The location of the 'module' keyword.
2265
  /// \param PrivateLoc The location of the 'private' keyword.
2266
  DeclGroupPtrTy ActOnPrivateModuleFragmentDecl(SourceLocation ModuleLoc,
2267
                                                SourceLocation PrivateLoc);
2268
2269
  /// The parser has processed a module import declaration.
2270
  ///
2271
  /// \param StartLoc The location of the first token in the declaration. This
2272
  ///        could be the location of an '@', 'export', or 'import'.
2273
  /// \param ExportLoc The location of the 'export' keyword, if any.
2274
  /// \param ImportLoc The location of the 'import' keyword.
2275
  /// \param Path The module access path.
2276
  DeclResult ActOnModuleImport(SourceLocation StartLoc,
2277
                               SourceLocation ExportLoc,
2278
                               SourceLocation ImportLoc, ModuleIdPath Path);
2279
  DeclResult ActOnModuleImport(SourceLocation StartLoc,
2280
                               SourceLocation ExportLoc,
2281
                               SourceLocation ImportLoc, Module *M,
2282
                               ModuleIdPath Path = {});
2283
2284
  /// The parser has processed a module import translated from a
2285
  /// #include or similar preprocessing directive.
2286
  void ActOnModuleInclude(SourceLocation DirectiveLoc, Module *Mod);
2287
  void BuildModuleInclude(SourceLocation DirectiveLoc, Module *Mod);
2288
2289
  /// The parsed has entered a submodule.
2290
  void ActOnModuleBegin(SourceLocation DirectiveLoc, Module *Mod);
2291
  /// The parser has left a submodule.
2292
  void ActOnModuleEnd(SourceLocation DirectiveLoc, Module *Mod);
2293
2294
  /// Create an implicit import of the given module at the given
2295
  /// source location, for error recovery, if possible.
2296
  ///
2297
  /// This routine is typically used when an entity found by name lookup
2298
  /// is actually hidden within a module that we know about but the user
2299
  /// has forgotten to import.
2300
  void createImplicitModuleImportForErrorRecovery(SourceLocation Loc,
2301
                                                  Module *Mod);
2302
2303
  /// Kinds of missing import. Note, the values of these enumerators correspond
2304
  /// to %select values in diagnostics.
2305
  enum class MissingImportKind {
2306
    Declaration,
2307
    Definition,
2308
    DefaultArgument,
2309
    ExplicitSpecialization,
2310
    PartialSpecialization
2311
  };
2312
2313
  /// Diagnose that the specified declaration needs to be visible but
2314
  /// isn't, and suggest a module import that would resolve the problem.
2315
  void diagnoseMissingImport(SourceLocation Loc, NamedDecl *Decl,
2316
                             MissingImportKind MIK, bool Recover = true);
2317
  void diagnoseMissingImport(SourceLocation Loc, NamedDecl *Decl,
2318
                             SourceLocation DeclLoc, ArrayRef<Module *> Modules,
2319
                             MissingImportKind MIK, bool Recover);
2320
2321
  Decl *ActOnStartExportDecl(Scope *S, SourceLocation ExportLoc,
2322
                             SourceLocation LBraceLoc);
2323
  Decl *ActOnFinishExportDecl(Scope *S, Decl *ExportDecl,
2324
                              SourceLocation RBraceLoc);
2325
2326
  /// We've found a use of a templated declaration that would trigger an
2327
  /// implicit instantiation. Check that any relevant explicit specializations
2328
  /// and partial specializations are visible, and diagnose if not.
2329
  void checkSpecializationVisibility(SourceLocation Loc, NamedDecl *Spec);
2330
2331
  /// We've found a use of a template specialization that would select a
2332
  /// partial specialization. Check that the partial specialization is visible,
2333
  /// and diagnose if not.
2334
  void checkPartialSpecializationVisibility(SourceLocation Loc,
2335
                                            NamedDecl *Spec);
2336
2337
  /// Retrieve a suitable printing policy for diagnostics.
2338
34.6M
  PrintingPolicy getPrintingPolicy() const {
2339
34.6M
    return getPrintingPolicy(Context, PP);
2340
34.6M
  }
2341
2342
  /// Retrieve a suitable printing policy for diagnostics.
2343
  static PrintingPolicy getPrintingPolicy(const ASTContext &Ctx,
2344
                                          const Preprocessor &PP);
2345
2346
  /// Scope actions.
2347
  void ActOnPopScope(SourceLocation Loc, Scope *S);
2348
  void ActOnTranslationUnitScope(Scope *S);
2349
2350
  Decl *ParsedFreeStandingDeclSpec(Scope *S, AccessSpecifier AS, DeclSpec &DS,
2351
                                   RecordDecl *&AnonRecord);
2352
  Decl *ParsedFreeStandingDeclSpec(Scope *S, AccessSpecifier AS, DeclSpec &DS,
2353
                                   MultiTemplateParamsArg TemplateParams,
2354
                                   bool IsExplicitInstantiation,
2355
                                   RecordDecl *&AnonRecord);
2356
2357
  Decl *BuildAnonymousStructOrUnion(Scope *S, DeclSpec &DS,
2358
                                    AccessSpecifier AS,
2359
                                    RecordDecl *Record,
2360
                                    const PrintingPolicy &Policy);
2361
2362
  Decl *BuildMicrosoftCAnonymousStruct(Scope *S, DeclSpec &DS,
2363
                                       RecordDecl *Record);
2364
2365
  /// Common ways to introduce type names without a tag for use in diagnostics.
2366
  /// Keep in sync with err_tag_reference_non_tag.
2367
  enum NonTagKind {
2368
    NTK_NonStruct,
2369
    NTK_NonClass,
2370
    NTK_NonUnion,
2371
    NTK_NonEnum,
2372
    NTK_Typedef,
2373
    NTK_TypeAlias,
2374
    NTK_Template,
2375
    NTK_TypeAliasTemplate,
2376
    NTK_TemplateTemplateArgument,
2377
  };
2378
2379
  /// Given a non-tag type declaration, returns an enum useful for indicating
2380
  /// what kind of non-tag type this is.
2381
  NonTagKind getNonTagTypeDeclKind(const Decl *D, TagTypeKind TTK);
2382
2383
  bool isAcceptableTagRedeclaration(const TagDecl *Previous,
2384
                                    TagTypeKind NewTag, bool isDefinition,
2385
                                    SourceLocation NewTagLoc,
2386
                                    const IdentifierInfo *Name);
2387
2388
  enum TagUseKind {
2389
    TUK_Reference,   // Reference to a tag:  'struct foo *X;'
2390
    TUK_Declaration, // Fwd decl of a tag:   'struct foo;'
2391
    TUK_Definition,  // Definition of a tag: 'struct foo { int X; } Y;'
2392
    TUK_Friend       // Friend declaration:  'friend struct foo;'
2393
  };
2394
2395
  Decl *ActOnTag(Scope *S, unsigned TagSpec, TagUseKind TUK,
2396
                 SourceLocation KWLoc, CXXScopeSpec &SS, IdentifierInfo *Name,
2397
                 SourceLocation NameLoc, const ParsedAttributesView &Attr,
2398
                 AccessSpecifier AS, SourceLocation ModulePrivateLoc,
2399
                 MultiTemplateParamsArg TemplateParameterLists, bool &OwnedDecl,
2400
                 bool &IsDependent, SourceLocation ScopedEnumKWLoc,
2401
                 bool ScopedEnumUsesClassTag, TypeResult UnderlyingType,
2402
                 bool IsTypeSpecifier, bool IsTemplateParamOrArg,
2403
                 SkipBodyInfo *SkipBody = nullptr);
2404
2405
  Decl *ActOnTemplatedFriendTag(Scope *S, SourceLocation FriendLoc,
2406
                                unsigned TagSpec, SourceLocation TagLoc,
2407
                                CXXScopeSpec &SS, IdentifierInfo *Name,
2408
                                SourceLocation NameLoc,
2409
                                const ParsedAttributesView &Attr,
2410
                                MultiTemplateParamsArg TempParamLists);
2411
2412
  TypeResult ActOnDependentTag(Scope *S,
2413
                               unsigned TagSpec,
2414
                               TagUseKind TUK,
2415
                               const CXXScopeSpec &SS,
2416
                               IdentifierInfo *Name,
2417
                               SourceLocation TagLoc,
2418
                               SourceLocation NameLoc);
2419
2420
  void ActOnDefs(Scope *S, Decl *TagD, SourceLocation DeclStart,
2421
                 IdentifierInfo *ClassName,
2422
                 SmallVectorImpl<Decl *> &Decls);
2423
  Decl *ActOnField(Scope *S, Decl *TagD, SourceLocation DeclStart,
2424
                   Declarator &D, Expr *BitfieldWidth);
2425
2426
  FieldDecl *HandleField(Scope *S, RecordDecl *TagD, SourceLocation DeclStart,
2427
                         Declarator &D, Expr *BitfieldWidth,
2428
                         InClassInitStyle InitStyle,
2429
                         AccessSpecifier AS);
2430
  MSPropertyDecl *HandleMSProperty(Scope *S, RecordDecl *TagD,
2431
                                   SourceLocation DeclStart, Declarator &D,
2432
                                   Expr *BitfieldWidth,
2433
                                   InClassInitStyle InitStyle,
2434
                                   AccessSpecifier AS,
2435
                                   const ParsedAttr &MSPropertyAttr);
2436
2437
  FieldDecl *CheckFieldDecl(DeclarationName Name, QualType T,
2438
                            TypeSourceInfo *TInfo,
2439
                            RecordDecl *Record, SourceLocation Loc,
2440
                            bool Mutable, Expr *BitfieldWidth,
2441
                            InClassInitStyle InitStyle,
2442
                            SourceLocation TSSL,
2443
                            AccessSpecifier AS, NamedDecl *PrevDecl,
2444
                            Declarator *D = nullptr);
2445
2446
  bool CheckNontrivialField(FieldDecl *FD);
2447
  void DiagnoseNontrivial(const CXXRecordDecl *Record, CXXSpecialMember CSM);
2448
2449
  enum TrivialABIHandling {
2450
    /// The triviality of a method unaffected by "trivial_abi".
2451
    TAH_IgnoreTrivialABI,
2452
2453
    /// The triviality of a method affected by "trivial_abi".
2454
    TAH_ConsiderTrivialABI
2455
  };
2456
2457
  bool SpecialMemberIsTrivial(CXXMethodDecl *MD, CXXSpecialMember CSM,
2458
                              TrivialABIHandling TAH = TAH_IgnoreTrivialABI,
2459
                              bool Diagnose = false);
2460
  CXXSpecialMember getSpecialMember(const CXXMethodDecl *MD);
2461
  void ActOnLastBitfield(SourceLocation DeclStart,
2462
                         SmallVectorImpl<Decl *> &AllIvarDecls);
2463
  Decl *ActOnIvar(Scope *S, SourceLocation DeclStart,
2464
                  Declarator &D, Expr *BitfieldWidth,
2465
                  tok::ObjCKeywordKind visibility);
2466
2467
  // This is used for both record definitions and ObjC interface declarations.
2468
  void ActOnFields(Scope *S, SourceLocation RecLoc, Decl *TagDecl,
2469
                   ArrayRef<Decl *> Fields, SourceLocation LBrac,
2470
                   SourceLocation RBrac, const ParsedAttributesView &AttrList);
2471
2472
  /// ActOnTagStartDefinition - Invoked when we have entered the
2473
  /// scope of a tag's definition (e.g., for an enumeration, class,
2474
  /// struct, or union).
2475
  void ActOnTagStartDefinition(Scope *S, Decl *TagDecl);
2476
2477
  /// Perform ODR-like check for C/ObjC when merging tag types from modules.
2478
  /// Differently from C++, actually parse the body and reject / error out
2479
  /// in case of a structural mismatch.
2480
  bool ActOnDuplicateDefinition(DeclSpec &DS, Decl *Prev,
2481
                                SkipBodyInfo &SkipBody);
2482
2483
  typedef void *SkippedDefinitionContext;
2484
2485
  /// Invoked when we enter a tag definition that we're skipping.
2486
  SkippedDefinitionContext ActOnTagStartSkippedDefinition(Scope *S, Decl *TD);
2487
2488
  Decl *ActOnObjCContainerStartDefinition(Decl *IDecl);
2489
2490
  /// ActOnStartCXXMemberDeclarations - Invoked when we have parsed a
2491
  /// C++ record definition's base-specifiers clause and are starting its
2492
  /// member declarations.
2493
  void ActOnStartCXXMemberDeclarations(Scope *S, Decl *TagDecl,
2494
                                       SourceLocation FinalLoc,
2495
                                       bool IsFinalSpelledSealed,
2496
                                       SourceLocation LBraceLoc);
2497
2498
  /// ActOnTagFinishDefinition - Invoked once we have finished parsing
2499
  /// the definition of a tag (enumeration, class, struct, or union).
2500
  void ActOnTagFinishDefinition(Scope *S, Decl *TagDecl,
2501
                                SourceRange BraceRange);
2502
2503
  void ActOnTagFinishSkippedDefinition(SkippedDefinitionContext Context);
2504
2505
  void ActOnObjCContainerFinishDefinition();
2506
2507
  /// Invoked when we must temporarily exit the objective-c container
2508
  /// scope for parsing/looking-up C constructs.
2509
  ///
2510
  /// Must be followed by a call to \see ActOnObjCReenterContainerContext
2511
  void ActOnObjCTemporaryExitContainerContext(DeclContext *DC);
2512
  void ActOnObjCReenterContainerContext(DeclContext *DC);
2513
2514
  /// ActOnTagDefinitionError - Invoked when there was an unrecoverable
2515
  /// error parsing the definition of a tag.
2516
  void ActOnTagDefinitionError(Scope *S, Decl *TagDecl);
2517
2518
  EnumConstantDecl *CheckEnumConstant(EnumDecl *Enum,
2519
                                      EnumConstantDecl *LastEnumConst,
2520
                                      SourceLocation IdLoc,
2521
                                      IdentifierInfo *Id,
2522
                                      Expr *val);
2523
  bool CheckEnumUnderlyingType(TypeSourceInfo *TI);
2524
  bool CheckEnumRedeclaration(SourceLocation EnumLoc, bool IsScoped,
2525
                              QualType EnumUnderlyingTy, bool IsFixed,
2526
                              const EnumDecl *Prev);
2527
2528
  /// Determine whether the body of an anonymous enumeration should be skipped.
2529
  /// \param II The name of the first enumerator.
2530
  SkipBodyInfo shouldSkipAnonEnumBody(Scope *S, IdentifierInfo *II,
2531
                                      SourceLocation IILoc);
2532
2533
  Decl *ActOnEnumConstant(Scope *S, Decl *EnumDecl, Decl *LastEnumConstant,
2534
                          SourceLocation IdLoc, IdentifierInfo *Id,
2535
                          const ParsedAttributesView &Attrs,
2536
                          SourceLocation EqualLoc, Expr *Val);
2537
  void ActOnEnumBody(SourceLocation EnumLoc, SourceRange BraceRange,
2538
                     Decl *EnumDecl, ArrayRef<Decl *> Elements, Scope *S,
2539
                     const ParsedAttributesView &Attr);
2540
2541
  DeclContext *getContainingDC(DeclContext *DC);
2542
2543
  /// Set the current declaration context until it gets popped.
2544
  void PushDeclContext(Scope *S, DeclContext *DC);
2545
  void PopDeclContext();
2546
2547
  /// EnterDeclaratorContext - Used when we must lookup names in the context
2548
  /// of a declarator's nested name specifier.
2549
  void EnterDeclaratorContext(Scope *S, DeclContext *DC);
2550
  void ExitDeclaratorContext(Scope *S);
2551
2552
  /// Push the parameters of D, which must be a function, into scope.
2553
  void ActOnReenterFunctionContext(Scope* S, Decl* D);
2554
  void ActOnExitFunctionContext();
2555
2556
  DeclContext *getFunctionLevelDeclContext();
2557
2558
  /// getCurFunctionDecl - If inside of a function body, this returns a pointer
2559
  /// to the function decl for the function being parsed.  If we're currently
2560
  /// in a 'block', this returns the containing context.
2561
  FunctionDecl *getCurFunctionDecl();
2562
2563
  /// getCurMethodDecl - If inside of a method body, this returns a pointer to
2564
  /// the method decl for the method being parsed.  If we're currently
2565
  /// in a 'block', this returns the containing context.
2566
  ObjCMethodDecl *getCurMethodDecl();
2567
2568
  /// getCurFunctionOrMethodDecl - Return the Decl for the current ObjC method
2569
  /// or C function we're in, otherwise return null.  If we're currently
2570
  /// in a 'block', this returns the containing context.
2571
  NamedDecl *getCurFunctionOrMethodDecl();
2572
2573
  /// Add this decl to the scope shadowed decl chains.
2574
  void PushOnScopeChains(NamedDecl *D, Scope *S, bool AddToContext = true);
2575
2576
  /// isDeclInScope - If 'Ctx' is a function/method, isDeclInScope returns true
2577
  /// if 'D' is in Scope 'S', otherwise 'S' is ignored and isDeclInScope returns
2578
  /// true if 'D' belongs to the given declaration context.
2579
  ///
2580
  /// \param AllowInlineNamespace If \c true, allow the declaration to be in the
2581
  ///        enclosing namespace set of the context, rather than contained
2582
  ///        directly within it.
2583
  bool isDeclInScope(NamedDecl *D, DeclContext *Ctx, Scope *S = nullptr,
2584
                     bool AllowInlineNamespace = false);
2585
2586
  /// Finds the scope corresponding to the given decl context, if it
2587
  /// happens to be an enclosing scope.  Otherwise return NULL.
2588
  static Scope *getScopeForDeclContext(Scope *S, DeclContext *DC);
2589
2590
  /// Subroutines of ActOnDeclarator().
2591
  TypedefDecl *ParseTypedefDecl(Scope *S, Declarator &D, QualType T,
2592
                                TypeSourceInfo *TInfo);
2593
  bool isIncompatibleTypedef(TypeDecl *Old, TypedefNameDecl *New);
2594
2595
  /// Describes the kind of merge to perform for availability
2596
  /// attributes (including "deprecated", "unavailable", and "availability").
2597
  enum AvailabilityMergeKind {
2598
    /// Don't merge availability attributes at all.
2599
    AMK_None,
2600
    /// Merge availability attributes for a redeclaration, which requires
2601
    /// an exact match.
2602
    AMK_Redeclaration,
2603
    /// Merge availability attributes for an override, which requires
2604
    /// an exact match or a weakening of constraints.
2605
    AMK_Override,
2606
    /// Merge availability attributes for an implementation of
2607
    /// a protocol requirement.
2608
    AMK_ProtocolImplementation,
2609
  };
2610
2611
  /// Describes the kind of priority given to an availability attribute.
2612
  ///
2613
  /// The sum of priorities deteremines the final priority of the attribute.
2614
  /// The final priority determines how the attribute will be merged.
2615
  /// An attribute with a lower priority will always remove higher priority
2616
  /// attributes for the specified platform when it is being applied. An
2617
  /// attribute with a higher priority will not be applied if the declaration
2618
  /// already has an availability attribute with a lower priority for the
2619
  /// specified platform. The final prirority values are not expected to match
2620
  /// the values in this enumeration, but instead should be treated as a plain
2621
  /// integer value. This enumeration just names the priority weights that are
2622
  /// used to calculate that final vaue.
2623
  enum AvailabilityPriority : int {
2624
    /// The availability attribute was specified explicitly next to the
2625
    /// declaration.
2626
    AP_Explicit = 0,
2627
2628
    /// The availability attribute was applied using '#pragma clang attribute'.
2629
    AP_PragmaClangAttribute = 1,
2630
2631
    /// The availability attribute for a specific platform was inferred from
2632
    /// an availability attribute for another platform.
2633
    AP_InferredFromOtherPlatform = 2
2634
  };
2635
2636
  /// Attribute merging methods. Return true if a new attribute was added.
2637
  AvailabilityAttr *mergeAvailabilityAttr(
2638
      NamedDecl *D, SourceRange Range, IdentifierInfo *Platform, bool Implicit,
2639
      VersionTuple Introduced, VersionTuple Deprecated, VersionTuple Obsoleted,
2640
      bool IsUnavailable, StringRef Message, bool IsStrict,
2641
      StringRef Replacement, AvailabilityMergeKind AMK, int Priority,
2642
      unsigned AttrSpellingListIndex);
2643
  TypeVisibilityAttr *mergeTypeVisibilityAttr(Decl *D, SourceRange Range,
2644
                                       TypeVisibilityAttr::VisibilityType Vis,
2645
                                              unsigned AttrSpellingListIndex);
2646
  VisibilityAttr *mergeVisibilityAttr(Decl *D, SourceRange Range,
2647
                                      VisibilityAttr::VisibilityType Vis,
2648
                                      unsigned AttrSpellingListIndex);
2649
  UuidAttr *mergeUuidAttr(Decl *D, SourceRange Range,
2650
                          unsigned AttrSpellingListIndex, StringRef Uuid);
2651
  DLLImportAttr *mergeDLLImportAttr(Decl *D, SourceRange Range,
2652
                                    unsigned AttrSpellingListIndex);
2653
  DLLExportAttr *mergeDLLExportAttr(Decl *D, SourceRange Range,
2654
                                    unsigned AttrSpellingListIndex);
2655
  MSInheritanceAttr *
2656
  mergeMSInheritanceAttr(Decl *D, SourceRange Range, bool BestCase,
2657
                         unsigned AttrSpellingListIndex,
2658
                         MSInheritanceAttr::Spelling SemanticSpelling);
2659
  FormatAttr *mergeFormatAttr(Decl *D, SourceRange Range,
2660
                              IdentifierInfo *Format, int FormatIdx,
2661
                              int FirstArg, unsigned AttrSpellingListIndex);
2662
  SectionAttr *mergeSectionAttr(Decl *D, SourceRange Range, StringRef Name,
2663
                                unsigned AttrSpellingListIndex);
2664
  CodeSegAttr *mergeCodeSegAttr(Decl *D, SourceRange Range, StringRef Name,
2665
                                unsigned AttrSpellingListIndex);
2666
  AlwaysInlineAttr *mergeAlwaysInlineAttr(Decl *D, SourceRange Range,
2667
                                          IdentifierInfo *Ident,
2668
                                          unsigned AttrSpellingListIndex);
2669
  MinSizeAttr *mergeMinSizeAttr(Decl *D, SourceRange Range,
2670
                                unsigned AttrSpellingListIndex);
2671
  NoSpeculativeLoadHardeningAttr *
2672
  mergeNoSpeculativeLoadHardeningAttr(Decl *D,
2673
                                      const NoSpeculativeLoadHardeningAttr &AL);
2674
  SpeculativeLoadHardeningAttr *
2675
  mergeSpeculativeLoadHardeningAttr(Decl *D,
2676
                                    const SpeculativeLoadHardeningAttr &AL);
2677
  OptimizeNoneAttr *mergeOptimizeNoneAttr(Decl *D, SourceRange Range,
2678
                                          unsigned AttrSpellingListIndex);
2679
  InternalLinkageAttr *mergeInternalLinkageAttr(Decl *D, const ParsedAttr &AL);
2680
  InternalLinkageAttr *mergeInternalLinkageAttr(Decl *D,
2681
                                                const InternalLinkageAttr &AL);
2682
  CommonAttr *mergeCommonAttr(Decl *D, const ParsedAttr &AL);
2683
  CommonAttr *mergeCommonAttr(Decl *D, const CommonAttr &AL);
2684
2685
  void mergeDeclAttributes(NamedDecl *New, Decl *Old,
2686
                           AvailabilityMergeKind AMK = AMK_Redeclaration);
2687
  void MergeTypedefNameDecl(Scope *S, TypedefNameDecl *New,
2688
                            LookupResult &OldDecls);
2689
  bool MergeFunctionDecl(FunctionDecl *New, NamedDecl *&Old, Scope *S,
2690
                         bool MergeTypeWithOld);
2691
  bool MergeCompatibleFunctionDecls(FunctionDecl *New, FunctionDecl *Old,
2692
                                    Scope *S, bool MergeTypeWithOld);
2693
  void mergeObjCMethodDecls(ObjCMethodDecl *New, ObjCMethodDecl *Old);
2694
  void MergeVarDecl(VarDecl *New, LookupResult &Previous);
2695
  void MergeVarDeclTypes(VarDecl *New, VarDecl *Old, bool MergeTypeWithOld);
2696
  void MergeVarDeclExceptionSpecs(VarDecl *New, VarDecl *Old);
2697
  bool checkVarDeclRedefinition(VarDecl *OldDefn, VarDecl *NewDefn);
2698
  void notePreviousDefinition(const NamedDecl *Old, SourceLocation New);
2699
  bool MergeCXXFunctionDecl(FunctionDecl *New, FunctionDecl *Old, Scope *S);
2700
2701
  // AssignmentAction - This is used by all the assignment diagnostic functions
2702
  // to represent what is actually causing the operation
2703
  enum AssignmentAction {
2704
    AA_Assigning,
2705
    AA_Passing,
2706
    AA_Returning,
2707
    AA_Converting,
2708
    AA_Initializing,
2709
    AA_Sending,
2710
    AA_Casting,
2711
    AA_Passing_CFAudited
2712
  };
2713
2714
  /// C++ Overloading.
2715
  enum OverloadKind {
2716
    /// This is a legitimate overload: the existing declarations are
2717
    /// functions or function templates with different signatures.
2718
    Ovl_Overload,
2719
2720
    /// This is not an overload because the signature exactly matches
2721
    /// an existing declaration.
2722
    Ovl_Match,
2723
2724
    /// This is not an overload because the lookup results contain a
2725
    /// non-function.
2726
    Ovl_NonFunction
2727
  };
2728
  OverloadKind CheckOverload(Scope *S,
2729
                             FunctionDecl *New,
2730
                             const LookupResult &OldDecls,
2731
                             NamedDecl *&OldDecl,
2732
                             bool IsForUsingDecl);
2733
  bool IsOverload(FunctionDecl *New, FunctionDecl *Old, bool IsForUsingDecl,
2734
                  bool ConsiderCudaAttrs = true);
2735
2736
  ImplicitConversionSequence
2737
  TryImplicitConversion(Expr *From, QualType ToType,
2738
                        bool SuppressUserConversions,
2739
                        bool AllowExplicit,
2740
                        bool InOverloadResolution,
2741
                        bool CStyle,
2742
                        bool AllowObjCWritebackConversion);
2743
2744
  bool IsIntegralPromotion(Expr *From, QualType FromType, QualType ToType);
2745
  bool IsFloatingPointPromotion(QualType FromType, QualType ToType);
2746
  bool IsComplexPromotion(QualType FromType, QualType ToType);
2747
  bool IsPointerConversion(Expr *From, QualType FromType, QualType ToType,
2748
                           bool InOverloadResolution,
2749
                           QualType& ConvertedType, bool &IncompatibleObjC);
2750
  bool isObjCPointerConversion(QualType FromType, QualType ToType,
2751
                               QualType& ConvertedType, bool &IncompatibleObjC);
2752
  bool isObjCWritebackConversion(QualType FromType, QualType ToType,
2753
                                 QualType &ConvertedType);
2754
  bool IsBlockPointerConversion(QualType FromType, QualType ToType,
2755
                                QualType& ConvertedType);
2756
  bool FunctionParamTypesAreEqual(const FunctionProtoType *OldType,
2757
                                  const FunctionProtoType *NewType,
2758
                                  unsigned *ArgPos = nullptr);
2759
  void HandleFunctionTypeMismatch(PartialDiagnostic &PDiag,
2760
                                  QualType FromType, QualType ToType);
2761
2762
  void maybeExtendBlockObject(ExprResult &E);
2763
  CastKind PrepareCastToObjCObjectPointer(ExprResult &E);
2764
  bool CheckPointerConversion(Expr *From, QualType ToType,
2765
                              CastKind &Kind,
2766
                              CXXCastPath& BasePath,
2767
                              bool IgnoreBaseAccess,
2768
                              bool Diagnose = true);
2769
  bool IsMemberPointerConversion(Expr *From, QualType FromType, QualType ToType,
2770
                                 bool InOverloadResolution,
2771
                                 QualType &ConvertedType);
2772
  bool CheckMemberPointerConversion(Expr *From, QualType ToType,
2773
                                    CastKind &Kind,
2774
                                    CXXCastPath &BasePath,
2775
                                    bool IgnoreBaseAccess);
2776
  bool IsQualificationConversion(QualType FromType, QualType ToType,
2777
                                 bool CStyle, bool &ObjCLifetimeConversion);
2778
  bool IsFunctionConversion(QualType FromType, QualType ToType,
2779
                            QualType &ResultTy);
2780
  bool DiagnoseMultipleUserDefinedConversion(Expr *From, QualType ToType);
2781
  bool isSameOrCompatibleFunctionType(CanQualType Param, CanQualType Arg);
2782
2783
  ExprResult PerformMoveOrCopyInitialization(const InitializedEntity &Entity,
2784
                                             const VarDecl *NRVOCandidate,
2785
                                             QualType ResultType,
2786
                                             Expr *Value,
2787
                                             bool AllowNRVO = true);
2788
2789
  bool CanPerformCopyInitialization(const InitializedEntity &Entity,
2790
                                    ExprResult Init);
2791
  ExprResult PerformCopyInitialization(const InitializedEntity &Entity,
2792
                                       SourceLocation EqualLoc,
2793
                                       ExprResult Init,
2794
                                       bool TopLevelOfInitList = false,
2795
                                       bool AllowExplicit = false);
2796
  ExprResult PerformObjectArgumentInitialization(Expr *From,
2797
                                                 NestedNameSpecifier *Qualifier,
2798
                                                 NamedDecl *FoundDecl,
2799
                                                 CXXMethodDecl *Method);
2800
2801
  /// Check that the lifetime of the initializer (and its subobjects) is
2802
  /// sufficient for initializing the entity, and perform lifetime extension
2803
  /// (when permitted) if not.
2804
  void checkInitializerLifetime(const InitializedEntity &Entity, Expr *Init);
2805
2806
  ExprResult PerformContextuallyConvertToBool(Expr *From);
2807
  ExprResult PerformContextuallyConvertToObjCPointer(Expr *From);
2808
2809
  /// Contexts in which a converted constant expression is required.
2810
  enum CCEKind {
2811
    CCEK_CaseValue,   ///< Expression in a case label.
2812
    CCEK_Enumerator,  ///< Enumerator value with fixed underlying type.
2813
    CCEK_TemplateArg, ///< Value of a non-type template parameter.
2814
    CCEK_NewExpr,     ///< Constant expression in a noptr-new-declarator.
2815
    CCEK_ConstexprIf, ///< Condition in a constexpr if statement.
2816
    CCEK_ExplicitBool ///< Condition in an explicit(bool) specifier.
2817
  };
2818
  ExprResult CheckConvertedConstantExpression(Expr *From, QualType T,
2819
                                              llvm::APSInt &Value, CCEKind CCE);
2820
  ExprResult CheckConvertedConstantExpression(Expr *From, QualType T,
2821
                                              APValue &Value, CCEKind CCE);
2822
2823
  /// Abstract base class used to perform a contextual implicit
2824
  /// conversion from an expression to any type passing a filter.
2825
  class ContextualImplicitConverter {
2826
  public:
2827
    bool Suppress;
2828
    bool SuppressConversion;
2829
2830
    ContextualImplicitConverter(bool Suppress = false,
2831
                                bool SuppressConversion = false)
2832
420k
        : Suppress(Suppress), SuppressConversion(SuppressConversion) {}
2833
2834
    /// Determine whether the specified type is a valid destination type
2835
    /// for this conversion.
2836
    virtual bool match(QualType T) = 0;
2837
2838
    /// Emits a diagnostic complaining that the expression does not have
2839
    /// integral or enumeration type.
2840
    virtual SemaDiagnosticBuilder
2841
    diagnoseNoMatch(Sema &S, SourceLocation Loc, QualType T) = 0;
2842
2843
    /// Emits a diagnostic when the expression has incomplete class type.
2844
    virtual SemaDiagnosticBuilder
2845
    diagnoseIncomplete(Sema &S, SourceLocation Loc, QualType T) = 0;
2846
2847
    /// Emits a diagnostic when the only matching conversion function
2848
    /// is explicit.
2849
    virtual SemaDiagnosticBuilder diagnoseExplicitConv(
2850
        Sema &S, SourceLocation Loc, QualType T, QualType ConvTy) = 0;
2851
2852
    /// Emits a note for the explicit conversion function.
2853
    virtual SemaDiagnosticBuilder
2854
    noteExplicitConv(Sema &S, CXXConversionDecl *Conv, QualType ConvTy) = 0;
2855
2856
    /// Emits a diagnostic when there are multiple possible conversion
2857
    /// functions.
2858
    virtual SemaDiagnosticBuilder
2859
    diagnoseAmbiguous(Sema &S, SourceLocation Loc, QualType T) = 0;
2860
2861
    /// Emits a note for one of the candidate conversions.
2862
    virtual SemaDiagnosticBuilder
2863
    noteAmbiguous(Sema &S, CXXConversionDecl *Conv, QualType ConvTy) = 0;
2864
2865
    /// Emits a diagnostic when we picked a conversion function
2866
    /// (for cases when we are not allowed to pick a conversion function).
2867
    virtual SemaDiagnosticBuilder diagnoseConversion(
2868
        Sema &S, SourceLocation Loc, QualType T, QualType ConvTy) = 0;
2869
2870
420k
    virtual ~ContextualImplicitConverter() {}
2871
  };
2872
2873
  class ICEConvertDiagnoser : public ContextualImplicitConverter {
2874
    bool AllowScopedEnumerations;
2875
2876
  public:
2877
    ICEConvertDiagnoser(bool AllowScopedEnumerations,
2878
                        bool Suppress, bool SuppressConversion)
2879
        : ContextualImplicitConverter(Suppress, SuppressConversion),
2880
416k
          AllowScopedEnumerations(AllowScopedEnumerations) {}
2881
2882
    /// Match an integral or (possibly scoped) enumeration type.
2883
    bool match(QualType T) override;
2884
2885
    SemaDiagnosticBuilder
2886
1.35k
    diagnoseNoMatch(Sema &S, SourceLocation Loc, QualType T) override {
2887
1.35k
      return diagnoseNotInt(S, Loc, T);
2888
1.35k
    }
2889
2890
    /// Emits a diagnostic complaining that the expression does not have
2891
    /// integral or enumeration type.
2892
    virtual SemaDiagnosticBuilder
2893
    diagnoseNotInt(Sema &S, SourceLocation Loc, QualType T) = 0;
2894
  };
2895
2896
  /// Perform a contextual implicit conversion.
2897
  ExprResult PerformContextualImplicitConversion(
2898
      SourceLocation Loc, Expr *FromE, ContextualImplicitConverter &Converter);
2899
2900
2901
  enum ObjCSubscriptKind {
2902
    OS_Array,
2903
    OS_Dictionary,
2904
    OS_Error
2905
  };
2906
  ObjCSubscriptKind CheckSubscriptingKind(Expr *FromE);
2907
2908
  // Note that LK_String is intentionally after the other literals, as
2909
  // this is used for diagnostics logic.
2910
  enum ObjCLiteralKind {
2911
    LK_Array,
2912
    LK_Dictionary,
2913
    LK_Numeric,
2914
    LK_Boxed,
2915
    LK_String,
2916
    LK_Block,
2917
    LK_None
2918
  };
2919
  ObjCLiteralKind CheckLiteralKind(Expr *FromE);
2920
2921
  ExprResult PerformObjectMemberConversion(Expr *From,
2922
                                           NestedNameSpecifier *Qualifier,
2923
                                           NamedDecl *FoundDecl,
2924
                                           NamedDecl *Member);
2925
2926
  // Members have to be NamespaceDecl* or TranslationUnitDecl*.
2927
  // TODO: make this is a typesafe union.
2928
  typedef llvm::SmallSetVector<DeclContext   *, 16> AssociatedNamespaceSet;
2929
  typedef llvm::SmallSetVector<CXXRecordDecl *, 16> AssociatedClassSet;
2930
2931
  using ADLCallKind = CallExpr::ADLCallKind;
2932
2933
  void AddOverloadCandidate(FunctionDecl *Function, DeclAccessPair FoundDecl,
2934
                            ArrayRef<Expr *> Args,
2935
                            OverloadCandidateSet &CandidateSet,
2936
                            bool SuppressUserConversions = false,
2937
                            bool PartialOverloading = false,
2938
                            bool AllowExplicit = true,
2939
                            bool AllowExplicitConversion = false,
2940
                            ADLCallKind IsADLCandidate = ADLCallKind::NotADL,
2941
                            ConversionSequenceList EarlyConversions = None);
2942
  void AddFunctionCandidates(const UnresolvedSetImpl &Functions,
2943
                      ArrayRef<Expr *> Args,
2944
                      OverloadCandidateSet &CandidateSet,
2945
                      TemplateArgumentListInfo *ExplicitTemplateArgs = nullptr,
2946
                      bool SuppressUserConversions = false,
2947
                      bool PartialOverloading = false,
2948
                      bool FirstArgumentIsBase = false);
2949
  void AddMethodCandidate(DeclAccessPair FoundDecl,
2950
                          QualType ObjectType,
2951
                          Expr::Classification ObjectClassification,
2952
                          ArrayRef<Expr *> Args,
2953
                          OverloadCandidateSet& CandidateSet,
2954
                          bool SuppressUserConversion = false);
2955
  void AddMethodCandidate(CXXMethodDecl *Method,
2956
                          DeclAccessPair FoundDecl,
2957
                          CXXRecordDecl *ActingContext, QualType ObjectType,
2958
                          Expr::Classification ObjectClassification,
2959
                          ArrayRef<Expr *> Args,
2960
                          OverloadCandidateSet& CandidateSet,
2961
                          bool SuppressUserConversions = false,
2962
                          bool PartialOverloading = false,
2963
                          ConversionSequenceList EarlyConversions = None);
2964
  void AddMethodTemplateCandidate(FunctionTemplateDecl *MethodTmpl,
2965
                                  DeclAccessPair FoundDecl,
2966
                                  CXXRecordDecl *ActingContext,
2967
                                 TemplateArgumentListInfo *ExplicitTemplateArgs,
2968
                                  QualType ObjectType,
2969
                                  Expr::Classification ObjectClassification,
2970
                                  ArrayRef<Expr *> Args,
2971
                                  OverloadCandidateSet& CandidateSet,
2972
                                  bool SuppressUserConversions = false,
2973
                                  bool PartialOverloading = false);
2974
  void AddTemplateOverloadCandidate(
2975
      FunctionTemplateDecl *FunctionTemplate, DeclAccessPair FoundDecl,
2976
      TemplateArgumentListInfo *ExplicitTemplateArgs, ArrayRef<Expr *> Args,
2977
      OverloadCandidateSet &CandidateSet, bool SuppressUserConversions = false,
2978
      bool PartialOverloading = false, bool AllowExplicit = true,
2979
      ADLCallKind IsADLCandidate = ADLCallKind::NotADL);
2980
  bool CheckNonDependentConversions(FunctionTemplateDecl *FunctionTemplate,
2981
                                    ArrayRef<QualType> ParamTypes,
2982
                                    ArrayRef<Expr *> Args,
2983
                                    OverloadCandidateSet &CandidateSet,
2984
                                    ConversionSequenceList &Conversions,
2985
                                    bool SuppressUserConversions,
2986
                                    CXXRecordDecl *ActingContext = nullptr,
2987
                                    QualType ObjectType = QualType(),
2988
                                    Expr::Classification
2989
                                        ObjectClassification = {});
2990
  void AddConversionCandidate(
2991
      CXXConversionDecl *Conversion, DeclAccessPair FoundDecl,
2992
      CXXRecordDecl *ActingContext, Expr *From, QualType ToType,
2993
      OverloadCandidateSet &CandidateSet, bool AllowObjCConversionOnExplicit,
2994
      bool AllowExplicit, bool AllowResultConversion = true);
2995
  void AddTemplateConversionCandidate(
2996
      FunctionTemplateDecl *FunctionTemplate, DeclAccessPair FoundDecl,
2997
      CXXRecordDecl *ActingContext, Expr *From, QualType ToType,
2998
      OverloadCandidateSet &CandidateSet, bool AllowObjCConversionOnExplicit,
2999
      bool AllowExplicit, bool AllowResultConversion = true);
3000
  void AddSurrogateCandidate(CXXConversionDecl *Conversion,
3001
                             DeclAccessPair FoundDecl,
3002
                             CXXRecordDecl *ActingContext,
3003
                             const FunctionProtoType *Proto,
3004
                             Expr *Object, ArrayRef<Expr *> Args,
3005
                             OverloadCandidateSet& CandidateSet);
3006
  void AddMemberOperatorCandidates(OverloadedOperatorKind Op,
3007
                                   SourceLocation OpLoc, ArrayRef<Expr *> Args,
3008
                                   OverloadCandidateSet& CandidateSet,
3009
                                   SourceRange OpRange = SourceRange());
3010
  void AddBuiltinCandidate(QualType *ParamTys, ArrayRef<Expr *> Args,
3011
                           OverloadCandidateSet& CandidateSet,
3012
                           bool IsAssignmentOperator = false,
3013
                           unsigned NumContextualBoolArguments = 0);
3014
  void AddBuiltinOperatorCandidates(OverloadedOperatorKind Op,
3015
                                    SourceLocation OpLoc, ArrayRef<Expr *> Args,
3016
                                    OverloadCandidateSet& CandidateSet);
3017
  void AddArgumentDependentLookupCandidates(DeclarationName Name,
3018
                                            SourceLocation Loc,
3019
                                            ArrayRef<Expr *> Args,
3020
                                TemplateArgumentListInfo *ExplicitTemplateArgs,
3021
                                            OverloadCandidateSet& CandidateSet,
3022
                                            bool PartialOverloading = false);
3023
3024
  // Emit as a 'note' the specific overload candidate
3025
  void NoteOverloadCandidate(NamedDecl *Found, FunctionDecl *Fn,
3026
                             QualType DestType = QualType(),
3027
                             bool TakingAddress = false);
3028
3029
  // Emit as a series of 'note's all template and non-templates identified by
3030
  // the expression Expr
3031
  void NoteAllOverloadCandidates(Expr *E, QualType DestType = QualType(),
3032
                                 bool TakingAddress = false);
3033
3034
  /// Check the enable_if expressions on the given function. Returns the first
3035
  /// failing attribute, or NULL if they were all successful.
3036
  EnableIfAttr *CheckEnableIf(FunctionDecl *Function, ArrayRef<Expr *> Args,
3037
                              bool MissingImplicitThis = false);
3038
3039
  /// Find the failed Boolean condition within a given Boolean
3040
  /// constant expression, and describe it with a string.
3041
  std::pair<Expr *, std::string> findFailedBooleanCondition(Expr *Cond);
3042
3043
  /// Emit diagnostics for the diagnose_if attributes on Function, ignoring any
3044
  /// non-ArgDependent DiagnoseIfAttrs.
3045
  ///
3046
  /// Argument-dependent diagnose_if attributes should be checked each time a
3047
  /// function is used as a direct callee of a function call.
3048
  ///
3049
  /// Returns true if any errors were emitted.
3050
  bool diagnoseArgDependentDiagnoseIfAttrs(const FunctionDecl *Function,
3051
                                           const Expr *ThisArg,
3052
                                           ArrayRef<const Expr *> Args,
3053
                                           SourceLocation Loc);
3054
3055
  /// Emit diagnostics for the diagnose_if attributes on Function, ignoring any
3056
  /// ArgDependent DiagnoseIfAttrs.
3057
  ///
3058
  /// Argument-independent diagnose_if attributes should be checked on every use
3059
  /// of a function.
3060
  ///
3061
  /// Returns true if any errors were emitted.
3062
  bool diagnoseArgIndependentDiagnoseIfAttrs(const NamedDecl *ND,
3063
                                             SourceLocation Loc);
3064
3065
  /// Returns whether the given function's address can be taken or not,
3066
  /// optionally emitting a diagnostic if the address can't be taken.
3067
  ///
3068
  /// Returns false if taking the address of the function is illegal.
3069
  bool checkAddressOfFunctionIsAvailable(const FunctionDecl *Function,
3070
                                         bool Complain = false,
3071
                                         SourceLocation Loc = SourceLocation());
3072
3073
  // [PossiblyAFunctionType]  -->   [Return]
3074
  // NonFunctionType --> NonFunctionType
3075
  // R (A) --> R(A)
3076
  // R (*)(A) --> R (A)
3077
  // R (&)(A) --> R (A)
3078
  // R (S::*)(A) --> R (A)
3079
  QualType ExtractUnqualifiedFunctionType(QualType PossiblyAFunctionType);
3080
3081
  FunctionDecl *
3082
  ResolveAddressOfOverloadedFunction(Expr *AddressOfExpr,
3083
                                     QualType TargetType,
3084
                                     bool Complain,
3085
                                     DeclAccessPair &Found,
3086
                                     bool *pHadMultipleCandidates = nullptr);
3087
3088
  FunctionDecl *
3089
  resolveAddressOfOnlyViableOverloadCandidate(Expr *E,
3090
                                              DeclAccessPair &FoundResult);
3091
3092
  bool resolveAndFixAddressOfOnlyViableOverloadCandidate(
3093
      ExprResult &SrcExpr, bool DoFunctionPointerConversion = false);
3094
3095
  FunctionDecl *
3096
  ResolveSingleFunctionTemplateSpecialization(OverloadExpr *ovl,
3097
                                              bool Complain = false,
3098
                                              DeclAccessPair *Found = nullptr);
3099
3100
  bool ResolveAndFixSingleFunctionTemplateSpecialization(
3101
                      ExprResult &SrcExpr,
3102
                      bool DoFunctionPointerConverion = false,
3103
                      bool Complain = false,
3104
                      SourceRange OpRangeForComplaining = SourceRange(),
3105
                      QualType DestTypeForComplaining = QualType(),
3106
                      unsigned DiagIDForComplaining = 0);
3107
3108
3109
  Expr *FixOverloadedFunctionReference(Expr *E,
3110
                                       DeclAccessPair FoundDecl,
3111
                                       FunctionDecl *Fn);
3112
  ExprResult FixOverloadedFunctionReference(ExprResult,
3113
                                            DeclAccessPair FoundDecl,
3114
                                            FunctionDecl *Fn);
3115
3116
  void AddOverloadedCallCandidates(UnresolvedLookupExpr *ULE,
3117
                                   ArrayRef<Expr *> Args,
3118
                                   OverloadCandidateSet &CandidateSet,
3119
                                   bool PartialOverloading = false);
3120
3121
  // An enum used to represent the different possible results of building a
3122
  // range-based for loop.
3123
  enum ForRangeStatus {
3124
    FRS_Success,
3125
    FRS_NoViableFunction,
3126
    FRS_DiagnosticIssued
3127
  };
3128
3129
  ForRangeStatus BuildForRangeBeginEndCall(SourceLocation Loc,
3130
                                           SourceLocation RangeLoc,
3131
                                           const DeclarationNameInfo &NameInfo,
3132
                                           LookupResult &MemberLookup,
3133
                                           OverloadCandidateSet *CandidateSet,
3134
                                           Expr *Range, ExprResult *CallExpr);
3135
3136
  ExprResult BuildOverloadedCallExpr(Scope *S, Expr *Fn,
3137
                                     UnresolvedLookupExpr *ULE,
3138
                                     SourceLocation LParenLoc,
3139
                                     MultiExprArg Args,
3140
                                     SourceLocation RParenLoc,
3141
                                     Expr *ExecConfig,
3142
                                     bool AllowTypoCorrection=true,
3143
                                     bool CalleesAddressIsTaken=false);
3144
3145
  bool buildOverloadedCallSet(Scope *S, Expr *Fn, UnresolvedLookupExpr *ULE,
3146
                              MultiExprArg Args, SourceLocation RParenLoc,
3147
                              OverloadCandidateSet *CandidateSet,
3148
                              ExprResult *Result);
3149
3150
  ExprResult CreateOverloadedUnaryOp(SourceLocation OpLoc,
3151
                                     UnaryOperatorKind Opc,
3152
                                     const UnresolvedSetImpl &Fns,
3153
                                     Expr *input, bool RequiresADL = true);
3154
3155
  ExprResult CreateOverloadedBinOp(SourceLocation OpLoc,
3156
                                   BinaryOperatorKind Opc,
3157
                                   const UnresolvedSetImpl &Fns,
3158
                                   Expr *LHS, Expr *RHS,
3159
                                   bool RequiresADL = true);
3160
3161
  ExprResult CreateOverloadedArraySubscriptExpr(SourceLocation LLoc,
3162
                                                SourceLocation RLoc,
3163
                                                Expr *Base,Expr *Idx);
3164
3165
  ExprResult
3166
  BuildCallToMemberFunction(Scope *S, Expr *MemExpr,
3167
                            SourceLocation LParenLoc,
3168
                            MultiExprArg Args,
3169
                            SourceLocation RParenLoc);
3170
  ExprResult
3171
  BuildCallToObjectOfClassType(Scope *S, Expr *Object, SourceLocation LParenLoc,
3172
                               MultiExprArg Args,
3173
                               SourceLocation RParenLoc);
3174
3175
  ExprResult BuildOverloadedArrowExpr(Scope *S, Expr *Base,
3176
                                      SourceLocation OpLoc,
3177
                                      bool *NoArrowOperatorFound = nullptr);
3178
3179
  /// CheckCallReturnType - Checks that a call expression's return type is
3180
  /// complete. Returns true on failure. The location passed in is the location
3181
  /// that best represents the call.
3182
  bool CheckCallReturnType(QualType ReturnType, SourceLocation Loc,
3183
                           CallExpr *CE, FunctionDecl *FD);
3184
3185
  /// Helpers for dealing with blocks and functions.
3186
  bool CheckParmsForFunctionDef(ArrayRef<ParmVarDecl *> Parameters,
3187
                                bool CheckParameterNames);
3188
  void CheckCXXDefaultArguments(FunctionDecl *FD);
3189
  void CheckExtraCXXDefaultArguments(Declarator &D);
3190
  Scope *getNonFieldDeclScope(Scope *S);
3191
3192
  /// \name Name lookup
3193
  ///
3194
  /// These routines provide name lookup that is used during semantic
3195
  /// analysis to resolve the various kinds of names (identifiers,
3196
  /// overloaded operator names, constructor names, etc.) into zero or
3197
  /// more declarations within a particular scope. The major entry
3198
  /// points are LookupName, which performs unqualified name lookup,
3199
  /// and LookupQualifiedName, which performs qualified name lookup.
3200
  ///
3201
  /// All name lookup is performed based on some specific criteria,
3202
  /// which specify what names will be visible to name lookup and how
3203
  /// far name lookup should work. These criteria are important both
3204
  /// for capturing language semantics (certain lookups will ignore
3205
  /// certain names, for example) and for performance, since name
3206
  /// lookup is often a bottleneck in the compilation of C++. Name
3207
  /// lookup criteria is specified via the LookupCriteria enumeration.
3208
  ///
3209
  /// The results of name lookup can vary based on the kind of name
3210
  /// lookup performed, the current language, and the translation
3211
  /// unit. In C, for example, name lookup will either return nothing
3212
  /// (no entity found) or a single declaration. In C++, name lookup
3213
  /// can additionally refer to a set of overloaded functions or
3214
  /// result in an ambiguity. All of the possible results of name
3215
  /// lookup are captured by the LookupResult class, which provides
3216
  /// the ability to distinguish among them.
3217
  //@{
3218
3219
  /// Describes the kind of name lookup to perform.
3220
  enum LookupNameKind {
3221
    /// Ordinary name lookup, which finds ordinary names (functions,
3222
    /// variables, typedefs, etc.) in C and most kinds of names
3223
    /// (functions, variables, members, types, etc.) in C++.
3224
    LookupOrdinaryName = 0,
3225
    /// Tag name lookup, which finds the names of enums, classes,
3226
    /// structs, and unions.
3227
    LookupTagName,
3228
    /// Label name lookup.
3229
    LookupLabel,
3230
    /// Member name lookup, which finds the names of
3231
    /// class/struct/union members.
3232
    LookupMemberName,
3233
    /// Look up of an operator name (e.g., operator+) for use with
3234
    /// operator overloading. This lookup is similar to ordinary name
3235
    /// lookup, but will ignore any declarations that are class members.
3236
    LookupOperatorName,
3237
    /// Look up of a name that precedes the '::' scope resolution
3238
    /// operator in C++. This lookup completely ignores operator, object,
3239
    /// function, and enumerator names (C++ [basic.lookup.qual]p1).
3240
    LookupNestedNameSpecifierName,
3241
    /// Look up a namespace name within a C++ using directive or
3242
    /// namespace alias definition, ignoring non-namespace names (C++
3243
    /// [basic.lookup.udir]p1).
3244
    LookupNamespaceName,
3245
    /// Look up all declarations in a scope with the given name,
3246
    /// including resolved using declarations.  This is appropriate
3247
    /// for checking redeclarations for a using declaration.
3248
    LookupUsingDeclName,
3249
    /// Look up an ordinary name that is going to be redeclared as a
3250
    /// name with linkage. This lookup ignores any declarations that
3251
    /// are outside of the current scope unless they have linkage. See
3252
    /// C99 6.2.2p4-5 and C++ [basic.link]p6.
3253
    LookupRedeclarationWithLinkage,
3254
    /// Look up a friend of a local class. This lookup does not look
3255
    /// outside the innermost non-class scope. See C++11 [class.friend]p11.
3256
    LookupLocalFriendName,
3257
    /// Look up the name of an Objective-C protocol.
3258
    LookupObjCProtocolName,
3259
    /// Look up implicit 'self' parameter of an objective-c method.
3260
    LookupObjCImplicitSelfParam,
3261
    /// Look up the name of an OpenMP user-defined reduction operation.
3262
    LookupOMPReductionName,
3263
    /// Look up the name of an OpenMP user-defined mapper.
3264
    LookupOMPMapperName,
3265
    /// Look up any declaration with any name.
3266
    LookupAnyName
3267
  };
3268
3269
  /// Specifies whether (or how) name lookup is being performed for a
3270
  /// redeclaration (vs. a reference).
3271
  enum RedeclarationKind {
3272
    /// The lookup is a reference to this name that is not for the
3273
    /// purpose of redeclaring the name.
3274
    NotForRedeclaration = 0,
3275
    /// The lookup results will be used for redeclaration of a name,
3276
    /// if an entity by that name already exists and is visible.
3277
    ForVisibleRedeclaration,
3278
    /// The lookup results will be used for redeclaration of a name
3279
    /// with external linkage; non-visible lookup results with external linkage
3280
    /// may also be found.
3281
    ForExternalRedeclaration
3282
  };
3283
3284
11.9M
  RedeclarationKind forRedeclarationInCurContext() {
3285
11.9M
    // A declaration with an owning module for linkage can never link against
3286
11.9M
    // anything that is not visible. We don't need to check linkage here; if
3287
11.9M
    // the context has internal linkage, redeclaration lookup won't find things
3288
11.9M
    // from other TUs, and we can't safely compute linkage yet in general.
3289
11.9M
    if (cast<Decl>(CurContext)
3290
11.9M
            ->getOwningModuleForLinkage(/*IgnoreLinkage*/true))
3291
376
      return ForVisibleRedeclaration;
3292
11.9M
    return ForExternalRedeclaration;
3293
11.9M
  }
3294
3295
  /// The possible outcomes of name lookup for a literal operator.
3296
  enum LiteralOperatorLookupResult {
3297
    /// The lookup resulted in an error.
3298
    LOLR_Error,
3299
    /// The lookup found no match but no diagnostic was issued.
3300
    LOLR_ErrorNoDiagnostic,
3301
    /// The lookup found a single 'cooked' literal operator, which
3302
    /// expects a normal literal to be built and passed to it.
3303
    LOLR_Cooked,
3304
    /// The lookup found a single 'raw' literal operator, which expects
3305
    /// a string literal containing the spelling of the literal token.
3306
    LOLR_Raw,
3307
    /// The lookup found an overload set of literal operator templates,
3308
    /// which expect the characters of the spelling of the literal token to be
3309
    /// passed as a non-type template argument pack.
3310
    LOLR_Template,
3311
    /// The lookup found an overload set of literal operator templates,
3312
    /// which expect the character type and characters of the spelling of the
3313
    /// string literal token to be passed as template arguments.
3314
    LOLR_StringTemplate
3315
  };
3316
3317
  SpecialMemberOverloadResult LookupSpecialMember(CXXRecordDecl *D,
3318
                                                  CXXSpecialMember SM,
3319
                                                  bool ConstArg,
3320
                                                  bool VolatileArg,
3321
                                                  bool RValueThis,
3322
                                                  bool ConstThis,
3323
                                                  bool VolatileThis);
3324
3325
  typedef std::function<void(const TypoCorrection &)> TypoDiagnosticGenerator;
3326
  typedef std::function<ExprResult(Sema &, TypoExpr *, TypoCorrection)>
3327
      TypoRecoveryCallback;
3328
3329
private:
3330
  bool CppLookupName(LookupResult &R, Scope *S);
3331
3332
  struct TypoExprState {
3333
    std::unique_ptr<TypoCorrectionConsumer> Consumer;
3334
    TypoDiagnosticGenerator DiagHandler;
3335
    TypoRecoveryCallback RecoveryHandler;
3336
    TypoExprState();
3337
    TypoExprState(TypoExprState &&other) noexcept;
3338
    TypoExprState &operator=(TypoExprState &&other) noexcept;
3339
  };
3340
3341
  /// The set of unhandled TypoExprs and their associated state.
3342
  llvm::MapVector<TypoExpr *, TypoExprState> DelayedTypos;
3343
3344
  /// Creates a new TypoExpr AST node.
3345
  TypoExpr *createDelayedTypo(std::unique_ptr<TypoCorrectionConsumer> TCC,
3346
                              TypoDiagnosticGenerator TDG,
3347
                              TypoRecoveryCallback TRC);
3348
3349
  // The set of known/encountered (unique, canonicalized) NamespaceDecls.
3350
  //
3351
  // The boolean value will be true to indicate that the namespace was loaded
3352
  // from an AST/PCH file, or false otherwise.
3353
  llvm::MapVector<NamespaceDecl*, bool> KnownNamespaces;
3354
3355
  /// Whether we have already loaded known namespaces from an extenal
3356
  /// source.
3357
  bool LoadedExternalKnownNamespaces;
3358
3359
  /// Helper for CorrectTypo and CorrectTypoDelayed used to create and
3360
  /// populate a new TypoCorrectionConsumer. Returns nullptr if typo correction
3361
  /// should be skipped entirely.
3362
  std::unique_ptr<TypoCorrectionConsumer>
3363
  makeTypoCorrectionConsumer(const DeclarationNameInfo &Typo,
3364
                             Sema::LookupNameKind LookupKind, Scope *S,
3365
                             CXXScopeSpec *SS,
3366
                             CorrectionCandidateCallback &CCC,
3367
                             DeclContext *MemberContext, bool EnteringContext,
3368
                             const ObjCObjectPointerType *OPT,
3369
                             bool ErrorRecovery);
3370
3371
public:
3372
  const TypoExprState &getTypoExprState(TypoExpr *TE) const;
3373
3374
  /// Clears the state of the given TypoExpr.
3375
  void clearDelayedTypo(TypoExpr *TE);
3376
3377
  /// Look up a name, looking for a single declaration.  Return
3378
  /// null if the results were absent, ambiguous, or overloaded.
3379
  ///
3380
  /// It is preferable to use the elaborated form and explicitly handle
3381
  /// ambiguity and overloaded.
3382
  NamedDecl *LookupSingleName(Scope *S, DeclarationName Name,
3383
                              SourceLocation Loc,
3384
                              LookupNameKind NameKind,
3385
                              RedeclarationKind Redecl
3386
                                = NotForRedeclaration);
3387
  bool LookupName(LookupResult &R, Scope *S,
3388
                  bool AllowBuiltinCreation = false);
3389
  bool LookupQualifiedName(LookupResult &R, DeclContext *LookupCtx,
3390
                           bool InUnqualifiedLookup = false);
3391
  bool LookupQualifiedName(LookupResult &R, DeclContext *LookupCtx,
3392
                           CXXScopeSpec &SS);
3393
  bool LookupParsedName(LookupResult &R, Scope *S, CXXScopeSpec *SS,
3394
                        bool AllowBuiltinCreation = false,
3395
                        bool EnteringContext = false);
3396
  ObjCProtocolDecl *LookupProtocol(IdentifierInfo *II, SourceLocation IdLoc,
3397
                                   RedeclarationKind Redecl
3398
                                     = NotForRedeclaration);
3399
  bool LookupInSuper(LookupResult &R, CXXRecordDecl *Class);
3400
3401
  void LookupOverloadedOperatorName(OverloadedOperatorKind Op, Scope *S,
3402
                                    QualType T1, QualType T2,
3403
                                    UnresolvedSetImpl &Functions);
3404
3405
  LabelDecl *LookupOrCreateLabel(IdentifierInfo *II, SourceLocation IdentLoc,
3406
                                 SourceLocation GnuLabelLoc = SourceLocation());
3407
3408
  DeclContextLookupResult LookupConstructors(CXXRecordDecl *Class);
3409
  CXXConstructorDecl *LookupDefaultConstructor(CXXRecordDecl *Class);
3410
  CXXConstructorDecl *LookupCopyingConstructor(CXXRecordDecl *Class,
3411
                                               unsigned Quals);
3412
  CXXMethodDecl *LookupCopyingAssignment(CXXRecordDecl *Class, unsigned Quals,
3413
                                         bool RValueThis, unsigned ThisQuals);
3414
  CXXConstructorDecl *LookupMovingConstructor(CXXRecordDecl *Class,
3415
                                              unsigned Quals);
3416
  CXXMethodDecl *LookupMovingAssignment(CXXRecordDecl *Class, unsigned Quals,
3417
                                        bool RValueThis, unsigned ThisQuals);
3418
  CXXDestructorDecl *LookupDestructor(CXXRecordDecl *Class);
3419
3420
  bool checkLiteralOperatorId(const CXXScopeSpec &SS, const UnqualifiedId &Id);
3421
  LiteralOperatorLookupResult LookupLiteralOperator(Scope *S, LookupResult &R,
3422
                                                    ArrayRef<QualType> ArgTys,
3423
                                                    bool AllowRaw,
3424
                                                    bool AllowTemplate,
3425
                                                    bool AllowStringTemplate,
3426
                                                    bool DiagnoseMissing);
3427
  bool isKnownName(StringRef name);
3428
3429
  void ArgumentDependentLookup(DeclarationName Name, SourceLocation Loc,
3430
                               ArrayRef<Expr *> Args, ADLResult &Functions);
3431
3432
  void LookupVisibleDecls(Scope *S, LookupNameKind Kind,
3433
                          VisibleDeclConsumer &Consumer,
3434
                          bool IncludeGlobalScope = true,
3435
                          bool LoadExternal = true);
3436
  void LookupVisibleDecls(DeclContext *Ctx, LookupNameKind Kind,
3437
                          VisibleDeclConsumer &Consumer,
3438
                          bool IncludeGlobalScope = true,
3439
                          bool IncludeDependentBases = false,
3440
                          bool LoadExternal = true);
3441
3442
  enum CorrectTypoKind {
3443
    CTK_NonError,     // CorrectTypo used in a non error recovery situation.
3444
    CTK_ErrorRecovery // CorrectTypo used in normal error recovery.
3445
  };
3446
3447
  TypoCorrection CorrectTypo(const DeclarationNameInfo &Typo,
3448
                             Sema::LookupNameKind LookupKind,
3449
                             Scope *S, CXXScopeSpec *SS,
3450
                             CorrectionCandidateCallback &CCC,
3451
                             CorrectTypoKind Mode,
3452
                             DeclContext *MemberContext = nullptr,
3453
                             bool EnteringContext = false,
3454
                             const ObjCObjectPointerType *OPT = nullptr,
3455
                             bool RecordFailure = true);
3456
3457
  TypoExpr *CorrectTypoDelayed(const DeclarationNameInfo &Typo,
3458
                               Sema::LookupNameKind LookupKind, Scope *S,
3459
                               CXXScopeSpec *SS,
3460
                               CorrectionCandidateCallback &CCC,
3461
                               TypoDiagnosticGenerator TDG,
3462
                               TypoRecoveryCallback TRC, CorrectTypoKind Mode,
3463
                               DeclContext *MemberContext = nullptr,
3464
                               bool EnteringContext = false,
3465
                               const ObjCObjectPointerType *OPT = nullptr);
3466
3467
  /// Process any TypoExprs in the given Expr and its children,
3468
  /// generating diagnostics as appropriate and returning a new Expr if there
3469
  /// were typos that were all successfully corrected and ExprError if one or
3470
  /// more typos could not be corrected.
3471
  ///
3472
  /// \param E The Expr to check for TypoExprs.
3473
  ///
3474
  /// \param InitDecl A VarDecl to avoid because the Expr being corrected is its
3475
  /// initializer.
3476
  ///
3477
  /// \param Filter A function applied to a newly rebuilt Expr to determine if
3478
  /// it is an acceptable/usable result from a single combination of typo
3479
  /// corrections. As long as the filter returns ExprError, different
3480
  /// combinations of corrections will be tried until all are exhausted.
3481
  ExprResult
3482
  CorrectDelayedTyposInExpr(Expr *E, VarDecl *InitDecl = nullptr,
3483
                            llvm::function_ref<ExprResult(Expr *)> Filter =
3484
244
                                [](Expr *E) -> ExprResult { return E; });
3485
3486
  ExprResult
3487
  CorrectDelayedTyposInExpr(Expr *E,
3488
14.8M
                            llvm::function_ref<ExprResult(Expr *)> Filter) {
3489
14.8M
    return CorrectDelayedTyposInExpr(E, nullptr, Filter);
3490
14.8M
  }
3491
3492
  ExprResult
3493
  CorrectDelayedTyposInExpr(ExprResult ER, VarDecl *InitDecl = nullptr,
3494
                            llvm::function_ref<ExprResult(Expr *)> Filter =
3495
14.8M
                                [](Expr *E) -> ExprResult 
{ return E; }41
) {
3496
14.8M
    return ER.isInvalid() ? 
ER22.5k
:
CorrectDelayedTyposInExpr(ER.get(), Filter)14.8M
;
3497
14.8M
  }
3498
3499
  ExprResult
3500
  CorrectDelayedTyposInExpr(ExprResult ER,
3501
3.06M
                            llvm::function_ref<ExprResult(Expr *)> Filter) {
3502
3.06M
    return CorrectDelayedTyposInExpr(ER, nullptr, Filter);
3503
3.06M
  }
3504
3505
  void diagnoseTypo(const TypoCorrection &Correction,
3506
                    const PartialDiagnostic &TypoDiag,
3507
                    bool ErrorRecovery = true);
3508
3509
  void diagnoseTypo(const TypoCorrection &Correction,
3510
                    const PartialDiagnostic &TypoDiag,
3511
                    const PartialDiagnostic &PrevNote,
3512
                    bool ErrorRecovery = true);
3513
3514
  void MarkTypoCorrectedFunctionDefinition(const NamedDecl *F);
3515
3516
  void FindAssociatedClassesAndNamespaces(SourceLocation InstantiationLoc,
3517
                                          ArrayRef<Expr *> Args,
3518
                                   AssociatedNamespaceSet &AssociatedNamespaces,
3519
                                   AssociatedClassSet &AssociatedClasses);
3520
3521
  void FilterLookupForScope(LookupResult &R, DeclContext *Ctx, Scope *S,
3522
                            bool ConsiderLinkage, bool AllowInlineNamespace);
3523
3524
  bool CheckRedeclarationModuleOwnership(NamedDecl *New, NamedDecl *Old);
3525
3526
  void DiagnoseAmbiguousLookup(LookupResult &Result);
3527
  //@}
3528
3529
  ObjCInterfaceDecl *getObjCInterfaceDecl(IdentifierInfo *&Id,
3530
                                          SourceLocation IdLoc,
3531
                                          bool TypoCorrection = false);
3532
  NamedDecl *LazilyCreateBuiltin(IdentifierInfo *II, unsigned ID,
3533
                                 Scope *S, bool ForRedeclaration,
3534
                                 SourceLocation Loc);
3535
  NamedDecl *ImplicitlyDefineFunction(SourceLocation Loc, IdentifierInfo &II,
3536
                                      Scope *S);
3537
  void AddKnownFunctionAttributes(FunctionDecl *FD);
3538
3539
  // More parsing and symbol table subroutines.
3540
3541
  void ProcessPragmaWeak(Scope *S, Decl *D);
3542
  // Decl attributes - this routine is the top level dispatcher.
3543
  void ProcessDeclAttributes(Scope *S, Decl *D, const Declarator &PD);
3544
  // Helper for delayed processing of attributes.
3545
  void ProcessDeclAttributeDelayed(Decl *D,
3546
                                   const ParsedAttributesView &AttrList);
3547
  void ProcessDeclAttributeList(Scope *S, Decl *D, const ParsedAttributesView &AL,
3548
                             bool IncludeCXX11Attributes = true);
3549
  bool ProcessAccessDeclAttributeList(AccessSpecDecl *ASDecl,
3550
                                   const ParsedAttributesView &AttrList);
3551
3552
  void checkUnusedDeclAttributes(Declarator &D);
3553
3554
  /// Determine if type T is a valid subject for a nonnull and similar
3555
  /// attributes. By default, we look through references (the behavior used by
3556
  /// nonnull), but if the second parameter is true, then we treat a reference
3557
  /// type as valid.
3558
  bool isValidPointerAttrType(QualType T, bool RefOkay = false);
3559
3560
  bool CheckRegparmAttr(const ParsedAttr &attr, unsigned &value);
3561
  bool CheckCallingConvAttr(const ParsedAttr &attr, CallingConv &CC,
3562
                            const FunctionDecl *FD = nullptr);
3563
  bool CheckAttrTarget(const ParsedAttr &CurrAttr);
3564
  bool CheckAttrNoArgs(const ParsedAttr &CurrAttr);
3565
  bool checkStringLiteralArgumentAttr(const ParsedAttr &Attr, unsigned ArgNum,
3566
                                      StringRef &Str,
3567
                                      SourceLocation *ArgLocation = nullptr);
3568
  bool checkSectionName(SourceLocation LiteralLoc, StringRef Str);
3569
  bool checkTargetAttr(SourceLocation LiteralLoc, StringRef Str);
3570
  bool checkMSInheritanceAttrOnDefinition(
3571
      CXXRecordDecl *RD, SourceRange Range, bool BestCase,
3572
      MSInheritanceAttr::Spelling SemanticSpelling);
3573
3574
  void CheckAlignasUnderalignment(Decl *D);
3575
3576
  /// Adjust the calling convention of a method to be the ABI default if it
3577
  /// wasn't specified explicitly.  This handles method types formed from
3578
  /// function type typedefs and typename template arguments.
3579
  void adjustMemberFunctionCC(QualType &T, bool IsStatic, bool IsCtorOrDtor,
3580
                              SourceLocation Loc);
3581
3582
  // Check if there is an explicit attribute, but only look through parens.
3583
  // The intent is to look for an attribute on the current declarator, but not
3584
  // one that came from a typedef.
3585
  bool hasExplicitCallingConv(QualType T);
3586
3587
  /// Get the outermost AttributedType node that sets a calling convention.
3588
  /// Valid types should not have multiple attributes with different CCs.
3589
  const AttributedType *getCallingConvAttributedType(QualType T) const;
3590
3591
  /// Stmt attributes - this routine is the top level dispatcher.
3592
  StmtResult ProcessStmtAttributes(Stmt *Stmt,
3593
                                   const ParsedAttributesView &Attrs,
3594
                                   SourceRange Range);
3595
3596
  void WarnConflictingTypedMethods(ObjCMethodDecl *Method,
3597
                                   ObjCMethodDecl *MethodDecl,
3598
                                   bool IsProtocolMethodDecl);
3599
3600
  void CheckConflictingOverridingMethod(ObjCMethodDecl *Method,
3601
                                   ObjCMethodDecl *Overridden,
3602
                                   bool IsProtocolMethodDecl);
3603
3604
  /// WarnExactTypedMethods - This routine issues a warning if method
3605
  /// implementation declaration matches exactly that of its declaration.
3606
  void WarnExactTypedMethods(ObjCMethodDecl *Method,
3607
                             ObjCMethodDecl *MethodDecl,
3608
                             bool IsProtocolMethodDecl);
3609
3610
  typedef llvm::SmallPtrSet<Selector, 8> SelectorSet;
3611
3612
  /// CheckImplementationIvars - This routine checks if the instance variables
3613
  /// listed in the implelementation match those listed in the interface.
3614
  void CheckImplementationIvars(ObjCImplementationDecl *ImpDecl,
3615
                                ObjCIvarDecl **Fields, unsigned nIvars,
3616
                                SourceLocation Loc);
3617
3618
  /// ImplMethodsVsClassMethods - This is main routine to warn if any method
3619
  /// remains unimplemented in the class or category \@implementation.
3620
  void ImplMethodsVsClassMethods(Scope *S, ObjCImplDecl* IMPDecl,
3621
                                 ObjCContainerDecl* IDecl,
3622
                                 bool IncompleteImpl = false);
3623
3624
  /// DiagnoseUnimplementedProperties - This routine warns on those properties
3625
  /// which must be implemented by this implementation.
3626
  void DiagnoseUnimplementedProperties(Scope *S, ObjCImplDecl* IMPDecl,
3627
                                       ObjCContainerDecl *CDecl,
3628
                                       bool SynthesizeProperties);
3629
3630
  /// Diagnose any null-resettable synthesized setters.
3631
  void diagnoseNullResettableSynthesizedSetters(const ObjCImplDecl *impDecl);
3632
3633
  /// DefaultSynthesizeProperties - This routine default synthesizes all
3634
  /// properties which must be synthesized in the class's \@implementation.
3635
  void DefaultSynthesizeProperties(Scope *S, ObjCImplDecl *IMPDecl,
3636
                                   ObjCInterfaceDecl *IDecl,
3637
                                   SourceLocation AtEnd);
3638
  void DefaultSynthesizeProperties(Scope *S, Decl *D, SourceLocation AtEnd);
3639
3640
  /// IvarBacksCurrentMethodAccessor - This routine returns 'true' if 'IV' is
3641
  /// an ivar synthesized for 'Method' and 'Method' is a property accessor
3642
  /// declared in class 'IFace'.
3643
  bool IvarBacksCurrentMethodAccessor(ObjCInterfaceDecl *IFace,
3644
                                      ObjCMethodDecl *Method, ObjCIvarDecl *IV);
3645
3646
  /// DiagnoseUnusedBackingIvarInAccessor - Issue an 'unused' warning if ivar which
3647
  /// backs the property is not used in the property's accessor.
3648
  void DiagnoseUnusedBackingIvarInAccessor(Scope *S,
3649
                                           const ObjCImplementationDecl *ImplD);
3650
3651
  /// GetIvarBackingPropertyAccessor - If method is a property setter/getter and
3652
  /// it property has a backing ivar, returns this ivar; otherwise, returns NULL.
3653
  /// It also returns ivar's property on success.
3654
  ObjCIvarDecl *GetIvarBackingPropertyAccessor(const ObjCMethodDecl *Method,
3655
                                               const ObjCPropertyDecl *&PDecl) const;
3656
3657
  /// Called by ActOnProperty to handle \@property declarations in
3658
  /// class extensions.
3659
  ObjCPropertyDecl *HandlePropertyInClassExtension(Scope *S,
3660
                      SourceLocation AtLoc,
3661
                      SourceLocation LParenLoc,
3662
                      FieldDeclarator &FD,
3663
                      Selector GetterSel,
3664
                      SourceLocation GetterNameLoc,
3665
                      Selector SetterSel,
3666
                      SourceLocation SetterNameLoc,
3667
                      const bool isReadWrite,
3668
                      unsigned &Attributes,
3669
                      const unsigned AttributesAsWritten,
3670
                      QualType T,
3671
                      TypeSourceInfo *TSI,
3672
                      tok::ObjCKeywordKind MethodImplKind);
3673
3674
  /// Called by ActOnProperty and HandlePropertyInClassExtension to
3675
  /// handle creating the ObjcPropertyDecl for a category or \@interface.
3676
  ObjCPropertyDecl *CreatePropertyDecl(Scope *S,
3677
                                       ObjCContainerDecl *CDecl,
3678
                                       SourceLocation AtLoc,
3679
                                       SourceLocation LParenLoc,
3680
                                       FieldDeclarator &FD,
3681
                                       Selector GetterSel,
3682
                                       SourceLocation GetterNameLoc,
3683
                                       Selector SetterSel,
3684
                                       SourceLocation SetterNameLoc,
3685
                                       const bool isReadWrite,
3686
                                       const unsigned Attributes,
3687
                                       const unsigned AttributesAsWritten,
3688
                                       QualType T,
3689
                                       TypeSourceInfo *TSI,
3690
                                       tok::ObjCKeywordKind MethodImplKind,
3691
                                       DeclContext *lexicalDC = nullptr);
3692
3693
  /// AtomicPropertySetterGetterRules - This routine enforces the rule (via
3694
  /// warning) when atomic property has one but not the other user-declared
3695
  /// setter or getter.
3696
  void AtomicPropertySetterGetterRules(ObjCImplDecl* IMPDecl,
3697
                                       ObjCInterfaceDecl* IDecl);
3698
3699
  void DiagnoseOwningPropertyGetterSynthesis(const ObjCImplementationDecl *D);
3700
3701
  void DiagnoseMissingDesignatedInitOverrides(
3702
                                          const ObjCImplementationDecl *ImplD,
3703
                                          const ObjCInterfaceDecl *IFD);
3704
3705
  void DiagnoseDuplicateIvars(ObjCInterfaceDecl *ID, ObjCInterfaceDecl *SID);
3706
3707
  enum MethodMatchStrategy {
3708
    MMS_loose,
3709
    MMS_strict
3710
  };
3711
3712
  /// MatchTwoMethodDeclarations - Checks if two methods' type match and returns
3713
  /// true, or false, accordingly.
3714
  bool MatchTwoMethodDeclarations(const ObjCMethodDecl *Method,
3715
                                  const ObjCMethodDecl *PrevMethod,
3716
                                  MethodMatchStrategy strategy = MMS_strict);
3717
3718
  /// MatchAllMethodDeclarations - Check methods declaraed in interface or
3719
  /// or protocol against those declared in their implementations.
3720
  void MatchAllMethodDeclarations(const SelectorSet &InsMap,
3721
                                  const SelectorSet &ClsMap,
3722
                                  SelectorSet &InsMapSeen,
3723
                                  SelectorSet &ClsMapSeen,
3724
                                  ObjCImplDecl* IMPDecl,
3725
                                  ObjCContainerDecl* IDecl,
3726
                                  bool &IncompleteImpl,
3727
                                  bool ImmediateClass,
3728
                                  bool WarnCategoryMethodImpl=false);
3729
3730
  /// CheckCategoryVsClassMethodMatches - Checks that methods implemented in
3731
  /// category matches with those implemented in its primary class and
3732
  /// warns each time an exact match is found.
3733
  void CheckCategoryVsClassMethodMatches(ObjCCategoryImplDecl *CatIMP);
3734
3735
  /// Add the given method to the list of globally-known methods.
3736
  void addMethodToGlobalList(ObjCMethodList *List, ObjCMethodDecl *Method);
3737
3738
private:
3739
  /// AddMethodToGlobalPool - Add an instance or factory method to the global
3740
  /// pool. See descriptoin of AddInstanceMethodToGlobalPool.
3741
  void AddMethodToGlobalPool(ObjCMethodDecl *Method, bool impl, bool instance);
3742
3743
  /// LookupMethodInGlobalPool - Returns the instance or factory method and
3744
  /// optionally warns if there are multiple signatures.
3745
  ObjCMethodDecl *LookupMethodInGlobalPool(Selector Sel, SourceRange R,
3746
                                           bool receiverIdOrClass,
3747
                                           bool instance);
3748
3749
public:
3750
  /// - Returns instance or factory methods in global method pool for
3751
  /// given selector. It checks the desired kind first, if none is found, and
3752
  /// parameter checkTheOther is set, it then checks the other kind. If no such
3753
  /// method or only one method is found, function returns false; otherwise, it
3754
  /// returns true.
3755
  bool
3756
  CollectMultipleMethodsInGlobalPool(Selector Sel,
3757
                                     SmallVectorImpl<ObjCMethodDecl*>& Methods,
3758
                                     bool InstanceFirst, bool CheckTheOther,
3759
                                     const ObjCObjectType *TypeBound = nullptr);
3760
3761
  bool
3762
  AreMultipleMethodsInGlobalPool(Selector Sel, ObjCMethodDecl *BestMethod,
3763
                                 SourceRange R, bool receiverIdOrClass,
3764
                                 SmallVectorImpl<ObjCMethodDecl*>& Methods);
3765
3766
  void
3767
  DiagnoseMultipleMethodInGlobalPool(SmallVectorImpl<ObjCMethodDecl*> &Methods,
3768
                                     Selector Sel, SourceRange R,
3769
                                     bool receiverIdOrClass);
3770
3771
private:
3772
  /// - Returns a selector which best matches given argument list or
3773
  /// nullptr if none could be found
3774
  ObjCMethodDecl *SelectBestMethod(Selector Sel, MultiExprArg Args,
3775
                                   bool IsInstance,
3776
                                   SmallVectorImpl<ObjCMethodDecl*>& Methods);
3777
3778
3779
  /// Record the typo correction failure and return an empty correction.
3780
  TypoCorrection FailedCorrection(IdentifierInfo *Typo, SourceLocation TypoLoc,
3781
1.62k
                                  bool RecordFailure = true) {
3782
1.62k
    if (RecordFailure)
3783
1.45k
      TypoCorrectionFailures[Typo].insert(TypoLoc);
3784
1.62k
    return TypoCorrection();
3785
1.62k
  }
3786
3787
public:
3788
  /// AddInstanceMethodToGlobalPool - All instance methods in a translation
3789
  /// unit are added to a global pool. This allows us to efficiently associate
3790
  /// a selector with a method declaraation for purposes of typechecking
3791
  /// messages sent to "id" (where the class of the object is unknown).
3792
71.7k
  void AddInstanceMethodToGlobalPool(ObjCMethodDecl *Method, bool impl=false) {
3793
71.7k
    AddMethodToGlobalPool(Method, impl, /*instance*/true);
3794
71.7k
  }
3795
3796
  /// AddFactoryMethodToGlobalPool - Same as above, but for factory methods.
3797
16.7k
  void AddFactoryMethodToGlobalPool(ObjCMethodDecl *Method, bool impl=false) {
3798
16.7k
    AddMethodToGlobalPool(Method, impl, /*instance*/false);
3799
16.7k
  }
3800
3801
  /// AddAnyMethodToGlobalPool - Add any method, instance or factory to global
3802
  /// pool.
3803
  void AddAnyMethodToGlobalPool(Decl *D);
3804
3805
  /// LookupInstanceMethodInGlobalPool - Returns the method and warns if
3806
  /// there are multiple signatures.
3807
  ObjCMethodDecl *LookupInstanceMethodInGlobalPool(Selector Sel, SourceRange R,
3808
290
                                                   bool receiverIdOrClass=false) {
3809
290
    return LookupMethodInGlobalPool(Sel, R, receiverIdOrClass,
3810
290
                                    /*instance*/true);
3811
290
  }
3812
3813
  /// LookupFactoryMethodInGlobalPool - Returns the method and warns if
3814
  /// there are multiple signatures.
3815
  ObjCMethodDecl *LookupFactoryMethodInGlobalPool(Selector Sel, SourceRange R,
3816
157
                                                  bool receiverIdOrClass=false) {
3817
157
    return LookupMethodInGlobalPool(Sel, R, receiverIdOrClass,
3818
157
                                    /*instance*/false);
3819
157
  }
3820
3821
  const ObjCMethodDecl *SelectorsForTypoCorrection(Selector Sel,
3822
                              QualType ObjectType=QualType());
3823
  /// LookupImplementedMethodInGlobalPool - Returns the method which has an
3824
  /// implementation.
3825
  ObjCMethodDecl *LookupImplementedMethodInGlobalPool(Selector Sel);
3826
3827
  /// CollectIvarsToConstructOrDestruct - Collect those ivars which require
3828
  /// initialization.
3829
  void CollectIvarsToConstructOrDestruct(ObjCInterfaceDecl *OI,
3830
                                  SmallVectorImpl<ObjCIvarDecl*> &Ivars);
3831
3832
  //===--------------------------------------------------------------------===//
3833
  // Statement Parsing Callbacks: SemaStmt.cpp.
3834
public:
3835
  class FullExprArg {
3836
  public:
3837
0
    FullExprArg() : E(nullptr) { }
3838
214k
    FullExprArg(Sema &actions) : E(nullptr) { }
3839
3840
252k
    ExprResult release() {
3841
252k
      return E;
3842
252k
    }
3843
3844
8.31M
    Expr *get() const { return E; }
3845
3846
0
    Expr *operator->() {
3847
0
      return E;
3848
0
    }
3849
3850
  private:
3851
    // FIXME: No need to make the entire Sema class a friend when it's just
3852
    // Sema::MakeFullExpr that needs access to the constructor below.
3853
    friend class Sema;
3854
3855
2.84M
    explicit FullExprArg(Expr *expr) : E(expr) {}
3856
3857
    Expr *E;
3858
  };
3859
3860
4.54k
  FullExprArg MakeFullExpr(Expr *Arg) {
3861
4.54k
    return MakeFullExpr(Arg, Arg ? Arg->getExprLoc() : 
SourceLocation()0
);
3862
4.54k
  }
3863
1.36M
  FullExprArg MakeFullExpr(Expr *Arg, SourceLocation CC) {
3864
1.36M
    return FullExprArg(
3865
1.36M
        ActOnFinishFullExpr(Arg, CC, /*DiscardedValue*/ false).get());
3866
1.36M
  }
3867
245k
  FullExprArg MakeFullDiscardedValueExpr(Expr *Arg) {
3868
245k
    ExprResult FE =
3869
245k
        ActOnFinishFullExpr(Arg, Arg ? 
Arg->getExprLoc()243k
:
SourceLocation()1.94k
,
3870
245k
                            /*DiscardedValue*/ true);
3871
245k
    return FullExprArg(FE.get());
3872
245k
  }
3873
3874
  StmtResult ActOnExprStmt(ExprResult Arg, bool DiscardedValue = true);
3875
  StmtResult ActOnExprStmtError();
3876
3877
  StmtResult ActOnNullStmt(SourceLocation SemiLoc,
3878
                           bool HasLeadingEmptyMacro = false);
3879
3880
  void ActOnStartOfCompoundStmt(bool IsStmtExpr);
3881
  void ActOnFinishOfCompoundStmt();
3882
  StmtResult ActOnCompoundStmt(SourceLocation L, SourceLocation R,
3883
                               ArrayRef<Stmt *> Elts, bool isStmtExpr);
3884
3885
  /// A RAII object to enter scope of a compound statement.
3886
  class CompoundScopeRAII {
3887
  public:
3888
4.70M
    CompoundScopeRAII(Sema &S, bool IsStmtExpr = false) : S(S) {
3889
4.70M
      S.ActOnStartOfCompoundStmt(IsStmtExpr);
3890
4.70M
    }
3891
3892
4.70M
    ~CompoundScopeRAII() {
3893
4.70M
      S.ActOnFinishOfCompoundStmt();
3894
4.70M
    }
3895
3896
  private:
3897
    Sema &S;
3898
  };
3899
3900
  /// An RAII helper that pops function a function scope on exit.
3901
  struct FunctionScopeRAII {
3902
    Sema &S;
3903
    bool Active;
3904
1.49k
    FunctionScopeRAII(Sema &S) : S(S), Active(true) {}
3905
1.49k
    ~FunctionScopeRAII() {
3906
1.49k
      if (Active)
3907
0
        S.PopFunctionScopeInfo();
3908
1.49k
    }
3909
1.49k
    void disable() { Active = false; }
3910
  };
3911
3912
  StmtResult ActOnDeclStmt(DeclGroupPtrTy Decl,
3913
                                   SourceLocation StartLoc,
3914
                                   SourceLocation EndLoc);
3915
  void ActOnForEachDeclStmt(DeclGroupPtrTy Decl);
3916
  StmtResult ActOnForEachLValueExpr(Expr *E);
3917
  ExprResult ActOnCaseExpr(SourceLocation CaseLoc, ExprResult Val);
3918
  StmtResult ActOnCaseStmt(SourceLocation CaseLoc, ExprResult LHS,
3919
                           SourceLocation DotDotDotLoc, ExprResult RHS,
3920
                           SourceLocation ColonLoc);
3921
  void ActOnCaseStmtBody(Stmt *CaseStmt, Stmt *SubStmt);
3922
3923
  StmtResult ActOnDefaultStmt(SourceLocation DefaultLoc,
3924
                                      SourceLocation ColonLoc,
3925
                                      Stmt *SubStmt, Scope *CurScope);
3926
  StmtResult ActOnLabelStmt(SourceLocation IdentLoc, LabelDecl *TheDecl,
3927
                            SourceLocation ColonLoc, Stmt *SubStmt);
3928
3929
  StmtResult ActOnAttributedStmt(SourceLocation AttrLoc,
3930
                                 ArrayRef<const Attr*> Attrs,
3931
                                 Stmt *SubStmt);
3932
3933
  class ConditionResult;
3934
  StmtResult ActOnIfStmt(SourceLocation IfLoc, bool IsConstexpr,
3935
                         Stmt *InitStmt,
3936
                         ConditionResult Cond, Stmt *ThenVal,
3937
                         SourceLocation ElseLoc, Stmt *ElseVal);
3938
  StmtResult BuildIfStmt(SourceLocation IfLoc, bool IsConstexpr,
3939
                         Stmt *InitStmt,
3940
                         ConditionResult Cond, Stmt *ThenVal,
3941
                         SourceLocation ElseLoc, Stmt *ElseVal);
3942
  StmtResult ActOnStartOfSwitchStmt(SourceLocation SwitchLoc,
3943
                                    Stmt *InitStmt,
3944
                                    ConditionResult Cond);
3945
  StmtResult ActOnFinishSwitchStmt(SourceLocation SwitchLoc,
3946
                                           Stmt *Switch, Stmt *Body);
3947
  StmtResult ActOnWhileStmt(SourceLocation WhileLoc, ConditionResult Cond,
3948
                            Stmt *Body);
3949
  StmtResult ActOnDoStmt(SourceLocation DoLoc, Stmt *Body,
3950
                         SourceLocation WhileLoc, SourceLocation CondLParen,
3951
                         Expr *Cond, SourceLocation CondRParen);
3952
3953
  StmtResult ActOnForStmt(SourceLocation ForLoc,
3954
                          SourceLocation LParenLoc,
3955
                          Stmt *First,
3956
                          ConditionResult Second,
3957
                          FullExprArg Third,
3958
                          SourceLocation RParenLoc,
3959
                          Stmt *Body);
3960
  ExprResult CheckObjCForCollectionOperand(SourceLocation forLoc,
3961
                                           Expr *collection);
3962
  StmtResult ActOnObjCForCollectionStmt(SourceLocation ForColLoc,
3963
                                        Stmt *First, Expr *collection,
3964
                                        SourceLocation RParenLoc);
3965
  StmtResult FinishObjCForCollectionStmt(Stmt *ForCollection, Stmt *Body);
3966
3967
  enum BuildForRangeKind {
3968
    /// Initial building of a for-range statement.
3969
    BFRK_Build,
3970
    /// Instantiation or recovery rebuild of a for-range statement. Don't
3971
    /// attempt any typo-correction.
3972
    BFRK_Rebuild,
3973
    /// Determining whether a for-range statement could be built. Avoid any
3974
    /// unnecessary or irreversible actions.
3975
    BFRK_Check
3976
  };
3977
3978
  StmtResult ActOnCXXForRangeStmt(Scope *S, SourceLocation ForLoc,
3979
                                  SourceLocation CoawaitLoc,
3980
                                  Stmt *InitStmt,
3981
                                  Stmt *LoopVar,
3982
                                  SourceLocation ColonLoc, Expr *Collection,
3983
                                  SourceLocation RParenLoc,
3984
                                  BuildForRangeKind Kind);
3985
  StmtResult BuildCXXForRangeStmt(SourceLocation ForLoc,
3986
                                  SourceLocation CoawaitLoc,
3987
                                  Stmt *InitStmt,
3988
                                  SourceLocation ColonLoc,
3989
                                  Stmt *RangeDecl, Stmt *Begin, Stmt *End,
3990
                                  Expr *Cond, Expr *Inc,
3991
                                  Stmt *LoopVarDecl,
3992
                                  SourceLocation RParenLoc,
3993
                                  BuildForRangeKind Kind);
3994
  StmtResult FinishCXXForRangeStmt(Stmt *ForRange, Stmt *Body);
3995
3996
  StmtResult ActOnGotoStmt(SourceLocation GotoLoc,
3997
                           SourceLocation LabelLoc,
3998
                           LabelDecl *TheDecl);
3999
  StmtResult ActOnIndirectGotoStmt(SourceLocation GotoLoc,
4000
                                   SourceLocation StarLoc,
4001
                                   Expr *DestExp);
4002
  StmtResult ActOnContinueStmt(SourceLocation ContinueLoc, Scope *CurScope);
4003
  StmtResult ActOnBreakStmt(SourceLocation BreakLoc, Scope *CurScope);
4004
4005
  void ActOnCapturedRegionStart(SourceLocation Loc, Scope *CurScope,
4006
                                CapturedRegionKind Kind, unsigned NumParams);
4007
  typedef std::pair<StringRef, QualType> CapturedParamNameType;
4008
  void ActOnCapturedRegionStart(SourceLocation Loc, Scope *CurScope,
4009
                                CapturedRegionKind Kind,
4010
                                ArrayRef<CapturedParamNameType> Params);
4011
  StmtResult ActOnCapturedRegionEnd(Stmt *S);
4012
  void ActOnCapturedRegionError();
4013
  RecordDecl *CreateCapturedStmtRecordDecl(CapturedDecl *&CD,
4014
                                           SourceLocation Loc,
4015
                                           unsigned NumParams);
4016
4017
  enum CopyElisionSemanticsKind {
4018
    CES_Strict = 0,
4019
    CES_AllowParameters = 1,
4020
    CES_AllowDifferentTypes = 2,
4021
    CES_AllowExceptionVariables = 4,
4022
    CES_FormerDefault = (CES_AllowParameters),
4023
    CES_Default = (CES_AllowParameters | CES_AllowDifferentTypes),
4024
    CES_AsIfByStdMove = (CES_AllowParameters | CES_AllowDifferentTypes |
4025
                         CES_AllowExceptionVariables),
4026
  };
4027
4028
  VarDecl *getCopyElisionCandidate(QualType ReturnType, Expr *E,
4029
                                   CopyElisionSemanticsKind CESK);
4030
  bool isCopyElisionCandidate(QualType ReturnType, const VarDecl *VD,
4031
                              CopyElisionSemanticsKind CESK);
4032
4033
  StmtResult ActOnReturnStmt(SourceLocation ReturnLoc, Expr *RetValExp,
4034
                             Scope *CurScope);
4035
  StmtResult BuildReturnStmt(SourceLocation ReturnLoc, Expr *RetValExp);
4036
  StmtResult ActOnCapScopeReturnStmt(SourceLocation ReturnLoc, Expr *RetValExp);
4037
4038
  StmtResult ActOnGCCAsmStmt(SourceLocation AsmLoc, bool IsSimple,
4039
                             bool IsVolatile, unsigned NumOutputs,
4040
                             unsigned NumInputs, IdentifierInfo **Names,
4041
                             MultiExprArg Constraints, MultiExprArg Exprs,
4042
                             Expr *AsmString, MultiExprArg Clobbers,
4043
                             unsigned NumLabels,
4044
                             SourceLocation RParenLoc);
4045
4046
  void FillInlineAsmIdentifierInfo(Expr *Res,
4047
                                   llvm::InlineAsmIdentifierInfo &Info);
4048
  ExprResult LookupInlineAsmIdentifier(CXXScopeSpec &SS,
4049
                                       SourceLocation TemplateKWLoc,
4050
                                       UnqualifiedId &Id,
4051
                                       bool IsUnevaluatedContext);
4052
  bool LookupInlineAsmField(StringRef Base, StringRef Member,
4053
                            unsigned &Offset, SourceLocation AsmLoc);
4054
  ExprResult LookupInlineAsmVarDeclField(Expr *RefExpr, StringRef Member,
4055
                                         SourceLocation AsmLoc);
4056
  StmtResult ActOnMSAsmStmt(SourceLocation AsmLoc, SourceLocation LBraceLoc,
4057
                            ArrayRef<Token> AsmToks,
4058
                            StringRef AsmString,
4059
                            unsigned NumOutputs, unsigned NumInputs,
4060
                            ArrayRef<StringRef> Constraints,
4061
                            ArrayRef<StringRef> Clobbers,
4062
                            ArrayRef<Expr*> Exprs,
4063
                            SourceLocation EndLoc);
4064
  LabelDecl *GetOrCreateMSAsmLabel(StringRef ExternalLabelName,
4065
                                   SourceLocation Location,
4066
                                   bool AlwaysCreate);
4067
4068
  VarDecl *BuildObjCExceptionDecl(TypeSourceInfo *TInfo, QualType ExceptionType,
4069
                                  SourceLocation StartLoc,
4070
                                  SourceLocation IdLoc, IdentifierInfo *Id,
4071
                                  bool Invalid = false);
4072
4073
  Decl *ActOnObjCExceptionDecl(Scope *S, Declarator &D);
4074
4075
  StmtResult ActOnObjCAtCatchStmt(SourceLocation AtLoc, SourceLocation RParen,
4076
                                  Decl *Parm, Stmt *Body);
4077
4078
  StmtResult ActOnObjCAtFinallyStmt(SourceLocation AtLoc, Stmt *Body);
4079
4080
  StmtResult ActOnObjCAtTryStmt(SourceLocation AtLoc, Stmt *Try,
4081
                                MultiStmtArg Catch, Stmt *Finally);
4082
4083
  StmtResult BuildObjCAtThrowStmt(SourceLocation AtLoc, Expr *Throw);
4084
  StmtResult ActOnObjCAtThrowStmt(SourceLocation AtLoc, Expr *Throw,
4085
                                  Scope *CurScope);
4086
  ExprResult ActOnObjCAtSynchronizedOperand(SourceLocation atLoc,
4087
                                            Expr *operand);
4088
  StmtResult ActOnObjCAtSynchronizedStmt(SourceLocation AtLoc,
4089
                                         Expr *SynchExpr,
4090
                                         Stmt *SynchBody);
4091
4092
  StmtResult ActOnObjCAutoreleasePoolStmt(SourceLocation AtLoc, Stmt *Body);
4093
4094
  VarDecl *BuildExceptionDeclaration(Scope *S, TypeSourceInfo *TInfo,
4095
                                     SourceLocation StartLoc,
4096
                                     SourceLocation IdLoc,
4097
                                     IdentifierInfo *Id);
4098
4099
  Decl *ActOnExceptionDeclarator(Scope *S, Declarator &D);
4100
4101
  StmtResult ActOnCXXCatchBlock(SourceLocation CatchLoc,
4102
                                Decl *ExDecl, Stmt *HandlerBlock);
4103
  StmtResult ActOnCXXTryBlock(SourceLocation TryLoc, Stmt *TryBlock,
4104
                              ArrayRef<Stmt *> Handlers);
4105
4106
  StmtResult ActOnSEHTryBlock(bool IsCXXTry, // try (true) or __try (false) ?
4107
                              SourceLocation TryLoc, Stmt *TryBlock,
4108
                              Stmt *Handler);
4109
  StmtResult ActOnSEHExceptBlock(SourceLocation Loc,
4110
                                 Expr *FilterExpr,
4111
                                 Stmt *Block);
4112
  void ActOnStartSEHFinallyBlock();
4113
  void ActOnAbortSEHFinallyBlock();
4114
  StmtResult ActOnFinishSEHFinallyBlock(SourceLocation Loc, Stmt *Block);
4115
  StmtResult ActOnSEHLeaveStmt(SourceLocation Loc, Scope *CurScope);
4116
4117
  void DiagnoseReturnInConstructorExceptionHandler(CXXTryStmt *TryBlock);
4118
4119
  bool ShouldWarnIfUnusedFileScopedDecl(const DeclaratorDecl *D) const;
4120
4121
  /// If it's a file scoped decl that must warn if not used, keep track
4122
  /// of it.
4123
  void MarkUnusedFileScopedDecl(const DeclaratorDecl *D);
4124
4125
  /// DiagnoseUnusedExprResult - If the statement passed in is an expression
4126
  /// whose result is unused, warn.
4127
  void DiagnoseUnusedExprResult(const Stmt *S);
4128
  void DiagnoseUnusedNestedTypedefs(const RecordDecl *D);
4129
  void DiagnoseUnusedDecl(const NamedDecl *ND);
4130
4131
  /// Emit \p DiagID if statement located on \p StmtLoc has a suspicious null
4132
  /// statement as a \p Body, and it is located on the same line.
4133
  ///
4134
  /// This helps prevent bugs due to typos, such as:
4135
  ///     if (condition);
4136
  ///       do_stuff();
4137
  void DiagnoseEmptyStmtBody(SourceLocation StmtLoc,
4138
                             const Stmt *Body,
4139
                             unsigned DiagID);
4140
4141
  /// Warn if a for/while loop statement \p S, which is followed by
4142
  /// \p PossibleBody, has a suspicious null statement as a body.
4143
  void DiagnoseEmptyLoopBody(const Stmt *S,
4144
                             const Stmt *PossibleBody);
4145
4146
  /// Warn if a value is moved to itself.
4147
  void DiagnoseSelfMove(const Expr *LHSExpr, const Expr *RHSExpr,
4148
                        SourceLocation OpLoc);
4149
4150
  /// Warn if we're implicitly casting from a _Nullable pointer type to a
4151
  /// _Nonnull one.
4152
  void diagnoseNullableToNonnullConversion(QualType DstType, QualType SrcType,
4153
                                           SourceLocation Loc);
4154
4155
  /// Warn when implicitly casting 0 to nullptr.
4156
  void diagnoseZeroToNullptrConversion(CastKind Kind, const Expr *E);
4157
4158
27.6M
  ParsingDeclState PushParsingDeclaration(sema::DelayedDiagnosticPool &pool) {
4159
27.6M
    return DelayedDiagnostics.push(pool);
4160
27.6M
  }
4161
  void PopParsingDeclaration(ParsingDeclState state, Decl *decl);
4162
4163
  typedef ProcessingContextState ParsingClassState;
4164
844k
  ParsingClassState PushParsingClass() {
4165
844k
    return DelayedDiagnostics.pushUndelayed();
4166
844k
  }
4167
844k
  void PopParsingClass(ParsingClassState state) {
4168
844k
    DelayedDiagnostics.popUndelayed(state);
4169
844k
  }
4170
4171
  void redelayDiagnostics(sema::DelayedDiagnosticPool &pool);
4172
4173
  void DiagnoseAvailabilityOfDecl(NamedDecl *D, ArrayRef<SourceLocation> Locs,
4174
                                  const ObjCInterfaceDecl *UnknownObjCClass,
4175
                                  bool ObjCPropertyAccess,
4176
                                  bool AvoidPartialAvailabilityChecks = false,
4177
                                  ObjCInterfaceDecl *ClassReceiver = nullptr);
4178
4179
  bool makeUnavailableInSystemHeader(SourceLocation loc,
4180
                                     UnavailableAttr::ImplicitReason reason);
4181
4182
  /// Issue any -Wunguarded-availability warnings in \c FD
4183
  void DiagnoseUnguardedAvailabilityViolations(Decl *FD);
4184
4185
  //===--------------------------------------------------------------------===//
4186
  // Expression Parsing Callbacks: SemaExpr.cpp.
4187
4188
  bool CanUseDecl(NamedDecl *D, bool TreatUnavailableAsInvalid);
4189
  bool DiagnoseUseOfDecl(NamedDecl *D, ArrayRef<SourceLocation> Locs,
4190
                         const ObjCInterfaceDecl *UnknownObjCClass = nullptr,
4191
                         bool ObjCPropertyAccess = false,
4192
                         bool AvoidPartialAvailabilityChecks = false,
4193
                         ObjCInterfaceDecl *ClassReciever = nullptr);
4194
  void NoteDeletedFunction(FunctionDecl *FD);
4195
  void NoteDeletedInheritingConstructor(CXXConstructorDecl *CD);
4196
  bool DiagnosePropertyAccessorMismatch(ObjCPropertyDecl *PD,
4197
                                        ObjCMethodDecl *Getter,
4198
                                        SourceLocation Loc);
4199
  void DiagnoseSentinelCalls(NamedDecl *D, SourceLocation Loc,
4200
                             ArrayRef<Expr *> Args);
4201
4202
  void PushExpressionEvaluationContext(
4203
      ExpressionEvaluationContext NewContext, Decl *LambdaContextDecl = nullptr,
4204
      ExpressionEvaluationContextRecord::ExpressionKind Type =
4205
          ExpressionEvaluationContextRecord::EK_Other);
4206
  enum ReuseLambdaContextDecl_t { ReuseLambdaContextDecl };
4207
  void PushExpressionEvaluationContext(
4208
      ExpressionEvaluationContext NewContext, ReuseLambdaContextDecl_t,
4209
      ExpressionEvaluationContextRecord::ExpressionKind Type =
4210
          ExpressionEvaluationContextRecord::EK_Other);
4211
  void PopExpressionEvaluationContext();
4212
4213
  void DiscardCleanupsInEvaluationContext();
4214
4215
  ExprResult TransformToPotentiallyEvaluated(Expr *E);
4216
  ExprResult HandleExprEvaluationContextForTypeof(Expr *E);
4217
4218
  ExprResult ActOnConstantExpression(ExprResult Res);
4219
4220
  // Functions for marking a declaration referenced.  These functions also
4221
  // contain the relevant logic for marking if a reference to a function or
4222
  // variable is an odr-use (in the C++11 sense).  There are separate variants
4223
  // for expressions referring to a decl; these exist because odr-use marking
4224
  // needs to be delayed for some constant variables when we build one of the
4225
  // named expressions.
4226
  //
4227
  // MightBeOdrUse indicates whether the use could possibly be an odr-use, and
4228
  // should usually be true. This only needs to be set to false if the lack of
4229
  // odr-use cannot be determined from the current context (for instance,
4230
  // because the name denotes a virtual function and was written without an
4231
  // explicit nested-name-specifier).
4232
  void MarkAnyDeclReferenced(SourceLocation Loc, Decl *D, bool MightBeOdrUse);
4233
  void MarkFunctionReferenced(SourceLocation Loc, FunctionDecl *Func,
4234
                              bool MightBeOdrUse = true);
4235
  void MarkVariableReferenced(SourceLocation Loc, VarDecl *Var);
4236
  void MarkDeclRefReferenced(DeclRefExpr *E, const Expr *Base = nullptr);
4237
  void MarkMemberReferenced(MemberExpr *E);
4238
  void MarkFunctionParmPackReferenced(FunctionParmPackExpr *E);
4239
  void MarkCaptureUsedInEnclosingContext(VarDecl *Capture, SourceLocation Loc,
4240
                                         unsigned CapturingScopeIndex);
4241
4242
  ExprResult CheckLValueToRValueConversionOperand(Expr *E);
4243
  void CleanupVarDeclMarking();
4244
4245
  enum TryCaptureKind {
4246
    TryCapture_Implicit, TryCapture_ExplicitByVal, TryCapture_ExplicitByRef
4247
  };
4248
4249
  /// Try to capture the given variable.
4250
  ///
4251
  /// \param Var The variable to capture.
4252
  ///
4253
  /// \param Loc The location at which the capture occurs.
4254
  ///
4255
  /// \param Kind The kind of capture, which may be implicit (for either a
4256
  /// block or a lambda), or explicit by-value or by-reference (for a lambda).
4257
  ///
4258
  /// \param EllipsisLoc The location of the ellipsis, if one is provided in
4259
  /// an explicit lambda capture.
4260
  ///
4261
  /// \param BuildAndDiagnose Whether we are actually supposed to add the
4262
  /// captures or diagnose errors. If false, this routine merely check whether
4263
  /// the capture can occur without performing the capture itself or complaining
4264
  /// if the variable cannot be captured.
4265
  ///
4266
  /// \param CaptureType Will be set to the type of the field used to capture
4267
  /// this variable in the innermost block or lambda. Only valid when the
4268
  /// variable can be captured.
4269
  ///
4270
  /// \param DeclRefType Will be set to the type of a reference to the capture
4271
  /// from within the current scope. Only valid when the variable can be
4272
  /// captured.
4273
  ///
4274
  /// \param FunctionScopeIndexToStopAt If non-null, it points to the index
4275
  /// of the FunctionScopeInfo stack beyond which we do not attempt to capture.
4276
  /// This is useful when enclosing lambdas must speculatively capture
4277
  /// variables that may or may not be used in certain specializations of
4278
  /// a nested generic lambda.
4279
  ///
4280
  /// \returns true if an error occurred (i.e., the variable cannot be
4281
  /// captured) and false if the capture succeeded.
4282
  bool tryCaptureVariable(VarDecl *Var, SourceLocation Loc, TryCaptureKind Kind,
4283
                          SourceLocation EllipsisLoc, bool BuildAndDiagnose,
4284
                          QualType &CaptureType,
4285
                          QualType &DeclRefType,
4286
                          const unsigned *const FunctionScopeIndexToStopAt);
4287
4288
  /// Try to capture the given variable.
4289
  bool tryCaptureVariable(VarDecl *Var, SourceLocation Loc,
4290
                          TryCaptureKind Kind = TryCapture_Implicit,
4291
                          SourceLocation EllipsisLoc = SourceLocation());
4292
4293
  /// Checks if the variable must be captured.
4294
  bool NeedToCaptureVariable(VarDecl *Var, SourceLocation Loc);
4295
4296
  /// Given a variable, determine the type that a reference to that
4297
  /// variable will have in the given scope.
4298
  QualType getCapturedDeclRefType(VarDecl *Var, SourceLocation Loc);
4299
4300
  /// Mark all of the declarations referenced within a particular AST node as
4301
  /// referenced. Used when template instantiation instantiates a non-dependent
4302
  /// type -- entities referenced by the type are now referenced.
4303
  void MarkDeclarationsReferencedInType(SourceLocation Loc, QualType T);
4304
  void MarkDeclarationsReferencedInExpr(Expr *E,
4305
                                        bool SkipLocalVariables = false);
4306
4307
  /// Try to recover by turning the given expression into a
4308
  /// call.  Returns true if recovery was attempted or an error was
4309
  /// emitted; this may also leave the ExprResult invalid.
4310
  bool tryToRecoverWithCall(ExprResult &E, const PartialDiagnostic &PD,
4311
                            bool ForceComplain = false,
4312
                            bool (*IsPlausibleResult)(QualType) = nullptr);
4313
4314
  /// Figure out if an expression could be turned into a call.
4315
  bool tryExprAsCall(Expr &E, QualType &ZeroArgCallReturnTy,
4316
                     UnresolvedSetImpl &NonTemplateOverloads);
4317
4318
  /// Conditionally issue a diagnostic based on the current
4319
  /// evaluation context.
4320
  ///
4321
  /// \param Statement If Statement is non-null, delay reporting the
4322
  /// diagnostic until the function body is parsed, and then do a basic
4323
  /// reachability analysis to determine if the statement is reachable.
4324
  /// If it is unreachable, the diagnostic will not be emitted.
4325
  bool DiagRuntimeBehavior(SourceLocation Loc, const Stmt *Statement,
4326
                           const PartialDiagnostic &PD);
4327
  /// Similar, but diagnostic is only produced if all the specified statements
4328
  /// are reachable.
4329
  bool DiagRuntimeBehavior(SourceLocation Loc, ArrayRef<const Stmt*> Stmts,
4330
                           const PartialDiagnostic &PD);
4331
4332
  // Primary Expressions.
4333
  SourceRange getExprRange(Expr *E) const;
4334
4335
  ExprResult ActOnIdExpression(
4336
      Scope *S, CXXScopeSpec &SS, SourceLocation TemplateKWLoc,
4337
      UnqualifiedId &Id, bool HasTrailingLParen, bool IsAddressOfOperand,
4338
      CorrectionCandidateCallback *CCC = nullptr,
4339
      bool IsInlineAsmIdentifier = false, Token *KeywordReplacement = nullptr);
4340
4341
  void DecomposeUnqualifiedId(const UnqualifiedId &Id,
4342
                              TemplateArgumentListInfo &Buffer,
4343
                              DeclarationNameInfo &NameInfo,
4344
                              const TemplateArgumentListInfo *&TemplateArgs);
4345
4346
  bool
4347
  DiagnoseEmptyLookup(Scope *S, CXXScopeSpec &SS, LookupResult &R,
4348
                      CorrectionCandidateCallback &CCC,
4349
                      TemplateArgumentListInfo *ExplicitTemplateArgs = nullptr,
4350
                      ArrayRef<Expr *> Args = None, TypoExpr **Out = nullptr);
4351
4352
  ExprResult LookupInObjCMethod(LookupResult &LookUp, Scope *S,
4353
                                IdentifierInfo *II,
4354
                                bool AllowBuiltinCreation=false);
4355
4356
  ExprResult ActOnDependentIdExpression(const CXXScopeSpec &SS,
4357
                                        SourceLocation TemplateKWLoc,
4358
                                        const DeclarationNameInfo &NameInfo,
4359
                                        bool isAddressOfOperand,
4360
                                const TemplateArgumentListInfo *TemplateArgs);
4361
4362
  /// If \p D cannot be odr-used in the current expression evaluation context,
4363
  /// return a reason explaining why. Otherwise, return NOUR_None.
4364
  NonOdrUseReason getNonOdrUseReasonInCurrentContext(ValueDecl *D);
4365
4366
  DeclRefExpr *BuildDeclRefExpr(ValueDecl *D, QualType Ty, ExprValueKind VK,
4367
                                SourceLocation Loc,
4368
                                const CXXScopeSpec *SS = nullptr);
4369
  DeclRefExpr *
4370
  BuildDeclRefExpr(ValueDecl *D, QualType Ty, ExprValueKind VK,
4371
                   const DeclarationNameInfo &NameInfo,
4372
                   const CXXScopeSpec *SS = nullptr,
4373
                   NamedDecl *FoundD = nullptr,
4374
                   SourceLocation TemplateKWLoc = SourceLocation(),
4375
                   const TemplateArgumentListInfo *TemplateArgs = nullptr);
4376
  DeclRefExpr *
4377
  BuildDeclRefExpr(ValueDecl *D, QualType Ty, ExprValueKind VK,
4378
                   const DeclarationNameInfo &NameInfo,
4379
                   NestedNameSpecifierLoc NNS,
4380
                   NamedDecl *FoundD = nullptr,
4381
                   SourceLocation TemplateKWLoc = SourceLocation(),
4382
                   const TemplateArgumentListInfo *TemplateArgs = nullptr);
4383
4384
  ExprResult
4385
  BuildAnonymousStructUnionMemberReference(
4386
      const CXXScopeSpec &SS,
4387
      SourceLocation nameLoc,
4388
      IndirectFieldDecl *indirectField,
4389
      DeclAccessPair FoundDecl = DeclAccessPair::make(nullptr, AS_none),
4390
      Expr *baseObjectExpr = nullptr,
4391
      SourceLocation opLoc = SourceLocation());
4392
4393
  ExprResult BuildPossibleImplicitMemberExpr(const CXXScopeSpec &SS,
4394
                                             SourceLocation TemplateKWLoc,
4395
                                             LookupResult &R,
4396
                                const TemplateArgumentListInfo *TemplateArgs,
4397
                                             const Scope *S);
4398
  ExprResult BuildImplicitMemberExpr(const CXXScopeSpec &SS,
4399
                                     SourceLocation TemplateKWLoc,
4400
                                     LookupResult &R,
4401
                                const TemplateArgumentListInfo *TemplateArgs,
4402
                                     bool IsDefiniteInstance,
4403
                                     const Scope *S);
4404
  bool UseArgumentDependentLookup(const CXXScopeSpec &SS,
4405
                                  const LookupResult &R,
4406
                                  bool HasTrailingLParen);
4407
4408
  ExprResult
4409
  BuildQualifiedDeclarationNameExpr(CXXScopeSpec &SS,
4410
                                    const DeclarationNameInfo &NameInfo,
4411
                                    bool IsAddressOfOperand, const Scope *S,
4412
                                    TypeSourceInfo **RecoveryTSI = nullptr);
4413
4414
  ExprResult BuildDependentDeclRefExpr(const CXXScopeSpec &SS,
4415
                                       SourceLocation TemplateKWLoc,
4416
                                const DeclarationNameInfo &NameInfo,
4417
                                const TemplateArgumentListInfo *TemplateArgs);
4418
4419
  ExprResult BuildDeclarationNameExpr(const CXXScopeSpec &SS,
4420
                                      LookupResult &R,
4421
                                      bool NeedsADL,
4422
                                      bool AcceptInvalidDecl = false);
4423
  ExprResult BuildDeclarationNameExpr(
4424
      const CXXScopeSpec &SS, const DeclarationNameInfo &NameInfo, NamedDecl *D,
4425
      NamedDecl *FoundD = nullptr,
4426
      const TemplateArgumentListInfo *TemplateArgs = nullptr,
4427
      bool AcceptInvalidDecl = false);
4428
4429
  ExprResult BuildLiteralOperatorCall(LookupResult &R,
4430
                      DeclarationNameInfo &SuffixInfo,
4431
                      ArrayRef<Expr *> Args,
4432
                      SourceLocation LitEndLoc,
4433
                      TemplateArgumentListInfo *ExplicitTemplateArgs = nullptr);
4434
4435
  ExprResult BuildPredefinedExpr(SourceLocation Loc,
4436
                                 PredefinedExpr::IdentKind IK);
4437
  ExprResult ActOnPredefinedExpr(SourceLocation Loc, tok::TokenKind Kind);
4438
  ExprResult ActOnIntegerConstant(SourceLocation Loc, uint64_t Val);
4439
4440
  bool CheckLoopHintExpr(Expr *E, SourceLocation Loc);
4441
4442
  ExprResult ActOnNumericConstant(const Token &Tok, Scope *UDLScope = nullptr);
4443
  ExprResult ActOnCharacterConstant(const Token &Tok,
4444
                                    Scope *UDLScope = nullptr);
4445
  ExprResult ActOnParenExpr(SourceLocation L, SourceLocation R, Expr *E);
4446
  ExprResult ActOnParenListExpr(SourceLocation L,
4447
                                SourceLocation R,
4448
                                MultiExprArg Val);
4449
4450
  /// ActOnStringLiteral - The specified tokens were lexed as pasted string
4451
  /// fragments (e.g. "foo" "bar" L"baz").
4452
  ExprResult ActOnStringLiteral(ArrayRef<Token> StringToks,
4453
                                Scope *UDLScope = nullptr);
4454
4455
  ExprResult ActOnGenericSelectionExpr(SourceLocation KeyLoc,
4456
                                       SourceLocation DefaultLoc,
4457
                                       SourceLocation RParenLoc,
4458
                                       Expr *ControllingExpr,
4459
                                       ArrayRef<ParsedType> ArgTypes,
4460
                                       ArrayRef<Expr *> ArgExprs);
4461
  ExprResult CreateGenericSelectionExpr(SourceLocation KeyLoc,
4462
                                        SourceLocation DefaultLoc,
4463
                                        SourceLocation RParenLoc,
4464
                                        Expr *ControllingExpr,
4465
                                        ArrayRef<TypeSourceInfo *> Types,
4466
                                        ArrayRef<Expr *> Exprs);
4467
4468
  // Binary/Unary Operators.  'Tok' is the token for the operator.
4469
  ExprResult CreateBuiltinUnaryOp(SourceLocation OpLoc, UnaryOperatorKind Opc,
4470
                                  Expr *InputExpr);
4471
  ExprResult BuildUnaryOp(Scope *S, SourceLocation OpLoc,
4472
                          UnaryOperatorKind Opc, Expr *Input);
4473
  ExprResult ActOnUnaryOp(Scope *S, SourceLocation OpLoc,
4474
                          tok::TokenKind Op, Expr *Input);
4475
4476
  bool isQualifiedMemberAccess(Expr *E);
4477
  QualType CheckAddressOfOperand(ExprResult &Operand, SourceLocation OpLoc);
4478
4479
  ExprResult CreateUnaryExprOrTypeTraitExpr(TypeSourceInfo *TInfo,
4480
                                            SourceLocation OpLoc,
4481
                                            UnaryExprOrTypeTrait ExprKind,
4482
                                            SourceRange R);
4483
  ExprResult CreateUnaryExprOrTypeTraitExpr(Expr *E, SourceLocation OpLoc,
4484
                                            UnaryExprOrTypeTrait ExprKind);
4485
  ExprResult
4486
    ActOnUnaryExprOrTypeTraitExpr(SourceLocation OpLoc,
4487
                                  UnaryExprOrTypeTrait ExprKind,
4488
                                  bool IsType, void *TyOrEx,
4489
                                  SourceRange ArgRange);
4490
4491
  ExprResult CheckPlaceholderExpr(Expr *E);
4492
  bool CheckVecStepExpr(Expr *E);
4493
4494
  bool CheckUnaryExprOrTypeTraitOperand(Expr *E, UnaryExprOrTypeTrait ExprKind);
4495
  bool CheckUnaryExprOrTypeTraitOperand(QualType ExprType, SourceLocation OpLoc,
4496
                                        SourceRange ExprRange,
4497
                                        UnaryExprOrTypeTrait ExprKind);
4498
  ExprResult ActOnSizeofParameterPackExpr(Scope *S,
4499
                                          SourceLocation OpLoc,
4500
                                          IdentifierInfo &Name,
4501
                                          SourceLocation NameLoc,
4502
                                          SourceLocation RParenLoc);
4503
  ExprResult ActOnPostfixUnaryOp(Scope *S, SourceLocation OpLoc,
4504
                                 tok::TokenKind Kind, Expr *Input);
4505
4506
  ExprResult ActOnArraySubscriptExpr(Scope *S, Expr *Base, SourceLocation LLoc,
4507
                                     Expr *Idx, SourceLocation RLoc);
4508
  ExprResult CreateBuiltinArraySubscriptExpr(Expr *Base, SourceLocation LLoc,
4509
                                             Expr *Idx, SourceLocation RLoc);
4510
  ExprResult ActOnOMPArraySectionExpr(Expr *Base, SourceLocation LBLoc,
4511
                                      Expr *LowerBound, SourceLocation ColonLoc,
4512
                                      Expr *Length, SourceLocation RBLoc);
4513
4514
  // This struct is for use by ActOnMemberAccess to allow
4515
  // BuildMemberReferenceExpr to be able to reinvoke ActOnMemberAccess after
4516
  // changing the access operator from a '.' to a '->' (to see if that is the
4517
  // change needed to fix an error about an unknown member, e.g. when the class
4518
  // defines a custom operator->).
4519
  struct ActOnMemberAccessExtraArgs {
4520
    Scope *S;
4521
    UnqualifiedId &Id;
4522
    Decl *ObjCImpDecl;
4523
  };
4524
4525
  ExprResult BuildMemberReferenceExpr(
4526
      Expr *Base, QualType BaseType, SourceLocation OpLoc, bool IsArrow,
4527
      CXXScopeSpec &SS, SourceLocation TemplateKWLoc,
4528
      NamedDecl *FirstQualifierInScope, const DeclarationNameInfo &NameInfo,
4529
      const TemplateArgumentListInfo *TemplateArgs,
4530
      const Scope *S,
4531
      ActOnMemberAccessExtraArgs *ExtraArgs = nullptr);
4532
4533
  ExprResult
4534
  BuildMemberReferenceExpr(Expr *Base, QualType BaseType, SourceLocation OpLoc,
4535
                           bool IsArrow, const CXXScopeSpec &SS,
4536
                           SourceLocation TemplateKWLoc,
4537
                           NamedDecl *FirstQualifierInScope, LookupResult &R,
4538
                           const TemplateArgumentListInfo *TemplateArgs,
4539
                           const Scope *S,
4540
                           bool SuppressQualifierCheck = false,
4541
                           ActOnMemberAccessExtraArgs *ExtraArgs = nullptr);
4542
4543
  ExprResult BuildFieldReferenceExpr(Expr *BaseExpr, bool IsArrow,
4544
                                     SourceLocation OpLoc,
4545
                                     const CXXScopeSpec &SS, FieldDecl *Field,
4546
                                     DeclAccessPair FoundDecl,
4547
                                     const DeclarationNameInfo &MemberNameInfo);
4548
4549
  ExprResult PerformMemberExprBaseConversion(Expr *Base, bool IsArrow);
4550
4551
  bool CheckQualifiedMemberReference(Expr *BaseExpr, QualType BaseType,
4552
                                     const CXXScopeSpec &SS,
4553
                                     const LookupResult &R);
4554
4555
  ExprResult ActOnDependentMemberExpr(Expr *Base, QualType BaseType,
4556
                                      bool IsArrow, SourceLocation OpLoc,
4557
                                      const CXXScopeSpec &SS,
4558
                                      SourceLocation TemplateKWLoc,
4559
                                      NamedDecl *FirstQualifierInScope,
4560
                               const DeclarationNameInfo &NameInfo,
4561
                               const TemplateArgumentListInfo *TemplateArgs);
4562
4563
  ExprResult ActOnMemberAccessExpr(Scope *S, Expr *Base,
4564
                                   SourceLocation OpLoc,
4565
                                   tok::TokenKind OpKind,
4566
                                   CXXScopeSpec &SS,
4567
                                   SourceLocation TemplateKWLoc,
4568
                                   UnqualifiedId &Member,
4569
                                   Decl *ObjCImpDecl);
4570
4571
  MemberExpr *
4572
  BuildMemberExpr(Expr *Base, bool IsArrow, SourceLocation OpLoc,
4573
                  const CXXScopeSpec *SS, SourceLocation TemplateKWLoc,
4574
                  ValueDecl *Member, DeclAccessPair FoundDecl,
4575
                  bool HadMultipleCandidates,
4576
                  const DeclarationNameInfo &MemberNameInfo, QualType Ty,
4577
                  ExprValueKind VK, ExprObjectKind OK,
4578
                  const TemplateArgumentListInfo *TemplateArgs = nullptr);
4579
  MemberExpr *
4580
  BuildMemberExpr(Expr *Base, bool IsArrow, SourceLocation OpLoc,
4581
                  NestedNameSpecifierLoc NNS, SourceLocation TemplateKWLoc,
4582
                  ValueDecl *Member, DeclAccessPair FoundDecl,
4583
                  bool HadMultipleCandidates,
4584
                  const DeclarationNameInfo &MemberNameInfo, QualType Ty,
4585
                  ExprValueKind VK, ExprObjectKind OK,
4586
                  const TemplateArgumentListInfo *TemplateArgs = nullptr);
4587
4588
  void ActOnDefaultCtorInitializers(Decl *CDtorDecl);
4589
  bool ConvertArgumentsForCall(CallExpr *Call, Expr *Fn,
4590
                               FunctionDecl *FDecl,
4591
                               const FunctionProtoType *Proto,
4592
                               ArrayRef<Expr *> Args,
4593
                               SourceLocation RParenLoc,
4594
                               bool ExecConfig = false);
4595
  void CheckStaticArrayArgument(SourceLocation CallLoc,
4596
                                ParmVarDecl *Param,
4597
                                const Expr *ArgExpr);
4598
4599
  /// ActOnCallExpr - Handle a call to Fn with the specified array of arguments.
4600
  /// This provides the location of the left/right parens and a list of comma
4601
  /// locations.
4602
  ExprResult ActOnCallExpr(Scope *S, Expr *Fn, SourceLocation LParenLoc,
4603
                           MultiExprArg ArgExprs, SourceLocation RParenLoc,
4604
                           Expr *ExecConfig = nullptr);
4605
  ExprResult BuildCallExpr(Scope *S, Expr *Fn, SourceLocation LParenLoc,
4606
                           MultiExprArg ArgExprs, SourceLocation RParenLoc,
4607
                           Expr *ExecConfig = nullptr,
4608
                           bool IsExecConfig = false);
4609
  ExprResult
4610
  BuildResolvedCallExpr(Expr *Fn, NamedDecl *NDecl, SourceLocation LParenLoc,
4611
                        ArrayRef<Expr *> Arg, SourceLocation RParenLoc,
4612
                        Expr *Config = nullptr, bool IsExecConfig = false,
4613
                        ADLCallKind UsesADL = ADLCallKind::NotADL);
4614
4615
  ExprResult ActOnCUDAExecConfigExpr(Scope *S, SourceLocation LLLLoc,
4616
                                     MultiExprArg ExecConfig,
4617
                                     SourceLocation GGGLoc);
4618
4619
  ExprResult ActOnCastExpr(Scope *S, SourceLocation LParenLoc,
4620
                           Declarator &D, ParsedType &Ty,
4621
                           SourceLocation RParenLoc, Expr *CastExpr);
4622
  ExprResult BuildCStyleCastExpr(SourceLocation LParenLoc,
4623
                                 TypeSourceInfo *Ty,
4624
                                 SourceLocation RParenLoc,
4625
                                 Expr *Op);
4626
  CastKind PrepareScalarCast(ExprResult &src, QualType destType);
4627
4628
  /// Build an altivec or OpenCL literal.
4629
  ExprResult BuildVectorLiteral(SourceLocation LParenLoc,
4630
                                SourceLocation RParenLoc, Expr *E,
4631
                                TypeSourceInfo *TInfo);
4632
4633
  ExprResult MaybeConvertParenListExprToParenExpr(Scope *S, Expr *ME);
4634
4635
  ExprResult ActOnCompoundLiteral(SourceLocation LParenLoc,
4636
                                  ParsedType Ty,
4637
                                  SourceLocation RParenLoc,
4638
                                  Expr *InitExpr);
4639
4640
  ExprResult BuildCompoundLiteralExpr(SourceLocation LParenLoc,
4641
                                      TypeSourceInfo *TInfo,
4642
                                      SourceLocation RParenLoc,
4643
                                      Expr *LiteralExpr);
4644
4645
  ExprResult ActOnInitList(SourceLocation LBraceLoc,
4646
                           MultiExprArg InitArgList,
4647
                           SourceLocation RBraceLoc);
4648
4649
  ExprResult ActOnDesignatedInitializer(Designation &Desig,
4650
                                        SourceLocation Loc,
4651
                                        bool GNUSyntax,
4652
                                        ExprResult Init);
4653
4654
private:
4655
  static BinaryOperatorKind ConvertTokenKindToBinaryOpcode(tok::TokenKind Kind);
4656
4657
public:
4658
  ExprResult ActOnBinOp(Scope *S, SourceLocation TokLoc,
4659
                        tok::TokenKind Kind, Expr *LHSExpr, Expr *RHSExpr);
4660
  ExprResult BuildBinOp(Scope *S, SourceLocation OpLoc,
4661
                        BinaryOperatorKind Opc, Expr *LHSExpr, Expr *RHSExpr);
4662
  ExprResult CreateBuiltinBinOp(SourceLocation OpLoc, BinaryOperatorKind Opc,
4663
                                Expr *LHSExpr, Expr *RHSExpr);
4664
4665
  void DiagnoseCommaOperator(const Expr *LHS, SourceLocation Loc);
4666
4667
  /// ActOnConditionalOp - Parse a ?: operation.  Note that 'LHS' may be null
4668
  /// in the case of a the GNU conditional expr extension.
4669
  ExprResult ActOnConditionalOp(SourceLocation QuestionLoc,
4670
                                SourceLocation ColonLoc,
4671
                                Expr *CondExpr, Expr *LHSExpr, Expr *RHSExpr);
4672
4673
  /// ActOnAddrLabel - Parse the GNU address of label extension: "&&foo".
4674
  ExprResult ActOnAddrLabel(SourceLocation OpLoc, SourceLocation LabLoc,
4675
                            LabelDecl *TheDecl);
4676
4677
  void ActOnStartStmtExpr();
4678
  ExprResult ActOnStmtExpr(SourceLocation LPLoc, Stmt *SubStmt,
4679
                           SourceLocation RPLoc); // "({..})"
4680
  // Handle the final expression in a statement expression.
4681
  ExprResult ActOnStmtExprResult(ExprResult E);
4682
  void ActOnStmtExprError();
4683
4684
  // __builtin_offsetof(type, identifier(.identifier|[expr])*)
4685
  struct OffsetOfComponent {
4686
    SourceLocation LocStart, LocEnd;
4687
    bool isBrackets;  // true if [expr], false if .ident
4688
    union {
4689
      IdentifierInfo *IdentInfo;
4690
      Expr *E;
4691
    } U;
4692
  };
4693
4694
  /// __builtin_offsetof(type, a.b[123][456].c)
4695
  ExprResult BuildBuiltinOffsetOf(SourceLocation BuiltinLoc,
4696
                                  TypeSourceInfo *TInfo,
4697
                                  ArrayRef<OffsetOfComponent> Components,
4698
                                  SourceLocation RParenLoc);
4699
  ExprResult ActOnBuiltinOffsetOf(Scope *S,
4700
                                  SourceLocation BuiltinLoc,
4701
                                  SourceLocation TypeLoc,
4702
                                  ParsedType ParsedArgTy,
4703
                                  ArrayRef<OffsetOfComponent> Components,
4704
                                  SourceLocation RParenLoc);
4705
4706
  // __builtin_choose_expr(constExpr, expr1, expr2)
4707
  ExprResult ActOnChooseExpr(SourceLocation BuiltinLoc,
4708
                             Expr *CondExpr, Expr *LHSExpr,
4709
                             Expr *RHSExpr, SourceLocation RPLoc);
4710
4711
  // __builtin_va_arg(expr, type)
4712
  ExprResult ActOnVAArg(SourceLocation BuiltinLoc, Expr *E, ParsedType Ty,
4713
                        SourceLocation RPLoc);
4714
  ExprResult BuildVAArgExpr(SourceLocation BuiltinLoc, Expr *E,
4715
                            TypeSourceInfo *TInfo, SourceLocation RPLoc);
4716
4717
  // __builtin_LINE(), __builtin_FUNCTION(), __builtin_FILE(),
4718
  // __builtin_COLUMN()
4719
  ExprResult ActOnSourceLocExpr(SourceLocExpr::IdentKind Kind,
4720
                                SourceLocation BuiltinLoc,
4721
                                SourceLocation RPLoc);
4722
4723
  // Build a potentially resolved SourceLocExpr.
4724
  ExprResult BuildSourceLocExpr(SourceLocExpr::IdentKind Kind,
4725
                                SourceLocation BuiltinLoc, SourceLocation RPLoc,
4726
                                DeclContext *ParentContext);
4727
4728
  // __null
4729
  ExprResult ActOnGNUNullExpr(SourceLocation TokenLoc);
4730
4731
  bool CheckCaseExpression(Expr *E);
4732
4733
  /// Describes the result of an "if-exists" condition check.
4734
  enum IfExistsResult {
4735
    /// The symbol exists.
4736
    IER_Exists,
4737
4738
    /// The symbol does not exist.
4739
    IER_DoesNotExist,
4740
4741
    /// The name is a dependent name, so the results will differ
4742
    /// from one instantiation to the next.
4743
    IER_Dependent,
4744
4745
    /// An error occurred.
4746
    IER_Error
4747
  };
4748
4749
  IfExistsResult
4750
  CheckMicrosoftIfExistsSymbol(Scope *S, CXXScopeSpec &SS,
4751
                               const DeclarationNameInfo &TargetNameInfo);
4752
4753
  IfExistsResult
4754
  CheckMicrosoftIfExistsSymbol(Scope *S, SourceLocation KeywordLoc,
4755
                               bool IsIfExists, CXXScopeSpec &SS,
4756
                               UnqualifiedId &Name);
4757
4758
  StmtResult BuildMSDependentExistsStmt(SourceLocation KeywordLoc,
4759
                                        bool IsIfExists,
4760
                                        NestedNameSpecifierLoc QualifierLoc,
4761
                                        DeclarationNameInfo NameInfo,
4762
                                        Stmt *Nested);
4763
  StmtResult ActOnMSDependentExistsStmt(SourceLocation KeywordLoc,
4764
                                        bool IsIfExists,
4765
                                        CXXScopeSpec &SS, UnqualifiedId &Name,
4766
                                        Stmt *Nested);
4767
4768
  //===------------------------- "Block" Extension ------------------------===//
4769
4770
  /// ActOnBlockStart - This callback is invoked when a block literal is
4771
  /// started.
4772
  void ActOnBlockStart(SourceLocation CaretLoc, Scope *CurScope);
4773
4774
  /// ActOnBlockArguments - This callback allows processing of block arguments.
4775
  /// If there are no arguments, this is still invoked.
4776
  void ActOnBlockArguments(SourceLocation CaretLoc, Declarator &ParamInfo,
4777
                           Scope *CurScope);
4778
4779
  /// ActOnBlockError - If there is an error parsing a block, this callback
4780
  /// is invoked to pop the information about the block from the action impl.
4781
  void ActOnBlockError(SourceLocation CaretLoc, Scope *CurScope);
4782
4783
  /// ActOnBlockStmtExpr - This is called when the body of a block statement
4784
  /// literal was successfully completed.  ^(int x){...}
4785
  ExprResult ActOnBlockStmtExpr(SourceLocation CaretLoc, Stmt *Body,
4786
                                Scope *CurScope);
4787
4788
  //===---------------------------- Clang Extensions ----------------------===//
4789
4790
  /// __builtin_convertvector(...)
4791
  ExprResult ActOnConvertVectorExpr(Expr *E, ParsedType ParsedDestTy,
4792
                                    SourceLocation BuiltinLoc,
4793
                                    SourceLocation RParenLoc);
4794
4795
  //===---------------------------- OpenCL Features -----------------------===//
4796
4797
  /// __builtin_astype(...)
4798
  ExprResult ActOnAsTypeExpr(Expr *E, ParsedType ParsedDestTy,
4799
                             SourceLocation BuiltinLoc,
4800
                             SourceLocation RParenLoc);
4801
4802
  //===---------------------------- C++ Features --------------------------===//
4803
4804
  // Act on C++ namespaces
4805
  Decl *ActOnStartNamespaceDef(Scope *S, SourceLocation InlineLoc,
4806
                               SourceLocation NamespaceLoc,
4807
                               SourceLocation IdentLoc, IdentifierInfo *Ident,
4808
                               SourceLocation LBrace,
4809
                               const ParsedAttributesView &AttrList,
4810
                               UsingDirectiveDecl *&UsingDecl);
4811
  void ActOnFinishNamespaceDef(Decl *Dcl, SourceLocation RBrace);
4812
4813
  NamespaceDecl *getStdNamespace() const;
4814
  NamespaceDecl *getOrCreateStdNamespace();
4815
4816
  NamespaceDecl *lookupStdExperimentalNamespace();
4817
4818
  CXXRecordDecl *getStdBadAlloc() const;
4819
  EnumDecl *getStdAlignValT() const;
4820
4821
private:
4822
  // A cache representing if we've fully checked the various comparison category
4823
  // types stored in ASTContext. The bit-index corresponds to the integer value
4824
  // of a ComparisonCategoryType enumerator.
4825
  llvm::SmallBitVector FullyCheckedComparisonCategories;
4826
4827
  ValueDecl *tryLookupCtorInitMemberDecl(CXXRecordDecl *ClassDecl,
4828
                                         CXXScopeSpec &SS,
4829
                                         ParsedType TemplateTypeTy,
4830
                                         IdentifierInfo *MemberOrBase);
4831
4832
public:
4833
  /// Lookup the specified comparison category types in the standard
4834
  ///   library, an check the VarDecls possibly returned by the operator<=>
4835
  ///   builtins for that type.
4836
  ///
4837
  /// \return The type of the comparison category type corresponding to the
4838
  ///   specified Kind, or a null type if an error occurs
4839
  QualType CheckComparisonCategoryType(ComparisonCategoryType Kind,
4840
                                       SourceLocation Loc);
4841
4842
  /// Tests whether Ty is an instance of std::initializer_list and, if
4843
  /// it is and Element is not NULL, assigns the element type to Element.
4844
  bool isStdInitializerList(QualType Ty, QualType *Element);
4845
4846
  /// Looks for the std::initializer_list template and instantiates it
4847
  /// with Element, or emits an error if it's not found.
4848
  ///
4849
  /// \returns The instantiated template, or null on error.
4850
  QualType BuildStdInitializerList(QualType Element, SourceLocation Loc);
4851
4852
  /// Determine whether Ctor is an initializer-list constructor, as
4853
  /// defined in [dcl.init.list]p2.
4854
  bool isInitListConstructor(const FunctionDecl *Ctor);
4855
4856
  Decl *ActOnUsingDirective(Scope *CurScope, SourceLocation UsingLoc,
4857
                            SourceLocation NamespcLoc, CXXScopeSpec &SS,
4858
                            SourceLocation IdentLoc,
4859
                            IdentifierInfo *NamespcName,
4860
                            const ParsedAttributesView &AttrList);
4861
4862
  void PushUsingDirective(Scope *S, UsingDirectiveDecl *UDir);
4863
4864
  Decl *ActOnNamespaceAliasDef(Scope *CurScope,
4865
                               SourceLocation NamespaceLoc,
4866
                               SourceLocation AliasLoc,
4867
                               IdentifierInfo *Alias,
4868
                               CXXScopeSpec &SS,
4869
                               SourceLocation IdentLoc,
4870
                               IdentifierInfo *Ident);
4871
4872
  void HideUsingShadowDecl(Scope *S, UsingShadowDecl *Shadow);
4873
  bool CheckUsingShadowDecl(UsingDecl *UD, NamedDecl *Target,
4874
                            const LookupResult &PreviousDecls,
4875
                            UsingShadowDecl *&PrevShadow);
4876
  UsingShadowDecl *BuildUsingShadowDecl(Scope *S, UsingDecl *UD,
4877
                                        NamedDecl *Target,
4878
                                        UsingShadowDecl *PrevDecl);
4879
4880
  bool CheckUsingDeclRedeclaration(SourceLocation UsingLoc,
4881
                                   bool HasTypenameKeyword,
4882
                                   const CXXScopeSpec &SS,
4883
                                   SourceLocation NameLoc,
4884
                                   const LookupResult &Previous);
4885
  bool CheckUsingDeclQualifier(SourceLocation UsingLoc,
4886
                               bool HasTypename,
4887
                               const CXXScopeSpec &SS,
4888
                               const DeclarationNameInfo &NameInfo,
4889
                               SourceLocation NameLoc);
4890
4891
  NamedDecl *BuildUsingDeclaration(
4892
      Scope *S, AccessSpecifier AS, SourceLocation UsingLoc,
4893
      bool HasTypenameKeyword, SourceLocation TypenameLoc, CXXScopeSpec &SS,
4894
      DeclarationNameInfo NameInfo, SourceLocation EllipsisLoc,
4895
      const ParsedAttributesView &AttrList, bool IsInstantiation);
4896
  NamedDecl *BuildUsingPackDecl(NamedDecl *InstantiatedFrom,
4897
                                ArrayRef<NamedDecl *> Expansions);
4898
4899
  bool CheckInheritingConstructorUsingDecl(UsingDecl *UD);
4900
4901
  /// Given a derived-class using shadow declaration for a constructor and the
4902
  /// correspnding base class constructor, find or create the implicit
4903
  /// synthesized derived class constructor to use for this initialization.
4904
  CXXConstructorDecl *
4905
  findInheritingConstructor(SourceLocation Loc, CXXConstructorDecl *BaseCtor,
4906
                            ConstructorUsingShadowDecl *DerivedShadow);
4907
4908
  Decl *ActOnUsingDeclaration(Scope *CurScope, AccessSpecifier AS,
4909
                              SourceLocation UsingLoc,
4910
                              SourceLocation TypenameLoc, CXXScopeSpec &SS,
4911
                              UnqualifiedId &Name, SourceLocation EllipsisLoc,
4912
                              const ParsedAttributesView &AttrList);
4913
  Decl *ActOnAliasDeclaration(Scope *CurScope, AccessSpecifier AS,
4914
                              MultiTemplateParamsArg TemplateParams,
4915
                              SourceLocation UsingLoc, UnqualifiedId &Name,
4916
                              const ParsedAttributesView &AttrList,
4917
                              TypeResult Type, Decl *DeclFromDeclSpec);
4918
4919
  /// BuildCXXConstructExpr - Creates a complete call to a constructor,
4920
  /// including handling of its default argument expressions.
4921
  ///
4922
  /// \param ConstructKind - a CXXConstructExpr::ConstructionKind
4923
  ExprResult
4924
  BuildCXXConstructExpr(SourceLocation ConstructLoc, QualType DeclInitType,
4925
                        NamedDecl *FoundDecl,
4926
                        CXXConstructorDecl *Constructor, MultiExprArg Exprs,
4927
                        bool HadMultipleCandidates, bool IsListInitialization,
4928
                        bool IsStdInitListInitialization,
4929
                        bool RequiresZeroInit, unsigned ConstructKind,
4930
                        SourceRange ParenRange);
4931
4932
  /// Build a CXXConstructExpr whose constructor has already been resolved if
4933
  /// it denotes an inherited constructor.
4934
  ExprResult
4935
  BuildCXXConstructExpr(SourceLocation ConstructLoc, QualType DeclInitType,
4936
                        CXXConstructorDecl *Constructor, bool Elidable,
4937
                        MultiExprArg Exprs,
4938
                        bool HadMultipleCandidates, bool IsListInitialization,
4939
                        bool IsStdInitListInitialization,
4940
                        bool RequiresZeroInit, unsigned ConstructKind,
4941
                        SourceRange ParenRange);
4942
4943
  // FIXME: Can we remove this and have the above BuildCXXConstructExpr check if
4944
  // the constructor can be elidable?
4945
  ExprResult
4946
  BuildCXXConstructExpr(SourceLocation ConstructLoc, QualType DeclInitType,
4947
                        NamedDecl *FoundDecl,
4948
                        CXXConstructorDecl *Constructor, bool Elidable,
4949
                        MultiExprArg Exprs, bool HadMultipleCandidates,
4950
                        bool IsListInitialization,
4951
                        bool IsStdInitListInitialization, bool RequiresZeroInit,
4952
                        unsigned ConstructKind, SourceRange ParenRange);
4953
4954
  ExprResult BuildCXXDefaultInitExpr(SourceLocation Loc, FieldDecl *Field);
4955
4956
4957
  /// Instantiate or parse a C++ default argument expression as necessary.
4958
  /// Return true on error.
4959
  bool CheckCXXDefaultArgExpr(SourceLocation CallLoc, FunctionDecl *FD,
4960
                              ParmVarDecl *Param);
4961
4962
  /// BuildCXXDefaultArgExpr - Creates a CXXDefaultArgExpr, instantiating
4963
  /// the default expr if needed.
4964
  ExprResult BuildCXXDefaultArgExpr(SourceLocation CallLoc,
4965
                                    FunctionDecl *FD,
4966
                                    ParmVarDecl *Param);
4967
4968
  /// FinalizeVarWithDestructor - Prepare for calling destructor on the
4969
  /// constructed variable.
4970
  void FinalizeVarWithDestructor(VarDecl *VD, const RecordType *DeclInitType);
4971
4972
  /// Helper class that collects exception specifications for
4973
  /// implicitly-declared special member functions.
4974
  class ImplicitExceptionSpecification {
4975
    // Pointer to allow copying
4976
    Sema *Self;
4977
    // We order exception specifications thus:
4978
    // noexcept is the most restrictive, but is only used in C++11.
4979
    // throw() comes next.
4980
    // Then a throw(collected exceptions)
4981
    // Finally no specification, which is expressed as noexcept(false).
4982
    // throw(...) is used instead if any called function uses it.
4983
    ExceptionSpecificationType ComputedEST;
4984
    llvm::SmallPtrSet<CanQualType, 4> ExceptionsSeen;
4985
    SmallVector<QualType, 4> Exceptions;
4986
4987
2.72k
    void ClearExceptions() {
4988
2.72k
      ExceptionsSeen.clear();
4989
2.72k
      Exceptions.clear();
4990
2.72k
    }
4991
4992
  public:
4993
    explicit ImplicitExceptionSpecification(Sema &Self)
4994
244k
      : Self(&Self), ComputedEST(EST_BasicNoexcept) {
4995
244k
      if (!Self.getLangOpts().CPlusPlus11)
4996
7.57k
        ComputedEST = EST_DynamicNone;
4997
244k
    }
4998
4999
    /// Get the computed exception specification type.
5000
244k
    ExceptionSpecificationType getExceptionSpecType() const {
5001
244k
      assert(!isComputedNoexcept(ComputedEST) &&
5002
244k
             "noexcept(expr) should not be a possible result");
5003
244k
      return ComputedEST;
5004
244k
    }
5005
5006
    /// The number of exceptions in the exception specification.
5007
0
    unsigned size() const { return Exceptions.size(); }
5008
5009
    /// The set of exceptions in the exception specification.
5010
0
    const QualType *data() const { return Exceptions.data(); }
5011
5012
    /// Integrate another called method into the collected data.
5013
    void CalledDecl(SourceLocation CallLoc, const CXXMethodDecl *Method);
5014
5015
    /// Integrate an invoked expression into the collected data.
5016
    void CalledExpr(Expr *E);
5017
5018
    /// Overwrite an EPI's exception specification with this
5019
    /// computed exception specification.
5020
244k
    FunctionProtoType::ExceptionSpecInfo getExceptionSpec() const {
5021
244k
      FunctionProtoType::ExceptionSpecInfo ESI;
5022
244k
      ESI.Type = getExceptionSpecType();
5023
244k
      if (ESI.Type == EST_Dynamic) {
5024
21
        ESI.Exceptions = Exceptions;
5025
244k
      } else if (ESI.Type == EST_None) {
5026
2.78k
        /// C++11 [except.spec]p14:
5027
2.78k
        ///   The exception-specification is noexcept(false) if the set of
5028
2.78k
        ///   potential exceptions of the special member function contains "any"
5029
2.78k
        ESI.Type = EST_NoexceptFalse;
5030
2.78k
        ESI.NoexceptExpr = Self->ActOnCXXBoolLiteral(SourceLocation(),
5031
2.78k
                                                     tok::kw_false).get();
5032
2.78k
      }
5033
244k
      return ESI;
5034
244k
    }
5035
  };
5036
5037
  /// Determine what sort of exception specification a defaulted
5038
  /// copy constructor of a class will have.
5039
  ImplicitExceptionSpecification
5040
  ComputeDefaultedDefaultCtorExceptionSpec(SourceLocation Loc,
5041
                                           CXXMethodDecl *MD);
5042
5043
  /// Determine what sort of exception specification a defaulted
5044
  /// default constructor of a class will have, and whether the parameter
5045
  /// will be const.
5046
  ImplicitExceptionSpecification
5047
  ComputeDefaultedCopyCtorExceptionSpec(CXXMethodDecl *MD);
5048
5049
  /// Determine what sort of exception specification a defaulted
5050
  /// copy assignment operator of a class will have, and whether the
5051
  /// parameter will be const.
5052
  ImplicitExceptionSpecification
5053
  ComputeDefaultedCopyAssignmentExceptionSpec(CXXMethodDecl *MD);
5054
5055
  /// Determine what sort of exception specification a defaulted move
5056
  /// constructor of a class will have.
5057
  ImplicitExceptionSpecification
5058
  ComputeDefaultedMoveCtorExceptionSpec(CXXMethodDecl *MD);
5059
5060
  /// Determine what sort of exception specification a defaulted move
5061
  /// assignment operator of a class will have.
5062
  ImplicitExceptionSpecification
5063
  ComputeDefaultedMoveAssignmentExceptionSpec(CXXMethodDecl *MD);
5064
5065
  /// Determine what sort of exception specification a defaulted
5066
  /// destructor of a class will have.
5067
  ImplicitExceptionSpecification
5068
  ComputeDefaultedDtorExceptionSpec(CXXMethodDecl *MD);
5069
5070
  /// Determine what sort of exception specification an inheriting
5071
  /// constructor of a class will have.
5072
  ImplicitExceptionSpecification
5073
  ComputeInheritingCtorExceptionSpec(SourceLocation Loc,
5074
                                     CXXConstructorDecl *CD);
5075
5076
  /// Evaluate the implicit exception specification for a defaulted
5077
  /// special member function.
5078
  void EvaluateImplicitExceptionSpec(SourceLocation Loc, CXXMethodDecl *MD);
5079
5080
  /// Check the given noexcept-specifier, convert its expression, and compute
5081
  /// the appropriate ExceptionSpecificationType.
5082
  ExprResult ActOnNoexceptSpec(SourceLocation NoexceptLoc, Expr *NoexceptExpr,
5083
                               ExceptionSpecificationType &EST);
5084
5085
  /// Check the given exception-specification and update the
5086
  /// exception specification information with the results.
5087
  void checkExceptionSpecification(bool IsTopLevel,
5088
                                   ExceptionSpecificationType EST,
5089
                                   ArrayRef<ParsedType> DynamicExceptions,
5090
                                   ArrayRef<SourceRange> DynamicExceptionRanges,
5091
                                   Expr *NoexceptExpr,
5092
                                   SmallVectorImpl<QualType> &Exceptions,
5093
                                   FunctionProtoType::ExceptionSpecInfo &ESI);
5094
5095
  /// Determine if we're in a case where we need to (incorrectly) eagerly
5096
  /// parse an exception specification to work around a libstdc++ bug.
5097
  bool isLibstdcxxEagerExceptionSpecHack(const Declarator &D);
5098
5099
  /// Add an exception-specification to the given member function
5100
  /// (or member function template). The exception-specification was parsed
5101
  /// after the method itself was declared.
5102
  void actOnDelayedExceptionSpecification(Decl *Method,
5103
         ExceptionSpecificationType EST,
5104
         SourceRange SpecificationRange,
5105
         ArrayRef<ParsedType> DynamicExceptions,
5106
         ArrayRef<SourceRange> DynamicExceptionRanges,
5107
         Expr *NoexceptExpr);
5108
5109
  class InheritedConstructorInfo;
5110
5111
  /// Determine if a special member function should have a deleted
5112
  /// definition when it is defaulted.
5113
  bool ShouldDeleteSpecialMember(CXXMethodDecl *MD, CXXSpecialMember CSM,
5114
                                 InheritedConstructorInfo *ICI = nullptr,
5115
                                 bool Diagnose = false);
5116
5117
  /// Declare the implicit default constructor for the given class.
5118
  ///
5119
  /// \param ClassDecl The class declaration into which the implicit
5120
  /// default constructor will be added.
5121
  ///
5122
  /// \returns The implicitly-declared default constructor.
5123
  CXXConstructorDecl *DeclareImplicitDefaultConstructor(
5124
                                                     CXXRecordDecl *ClassDecl);
5125
5126
  /// DefineImplicitDefaultConstructor - Checks for feasibility of
5127
  /// defining this constructor as the default constructor.
5128
  void DefineImplicitDefaultConstructor(SourceLocation CurrentLocation,
5129
                                        CXXConstructorDecl *Constructor);
5130
5131
  /// Declare the implicit destructor for the given class.
5132
  ///
5133
  /// \param ClassDecl The class declaration into which the implicit
5134
  /// destructor will be added.
5135
  ///
5136
  /// \returns The implicitly-declared destructor.
5137
  CXXDestructorDecl *DeclareImplicitDestructor(CXXRecordDecl *ClassDecl);
5138
5139
  /// DefineImplicitDestructor - Checks for feasibility of
5140
  /// defining this destructor as the default destructor.
5141
  void DefineImplicitDestructor(SourceLocation CurrentLocation,
5142
                                CXXDestructorDecl *Destructor);
5143
5144
  /// Build an exception spec for destructors that don't have one.
5145
  ///
5146
  /// C++11 says that user-defined destructors with no exception spec get one
5147
  /// that looks as if the destructor was implicitly declared.
5148
  void AdjustDestructorExceptionSpec(CXXDestructorDecl *Destructor);
5149
5150
  /// Define the specified inheriting constructor.
5151
  void DefineInheritingConstructor(SourceLocation UseLoc,
5152
                                   CXXConstructorDecl *Constructor);
5153
5154
  /// Declare the implicit copy constructor for the given class.
5155
  ///
5156
  /// \param ClassDecl The class declaration into which the implicit
5157
  /// copy constructor will be added.
5158
  ///
5159
  /// \returns The implicitly-declared copy constructor.
5160
  CXXConstructorDecl *DeclareImplicitCopyConstructor(CXXRecordDecl *ClassDecl);
5161
5162
  /// DefineImplicitCopyConstructor - Checks for feasibility of
5163
  /// defining this constructor as the copy constructor.
5164
  void DefineImplicitCopyConstructor(SourceLocation CurrentLocation,
5165
                                     CXXConstructorDecl *Constructor);
5166
5167
  /// Declare the implicit move constructor for the given class.
5168
  ///
5169
  /// \param ClassDecl The Class declaration into which the implicit
5170
  /// move constructor will be added.
5171
  ///
5172
  /// \returns The implicitly-declared move constructor, or NULL if it wasn't
5173
  /// declared.
5174
  CXXConstructorDecl *DeclareImplicitMoveConstructor(CXXRecordDecl *ClassDecl);
5175
5176
  /// DefineImplicitMoveConstructor - Checks for feasibility of
5177
  /// defining this constructor as the move constructor.
5178
  void DefineImplicitMoveConstructor(SourceLocation CurrentLocation,
5179
                                     CXXConstructorDecl *Constructor);
5180
5181
  /// Declare the implicit copy assignment operator for the given class.
5182
  ///
5183
  /// \param ClassDecl The class declaration into which the implicit
5184
  /// copy assignment operator will be added.
5185
  ///
5186
  /// \returns The implicitly-declared copy assignment operator.
5187
  CXXMethodDecl *DeclareImplicitCopyAssignment(CXXRecordDecl *ClassDecl);
5188
5189
  /// Defines an implicitly-declared copy assignment operator.
5190
  void DefineImplicitCopyAssignment(SourceLocation CurrentLocation,
5191
                                    CXXMethodDecl *MethodDecl);
5192
5193
  /// Declare the implicit move assignment operator for the given class.
5194
  ///
5195
  /// \param ClassDecl The Class declaration into which the implicit
5196
  /// move assignment operator will be added.
5197
  ///
5198
  /// \returns The implicitly-declared move assignment operator, or NULL if it
5199
  /// wasn't declared.
5200
  CXXMethodDecl *DeclareImplicitMoveAssignment(CXXRecordDecl *ClassDecl);
5201
5202
  /// Defines an implicitly-declared move assignment operator.
5203
  void DefineImplicitMoveAssignment(SourceLocation CurrentLocation,
5204
                                    CXXMethodDecl *MethodDecl);
5205
5206
  /// Force the declaration of any implicitly-declared members of this
5207
  /// class.
5208
  void ForceDeclarationOfImplicitMembers(CXXRecordDecl *Class);
5209
5210
  /// Check a completed declaration of an implicit special member.
5211
  void CheckImplicitSpecialMemberDeclaration(Scope *S, FunctionDecl *FD);
5212
5213
  /// Determine whether the given function is an implicitly-deleted
5214
  /// special member function.
5215
  bool isImplicitlyDeleted(FunctionDecl *FD);
5216
5217
  /// Check whether 'this' shows up in the type of a static member
5218
  /// function after the (naturally empty) cv-qualifier-seq would be.
5219
  ///
5220
  /// \returns true if an error occurred.
5221
  bool checkThisInStaticMemberFunctionType(CXXMethodDecl *Method);
5222
5223
  /// Whether this' shows up in the exception specification of a static
5224
  /// member function.
5225
  bool checkThisInStaticMemberFunctionExceptionSpec(CXXMethodDecl *Method);
5226
5227
  /// Check whether 'this' shows up in the attributes of the given
5228
  /// static member function.
5229
  ///
5230
  /// \returns true if an error occurred.
5231
  bool checkThisInStaticMemberFunctionAttributes(CXXMethodDecl *Method);
5232
5233
  /// MaybeBindToTemporary - If the passed in expression has a record type with
5234
  /// a non-trivial destructor, this will return CXXBindTemporaryExpr. Otherwise
5235
  /// it simply returns the passed in expression.
5236
  ExprResult MaybeBindToTemporary(Expr *E);
5237
5238
  bool CompleteConstructorCall(CXXConstructorDecl *Constructor,
5239
                               MultiExprArg ArgsPtr,
5240
                               SourceLocation Loc,
5241
                               SmallVectorImpl<Expr*> &ConvertedArgs,
5242
                               bool AllowExplicit = false,
5243
                               bool IsListInitialization = false);
5244
5245
  ParsedType getInheritingConstructorName(CXXScopeSpec &SS,
5246
                                          SourceLocation NameLoc,
5247
                                          IdentifierInfo &Name);
5248
5249
  ParsedType getConstructorName(IdentifierInfo &II, SourceLocation NameLoc,
5250
                                Scope *S, CXXScopeSpec &SS,
5251
                                bool EnteringContext);
5252
  ParsedType getDestructorName(SourceLocation TildeLoc,
5253
                               IdentifierInfo &II, SourceLocation NameLoc,
5254
                               Scope *S, CXXScopeSpec &SS,
5255
                               ParsedType ObjectType,
5256
                               bool EnteringContext);
5257
5258
  ParsedType getDestructorTypeForDecltype(const DeclSpec &DS,
5259
                                          ParsedType ObjectType);
5260
5261
  // Checks that reinterpret casts don't have undefined behavior.
5262
  void CheckCompatibleReinterpretCast(QualType SrcType, QualType DestType,
5263
                                      bool IsDereference, SourceRange Range);
5264
5265
  /// ActOnCXXNamedCast - Parse {dynamic,static,reinterpret,const}_cast's.
5266
  ExprResult ActOnCXXNamedCast(SourceLocation OpLoc,
5267
                               tok::TokenKind Kind,
5268
                               SourceLocation LAngleBracketLoc,
5269
                               Declarator &D,
5270
                               SourceLocation RAngleBracketLoc,
5271
                               SourceLocation LParenLoc,
5272
                               Expr *E,
5273
                               SourceLocation RParenLoc);
5274
5275
  ExprResult BuildCXXNamedCast(SourceLocation OpLoc,
5276
                               tok::TokenKind Kind,
5277
                               TypeSourceInfo *Ty,
5278
                               Expr *E,
5279
                               SourceRange AngleBrackets,
5280
                               SourceRange Parens);
5281
5282
  ExprResult ActOnBuiltinBitCastExpr(SourceLocation KWLoc, Declarator &Dcl,
5283
                                     ExprResult Operand,
5284
                                     SourceLocation RParenLoc);
5285
5286
  ExprResult BuildBuiltinBitCastExpr(SourceLocation KWLoc, TypeSourceInfo *TSI,
5287
                                     Expr *Operand, SourceLocation RParenLoc);
5288
5289
  ExprResult BuildCXXTypeId(QualType TypeInfoType,
5290
                            SourceLocation TypeidLoc,
5291
                            TypeSourceInfo *Operand,
5292
                            SourceLocation RParenLoc);
5293
  ExprResult BuildCXXTypeId(QualType TypeInfoType,
5294
                            SourceLocation TypeidLoc,
5295
                            Expr *Operand,
5296
                            SourceLocation RParenLoc);
5297
5298
  /// ActOnCXXTypeid - Parse typeid( something ).
5299
  ExprResult ActOnCXXTypeid(SourceLocation OpLoc,
5300
                            SourceLocation LParenLoc, bool isType,
5301
                            void *TyOrExpr,
5302
                            SourceLocation RParenLoc);
5303
5304
  ExprResult BuildCXXUuidof(QualType TypeInfoType,
5305
                            SourceLocation TypeidLoc,
5306
                            TypeSourceInfo *Operand,
5307
                            SourceLocation RParenLoc);
5308
  ExprResult BuildCXXUuidof(QualType TypeInfoType,
5309
                            SourceLocation TypeidLoc,
5310
                            Expr *Operand,
5311
                            SourceLocation RParenLoc);
5312
5313
  /// ActOnCXXUuidof - Parse __uuidof( something ).
5314
  ExprResult ActOnCXXUuidof(SourceLocation OpLoc,
5315
                            SourceLocation LParenLoc, bool isType,
5316
                            void *TyOrExpr,
5317
                            SourceLocation RParenLoc);
5318
5319
  /// Handle a C++1z fold-expression: ( expr op ... op expr ).
5320
  ExprResult ActOnCXXFoldExpr(SourceLocation LParenLoc, Expr *LHS,
5321
                              tok::TokenKind Operator,
5322
                              SourceLocation EllipsisLoc, Expr *RHS,
5323
                              SourceLocation RParenLoc);
5324
  ExprResult BuildCXXFoldExpr(SourceLocation LParenLoc, Expr *LHS,
5325
                              BinaryOperatorKind Operator,
5326
                              SourceLocation EllipsisLoc, Expr *RHS,
5327
                              SourceLocation RParenLoc,
5328
                              Optional<unsigned> NumExpansions);
5329
  ExprResult BuildEmptyCXXFoldExpr(SourceLocation EllipsisLoc,
5330
                                   BinaryOperatorKind Operator);
5331
5332
  //// ActOnCXXThis -  Parse 'this' pointer.
5333
  ExprResult ActOnCXXThis(SourceLocation loc);
5334
5335
  /// Build a CXXThisExpr and mark it referenced in the current context.
5336
  Expr *BuildCXXThisExpr(SourceLocation Loc, QualType Type, bool IsImplicit);
5337
  void MarkThisReferenced(CXXThisExpr *This);
5338
5339
  /// Try to retrieve the type of the 'this' pointer.
5340
  ///
5341
  /// \returns The type of 'this', if possible. Otherwise, returns a NULL type.
5342
  QualType getCurrentThisType();
5343
5344
  /// When non-NULL, the C++ 'this' expression is allowed despite the
5345
  /// current context not being a non-static member function. In such cases,
5346
  /// this provides the type used for 'this'.
5347
  QualType CXXThisTypeOverride;
5348
5349
  /// RAII object used to temporarily allow the C++ 'this' expression
5350
  /// to be used, with the given qualifiers on the current class type.
5351
  class CXXThisScopeRAII {
5352
    Sema &S;
5353
    QualType OldCXXThisTypeOverride;
5354
    bool Enabled;
5355
5356
  public:
5357
    /// Introduce a new scope where 'this' may be allowed (when enabled),
5358
    /// using the given declaration (which is either a class template or a
5359
    /// class) along with the given qualifiers.
5360
    /// along with the qualifiers placed on '*this'.
5361
    CXXThisScopeRAII(Sema &S, Decl *ContextDecl, Qualifiers CXXThisTypeQuals,
5362
                     bool Enabled = true);
5363
5364
    ~CXXThisScopeRAII();
5365
  };
5366
5367
  /// Make sure the value of 'this' is actually available in the current
5368
  /// context, if it is a potentially evaluated context.
5369
  ///
5370
  /// \param Loc The location at which the capture of 'this' occurs.
5371
  ///
5372
  /// \param Explicit Whether 'this' is explicitly captured in a lambda
5373
  /// capture list.
5374
  ///
5375
  /// \param FunctionScopeIndexToStopAt If non-null, it points to the index
5376
  /// of the FunctionScopeInfo stack beyond which we do not attempt to capture.
5377
  /// This is useful when enclosing lambdas must speculatively capture
5378
  /// 'this' that may or may not be used in certain specializations of
5379
  /// a nested generic lambda (depending on whether the name resolves to
5380
  /// a non-static member function or a static function).
5381
  /// \return returns 'true' if failed, 'false' if success.
5382
  bool CheckCXXThisCapture(SourceLocation Loc, bool Explicit = false,
5383
      bool BuildAndDiagnose = true,
5384
      const unsigned *const FunctionScopeIndexToStopAt = nullptr,
5385
      bool ByCopy = false);
5386
5387
  /// Determine whether the given type is the type of *this that is used
5388
  /// outside of the body of a member function for a type that is currently
5389
  /// being defined.
5390
  bool isThisOutsideMemberFunctionBody(QualType BaseType);
5391
5392
  /// ActOnCXXBoolLiteral - Parse {true,false} literals.
5393
  ExprResult ActOnCXXBoolLiteral(SourceLocation OpLoc, tok::TokenKind Kind);
5394
5395
5396
  /// ActOnObjCBoolLiteral - Parse {__objc_yes,__objc_no} literals.
5397
  ExprResult ActOnObjCBoolLiteral(SourceLocation OpLoc, tok::TokenKind Kind);
5398
5399
  ExprResult
5400
  ActOnObjCAvailabilityCheckExpr(llvm::ArrayRef<AvailabilitySpec> AvailSpecs,
5401
                                 SourceLocation AtLoc, SourceLocation RParen);
5402
5403
  /// ActOnCXXNullPtrLiteral - Parse 'nullptr'.
5404
  ExprResult ActOnCXXNullPtrLiteral(SourceLocation Loc);
5405
5406
  //// ActOnCXXThrow -  Parse throw expressions.
5407
  ExprResult ActOnCXXThrow(Scope *S, SourceLocation OpLoc, Expr *expr);
5408
  ExprResult BuildCXXThrow(SourceLocation OpLoc, Expr *Ex,
5409
                           bool IsThrownVarInScope);
5410
  bool CheckCXXThrowOperand(SourceLocation ThrowLoc, QualType ThrowTy, Expr *E);
5411
5412
  /// ActOnCXXTypeConstructExpr - Parse construction of a specified type.
5413
  /// Can be interpreted either as function-style casting ("int(x)")
5414
  /// or class type construction ("ClassType(x,y,z)")
5415
  /// or creation of a value-initialized type ("int()").
5416
  ExprResult ActOnCXXTypeConstructExpr(ParsedType TypeRep,
5417
                                       SourceLocation LParenOrBraceLoc,
5418
                                       MultiExprArg Exprs,
5419
                                       SourceLocation RParenOrBraceLoc,
5420
                                       bool ListInitialization);
5421
5422
  ExprResult BuildCXXTypeConstructExpr(TypeSourceInfo *Type,
5423
                                       SourceLocation LParenLoc,
5424
                                       MultiExprArg Exprs,
5425
                                       SourceLocation RParenLoc,
5426
                                       bool ListInitialization);
5427
5428
  /// ActOnCXXNew - Parsed a C++ 'new' expression.
5429
  ExprResult ActOnCXXNew(SourceLocation StartLoc, bool UseGlobal,
5430
                         SourceLocation PlacementLParen,
5431
                         MultiExprArg PlacementArgs,
5432
                         SourceLocation PlacementRParen,
5433
                         SourceRange TypeIdParens, Declarator &D,
5434
                         Expr *Initializer);
5435
  ExprResult BuildCXXNew(SourceRange Range, bool UseGlobal,
5436
                         SourceLocation PlacementLParen,
5437
                         MultiExprArg PlacementArgs,
5438
                         SourceLocation PlacementRParen,
5439
                         SourceRange TypeIdParens,
5440
                         QualType AllocType,
5441
                         TypeSourceInfo *AllocTypeInfo,
5442
                         Optional<Expr *> ArraySize,
5443
                         SourceRange DirectInitRange,
5444
                         Expr *Initializer);
5445
5446
  /// Determine whether \p FD is an aligned allocation or deallocation
5447
  /// function that is unavailable.
5448
  bool isUnavailableAlignedAllocationFunction(const FunctionDecl &FD) const;
5449
5450
  /// Produce diagnostics if \p FD is an aligned allocation or deallocation
5451
  /// function that is unavailable.
5452
  void diagnoseUnavailableAlignedAllocation(const FunctionDecl &FD,
5453
                                            SourceLocation Loc);
5454
5455
  bool CheckAllocatedType(QualType AllocType, SourceLocation Loc,
5456
                          SourceRange R);
5457
5458
  /// The scope in which to find allocation functions.
5459
  enum AllocationFunctionScope {
5460
    /// Only look for allocation functions in the global scope.
5461
    AFS_Global,
5462
    /// Only look for allocation functions in the scope of the
5463
    /// allocated class.
5464
    AFS_Class,
5465
    /// Look for allocation functions in both the global scope
5466
    /// and in the scope of the allocated class.
5467
    AFS_Both
5468
  };
5469
5470
  /// Finds the overloads of operator new and delete that are appropriate
5471
  /// for the allocation.
5472
  bool FindAllocationFunctions(SourceLocation StartLoc, SourceRange Range,
5473
                               AllocationFunctionScope NewScope,
5474
                               AllocationFunctionScope DeleteScope,
5475
                               QualType AllocType, bool IsArray,
5476
                               bool &PassAlignment, MultiExprArg PlaceArgs,
5477
                               FunctionDecl *&OperatorNew,
5478
                               FunctionDecl *&OperatorDelete,
5479
                               bool Diagnose = true);
5480
  void DeclareGlobalNewDelete();
5481
  void DeclareGlobalAllocationFunction(DeclarationName Name, QualType Return,
5482
                                       ArrayRef<QualType> Params);
5483
5484
  bool FindDeallocationFunction(SourceLocation StartLoc, CXXRecordDecl *RD,
5485
                                DeclarationName Name, FunctionDecl* &Operator,
5486
                                bool Diagnose = true);
5487
  FunctionDecl *FindUsualDeallocationFunction(SourceLocation StartLoc,
5488
                                              bool CanProvideSize,
5489
                                              bool Overaligned,
5490
                                              DeclarationName Name);
5491
  FunctionDecl *FindDeallocationFunctionForDestructor(SourceLocation StartLoc,
5492
                                                      CXXRecordDecl *RD);
5493
5494
  /// ActOnCXXDelete - Parsed a C++ 'delete' expression
5495
  ExprResult ActOnCXXDelete(SourceLocation StartLoc,
5496
                            bool UseGlobal, bool ArrayForm,
5497
                            Expr *Operand);
5498
  void CheckVirtualDtorCall(CXXDestructorDecl *dtor, SourceLocation Loc,
5499
                            bool IsDelete, bool CallCanBeVirtual,
5500
                            bool WarnOnNonAbstractTypes,
5501
                            SourceLocation DtorLoc);
5502
5503
  ExprResult ActOnNoexceptExpr(SourceLocation KeyLoc, SourceLocation LParen,
5504
                               Expr *Operand, SourceLocation RParen);
5505
  ExprResult BuildCXXNoexceptExpr(SourceLocation KeyLoc, Expr *Operand,
5506
                                  SourceLocation RParen);
5507
5508
  /// Parsed one of the type trait support pseudo-functions.
5509
  ExprResult ActOnTypeTrait(TypeTrait Kind, SourceLocation KWLoc,
5510
                            ArrayRef<ParsedType> Args,
5511
                            SourceLocation RParenLoc);
5512
  ExprResult BuildTypeTrait(TypeTrait Kind, SourceLocation KWLoc,
5513
                            ArrayRef<TypeSourceInfo *> Args,
5514
                            SourceLocation RParenLoc);
5515
5516
  /// ActOnArrayTypeTrait - Parsed one of the binary type trait support
5517
  /// pseudo-functions.
5518
  ExprResult ActOnArrayTypeTrait(ArrayTypeTrait ATT,
5519
                                 SourceLocation KWLoc,
5520
                                 ParsedType LhsTy,
5521
                                 Expr *DimExpr,
5522
                                 SourceLocation RParen);
5523
5524
  ExprResult BuildArrayTypeTrait(ArrayTypeTrait ATT,
5525
                                 SourceLocation KWLoc,
5526
                                 TypeSourceInfo *TSInfo,
5527
                                 Expr *DimExpr,
5528
                                 SourceLocation RParen);
5529
5530
  /// ActOnExpressionTrait - Parsed one of the unary type trait support
5531
  /// pseudo-functions.
5532
  ExprResult ActOnExpressionTrait(ExpressionTrait OET,
5533
                                  SourceLocation KWLoc,
5534
                                  Expr *Queried,
5535
                                  SourceLocation RParen);
5536
5537
  ExprResult BuildExpressionTrait(ExpressionTrait OET,
5538
                                  SourceLocation KWLoc,
5539
                                  Expr *Queried,
5540
                                  SourceLocation RParen);
5541
5542
  ExprResult ActOnStartCXXMemberReference(Scope *S,
5543
                                          Expr *Base,
5544
                                          SourceLocation OpLoc,
5545
                                          tok::TokenKind OpKind,
5546
                                          ParsedType &ObjectType,
5547
                                          bool &MayBePseudoDestructor);
5548
5549
  ExprResult BuildPseudoDestructorExpr(Expr *Base,
5550
                                       SourceLocation OpLoc,
5551
                                       tok::TokenKind OpKind,
5552
                                       const CXXScopeSpec &SS,
5553
                                       TypeSourceInfo *ScopeType,
5554
                                       SourceLocation CCLoc,
5555
                                       SourceLocation TildeLoc,
5556
                                     PseudoDestructorTypeStorage DestroyedType);
5557
5558
  ExprResult ActOnPseudoDestructorExpr(Scope *S, Expr *Base,
5559
                                       SourceLocation OpLoc,
5560
                                       tok::TokenKind OpKind,
5561
                                       CXXScopeSpec &SS,
5562
                                       UnqualifiedId &FirstTypeName,
5563
                                       SourceLocation CCLoc,
5564
                                       SourceLocation TildeLoc,
5565
                                       UnqualifiedId &SecondTypeName);
5566
5567
  ExprResult ActOnPseudoDestructorExpr(Scope *S, Expr *Base,
5568
                                       SourceLocation OpLoc,
5569
                                       tok::TokenKind OpKind,
5570
                                       SourceLocation TildeLoc,
5571
                                       const DeclSpec& DS);
5572
5573
  /// MaybeCreateExprWithCleanups - If the current full-expression
5574
  /// requires any cleanups, surround it with a ExprWithCleanups node.
5575
  /// Otherwise, just returns the passed-in expression.
5576
  Expr *MaybeCreateExprWithCleanups(Expr *SubExpr);
5577
  Stmt *MaybeCreateStmtWithCleanups(Stmt *SubStmt);
5578
  ExprResult MaybeCreateExprWithCleanups(ExprResult SubExpr);
5579
5580
  MaterializeTemporaryExpr *
5581
  CreateMaterializeTemporaryExpr(QualType T, Expr *Temporary,
5582
                                 bool BoundToLvalueReference);
5583
5584
415k
  ExprResult ActOnFinishFullExpr(Expr *Expr, bool DiscardedValue) {
5585
415k
    return ActOnFinishFullExpr(
5586
415k
        Expr, Expr ? 
Expr->getExprLoc()361k
:
SourceLocation()53.3k
, DiscardedValue);
5587
415k
  }
5588
  ExprResult ActOnFinishFullExpr(Expr *Expr, SourceLocation CC,
5589
                                 bool DiscardedValue, bool IsConstexpr = false);
5590
  StmtResult ActOnFinishFullStmt(Stmt *Stmt);
5591
5592
  // Marks SS invalid if it represents an incomplete type.
5593
  bool RequireCompleteDeclContext(CXXScopeSpec &SS, DeclContext *DC);
5594
5595
  DeclContext *computeDeclContext(QualType T);
5596
  DeclContext *computeDeclContext(const CXXScopeSpec &SS,
5597
                                  bool EnteringContext = false);
5598
  bool isDependentScopeSpecifier(const CXXScopeSpec &SS);
5599
  CXXRecordDecl *getCurrentInstantiationOf(NestedNameSpecifier *NNS);
5600
5601
  /// The parser has parsed a global nested-name-specifier '::'.
5602
  ///
5603
  /// \param CCLoc The location of the '::'.
5604
  ///
5605
  /// \param SS The nested-name-specifier, which will be updated in-place
5606
  /// to reflect the parsed nested-name-specifier.
5607
  ///
5608
  /// \returns true if an error occurred, false otherwise.
5609
  bool ActOnCXXGlobalScopeSpecifier(SourceLocation CCLoc, CXXScopeSpec &SS);
5610
5611
  /// The parser has parsed a '__super' nested-name-specifier.
5612
  ///
5613
  /// \param SuperLoc The location of the '__super' keyword.
5614
  ///
5615
  /// \param ColonColonLoc The location of the '::'.
5616
  ///
5617
  /// \param SS The nested-name-specifier, which will be updated in-place
5618
  /// to reflect the parsed nested-name-specifier.
5619
  ///
5620
  /// \returns true if an error occurred, false otherwise.
5621
  bool ActOnSuperScopeSpecifier(SourceLocation SuperLoc,
5622
                                SourceLocation ColonColonLoc, CXXScopeSpec &SS);
5623
5624
  bool isAcceptableNestedNameSpecifier(const NamedDecl *SD,
5625
                                       bool *CanCorrect = nullptr);
5626
  NamedDecl *FindFirstQualifierInScope(Scope *S, NestedNameSpecifier *NNS);
5627
5628
  /// Keeps information about an identifier in a nested-name-spec.
5629
  ///
5630
  struct NestedNameSpecInfo {
5631
    /// The type of the object, if we're parsing nested-name-specifier in
5632
    /// a member access expression.
5633
    ParsedType ObjectType;
5634
5635
    /// The identifier preceding the '::'.
5636
    IdentifierInfo *Identifier;
5637
5638
    /// The location of the identifier.
5639
    SourceLocation IdentifierLoc;
5640
5641
    /// The location of the '::'.
5642
    SourceLocation CCLoc;
5643
5644
    /// Creates info object for the most typical case.
5645
    NestedNameSpecInfo(IdentifierInfo *II, SourceLocation IdLoc,
5646
             SourceLocation ColonColonLoc, ParsedType ObjectType = ParsedType())
5647
      : ObjectType(ObjectType), Identifier(II), IdentifierLoc(IdLoc),
5648
41.1M
        CCLoc(ColonColonLoc) {
5649
41.1M
    }
5650
5651
    NestedNameSpecInfo(IdentifierInfo *II, SourceLocation IdLoc,
5652
                       SourceLocation ColonColonLoc, QualType ObjectType)
5653
      : ObjectType(ParsedType::make(ObjectType)), Identifier(II),
5654
6.04k
        IdentifierLoc(IdLoc), CCLoc(ColonColonLoc) {
5655
6.04k
    }
5656
  };
5657
5658
  bool isNonTypeNestedNameSpecifier(Scope *S, CXXScopeSpec &SS,
5659
                                    NestedNameSpecInfo &IdInfo);
5660
5661
  bool BuildCXXNestedNameSpecifier(Scope *S,
5662
                                   NestedNameSpecInfo &IdInfo,
5663
                                   bool EnteringContext,
5664
                                   CXXScopeSpec &SS,
5665
                                   NamedDecl *ScopeLookupResult,
5666
                                   bool ErrorRecoveryLookup,
5667
                                   bool *IsCorrectedToColon = nullptr,
5668
                                   bool OnlyNamespace = false);
5669
5670
  /// The parser has parsed a nested-name-specifier 'identifier::'.
5671
  ///
5672
  /// \param S The scope in which this nested-name-specifier occurs.
5673
  ///
5674
  /// \param IdInfo Parser information about an identifier in the
5675
  /// nested-name-spec.
5676
  ///
5677
  /// \param EnteringContext Whether we're entering the context nominated by
5678
  /// this nested-name-specifier.
5679
  ///
5680
  /// \param SS The nested-name-specifier, which is both an input
5681
  /// parameter (the nested-name-specifier before this type) and an
5682
  /// output parameter (containing the full nested-name-specifier,
5683
  /// including this new type).
5684
  ///
5685
  /// \param ErrorRecoveryLookup If true, then this method is called to improve
5686
  /// error recovery. In this case do not emit error message.
5687
  ///
5688
  /// \param IsCorrectedToColon If not null, suggestions to replace '::' -> ':'
5689
  /// are allowed.  The bool value pointed by this parameter is set to 'true'
5690
  /// if the identifier is treated as if it was followed by ':', not '::'.
5691
  ///
5692
  /// \param OnlyNamespace If true, only considers namespaces in lookup.
5693
  ///
5694
  /// \returns true if an error occurred, false otherwise.
5695
  bool ActOnCXXNestedNameSpecifier(Scope *S,
5696
                                   NestedNameSpecInfo &IdInfo,
5697
                                   bool EnteringContext,
5698
                                   CXXScopeSpec &SS,
5699
                                   bool ErrorRecoveryLookup = false,
5700
                                   bool *IsCorrectedToColon = nullptr,
5701
                                   bool OnlyNamespace = false);
5702
5703
  ExprResult ActOnDecltypeExpression(Expr *E);
5704
5705
  bool ActOnCXXNestedNameSpecifierDecltype(CXXScopeSpec &SS,
5706
                                           const DeclSpec &DS,
5707
                                           SourceLocation ColonColonLoc);
5708
5709
  bool IsInvalidUnlessNestedName(Scope *S, CXXScopeSpec &SS,
5710
                                 NestedNameSpecInfo &IdInfo,
5711
                                 bool EnteringContext);
5712
5713
  /// The parser has parsed a nested-name-specifier
5714
  /// 'template[opt] template-name < template-args >::'.
5715
  ///
5716
  /// \param S The scope in which this nested-name-specifier occurs.
5717
  ///
5718
  /// \param SS The nested-name-specifier, which is both an input
5719
  /// parameter (the nested-name-specifier before this type) and an
5720
  /// output parameter (containing the full nested-name-specifier,
5721
  /// including this new type).
5722
  ///
5723
  /// \param TemplateKWLoc the location of the 'template' keyword, if any.
5724
  /// \param TemplateName the template name.
5725
  /// \param TemplateNameLoc The location of the template name.
5726
  /// \param LAngleLoc The location of the opening angle bracket  ('<').
5727
  /// \param TemplateArgs The template arguments.
5728
  /// \param RAngleLoc The location of the closing angle bracket  ('>').
5729
  /// \param CCLoc The location of the '::'.
5730
  ///
5731
  /// \param EnteringContext Whether we're entering the context of the
5732
  /// nested-name-specifier.
5733
  ///
5734
  ///
5735
  /// \returns true if an error occurred, false otherwise.
5736
  bool ActOnCXXNestedNameSpecifier(Scope *S,
5737
                                   CXXScopeSpec &SS,
5738
                                   SourceLocation TemplateKWLoc,
5739
                                   TemplateTy TemplateName,
5740
                                   SourceLocation TemplateNameLoc,
5741
                                   SourceLocation LAngleLoc,
5742
                                   ASTTemplateArgsPtr TemplateArgs,
5743
                                   SourceLocation RAngleLoc,
5744
                                   SourceLocation CCLoc,
5745
                                   bool EnteringContext);
5746
5747
  /// Given a C++ nested-name-specifier, produce an annotation value
5748
  /// that the parser can use later to reconstruct the given
5749
  /// nested-name-specifier.
5750
  ///
5751
  /// \param SS A nested-name-specifier.
5752
  ///
5753
  /// \returns A pointer containing all of the information in the
5754
  /// nested-name-specifier \p SS.
5755
  void *SaveNestedNameSpecifierAnnotation(CXXScopeSpec &SS);
5756
5757
  /// Given an annotation pointer for a nested-name-specifier, restore
5758
  /// the nested-name-specifier structure.
5759
  ///
5760
  /// \param Annotation The annotation pointer, produced by
5761
  /// \c SaveNestedNameSpecifierAnnotation().
5762
  ///
5763
  /// \param AnnotationRange The source range corresponding to the annotation.
5764
  ///
5765
  /// \param SS The nested-name-specifier that will be updated with the contents
5766
  /// of the annotation pointer.
5767
  void RestoreNestedNameSpecifierAnnotation(void *Annotation,
5768
                                            SourceRange AnnotationRange,
5769
                                            CXXScopeSpec &SS);
5770
5771
  bool ShouldEnterDeclaratorScope(Scope *S, const CXXScopeSpec &SS);
5772
5773
  /// ActOnCXXEnterDeclaratorScope - Called when a C++ scope specifier (global
5774
  /// scope or nested-name-specifier) is parsed, part of a declarator-id.
5775
  /// After this method is called, according to [C++ 3.4.3p3], names should be
5776
  /// looked up in the declarator-id's scope, until the declarator is parsed and
5777
  /// ActOnCXXExitDeclaratorScope is called.
5778
  /// The 'SS' should be a non-empty valid CXXScopeSpec.
5779
  bool ActOnCXXEnterDeclaratorScope(Scope *S, CXXScopeSpec &SS);
5780
5781
  /// ActOnCXXExitDeclaratorScope - Called when a declarator that previously
5782
  /// invoked ActOnCXXEnterDeclaratorScope(), is finished. 'SS' is the same
5783
  /// CXXScopeSpec that was passed to ActOnCXXEnterDeclaratorScope as well.
5784
  /// Used to indicate that names should revert to being looked up in the
5785
  /// defining scope.
5786
  void ActOnCXXExitDeclaratorScope(Scope *S, const CXXScopeSpec &SS);
5787
5788
  /// ActOnCXXEnterDeclInitializer - Invoked when we are about to parse an
5789
  /// initializer for the declaration 'Dcl'.
5790
  /// After this method is called, according to [C++ 3.4.1p13], if 'Dcl' is a
5791
  /// static data member of class X, names should be looked up in the scope of
5792
  /// class X.
5793
  void ActOnCXXEnterDeclInitializer(Scope *S, Decl *Dcl);
5794
5795
  /// ActOnCXXExitDeclInitializer - Invoked after we are finished parsing an
5796
  /// initializer for the declaration 'Dcl'.
5797
  void ActOnCXXExitDeclInitializer(Scope *S, Decl *Dcl);
5798
5799
  /// Create a new lambda closure type.
5800
  CXXRecordDecl *createLambdaClosureType(SourceRange IntroducerRange,
5801
                                         TypeSourceInfo *Info,
5802
                                         bool KnownDependent,
5803
                                         LambdaCaptureDefault CaptureDefault);
5804
5805
  /// Start the definition of a lambda expression.
5806
  CXXMethodDecl *
5807
  startLambdaDefinition(CXXRecordDecl *Class, SourceRange IntroducerRange,
5808
                        TypeSourceInfo *MethodType, SourceLocation EndLoc,
5809
                        ArrayRef<ParmVarDecl *> Params,
5810
                        ConstexprSpecKind ConstexprKind,
5811
                        Optional<std::pair<unsigned, Decl *>> Mangling = None);
5812
5813
  /// Endow the lambda scope info with the relevant properties.
5814
  void buildLambdaScope(sema::LambdaScopeInfo *LSI,
5815
                        CXXMethodDecl *CallOperator,
5816
                        SourceRange IntroducerRange,
5817
                        LambdaCaptureDefault CaptureDefault,
5818
                        SourceLocation CaptureDefaultLoc,
5819
                        bool ExplicitParams,
5820
                        bool ExplicitResultType,
5821
                        bool Mutable);
5822
5823
  /// Perform initialization analysis of the init-capture and perform
5824
  /// any implicit conversions such as an lvalue-to-rvalue conversion if
5825
  /// not being used to initialize a reference.
5826
  ParsedType actOnLambdaInitCaptureInitialization(
5827
      SourceLocation Loc, bool ByRef, SourceLocation EllipsisLoc,
5828
324
      IdentifierInfo *Id, LambdaCaptureInitKind InitKind, Expr *&Init) {
5829
324
    return ParsedType::make(buildLambdaInitCaptureInitialization(
5830
324
        Loc, ByRef, EllipsisLoc, None, Id,
5831
324
        InitKind != LambdaCaptureInitKind::CopyInit, Init));
5832
324
  }
5833
  QualType buildLambdaInitCaptureInitialization(
5834
      SourceLocation Loc, bool ByRef, SourceLocation EllipsisLoc,
5835
      Optional<unsigned> NumExpansions, IdentifierInfo *Id, bool DirectInit,
5836
      Expr *&Init);
5837
5838
  /// Create a dummy variable within the declcontext of the lambda's
5839
  ///  call operator, for name lookup purposes for a lambda init capture.
5840
  ///
5841
  ///  CodeGen handles emission of lambda captures, ignoring these dummy
5842
  ///  variables appropriately.
5843
  VarDecl *createLambdaInitCaptureVarDecl(SourceLocation Loc,
5844
                                          QualType InitCaptureType,
5845
                                          SourceLocation EllipsisLoc,
5846
                                          IdentifierInfo *Id,
5847
                                          unsigned InitStyle, Expr *Init);
5848
5849
  /// Add an init-capture to a lambda scope.
5850
  void addInitCapture(sema::LambdaScopeInfo *LSI, VarDecl *Var);
5851
5852
  /// Note that we have finished the explicit captures for the
5853
  /// given lambda.
5854
  void finishLambdaExplicitCaptures(sema::LambdaScopeInfo *LSI);
5855
5856
  /// \brief This is called after parsing the explicit template parameter list
5857
  /// on a lambda (if it exists) in C++2a.
5858
  void ActOnLambdaExplicitTemplateParameterList(SourceLocation LAngleLoc,
5859
                                                ArrayRef<NamedDecl *> TParams,
5860
                                                SourceLocation RAngleLoc);
5861
5862
  /// Introduce the lambda parameters into scope.
5863
  void addLambdaParameters(
5864
      ArrayRef<LambdaIntroducer::LambdaCapture> Captures,
5865
      CXXMethodDecl *CallOperator, Scope *CurScope);
5866
5867
  /// Deduce a block or lambda's return type based on the return
5868
  /// statements present in the body.
5869
  void deduceClosureReturnType(sema::CapturingScopeInfo &CSI);
5870
5871
  /// ActOnStartOfLambdaDefinition - This is called just before we start
5872
  /// parsing the body of a lambda; it analyzes the explicit captures and
5873
  /// arguments, and sets up various data-structures for the body of the
5874
  /// lambda.
5875
  void ActOnStartOfLambdaDefinition(LambdaIntroducer &Intro,
5876
                                    Declarator &ParamInfo, Scope *CurScope);
5877
5878
  /// ActOnLambdaError - If there is an error parsing a lambda, this callback
5879
  /// is invoked to pop the information about the lambda.
5880
  void ActOnLambdaError(SourceLocation StartLoc, Scope *CurScope,
5881
                        bool IsInstantiation = false);
5882
5883
  /// ActOnLambdaExpr - This is called when the body of a lambda expression
5884
  /// was successfully completed.
5885
  ExprResult ActOnLambdaExpr(SourceLocation StartLoc, Stmt *Body,
5886
                             Scope *CurScope);
5887
5888
  /// Does copying/destroying the captured variable have side effects?
5889
  bool CaptureHasSideEffects(const sema::Capture &From);
5890
5891
  /// Diagnose if an explicit lambda capture is unused. Returns true if a
5892
  /// diagnostic is emitted.
5893
  bool DiagnoseUnusedLambdaCapture(SourceRange CaptureRange,
5894
                                   const sema::Capture &From);
5895
5896
  /// Build a FieldDecl suitable to hold the given capture.
5897
  FieldDecl *BuildCaptureField(RecordDecl *RD, const sema::Capture &Capture);
5898
5899
  /// Initialize the given capture with a suitable expression.
5900
  ExprResult BuildCaptureInit(const sema::Capture &Capture,
5901
                              SourceLocation ImplicitCaptureLoc,
5902
                              bool IsOpenMPMapping = false);
5903
5904
  /// Complete a lambda-expression having processed and attached the
5905
  /// lambda body.
5906
  ExprResult BuildLambdaExpr(SourceLocation StartLoc, SourceLocation EndLoc,
5907
                             sema::LambdaScopeInfo *LSI);
5908
5909
  /// Get the return type to use for a lambda's conversion function(s) to
5910
  /// function pointer type, given the type of the call operator.
5911
  QualType
5912
  getLambdaConversionFunctionResultType(const FunctionProtoType *CallOpType);
5913
5914
  /// Define the "body" of the conversion from a lambda object to a
5915
  /// function pointer.
5916
  ///
5917
  /// This routine doesn't actually define a sensible body; rather, it fills
5918
  /// in the initialization expression needed to copy the lambda object into
5919
  /// the block, and IR generation actually generates the real body of the
5920
  /// block pointer conversion.
5921
  void DefineImplicitLambdaToFunctionPointerConversion(
5922
         SourceLocation CurrentLoc, CXXConversionDecl *Conv);
5923
5924
  /// Define the "body" of the conversion from a lambda object to a
5925
  /// block pointer.
5926
  ///
5927
  /// This routine doesn't actually define a sensible body; rather, it fills
5928
  /// in the initialization expression needed to copy the lambda object into
5929
  /// the block, and IR generation actually generates the real body of the
5930
  /// block pointer conversion.
5931
  void DefineImplicitLambdaToBlockPointerConversion(SourceLocation CurrentLoc,
5932
                                                    CXXConversionDecl *Conv);
5933
5934
  ExprResult BuildBlockForLambdaConversion(SourceLocation CurrentLocation,
5935
                                           SourceLocation ConvLocation,
5936
                                           CXXConversionDecl *Conv,
5937
                                           Expr *Src);
5938
5939
  // ParseObjCStringLiteral - Parse Objective-C string literals.
5940
  ExprResult ParseObjCStringLiteral(SourceLocation *AtLocs,
5941
                                    ArrayRef<Expr *> Strings);
5942
5943
  ExprResult BuildObjCStringLiteral(SourceLocation AtLoc, StringLiteral *S);
5944
5945
  /// BuildObjCNumericLiteral - builds an ObjCBoxedExpr AST node for the
5946
  /// numeric literal expression. Type of the expression will be "NSNumber *"
5947
  /// or "id" if NSNumber is unavailable.
5948
  ExprResult BuildObjCNumericLiteral(SourceLocation AtLoc, Expr *Number);
5949
  ExprResult ActOnObjCBoolLiteral(SourceLocation AtLoc, SourceLocation ValueLoc,
5950
                                  bool Value);
5951
  ExprResult BuildObjCArrayLiteral(SourceRange SR, MultiExprArg Elements);
5952
5953
  /// BuildObjCBoxedExpr - builds an ObjCBoxedExpr AST node for the
5954
  /// '@' prefixed parenthesized expression. The type of the expression will
5955
  /// either be "NSNumber *", "NSString *" or "NSValue *" depending on the type
5956
  /// of ValueType, which is allowed to be a built-in numeric type, "char *",
5957
  /// "const char *" or C structure with attribute 'objc_boxable'.
5958
  ExprResult BuildObjCBoxedExpr(SourceRange SR, Expr *ValueExpr);
5959
5960
  ExprResult BuildObjCSubscriptExpression(SourceLocation RB, Expr *BaseExpr,
5961
                                          Expr *IndexExpr,
5962
                                          ObjCMethodDecl *getterMethod,
5963
                                          ObjCMethodDecl *setterMethod);
5964
5965
  ExprResult BuildObjCDictionaryLiteral(SourceRange SR,
5966
                               MutableArrayRef<ObjCDictionaryElement> Elements);
5967
5968
  ExprResult BuildObjCEncodeExpression(SourceLocation AtLoc,
5969
                                  TypeSourceInfo *EncodedTypeInfo,
5970
                                  SourceLocation RParenLoc);
5971
  ExprResult BuildCXXMemberCallExpr(Expr *Exp, NamedDecl *FoundDecl,
5972
                                    CXXConversionDecl *Method,
5973
                                    bool HadMultipleCandidates);
5974
5975
  ExprResult ParseObjCEncodeExpression(SourceLocation AtLoc,
5976
                                       SourceLocation EncodeLoc,
5977
                                       SourceLocation LParenLoc,
5978
                                       ParsedType Ty,
5979
                                       SourceLocation RParenLoc);
5980
5981
  /// ParseObjCSelectorExpression - Build selector expression for \@selector
5982
  ExprResult ParseObjCSelectorExpression(Selector Sel,
5983
                                         SourceLocation AtLoc,
5984
                                         SourceLocation SelLoc,
5985
                                         SourceLocation LParenLoc,
5986
                                         SourceLocation RParenLoc,
5987
                                         bool WarnMultipleSelectors);
5988
5989
  /// ParseObjCProtocolExpression - Build protocol expression for \@protocol
5990
  ExprResult ParseObjCProtocolExpression(IdentifierInfo * ProtocolName,
5991
                                         SourceLocation AtLoc,
5992
                                         SourceLocation ProtoLoc,
5993
                                         SourceLocation LParenLoc,
5994
                                         SourceLocation ProtoIdLoc,
5995
                                         SourceLocation RParenLoc);
5996
5997
  //===--------------------------------------------------------------------===//
5998
  // C++ Declarations
5999
  //
6000
  Decl *ActOnStartLinkageSpecification(Scope *S,
6001
                                       SourceLocation ExternLoc,
6002
                                       Expr *LangStr,
6003
                                       SourceLocation LBraceLoc);
6004
  Decl *ActOnFinishLinkageSpecification(Scope *S,
6005
                                        Decl *LinkageSpec,
6006
                                        SourceLocation RBraceLoc);
6007
6008
6009
  //===--------------------------------------------------------------------===//
6010
  // C++ Classes
6011
  //
6012
  CXXRecordDecl *getCurrentClass(Scope *S, const CXXScopeSpec *SS);
6013
  bool isCurrentClassName(const IdentifierInfo &II, Scope *S,
6014
                          const CXXScopeSpec *SS = nullptr);
6015
  bool isCurrentClassNameTypo(IdentifierInfo *&II, const CXXScopeSpec *SS);
6016
6017
  bool ActOnAccessSpecifier(AccessSpecifier Access, SourceLocation ASLoc,
6018
                            SourceLocation ColonLoc,
6019
                            const ParsedAttributesView &Attrs);
6020
6021
  NamedDecl *ActOnCXXMemberDeclarator(Scope *S, AccessSpecifier AS,
6022
                                 Declarator &D,
6023
                                 MultiTemplateParamsArg TemplateParameterLists,
6024
                                 Expr *BitfieldWidth, const VirtSpecifiers &VS,
6025
                                 InClassInitStyle InitStyle);
6026
6027
  void ActOnStartCXXInClassMemberInitializer();
6028
  void ActOnFinishCXXInClassMemberInitializer(Decl *VarDecl,
6029
                                              SourceLocation EqualLoc,
6030
                                              Expr *Init);
6031
6032
  MemInitResult ActOnMemInitializer(Decl *ConstructorD,
6033
                                    Scope *S,
6034
                                    CXXScopeSpec &SS,
6035
                                    IdentifierInfo *MemberOrBase,
6036
                                    ParsedType TemplateTypeTy,
6037
                                    const DeclSpec &DS,
6038
                                    SourceLocation IdLoc,
6039
                                    SourceLocation LParenLoc,
6040
                                    ArrayRef<Expr *> Args,
6041
                                    SourceLocation RParenLoc,
6042
                                    SourceLocation EllipsisLoc);
6043
6044
  MemInitResult ActOnMemInitializer(Decl *ConstructorD,
6045
                                    Scope *S,
6046
                                    CXXScopeSpec &SS,
6047
                                    IdentifierInfo *MemberOrBase,
6048
                                    ParsedType TemplateTypeTy,
6049
                                    const DeclSpec &DS,
6050
                                    SourceLocation IdLoc,
6051
                                    Expr *InitList,
6052
                                    SourceLocation EllipsisLoc);
6053
6054
  MemInitResult BuildMemInitializer(Decl *ConstructorD,
6055
                                    Scope *S,
6056
                                    CXXScopeSpec &SS,
6057
                                    IdentifierInfo *MemberOrBase,
6058
                                    ParsedType TemplateTypeTy,
6059
                                    const DeclSpec &DS,
6060
                                    SourceLocation IdLoc,
6061
                                    Expr *Init,
6062
                                    SourceLocation EllipsisLoc);
6063
6064
  MemInitResult BuildMemberInitializer(ValueDecl *Member,
6065
                                       Expr *Init,
6066
                                       SourceLocation IdLoc);
6067
6068
  MemInitResult BuildBaseInitializer(QualType BaseType,
6069
                                     TypeSourceInfo *BaseTInfo,
6070
                                     Expr *Init,
6071
                                     CXXRecordDecl *ClassDecl,
6072
                                     SourceLocation EllipsisLoc);
6073
6074
  MemInitResult BuildDelegatingInitializer(TypeSourceInfo *TInfo,
6075
                                           Expr *Init,
6076
                                           CXXRecordDecl *ClassDecl);
6077
6078
  bool SetDelegatingInitializer(CXXConstructorDecl *Constructor,
6079
                                CXXCtorInitializer *Initializer);
6080
6081
  bool SetCtorInitializers(CXXConstructorDecl *Constructor, bool AnyErrors,
6082
                           ArrayRef<CXXCtorInitializer *> Initializers = None);
6083
6084
  void SetIvarInitializers(ObjCImplementationDecl *ObjCImplementation);
6085
6086
6087
  /// MarkBaseAndMemberDestructorsReferenced - Given a record decl,
6088
  /// mark all the non-trivial destructors of its members and bases as
6089
  /// referenced.
6090
  void MarkBaseAndMemberDestructorsReferenced(SourceLocation Loc,
6091
                                              CXXRecordDecl *Record);
6092
6093
  /// The list of classes whose vtables have been used within
6094
  /// this translation unit, and the source locations at which the
6095
  /// first use occurred.
6096
  typedef std::pair<CXXRecordDecl*, SourceLocation> VTableUse;
6097
6098
  /// The list of vtables that are required but have not yet been
6099
  /// materialized.
6100
  SmallVector<VTableUse, 16> VTableUses;
6101
6102
  /// The set of classes whose vtables have been used within
6103
  /// this translation unit, and a bit that will be true if the vtable is
6104
  /// required to be emitted (otherwise, it should be emitted only if needed
6105
  /// by code generation).
6106
  llvm::DenseMap<CXXRecordDecl *, bool> VTablesUsed;
6107
6108
  /// Load any externally-stored vtable uses.
6109
  void LoadExternalVTableUses();
6110
6111
  /// Note that the vtable for the given class was used at the
6112
  /// given location.
6113
  void MarkVTableUsed(SourceLocation Loc, CXXRecordDecl *Class,
6114
                      bool DefinitionRequired = false);
6115
6116
  /// Mark the exception specifications of all virtual member functions
6117
  /// in the given class as needed.
6118
  void MarkVirtualMemberExceptionSpecsNeeded(SourceLocation Loc,
6119
                                             const CXXRecordDecl *RD);
6120
6121
  /// MarkVirtualMembersReferenced - Will mark all members of the given
6122
  /// CXXRecordDecl referenced.
6123
  void MarkVirtualMembersReferenced(SourceLocation Loc, const CXXRecordDecl *RD,
6124
                                    bool ConstexprOnly = false);
6125
6126
  /// Define all of the vtables that have been used in this
6127
  /// translation unit and reference any virtual members used by those
6128
  /// vtables.
6129
  ///
6130
  /// \returns true if any work was done, false otherwise.
6131
  bool DefineUsedVTables();
6132
6133
  void AddImplicitlyDeclaredMembersToClass(CXXRecordDecl *ClassDecl);
6134
6135
  void ActOnMemInitializers(Decl *ConstructorDecl,
6136
                            SourceLocation ColonLoc,
6137
                            ArrayRef<CXXCtorInitializer*> MemInits,
6138
                            bool AnyErrors);
6139
6140
  /// Check class-level dllimport/dllexport attribute. The caller must
6141
  /// ensure that referenceDLLExportedClassMethods is called some point later
6142
  /// when all outer classes of Class are complete.
6143
  void checkClassLevelDLLAttribute(CXXRecordDecl *Class);
6144
  void checkClassLevelCodeSegAttribute(CXXRecordDecl *Class);
6145
6146
  void referenceDLLExportedClassMethods();
6147
6148
  void propagateDLLAttrToBaseClassTemplate(
6149
      CXXRecordDecl *Class, Attr *ClassAttr,
6150
      ClassTemplateSpecializationDecl *BaseTemplateSpec,
6151
      SourceLocation BaseLoc);
6152
6153
  void CheckCompletedCXXClass(CXXRecordDecl *Record);
6154
6155
  /// Check that the C++ class annoated with "trivial_abi" satisfies all the
6156
  /// conditions that are needed for the attribute to have an effect.
6157
  void checkIllFormedTrivialABIStruct(CXXRecordDecl &RD);
6158
6159
  void ActOnFinishCXXMemberSpecification(Scope *S, SourceLocation RLoc,
6160
                                         Decl *TagDecl, SourceLocation LBrac,
6161
                                         SourceLocation RBrac,
6162
                                         const ParsedAttributesView &AttrList);
6163
  void ActOnFinishCXXMemberDecls();
6164
  void ActOnFinishCXXNonNestedClass(Decl *D);
6165
6166
  void ActOnReenterCXXMethodParameter(Scope *S, ParmVarDecl *Param);
6167
  unsigned ActOnReenterTemplateScope(Scope *S, Decl *Template);
6168
  void ActOnStartDelayedMemberDeclarations(Scope *S, Decl *Record);
6169
  void ActOnStartDelayedCXXMethodDeclaration(Scope *S, Decl *Method);
6170
  void ActOnDelayedCXXMethodParameter(Scope *S, Decl *Param);
6171
  void ActOnFinishDelayedMemberDeclarations(Scope *S, Decl *Record);
6172
  void ActOnFinishDelayedCXXMethodDeclaration(Scope *S, Decl *Method);
6173
  void ActOnFinishDelayedMemberInitializers(Decl *Record);
6174
  void MarkAsLateParsedTemplate(FunctionDecl *FD, Decl *FnD,
6175
                                CachedTokens &Toks);
6176
  void UnmarkAsLateParsedTemplate(FunctionDecl *FD);
6177
  bool IsInsideALocalClassWithinATemplateFunction();
6178
6179
  Decl *ActOnStaticAssertDeclaration(SourceLocation StaticAssertLoc,
6180
                                     Expr *AssertExpr,
6181
                                     Expr *AssertMessageExpr,
6182
                                     SourceLocation RParenLoc);
6183
  Decl *BuildStaticAssertDeclaration(SourceLocation StaticAssertLoc,
6184
                                     Expr *AssertExpr,
6185
                                     StringLiteral *AssertMessageExpr,
6186
                                     SourceLocation RParenLoc,
6187
                                     bool Failed);
6188
6189
  FriendDecl *CheckFriendTypeDecl(SourceLocation LocStart,
6190
                                  SourceLocation FriendLoc,
6191
                                  TypeSourceInfo *TSInfo);
6192
  Decl *ActOnFriendTypeDecl(Scope *S, const DeclSpec &DS,
6193
                            MultiTemplateParamsArg TemplateParams);
6194
  NamedDecl *ActOnFriendFunctionDecl(Scope *S, Declarator &D,
6195
                                     MultiTemplateParamsArg TemplateParams);
6196
6197
  QualType CheckConstructorDeclarator(Declarator &D, QualType R,
6198
                                      StorageClass& SC);
6199
  void CheckConstructor(CXXConstructorDecl *Constructor);
6200
  QualType CheckDestructorDeclarator(Declarator &D, QualType R,
6201
                                     StorageClass& SC);
6202
  bool CheckDestructor(CXXDestructorDecl *Destructor);
6203
  void CheckConversionDeclarator(Declarator &D, QualType &R,
6204
                                 StorageClass& SC);
6205
  Decl *ActOnConversionDeclarator(CXXConversionDecl *Conversion);
6206
  void CheckDeductionGuideDeclarator(Declarator &D, QualType &R,
6207
                                     StorageClass &SC);
6208
  void CheckDeductionGuideTemplate(FunctionTemplateDecl *TD);
6209
6210
  void CheckExplicitlyDefaultedSpecialMember(CXXMethodDecl *MD);
6211
  void CheckDelayedMemberExceptionSpecs();
6212
6213
  //===--------------------------------------------------------------------===//
6214
  // C++ Derived Classes
6215
  //
6216
6217
  /// ActOnBaseSpecifier - Parsed a base specifier
6218
  CXXBaseSpecifier *CheckBaseSpecifier(CXXRecordDecl *Class,
6219
                                       SourceRange SpecifierRange,
6220
                                       bool Virtual, AccessSpecifier Access,
6221
                                       TypeSourceInfo *TInfo,
6222
                                       SourceLocation EllipsisLoc);
6223
6224
  BaseResult ActOnBaseSpecifier(Decl *classdecl,
6225
                                SourceRange SpecifierRange,
6226
                                ParsedAttributes &Attrs,
6227
                                bool Virtual, AccessSpecifier Access,
6228
                                ParsedType basetype,
6229
                                SourceLocation BaseLoc,
6230
                                SourceLocation EllipsisLoc);
6231
6232
  bool AttachBaseSpecifiers(CXXRecordDecl *Class,
6233
                            MutableArrayRef<CXXBaseSpecifier *> Bases);
6234
  void ActOnBaseSpecifiers(Decl *ClassDecl,
6235
                           MutableArrayRef<CXXBaseSpecifier *> Bases);
6236
6237
  bool IsDerivedFrom(SourceLocation Loc, QualType Derived, QualType Base);
6238
  bool IsDerivedFrom(SourceLocation Loc, QualType Derived, QualType Base,
6239
                     CXXBasePaths &Paths);
6240
6241
  // FIXME: I don't like this name.
6242
  void BuildBasePathArray(const CXXBasePaths &Paths, CXXCastPath &BasePath);
6243
6244
  bool CheckDerivedToBaseConversion(QualType Derived, QualType Base,
6245
                                    SourceLocation Loc, SourceRange Range,
6246
                                    CXXCastPath *BasePath = nullptr,
6247
                                    bool IgnoreAccess = false);
6248
  bool CheckDerivedToBaseConversion(QualType Derived, QualType Base,
6249
                                    unsigned InaccessibleBaseID,
6250
                                    unsigned AmbigiousBaseConvID,
6251
                                    SourceLocation Loc, SourceRange Range,
6252
                                    DeclarationName Name,
6253
                                    CXXCastPath *BasePath,
6254
                                    bool IgnoreAccess = false);
6255
6256
  std::string getAmbiguousPathsDisplayString(CXXBasePaths &Paths);
6257
6258
  bool CheckOverridingFunctionAttributes(const CXXMethodDecl *New,
6259
                                         const CXXMethodDecl *Old);
6260
6261
  /// CheckOverridingFunctionReturnType - Checks whether the return types are
6262
  /// covariant, according to C++ [class.virtual]p5.
6263
  bool CheckOverridingFunctionReturnType(const CXXMethodDecl *New,
6264
                                         const CXXMethodDecl *Old);
6265
6266
  /// CheckOverridingFunctionExceptionSpec - Checks whether the exception
6267
  /// spec is a subset of base spec.
6268
  bool CheckOverridingFunctionExceptionSpec(const CXXMethodDecl *New,
6269
                                            const CXXMethodDecl *Old);
6270
6271
  bool CheckPureMethod(CXXMethodDecl *Method, SourceRange InitRange);
6272
6273
  /// CheckOverrideControl - Check C++11 override control semantics.
6274
  void CheckOverrideControl(NamedDecl *D);
6275
6276
  /// DiagnoseAbsenceOfOverrideControl - Diagnose if 'override' keyword was
6277
  /// not used in the declaration of an overriding method.
6278
  void DiagnoseAbsenceOfOverrideControl(NamedDecl *D);
6279
6280
  /// CheckForFunctionMarkedFinal - Checks whether a virtual member function
6281
  /// overrides a virtual member function marked 'final', according to
6282
  /// C++11 [class.virtual]p4.
6283
  bool CheckIfOverriddenFunctionIsMarkedFinal(const CXXMethodDecl *New,
6284
                                              const CXXMethodDecl *Old);
6285
6286
6287
  //===--------------------------------------------------------------------===//
6288
  // C++ Access Control
6289
  //
6290
6291
  enum AccessResult {
6292
    AR_accessible,
6293
    AR_inaccessible,
6294
    AR_dependent,
6295
    AR_delayed
6296
  };
6297
6298
  bool SetMemberAccessSpecifier(NamedDecl *MemberDecl,
6299
                                NamedDecl *PrevMemberDecl,
6300
                                AccessSpecifier LexicalAS);
6301
6302
  AccessResult CheckUnresolvedMemberAccess(UnresolvedMemberExpr *E,
6303
                                           DeclAccessPair FoundDecl);
6304
  AccessResult CheckUnresolvedLookupAccess(UnresolvedLookupExpr *E,
6305
                                           DeclAccessPair FoundDecl);
6306
  AccessResult CheckAllocationAccess(SourceLocation OperatorLoc,
6307
                                     SourceRange PlacementRange,
6308
                                     CXXRecordDecl *NamingClass,
6309
                                     DeclAccessPair FoundDecl,
6310
                                     bool Diagnose = true);
6311
  AccessResult CheckConstructorAccess(SourceLocation Loc,
6312
                                      CXXConstructorDecl *D,
6313
                                      DeclAccessPair FoundDecl,
6314
                                      const InitializedEntity &Entity,
6315
                                      bool IsCopyBindingRefToTemp = false);
6316
  AccessResult CheckConstructorAccess(SourceLocation Loc,
6317
                                      CXXConstructorDecl *D,
6318
                                      DeclAccessPair FoundDecl,
6319
                                      const InitializedEntity &Entity,
6320
                                      const PartialDiagnostic &PDiag);
6321
  AccessResult CheckDestructorAccess(SourceLocation Loc,
6322
                                     CXXDestructorDecl *Dtor,
6323
                                     const PartialDiagnostic &PDiag,
6324
                                     QualType objectType = QualType());
6325
  AccessResult CheckFriendAccess(NamedDecl *D);
6326
  AccessResult CheckMemberAccess(SourceLocation UseLoc,
6327
                                 CXXRecordDecl *NamingClass,
6328
                                 DeclAccessPair Found);
6329
  AccessResult
6330
  CheckStructuredBindingMemberAccess(SourceLocation UseLoc,
6331
                                     CXXRecordDecl *DecomposedClass,
6332
                                     DeclAccessPair Field);
6333
  AccessResult CheckMemberOperatorAccess(SourceLocation Loc,
6334
                                         Expr *ObjectExpr,
6335
                                         Expr *ArgExpr,
6336
                                         DeclAccessPair FoundDecl);
6337
  AccessResult CheckAddressOfMemberAccess(Expr *OvlExpr,
6338
                                          DeclAccessPair FoundDecl);
6339
  AccessResult CheckBaseClassAccess(SourceLocation AccessLoc,
6340
                                    QualType Base, QualType Derived,
6341
                                    const CXXBasePath &Path,
6342
                                    unsigned DiagID,
6343
                                    bool ForceCheck = false,
6344
                                    bool ForceUnprivileged = false);
6345
  void CheckLookupAccess(const LookupResult &R);
6346
  bool IsSimplyAccessible(NamedDecl *Decl, CXXRecordDecl *NamingClass,
6347
                          QualType BaseType);
6348
  bool isSpecialMemberAccessibleForDeletion(CXXMethodDecl *decl,
6349
                                            AccessSpecifier access,
6350
                                            QualType objectType);
6351
6352
  void HandleDependentAccessCheck(const DependentDiagnostic &DD,
6353
                         const MultiLevelTemplateArgumentList &TemplateArgs);
6354
  void PerformDependentDiagnostics(const DeclContext *Pattern,
6355
                        const MultiLevelTemplateArgumentList &TemplateArgs);
6356
6357
  void HandleDelayedAccessCheck(sema::DelayedDiagnostic &DD, Decl *Ctx);
6358
6359
  /// When true, access checking violations are treated as SFINAE
6360
  /// failures rather than hard errors.
6361
  bool AccessCheckingSFINAE;
6362
6363
  enum AbstractDiagSelID {
6364
    AbstractNone = -1,
6365
    AbstractReturnType,
6366
    AbstractParamType,
6367
    AbstractVariableType,
6368
    AbstractFieldType,
6369
    AbstractIvarType,
6370
    AbstractSynthesizedIvarType,
6371
    AbstractArrayType
6372
  };
6373
6374
  bool isAbstractType(SourceLocation Loc, QualType T);
6375
  bool RequireNonAbstractType(SourceLocation Loc, QualType T,
6376
                              TypeDiagnoser &Diagnoser);
6377
  template <typename... Ts>
6378
  bool RequireNonAbstractType(SourceLocation Loc, QualType T, unsigned DiagID,
6379
16.8M
                              const Ts &...Args) {
6380
16.8M
    BoundTypeDiagnoser<Ts...> Diagnoser(DiagID, Args...);
6381
16.8M
    return RequireNonAbstractType(Loc, T, Diagnoser);
6382
16.8M
  }
bool clang::Sema::RequireNonAbstractType<>(clang::SourceLocation, clang::QualType, unsigned int)
Line
Count
Source
6379
720k
                              const Ts &...Args) {
6380
720k
    BoundTypeDiagnoser<Ts...> Diagnoser(DiagID, Args...);
6381
720k
    return RequireNonAbstractType(Loc, T, Diagnoser);
6382
720k
  }
bool clang::Sema::RequireNonAbstractType<clang::Sema::AbstractDiagSelID>(clang::SourceLocation, clang::QualType, unsigned int, clang::Sema::AbstractDiagSelID const&)
Line
Count
Source
6379
16.1M
                              const Ts &...Args) {
6380
16.1M
    BoundTypeDiagnoser<Ts...> Diagnoser(DiagID, Args...);
6381
16.1M
    return RequireNonAbstractType(Loc, T, Diagnoser);
6382
16.1M
  }
bool clang::Sema::RequireNonAbstractType<clang::TypeLoc>(clang::SourceLocation, clang::QualType, unsigned int, clang::TypeLoc const&)
Line
Count
Source
6379
1.47k
                              const Ts &...Args) {
6380
1.47k
    BoundTypeDiagnoser<Ts...> Diagnoser(DiagID, Args...);
6381
1.47k
    return RequireNonAbstractType(Loc, T, Diagnoser);
6382
1.47k
  }
bool clang::Sema::RequireNonAbstractType<clang::Expr*>(clang::SourceLocation, clang::QualType, unsigned int, clang::Expr* const&)
Line
Count
Source
6379
3.55k
                              const Ts &...Args) {
6380
3.55k
    BoundTypeDiagnoser<Ts...> Diagnoser(DiagID, Args...);
6381
3.55k
    return RequireNonAbstractType(Loc, T, Diagnoser);
6382
3.55k
  }
6383
6384
  void DiagnoseAbstractType(const CXXRecordDecl *RD);
6385
6386
  //===--------------------------------------------------------------------===//
6387
  // C++ Overloaded Operators [C++ 13.5]
6388
  //
6389
6390
  bool CheckOverloadedOperatorDeclaration(FunctionDecl *FnDecl);
6391
6392
  bool CheckLiteralOperatorDeclaration(FunctionDecl *FnDecl);
6393
6394
  //===--------------------------------------------------------------------===//
6395
  // C++ Templates [C++ 14]
6396
  //
6397
  void FilterAcceptableTemplateNames(LookupResult &R,
6398
                                     bool AllowFunctionTemplates = true,
6399
                                     bool AllowDependent = true);
6400
  bool hasAnyAcceptableTemplateNames(LookupResult &R,
6401
                                     bool AllowFunctionTemplates = true,
6402
                                     bool AllowDependent = true,
6403
                                     bool AllowNonTemplateFunctions = false);
6404
  /// Try to interpret the lookup result D as a template-name.
6405
  ///
6406
  /// \param D A declaration found by name lookup.
6407
  /// \param AllowFunctionTemplates Whether function templates should be
6408
  ///        considered valid results.
6409
  /// \param AllowDependent Whether unresolved using declarations (that might
6410
  ///        name templates) should be considered valid results.
6411
  NamedDecl *getAsTemplateNameDecl(NamedDecl *D,
6412
                                   bool AllowFunctionTemplates = true,
6413
                                   bool AllowDependent = true);
6414
6415
  enum class AssumedTemplateKind {
6416
    /// This is not assumed to be a template name.
6417
    None,
6418
    /// This is assumed to be a template name because lookup found nothing.
6419
    FoundNothing,
6420
    /// This is assumed to be a template name because lookup found one or more
6421
    /// functions (but no function templates).
6422
    FoundFunctions,
6423
  };
6424
  bool LookupTemplateName(LookupResult &R, Scope *S, CXXScopeSpec &SS,
6425
                          QualType ObjectType, bool EnteringContext,
6426
                          bool &MemberOfUnknownSpecialization,
6427
                          SourceLocation TemplateKWLoc = SourceLocation(),
6428
                          AssumedTemplateKind *ATK = nullptr);
6429
6430
  TemplateNameKind isTemplateName(Scope *S,
6431
                                  CXXScopeSpec &SS,
6432
                                  bool hasTemplateKeyword,
6433
                                  const UnqualifiedId &Name,
6434
                                  ParsedType ObjectType,
6435
                                  bool EnteringContext,
6436
                                  TemplateTy &Template,
6437
                                  bool &MemberOfUnknownSpecialization);
6438
6439
  /// Try to resolve an undeclared template name as a type template.
6440
  ///
6441
  /// Sets II to the identifier corresponding to the template name, and updates
6442
  /// Name to a corresponding (typo-corrected) type template name and TNK to
6443
  /// the corresponding kind, if possible.
6444
  void ActOnUndeclaredTypeTemplateName(Scope *S, TemplateTy &Name,
6445
                                       TemplateNameKind &TNK,
6446
                                       SourceLocation NameLoc,
6447
                                       IdentifierInfo *&II);
6448
6449
  bool resolveAssumedTemplateNameAsType(Scope *S, TemplateName &Name,
6450
                                        SourceLocation NameLoc,
6451
                                        bool Diagnose = true);
6452
6453
  /// Determine whether a particular identifier might be the name in a C++1z
6454
  /// deduction-guide declaration.
6455
  bool isDeductionGuideName(Scope *S, const IdentifierInfo &Name,
6456
                            SourceLocation NameLoc,
6457
                            ParsedTemplateTy *Template = nullptr);
6458
6459
  bool DiagnoseUnknownTemplateName(const IdentifierInfo &II,
6460
                                   SourceLocation IILoc,
6461
                                   Scope *S,
6462
                                   const CXXScopeSpec *SS,
6463
                                   TemplateTy &SuggestedTemplate,
6464
                                   TemplateNameKind &SuggestedKind);
6465
6466
  bool DiagnoseUninstantiableTemplate(SourceLocation PointOfInstantiation,
6467
                                      NamedDecl *Instantiation,
6468
                                      bool InstantiatedFromMember,
6469
                                      const NamedDecl *Pattern,
6470
                                      const NamedDecl *PatternDef,
6471
                                      TemplateSpecializationKind TSK,
6472
                                      bool Complain = true);
6473
6474
  void DiagnoseTemplateParameterShadow(SourceLocation Loc, Decl *PrevDecl);
6475
  TemplateDecl *AdjustDeclIfTemplate(Decl *&Decl);
6476
6477
  NamedDecl *ActOnTypeParameter(Scope *S, bool Typename,
6478
                           SourceLocation EllipsisLoc,
6479
                           SourceLocation KeyLoc,
6480
                           IdentifierInfo *ParamName,
6481
                           SourceLocation ParamNameLoc,
6482
                           unsigned Depth, unsigned Position,
6483
                           SourceLocation EqualLoc,
6484
                           ParsedType DefaultArg);
6485
6486
  QualType CheckNonTypeTemplateParameterType(TypeSourceInfo *&TSI,
6487
                                             SourceLocation Loc);
6488
  QualType CheckNonTypeTemplateParameterType(QualType T, SourceLocation Loc);
6489
6490
  NamedDecl *ActOnNonTypeTemplateParameter(Scope *S, Declarator &D,
6491
                                      unsigned Depth,
6492
                                      unsigned Position,
6493
                                      SourceLocation EqualLoc,
6494
                                      Expr *DefaultArg);
6495
  NamedDecl *ActOnTemplateTemplateParameter(Scope *S,
6496
                                       SourceLocation TmpLoc,
6497
                                       TemplateParameterList *Params,
6498
                                       SourceLocation EllipsisLoc,
6499
                                       IdentifierInfo *ParamName,
6500
                                       SourceLocation ParamNameLoc,
6501
                                       unsigned Depth,
6502
                                       unsigned Position,
6503
                                       SourceLocation EqualLoc,
6504
                                       ParsedTemplateArgument DefaultArg);
6505
6506
  TemplateParameterList *
6507
  ActOnTemplateParameterList(unsigned Depth,
6508
                             SourceLocation ExportLoc,
6509
                             SourceLocation TemplateLoc,
6510
                             SourceLocation LAngleLoc,
6511
                             ArrayRef<NamedDecl *> Params,
6512
                             SourceLocation RAngleLoc,
6513
                             Expr *RequiresClause);
6514
6515
  /// The context in which we are checking a template parameter list.
6516
  enum TemplateParamListContext {
6517
    TPC_ClassTemplate,
6518
    TPC_VarTemplate,
6519
    TPC_FunctionTemplate,
6520
    TPC_ClassTemplateMember,
6521
    TPC_FriendClassTemplate,
6522
    TPC_FriendFunctionTemplate,
6523
    TPC_FriendFunctionTemplateDefinition,
6524
    TPC_TypeAliasTemplate
6525
  };
6526
6527
  bool CheckTemplateParameterList(TemplateParameterList *NewParams,
6528
                                  TemplateParameterList *OldParams,
6529
                                  TemplateParamListContext TPC,
6530
                                  SkipBodyInfo *SkipBody = nullptr);
6531
  TemplateParameterList *MatchTemplateParametersToScopeSpecifier(
6532
      SourceLocation DeclStartLoc, SourceLocation DeclLoc,
6533
      const CXXScopeSpec &SS, TemplateIdAnnotation *TemplateId,
6534
      ArrayRef<TemplateParameterList *> ParamLists,
6535
      bool IsFriend, bool &IsMemberSpecialization, bool &Invalid);
6536
6537
  DeclResult CheckClassTemplate(
6538
      Scope *S, unsigned TagSpec, TagUseKind TUK, SourceLocation KWLoc,
6539
      CXXScopeSpec &SS, IdentifierInfo *Name, SourceLocation NameLoc,
6540
      const ParsedAttributesView &Attr, TemplateParameterList *TemplateParams,
6541
      AccessSpecifier AS, SourceLocation ModulePrivateLoc,
6542
      SourceLocation FriendLoc, unsigned NumOuterTemplateParamLists,
6543
      TemplateParameterList **OuterTemplateParamLists,
6544
      SkipBodyInfo *SkipBody = nullptr);
6545
6546
  TemplateArgumentLoc getTrivialTemplateArgumentLoc(const TemplateArgument &Arg,
6547
                                                    QualType NTTPType,
6548
                                                    SourceLocation Loc);
6549
6550
  void translateTemplateArguments(const ASTTemplateArgsPtr &In,
6551
                                  TemplateArgumentListInfo &Out);
6552
6553
  ParsedTemplateArgument ActOnTemplateTypeArgument(TypeResult ParsedType);
6554
6555
  void NoteAllFoundTemplates(TemplateName Name);
6556
6557
  QualType CheckTemplateIdType(TemplateName Template,
6558
                               SourceLocation TemplateLoc,
6559
                              TemplateArgumentListInfo &TemplateArgs);
6560
6561
  TypeResult
6562
  ActOnTemplateIdType(Scope *S, CXXScopeSpec &SS, SourceLocation TemplateKWLoc,
6563
                      TemplateTy Template, IdentifierInfo *TemplateII,
6564
                      SourceLocation TemplateIILoc, SourceLocation LAngleLoc,
6565
                      ASTTemplateArgsPtr TemplateArgs, SourceLocation RAngleLoc,
6566
                      bool IsCtorOrDtorName = false, bool IsClassName = false);
6567
6568
  /// Parsed an elaborated-type-specifier that refers to a template-id,
6569
  /// such as \c class T::template apply<U>.
6570
  TypeResult ActOnTagTemplateIdType(TagUseKind TUK,
6571
                                    TypeSpecifierType TagSpec,
6572
                                    SourceLocation TagLoc,
6573
                                    CXXScopeSpec &SS,
6574
                                    SourceLocation TemplateKWLoc,
6575
                                    TemplateTy TemplateD,
6576
                                    SourceLocation TemplateLoc,
6577
                                    SourceLocation LAngleLoc,
6578
                                    ASTTemplateArgsPtr TemplateArgsIn,
6579
                                    SourceLocation RAngleLoc);
6580
6581
  DeclResult ActOnVarTemplateSpecialization(
6582
      Scope *S, Declarator &D, TypeSourceInfo *DI,
6583
      SourceLocation TemplateKWLoc, TemplateParameterList *TemplateParams,
6584
      StorageClass SC, bool IsPartialSpecialization);
6585
6586
  DeclResult CheckVarTemplateId(VarTemplateDecl *Template,
6587
                                SourceLocation TemplateLoc,
6588
                                SourceLocation TemplateNameLoc,
6589
                                const TemplateArgumentListInfo &TemplateArgs);
6590
6591
  ExprResult CheckVarTemplateId(const CXXScopeSpec &SS,
6592
                                const DeclarationNameInfo &NameInfo,
6593
                                VarTemplateDecl *Template,
6594
                                SourceLocation TemplateLoc,
6595
                                const TemplateArgumentListInfo *TemplateArgs);
6596
6597
  ExprResult
6598
  CheckConceptTemplateId(const CXXScopeSpec &SS,
6599
                         const DeclarationNameInfo &NameInfo,
6600
                         ConceptDecl *Template,
6601
                         SourceLocation TemplateLoc,
6602
                         const TemplateArgumentListInfo *TemplateArgs);
6603
6604
  void diagnoseMissingTemplateArguments(TemplateName Name, SourceLocation Loc);
6605
6606
  ExprResult BuildTemplateIdExpr(const CXXScopeSpec &SS,
6607
                                 SourceLocation TemplateKWLoc,
6608
                                 LookupResult &R,
6609
                                 bool RequiresADL,
6610
                               const TemplateArgumentListInfo *TemplateArgs);
6611
6612
  ExprResult BuildQualifiedTemplateIdExpr(CXXScopeSpec &SS,
6613
                                          SourceLocation TemplateKWLoc,
6614
                               const DeclarationNameInfo &NameInfo,
6615
                               const TemplateArgumentListInfo *TemplateArgs);
6616
6617
  TemplateNameKind ActOnDependentTemplateName(
6618
      Scope *S, CXXScopeSpec &SS, SourceLocation TemplateKWLoc,
6619
      const UnqualifiedId &Name, ParsedType ObjectType, bool EnteringContext,
6620
      TemplateTy &Template, bool AllowInjectedClassName = false);
6621
6622
  DeclResult ActOnClassTemplateSpecialization(
6623
      Scope *S, unsigned TagSpec, TagUseKind TUK, SourceLocation KWLoc,
6624
      SourceLocation ModulePrivateLoc, TemplateIdAnnotation &TemplateId,
6625
      const ParsedAttributesView &Attr,
6626
      MultiTemplateParamsArg TemplateParameterLists,
6627
      SkipBodyInfo *SkipBody = nullptr);
6628
6629
  bool CheckTemplatePartialSpecializationArgs(SourceLocation Loc,
6630
                                              TemplateDecl *PrimaryTemplate,
6631
                                              unsigned NumExplicitArgs,
6632
                                              ArrayRef<TemplateArgument> Args);
6633
  void CheckTemplatePartialSpecialization(
6634
      ClassTemplatePartialSpecializationDecl *Partial);
6635
  void CheckTemplatePartialSpecialization(
6636
      VarTemplatePartialSpecializationDecl *Partial);
6637
6638
  Decl *ActOnTemplateDeclarator(Scope *S,
6639
                                MultiTemplateParamsArg TemplateParameterLists,
6640
                                Declarator &D);
6641
6642
  bool
6643
  CheckSpecializationInstantiationRedecl(SourceLocation NewLoc,
6644
                                         TemplateSpecializationKind NewTSK,
6645
                                         NamedDecl *PrevDecl,
6646
                                         TemplateSpecializationKind PrevTSK,
6647
                                         SourceLocation PrevPtOfInstantiation,
6648
                                         bool &SuppressNew);
6649
6650
  bool CheckDependentFunctionTemplateSpecialization(FunctionDecl *FD,
6651
                    const TemplateArgumentListInfo &ExplicitTemplateArgs,
6652
                                                    LookupResult &Previous);
6653
6654
  bool CheckFunctionTemplateSpecialization(
6655
      FunctionDecl *FD, TemplateArgumentListInfo *ExplicitTemplateArgs,
6656
      LookupResult &Previous, bool QualifiedFriend = false);
6657
  bool CheckMemberSpecialization(NamedDecl *Member, LookupResult &Previous);
6658
  void CompleteMemberSpecialization(NamedDecl *Member, LookupResult &Previous);
6659
6660
  DeclResult ActOnExplicitInstantiation(
6661
      Scope *S, SourceLocation ExternLoc, SourceLocation TemplateLoc,
6662
      unsigned TagSpec, SourceLocation KWLoc, const CXXScopeSpec &SS,
6663
      TemplateTy Template, SourceLocation TemplateNameLoc,
6664
      SourceLocation LAngleLoc, ASTTemplateArgsPtr TemplateArgs,
6665
      SourceLocation RAngleLoc, const ParsedAttributesView &Attr);
6666
6667
  DeclResult ActOnExplicitInstantiation(Scope *S, SourceLocation ExternLoc,
6668
                                        SourceLocation TemplateLoc,
6669
                                        unsigned TagSpec, SourceLocation KWLoc,
6670
                                        CXXScopeSpec &SS, IdentifierInfo *Name,
6671
                                        SourceLocation NameLoc,
6672
                                        const ParsedAttributesView &Attr);
6673
6674
  DeclResult ActOnExplicitInstantiation(Scope *S,
6675
                                        SourceLocation ExternLoc,
6676
                                        SourceLocation TemplateLoc,
6677
                                        Declarator &D);
6678
6679
  TemplateArgumentLoc
6680
  SubstDefaultTemplateArgumentIfAvailable(TemplateDecl *Template,
6681
                                          SourceLocation TemplateLoc,
6682
                                          SourceLocation RAngleLoc,
6683
                                          Decl *Param,
6684
                                          SmallVectorImpl<TemplateArgument>
6685
                                            &Converted,
6686
                                          bool &HasDefaultArg);
6687
6688
  /// Specifies the context in which a particular template
6689
  /// argument is being checked.
6690
  enum CheckTemplateArgumentKind {
6691
    /// The template argument was specified in the code or was
6692
    /// instantiated with some deduced template arguments.
6693
    CTAK_Specified,
6694
6695
    /// The template argument was deduced via template argument
6696
    /// deduction.
6697
    CTAK_Deduced,
6698
6699
    /// The template argument was deduced from an array bound
6700
    /// via template argument deduction.
6701
    CTAK_DeducedFromArrayBound
6702
  };
6703
6704
  bool CheckTemplateArgument(NamedDecl *Param,
6705
                             TemplateArgumentLoc &Arg,
6706
                             NamedDecl *Template,
6707
                             SourceLocation TemplateLoc,
6708
                             SourceLocation RAngleLoc,
6709
                             unsigned ArgumentPackIndex,
6710
                           SmallVectorImpl<TemplateArgument> &Converted,
6711
                             CheckTemplateArgumentKind CTAK = CTAK_Specified);
6712
6713
  /// Check that the given template arguments can be be provided to
6714
  /// the given template, converting the arguments along the way.
6715
  ///
6716
  /// \param Template The template to which the template arguments are being
6717
  /// provided.
6718
  ///
6719
  /// \param TemplateLoc The location of the template name in the source.
6720
  ///
6721
  /// \param TemplateArgs The list of template arguments. If the template is
6722
  /// a template template parameter, this function may extend the set of
6723
  /// template arguments to also include substituted, defaulted template
6724
  /// arguments.
6725
  ///
6726
  /// \param PartialTemplateArgs True if the list of template arguments is
6727
  /// intentionally partial, e.g., because we're checking just the initial
6728
  /// set of template arguments.
6729
  ///
6730
  /// \param Converted Will receive the converted, canonicalized template
6731
  /// arguments.
6732
  ///
6733
  /// \param UpdateArgsWithConversions If \c true, update \p TemplateArgs to
6734
  /// contain the converted forms of the template arguments as written.
6735
  /// Otherwise, \p TemplateArgs will not be modified.
6736
  ///
6737
  /// \returns true if an error occurred, false otherwise.
6738
  bool CheckTemplateArgumentList(TemplateDecl *Template,
6739
                                 SourceLocation TemplateLoc,
6740
                                 TemplateArgumentListInfo &TemplateArgs,
6741
                                 bool PartialTemplateArgs,
6742
                                 SmallVectorImpl<TemplateArgument> &Converted,
6743
                                 bool UpdateArgsWithConversions = true);
6744
6745
  bool CheckTemplateTypeArgument(TemplateTypeParmDecl *Param,
6746
                                 TemplateArgumentLoc &Arg,
6747
                           SmallVectorImpl<TemplateArgument> &Converted);
6748
6749
  bool CheckTemplateArgument(TemplateTypeParmDecl *Param,
6750
                             TypeSourceInfo *Arg);
6751
  ExprResult CheckTemplateArgument(NonTypeTemplateParmDecl *Param,
6752
                                   QualType InstantiatedParamType, Expr *Arg,
6753
                                   TemplateArgument &Converted,
6754
                               CheckTemplateArgumentKind CTAK = CTAK_Specified);
6755
  bool CheckTemplateTemplateArgument(TemplateParameterList *Params,
6756
                                     TemplateArgumentLoc &Arg);
6757
6758
  ExprResult
6759
  BuildExpressionFromDeclTemplateArgument(const TemplateArgument &Arg,
6760
                                          QualType ParamType,
6761
                                          SourceLocation Loc);
6762
  ExprResult
6763
  BuildExpressionFromIntegralTemplateArgument(const TemplateArgument &Arg,
6764
                                              SourceLocation Loc);
6765
6766
  /// Enumeration describing how template parameter lists are compared
6767
  /// for equality.
6768
  enum TemplateParameterListEqualKind {
6769
    /// We are matching the template parameter lists of two templates
6770
    /// that might be redeclarations.
6771
    ///
6772
    /// \code
6773
    /// template<typename T> struct X;
6774
    /// template<typename T> struct X;
6775
    /// \endcode
6776
    TPL_TemplateMatch,
6777
6778
    /// We are matching the template parameter lists of two template
6779
    /// template parameters as part of matching the template parameter lists
6780
    /// of two templates that might be redeclarations.
6781
    ///
6782
    /// \code
6783
    /// template<template<int I> class TT> struct X;
6784
    /// template<template<int Value> class Other> struct X;
6785
    /// \endcode
6786
    TPL_TemplateTemplateParmMatch,
6787
6788
    /// We are matching the template parameter lists of a template
6789
    /// template argument against the template parameter lists of a template
6790
    /// template parameter.
6791
    ///
6792
    /// \code
6793
    /// template<template<int Value> class Metafun> struct X;
6794
    /// template<int Value> struct integer_c;
6795
    /// X<integer_c> xic;
6796
    /// \endcode
6797
    TPL_TemplateTemplateArgumentMatch
6798
  };
6799
6800
  bool TemplateParameterListsAreEqual(TemplateParameterList *New,
6801
                                      TemplateParameterList *Old,
6802
                                      bool Complain,
6803
                                      TemplateParameterListEqualKind Kind,
6804
                                      SourceLocation TemplateArgLoc
6805
                                        = SourceLocation());
6806
6807
  bool CheckTemplateDeclScope(Scope *S, TemplateParameterList *TemplateParams);
6808
6809
  /// Called when the parser has parsed a C++ typename
6810
  /// specifier, e.g., "typename T::type".
6811
  ///
6812
  /// \param S The scope in which this typename type occurs.
6813
  /// \param TypenameLoc the location of the 'typename' keyword
6814
  /// \param SS the nested-name-specifier following the typename (e.g., 'T::').
6815
  /// \param II the identifier we're retrieving (e.g., 'type' in the example).
6816
  /// \param IdLoc the location of the identifier.
6817
  TypeResult
6818
  ActOnTypenameType(Scope *S, SourceLocation TypenameLoc,
6819
                    const CXXScopeSpec &SS, const IdentifierInfo &II,
6820
                    SourceLocation IdLoc);
6821
6822
  /// Called when the parser has parsed a C++ typename
6823
  /// specifier that ends in a template-id, e.g.,
6824
  /// "typename MetaFun::template apply<T1, T2>".
6825
  ///
6826
  /// \param S The scope in which this typename type occurs.
6827
  /// \param TypenameLoc the location of the 'typename' keyword
6828
  /// \param SS the nested-name-specifier following the typename (e.g., 'T::').
6829
  /// \param TemplateLoc the location of the 'template' keyword, if any.
6830
  /// \param TemplateName The template name.
6831
  /// \param TemplateII The identifier used to name the template.
6832
  /// \param TemplateIILoc The location of the template name.
6833
  /// \param LAngleLoc The location of the opening angle bracket  ('<').
6834
  /// \param TemplateArgs The template arguments.
6835
  /// \param RAngleLoc The location of the closing angle bracket  ('>').
6836
  TypeResult
6837
  ActOnTypenameType(Scope *S, SourceLocation TypenameLoc,
6838
                    const CXXScopeSpec &SS,
6839
                    SourceLocation TemplateLoc,
6840
                    TemplateTy TemplateName,
6841
                    IdentifierInfo *TemplateII,
6842
                    SourceLocation TemplateIILoc,
6843
                    SourceLocation LAngleLoc,
6844
                    ASTTemplateArgsPtr TemplateArgs,
6845
                    SourceLocation RAngleLoc);
6846
6847
  QualType CheckTypenameType(ElaboratedTypeKeyword Keyword,
6848
                             SourceLocation KeywordLoc,
6849
                             NestedNameSpecifierLoc QualifierLoc,
6850
                             const IdentifierInfo &II,
6851
                             SourceLocation IILoc);
6852
6853
  TypeSourceInfo *RebuildTypeInCurrentInstantiation(TypeSourceInfo *T,
6854
                                                    SourceLocation Loc,
6855
                                                    DeclarationName Name);
6856
  bool RebuildNestedNameSpecifierInCurrentInstantiation(CXXScopeSpec &SS);
6857
6858
  ExprResult RebuildExprInCurrentInstantiation(Expr *E);
6859
  bool RebuildTemplateParamsInCurrentInstantiation(
6860
                                                TemplateParameterList *Params);
6861
6862
  std::string
6863
  getTemplateArgumentBindingsText(const TemplateParameterList *Params,
6864
                                  const TemplateArgumentList &Args);
6865
6866
  std::string
6867
  getTemplateArgumentBindingsText(const TemplateParameterList *Params,
6868
                                  const TemplateArgument *Args,
6869
                                  unsigned NumArgs);
6870
6871
  // Concepts
6872
  Decl *ActOnConceptDefinition(
6873
      Scope *S, MultiTemplateParamsArg TemplateParameterLists,
6874
      IdentifierInfo *Name, SourceLocation NameLoc, Expr *ConstraintExpr);
6875
6876
  //===--------------------------------------------------------------------===//
6877
  // C++ Variadic Templates (C++0x [temp.variadic])
6878
  //===--------------------------------------------------------------------===//
6879
6880
  /// Determine whether an unexpanded parameter pack might be permitted in this
6881
  /// location. Useful for error recovery.
6882
  bool isUnexpandedParameterPackPermitted();
6883
6884
  /// The context in which an unexpanded parameter pack is
6885
  /// being diagnosed.
6886
  ///
6887
  /// Note that the values of this enumeration line up with the first
6888
  /// argument to the \c err_unexpanded_parameter_pack diagnostic.
6889
  enum UnexpandedParameterPackContext {
6890
    /// An arbitrary expression.
6891
    UPPC_Expression = 0,
6892
6893
    /// The base type of a class type.
6894
    UPPC_BaseType,
6895
6896
    /// The type of an arbitrary declaration.
6897
    UPPC_DeclarationType,
6898
6899
    /// The type of a data member.
6900
    UPPC_DataMemberType,
6901
6902
    /// The size of a bit-field.
6903
    UPPC_BitFieldWidth,
6904
6905
    /// The expression in a static assertion.
6906
    UPPC_StaticAssertExpression,
6907
6908
    /// The fixed underlying type of an enumeration.
6909
    UPPC_FixedUnderlyingType,
6910
6911
    /// The enumerator value.
6912
    UPPC_EnumeratorValue,
6913
6914
    /// A using declaration.
6915
    UPPC_UsingDeclaration,
6916
6917
    /// A friend declaration.
6918
    UPPC_FriendDeclaration,
6919
6920
    /// A declaration qualifier.
6921
    UPPC_DeclarationQualifier,
6922
6923
    /// An initializer.
6924
    UPPC_Initializer,
6925
6926
    /// A default argument.
6927
    UPPC_DefaultArgument,
6928
6929
    /// The type of a non-type template parameter.
6930
    UPPC_NonTypeTemplateParameterType,
6931
6932
    /// The type of an exception.
6933
    UPPC_ExceptionType,
6934
6935
    /// Partial specialization.
6936
    UPPC_PartialSpecialization,
6937
6938
    /// Microsoft __if_exists.
6939
    UPPC_IfExists,
6940
6941
    /// Microsoft __if_not_exists.
6942
    UPPC_IfNotExists,
6943
6944
    /// Lambda expression.
6945
    UPPC_Lambda,
6946
6947
    /// Block expression,
6948
    UPPC_Block
6949
  };
6950
6951
  /// Diagnose unexpanded parameter packs.
6952
  ///
6953
  /// \param Loc The location at which we should emit the diagnostic.
6954
  ///
6955
  /// \param UPPC The context in which we are diagnosing unexpanded
6956
  /// parameter packs.
6957
  ///
6958
  /// \param Unexpanded the set of unexpanded parameter packs.
6959
  ///
6960
  /// \returns true if an error occurred, false otherwise.
6961
  bool DiagnoseUnexpandedParameterPacks(SourceLocation Loc,
6962
                                        UnexpandedParameterPackContext UPPC,
6963
                                  ArrayRef<UnexpandedParameterPack> Unexpanded);
6964
6965
  /// If the given type contains an unexpanded parameter pack,
6966
  /// diagnose the error.
6967
  ///
6968
  /// \param Loc The source location where a diagnostc should be emitted.
6969
  ///
6970
  /// \param T The type that is being checked for unexpanded parameter
6971
  /// packs.
6972
  ///
6973
  /// \returns true if an error occurred, false otherwise.
6974
  bool DiagnoseUnexpandedParameterPack(SourceLocation Loc, TypeSourceInfo *T,
6975
                                       UnexpandedParameterPackContext UPPC);
6976
6977
  /// If the given expression contains an unexpanded parameter
6978
  /// pack, diagnose the error.
6979
  ///
6980
  /// \param E The expression that is being checked for unexpanded
6981
  /// parameter packs.
6982
  ///
6983
  /// \returns true if an error occurred, false otherwise.
6984
  bool DiagnoseUnexpandedParameterPack(Expr *E,
6985
                       UnexpandedParameterPackContext UPPC = UPPC_Expression);
6986
6987
  /// If the given nested-name-specifier contains an unexpanded
6988
  /// parameter pack, diagnose the error.
6989
  ///
6990
  /// \param SS The nested-name-specifier that is being checked for
6991
  /// unexpanded parameter packs.
6992
  ///
6993
  /// \returns true if an error occurred, false otherwise.
6994
  bool DiagnoseUnexpandedParameterPack(const CXXScopeSpec &SS,
6995
                                       UnexpandedParameterPackContext UPPC);
6996
6997
  /// If the given name contains an unexpanded parameter pack,
6998
  /// diagnose the error.
6999
  ///
7000
  /// \param NameInfo The name (with source location information) that
7001
  /// is being checked for unexpanded parameter packs.
7002
  ///
7003
  /// \returns true if an error occurred, false otherwise.
7004
  bool DiagnoseUnexpandedParameterPack(const DeclarationNameInfo &NameInfo,
7005
                                       UnexpandedParameterPackContext UPPC);
7006
7007
  /// If the given template name contains an unexpanded parameter pack,
7008
  /// diagnose the error.
7009
  ///
7010
  /// \param Loc The location of the template name.
7011
  ///
7012
  /// \param Template The template name that is being checked for unexpanded
7013
  /// parameter packs.
7014
  ///
7015
  /// \returns true if an error occurred, false otherwise.
7016
  bool DiagnoseUnexpandedParameterPack(SourceLocation Loc,
7017
                                       TemplateName Template,
7018
                                       UnexpandedParameterPackContext UPPC);
7019
7020
  /// If the given template argument contains an unexpanded parameter
7021
  /// pack, diagnose the error.
7022
  ///
7023
  /// \param Arg The template argument that is being checked for unexpanded
7024
  /// parameter packs.
7025
  ///
7026
  /// \returns true if an error occurred, false otherwise.
7027
  bool DiagnoseUnexpandedParameterPack(TemplateArgumentLoc Arg,
7028
                                       UnexpandedParameterPackContext UPPC);
7029
7030
  /// Collect the set of unexpanded parameter packs within the given
7031
  /// template argument.
7032
  ///
7033
  /// \param Arg The template argument that will be traversed to find
7034
  /// unexpanded parameter packs.
7035
  void collectUnexpandedParameterPacks(TemplateArgument Arg,
7036
                   SmallVectorImpl<UnexpandedParameterPack> &Unexpanded);
7037
7038
  /// Collect the set of unexpanded parameter packs within the given
7039
  /// template argument.
7040
  ///
7041
  /// \param Arg The template argument that will be traversed to find
7042
  /// unexpanded parameter packs.
7043
  void collectUnexpandedParameterPacks(TemplateArgumentLoc Arg,
7044
                    SmallVectorImpl<UnexpandedParameterPack> &Unexpanded);
7045
7046
  /// Collect the set of unexpanded parameter packs within the given
7047
  /// type.
7048
  ///
7049
  /// \param T The type that will be traversed to find
7050
  /// unexpanded parameter packs.
7051
  void collectUnexpandedParameterPacks(QualType T,
7052
                   SmallVectorImpl<UnexpandedParameterPack> &Unexpanded);
7053
7054
  /// Collect the set of unexpanded parameter packs within the given
7055
  /// type.
7056
  ///
7057
  /// \param TL The type that will be traversed to find
7058
  /// unexpanded parameter packs.
7059
  void collectUnexpandedParameterPacks(TypeLoc TL,
7060
                   SmallVectorImpl<UnexpandedParameterPack> &Unexpanded);
7061
7062
  /// Collect the set of unexpanded parameter packs within the given
7063
  /// nested-name-specifier.
7064
  ///
7065
  /// \param NNS The nested-name-specifier that will be traversed to find
7066
  /// unexpanded parameter packs.
7067
  void collectUnexpandedParameterPacks(NestedNameSpecifierLoc NNS,
7068
                         SmallVectorImpl<UnexpandedParameterPack> &Unexpanded);
7069
7070
  /// Collect the set of unexpanded parameter packs within the given
7071
  /// name.
7072
  ///
7073
  /// \param NameInfo The name that will be traversed to find
7074
  /// unexpanded parameter packs.
7075
  void collectUnexpandedParameterPacks(const DeclarationNameInfo &NameInfo,
7076
                         SmallVectorImpl<UnexpandedParameterPack> &Unexpanded);
7077
7078
  /// Invoked when parsing a template argument followed by an
7079
  /// ellipsis, which creates a pack expansion.
7080
  ///
7081
  /// \param Arg The template argument preceding the ellipsis, which
7082
  /// may already be invalid.
7083
  ///
7084
  /// \param EllipsisLoc The location of the ellipsis.
7085
  ParsedTemplateArgument ActOnPackExpansion(const ParsedTemplateArgument &Arg,
7086
                                            SourceLocation EllipsisLoc);
7087
7088
  /// Invoked when parsing a type followed by an ellipsis, which
7089
  /// creates a pack expansion.
7090
  ///
7091
  /// \param Type The type preceding the ellipsis, which will become
7092
  /// the pattern of the pack expansion.
7093
  ///
7094
  /// \param EllipsisLoc The location of the ellipsis.
7095
  TypeResult ActOnPackExpansion(ParsedType Type, SourceLocation EllipsisLoc);
7096
7097
  /// Construct a pack expansion type from the pattern of the pack
7098
  /// expansion.
7099
  TypeSourceInfo *CheckPackExpansion(TypeSourceInfo *Pattern,
7100
                                     SourceLocation EllipsisLoc,
7101
                                     Optional<unsigned> NumExpansions);
7102
7103
  /// Construct a pack expansion type from the pattern of the pack
7104
  /// expansion.
7105
  QualType CheckPackExpansion(QualType Pattern,
7106
                              SourceRange PatternRange,
7107
                              SourceLocation EllipsisLoc,
7108
                              Optional<unsigned> NumExpansions);
7109
7110
  /// Invoked when parsing an expression followed by an ellipsis, which
7111
  /// creates a pack expansion.
7112
  ///
7113
  /// \param Pattern The expression preceding the ellipsis, which will become
7114
  /// the pattern of the pack expansion.
7115
  ///
7116
  /// \param EllipsisLoc The location of the ellipsis.
7117
  ExprResult ActOnPackExpansion(Expr *Pattern, SourceLocation EllipsisLoc);
7118
7119
  /// Invoked when parsing an expression followed by an ellipsis, which
7120
  /// creates a pack expansion.
7121
  ///
7122
  /// \param Pattern The expression preceding the ellipsis, which will become
7123
  /// the pattern of the pack expansion.
7124
  ///
7125
  /// \param EllipsisLoc The location of the ellipsis.
7126
  ExprResult CheckPackExpansion(Expr *Pattern, SourceLocation EllipsisLoc,
7127
                                Optional<unsigned> NumExpansions);
7128
7129
  /// Determine whether we could expand a pack expansion with the
7130
  /// given set of parameter packs into separate arguments by repeatedly
7131
  /// transforming the pattern.
7132
  ///
7133
  /// \param EllipsisLoc The location of the ellipsis that identifies the
7134
  /// pack expansion.
7135
  ///
7136
  /// \param PatternRange The source range that covers the entire pattern of
7137
  /// the pack expansion.
7138
  ///
7139
  /// \param Unexpanded The set of unexpanded parameter packs within the
7140
  /// pattern.
7141
  ///
7142
  /// \param ShouldExpand Will be set to \c true if the transformer should
7143
  /// expand the corresponding pack expansions into separate arguments. When
7144
  /// set, \c NumExpansions must also be set.
7145
  ///
7146
  /// \param RetainExpansion Whether the caller should add an unexpanded
7147
  /// pack expansion after all of the expanded arguments. This is used
7148
  /// when extending explicitly-specified template argument packs per
7149
  /// C++0x [temp.arg.explicit]p9.
7150
  ///
7151
  /// \param NumExpansions The number of separate arguments that will be in
7152
  /// the expanded form of the corresponding pack expansion. This is both an
7153
  /// input and an output parameter, which can be set by the caller if the
7154
  /// number of expansions is known a priori (e.g., due to a prior substitution)
7155
  /// and will be set by the callee when the number of expansions is known.
7156
  /// The callee must set this value when \c ShouldExpand is \c true; it may
7157
  /// set this value in other cases.
7158
  ///
7159
  /// \returns true if an error occurred (e.g., because the parameter packs
7160
  /// are to be instantiated with arguments of different lengths), false
7161
  /// otherwise. If false, \c ShouldExpand (and possibly \c NumExpansions)
7162
  /// must be set.
7163
  bool CheckParameterPacksForExpansion(SourceLocation EllipsisLoc,
7164
                                       SourceRange PatternRange,
7165
                             ArrayRef<UnexpandedParameterPack> Unexpanded,
7166
                             const MultiLevelTemplateArgumentList &TemplateArgs,
7167
                                       bool &ShouldExpand,
7168
                                       bool &RetainExpansion,
7169
                                       Optional<unsigned> &NumExpansions);
7170
7171
  /// Determine the number of arguments in the given pack expansion
7172
  /// type.
7173
  ///
7174
  /// This routine assumes that the number of arguments in the expansion is
7175
  /// consistent across all of the unexpanded parameter packs in its pattern.
7176
  ///
7177
  /// Returns an empty Optional if the type can't be expanded.
7178
  Optional<unsigned> getNumArgumentsInExpansion(QualType T,
7179
      const MultiLevelTemplateArgumentList &TemplateArgs);
7180
7181
  /// Determine whether the given declarator contains any unexpanded
7182
  /// parameter packs.
7183
  ///
7184
  /// This routine is used by the parser to disambiguate function declarators
7185
  /// with an ellipsis prior to the ')', e.g.,
7186
  ///
7187
  /// \code
7188
  ///   void f(T...);
7189
  /// \endcode
7190
  ///
7191
  /// To determine whether we have an (unnamed) function parameter pack or
7192
  /// a variadic function.
7193
  ///
7194
  /// \returns true if the declarator contains any unexpanded parameter packs,
7195
  /// false otherwise.
7196
  bool containsUnexpandedParameterPacks(Declarator &D);
7197
7198
  /// Returns the pattern of the pack expansion for a template argument.
7199
  ///
7200
  /// \param OrigLoc The template argument to expand.
7201
  ///
7202
  /// \param Ellipsis Will be set to the location of the ellipsis.
7203
  ///
7204
  /// \param NumExpansions Will be set to the number of expansions that will
7205
  /// be generated from this pack expansion, if known a priori.
7206
  TemplateArgumentLoc getTemplateArgumentPackExpansionPattern(
7207
      TemplateArgumentLoc OrigLoc,
7208
      SourceLocation &Ellipsis,
7209
      Optional<unsigned> &NumExpansions) const;
7210
7211
  /// Given a template argument that contains an unexpanded parameter pack, but
7212
  /// which has already been substituted, attempt to determine the number of
7213
  /// elements that will be produced once this argument is fully-expanded.
7214
  ///
7215
  /// This is intended for use when transforming 'sizeof...(Arg)' in order to
7216
  /// avoid actually expanding the pack where possible.
7217
  Optional<unsigned> getFullyPackExpandedSize(TemplateArgument Arg);
7218
7219
  //===--------------------------------------------------------------------===//
7220
  // C++ Template Argument Deduction (C++ [temp.deduct])
7221
  //===--------------------------------------------------------------------===//
7222
7223
  /// Adjust the type \p ArgFunctionType to match the calling convention,
7224
  /// noreturn, and optionally the exception specification of \p FunctionType.
7225
  /// Deduction often wants to ignore these properties when matching function
7226
  /// types.
7227
  QualType adjustCCAndNoReturn(QualType ArgFunctionType, QualType FunctionType,
7228
                               bool AdjustExceptionSpec = false);
7229
7230
  /// Describes the result of template argument deduction.
7231
  ///
7232
  /// The TemplateDeductionResult enumeration describes the result of
7233
  /// template argument deduction, as returned from
7234
  /// DeduceTemplateArguments(). The separate TemplateDeductionInfo
7235
  /// structure provides additional information about the results of
7236
  /// template argument deduction, e.g., the deduced template argument
7237
  /// list (if successful) or the specific template parameters or
7238
  /// deduced arguments that were involved in the failure.
7239
  enum TemplateDeductionResult {
7240
    /// Template argument deduction was successful.
7241
    TDK_Success = 0,
7242
    /// The declaration was invalid; do nothing.
7243
    TDK_Invalid,
7244
    /// Template argument deduction exceeded the maximum template
7245
    /// instantiation depth (which has already been diagnosed).
7246
    TDK_InstantiationDepth,
7247
    /// Template argument deduction did not deduce a value
7248
    /// for every template parameter.
7249
    TDK_Incomplete,
7250
    /// Template argument deduction did not deduce a value for every
7251
    /// expansion of an expanded template parameter pack.
7252
    TDK_IncompletePack,
7253
    /// Template argument deduction produced inconsistent
7254
    /// deduced values for the given template parameter.
7255
    TDK_Inconsistent,
7256
    /// Template argument deduction failed due to inconsistent
7257
    /// cv-qualifiers on a template parameter type that would
7258
    /// otherwise be deduced, e.g., we tried to deduce T in "const T"
7259
    /// but were given a non-const "X".
7260
    TDK_Underqualified,
7261
    /// Substitution of the deduced template argument values
7262
    /// resulted in an error.
7263
    TDK_SubstitutionFailure,
7264
    /// After substituting deduced template arguments, a dependent
7265
    /// parameter type did not match the corresponding argument.
7266
    TDK_DeducedMismatch,
7267
    /// After substituting deduced template arguments, an element of
7268
    /// a dependent parameter type did not match the corresponding element
7269
    /// of the corresponding argument (when deducing from an initializer list).
7270
    TDK_DeducedMismatchNested,
7271
    /// A non-depnedent component of the parameter did not match the
7272
    /// corresponding component of the argument.
7273
    TDK_NonDeducedMismatch,
7274
    /// When performing template argument deduction for a function
7275
    /// template, there were too many call arguments.
7276
    TDK_TooManyArguments,
7277
    /// When performing template argument deduction for a function
7278
    /// template, there were too few call arguments.
7279
    TDK_TooFewArguments,
7280
    /// The explicitly-specified template arguments were not valid
7281
    /// template arguments for the given template.
7282
    TDK_InvalidExplicitArguments,
7283
    /// Checking non-dependent argument conversions failed.
7284
    TDK_NonDependentConversionFailure,
7285
    /// Deduction failed; that's all we know.
7286
    TDK_MiscellaneousDeductionFailure,
7287
    /// CUDA Target attributes do not match.
7288
    TDK_CUDATargetMismatch
7289
  };
7290
7291
  TemplateDeductionResult
7292
  DeduceTemplateArguments(ClassTemplatePartialSpecializationDecl *Partial,
7293
                          const TemplateArgumentList &TemplateArgs,
7294
                          sema::TemplateDeductionInfo &Info);
7295
7296
  TemplateDeductionResult
7297
  DeduceTemplateArguments(VarTemplatePartialSpecializationDecl *Partial,
7298
                          const TemplateArgumentList &TemplateArgs,
7299
                          sema::TemplateDeductionInfo &Info);
7300
7301
  TemplateDeductionResult SubstituteExplicitTemplateArguments(
7302
      FunctionTemplateDecl *FunctionTemplate,
7303
      TemplateArgumentListInfo &ExplicitTemplateArgs,
7304
      SmallVectorImpl<DeducedTemplateArgument> &Deduced,
7305
      SmallVectorImpl<QualType> &ParamTypes, QualType *FunctionType,
7306
      sema::TemplateDeductionInfo &Info);
7307
7308
  /// brief A function argument from which we performed template argument
7309
  // deduction for a call.
7310
  struct OriginalCallArg {
7311
    OriginalCallArg(QualType OriginalParamType, bool DecomposedParam,
7312
                    unsigned ArgIdx, QualType OriginalArgType)
7313
        : OriginalParamType(OriginalParamType),
7314
          DecomposedParam(DecomposedParam), ArgIdx(ArgIdx),
7315
1.59M
          OriginalArgType(OriginalArgType) {}
7316
7317
    QualType OriginalParamType;
7318
    bool DecomposedParam;
7319
    unsigned ArgIdx;
7320
    QualType OriginalArgType;
7321
  };
7322
7323
  TemplateDeductionResult FinishTemplateArgumentDeduction(
7324
      FunctionTemplateDecl *FunctionTemplate,
7325
      SmallVectorImpl<DeducedTemplateArgument> &Deduced,
7326
      unsigned NumExplicitlySpecified, FunctionDecl *&Specialization,
7327
      sema::TemplateDeductionInfo &Info,
7328
      SmallVectorImpl<OriginalCallArg> const *OriginalCallArgs = nullptr,
7329
      bool PartialOverloading = false,
7330
26.3k
      llvm::function_ref<bool()> CheckNonDependent = []{ return false; });
7331
7332
  TemplateDeductionResult DeduceTemplateArguments(
7333
      FunctionTemplateDecl *FunctionTemplate,
7334
      TemplateArgumentListInfo *ExplicitTemplateArgs, ArrayRef<Expr *> Args,
7335
      FunctionDecl *&Specialization, sema::TemplateDeductionInfo &Info,
7336
      bool PartialOverloading,
7337
      llvm::function_ref<bool(ArrayRef<QualType>)> CheckNonDependent);
7338
7339
  TemplateDeductionResult
7340
  DeduceTemplateArguments(FunctionTemplateDecl *FunctionTemplate,
7341
                          TemplateArgumentListInfo *ExplicitTemplateArgs,
7342
                          QualType ArgFunctionType,
7343
                          FunctionDecl *&Specialization,
7344
                          sema::TemplateDeductionInfo &Info,
7345
                          bool IsAddressOfFunction = false);
7346
7347
  TemplateDeductionResult
7348
  DeduceTemplateArguments(FunctionTemplateDecl *FunctionTemplate,
7349
                          QualType ToType,
7350
                          CXXConversionDecl *&Specialization,
7351
                          sema::TemplateDeductionInfo &Info);
7352
7353
  TemplateDeductionResult
7354
  DeduceTemplateArguments(FunctionTemplateDecl *FunctionTemplate,
7355
                          TemplateArgumentListInfo *ExplicitTemplateArgs,
7356
                          FunctionDecl *&Specialization,
7357
                          sema::TemplateDeductionInfo &Info,
7358
                          bool IsAddressOfFunction = false);
7359
7360
  /// Substitute Replacement for \p auto in \p TypeWithAuto
7361
  QualType SubstAutoType(QualType TypeWithAuto, QualType Replacement);
7362
  /// Substitute Replacement for auto in TypeWithAuto
7363
  TypeSourceInfo* SubstAutoTypeSourceInfo(TypeSourceInfo *TypeWithAuto,
7364
                                          QualType Replacement);
7365
  /// Completely replace the \c auto in \p TypeWithAuto by
7366
  /// \p Replacement. This does not retain any \c auto type sugar.
7367
  QualType ReplaceAutoType(QualType TypeWithAuto, QualType Replacement);
7368
7369
  /// Result type of DeduceAutoType.
7370
  enum DeduceAutoResult {
7371
    DAR_Succeeded,
7372
    DAR_Failed,
7373
    DAR_FailedAlreadyDiagnosed
7374
  };
7375
7376
  DeduceAutoResult
7377
  DeduceAutoType(TypeSourceInfo *AutoType, Expr *&Initializer, QualType &Result,
7378
                 Optional<unsigned> DependentDeductionDepth = None);
7379
  DeduceAutoResult
7380
  DeduceAutoType(TypeLoc AutoTypeLoc, Expr *&Initializer, QualType &Result,
7381
                 Optional<unsigned> DependentDeductionDepth = None);
7382
  void DiagnoseAutoDeductionFailure(VarDecl *VDecl, Expr *Init);
7383
  bool DeduceReturnType(FunctionDecl *FD, SourceLocation Loc,
7384
                        bool Diagnose = true);
7385
7386
  /// Declare implicit deduction guides for a class template if we've
7387
  /// not already done so.
7388
  void DeclareImplicitDeductionGuides(TemplateDecl *Template,
7389
                                      SourceLocation Loc);
7390
7391
  QualType DeduceTemplateSpecializationFromInitializer(
7392
      TypeSourceInfo *TInfo, const InitializedEntity &Entity,
7393
      const InitializationKind &Kind, MultiExprArg Init);
7394
7395
  QualType deduceVarTypeFromInitializer(VarDecl *VDecl, DeclarationName Name,
7396
                                        QualType Type, TypeSourceInfo *TSI,
7397
                                        SourceRange Range, bool DirectInit,
7398
                                        Expr *Init);
7399
7400
  TypeLoc getReturnTypeLoc(FunctionDecl *FD) const;
7401
7402
  bool DeduceFunctionTypeFromReturnExpr(FunctionDecl *FD,
7403
                                        SourceLocation ReturnLoc,
7404
                                        Expr *&RetExpr, AutoType *AT);
7405
7406
  FunctionTemplateDecl *getMoreSpecializedTemplate(FunctionTemplateDecl *FT1,
7407
                                                   FunctionTemplateDecl *FT2,
7408
                                                   SourceLocation Loc,
7409
                                           TemplatePartialOrderingContext TPOC,
7410
                                                   unsigned NumCallArguments1,
7411
                                                   unsigned NumCallArguments2);
7412
  UnresolvedSetIterator
7413
  getMostSpecialized(UnresolvedSetIterator SBegin, UnresolvedSetIterator SEnd,
7414
                     TemplateSpecCandidateSet &FailedCandidates,
7415
                     SourceLocation Loc,
7416
                     const PartialDiagnostic &NoneDiag,
7417
                     const PartialDiagnostic &AmbigDiag,
7418
                     const PartialDiagnostic &CandidateDiag,
7419
                     bool Complain = true, QualType TargetType = QualType());
7420
7421
  ClassTemplatePartialSpecializationDecl *
7422
  getMoreSpecializedPartialSpecialization(
7423
                                  ClassTemplatePartialSpecializationDecl *PS1,
7424
                                  ClassTemplatePartialSpecializationDecl *PS2,
7425
                                  SourceLocation Loc);
7426
7427
  bool isMoreSpecializedThanPrimary(ClassTemplatePartialSpecializationDecl *T,
7428
                                    sema::TemplateDeductionInfo &Info);
7429
7430
  VarTemplatePartialSpecializationDecl *getMoreSpecializedPartialSpecialization(
7431
      VarTemplatePartialSpecializationDecl *PS1,
7432
      VarTemplatePartialSpecializationDecl *PS2, SourceLocation Loc);
7433
7434
  bool isMoreSpecializedThanPrimary(VarTemplatePartialSpecializationDecl *T,
7435
                                    sema::TemplateDeductionInfo &Info);
7436
7437
  bool isTemplateTemplateParameterAtLeastAsSpecializedAs(
7438
      TemplateParameterList *P, TemplateDecl *AArg, SourceLocation Loc);
7439
7440
  void MarkUsedTemplateParameters(const TemplateArgumentList &TemplateArgs,
7441
                                  bool OnlyDeduced,
7442
                                  unsigned Depth,
7443
                                  llvm::SmallBitVector &Used);
7444
  void MarkDeducedTemplateParameters(
7445
                                  const FunctionTemplateDecl *FunctionTemplate,
7446
54
                                  llvm::SmallBitVector &Deduced) {
7447
54
    return MarkDeducedTemplateParameters(Context, FunctionTemplate, Deduced);
7448
54
  }
7449
  static void MarkDeducedTemplateParameters(ASTContext &Ctx,
7450
                                  const FunctionTemplateDecl *FunctionTemplate,
7451
                                  llvm::SmallBitVector &Deduced);
7452
7453
  //===--------------------------------------------------------------------===//
7454
  // C++ Template Instantiation
7455
  //
7456
7457
  MultiLevelTemplateArgumentList
7458
  getTemplateInstantiationArgs(NamedDecl *D,
7459
                               const TemplateArgumentList *Innermost = nullptr,
7460
                               bool RelativeToPrimary = false,
7461
                               const FunctionDecl *Pattern = nullptr);
7462
7463
  /// A context in which code is being synthesized (where a source location
7464
  /// alone is not sufficient to identify the context). This covers template
7465
  /// instantiation and various forms of implicitly-generated functions.
7466
  struct CodeSynthesisContext {
7467
    /// The kind of template instantiation we are performing
7468
    enum SynthesisKind {
7469
      /// We are instantiating a template declaration. The entity is
7470
      /// the declaration we're instantiating (e.g., a CXXRecordDecl).
7471
      TemplateInstantiation,
7472
7473
      /// We are instantiating a default argument for a template
7474
      /// parameter. The Entity is the template parameter whose argument is
7475
      /// being instantiated, the Template is the template, and the
7476
      /// TemplateArgs/NumTemplateArguments provide the template arguments as
7477
      /// specified.
7478
      DefaultTemplateArgumentInstantiation,
7479
7480
      /// We are instantiating a default argument for a function.
7481
      /// The Entity is the ParmVarDecl, and TemplateArgs/NumTemplateArgs
7482
      /// provides the template arguments as specified.
7483
      DefaultFunctionArgumentInstantiation,
7484
7485
      /// We are substituting explicit template arguments provided for
7486
      /// a function template. The entity is a FunctionTemplateDecl.
7487
      ExplicitTemplateArgumentSubstitution,
7488
7489
      /// We are substituting template argument determined as part of
7490
      /// template argument deduction for either a class template
7491
      /// partial specialization or a function template. The
7492
      /// Entity is either a {Class|Var}TemplatePartialSpecializationDecl or
7493
      /// a TemplateDecl.
7494
      DeducedTemplateArgumentSubstitution,
7495
7496
      /// We are substituting prior template arguments into a new
7497
      /// template parameter. The template parameter itself is either a
7498
      /// NonTypeTemplateParmDecl or a TemplateTemplateParmDecl.
7499
      PriorTemplateArgumentSubstitution,
7500
7501
      /// We are checking the validity of a default template argument that
7502
      /// has been used when naming a template-id.
7503
      DefaultTemplateArgumentChecking,
7504
7505
      /// We are computing the exception specification for a defaulted special
7506
      /// member function.
7507
      ExceptionSpecEvaluation,
7508
7509
      /// We are instantiating the exception specification for a function
7510
      /// template which was deferred until it was needed.
7511
      ExceptionSpecInstantiation,
7512
7513
      /// We are declaring an implicit special member function.
7514
      DeclaringSpecialMember,
7515
7516
      /// We are defining a synthesized function (such as a defaulted special
7517
      /// member).
7518
      DefiningSynthesizedFunction,
7519
7520
      /// Added for Template instantiation observation.
7521
      /// Memoization means we are _not_ instantiating a template because
7522
      /// it is already instantiated (but we entered a context where we
7523
      /// would have had to if it was not already instantiated).
7524
      Memoization
7525
    } Kind;
7526
7527
    /// Was the enclosing context a non-instantiation SFINAE context?
7528
    bool SavedInNonInstantiationSFINAEContext;
7529
7530
    /// The point of instantiation or synthesis within the source code.
7531
    SourceLocation PointOfInstantiation;
7532
7533
    /// The entity that is being synthesized.
7534
    Decl *Entity;
7535
7536
    /// The template (or partial specialization) in which we are
7537
    /// performing the instantiation, for substitutions of prior template
7538
    /// arguments.
7539
    NamedDecl *Template;
7540
7541
    /// The list of template arguments we are substituting, if they
7542
    /// are not part of the entity.
7543
    const TemplateArgument *TemplateArgs;
7544
7545
    // FIXME: Wrap this union around more members, or perhaps store the
7546
    // kind-specific members in the RAII object owning the context.
7547
    union {
7548
      /// The number of template arguments in TemplateArgs.
7549
      unsigned NumTemplateArgs;
7550
7551
      /// The special member being declared or defined.
7552
      CXXSpecialMember SpecialMember;
7553
    };
7554
7555
113
    ArrayRef<TemplateArgument> template_arguments() const {
7556
113
      assert(Kind != DeclaringSpecialMember);
7557
113
      return {TemplateArgs, NumTemplateArgs};
7558
113
    }
7559
7560
    /// The template deduction info object associated with the
7561
    /// substitution or checking of explicit or deduced template arguments.
7562
    sema::TemplateDeductionInfo *DeductionInfo;
7563
7564
    /// The source range that covers the construct that cause
7565
    /// the instantiation, e.g., the template-id that causes a class
7566
    /// template instantiation.
7567
    SourceRange InstantiationRange;
7568
7569
    CodeSynthesisContext()
7570
        : Kind(TemplateInstantiation),
7571
          SavedInNonInstantiationSFINAEContext(false), Entity(nullptr),
7572
          Template(nullptr), TemplateArgs(nullptr), NumTemplateArgs(0),
7573
7.81M
          DeductionInfo(nullptr) {}
7574
7575
    /// Determines whether this template is an actual instantiation
7576
    /// that should be counted toward the maximum instantiation depth.
7577
    bool isInstantiationRecord() const;
7578
  };
7579
7580
  /// List of active code synthesis contexts.
7581
  ///
7582
  /// This vector is treated as a stack. As synthesis of one entity requires
7583
  /// synthesis of another, additional contexts are pushed onto the stack.
7584
  SmallVector<CodeSynthesisContext, 16> CodeSynthesisContexts;
7585
7586
  /// Specializations whose definitions are currently being instantiated.
7587
  llvm::DenseSet<std::pair<Decl *, unsigned>> InstantiatingSpecializations;
7588
7589
  /// Non-dependent types used in templates that have already been instantiated
7590
  /// by some template instantiation.
7591
  llvm::DenseSet<QualType> InstantiatedNonDependentTypes;
7592
7593
  /// Extra modules inspected when performing a lookup during a template
7594
  /// instantiation. Computed lazily.
7595
  SmallVector<Module*, 16> CodeSynthesisContextLookupModules;
7596
7597
  /// Cache of additional modules that should be used for name lookup
7598
  /// within the current template instantiation. Computed lazily; use
7599
  /// getLookupModules() to get a complete set.
7600
  llvm::DenseSet<Module*> LookupModulesCache;
7601
7602
  /// Get the set of additional modules that should be checked during
7603
  /// name lookup. A module and its imports become visible when instanting a
7604
  /// template defined within it.
7605
  llvm::DenseSet<Module*> &getLookupModules();
7606
7607
  /// Map from the most recent declaration of a namespace to the most
7608
  /// recent visible declaration of that namespace.
7609
  llvm::DenseMap<NamedDecl*, NamedDecl*> VisibleNamespaceCache;
7610
7611
  /// Whether we are in a SFINAE context that is not associated with
7612
  /// template instantiation.
7613
  ///
7614
  /// This is used when setting up a SFINAE trap (\c see SFINAETrap) outside
7615
  /// of a template instantiation or template argument deduction.
7616
  bool InNonInstantiationSFINAEContext;
7617
7618
  /// The number of \p CodeSynthesisContexts that are not template
7619
  /// instantiations and, therefore, should not be counted as part of the
7620
  /// instantiation depth.
7621
  ///
7622
  /// When the instantiation depth reaches the user-configurable limit
7623
  /// \p LangOptions::InstantiationDepth we will abort instantiation.
7624
  // FIXME: Should we have a similar limit for other forms of synthesis?
7625
  unsigned NonInstantiationEntries;
7626
7627
  /// The depth of the context stack at the point when the most recent
7628
  /// error or warning was produced.
7629
  ///
7630
  /// This value is used to suppress printing of redundant context stacks
7631
  /// when there are multiple errors or warnings in the same instantiation.
7632
  // FIXME: Does this belong in Sema? It's tough to implement it anywhere else.
7633
  unsigned LastEmittedCodeSynthesisContextDepth = 0;
7634
7635
  /// The template instantiation callbacks to trace or track
7636
  /// instantiations (objects can be chained).
7637
  ///
7638
  /// This callbacks is used to print, trace or track template
7639
  /// instantiations as they are being constructed.
7640
  std::vector<std::unique_ptr<TemplateInstantiationCallback>>
7641
      TemplateInstCallbacks;
7642
7643
  /// The current index into pack expansion arguments that will be
7644
  /// used for substitution of parameter packs.
7645
  ///
7646
  /// The pack expansion index will be -1 to indicate that parameter packs
7647
  /// should be instantiated as themselves. Otherwise, the index specifies
7648
  /// which argument within the parameter pack will be used for substitution.
7649
  int ArgumentPackSubstitutionIndex;
7650
7651
  /// RAII object used to change the argument pack substitution index
7652
  /// within a \c Sema object.
7653
  ///
7654
  /// See \c ArgumentPackSubstitutionIndex for more information.
7655
  class ArgumentPackSubstitutionIndexRAII {
7656
    Sema &Self;
7657
    int OldSubstitutionIndex;
7658
7659
  public:
7660
    ArgumentPackSubstitutionIndexRAII(Sema &Self, int NewSubstitutionIndex)
7661
2.48M
      : Self(Self), OldSubstitutionIndex(Self.ArgumentPackSubstitutionIndex) {
7662
2.48M
      Self.ArgumentPackSubstitutionIndex = NewSubstitutionIndex;
7663
2.48M
    }
7664
7665
2.48M
    ~ArgumentPackSubstitutionIndexRAII() {
7666
2.48M
      Self.ArgumentPackSubstitutionIndex = OldSubstitutionIndex;
7667
2.48M
    }
7668
  };
7669
7670
  friend class ArgumentPackSubstitutionRAII;
7671
7672
  /// For each declaration that involved template argument deduction, the
7673
  /// set of diagnostics that were suppressed during that template argument
7674
  /// deduction.
7675
  ///
7676
  /// FIXME: Serialize this structure to the AST file.
7677
  typedef llvm::DenseMap<Decl *, SmallVector<PartialDiagnosticAt, 1> >
7678
    SuppressedDiagnosticsMap;
7679
  SuppressedDiagnosticsMap SuppressedDiagnostics;
7680
7681
  /// A stack object to be created when performing template
7682
  /// instantiation.
7683
  ///
7684
  /// Construction of an object of type \c InstantiatingTemplate
7685
  /// pushes the current instantiation onto the stack of active
7686
  /// instantiations. If the size of this stack exceeds the maximum
7687
  /// number of recursive template instantiations, construction
7688
  /// produces an error and evaluates true.
7689
  ///
7690
  /// Destruction of this object will pop the named instantiation off
7691
  /// the stack.
7692
  struct InstantiatingTemplate {
7693
    /// Note that we are instantiating a class template,
7694
    /// function template, variable template, alias template,
7695
    /// or a member thereof.
7696
    InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
7697
                          Decl *Entity,
7698
                          SourceRange InstantiationRange = SourceRange());
7699
7700
    struct ExceptionSpecification {};
7701
    /// Note that we are instantiating an exception specification
7702
    /// of a function template.
7703
    InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
7704
                          FunctionDecl *Entity, ExceptionSpecification,
7705
                          SourceRange InstantiationRange = SourceRange());
7706
7707
    /// Note that we are instantiating a default argument in a
7708
    /// template-id.
7709
    InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
7710
                          TemplateParameter Param, TemplateDecl *Template,
7711
                          ArrayRef<TemplateArgument> TemplateArgs,
7712
                          SourceRange InstantiationRange = SourceRange());
7713
7714
    /// Note that we are substituting either explicitly-specified or
7715
    /// deduced template arguments during function template argument deduction.
7716
    InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
7717
                          FunctionTemplateDecl *FunctionTemplate,
7718
                          ArrayRef<TemplateArgument> TemplateArgs,
7719
                          CodeSynthesisContext::SynthesisKind Kind,
7720
                          sema::TemplateDeductionInfo &DeductionInfo,
7721
                          SourceRange InstantiationRange = SourceRange());
7722
7723
    /// Note that we are instantiating as part of template
7724
    /// argument deduction for a class template declaration.
7725
    InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
7726
                          TemplateDecl *Template,
7727
                          ArrayRef<TemplateArgument> TemplateArgs,
7728
                          sema::TemplateDeductionInfo &DeductionInfo,
7729
                          SourceRange InstantiationRange = SourceRange());
7730
7731
    /// Note that we are instantiating as part of template
7732
    /// argument deduction for a class template partial
7733
    /// specialization.
7734
    InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
7735
                          ClassTemplatePartialSpecializationDecl *PartialSpec,
7736
                          ArrayRef<TemplateArgument> TemplateArgs,
7737
                          sema::TemplateDeductionInfo &DeductionInfo,
7738
                          SourceRange InstantiationRange = SourceRange());
7739
7740
    /// Note that we are instantiating as part of template
7741
    /// argument deduction for a variable template partial
7742
    /// specialization.
7743
    InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
7744
                          VarTemplatePartialSpecializationDecl *PartialSpec,
7745
                          ArrayRef<TemplateArgument> TemplateArgs,
7746
                          sema::TemplateDeductionInfo &DeductionInfo,
7747
                          SourceRange InstantiationRange = SourceRange());
7748
7749
    /// Note that we are instantiating a default argument for a function
7750
    /// parameter.
7751
    InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
7752
                          ParmVarDecl *Param,
7753
                          ArrayRef<TemplateArgument> TemplateArgs,
7754
                          SourceRange InstantiationRange = SourceRange());
7755
7756
    /// Note that we are substituting prior template arguments into a
7757
    /// non-type parameter.
7758
    InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
7759
                          NamedDecl *Template,
7760
                          NonTypeTemplateParmDecl *Param,
7761
                          ArrayRef<TemplateArgument> TemplateArgs,
7762
                          SourceRange InstantiationRange);
7763
7764
    /// Note that we are substituting prior template arguments into a
7765
    /// template template parameter.
7766
    InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
7767
                          NamedDecl *Template,
7768
                          TemplateTemplateParmDecl *Param,
7769
                          ArrayRef<TemplateArgument> TemplateArgs,
7770
                          SourceRange InstantiationRange);
7771
7772
    /// Note that we are checking the default template argument
7773
    /// against the template parameter for a given template-id.
7774
    InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
7775
                          TemplateDecl *Template,
7776
                          NamedDecl *Param,
7777
                          ArrayRef<TemplateArgument> TemplateArgs,
7778
                          SourceRange InstantiationRange);
7779
7780
7781
    /// Note that we have finished instantiating this template.
7782
    void Clear();
7783
7784
6.83M
    ~InstantiatingTemplate() { Clear(); }
7785
7786
    /// Determines whether we have exceeded the maximum
7787
    /// recursive template instantiations.
7788
6.64M
    bool isInvalid() const { return Invalid; }
7789
7790
    /// Determine whether we are already instantiating this
7791
    /// specialization in some surrounding active instantiation.
7792
1.46M
    bool isAlreadyInstantiating() const { return AlreadyInstantiating; }
7793
7794
  private:
7795
    Sema &SemaRef;
7796
    bool Invalid;
7797
    bool AlreadyInstantiating;
7798
    bool CheckInstantiationDepth(SourceLocation PointOfInstantiation,
7799
                                 SourceRange InstantiationRange);
7800
7801
    InstantiatingTemplate(
7802
        Sema &SemaRef, CodeSynthesisContext::SynthesisKind Kind,
7803
        SourceLocation PointOfInstantiation, SourceRange InstantiationRange,
7804
        Decl *Entity, NamedDecl *Template = nullptr,
7805
        ArrayRef<TemplateArgument> TemplateArgs = None,
7806
        sema::TemplateDeductionInfo *DeductionInfo = nullptr);
7807
7808
    InstantiatingTemplate(const InstantiatingTemplate&) = delete;
7809
7810
    InstantiatingTemplate&
7811
    operator=(const InstantiatingTemplate&) = delete;
7812
  };
7813
7814
  void pushCodeSynthesisContext(CodeSynthesisContext Ctx);
7815
  void popCodeSynthesisContext();
7816
7817
  /// Determine whether we are currently performing template instantiation.
7818
28.3M
  bool inTemplateInstantiation() const {
7819
28.3M
    return CodeSynthesisContexts.size() > NonInstantiationEntries;
7820
28.3M
  }
7821
7822
107k
  void PrintContextStack() {
7823
107k
    if (!CodeSynthesisContexts.empty() &&
7824
107k
        
CodeSynthesisContexts.size() != LastEmittedCodeSynthesisContextDepth14.2k
) {
7825
4.13k
      PrintInstantiationStack();
7826
4.13k
      LastEmittedCodeSynthesisContextDepth = CodeSynthesisContexts.size();
7827
4.13k
    }
7828
107k
    if (PragmaAttributeCurrentTargetDecl)
7829
22
      PrintPragmaAttributeInstantiationPoint();
7830
107k
  }
7831
  void PrintInstantiationStack();
7832
7833
  void PrintPragmaAttributeInstantiationPoint();
7834
7835
  /// Determines whether we are currently in a context where
7836
  /// template argument substitution failures are not considered
7837
  /// errors.
7838
  ///
7839
  /// \returns An empty \c Optional if we're not in a SFINAE context.
7840
  /// Otherwise, contains a pointer that, if non-NULL, contains the nearest
7841
  /// template-deduction context object, which can be used to capture
7842
  /// diagnostics that will be suppressed.
7843
  Optional<sema::TemplateDeductionInfo *> isSFINAEContext() const;
7844
7845
  /// Determines whether we are currently in a context that
7846
  /// is not evaluated as per C++ [expr] p5.
7847
60.4M
  bool isUnevaluatedContext() const {
7848
60.4M
    assert(!ExprEvalContexts.empty() &&
7849
60.4M
           "Must be in an expression evaluation context");
7850
60.4M
    return ExprEvalContexts.back().isUnevaluated();
7851
60.4M
  }
7852
7853
  /// RAII class used to determine whether SFINAE has
7854
  /// trapped any errors that occur during template argument
7855
  /// deduction.
7856
  class SFINAETrap {
7857
    Sema &SemaRef;
7858
    unsigned PrevSFINAEErrors;
7859
    bool PrevInNonInstantiationSFINAEContext;
7860
    bool PrevAccessCheckingSFINAE;
7861
    bool PrevLastDiagnosticIgnored;
7862
7863
  public:
7864
    explicit SFINAETrap(Sema &SemaRef, bool AccessCheckingSFINAE = false)
7865
      : SemaRef(SemaRef), PrevSFINAEErrors(SemaRef.NumSFINAEErrors),
7866
        PrevInNonInstantiationSFINAEContext(
7867
                                      SemaRef.InNonInstantiationSFINAEContext),
7868
        PrevAccessCheckingSFINAE(SemaRef.AccessCheckingSFINAE),
7869
        PrevLastDiagnosticIgnored(
7870
            SemaRef.getDiagnostics().isLastDiagnosticIgnored())
7871
2.63M
    {
7872
2.63M
      if (!SemaRef.isSFINAEContext())
7873
1.83M
        SemaRef.InNonInstantiationSFINAEContext = true;
7874
2.63M
      SemaRef.AccessCheckingSFINAE = AccessCheckingSFINAE;
7875
2.63M
    }
7876
7877
2.63M
    ~SFINAETrap() {
7878
2.63M
      SemaRef.NumSFINAEErrors = PrevSFINAEErrors;
7879
2.63M
      SemaRef.InNonInstantiationSFINAEContext
7880
2.63M
        = PrevInNonInstantiationSFINAEContext;
7881
2.63M
      SemaRef.AccessCheckingSFINAE = PrevAccessCheckingSFINAE;
7882
2.63M
      SemaRef.getDiagnostics().setLastDiagnosticIgnored(
7883
2.63M
          PrevLastDiagnosticIgnored);
7884
2.63M
    }
7885
7886
    /// Determine whether any SFINAE errors have been trapped.
7887
2.02M
    bool hasErrorOccurred() const {
7888
2.02M
      return SemaRef.NumSFINAEErrors > PrevSFINAEErrors;
7889
2.02M
    }
7890
  };
7891
7892
  /// RAII class used to indicate that we are performing provisional
7893
  /// semantic analysis to determine the validity of a construct, so
7894
  /// typo-correction and diagnostics in the immediate context (not within
7895
  /// implicitly-instantiated templates) should be suppressed.
7896
  class TentativeAnalysisScope {
7897
    Sema &SemaRef;
7898
    // FIXME: Using a SFINAETrap for this is a hack.
7899
    SFINAETrap Trap;
7900
    bool PrevDisableTypoCorrection;
7901
  public:
7902
    explicit TentativeAnalysisScope(Sema &SemaRef)
7903
        : SemaRef(SemaRef), Trap(SemaRef, true),
7904
985
          PrevDisableTypoCorrection(SemaRef.DisableTypoCorrection) {
7905
985
      SemaRef.DisableTypoCorrection = true;
7906
985
    }
7907
985
    ~TentativeAnalysisScope() {
7908
985
      SemaRef.DisableTypoCorrection = PrevDisableTypoCorrection;
7909
985
    }
7910
  };
7911
7912
  /// The current instantiation scope used to store local
7913
  /// variables.
7914
  LocalInstantiationScope *CurrentInstantiationScope;
7915
7916
  /// Tracks whether we are in a context where typo correction is
7917
  /// disabled.
7918
  bool DisableTypoCorrection;
7919
7920
  /// The number of typos corrected by CorrectTypo.
7921
  unsigned TyposCorrected;
7922
7923
  typedef llvm::SmallSet<SourceLocation, 2> SrcLocSet;
7924
  typedef llvm::DenseMap<IdentifierInfo *, SrcLocSet> IdentifierSourceLocations;
7925
7926
  /// A cache containing identifiers for which typo correction failed and
7927
  /// their locations, so that repeated attempts to correct an identifier in a
7928
  /// given location are ignored if typo correction already failed for it.
7929
  IdentifierSourceLocations TypoCorrectionFailures;
7930
7931
  /// Worker object for performing CFG-based warnings.
7932
  sema::AnalysisBasedWarnings AnalysisWarnings;
7933
  threadSafety::BeforeSet *ThreadSafetyDeclCache;
7934
7935
  /// An entity for which implicit template instantiation is required.
7936
  ///
7937
  /// The source location associated with the declaration is the first place in
7938
  /// the source code where the declaration was "used". It is not necessarily
7939
  /// the point of instantiation (which will be either before or after the
7940
  /// namespace-scope declaration that triggered this implicit instantiation),
7941
  /// However, it is the location that diagnostics should generally refer to,
7942
  /// because users will need to know what code triggered the instantiation.
7943
  typedef std::pair<ValueDecl *, SourceLocation> PendingImplicitInstantiation;
7944
7945
  /// The queue of implicit template instantiations that are required
7946
  /// but have not yet been performed.
7947
  std::deque<PendingImplicitInstantiation> PendingInstantiations;
7948
7949
  /// Queue of implicit template instantiations that cannot be performed
7950
  /// eagerly.
7951
  SmallVector<PendingImplicitInstantiation, 1> LateParsedInstantiations;
7952
7953
  class GlobalEagerInstantiationScope {
7954
  public:
7955
    GlobalEagerInstantiationScope(Sema &S, bool Enabled)
7956
327k
        : S(S), Enabled(Enabled) {
7957
327k
      if (!Enabled) 
return56.9k
;
7958
271k
7959
271k
      SavedPendingInstantiations.swap(S.PendingInstantiations);
7960
271k
      SavedVTableUses.swap(S.VTableUses);
7961
271k
    }
7962
7963
327k
    void perform() {
7964
327k
      if (Enabled) {
7965
270k
        S.DefineUsedVTables();
7966
270k
        S.PerformPendingInstantiations();
7967
270k
      }
7968
327k
    }
7969
7970
327k
    ~GlobalEagerInstantiationScope() {
7971
327k
      if (!Enabled) 
return56.9k
;
7972
271k
7973
271k
      // Restore the set of pending vtables.
7974
271k
      assert(S.VTableUses.empty() &&
7975
271k
             "VTableUses should be empty before it is discarded.");
7976
271k
      S.VTableUses.swap(SavedVTableUses);
7977
271k
7978
271k
      // Restore the set of pending implicit instantiations.
7979
271k
      assert(S.PendingInstantiations.empty() &&
7980
271k
             "PendingInstantiations should be empty before it is discarded.");
7981
271k
      S.PendingInstantiations.swap(SavedPendingInstantiations);
7982
271k
    }
7983
7984
  private:
7985
    Sema &S;
7986
    SmallVector<VTableUse, 16> SavedVTableUses;
7987
    std::deque<PendingImplicitInstantiation> SavedPendingInstantiations;
7988
    bool Enabled;
7989
  };
7990
7991
  /// The queue of implicit template instantiations that are required
7992
  /// and must be performed within the current local scope.
7993
  ///
7994
  /// This queue is only used for member functions of local classes in
7995
  /// templates, which must be instantiated in the same scope as their
7996
  /// enclosing function, so that they can reference function-local
7997
  /// types, static variables, enumerators, etc.
7998
  std::deque<PendingImplicitInstantiation> PendingLocalImplicitInstantiations;
7999
8000
  class LocalEagerInstantiationScope {
8001
  public:
8002
329k
    LocalEagerInstantiationScope(Sema &S) : S(S) {
8003
329k
      SavedPendingLocalImplicitInstantiations.swap(
8004
329k
          S.PendingLocalImplicitInstantiations);
8005
329k
    }
8006
8007
329k
    void perform() { S.PerformPendingInstantiations(/*LocalOnly=*/true); }
8008
8009
329k
    ~LocalEagerInstantiationScope() {
8010
329k
      assert(S.PendingLocalImplicitInstantiations.empty() &&
8011
329k
             "there shouldn't be any pending local implicit instantiations");
8012
329k
      SavedPendingLocalImplicitInstantiations.swap(
8013
329k
          S.PendingLocalImplicitInstantiations);
8014
329k
    }
8015
8016
  private:
8017
    Sema &S;
8018
    std::deque<PendingImplicitInstantiation>
8019
        SavedPendingLocalImplicitInstantiations;
8020
  };
8021
8022
  /// A helper class for building up ExtParameterInfos.
8023
  class ExtParameterInfoBuilder {
8024
    SmallVector<FunctionProtoType::ExtParameterInfo, 16> Infos;
8025
    bool HasInteresting = false;
8026
8027
  public:
8028
    /// Set the ExtParameterInfo for the parameter at the given index,
8029
    ///
8030
160
    void set(unsigned index, FunctionProtoType::ExtParameterInfo info) {
8031
160
      assert(Infos.size() <= index);
8032
160
      Infos.resize(index);
8033
160
      Infos.push_back(info);
8034
160
8035
160
      if (!HasInteresting)
8036
108
        HasInteresting = (info != FunctionProtoType::ExtParameterInfo());
8037
160
    }
8038
8039
    /// Return a pointer (suitable for setting in an ExtProtoInfo) to the
8040
    /// ExtParameterInfo array we've built up.
8041
    const FunctionProtoType::ExtParameterInfo *
8042
1.58M
    getPointerOrNull(unsigned numParams) {
8043
1.58M
      if (!HasInteresting) 
return nullptr1.58M
;
8044
83
      Infos.resize(numParams);
8045
83
      return Infos.data();
8046
83
    }
8047
  };
8048
8049
  void PerformPendingInstantiations(bool LocalOnly = false);
8050
8051
  TypeSourceInfo *SubstType(TypeSourceInfo *T,
8052
                            const MultiLevelTemplateArgumentList &TemplateArgs,
8053
                            SourceLocation Loc, DeclarationName Entity,
8054
                            bool AllowDeducedTST = false);
8055
8056
  QualType SubstType(QualType T,
8057
                     const MultiLevelTemplateArgumentList &TemplateArgs,
8058
                     SourceLocation Loc, DeclarationName Entity);
8059
8060
  TypeSourceInfo *SubstType(TypeLoc TL,
8061
                            const MultiLevelTemplateArgumentList &TemplateArgs,
8062
                            SourceLocation Loc, DeclarationName Entity);
8063
8064
  TypeSourceInfo *SubstFunctionDeclType(TypeSourceInfo *T,
8065
                            const MultiLevelTemplateArgumentList &TemplateArgs,
8066
                                        SourceLocation Loc,
8067
                                        DeclarationName Entity,
8068
                                        CXXRecordDecl *ThisContext,
8069
                                        Qualifiers ThisTypeQuals);
8070
  void SubstExceptionSpec(FunctionDecl *New, const FunctionProtoType *Proto,
8071
                          const MultiLevelTemplateArgumentList &Args);
8072
  bool SubstExceptionSpec(SourceLocation Loc,
8073
                          FunctionProtoType::ExceptionSpecInfo &ESI,
8074
                          SmallVectorImpl<QualType> &ExceptionStorage,
8075
                          const MultiLevelTemplateArgumentList &Args);
8076
  ParmVarDecl *SubstParmVarDecl(ParmVarDecl *D,
8077
                            const MultiLevelTemplateArgumentList &TemplateArgs,
8078
                                int indexAdjustment,
8079
                                Optional<unsigned> NumExpansions,
8080
                                bool ExpectParameterPack);
8081
  bool SubstParmTypes(SourceLocation Loc, ArrayRef<ParmVarDecl *> Params,
8082
                      const FunctionProtoType::ExtParameterInfo *ExtParamInfos,
8083
                      const MultiLevelTemplateArgumentList &TemplateArgs,
8084
                      SmallVectorImpl<QualType> &ParamTypes,
8085
                      SmallVectorImpl<ParmVarDecl *> *OutParams,
8086
                      ExtParameterInfoBuilder &ParamInfos);
8087
  ExprResult SubstExpr(Expr *E,
8088
                       const MultiLevelTemplateArgumentList &TemplateArgs);
8089
8090
  /// Substitute the given template arguments into a list of
8091
  /// expressions, expanding pack expansions if required.
8092
  ///
8093
  /// \param Exprs The list of expressions to substitute into.
8094
  ///
8095
  /// \param IsCall Whether this is some form of call, in which case
8096
  /// default arguments will be dropped.
8097
  ///
8098
  /// \param TemplateArgs The set of template arguments to substitute.
8099
  ///
8100
  /// \param Outputs Will receive all of the substituted arguments.
8101
  ///
8102
  /// \returns true if an error occurred, false otherwise.
8103
  bool SubstExprs(ArrayRef<Expr *> Exprs, bool IsCall,
8104
                  const MultiLevelTemplateArgumentList &TemplateArgs,
8105
                  SmallVectorImpl<Expr *> &Outputs);
8106
8107
  StmtResult SubstStmt(Stmt *S,
8108
                       const MultiLevelTemplateArgumentList &TemplateArgs);
8109
8110
  TemplateParameterList *
8111
  SubstTemplateParams(TemplateParameterList *Params, DeclContext *Owner,
8112
                      const MultiLevelTemplateArgumentList &TemplateArgs);
8113
8114
  Decl *SubstDecl(Decl *D, DeclContext *Owner,
8115
                  const MultiLevelTemplateArgumentList &TemplateArgs);
8116
8117
  ExprResult SubstInitializer(Expr *E,
8118
                       const MultiLevelTemplateArgumentList &TemplateArgs,
8119
                       bool CXXDirectInit);
8120
8121
  bool
8122
  SubstBaseSpecifiers(CXXRecordDecl *Instantiation,
8123
                      CXXRecordDecl *Pattern,
8124
                      const MultiLevelTemplateArgumentList &TemplateArgs);
8125
8126
  bool
8127
  InstantiateClass(SourceLocation PointOfInstantiation,
8128
                   CXXRecordDecl *Instantiation, CXXRecordDecl *Pattern,
8129
                   const MultiLevelTemplateArgumentList &TemplateArgs,
8130
                   TemplateSpecializationKind TSK,
8131
                   bool Complain = true);
8132
8133
  bool InstantiateEnum(SourceLocation PointOfInstantiation,
8134
                       EnumDecl *Instantiation, EnumDecl *Pattern,
8135
                       const MultiLevelTemplateArgumentList &TemplateArgs,
8136
                       TemplateSpecializationKind TSK);
8137
8138
  bool InstantiateInClassInitializer(
8139
      SourceLocation PointOfInstantiation, FieldDecl *Instantiation,
8140
      FieldDecl *Pattern, const MultiLevelTemplateArgumentList &TemplateArgs);
8141
8142
  struct LateInstantiatedAttribute {
8143
    const Attr *TmplAttr;
8144
    LocalInstantiationScope *Scope;
8145
    Decl *NewDecl;
8146
8147
    LateInstantiatedAttribute(const Attr *A, LocalInstantiationScope *S,
8148
                              Decl *D)
8149
      : TmplAttr(A), Scope(S), NewDecl(D)
8150
82
    { }
8151
  };
8152
  typedef SmallVector<LateInstantiatedAttribute, 16> LateInstantiatedAttrVec;
8153
8154
  void InstantiateAttrs(const MultiLevelTemplateArgumentList &TemplateArgs,
8155
                        const Decl *Pattern, Decl *Inst,
8156
                        LateInstantiatedAttrVec *LateAttrs = nullptr,
8157
                        LocalInstantiationScope *OuterMostScope = nullptr);
8158
8159
  void
8160
  InstantiateAttrsForDecl(const MultiLevelTemplateArgumentList &TemplateArgs,
8161
                          const Decl *Pattern, Decl *Inst,
8162
                          LateInstantiatedAttrVec *LateAttrs = nullptr,
8163
                          LocalInstantiationScope *OuterMostScope = nullptr);
8164
8165
  bool usesPartialOrExplicitSpecialization(
8166
      SourceLocation Loc, ClassTemplateSpecializationDecl *ClassTemplateSpec);
8167
8168
  bool
8169
  InstantiateClassTemplateSpecialization(SourceLocation PointOfInstantiation,
8170
                           ClassTemplateSpecializationDecl *ClassTemplateSpec,
8171
                           TemplateSpecializationKind TSK,
8172
                           bool Complain = true);
8173
8174
  void InstantiateClassMembers(SourceLocation PointOfInstantiation,
8175
                               CXXRecordDecl *Instantiation,
8176
                            const MultiLevelTemplateArgumentList &TemplateArgs,
8177
                               TemplateSpecializationKind TSK);
8178
8179
  void InstantiateClassTemplateSpecializationMembers(
8180
                                          SourceLocation PointOfInstantiation,
8181
                           ClassTemplateSpecializationDecl *ClassTemplateSpec,
8182
                                                TemplateSpecializationKind TSK);
8183
8184
  NestedNameSpecifierLoc
8185
  SubstNestedNameSpecifierLoc(NestedNameSpecifierLoc NNS,
8186
                           const MultiLevelTemplateArgumentList &TemplateArgs);
8187
8188
  DeclarationNameInfo
8189
  SubstDeclarationNameInfo(const DeclarationNameInfo &NameInfo,
8190
                           const MultiLevelTemplateArgumentList &TemplateArgs);
8191
  TemplateName
8192
  SubstTemplateName(NestedNameSpecifierLoc QualifierLoc, TemplateName Name,
8193
                    SourceLocation Loc,
8194
                    const MultiLevelTemplateArgumentList &TemplateArgs);
8195
  bool Subst(const TemplateArgumentLoc *Args, unsigned NumArgs,
8196
             TemplateArgumentListInfo &Result,
8197
             const MultiLevelTemplateArgumentList &TemplateArgs);
8198
8199
  void InstantiateExceptionSpec(SourceLocation PointOfInstantiation,
8200
                                FunctionDecl *Function);
8201
  FunctionDecl *InstantiateFunctionDeclaration(FunctionTemplateDecl *FTD,
8202
                                               const TemplateArgumentList *Args,
8203
                                               SourceLocation Loc);
8204
  void InstantiateFunctionDefinition(SourceLocation PointOfInstantiation,
8205
                                     FunctionDecl *Function,
8206
                                     bool Recursive = false,
8207
                                     bool DefinitionRequired = false,
8208
                                     bool AtEndOfTU = false);
8209
  VarTemplateSpecializationDecl *BuildVarTemplateInstantiation(
8210
      VarTemplateDecl *VarTemplate, VarDecl *FromVar,
8211
      const TemplateArgumentList &TemplateArgList,
8212
      const TemplateArgumentListInfo &TemplateArgsInfo,
8213
      SmallVectorImpl<TemplateArgument> &Converted,
8214
      SourceLocation PointOfInstantiation, void *InsertPos,
8215
      LateInstantiatedAttrVec *LateAttrs = nullptr,
8216
      LocalInstantiationScope *StartingScope = nullptr);
8217
  VarTemplateSpecializationDecl *CompleteVarTemplateSpecializationDecl(
8218
      VarTemplateSpecializationDecl *VarSpec, VarDecl *PatternDecl,
8219
      const MultiLevelTemplateArgumentList &TemplateArgs);
8220
  void
8221
  BuildVariableInstantiation(VarDecl *NewVar, VarDecl *OldVar,
8222
                             const MultiLevelTemplateArgumentList &TemplateArgs,
8223
                             LateInstantiatedAttrVec *LateAttrs,
8224
                             DeclContext *Owner,
8225
                             LocalInstantiationScope *StartingScope,
8226
                             bool InstantiatingVarTemplate = false,
8227
                             VarTemplateSpecializationDecl *PrevVTSD = nullptr);
8228
  void InstantiateVariableInitializer(
8229
      VarDecl *Var, VarDecl *OldVar,
8230
      const MultiLevelTemplateArgumentList &TemplateArgs);
8231
  void InstantiateVariableDefinition(SourceLocation PointOfInstantiation,
8232
                                     VarDecl *Var, bool Recursive = false,
8233
                                     bool DefinitionRequired = false,
8234
                                     bool AtEndOfTU = false);
8235
8236
  void InstantiateMemInitializers(CXXConstructorDecl *New,
8237
                                  const CXXConstructorDecl *Tmpl,
8238
                            const MultiLevelTemplateArgumentList &TemplateArgs);
8239
8240
  NamedDecl *FindInstantiatedDecl(SourceLocation Loc, NamedDecl *D,
8241
                          const MultiLevelTemplateArgumentList &TemplateArgs,
8242
                          bool FindingInstantiatedContext = false);
8243
  DeclContext *FindInstantiatedContext(SourceLocation Loc, DeclContext *DC,
8244
                          const MultiLevelTemplateArgumentList &TemplateArgs);
8245
8246
  // Objective-C declarations.
8247
  enum ObjCContainerKind {
8248
    OCK_None = -1,
8249
    OCK_Interface = 0,
8250
    OCK_Protocol,
8251
    OCK_Category,
8252
    OCK_ClassExtension,
8253
    OCK_Implementation,
8254
    OCK_CategoryImplementation
8255
  };
8256
  ObjCContainerKind getObjCContainerKind() const;
8257
8258
  DeclResult actOnObjCTypeParam(Scope *S,
8259
                                ObjCTypeParamVariance variance,
8260
                                SourceLocation varianceLoc,
8261
                                unsigned index,
8262
                                IdentifierInfo *paramName,
8263
                                SourceLocation paramLoc,
8264
                                SourceLocation colonLoc,
8265
                                ParsedType typeBound);
8266
8267
  ObjCTypeParamList *actOnObjCTypeParamList(Scope *S, SourceLocation lAngleLoc,
8268
                                            ArrayRef<Decl *> typeParams,
8269
                                            SourceLocation rAngleLoc);
8270
  void popObjCTypeParamList(Scope *S, ObjCTypeParamList *typeParamList);
8271
8272
  Decl *ActOnStartClassInterface(
8273
      Scope *S, SourceLocation AtInterfaceLoc, IdentifierInfo *ClassName,
8274
      SourceLocation ClassLoc, ObjCTypeParamList *typeParamList,
8275
      IdentifierInfo *SuperName, SourceLocation SuperLoc,
8276
      ArrayRef<ParsedType> SuperTypeArgs, SourceRange SuperTypeArgsRange,
8277
      Decl *const *ProtoRefs, unsigned NumProtoRefs,
8278
      const SourceLocation *ProtoLocs, SourceLocation EndProtoLoc,
8279
      const ParsedAttributesView &AttrList);
8280
8281
  void ActOnSuperClassOfClassInterface(Scope *S,
8282
                                       SourceLocation AtInterfaceLoc,
8283
                                       ObjCInterfaceDecl *IDecl,
8284
                                       IdentifierInfo *ClassName,
8285
                                       SourceLocation ClassLoc,
8286
                                       IdentifierInfo *SuperName,
8287
                                       SourceLocation SuperLoc,
8288
                                       ArrayRef<ParsedType> SuperTypeArgs,
8289
                                       SourceRange SuperTypeArgsRange);
8290
8291
  void ActOnTypedefedProtocols(SmallVectorImpl<Decl *> &ProtocolRefs,
8292
                               SmallVectorImpl<SourceLocation> &ProtocolLocs,
8293
                               IdentifierInfo *SuperName,
8294
                               SourceLocation SuperLoc);
8295
8296
  Decl *ActOnCompatibilityAlias(
8297
                    SourceLocation AtCompatibilityAliasLoc,
8298
                    IdentifierInfo *AliasName,  SourceLocation AliasLocation,
8299
                    IdentifierInfo *ClassName, SourceLocation ClassLocation);
8300
8301
  bool CheckForwardProtocolDeclarationForCircularDependency(
8302
    IdentifierInfo *PName,
8303
    SourceLocation &PLoc, SourceLocation PrevLoc,
8304
    const ObjCList<ObjCProtocolDecl> &PList);
8305
8306
  Decl *ActOnStartProtocolInterface(
8307
      SourceLocation AtProtoInterfaceLoc, IdentifierInfo *ProtocolName,
8308
      SourceLocation ProtocolLoc, Decl *const *ProtoRefNames,
8309
      unsigned NumProtoRefs, const SourceLocation *ProtoLocs,
8310
      SourceLocation EndProtoLoc, const ParsedAttributesView &AttrList);
8311
8312
  Decl *ActOnStartCategoryInterface(
8313
      SourceLocation AtInterfaceLoc, IdentifierInfo *ClassName,
8314
      SourceLocation ClassLoc, ObjCTypeParamList *typeParamList,
8315
      IdentifierInfo *CategoryName, SourceLocation CategoryLoc,
8316
      Decl *const *ProtoRefs, unsigned NumProtoRefs,
8317
      const SourceLocation *ProtoLocs, SourceLocation EndProtoLoc,
8318
      const ParsedAttributesView &AttrList);
8319
8320
  Decl *ActOnStartClassImplementation(SourceLocation AtClassImplLoc,
8321
                                      IdentifierInfo *ClassName,
8322
                                      SourceLocation ClassLoc,
8323
                                      IdentifierInfo *SuperClassname,
8324
                                      SourceLocation SuperClassLoc,
8325
                                      const ParsedAttributesView &AttrList);
8326
8327
  Decl *ActOnStartCategoryImplementation(SourceLocation AtCatImplLoc,
8328
                                         IdentifierInfo *ClassName,
8329
                                         SourceLocation ClassLoc,
8330
                                         IdentifierInfo *CatName,
8331
                                         SourceLocation CatLoc,
8332
                                         const ParsedAttributesView &AttrList);
8333
8334
  DeclGroupPtrTy ActOnFinishObjCImplementation(Decl *ObjCImpDecl,
8335
                                               ArrayRef<Decl *> Decls);
8336
8337
  DeclGroupPtrTy ActOnForwardClassDeclaration(SourceLocation Loc,
8338
                   IdentifierInfo **IdentList,
8339
                   SourceLocation *IdentLocs,
8340
                   ArrayRef<ObjCTypeParamList *> TypeParamLists,
8341
                   unsigned NumElts);
8342
8343
  DeclGroupPtrTy
8344
  ActOnForwardProtocolDeclaration(SourceLocation AtProtoclLoc,
8345
                                  ArrayRef<IdentifierLocPair> IdentList,
8346
                                  const ParsedAttributesView &attrList);
8347
8348
  void FindProtocolDeclaration(bool WarnOnDeclarations, bool ForObjCContainer,
8349
                               ArrayRef<IdentifierLocPair> ProtocolId,
8350
                               SmallVectorImpl<Decl *> &Protocols);
8351
8352
  void DiagnoseTypeArgsAndProtocols(IdentifierInfo *ProtocolId,
8353
                                    SourceLocation ProtocolLoc,
8354
                                    IdentifierInfo *TypeArgId,
8355
                                    SourceLocation TypeArgLoc,
8356
                                    bool SelectProtocolFirst = false);
8357
8358
  /// Given a list of identifiers (and their locations), resolve the
8359
  /// names to either Objective-C protocol qualifiers or type
8360
  /// arguments, as appropriate.
8361
  void actOnObjCTypeArgsOrProtocolQualifiers(
8362
         Scope *S,
8363
         ParsedType baseType,
8364
         SourceLocation lAngleLoc,
8365
         ArrayRef<IdentifierInfo *> identifiers,
8366
         ArrayRef<SourceLocation> identifierLocs,
8367
         SourceLocation rAngleLoc,
8368
         SourceLocation &typeArgsLAngleLoc,
8369
         SmallVectorImpl<ParsedType> &typeArgs,
8370
         SourceLocation &typeArgsRAngleLoc,
8371
         SourceLocation &protocolLAngleLoc,
8372
         SmallVectorImpl<Decl *> &protocols,
8373
         SourceLocation &protocolRAngleLoc,
8374
         bool warnOnIncompleteProtocols);
8375
8376
  /// Build a an Objective-C protocol-qualified 'id' type where no
8377
  /// base type was specified.
8378
  TypeResult actOnObjCProtocolQualifierType(
8379
               SourceLocation lAngleLoc,
8380
               ArrayRef<Decl *> protocols,
8381
               ArrayRef<SourceLocation> protocolLocs,
8382
               SourceLocation rAngleLoc);
8383
8384
  /// Build a specialized and/or protocol-qualified Objective-C type.
8385
  TypeResult actOnObjCTypeArgsAndProtocolQualifiers(
8386
               Scope *S,
8387
               SourceLocation Loc,
8388
               ParsedType BaseType,
8389
               SourceLocation TypeArgsLAngleLoc,
8390
               ArrayRef<ParsedType> TypeArgs,
8391
               SourceLocation TypeArgsRAngleLoc,
8392
               SourceLocation ProtocolLAngleLoc,
8393
               ArrayRef<Decl *> Protocols,
8394
               ArrayRef<SourceLocation> ProtocolLocs,
8395
               SourceLocation ProtocolRAngleLoc);
8396
8397
  /// Build an Objective-C type parameter type.
8398
  QualType BuildObjCTypeParamType(const ObjCTypeParamDecl *Decl,
8399
                                  SourceLocation ProtocolLAngleLoc,
8400
                                  ArrayRef<ObjCProtocolDecl *> Protocols,
8401
                                  ArrayRef<SourceLocation> ProtocolLocs,
8402
                                  SourceLocation ProtocolRAngleLoc,
8403
                                  bool FailOnError = false);
8404
8405
  /// Build an Objective-C object pointer type.
8406
  QualType BuildObjCObjectType(QualType BaseType,
8407
                               SourceLocation Loc,
8408
                               SourceLocation TypeArgsLAngleLoc,
8409
                               ArrayRef<TypeSourceInfo *> TypeArgs,
8410
                               SourceLocation TypeArgsRAngleLoc,
8411
                               SourceLocation ProtocolLAngleLoc,
8412
                               ArrayRef<ObjCProtocolDecl *> Protocols,
8413
                               ArrayRef<SourceLocation> ProtocolLocs,
8414
                               SourceLocation ProtocolRAngleLoc,
8415
                               bool FailOnError = false);
8416
8417
  /// Ensure attributes are consistent with type.
8418
  /// \param [in, out] Attributes The attributes to check; they will
8419
  /// be modified to be consistent with \p PropertyTy.
8420
  void CheckObjCPropertyAttributes(Decl *PropertyPtrTy,
8421
                                   SourceLocation Loc,
8422
                                   unsigned &Attributes,
8423
                                   bool propertyInPrimaryClass);
8424
8425
  /// Process the specified property declaration and create decls for the
8426
  /// setters and getters as needed.
8427
  /// \param property The property declaration being processed
8428
  void ProcessPropertyDecl(ObjCPropertyDecl *property);
8429
8430
8431
  void DiagnosePropertyMismatch(ObjCPropertyDecl *Property,
8432
                                ObjCPropertyDecl *SuperProperty,
8433
                                const IdentifierInfo *Name,
8434
                                bool OverridingProtocolProperty);
8435
8436
  void DiagnoseClassExtensionDupMethods(ObjCCategoryDecl *CAT,
8437
                                        ObjCInterfaceDecl *ID);
8438
8439
  Decl *ActOnAtEnd(Scope *S, SourceRange AtEnd,
8440
                   ArrayRef<Decl *> allMethods = None,
8441
                   ArrayRef<DeclGroupPtrTy> allTUVars = None);
8442
8443
  Decl *ActOnProperty(Scope *S, SourceLocation AtLoc,
8444
                      SourceLocation LParenLoc,
8445
                      FieldDeclarator &FD, ObjCDeclSpec &ODS,
8446
                      Selector GetterSel, Selector SetterSel,
8447
                      tok::ObjCKeywordKind MethodImplKind,
8448
                      DeclContext *lexicalDC = nullptr);
8449
8450
  Decl *ActOnPropertyImplDecl(Scope *S,
8451
                              SourceLocation AtLoc,
8452
                              SourceLocation PropertyLoc,
8453
                              bool ImplKind,
8454
                              IdentifierInfo *PropertyId,
8455
                              IdentifierInfo *PropertyIvar,
8456
                              SourceLocation PropertyIvarLoc,
8457
                              ObjCPropertyQueryKind QueryKind);
8458
8459
  enum ObjCSpecialMethodKind {
8460
    OSMK_None,
8461
    OSMK_Alloc,
8462
    OSMK_New,
8463
    OSMK_Copy,
8464
    OSMK_RetainingInit,
8465
    OSMK_NonRetainingInit
8466
  };
8467
8468
  struct ObjCArgInfo {
8469
    IdentifierInfo *Name;
8470
    SourceLocation NameLoc;
8471
    // The Type is null if no type was specified, and the DeclSpec is invalid
8472
    // in this case.
8473
    ParsedType Type;
8474
    ObjCDeclSpec DeclSpec;
8475
8476
    /// ArgAttrs - Attribute list for this argument.
8477
    ParsedAttributesView ArgAttrs;
8478
  };
8479
8480
  Decl *ActOnMethodDeclaration(
8481
      Scope *S,
8482
      SourceLocation BeginLoc, // location of the + or -.
8483
      SourceLocation EndLoc,   // location of the ; or {.
8484
      tok::TokenKind MethodType, ObjCDeclSpec &ReturnQT, ParsedType ReturnType,
8485
      ArrayRef<SourceLocation> SelectorLocs, Selector Sel,
8486
      // optional arguments. The number of types/arguments is obtained
8487
      // from the Sel.getNumArgs().
8488
      ObjCArgInfo *ArgInfo, DeclaratorChunk::ParamInfo *CParamInfo,
8489
      unsigned CNumArgs, // c-style args
8490
      const ParsedAttributesView &AttrList, tok::ObjCKeywordKind MethodImplKind,
8491
      bool isVariadic, bool MethodDefinition);
8492
8493
  ObjCMethodDecl *LookupMethodInQualifiedType(Selector Sel,
8494
                                              const ObjCObjectPointerType *OPT,
8495
                                              bool IsInstance);
8496
  ObjCMethodDecl *LookupMethodInObjectType(Selector Sel, QualType Ty,
8497
                                           bool IsInstance);
8498
8499
  bool CheckARCMethodDecl(ObjCMethodDecl *method);
8500
  bool inferObjCARCLifetime(ValueDecl *decl);
8501
8502
  ExprResult
8503
  HandleExprPropertyRefExpr(const ObjCObjectPointerType *OPT,
8504
                            Expr *BaseExpr,
8505
                            SourceLocation OpLoc,
8506
                            DeclarationName MemberName,
8507
                            SourceLocation MemberLoc,
8508
                            SourceLocation SuperLoc, QualType SuperType,
8509
                            bool Super);
8510
8511
  ExprResult
8512
  ActOnClassPropertyRefExpr(IdentifierInfo &receiverName,
8513
                            IdentifierInfo &propertyName,
8514
                            SourceLocation receiverNameLoc,
8515
                            SourceLocation propertyNameLoc);
8516
8517
  ObjCMethodDecl *tryCaptureObjCSelf(SourceLocation Loc);
8518
8519
  /// Describes the kind of message expression indicated by a message
8520
  /// send that starts with an identifier.
8521
  enum ObjCMessageKind {
8522
    /// The message is sent to 'super'.
8523
    ObjCSuperMessage,
8524
    /// The message is an instance message.
8525
    ObjCInstanceMessage,
8526
    /// The message is a class message, and the identifier is a type
8527
    /// name.
8528
    ObjCClassMessage
8529
  };
8530
8531
  ObjCMessageKind getObjCMessageKind(Scope *S,
8532
                                     IdentifierInfo *Name,
8533
                                     SourceLocation NameLoc,
8534
                                     bool IsSuper,
8535
                                     bool HasTrailingDot,
8536
                                     ParsedType &ReceiverType);
8537
8538
  ExprResult ActOnSuperMessage(Scope *S, SourceLocation SuperLoc,
8539
                               Selector Sel,
8540
                               SourceLocation LBracLoc,
8541
                               ArrayRef<SourceLocation> SelectorLocs,
8542
                               SourceLocation RBracLoc,
8543
                               MultiExprArg Args);
8544
8545
  ExprResult BuildClassMessage(TypeSourceInfo *ReceiverTypeInfo,
8546
                               QualType ReceiverType,
8547
                               SourceLocation SuperLoc,
8548
                               Selector Sel,
8549
                               ObjCMethodDecl *Method,
8550
                               SourceLocation LBracLoc,
8551
                               ArrayRef<SourceLocation> SelectorLocs,
8552
                               SourceLocation RBracLoc,
8553
                               MultiExprArg Args,
8554
                               bool isImplicit = false);
8555
8556
  ExprResult BuildClassMessageImplicit(QualType ReceiverType,
8557
                                       bool isSuperReceiver,
8558
                                       SourceLocation Loc,
8559
                                       Selector Sel,
8560
                                       ObjCMethodDecl *Method,
8561
                                       MultiExprArg Args);
8562
8563
  ExprResult ActOnClassMessage(Scope *S,
8564
                               ParsedType Receiver,
8565
                               Selector Sel,
8566
                               SourceLocation LBracLoc,
8567
                               ArrayRef<SourceLocation> SelectorLocs,
8568
                               SourceLocation RBracLoc,
8569
                               MultiExprArg Args);
8570
8571
  ExprResult BuildInstanceMessage(Expr *Receiver,
8572
                                  QualType ReceiverType,
8573
                                  SourceLocation SuperLoc,
8574
                                  Selector Sel,
8575
                                  ObjCMethodDecl *Method,
8576
                                  SourceLocation LBracLoc,
8577
                                  ArrayRef<SourceLocation> SelectorLocs,
8578
                                  SourceLocation RBracLoc,
8579
                                  MultiExprArg Args,
8580
                                  bool isImplicit = false);
8581
8582
  ExprResult BuildInstanceMessageImplicit(Expr *Receiver,
8583
                                          QualType ReceiverType,
8584
                                          SourceLocation Loc,
8585
                                          Selector Sel,
8586
                                          ObjCMethodDecl *Method,
8587
                                          MultiExprArg Args);
8588
8589
  ExprResult ActOnInstanceMessage(Scope *S,
8590
                                  Expr *Receiver,
8591
                                  Selector Sel,
8592
                                  SourceLocation LBracLoc,
8593
                                  ArrayRef<SourceLocation> SelectorLocs,
8594
                                  SourceLocation RBracLoc,
8595
                                  MultiExprArg Args);
8596
8597
  ExprResult BuildObjCBridgedCast(SourceLocation LParenLoc,
8598
                                  ObjCBridgeCastKind Kind,
8599
                                  SourceLocation BridgeKeywordLoc,
8600
                                  TypeSourceInfo *TSInfo,
8601
                                  Expr *SubExpr);
8602
8603
  ExprResult ActOnObjCBridgedCast(Scope *S,
8604
                                  SourceLocation LParenLoc,
8605
                                  ObjCBridgeCastKind Kind,
8606
                                  SourceLocation BridgeKeywordLoc,
8607
                                  ParsedType Type,
8608
                                  SourceLocation RParenLoc,
8609
                                  Expr *SubExpr);
8610
8611
  void CheckTollFreeBridgeCast(QualType castType, Expr *castExpr);
8612
8613
  void CheckObjCBridgeRelatedCast(QualType castType, Expr *castExpr);
8614
8615
  bool CheckTollFreeBridgeStaticCast(QualType castType, Expr *castExpr,
8616
                                     CastKind &Kind);
8617
8618
  bool checkObjCBridgeRelatedComponents(SourceLocation Loc,
8619
                                        QualType DestType, QualType SrcType,
8620
                                        ObjCInterfaceDecl *&RelatedClass,
8621
                                        ObjCMethodDecl *&ClassMethod,
8622
                                        ObjCMethodDecl *&InstanceMethod,
8623
                                        TypedefNameDecl *&TDNDecl,
8624
                                        bool CfToNs, bool Diagnose = true);
8625
8626
  bool CheckObjCBridgeRelatedConversions(SourceLocation Loc,
8627
                                         QualType DestType, QualType SrcType,
8628
                                         Expr *&SrcExpr, bool Diagnose = true);
8629
8630
  bool ConversionToObjCStringLiteralCheck(QualType DstType, Expr *&SrcExpr,
8631
                                          bool Diagnose = true);
8632
8633
  bool checkInitMethod(ObjCMethodDecl *method, QualType receiverTypeIfCall);
8634
8635
  /// Check whether the given new method is a valid override of the
8636
  /// given overridden method, and set any properties that should be inherited.
8637
  void CheckObjCMethodOverride(ObjCMethodDecl *NewMethod,
8638
                               const ObjCMethodDecl *Overridden);
8639
8640
  /// Describes the compatibility of a result type with its method.
8641
  enum ResultTypeCompatibilityKind {
8642
    RTC_Compatible,
8643
    RTC_Incompatible,
8644
    RTC_Unknown
8645
  };
8646
8647
  void CheckObjCMethodOverrides(ObjCMethodDecl *ObjCMethod,
8648
                                ObjCInterfaceDecl *CurrentClass,
8649
                                ResultTypeCompatibilityKind RTC);
8650
8651
  enum PragmaOptionsAlignKind {
8652
    POAK_Native,  // #pragma options align=native
8653
    POAK_Natural, // #pragma options align=natural
8654
    POAK_Packed,  // #pragma options align=packed
8655
    POAK_Power,   // #pragma options align=power
8656
    POAK_Mac68k,  // #pragma options align=mac68k
8657
    POAK_Reset    // #pragma options align=reset
8658
  };
8659
8660
  /// ActOnPragmaClangSection - Called on well formed \#pragma clang section
8661
  void ActOnPragmaClangSection(SourceLocation PragmaLoc,
8662
                               PragmaClangSectionAction Action,
8663
                               PragmaClangSectionKind SecKind, StringRef SecName);
8664
8665
  /// ActOnPragmaOptionsAlign - Called on well formed \#pragma options align.
8666
  void ActOnPragmaOptionsAlign(PragmaOptionsAlignKind Kind,
8667
                               SourceLocation PragmaLoc);
8668
8669
  /// ActOnPragmaPack - Called on well formed \#pragma pack(...).
8670
  void ActOnPragmaPack(SourceLocation PragmaLoc, PragmaMsStackAction Action,
8671
                       StringRef SlotLabel, Expr *Alignment);
8672
8673
  enum class PragmaPackDiagnoseKind {
8674
    NonDefaultStateAtInclude,
8675
    ChangedStateAtExit
8676
  };
8677
8678
  void DiagnoseNonDefaultPragmaPack(PragmaPackDiagnoseKind Kind,
8679
                                    SourceLocation IncludeLoc);
8680
  void DiagnoseUnterminatedPragmaPack();
8681
8682
  /// ActOnPragmaMSStruct - Called on well formed \#pragma ms_struct [on|off].
8683
  void ActOnPragmaMSStruct(PragmaMSStructKind Kind);
8684
8685
  /// ActOnPragmaMSComment - Called on well formed
8686
  /// \#pragma comment(kind, "arg").
8687
  void ActOnPragmaMSComment(SourceLocation CommentLoc, PragmaMSCommentKind Kind,
8688
                            StringRef Arg);
8689
8690
  /// ActOnPragmaMSPointersToMembers - called on well formed \#pragma
8691
  /// pointers_to_members(representation method[, general purpose
8692
  /// representation]).
8693
  void ActOnPragmaMSPointersToMembers(
8694
      LangOptions::PragmaMSPointersToMembersKind Kind,
8695
      SourceLocation PragmaLoc);
8696
8697
  /// Called on well formed \#pragma vtordisp().
8698
  void ActOnPragmaMSVtorDisp(PragmaMsStackAction Action,
8699
                             SourceLocation PragmaLoc,
8700
                             MSVtorDispAttr::Mode Value);
8701
8702
  enum PragmaSectionKind {
8703
    PSK_DataSeg,
8704
    PSK_BSSSeg,
8705
    PSK_ConstSeg,
8706
    PSK_CodeSeg,
8707
  };
8708
8709
  bool UnifySection(StringRef SectionName,
8710
                    int SectionFlags,
8711
                    DeclaratorDecl *TheDecl);
8712
  bool UnifySection(StringRef SectionName,
8713
                    int SectionFlags,
8714
                    SourceLocation PragmaSectionLocation);
8715
8716
  /// Called on well formed \#pragma bss_seg/data_seg/const_seg/code_seg.
8717
  void ActOnPragmaMSSeg(SourceLocation PragmaLocation,
8718
                        PragmaMsStackAction Action,
8719
                        llvm::StringRef StackSlotLabel,
8720
                        StringLiteral *SegmentName,
8721
                        llvm::StringRef PragmaName);
8722
8723
  /// Called on well formed \#pragma section().
8724
  void ActOnPragmaMSSection(SourceLocation PragmaLocation,
8725
                            int SectionFlags, StringLiteral *SegmentName);
8726
8727
  /// Called on well-formed \#pragma init_seg().
8728
  void ActOnPragmaMSInitSeg(SourceLocation PragmaLocation,
8729
                            StringLiteral *SegmentName);
8730
8731
  /// Called on #pragma clang __debug dump II
8732
  void ActOnPragmaDump(Scope *S, SourceLocation Loc, IdentifierInfo *II);
8733
8734
  /// ActOnPragmaDetectMismatch - Call on well-formed \#pragma detect_mismatch
8735
  void ActOnPragmaDetectMismatch(SourceLocation Loc, StringRef Name,
8736
                                 StringRef Value);
8737
8738
  /// ActOnPragmaUnused - Called on well-formed '\#pragma unused'.
8739
  void ActOnPragmaUnused(const Token &Identifier,
8740
                         Scope *curScope,
8741
                         SourceLocation PragmaLoc);
8742
8743
  /// ActOnPragmaVisibility - Called on well formed \#pragma GCC visibility... .
8744
  void ActOnPragmaVisibility(const IdentifierInfo* VisType,
8745
                             SourceLocation PragmaLoc);
8746
8747
  NamedDecl *DeclClonePragmaWeak(NamedDecl *ND, IdentifierInfo *II,
8748
                                 SourceLocation Loc);
8749
  void DeclApplyPragmaWeak(Scope *S, NamedDecl *ND, WeakInfo &W);
8750
8751
  /// ActOnPragmaWeakID - Called on well formed \#pragma weak ident.
8752
  void ActOnPragmaWeakID(IdentifierInfo* WeakName,
8753
                         SourceLocation PragmaLoc,
8754
                         SourceLocation WeakNameLoc);
8755
8756
  /// ActOnPragmaRedefineExtname - Called on well formed
8757
  /// \#pragma redefine_extname oldname newname.
8758
  void ActOnPragmaRedefineExtname(IdentifierInfo* WeakName,
8759
                                  IdentifierInfo* AliasName,
8760
                                  SourceLocation PragmaLoc,
8761
                                  SourceLocation WeakNameLoc,
8762
                                  SourceLocation AliasNameLoc);
8763
8764
  /// ActOnPragmaWeakAlias - Called on well formed \#pragma weak ident = ident.
8765
  void ActOnPragmaWeakAlias(IdentifierInfo* WeakName,
8766
                            IdentifierInfo* AliasName,
8767
                            SourceLocation PragmaLoc,
8768
                            SourceLocation WeakNameLoc,
8769
                            SourceLocation AliasNameLoc);
8770
8771
  /// ActOnPragmaFPContract - Called on well formed
8772
  /// \#pragma {STDC,OPENCL} FP_CONTRACT and
8773
  /// \#pragma clang fp contract
8774
  void ActOnPragmaFPContract(LangOptions::FPContractModeKind FPC);
8775
8776
  /// ActOnPragmaFenvAccess - Called on well formed
8777
  /// \#pragma STDC FENV_ACCESS
8778
  void ActOnPragmaFEnvAccess(LangOptions::FEnvAccessModeKind FPC);
8779
8780
  /// AddAlignmentAttributesForRecord - Adds any needed alignment attributes to
8781
  /// a the record decl, to handle '\#pragma pack' and '\#pragma options align'.
8782
  void AddAlignmentAttributesForRecord(RecordDecl *RD);
8783
8784
  /// AddMsStructLayoutForRecord - Adds ms_struct layout attribute to record.
8785
  void AddMsStructLayoutForRecord(RecordDecl *RD);
8786
8787
  /// FreePackedContext - Deallocate and null out PackContext.
8788
  void FreePackedContext();
8789
8790
  /// PushNamespaceVisibilityAttr - Note that we've entered a
8791
  /// namespace with a visibility attribute.
8792
  void PushNamespaceVisibilityAttr(const VisibilityAttr *Attr,
8793
                                   SourceLocation Loc);
8794
8795
  /// AddPushedVisibilityAttribute - If '\#pragma GCC visibility' was used,
8796
  /// add an appropriate visibility attribute.
8797
  void AddPushedVisibilityAttribute(Decl *RD);
8798
8799
  /// PopPragmaVisibility - Pop the top element of the visibility stack; used
8800
  /// for '\#pragma GCC visibility' and visibility attributes on namespaces.
8801
  void PopPragmaVisibility(bool IsNamespaceEnd, SourceLocation EndLoc);
8802
8803
  /// FreeVisContext - Deallocate and null out VisContext.
8804
  void FreeVisContext();
8805
8806
  /// AddCFAuditedAttribute - Check whether we're currently within
8807
  /// '\#pragma clang arc_cf_code_audited' and, if so, consider adding
8808
  /// the appropriate attribute.
8809
  void AddCFAuditedAttribute(Decl *D);
8810
8811
  void ActOnPragmaAttributeAttribute(ParsedAttr &Attribute,
8812
                                     SourceLocation PragmaLoc,
8813
                                     attr::ParsedSubjectMatchRuleSet Rules);
8814
  void ActOnPragmaAttributeEmptyPush(SourceLocation PragmaLoc,
8815
                                     const IdentifierInfo *Namespace);
8816
8817
  /// Called on well-formed '\#pragma clang attribute pop'.
8818
  void ActOnPragmaAttributePop(SourceLocation PragmaLoc,
8819
                               const IdentifierInfo *Namespace);
8820
8821
  /// Adds the attributes that have been specified using the
8822
  /// '\#pragma clang attribute push' directives to the given declaration.
8823
  void AddPragmaAttributes(Scope *S, Decl *D);
8824
8825
  void DiagnoseUnterminatedPragmaAttribute();
8826
8827
  /// Called on well formed \#pragma clang optimize.
8828
  void ActOnPragmaOptimize(bool On, SourceLocation PragmaLoc);
8829
8830
  /// Get the location for the currently active "\#pragma clang optimize
8831
  /// off". If this location is invalid, then the state of the pragma is "on".
8832
2.13k
  SourceLocation getOptimizeOffPragmaLocation() const {
8833
2.13k
    return OptimizeOffPragmaLocation;
8834
2.13k
  }
8835
8836
  /// Only called on function definitions; if there is a pragma in scope
8837
  /// with the effect of a range-based optnone, consider marking the function
8838
  /// with attribute optnone.
8839
  void AddRangeBasedOptnone(FunctionDecl *FD);
8840
8841
  /// Adds the 'optnone' attribute to the function declaration if there
8842
  /// are no conflicts; Loc represents the location causing the 'optnone'
8843
  /// attribute to be added (usually because of a pragma).
8844
  void AddOptnoneAttributeIfNoConflicts(FunctionDecl *FD, SourceLocation Loc);
8845
8846
  /// AddAlignedAttr - Adds an aligned attribute to a particular declaration.
8847
  void AddAlignedAttr(SourceRange AttrRange, Decl *D, Expr *E,
8848
                      unsigned SpellingListIndex, bool IsPackExpansion);
8849
  void AddAlignedAttr(SourceRange AttrRange, Decl *D, TypeSourceInfo *T,
8850
                      unsigned SpellingListIndex, bool IsPackExpansion);
8851
8852
  /// AddAssumeAlignedAttr - Adds an assume_aligned attribute to a particular
8853
  /// declaration.
8854
  void AddAssumeAlignedAttr(SourceRange AttrRange, Decl *D, Expr *E, Expr *OE,
8855
                            unsigned SpellingListIndex);
8856
8857
  /// AddAllocAlignAttr - Adds an alloc_align attribute to a particular
8858
  /// declaration.
8859
  void AddAllocAlignAttr(SourceRange AttrRange, Decl *D, Expr *ParamExpr,
8860
                         unsigned SpellingListIndex);
8861
8862
  /// AddAlignValueAttr - Adds an align_value attribute to a particular
8863
  /// declaration.
8864
  void AddAlignValueAttr(SourceRange AttrRange, Decl *D, Expr *E,
8865
                         unsigned SpellingListIndex);
8866
8867
  /// AddLaunchBoundsAttr - Adds a launch_bounds attribute to a particular
8868
  /// declaration.
8869
  void AddLaunchBoundsAttr(SourceRange AttrRange, Decl *D, Expr *MaxThreads,
8870
                           Expr *MinBlocks, unsigned SpellingListIndex);
8871
8872
  /// AddModeAttr - Adds a mode attribute to a particular declaration.
8873
  void AddModeAttr(SourceRange AttrRange, Decl *D, IdentifierInfo *Name,
8874
                   unsigned SpellingListIndex, bool InInstantiation = false);
8875
8876
  void AddParameterABIAttr(SourceRange AttrRange, Decl *D,
8877
                           ParameterABI ABI, unsigned SpellingListIndex);
8878
8879
  enum class RetainOwnershipKind {NS, CF, OS};
8880
  void AddXConsumedAttr(Decl *D, SourceRange SR, unsigned SpellingIndex,
8881
                        RetainOwnershipKind K, bool IsTemplateInstantiation);
8882
8883
  /// addAMDGPUFlatWorkGroupSizeAttr - Adds an amdgpu_flat_work_group_size
8884
  /// attribute to a particular declaration.
8885
  void addAMDGPUFlatWorkGroupSizeAttr(SourceRange AttrRange, Decl *D, Expr *Min,
8886
                                      Expr *Max, unsigned SpellingListIndex);
8887
8888
  /// addAMDGPUWavePersEUAttr - Adds an amdgpu_waves_per_eu attribute to a
8889
  /// particular declaration.
8890
  void addAMDGPUWavesPerEUAttr(SourceRange AttrRange, Decl *D, Expr *Min,
8891
                               Expr *Max, unsigned SpellingListIndex);
8892
8893
  bool checkNSReturnsRetainedReturnType(SourceLocation loc, QualType type);
8894
8895
  //===--------------------------------------------------------------------===//
8896
  // C++ Coroutines TS
8897
  //
8898
  bool ActOnCoroutineBodyStart(Scope *S, SourceLocation KwLoc,
8899
                               StringRef Keyword);
8900
  ExprResult ActOnCoawaitExpr(Scope *S, SourceLocation KwLoc, Expr *E);
8901
  ExprResult ActOnCoyieldExpr(Scope *S, SourceLocation KwLoc, Expr *E);
8902
  StmtResult ActOnCoreturnStmt(Scope *S, SourceLocation KwLoc, Expr *E);
8903
8904
  ExprResult BuildResolvedCoawaitExpr(SourceLocation KwLoc, Expr *E,
8905
                                      bool IsImplicit = false);
8906
  ExprResult BuildUnresolvedCoawaitExpr(SourceLocation KwLoc, Expr *E,
8907
                                        UnresolvedLookupExpr* Lookup);
8908
  ExprResult BuildCoyieldExpr(SourceLocation KwLoc, Expr *E);
8909
  StmtResult BuildCoreturnStmt(SourceLocation KwLoc, Expr *E,
8910
                               bool IsImplicit = false);
8911
  StmtResult BuildCoroutineBodyStmt(CoroutineBodyStmt::CtorArgs);
8912
  bool buildCoroutineParameterMoves(SourceLocation Loc);
8913
  VarDecl *buildCoroutinePromise(SourceLocation Loc);
8914
  void CheckCompletedCoroutineBody(FunctionDecl *FD, Stmt *&Body);
8915
  ClassTemplateDecl *lookupCoroutineTraits(SourceLocation KwLoc,
8916
                                           SourceLocation FuncLoc);
8917
8918
  //===--------------------------------------------------------------------===//
8919
  // OpenCL extensions.
8920
  //
8921
private:
8922
  std::string CurrOpenCLExtension;
8923
  /// Extensions required by an OpenCL type.
8924
  llvm::DenseMap<const Type*, std::set<std::string>> OpenCLTypeExtMap;
8925
  /// Extensions required by an OpenCL declaration.
8926
  llvm::DenseMap<const Decl*, std::set<std::string>> OpenCLDeclExtMap;
8927
public:
8928
87
  llvm::StringRef getCurrentOpenCLExtension() const {
8929
87
    return CurrOpenCLExtension;
8930
87
  }
8931
8932
  /// Check if a function declaration \p FD associates with any
8933
  /// extensions present in OpenCLDeclExtMap and if so return the
8934
  /// extension(s) name(s).
8935
  std::string getOpenCLExtensionsFromDeclExtMap(FunctionDecl *FD);
8936
8937
  /// Check if a function type \p FT associates with any
8938
  /// extensions present in OpenCLTypeExtMap and if so return the
8939
  /// extension(s) name(s).
8940
  std::string getOpenCLExtensionsFromTypeExtMap(FunctionType *FT);
8941
8942
  /// Find an extension in an appropriate extension map and return its name
8943
  template<typename T, typename MapT>
8944
  std::string getOpenCLExtensionsFromExtMap(T* FT, MapT &Map);
8945
8946
170
  void setCurrentOpenCLExtension(llvm::StringRef Ext) {
8947
170
    CurrOpenCLExtension = Ext;
8948
170
  }
8949
8950
  /// Set OpenCL extensions for a type which can only be used when these
8951
  /// OpenCL extensions are enabled. If \p Exts is empty, do nothing.
8952
  /// \param Exts A space separated list of OpenCL extensions.
8953
  void setOpenCLExtensionForType(QualType T, llvm::StringRef Exts);
8954
8955
  /// Set OpenCL extensions for a declaration which can only be
8956
  /// used when these OpenCL extensions are enabled. If \p Exts is empty, do
8957
  /// nothing.
8958
  /// \param Exts A space separated list of OpenCL extensions.
8959
  void setOpenCLExtensionForDecl(Decl *FD, llvm::StringRef Exts);
8960
8961
  /// Set current OpenCL extensions for a type which can only be used
8962
  /// when these OpenCL extensions are enabled. If current OpenCL extension is
8963
  /// empty, do nothing.
8964
  void setCurrentOpenCLExtensionForType(QualType T);
8965
8966
  /// Set current OpenCL extensions for a declaration which
8967
  /// can only be used when these OpenCL extensions are enabled. If current
8968
  /// OpenCL extension is empty, do nothing.
8969
  void setCurrentOpenCLExtensionForDecl(Decl *FD);
8970
8971
  bool isOpenCLDisabledDecl(Decl *FD);
8972
8973
  /// Check if type \p T corresponding to declaration specifier \p DS
8974
  /// is disabled due to required OpenCL extensions being disabled. If so,
8975
  /// emit diagnostics.
8976
  /// \return true if type is disabled.
8977
  bool checkOpenCLDisabledTypeDeclSpec(const DeclSpec &DS, QualType T);
8978
8979
  /// Check if declaration \p D used by expression \p E
8980
  /// is disabled due to required OpenCL extensions being disabled. If so,
8981
  /// emit diagnostics.
8982
  /// \return true if type is disabled.
8983
  bool checkOpenCLDisabledDecl(const NamedDecl &D, const Expr &E);
8984
8985
  //===--------------------------------------------------------------------===//
8986
  // OpenMP directives and clauses.
8987
  //
8988
private:
8989
  void *VarDataSharingAttributesStack;
8990
  /// Number of nested '#pragma omp declare target' directives.
8991
  unsigned DeclareTargetNestingLevel = 0;
8992
  /// Initialization of data-sharing attributes stack.
8993
  void InitDataSharingAttributesStack();
8994
  void DestroyDataSharingAttributesStack();
8995
  ExprResult
8996
  VerifyPositiveIntegerConstantInClause(Expr *Op, OpenMPClauseKind CKind,
8997
                                        bool StrictlyPositive = true);
8998
  /// Returns OpenMP nesting level for current directive.
8999
  unsigned getOpenMPNestingLevel() const;
9000
9001
  /// Adjusts the function scopes index for the target-based regions.
9002
  void adjustOpenMPTargetScopeIndex(unsigned &FunctionScopesIndex,
9003
                                    unsigned Level) const;
9004
9005
  /// Push new OpenMP function region for non-capturing function.
9006
  void pushOpenMPFunctionRegion();
9007
9008
  /// Pop OpenMP function region for non-capturing function.
9009
  void popOpenMPFunctionRegion(const sema::FunctionScopeInfo *OldFSI);
9010
9011
  /// Check whether we're allowed to call Callee from the current function.
9012
  void checkOpenMPDeviceFunction(SourceLocation Loc, FunctionDecl *Callee);
9013
9014
  /// Check if the expression is allowed to be used in expressions for the
9015
  /// OpenMP devices.
9016
  void checkOpenMPDeviceExpr(const Expr *E);
9017
9018
  /// Checks if a type or a declaration is disabled due to the owning extension
9019
  /// being disabled, and emits diagnostic messages if it is disabled.
9020
  /// \param D type or declaration to be checked.
9021
  /// \param DiagLoc source location for the diagnostic message.
9022
  /// \param DiagInfo information to be emitted for the diagnostic message.
9023
  /// \param SrcRange source range of the declaration.
9024
  /// \param Map maps type or declaration to the extensions.
9025
  /// \param Selector selects diagnostic message: 0 for type and 1 for
9026
  ///        declaration.
9027
  /// \return true if the type or declaration is disabled.
9028
  template <typename T, typename DiagLocT, typename DiagInfoT, typename MapT>
9029
  bool checkOpenCLDisabledTypeOrDecl(T D, DiagLocT DiagLoc, DiagInfoT DiagInfo,
9030
                                     MapT &Map, unsigned Selector = 0,
9031
                                     SourceRange SrcRange = SourceRange());
9032
9033
public:
9034
  /// Function tries to capture lambda's captured variables in the OpenMP region
9035
  /// before the original lambda is captured.
9036
  void tryCaptureOpenMPLambdas(ValueDecl *V);
9037
9038
  /// Return true if the provided declaration \a VD should be captured by
9039
  /// reference.
9040
  /// \param Level Relative level of nested OpenMP construct for that the check
9041
  /// is performed.
9042
  bool isOpenMPCapturedByRef(const ValueDecl *D, unsigned Level) const;
9043
9044
  /// Check if the specified variable is used in one of the private
9045
  /// clauses (private, firstprivate, lastprivate, reduction etc.) in OpenMP
9046
  /// constructs.
9047
  VarDecl *isOpenMPCapturedDecl(ValueDecl *D, bool CheckScopeInfo = false,
9048
                                unsigned StopAt = 0);
9049
  ExprResult getOpenMPCapturedExpr(VarDecl *Capture, ExprValueKind VK,
9050
                                   ExprObjectKind OK, SourceLocation Loc);
9051
9052
  /// If the current region is a loop-based region, mark the start of the loop
9053
  /// construct.
9054
  void startOpenMPLoop();
9055
9056
  /// Check if the specified variable is used in 'private' clause.
9057
  /// \param Level Relative level of nested OpenMP construct for that the check
9058
  /// is performed.
9059
  bool isOpenMPPrivateDecl(const ValueDecl *D, unsigned Level) const;
9060
9061
  /// Sets OpenMP capture kind (OMPC_private, OMPC_firstprivate, OMPC_map etc.)
9062
  /// for \p FD based on DSA for the provided corresponding captured declaration
9063
  /// \p D.
9064
  void setOpenMPCaptureKind(FieldDecl *FD, const ValueDecl *D, unsigned Level);
9065
9066
  /// Check if the specified variable is captured  by 'target' directive.
9067
  /// \param Level Relative level of nested OpenMP construct for that the check
9068
  /// is performed.
9069
  bool isOpenMPTargetCapturedDecl(const ValueDecl *D, unsigned Level) const;
9070
9071
  ExprResult PerformOpenMPImplicitIntegerConversion(SourceLocation OpLoc,
9072
                                                    Expr *Op);
9073
  /// Called on start of new data sharing attribute block.
9074
  void StartOpenMPDSABlock(OpenMPDirectiveKind K,
9075
                           const DeclarationNameInfo &DirName, Scope *CurScope,
9076
                           SourceLocation Loc);
9077
  /// Start analysis of clauses.
9078
  void StartOpenMPClause(OpenMPClauseKind K);
9079
  /// End analysis of clauses.
9080
  void EndOpenMPClause();
9081
  /// Called on end of data sharing attribute block.
9082
  void EndOpenMPDSABlock(Stmt *CurDirective);
9083
9084
  /// Check if the current region is an OpenMP loop region and if it is,
9085
  /// mark loop control variable, used in \p Init for loop initialization, as
9086
  /// private by default.
9087
  /// \param Init First part of the for loop.
9088
  void ActOnOpenMPLoopInitialization(SourceLocation ForLoc, Stmt *Init);
9089
9090
  // OpenMP directives and clauses.
9091
  /// Called on correct id-expression from the '#pragma omp
9092
  /// threadprivate'.
9093
  ExprResult ActOnOpenMPIdExpression(Scope *CurScope, CXXScopeSpec &ScopeSpec,
9094
                                     const DeclarationNameInfo &Id,
9095
                                     OpenMPDirectiveKind Kind);
9096
  /// Called on well-formed '#pragma omp threadprivate'.
9097
  DeclGroupPtrTy ActOnOpenMPThreadprivateDirective(
9098
                                     SourceLocation Loc,
9099
                                     ArrayRef<Expr *> VarList);
9100
  /// Builds a new OpenMPThreadPrivateDecl and checks its correctness.
9101
  OMPThreadPrivateDecl *CheckOMPThreadPrivateDecl(SourceLocation Loc,
9102
                                                  ArrayRef<Expr *> VarList);
9103
  /// Called on well-formed '#pragma omp allocate'.
9104
  DeclGroupPtrTy ActOnOpenMPAllocateDirective(SourceLocation Loc,
9105
                                              ArrayRef<Expr *> VarList,
9106
                                              ArrayRef<OMPClause *> Clauses,
9107
                                              DeclContext *Owner = nullptr);
9108
  /// Called on well-formed '#pragma omp requires'.
9109
  DeclGroupPtrTy ActOnOpenMPRequiresDirective(SourceLocation Loc,
9110
                                              ArrayRef<OMPClause *> ClauseList);
9111
  /// Check restrictions on Requires directive
9112
  OMPRequiresDecl *CheckOMPRequiresDecl(SourceLocation Loc,
9113
                                        ArrayRef<OMPClause *> Clauses);
9114
  /// Check if the specified type is allowed to be used in 'omp declare
9115
  /// reduction' construct.
9116
  QualType ActOnOpenMPDeclareReductionType(SourceLocation TyLoc,
9117
                                           TypeResult ParsedType);
9118
  /// Called on start of '#pragma omp declare reduction'.
9119
  DeclGroupPtrTy ActOnOpenMPDeclareReductionDirectiveStart(
9120
      Scope *S, DeclContext *DC, DeclarationName Name,
9121
      ArrayRef<std::pair<QualType, SourceLocation>> ReductionTypes,
9122
      AccessSpecifier AS, Decl *PrevDeclInScope = nullptr);
9123
  /// Initialize declare reduction construct initializer.
9124
  void ActOnOpenMPDeclareReductionCombinerStart(Scope *S, Decl *D);
9125
  /// Finish current declare reduction construct initializer.
9126
  void ActOnOpenMPDeclareReductionCombinerEnd(Decl *D, Expr *Combiner);
9127
  /// Initialize declare reduction construct initializer.
9128
  /// \return omp_priv variable.
9129
  VarDecl *ActOnOpenMPDeclareReductionInitializerStart(Scope *S, Decl *D);
9130
  /// Finish current declare reduction construct initializer.
9131
  void ActOnOpenMPDeclareReductionInitializerEnd(Decl *D, Expr *Initializer,
9132
                                                 VarDecl *OmpPrivParm);
9133
  /// Called at the end of '#pragma omp declare reduction'.
9134
  DeclGroupPtrTy ActOnOpenMPDeclareReductionDirectiveEnd(
9135
      Scope *S, DeclGroupPtrTy DeclReductions, bool IsValid);
9136
9137
  /// Check variable declaration in 'omp declare mapper' construct.
9138
  TypeResult ActOnOpenMPDeclareMapperVarDecl(Scope *S, Declarator &D);
9139
  /// Check if the specified type is allowed to be used in 'omp declare
9140
  /// mapper' construct.
9141
  QualType ActOnOpenMPDeclareMapperType(SourceLocation TyLoc,
9142
                                        TypeResult ParsedType);
9143
  /// Called on start of '#pragma omp declare mapper'.
9144
  OMPDeclareMapperDecl *ActOnOpenMPDeclareMapperDirectiveStart(
9145
      Scope *S, DeclContext *DC, DeclarationName Name, QualType MapperType,
9146
      SourceLocation StartLoc, DeclarationName VN, AccessSpecifier AS,
9147
      Decl *PrevDeclInScope = nullptr);
9148
  /// Build the mapper variable of '#pragma omp declare mapper'.
9149
  void ActOnOpenMPDeclareMapperDirectiveVarDecl(OMPDeclareMapperDecl *DMD,
9150
                                                Scope *S, QualType MapperType,
9151
                                                SourceLocation StartLoc,
9152
                                                DeclarationName VN);
9153
  /// Called at the end of '#pragma omp declare mapper'.
9154
  DeclGroupPtrTy
9155
  ActOnOpenMPDeclareMapperDirectiveEnd(OMPDeclareMapperDecl *D, Scope *S,
9156
                                       ArrayRef<OMPClause *> ClauseList);
9157
9158
  /// Called on the start of target region i.e. '#pragma omp declare target'.
9159
  bool ActOnStartOpenMPDeclareTargetDirective(SourceLocation Loc);
9160
  /// Called at the end of target region i.e. '#pragme omp end declare target'.
9161
  void ActOnFinishOpenMPDeclareTargetDirective();
9162
  /// Called on correct id-expression from the '#pragma omp declare target'.
9163
  void ActOnOpenMPDeclareTargetName(Scope *CurScope, CXXScopeSpec &ScopeSpec,
9164
                                    const DeclarationNameInfo &Id,
9165
                                    OMPDeclareTargetDeclAttr::MapTypeTy MT,
9166
                                    NamedDeclSetType &SameDirectiveDecls);
9167
  /// Check declaration inside target region.
9168
  void
9169
  checkDeclIsAllowedInOpenMPTarget(Expr *E, Decl *D,
9170
                                   SourceLocation IdLoc = SourceLocation());
9171
  /// Return true inside OpenMP declare target region.
9172
33.5M
  bool isInOpenMPDeclareTargetContext() const {
9173
33.5M
    return DeclareTargetNestingLevel > 0;
9174
33.5M
  }
9175
  /// Return true inside OpenMP target region.
9176
  bool isInOpenMPTargetExecutionDirective() const;
9177
9178
  /// Return the number of captured regions created for an OpenMP directive.
9179
  static int getOpenMPCaptureLevels(OpenMPDirectiveKind Kind);
9180
9181
  /// Initialization of captured region for OpenMP region.
9182
  void ActOnOpenMPRegionStart(OpenMPDirectiveKind DKind, Scope *CurScope);
9183
  /// End of OpenMP region.
9184
  ///
9185
  /// \param S Statement associated with the current OpenMP region.
9186
  /// \param Clauses List of clauses for the current OpenMP region.
9187
  ///
9188
  /// \returns Statement for finished OpenMP region.
9189
  StmtResult ActOnOpenMPRegionEnd(StmtResult S, ArrayRef<OMPClause *> Clauses);
9190
  StmtResult ActOnOpenMPExecutableDirective(
9191
      OpenMPDirectiveKind Kind, const DeclarationNameInfo &DirName,
9192
      OpenMPDirectiveKind CancelRegion, ArrayRef<OMPClause *> Clauses,
9193
      Stmt *AStmt, SourceLocation StartLoc, SourceLocation EndLoc);
9194
  /// Called on well-formed '\#pragma omp parallel' after parsing
9195
  /// of the  associated statement.
9196
  StmtResult ActOnOpenMPParallelDirective(ArrayRef<OMPClause *> Clauses,
9197
                                          Stmt *AStmt,
9198
                                          SourceLocation StartLoc,
9199
                                          SourceLocation EndLoc);
9200
  using VarsWithInheritedDSAType =
9201
      llvm::SmallDenseMap<const ValueDecl *, const Expr *, 4>;
9202
  /// Called on well-formed '\#pragma omp simd' after parsing
9203
  /// of the associated statement.
9204
  StmtResult
9205
  ActOnOpenMPSimdDirective(ArrayRef<OMPClause *> Clauses, Stmt *AStmt,
9206
                           SourceLocation StartLoc, SourceLocation EndLoc,
9207
                           VarsWithInheritedDSAType &VarsWithImplicitDSA);
9208
  /// Called on well-formed '\#pragma omp for' after parsing
9209
  /// of the associated statement.
9210
  StmtResult
9211
  ActOnOpenMPForDirective(ArrayRef<OMPClause *> Clauses, Stmt *AStmt,
9212
                          SourceLocation StartLoc, SourceLocation EndLoc,
9213
                          VarsWithInheritedDSAType &VarsWithImplicitDSA);
9214
  /// Called on well-formed '\#pragma omp for simd' after parsing
9215
  /// of the associated statement.
9216
  StmtResult
9217
  ActOnOpenMPForSimdDirective(ArrayRef<OMPClause *> Clauses, Stmt *AStmt,
9218
                              SourceLocation StartLoc, SourceLocation EndLoc,
9219
                              VarsWithInheritedDSAType &VarsWithImplicitDSA);
9220
  /// Called on well-formed '\#pragma omp sections' after parsing
9221
  /// of the associated statement.
9222
  StmtResult ActOnOpenMPSectionsDirective(ArrayRef<OMPClause *> Clauses,
9223
                                          Stmt *AStmt, SourceLocation StartLoc,
9224
                                          SourceLocation EndLoc);
9225
  /// Called on well-formed '\#pragma omp section' after parsing of the
9226
  /// associated statement.
9227
  StmtResult ActOnOpenMPSectionDirective(Stmt *AStmt, SourceLocation StartLoc,
9228
                                         SourceLocation EndLoc);
9229
  /// Called on well-formed '\#pragma omp single' after parsing of the
9230
  /// associated statement.
9231
  StmtResult ActOnOpenMPSingleDirective(ArrayRef<OMPClause *> Clauses,
9232
                                        Stmt *AStmt, SourceLocation StartLoc,
9233
                                        SourceLocation EndLoc);
9234
  /// Called on well-formed '\#pragma omp master' after parsing of the
9235
  /// associated statement.
9236
  StmtResult ActOnOpenMPMasterDirective(Stmt *AStmt, SourceLocation StartLoc,
9237
                                        SourceLocation EndLoc);
9238
  /// Called on well-formed '\#pragma omp critical' after parsing of the
9239
  /// associated statement.
9240
  StmtResult ActOnOpenMPCriticalDirective(const DeclarationNameInfo &DirName,
9241
                                          ArrayRef<OMPClause *> Clauses,
9242
                                          Stmt *AStmt, SourceLocation StartLoc,
9243
                                          SourceLocation EndLoc);
9244
  /// Called on well-formed '\#pragma omp parallel for' after parsing
9245
  /// of the  associated statement.
9246
  StmtResult ActOnOpenMPParallelForDirective(
9247
      ArrayRef<OMPClause *> Clauses, Stmt *AStmt, SourceLocation StartLoc,
9248
      SourceLocation EndLoc, VarsWithInheritedDSAType &VarsWithImplicitDSA);
9249
  /// Called on well-formed '\#pragma omp parallel for simd' after
9250
  /// parsing of the  associated statement.
9251
  StmtResult ActOnOpenMPParallelForSimdDirective(
9252
      ArrayRef<OMPClause *> Clauses, Stmt *AStmt, SourceLocation StartLoc,
9253
      SourceLocation EndLoc, VarsWithInheritedDSAType &VarsWithImplicitDSA);
9254
  /// Called on well-formed '\#pragma omp parallel sections' after
9255
  /// parsing of the  associated statement.
9256
  StmtResult ActOnOpenMPParallelSectionsDirective(ArrayRef<OMPClause *> Clauses,
9257
                                                  Stmt *AStmt,
9258
                                                  SourceLocation StartLoc,
9259
                                                  SourceLocation EndLoc);
9260
  /// Called on well-formed '\#pragma omp task' after parsing of the
9261
  /// associated statement.
9262
  StmtResult ActOnOpenMPTaskDirective(ArrayRef<OMPClause *> Clauses,
9263
                                      Stmt *AStmt, SourceLocation StartLoc,
9264
                                      SourceLocation EndLoc);
9265
  /// Called on well-formed '\#pragma omp taskyield'.
9266
  StmtResult ActOnOpenMPTaskyieldDirective(SourceLocation StartLoc,
9267
                                           SourceLocation EndLoc);
9268
  /// Called on well-formed '\#pragma omp barrier'.
9269
  StmtResult ActOnOpenMPBarrierDirective(SourceLocation StartLoc,
9270
                                         SourceLocation EndLoc);
9271
  /// Called on well-formed '\#pragma omp taskwait'.
9272
  StmtResult ActOnOpenMPTaskwaitDirective(SourceLocation StartLoc,
9273
                                          SourceLocation EndLoc);
9274
  /// Called on well-formed '\#pragma omp taskgroup'.
9275
  StmtResult ActOnOpenMPTaskgroupDirective(ArrayRef<OMPClause *> Clauses,
9276
                                           Stmt *AStmt, SourceLocation StartLoc,
9277
                                           SourceLocation EndLoc);
9278
  /// Called on well-formed '\#pragma omp flush'.
9279
  StmtResult ActOnOpenMPFlushDirective(ArrayRef<OMPClause *> Clauses,
9280
                                       SourceLocation StartLoc,
9281
                                       SourceLocation EndLoc);
9282
  /// Called on well-formed '\#pragma omp ordered' after parsing of the
9283
  /// associated statement.
9284
  StmtResult ActOnOpenMPOrderedDirective(ArrayRef<OMPClause *> Clauses,
9285
                                         Stmt *AStmt, SourceLocation StartLoc,
9286
                                         SourceLocation EndLoc);
9287
  /// Called on well-formed '\#pragma omp atomic' after parsing of the
9288
  /// associated statement.
9289
  StmtResult ActOnOpenMPAtomicDirective(ArrayRef<OMPClause *> Clauses,
9290
                                        Stmt *AStmt, SourceLocation StartLoc,
9291
                                        SourceLocation EndLoc);
9292
  /// Called on well-formed '\#pragma omp target' after parsing of the
9293
  /// associated statement.
9294
  StmtResult ActOnOpenMPTargetDirective(ArrayRef<OMPClause *> Clauses,
9295
                                        Stmt *AStmt, SourceLocation StartLoc,
9296
                                        SourceLocation EndLoc);
9297
  /// Called on well-formed '\#pragma omp target data' after parsing of
9298
  /// the associated statement.
9299
  StmtResult ActOnOpenMPTargetDataDirective(ArrayRef<OMPClause *> Clauses,
9300
                                            Stmt *AStmt, SourceLocation StartLoc,
9301
                                            SourceLocation EndLoc);
9302
  /// Called on well-formed '\#pragma omp target enter data' after
9303
  /// parsing of the associated statement.
9304
  StmtResult ActOnOpenMPTargetEnterDataDirective(ArrayRef<OMPClause *> Clauses,
9305
                                                 SourceLocation StartLoc,
9306
                                                 SourceLocation EndLoc,
9307
                                                 Stmt *AStmt);
9308
  /// Called on well-formed '\#pragma omp target exit data' after
9309
  /// parsing of the associated statement.
9310
  StmtResult ActOnOpenMPTargetExitDataDirective(ArrayRef<OMPClause *> Clauses,
9311
                                                SourceLocation StartLoc,
9312
                                                SourceLocation EndLoc,
9313
                                                Stmt *AStmt);
9314
  /// Called on well-formed '\#pragma omp target parallel' after
9315
  /// parsing of the associated statement.
9316
  StmtResult ActOnOpenMPTargetParallelDirective(ArrayRef<OMPClause *> Clauses,
9317
                                                Stmt *AStmt,
9318
                                                SourceLocation StartLoc,
9319
                                                SourceLocation EndLoc);
9320
  /// Called on well-formed '\#pragma omp target parallel for' after
9321
  /// parsing of the  associated statement.
9322
  StmtResult ActOnOpenMPTargetParallelForDirective(
9323
      ArrayRef<OMPClause *> Clauses, Stmt *AStmt, SourceLocation StartLoc,
9324
      SourceLocation EndLoc, VarsWithInheritedDSAType &VarsWithImplicitDSA);
9325
  /// Called on well-formed '\#pragma omp teams' after parsing of the
9326
  /// associated statement.
9327
  StmtResult ActOnOpenMPTeamsDirective(ArrayRef<OMPClause *> Clauses,
9328
                                       Stmt *AStmt, SourceLocation StartLoc,
9329
                                       SourceLocation EndLoc);
9330
  /// Called on well-formed '\#pragma omp cancellation point'.
9331
  StmtResult
9332
  ActOnOpenMPCancellationPointDirective(SourceLocation StartLoc,
9333
                                        SourceLocation EndLoc,
9334
                                        OpenMPDirectiveKind CancelRegion);
9335
  /// Called on well-formed '\#pragma omp cancel'.
9336
  StmtResult ActOnOpenMPCancelDirective(ArrayRef<OMPClause *> Clauses,
9337
                                        SourceLocation StartLoc,
9338
                                        SourceLocation EndLoc,
9339
                                        OpenMPDirectiveKind CancelRegion);
9340
  /// Called on well-formed '\#pragma omp taskloop' after parsing of the
9341
  /// associated statement.
9342
  StmtResult
9343
  ActOnOpenMPTaskLoopDirective(ArrayRef<OMPClause *> Clauses, Stmt *AStmt,
9344
                               SourceLocation StartLoc, SourceLocation EndLoc,
9345
                               VarsWithInheritedDSAType &VarsWithImplicitDSA);
9346
  /// Called on well-formed '\#pragma omp taskloop simd' after parsing of
9347
  /// the associated statement.
9348
  StmtResult ActOnOpenMPTaskLoopSimdDirective(
9349
      ArrayRef<OMPClause *> Clauses, Stmt *AStmt, SourceLocation StartLoc,
9350
      SourceLocation EndLoc, VarsWithInheritedDSAType &VarsWithImplicitDSA);
9351
  /// Called on well-formed '\#pragma omp distribute' after parsing
9352
  /// of the associated statement.
9353
  StmtResult
9354
  ActOnOpenMPDistributeDirective(ArrayRef<OMPClause *> Clauses, Stmt *AStmt,
9355
                                 SourceLocation StartLoc, SourceLocation EndLoc,
9356
                                 VarsWithInheritedDSAType &VarsWithImplicitDSA);
9357
  /// Called on well-formed '\#pragma omp target update'.
9358
  StmtResult ActOnOpenMPTargetUpdateDirective(ArrayRef<OMPClause *> Clauses,
9359
                                              SourceLocation StartLoc,
9360
                                              SourceLocation EndLoc,
9361
                                              Stmt *AStmt);
9362
  /// Called on well-formed '\#pragma omp distribute parallel for' after
9363
  /// parsing of the associated statement.
9364
  StmtResult ActOnOpenMPDistributeParallelForDirective(
9365
      ArrayRef<OMPClause *> Clauses, Stmt *AStmt, SourceLocation StartLoc,
9366
      SourceLocation EndLoc, VarsWithInheritedDSAType &VarsWithImplicitDSA);
9367
  /// Called on well-formed '\#pragma omp distribute parallel for simd'
9368
  /// after parsing of the associated statement.
9369
  StmtResult ActOnOpenMPDistributeParallelForSimdDirective(
9370
      ArrayRef<OMPClause *> Clauses, Stmt *AStmt, SourceLocation StartLoc,
9371
      SourceLocation EndLoc, VarsWithInheritedDSAType &VarsWithImplicitDSA);
9372
  /// Called on well-formed '\#pragma omp distribute simd' after
9373
  /// parsing of the associated statement.
9374
  StmtResult ActOnOpenMPDistributeSimdDirective(
9375
      ArrayRef<OMPClause *> Clauses, Stmt *AStmt, SourceLocation StartLoc,
9376
      SourceLocation EndLoc, VarsWithInheritedDSAType &VarsWithImplicitDSA);
9377
  /// Called on well-formed '\#pragma omp target parallel for simd' after
9378
  /// parsing of the associated statement.
9379
  StmtResult ActOnOpenMPTargetParallelForSimdDirective(
9380
      ArrayRef<OMPClause *> Clauses, Stmt *AStmt, SourceLocation StartLoc,
9381
      SourceLocation EndLoc, VarsWithInheritedDSAType &VarsWithImplicitDSA);
9382
  /// Called on well-formed '\#pragma omp target simd' after parsing of
9383
  /// the associated statement.
9384
  StmtResult
9385
  ActOnOpenMPTargetSimdDirective(ArrayRef<OMPClause *> Clauses, Stmt *AStmt,
9386
                                 SourceLocation StartLoc, SourceLocation EndLoc,
9387
                                 VarsWithInheritedDSAType &VarsWithImplicitDSA);
9388
  /// Called on well-formed '\#pragma omp teams distribute' after parsing of
9389
  /// the associated statement.
9390
  StmtResult ActOnOpenMPTeamsDistributeDirective(
9391
      ArrayRef<OMPClause *> Clauses, Stmt *AStmt, SourceLocation StartLoc,
9392
      SourceLocation EndLoc, VarsWithInheritedDSAType &VarsWithImplicitDSA);
9393
  /// Called on well-formed '\#pragma omp teams distribute simd' after parsing
9394
  /// of the associated statement.
9395
  StmtResult ActOnOpenMPTeamsDistributeSimdDirective(
9396
      ArrayRef<OMPClause *> Clauses, Stmt *AStmt, SourceLocation StartLoc,
9397
      SourceLocation EndLoc, VarsWithInheritedDSAType &VarsWithImplicitDSA);
9398
  /// Called on well-formed '\#pragma omp teams distribute parallel for simd'
9399
  /// after parsing of the associated statement.
9400
  StmtResult ActOnOpenMPTeamsDistributeParallelForSimdDirective(
9401
      ArrayRef<OMPClause *> Clauses, Stmt *AStmt, SourceLocation StartLoc,
9402
      SourceLocation EndLoc, VarsWithInheritedDSAType &VarsWithImplicitDSA);
9403
  /// Called on well-formed '\#pragma omp teams distribute parallel for'
9404
  /// after parsing of the associated statement.
9405
  StmtResult ActOnOpenMPTeamsDistributeParallelForDirective(
9406
      ArrayRef<OMPClause *> Clauses, Stmt *AStmt, SourceLocation StartLoc,
9407
      SourceLocation EndLoc, VarsWithInheritedDSAType &VarsWithImplicitDSA);
9408
  /// Called on well-formed '\#pragma omp target teams' after parsing of the
9409
  /// associated statement.
9410
  StmtResult ActOnOpenMPTargetTeamsDirective(ArrayRef<OMPClause *> Clauses,
9411
                                             Stmt *AStmt,
9412
                                             SourceLocation StartLoc,
9413
                                             SourceLocation EndLoc);
9414
  /// Called on well-formed '\#pragma omp target teams distribute' after parsing
9415
  /// of the associated statement.
9416
  StmtResult ActOnOpenMPTargetTeamsDistributeDirective(
9417
      ArrayRef<OMPClause *> Clauses, Stmt *AStmt, SourceLocation StartLoc,
9418
      SourceLocation EndLoc, VarsWithInheritedDSAType &VarsWithImplicitDSA);
9419
  /// Called on well-formed '\#pragma omp target teams distribute parallel for'
9420
  /// after parsing of the associated statement.
9421
  StmtResult ActOnOpenMPTargetTeamsDistributeParallelForDirective(
9422
      ArrayRef<OMPClause *> Clauses, Stmt *AStmt, SourceLocation StartLoc,
9423
      SourceLocation EndLoc, VarsWithInheritedDSAType &VarsWithImplicitDSA);
9424
  /// Called on well-formed '\#pragma omp target teams distribute parallel for
9425
  /// simd' after parsing of the associated statement.
9426
  StmtResult ActOnOpenMPTargetTeamsDistributeParallelForSimdDirective(
9427
      ArrayRef<OMPClause *> Clauses, Stmt *AStmt, SourceLocation StartLoc,
9428
      SourceLocation EndLoc, VarsWithInheritedDSAType &VarsWithImplicitDSA);
9429
  /// Called on well-formed '\#pragma omp target teams distribute simd' after
9430
  /// parsing of the associated statement.
9431
  StmtResult ActOnOpenMPTargetTeamsDistributeSimdDirective(
9432
      ArrayRef<OMPClause *> Clauses, Stmt *AStmt, SourceLocation StartLoc,
9433
      SourceLocation EndLoc, VarsWithInheritedDSAType &VarsWithImplicitDSA);
9434
9435
  /// Checks correctness of linear modifiers.
9436
  bool CheckOpenMPLinearModifier(OpenMPLinearClauseKind LinKind,
9437
                                 SourceLocation LinLoc);
9438
  /// Checks that the specified declaration matches requirements for the linear
9439
  /// decls.
9440
  bool CheckOpenMPLinearDecl(const ValueDecl *D, SourceLocation ELoc,
9441
                             OpenMPLinearClauseKind LinKind, QualType Type);
9442
9443
  /// Called on well-formed '\#pragma omp declare simd' after parsing of
9444
  /// the associated method/function.
9445
  DeclGroupPtrTy ActOnOpenMPDeclareSimdDirective(
9446
      DeclGroupPtrTy DG, OMPDeclareSimdDeclAttr::BranchStateTy BS,
9447
      Expr *Simdlen, ArrayRef<Expr *> Uniforms, ArrayRef<Expr *> Aligneds,
9448
      ArrayRef<Expr *> Alignments, ArrayRef<Expr *> Linears,
9449
      ArrayRef<unsigned> LinModifiers, ArrayRef<Expr *> Steps, SourceRange SR);
9450
9451
  OMPClause *ActOnOpenMPSingleExprClause(OpenMPClauseKind Kind,
9452
                                         Expr *Expr,
9453
                                         SourceLocation StartLoc,
9454
                                         SourceLocation LParenLoc,
9455
                                         SourceLocation EndLoc);
9456
  /// Called on well-formed 'allocator' clause.
9457
  OMPClause *ActOnOpenMPAllocatorClause(Expr *Allocator,
9458
                                        SourceLocation StartLoc,
9459
                                        SourceLocation LParenLoc,
9460
                                        SourceLocation EndLoc);
9461
  /// Called on well-formed 'if' clause.
9462
  OMPClause *ActOnOpenMPIfClause(OpenMPDirectiveKind NameModifier,
9463
                                 Expr *Condition, SourceLocation StartLoc,
9464
                                 SourceLocation LParenLoc,
9465
                                 SourceLocation NameModifierLoc,
9466
                                 SourceLocation ColonLoc,
9467
                                 SourceLocation EndLoc);
9468
  /// Called on well-formed 'final' clause.
9469
  OMPClause *ActOnOpenMPFinalClause(Expr *Condition, SourceLocation StartLoc,
9470
                                    SourceLocation LParenLoc,
9471
                                    SourceLocation EndLoc);
9472
  /// Called on well-formed 'num_threads' clause.
9473
  OMPClause *ActOnOpenMPNumThreadsClause(Expr *NumThreads,
9474
                                         SourceLocation StartLoc,
9475
                                         SourceLocation LParenLoc,
9476
                                         SourceLocation EndLoc);
9477
  /// Called on well-formed 'safelen' clause.
9478
  OMPClause *ActOnOpenMPSafelenClause(Expr *Length,
9479
                                      SourceLocation StartLoc,
9480
                                      SourceLocation LParenLoc,
9481
                                      SourceLocation EndLoc);
9482
  /// Called on well-formed 'simdlen' clause.
9483
  OMPClause *ActOnOpenMPSimdlenClause(Expr *Length, SourceLocation StartLoc,
9484
                                      SourceLocation LParenLoc,
9485
                                      SourceLocation EndLoc);
9486
  /// Called on well-formed 'collapse' clause.
9487
  OMPClause *ActOnOpenMPCollapseClause(Expr *NumForLoops,
9488
                                       SourceLocation StartLoc,
9489
                                       SourceLocation LParenLoc,
9490
                                       SourceLocation EndLoc);
9491
  /// Called on well-formed 'ordered' clause.
9492
  OMPClause *
9493
  ActOnOpenMPOrderedClause(SourceLocation StartLoc, SourceLocation EndLoc,
9494
                           SourceLocation LParenLoc = SourceLocation(),
9495
                           Expr *NumForLoops = nullptr);
9496
  /// Called on well-formed 'grainsize' clause.
9497
  OMPClause *ActOnOpenMPGrainsizeClause(Expr *Size, SourceLocation StartLoc,
9498
                                        SourceLocation LParenLoc,
9499
                                        SourceLocation EndLoc);
9500
  /// Called on well-formed 'num_tasks' clause.
9501
  OMPClause *ActOnOpenMPNumTasksClause(Expr *NumTasks, SourceLocation StartLoc,
9502
                                       SourceLocation LParenLoc,
9503
                                       SourceLocation EndLoc);
9504
  /// Called on well-formed 'hint' clause.
9505
  OMPClause *ActOnOpenMPHintClause(Expr *Hint, SourceLocation StartLoc,
9506
                                   SourceLocation LParenLoc,
9507
                                   SourceLocation EndLoc);
9508
9509
  OMPClause *ActOnOpenMPSimpleClause(OpenMPClauseKind Kind,
9510
                                     unsigned Argument,
9511
                                     SourceLocation ArgumentLoc,
9512
                                     SourceLocation StartLoc,
9513
                                     SourceLocation LParenLoc,
9514
                                     SourceLocation EndLoc);
9515
  /// Called on well-formed 'default' clause.
9516
  OMPClause *ActOnOpenMPDefaultClause(OpenMPDefaultClauseKind Kind,
9517
                                      SourceLocation KindLoc,
9518
                                      SourceLocation StartLoc,
9519
                                      SourceLocation LParenLoc,
9520
                                      SourceLocation EndLoc);
9521
  /// Called on well-formed 'proc_bind' clause.
9522
  OMPClause *ActOnOpenMPProcBindClause(OpenMPProcBindClauseKind Kind,
9523
                                       SourceLocation KindLoc,
9524
                                       SourceLocation StartLoc,
9525
                                       SourceLocation LParenLoc,
9526
                                       SourceLocation EndLoc);
9527
9528
  OMPClause *ActOnOpenMPSingleExprWithArgClause(
9529
      OpenMPClauseKind Kind, ArrayRef<unsigned> Arguments, Expr *Expr,
9530
      SourceLocation StartLoc, SourceLocation LParenLoc,
9531
      ArrayRef<SourceLocation> ArgumentsLoc, SourceLocation DelimLoc,
9532
      SourceLocation EndLoc);
9533
  /// Called on well-formed 'schedule' clause.
9534
  OMPClause *ActOnOpenMPScheduleClause(
9535
      OpenMPScheduleClauseModifier M1, OpenMPScheduleClauseModifier M2,
9536
      OpenMPScheduleClauseKind Kind, Expr *ChunkSize, SourceLocation StartLoc,
9537
      SourceLocation LParenLoc, SourceLocation M1Loc, SourceLocation M2Loc,
9538
      SourceLocation KindLoc, SourceLocation CommaLoc, SourceLocation EndLoc);
9539
9540
  OMPClause *ActOnOpenMPClause(OpenMPClauseKind Kind, SourceLocation StartLoc,
9541
                               SourceLocation EndLoc);
9542
  /// Called on well-formed 'nowait' clause.
9543
  OMPClause *ActOnOpenMPNowaitClause(SourceLocation StartLoc,
9544
                                     SourceLocation EndLoc);
9545
  /// Called on well-formed 'untied' clause.
9546
  OMPClause *ActOnOpenMPUntiedClause(SourceLocation StartLoc,
9547
                                     SourceLocation EndLoc);
9548
  /// Called on well-formed 'mergeable' clause.
9549
  OMPClause *ActOnOpenMPMergeableClause(SourceLocation StartLoc,
9550
                                        SourceLocation EndLoc);
9551
  /// Called on well-formed 'read' clause.
9552
  OMPClause *ActOnOpenMPReadClause(SourceLocation StartLoc,
9553
                                   SourceLocation EndLoc);
9554
  /// Called on well-formed 'write' clause.
9555
  OMPClause *ActOnOpenMPWriteClause(SourceLocation StartLoc,
9556
                                    SourceLocation EndLoc);
9557
  /// Called on well-formed 'update' clause.
9558
  OMPClause *ActOnOpenMPUpdateClause(SourceLocation StartLoc,
9559
                                     SourceLocation EndLoc);
9560
  /// Called on well-formed 'capture' clause.
9561
  OMPClause *ActOnOpenMPCaptureClause(SourceLocation StartLoc,
9562
                                      SourceLocation EndLoc);
9563
  /// Called on well-formed 'seq_cst' clause.
9564
  OMPClause *ActOnOpenMPSeqCstClause(SourceLocation StartLoc,
9565
                                     SourceLocation EndLoc);
9566
  /// Called on well-formed 'threads' clause.
9567
  OMPClause *ActOnOpenMPThreadsClause(SourceLocation StartLoc,
9568
                                      SourceLocation EndLoc);
9569
  /// Called on well-formed 'simd' clause.
9570
  OMPClause *ActOnOpenMPSIMDClause(SourceLocation StartLoc,
9571
                                   SourceLocation EndLoc);
9572
  /// Called on well-formed 'nogroup' clause.
9573
  OMPClause *ActOnOpenMPNogroupClause(SourceLocation StartLoc,
9574
                                      SourceLocation EndLoc);
9575
  /// Called on well-formed 'unified_address' clause.
9576
  OMPClause *ActOnOpenMPUnifiedAddressClause(SourceLocation StartLoc,
9577
                                             SourceLocation EndLoc);
9578
9579
  /// Called on well-formed 'unified_address' clause.
9580
  OMPClause *ActOnOpenMPUnifiedSharedMemoryClause(SourceLocation StartLoc,
9581
                                                  SourceLocation EndLoc);
9582
9583
  /// Called on well-formed 'reverse_offload' clause.
9584
  OMPClause *ActOnOpenMPReverseOffloadClause(SourceLocation StartLoc,
9585
                                             SourceLocation EndLoc);
9586
9587
  /// Called on well-formed 'dynamic_allocators' clause.
9588
  OMPClause *ActOnOpenMPDynamicAllocatorsClause(SourceLocation StartLoc,
9589
                                                SourceLocation EndLoc);
9590
9591
  /// Called on well-formed 'atomic_default_mem_order' clause.
9592
  OMPClause *ActOnOpenMPAtomicDefaultMemOrderClause(
9593
      OpenMPAtomicDefaultMemOrderClauseKind Kind, SourceLocation KindLoc,
9594
      SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc);
9595
9596
  OMPClause *ActOnOpenMPVarListClause(
9597
      OpenMPClauseKind Kind, ArrayRef<Expr *> Vars, Expr *TailExpr,
9598
      const OMPVarListLocTy &Locs, SourceLocation ColonLoc,
9599
      CXXScopeSpec &ReductionOrMapperIdScopeSpec,
9600
      DeclarationNameInfo &ReductionOrMapperId, OpenMPDependClauseKind DepKind,
9601
      OpenMPLinearClauseKind LinKind,
9602
      ArrayRef<OpenMPMapModifierKind> MapTypeModifiers,
9603
      ArrayRef<SourceLocation> MapTypeModifiersLoc, OpenMPMapClauseKind MapType,
9604
      bool IsMapTypeImplicit, SourceLocation DepLinMapLoc);
9605
  /// Called on well-formed 'allocate' clause.
9606
  OMPClause *
9607
  ActOnOpenMPAllocateClause(Expr *Allocator, ArrayRef<Expr *> VarList,
9608
                            SourceLocation StartLoc, SourceLocation ColonLoc,
9609
                            SourceLocation LParenLoc, SourceLocation EndLoc);
9610
  /// Called on well-formed 'private' clause.
9611
  OMPClause *ActOnOpenMPPrivateClause(ArrayRef<Expr *> VarList,
9612
                                      SourceLocation StartLoc,
9613
                                      SourceLocation LParenLoc,
9614
                                      SourceLocation EndLoc);
9615
  /// Called on well-formed 'firstprivate' clause.
9616
  OMPClause *ActOnOpenMPFirstprivateClause(ArrayRef<Expr *> VarList,
9617
                                           SourceLocation StartLoc,
9618
                                           SourceLocation LParenLoc,
9619
                                           SourceLocation EndLoc);
9620
  /// Called on well-formed 'lastprivate' clause.
9621
  OMPClause *ActOnOpenMPLastprivateClause(ArrayRef<Expr *> VarList,
9622
                                          SourceLocation StartLoc,
9623
                                          SourceLocation LParenLoc,
9624
                                          SourceLocation EndLoc);
9625
  /// Called on well-formed 'shared' clause.
9626
  OMPClause *ActOnOpenMPSharedClause(ArrayRef<Expr *> VarList,
9627
                                     SourceLocation StartLoc,
9628
                                     SourceLocation LParenLoc,
9629
                                     SourceLocation EndLoc);
9630
  /// Called on well-formed 'reduction' clause.
9631
  OMPClause *ActOnOpenMPReductionClause(
9632
      ArrayRef<Expr *> VarList, SourceLocation StartLoc,
9633
      SourceLocation LParenLoc, SourceLocation ColonLoc, SourceLocation EndLoc,
9634
      CXXScopeSpec &ReductionIdScopeSpec,
9635
      const DeclarationNameInfo &ReductionId,
9636
      ArrayRef<Expr *> UnresolvedReductions = llvm::None);
9637
  /// Called on well-formed 'task_reduction' clause.
9638
  OMPClause *ActOnOpenMPTaskReductionClause(
9639
      ArrayRef<Expr *> VarList, SourceLocation StartLoc,
9640
      SourceLocation LParenLoc, SourceLocation ColonLoc, SourceLocation EndLoc,
9641
      CXXScopeSpec &ReductionIdScopeSpec,
9642
      const DeclarationNameInfo &ReductionId,
9643
      ArrayRef<Expr *> UnresolvedReductions = llvm::None);
9644
  /// Called on well-formed 'in_reduction' clause.
9645
  OMPClause *ActOnOpenMPInReductionClause(
9646
      ArrayRef<Expr *> VarList, SourceLocation StartLoc,
9647
      SourceLocation LParenLoc, SourceLocation ColonLoc, SourceLocation EndLoc,
9648
      CXXScopeSpec &ReductionIdScopeSpec,
9649
      const DeclarationNameInfo &ReductionId,
9650
      ArrayRef<Expr *> UnresolvedReductions = llvm::None);
9651
  /// Called on well-formed 'linear' clause.
9652
  OMPClause *
9653
  ActOnOpenMPLinearClause(ArrayRef<Expr *> VarList, Expr *Step,
9654
                          SourceLocation StartLoc, SourceLocation LParenLoc,
9655
                          OpenMPLinearClauseKind LinKind, SourceLocation LinLoc,
9656
                          SourceLocation ColonLoc, SourceLocation EndLoc);
9657
  /// Called on well-formed 'aligned' clause.
9658
  OMPClause *ActOnOpenMPAlignedClause(ArrayRef<Expr *> VarList,
9659
                                      Expr *Alignment,
9660
                                      SourceLocation StartLoc,
9661
                                      SourceLocation LParenLoc,
9662
                                      SourceLocation ColonLoc,
9663
                                      SourceLocation EndLoc);
9664
  /// Called on well-formed 'copyin' clause.
9665
  OMPClause *ActOnOpenMPCopyinClause(ArrayRef<Expr *> VarList,
9666
                                     SourceLocation StartLoc,
9667
                                     SourceLocation LParenLoc,
9668
                                     SourceLocation EndLoc);
9669
  /// Called on well-formed 'copyprivate' clause.
9670
  OMPClause *ActOnOpenMPCopyprivateClause(ArrayRef<Expr *> VarList,
9671
                                          SourceLocation StartLoc,
9672
                                          SourceLocation LParenLoc,
9673
                                          SourceLocation EndLoc);
9674
  /// Called on well-formed 'flush' pseudo clause.
9675
  OMPClause *ActOnOpenMPFlushClause(ArrayRef<Expr *> VarList,
9676
                                    SourceLocation StartLoc,
9677
                                    SourceLocation LParenLoc,
9678
                                    SourceLocation EndLoc);
9679
  /// Called on well-formed 'depend' clause.
9680
  OMPClause *
9681
  ActOnOpenMPDependClause(OpenMPDependClauseKind DepKind, SourceLocation DepLoc,
9682
                          SourceLocation ColonLoc, ArrayRef<Expr *> VarList,
9683
                          SourceLocation StartLoc, SourceLocation LParenLoc,
9684
                          SourceLocation EndLoc);
9685
  /// Called on well-formed 'device' clause.
9686
  OMPClause *ActOnOpenMPDeviceClause(Expr *Device, SourceLocation StartLoc,
9687
                                     SourceLocation LParenLoc,
9688
                                     SourceLocation EndLoc);
9689
  /// Called on well-formed 'map' clause.
9690
  OMPClause *
9691
  ActOnOpenMPMapClause(ArrayRef<OpenMPMapModifierKind> MapTypeModifiers,
9692
                       ArrayRef<SourceLocation> MapTypeModifiersLoc,
9693
                       CXXScopeSpec &MapperIdScopeSpec,
9694
                       DeclarationNameInfo &MapperId,
9695
                       OpenMPMapClauseKind MapType, bool IsMapTypeImplicit,
9696
                       SourceLocation MapLoc, SourceLocation ColonLoc,
9697
                       ArrayRef<Expr *> VarList, const OMPVarListLocTy &Locs,
9698
                       ArrayRef<Expr *> UnresolvedMappers = llvm::None);
9699
  /// Called on well-formed 'num_teams' clause.
9700
  OMPClause *ActOnOpenMPNumTeamsClause(Expr *NumTeams, SourceLocation StartLoc,
9701
                                       SourceLocation LParenLoc,
9702
                                       SourceLocation EndLoc);
9703
  /// Called on well-formed 'thread_limit' clause.
9704
  OMPClause *ActOnOpenMPThreadLimitClause(Expr *ThreadLimit,
9705
                                          SourceLocation StartLoc,
9706
                                          SourceLocation LParenLoc,
9707
                                          SourceLocation EndLoc);
9708
  /// Called on well-formed 'priority' clause.
9709
  OMPClause *ActOnOpenMPPriorityClause(Expr *Priority, SourceLocation StartLoc,
9710
                                       SourceLocation LParenLoc,
9711
                                       SourceLocation EndLoc);
9712
  /// Called on well-formed 'dist_schedule' clause.
9713
  OMPClause *ActOnOpenMPDistScheduleClause(
9714
      OpenMPDistScheduleClauseKind Kind, Expr *ChunkSize,
9715
      SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation KindLoc,
9716
      SourceLocation CommaLoc, SourceLocation EndLoc);
9717
  /// Called on well-formed 'defaultmap' clause.
9718
  OMPClause *ActOnOpenMPDefaultmapClause(
9719
      OpenMPDefaultmapClauseModifier M, OpenMPDefaultmapClauseKind Kind,
9720
      SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation MLoc,
9721
      SourceLocation KindLoc, SourceLocation EndLoc);
9722
  /// Called on well-formed 'to' clause.
9723
  OMPClause *
9724
  ActOnOpenMPToClause(ArrayRef<Expr *> VarList, CXXScopeSpec &MapperIdScopeSpec,
9725
                      DeclarationNameInfo &MapperId,
9726
                      const OMPVarListLocTy &Locs,
9727
                      ArrayRef<Expr *> UnresolvedMappers = llvm::None);
9728
  /// Called on well-formed 'from' clause.
9729
  OMPClause *ActOnOpenMPFromClause(
9730
      ArrayRef<Expr *> VarList, CXXScopeSpec &MapperIdScopeSpec,
9731
      DeclarationNameInfo &MapperId, const OMPVarListLocTy &Locs,
9732
      ArrayRef<Expr *> UnresolvedMappers = llvm::None);
9733
  /// Called on well-formed 'use_device_ptr' clause.
9734
  OMPClause *ActOnOpenMPUseDevicePtrClause(ArrayRef<Expr *> VarList,
9735
                                           const OMPVarListLocTy &Locs);
9736
  /// Called on well-formed 'is_device_ptr' clause.
9737
  OMPClause *ActOnOpenMPIsDevicePtrClause(ArrayRef<Expr *> VarList,
9738
                                          const OMPVarListLocTy &Locs);
9739
9740
  /// The kind of conversion being performed.
9741
  enum CheckedConversionKind {
9742
    /// An implicit conversion.
9743
    CCK_ImplicitConversion,
9744
    /// A C-style cast.
9745
    CCK_CStyleCast,
9746
    /// A functional-style cast.
9747
    CCK_FunctionalCast,
9748
    /// A cast other than a C-style cast.
9749
    CCK_OtherCast,
9750
    /// A conversion for an operand of a builtin overloaded operator.
9751
    CCK_ForBuiltinOverloadedOp
9752
  };
9753
9754
12.5M
  static bool isCast(CheckedConversionKind CCK) {
9755
12.5M
    return CCK == CCK_CStyleCast || 
CCK == CCK_FunctionalCast12.0M
||
9756
12.5M
           
CCK == CCK_OtherCast11.9M
;
9757
12.5M
  }
9758
9759
  /// ImpCastExprToType - If Expr is not of type 'Type', insert an implicit
9760
  /// cast.  If there is already an implicit cast, merge into the existing one.
9761
  /// If isLvalue, the result of the cast is an lvalue.
9762
  ExprResult ImpCastExprToType(Expr *E, QualType Type, CastKind CK,
9763
                               ExprValueKind VK = VK_RValue,
9764
                               const CXXCastPath *BasePath = nullptr,
9765
                               CheckedConversionKind CCK
9766
                                  = CCK_ImplicitConversion);
9767
9768
  /// ScalarTypeToBooleanCastKind - Returns the cast kind corresponding
9769
  /// to the conversion from scalar type ScalarTy to the Boolean type.
9770
  static CastKind ScalarTypeToBooleanCastKind(QualType ScalarTy);
9771
9772
  /// IgnoredValueConversions - Given that an expression's result is
9773
  /// syntactically ignored, perform any conversions that are
9774
  /// required.
9775
  ExprResult IgnoredValueConversions(Expr *E);
9776
9777
  // UsualUnaryConversions - promotes integers (C99 6.3.1.1p2) and converts
9778
  // functions and arrays to their respective pointers (C99 6.3.2.1).
9779
  ExprResult UsualUnaryConversions(Expr *E);
9780
9781
  /// CallExprUnaryConversions - a special case of an unary conversion
9782
  /// performed on a function designator of a call expression.
9783
  ExprResult CallExprUnaryConversions(Expr *E);
9784
9785
  // DefaultFunctionArrayConversion - converts functions and arrays
9786
  // to their respective pointers (C99 6.3.2.1).
9787
  ExprResult DefaultFunctionArrayConversion(Expr *E, bool Diagnose = true);
9788
9789
  // DefaultFunctionArrayLvalueConversion - converts functions and
9790
  // arrays to their respective pointers and performs the
9791
  // lvalue-to-rvalue conversion.
9792
  ExprResult DefaultFunctionArrayLvalueConversion(Expr *E,
9793
                                                  bool Diagnose = true);
9794
9795
  // DefaultLvalueConversion - performs lvalue-to-rvalue conversion on
9796
  // the operand.  This is DefaultFunctionArrayLvalueConversion,
9797
  // except that it assumes the operand isn't of function or array
9798
  // type.
9799
  ExprResult DefaultLvalueConversion(Expr *E);
9800
9801
  // DefaultArgumentPromotion (C99 6.5.2.2p6). Used for function calls that
9802
  // do not have a prototype. Integer promotions are performed on each
9803
  // argument, and arguments that have type float are promoted to double.
9804
  ExprResult DefaultArgumentPromotion(Expr *E);
9805
9806
  /// If \p E is a prvalue denoting an unmaterialized temporary, materialize
9807
  /// it as an xvalue. In C++98, the result will still be a prvalue, because
9808
  /// we don't have xvalues there.
9809
  ExprResult TemporaryMaterializationConversion(Expr *E);
9810
9811
  // Used for emitting the right warning by DefaultVariadicArgumentPromotion
9812
  enum VariadicCallType {
9813
    VariadicFunction,
9814
    VariadicBlock,
9815
    VariadicMethod,
9816
    VariadicConstructor,
9817
    VariadicDoesNotApply
9818
  };
9819
9820
  VariadicCallType getVariadicCallType(FunctionDecl *FDecl,
9821
                                       const FunctionProtoType *Proto,
9822
                                       Expr *Fn);
9823
9824
  // Used for determining in which context a type is allowed to be passed to a
9825
  // vararg function.
9826
  enum VarArgKind {
9827
    VAK_Valid,
9828
    VAK_ValidInCXX11,
9829
    VAK_Undefined,
9830
    VAK_MSVCUndefined,
9831
    VAK_Invalid
9832
  };
9833
9834
  // Determines which VarArgKind fits an expression.
9835
  VarArgKind isValidVarArgType(const QualType &Ty);
9836
9837
  /// Check to see if the given expression is a valid argument to a variadic
9838
  /// function, issuing a diagnostic if not.
9839
  void checkVariadicArgument(const Expr *E, VariadicCallType CT);
9840
9841
  /// Check to see if a given expression could have '.c_str()' called on it.
9842
  bool hasCStrMethod(const Expr *E);
9843
9844
  /// GatherArgumentsForCall - Collector argument expressions for various
9845
  /// form of call prototypes.
9846
  bool GatherArgumentsForCall(SourceLocation CallLoc, FunctionDecl *FDecl,
9847
                              const FunctionProtoType *Proto,
9848
                              unsigned FirstParam, ArrayRef<Expr *> Args,
9849
                              SmallVectorImpl<Expr *> &AllArgs,
9850
                              VariadicCallType CallType = VariadicDoesNotApply,
9851
                              bool AllowExplicit = false,
9852
                              bool IsListInitialization = false);
9853
9854
  // DefaultVariadicArgumentPromotion - Like DefaultArgumentPromotion, but
9855
  // will create a runtime trap if the resulting type is not a POD type.
9856
  ExprResult DefaultVariadicArgumentPromotion(Expr *E, VariadicCallType CT,
9857
                                              FunctionDecl *FDecl);
9858
9859
  // UsualArithmeticConversions - performs the UsualUnaryConversions on it's
9860
  // operands and then handles various conversions that are common to binary
9861
  // operators (C99 6.3.1.8). If both operands aren't arithmetic, this
9862
  // routine returns the first non-arithmetic type found. The client is
9863
  // responsible for emitting appropriate error diagnostics.
9864
  QualType UsualArithmeticConversions(ExprResult &LHS, ExprResult &RHS,
9865
                                      bool IsCompAssign = false);
9866
9867
  /// AssignConvertType - All of the 'assignment' semantic checks return this
9868
  /// enum to indicate whether the assignment was allowed.  These checks are
9869
  /// done for simple assignments, as well as initialization, return from
9870
  /// function, argument passing, etc.  The query is phrased in terms of a
9871
  /// source and destination type.
9872
  enum AssignConvertType {
9873
    /// Compatible - the types are compatible according to the standard.
9874
    Compatible,
9875
9876
    /// PointerToInt - The assignment converts a pointer to an int, which we
9877
    /// accept as an extension.
9878
    PointerToInt,
9879
9880
    /// IntToPointer - The assignment converts an int to a pointer, which we
9881
    /// accept as an extension.
9882
    IntToPointer,
9883
9884
    /// FunctionVoidPointer - The assignment is between a function pointer and
9885
    /// void*, which the standard doesn't allow, but we accept as an extension.
9886
    FunctionVoidPointer,
9887
9888
    /// IncompatiblePointer - The assignment is between two pointers types that
9889
    /// are not compatible, but we accept them as an extension.
9890
    IncompatiblePointer,
9891
9892
    /// IncompatiblePointerSign - The assignment is between two pointers types
9893
    /// which point to integers which have a different sign, but are otherwise
9894
    /// identical. This is a subset of the above, but broken out because it's by
9895
    /// far the most common case of incompatible pointers.
9896
    IncompatiblePointerSign,
9897
9898
    /// CompatiblePointerDiscardsQualifiers - The assignment discards
9899
    /// c/v/r qualifiers, which we accept as an extension.
9900
    CompatiblePointerDiscardsQualifiers,
9901
9902
    /// IncompatiblePointerDiscardsQualifiers - The assignment
9903
    /// discards qualifiers that we don't permit to be discarded,
9904
    /// like address spaces.
9905
    IncompatiblePointerDiscardsQualifiers,
9906
9907
    /// IncompatibleNestedPointerAddressSpaceMismatch - The assignment
9908
    /// changes address spaces in nested pointer types which is not allowed.
9909
    /// For instance, converting __private int ** to __generic int ** is
9910
    /// illegal even though __private could be converted to __generic.
9911
    IncompatibleNestedPointerAddressSpaceMismatch,
9912
9913
    /// IncompatibleNestedPointerQualifiers - The assignment is between two
9914
    /// nested pointer types, and the qualifiers other than the first two
9915
    /// levels differ e.g. char ** -> const char **, but we accept them as an
9916
    /// extension.
9917
    IncompatibleNestedPointerQualifiers,
9918
9919
    /// IncompatibleVectors - The assignment is between two vector types that
9920
    /// have the same size, which we accept as an extension.
9921
    IncompatibleVectors,
9922
9923
    /// IntToBlockPointer - The assignment converts an int to a block
9924
    /// pointer. We disallow this.
9925
    IntToBlockPointer,
9926
9927
    /// IncompatibleBlockPointer - The assignment is between two block
9928
    /// pointers types that are not compatible.
9929
    IncompatibleBlockPointer,
9930
9931
    /// IncompatibleObjCQualifiedId - The assignment is between a qualified
9932
    /// id type and something else (that is incompatible with it). For example,
9933
    /// "id <XXX>" = "Foo *", where "Foo *" doesn't implement the XXX protocol.
9934
    IncompatibleObjCQualifiedId,
9935
9936
    /// IncompatibleObjCWeakRef - Assigning a weak-unavailable object to an
9937
    /// object with __weak qualifier.
9938
    IncompatibleObjCWeakRef,
9939
9940
    /// Incompatible - We reject this conversion outright, it is invalid to
9941
    /// represent it in the AST.
9942
    Incompatible
9943
  };
9944
9945
  /// DiagnoseAssignmentResult - Emit a diagnostic, if required, for the
9946
  /// assignment conversion type specified by ConvTy.  This returns true if the
9947
  /// conversion was invalid or false if the conversion was accepted.
9948
  bool DiagnoseAssignmentResult(AssignConvertType ConvTy,
9949
                                SourceLocation Loc,
9950
                                QualType DstType, QualType SrcType,
9951
                                Expr *SrcExpr, AssignmentAction Action,
9952
                                bool *Complained = nullptr);
9953
9954
  /// IsValueInFlagEnum - Determine if a value is allowed as part of a flag
9955
  /// enum. If AllowMask is true, then we also allow the complement of a valid
9956
  /// value, to be used as a mask.
9957
  bool IsValueInFlagEnum(const EnumDecl *ED, const llvm::APInt &Val,
9958
                         bool AllowMask) const;
9959
9960
  /// DiagnoseAssignmentEnum - Warn if assignment to enum is a constant
9961
  /// integer not in the range of enum values.
9962
  void DiagnoseAssignmentEnum(QualType DstType, QualType SrcType,
9963
                              Expr *SrcExpr);
9964
9965
  /// CheckAssignmentConstraints - Perform type checking for assignment,
9966
  /// argument passing, variable initialization, and function return values.
9967
  /// C99 6.5.16.
9968
  AssignConvertType CheckAssignmentConstraints(SourceLocation Loc,
9969
                                               QualType LHSType,
9970
                                               QualType RHSType);
9971
9972
  /// Check assignment constraints and optionally prepare for a conversion of
9973
  /// the RHS to the LHS type. The conversion is prepared for if ConvertRHS
9974
  /// is true.
9975
  AssignConvertType CheckAssignmentConstraints(QualType LHSType,
9976
                                               ExprResult &RHS,
9977
                                               CastKind &Kind,
9978
                                               bool ConvertRHS = true);
9979
9980
  /// Check assignment constraints for an assignment of RHS to LHSType.
9981
  ///
9982
  /// \param LHSType The destination type for the assignment.
9983
  /// \param RHS The source expression for the assignment.
9984
  /// \param Diagnose If \c true, diagnostics may be produced when checking
9985
  ///        for assignability. If a diagnostic is produced, \p RHS will be
9986
  ///        set to ExprError(). Note that this function may still return
9987
  ///        without producing a diagnostic, even for an invalid assignment.
9988
  /// \param DiagnoseCFAudited If \c true, the target is a function parameter
9989
  ///        in an audited Core Foundation API and does not need to be checked
9990
  ///        for ARC retain issues.
9991
  /// \param ConvertRHS If \c true, \p RHS will be updated to model the
9992
  ///        conversions necessary to perform the assignment. If \c false,
9993
  ///        \p Diagnose must also be \c false.
9994
  AssignConvertType CheckSingleAssignmentConstraints(
9995
      QualType LHSType, ExprResult &RHS, bool Diagnose = true,
9996
      bool DiagnoseCFAudited = false, bool ConvertRHS = true);
9997
9998
  // If the lhs type is a transparent union, check whether we
9999
  // can initialize the transparent union with the given expression.
10000
  AssignConvertType CheckTransparentUnionArgumentConstraints(QualType ArgType,
10001
                                                             ExprResult &RHS);
10002
10003
  bool IsStringLiteralToNonConstPointerConversion(Expr *From, QualType ToType);
10004
10005
  bool CheckExceptionSpecCompatibility(Expr *From, QualType ToType);
10006
10007
  ExprResult PerformImplicitConversion(Expr *From, QualType ToType,
10008
                                       AssignmentAction Action,
10009
                                       bool AllowExplicit = false);
10010
  ExprResult PerformImplicitConversion(Expr *From, QualType ToType,
10011
                                       AssignmentAction Action,
10012
                                       bool AllowExplicit,
10013
                                       ImplicitConversionSequence& ICS);
10014
  ExprResult PerformImplicitConversion(Expr *From, QualType ToType,
10015
                                       const ImplicitConversionSequence& ICS,
10016
                                       AssignmentAction Action,
10017
                                       CheckedConversionKind CCK
10018
                                          = CCK_ImplicitConversion);
10019
  ExprResult PerformImplicitConversion(Expr *From, QualType ToType,
10020
                                       const StandardConversionSequence& SCS,
10021
                                       AssignmentAction Action,
10022
                                       CheckedConversionKind CCK);
10023
10024
  ExprResult PerformQualificationConversion(
10025
      Expr *E, QualType Ty, ExprValueKind VK = VK_RValue,
10026
      CheckedConversionKind CCK = CCK_ImplicitConversion);
10027
10028
  /// the following "Check" methods will return a valid/converted QualType
10029
  /// or a null QualType (indicating an error diagnostic was issued).
10030
10031
  /// type checking binary operators (subroutines of CreateBuiltinBinOp).
10032
  QualType InvalidOperands(SourceLocation Loc, ExprResult &LHS,
10033
                           ExprResult &RHS);
10034
  QualType InvalidLogicalVectorOperands(SourceLocation Loc, ExprResult &LHS,
10035
                                 ExprResult &RHS);
10036
  QualType CheckPointerToMemberOperands( // C++ 5.5
10037
    ExprResult &LHS, ExprResult &RHS, ExprValueKind &VK,
10038
    SourceLocation OpLoc, bool isIndirect);
10039
  QualType CheckMultiplyDivideOperands( // C99 6.5.5
10040
    ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, bool IsCompAssign,
10041
    bool IsDivide);
10042
  QualType CheckRemainderOperands( // C99 6.5.5
10043
    ExprResult &LHS, ExprResult &RHS, SourceLocation Loc,
10044
    bool IsCompAssign = false);
10045
  QualType CheckAdditionOperands( // C99 6.5.6
10046
    ExprResult &LHS, ExprResult &RHS, SourceLocation Loc,
10047
    BinaryOperatorKind Opc, QualType* CompLHSTy = nullptr);
10048
  QualType CheckSubtractionOperands( // C99 6.5.6
10049
    ExprResult &LHS, ExprResult &RHS, SourceLocation Loc,
10050
    QualType* CompLHSTy = nullptr);
10051
  QualType CheckShiftOperands( // C99 6.5.7
10052
    ExprResult &LHS, ExprResult &RHS, SourceLocation Loc,
10053
    BinaryOperatorKind Opc, bool IsCompAssign = false);
10054
  QualType CheckCompareOperands( // C99 6.5.8/9
10055
      ExprResult &LHS, ExprResult &RHS, SourceLocation Loc,
10056
      BinaryOperatorKind Opc);
10057
  QualType CheckBitwiseOperands( // C99 6.5.[10...12]
10058
      ExprResult &LHS, ExprResult &RHS, SourceLocation Loc,
10059
      BinaryOperatorKind Opc);
10060
  QualType CheckLogicalOperands( // C99 6.5.[13,14]
10061
    ExprResult &LHS, ExprResult &RHS, SourceLocation Loc,
10062
    BinaryOperatorKind Opc);
10063
  // CheckAssignmentOperands is used for both simple and compound assignment.
10064
  // For simple assignment, pass both expressions and a null converted type.
10065
  // For compound assignment, pass both expressions and the converted type.
10066
  QualType CheckAssignmentOperands( // C99 6.5.16.[1,2]
10067
    Expr *LHSExpr, ExprResult &RHS, SourceLocation Loc, QualType CompoundType);
10068
10069
  ExprResult checkPseudoObjectIncDec(Scope *S, SourceLocation OpLoc,
10070
                                     UnaryOperatorKind Opcode, Expr *Op);
10071
  ExprResult checkPseudoObjectAssignment(Scope *S, SourceLocation OpLoc,
10072
                                         BinaryOperatorKind Opcode,
10073
                                         Expr *LHS, Expr *RHS);
10074
  ExprResult checkPseudoObjectRValue(Expr *E);
10075
  Expr *recreateSyntacticForm(PseudoObjectExpr *E);
10076
10077
  QualType CheckConditionalOperands( // C99 6.5.15
10078
    ExprResult &Cond, ExprResult &LHS, ExprResult &RHS,
10079
    ExprValueKind &VK, ExprObjectKind &OK, SourceLocation QuestionLoc);
10080
  QualType CXXCheckConditionalOperands( // C++ 5.16
10081
    ExprResult &cond, ExprResult &lhs, ExprResult &rhs,
10082
    ExprValueKind &VK, ExprObjectKind &OK, SourceLocation questionLoc);
10083
  QualType FindCompositePointerType(SourceLocation Loc, Expr *&E1, Expr *&E2,
10084
                                    bool ConvertArgs = true);
10085
  QualType FindCompositePointerType(SourceLocation Loc,
10086
                                    ExprResult &E1, ExprResult &E2,
10087
45.6k
                                    bool ConvertArgs = true) {
10088
45.6k
    Expr *E1Tmp = E1.get(), *E2Tmp = E2.get();
10089
45.6k
    QualType Composite =
10090
45.6k
        FindCompositePointerType(Loc, E1Tmp, E2Tmp, ConvertArgs);
10091
45.6k
    E1 = E1Tmp;
10092
45.6k
    E2 = E2Tmp;
10093
45.6k
    return Composite;
10094
45.6k
  }
10095
10096
  QualType FindCompositeObjCPointerType(ExprResult &LHS, ExprResult &RHS,
10097
                                        SourceLocation QuestionLoc);
10098
10099
  bool DiagnoseConditionalForNull(Expr *LHSExpr, Expr *RHSExpr,
10100
                                  SourceLocation QuestionLoc);
10101
10102
  void DiagnoseAlwaysNonNullPointer(Expr *E,
10103
                                    Expr::NullPointerConstantKind NullType,
10104
                                    bool IsEqual, SourceRange Range);
10105
10106
  /// type checking for vector binary operators.
10107
  QualType CheckVectorOperands(ExprResult &LHS, ExprResult &RHS,
10108
                               SourceLocation Loc, bool IsCompAssign,
10109
                               bool AllowBothBool, bool AllowBoolConversion);
10110
  QualType GetSignedVectorType(QualType V);
10111
  QualType CheckVectorCompareOperands(ExprResult &LHS, ExprResult &RHS,
10112
                                      SourceLocation Loc,
10113
                                      BinaryOperatorKind Opc);
10114
  QualType CheckVectorLogicalOperands(ExprResult &LHS, ExprResult &RHS,
10115
                                      SourceLocation Loc);
10116
10117
  bool areLaxCompatibleVectorTypes(QualType srcType, QualType destType);
10118
  bool isLaxVectorConversion(QualType srcType, QualType destType);
10119
10120
  /// type checking declaration initializers (C99 6.7.8)
10121
  bool CheckForConstantInitializer(Expr *e, QualType t);
10122
10123
  // type checking C++ declaration initializers (C++ [dcl.init]).
10124
10125
  /// ReferenceCompareResult - Expresses the result of comparing two
10126
  /// types (cv1 T1 and cv2 T2) to determine their compatibility for the
10127
  /// purposes of initialization by reference (C++ [dcl.init.ref]p4).
10128
  enum ReferenceCompareResult {
10129
    /// Ref_Incompatible - The two types are incompatible, so direct
10130
    /// reference binding is not possible.
10131
    Ref_Incompatible = 0,
10132
    /// Ref_Related - The two types are reference-related, which means
10133
    /// that their unqualified forms (T1 and T2) are either the same
10134
    /// or T1 is a base class of T2.
10135
    Ref_Related,
10136
    /// Ref_Compatible - The two types are reference-compatible.
10137
    Ref_Compatible
10138
  };
10139
10140
  ReferenceCompareResult CompareReferenceRelationship(SourceLocation Loc,
10141
                                                      QualType T1, QualType T2,
10142
                                                      bool &DerivedToBase,
10143
                                                      bool &ObjCConversion,
10144
                                                bool &ObjCLifetimeConversion);
10145
10146
  ExprResult checkUnknownAnyCast(SourceRange TypeRange, QualType CastType,
10147
                                 Expr *CastExpr, CastKind &CastKind,
10148
                                 ExprValueKind &VK, CXXCastPath &Path);
10149
10150
  /// Force an expression with unknown-type to an expression of the
10151
  /// given type.
10152
  ExprResult forceUnknownAnyToType(Expr *E, QualType ToType);
10153
10154
  /// Type-check an expression that's being passed to an
10155
  /// __unknown_anytype parameter.
10156
  ExprResult checkUnknownAnyArg(SourceLocation callLoc,
10157
                                Expr *result, QualType &paramType);
10158
10159
  // CheckVectorCast - check type constraints for vectors.
10160
  // Since vectors are an extension, there are no C standard reference for this.
10161
  // We allow casting between vectors and integer datatypes of the same size.
10162
  // returns true if the cast is invalid
10163
  bool CheckVectorCast(SourceRange R, QualType VectorTy, QualType Ty,
10164
                       CastKind &Kind);
10165
10166
  /// Prepare `SplattedExpr` for a vector splat operation, adding
10167
  /// implicit casts if necessary.
10168
  ExprResult prepareVectorSplat(QualType VectorTy, Expr *SplattedExpr);
10169
10170
  // CheckExtVectorCast - check type constraints for extended vectors.
10171
  // Since vectors are an extension, there are no C standard reference for this.
10172
  // We allow casting between vectors and integer datatypes of the same size,
10173
  // or vectors and the element type of that vector.
10174
  // returns the cast expr
10175
  ExprResult CheckExtVectorCast(SourceRange R, QualType DestTy, Expr *CastExpr,
10176
                                CastKind &Kind);
10177
10178
  ExprResult BuildCXXFunctionalCastExpr(TypeSourceInfo *TInfo, QualType Type,
10179
                                        SourceLocation LParenLoc,
10180
                                        Expr *CastExpr,
10181
                                        SourceLocation RParenLoc);
10182
10183
  enum ARCConversionResult { ACR_okay, ACR_unbridged, ACR_error };
10184
10185
  /// Checks for invalid conversions and casts between
10186
  /// retainable pointers and other pointer kinds for ARC and Weak.
10187
  ARCConversionResult CheckObjCConversion(SourceRange castRange,
10188
                                          QualType castType, Expr *&op,
10189
                                          CheckedConversionKind CCK,
10190
                                          bool Diagnose = true,
10191
                                          bool DiagnoseCFAudited = false,
10192
                                          BinaryOperatorKind Opc = BO_PtrMemD
10193
                                          );
10194
10195
  Expr *stripARCUnbridgedCast(Expr *e);
10196
  void diagnoseARCUnbridgedCast(Expr *e);
10197
10198
  bool CheckObjCARCUnavailableWeakConversion(QualType castType,
10199
                                             QualType ExprType);
10200
10201
  /// checkRetainCycles - Check whether an Objective-C message send
10202
  /// might create an obvious retain cycle.
10203
  void checkRetainCycles(ObjCMessageExpr *msg);
10204
  void checkRetainCycles(Expr *receiver, Expr *argument);
10205
  void checkRetainCycles(VarDecl *Var, Expr *Init);
10206
10207
  /// checkUnsafeAssigns - Check whether +1 expr is being assigned
10208
  /// to weak/__unsafe_unretained type.
10209
  bool checkUnsafeAssigns(SourceLocation Loc, QualType LHS, Expr *RHS);
10210
10211
  /// checkUnsafeExprAssigns - Check whether +1 expr is being assigned
10212
  /// to weak/__unsafe_unretained expression.
10213
  void checkUnsafeExprAssigns(SourceLocation Loc, Expr *LHS, Expr *RHS);
10214
10215
  /// CheckMessageArgumentTypes - Check types in an Obj-C message send.
10216
  /// \param Method - May be null.
10217
  /// \param [out] ReturnType - The return type of the send.
10218
  /// \return true iff there were any incompatible types.
10219
  bool CheckMessageArgumentTypes(const Expr *Receiver, QualType ReceiverType,
10220
                                 MultiExprArg Args, Selector Sel,
10221
                                 ArrayRef<SourceLocation> SelectorLocs,
10222
                                 ObjCMethodDecl *Method, bool isClassMessage,
10223
                                 bool isSuperMessage, SourceLocation lbrac,
10224
                                 SourceLocation rbrac, SourceRange RecRange,
10225
                                 QualType &ReturnType, ExprValueKind &VK);
10226
10227
  /// Determine the result of a message send expression based on
10228
  /// the type of the receiver, the method expected to receive the message,
10229
  /// and the form of the message send.
10230
  QualType getMessageSendResultType(const Expr *Receiver, QualType ReceiverType,
10231
                                    ObjCMethodDecl *Method, bool isClassMessage,
10232
                                    bool isSuperMessage);
10233
10234
  /// If the given expression involves a message send to a method
10235
  /// with a related result type, emit a note describing what happened.
10236
  void EmitRelatedResultTypeNote(const Expr *E);
10237
10238
  /// Given that we had incompatible pointer types in a return
10239
  /// statement, check whether we're in a method with a related result
10240
  /// type, and if so, emit a note describing what happened.
10241
  void EmitRelatedResultTypeNoteForReturn(QualType destType);
10242
10243
  class ConditionResult {
10244
    Decl *ConditionVar;
10245
    FullExprArg Condition;
10246
    bool Invalid;
10247
    bool HasKnownValue;
10248
    bool KnownValue;
10249
10250
    friend class Sema;
10251
    ConditionResult(Sema &S, Decl *ConditionVar, FullExprArg Condition,
10252
                    bool IsConstexpr)
10253
        : ConditionVar(ConditionVar), Condition(Condition), Invalid(false),
10254
          HasKnownValue(IsConstexpr && Condition.get() &&
10255
                        !Condition.get()->isValueDependent()),
10256
          KnownValue(HasKnownValue &&
10257
1.36M
                     !!Condition.get()->EvaluateKnownConstInt(S.Context)) {}
10258
    explicit ConditionResult(bool Invalid)
10259
        : ConditionVar(nullptr), Condition(nullptr), Invalid(Invalid),
10260
1.22M
          HasKnownValue(false), KnownValue(false) {}
10261
10262
  public:
10263
1.22M
    ConditionResult() : ConditionResult(false) {}
Unexecuted instantiation: clang::Sema::ConditionResult::ConditionResult()
clang::Sema::ConditionResult::ConditionResult()
Line
Count
Source
10263
1.22M
    ConditionResult() : ConditionResult(false) {}
10264
3.84M
    bool isInvalid() const { return Invalid; }
10265
6.15M
    std::pair<VarDecl *, Expr *> get() const {
10266
6.15M
      return std::make_pair(cast_or_null<VarDecl>(ConditionVar),
10267
6.15M
                            Condition.get());
10268
6.15M
    }
10269
120
    llvm::Optional<bool> getKnownValue() const {
10270
120
      if (!HasKnownValue)
10271
21
        return None;
10272
99
      return KnownValue;
10273
99
    }
10274
  };
10275
255
  static ConditionResult ConditionError() { return ConditionResult(true); }
10276
10277
  enum class ConditionKind {
10278
    Boolean,     ///< A boolean condition, from 'if', 'while', 'for', or 'do'.
10279
    ConstexprIf, ///< A constant boolean condition from 'if constexpr'.
10280
    Switch       ///< An integral condition for a 'switch' statement.
10281
  };
10282
10283
  ConditionResult ActOnCondition(Scope *S, SourceLocation Loc,
10284
                                 Expr *SubExpr, ConditionKind CK);
10285
10286
  ConditionResult ActOnConditionVariable(Decl *ConditionVar,
10287
                                         SourceLocation StmtLoc,
10288
                                         ConditionKind CK);
10289
10290
  DeclResult ActOnCXXConditionDeclaration(Scope *S, Declarator &D);
10291
10292
  ExprResult CheckConditionVariable(VarDecl *ConditionVar,
10293
                                    SourceLocation StmtLoc,
10294
                                    ConditionKind CK);
10295
  ExprResult CheckSwitchCondition(SourceLocation SwitchLoc, Expr *Cond);
10296
10297
  /// CheckBooleanCondition - Diagnose problems involving the use of
10298
  /// the given expression as a boolean condition (e.g. in an if
10299
  /// statement).  Also performs the standard function and array
10300
  /// decays, possibly changing the input variable.
10301
  ///
10302
  /// \param Loc - A location associated with the condition, e.g. the
10303
  /// 'if' keyword.
10304
  /// \return true iff there were any errors
10305
  ExprResult CheckBooleanCondition(SourceLocation Loc, Expr *E,
10306
                                   bool IsConstexpr = false);
10307
10308
  /// ActOnExplicitBoolSpecifier - Build an ExplicitSpecifier from an expression
10309
  /// found in an explicit(bool) specifier.
10310
  ExplicitSpecifier ActOnExplicitBoolSpecifier(Expr *E);
10311
10312
  /// tryResolveExplicitSpecifier - Attempt to resolve the explict specifier.
10313
  /// Returns true if the explicit specifier is now resolved.
10314
  bool tryResolveExplicitSpecifier(ExplicitSpecifier &ExplicitSpec);
10315
10316
  /// DiagnoseAssignmentAsCondition - Given that an expression is
10317
  /// being used as a boolean condition, warn if it's an assignment.
10318
  void DiagnoseAssignmentAsCondition(Expr *E);
10319
10320
  /// Redundant parentheses over an equality comparison can indicate
10321
  /// that the user intended an assignment used as condition.
10322
  void DiagnoseEqualityWithExtraParens(ParenExpr *ParenE);
10323
10324
  /// CheckCXXBooleanCondition - Returns true if conversion to bool is invalid.
10325
  ExprResult CheckCXXBooleanCondition(Expr *CondExpr, bool IsConstexpr = false);
10326
10327
  /// ConvertIntegerToTypeWarnOnOverflow - Convert the specified APInt to have
10328
  /// the specified width and sign.  If an overflow occurs, detect it and emit
10329
  /// the specified diagnostic.
10330
  void ConvertIntegerToTypeWarnOnOverflow(llvm::APSInt &OldVal,
10331
                                          unsigned NewWidth, bool NewSign,
10332
                                          SourceLocation Loc, unsigned DiagID);
10333
10334
  /// Checks that the Objective-C declaration is declared in the global scope.
10335
  /// Emits an error and marks the declaration as invalid if it's not declared
10336
  /// in the global scope.
10337
  bool CheckObjCDeclScope(Decl *D);
10338
10339
  /// Abstract base class used for diagnosing integer constant
10340
  /// expression violations.
10341
  class VerifyICEDiagnoser {
10342
  public:
10343
    bool Suppress;
10344
10345
634k
    VerifyICEDiagnoser(bool Suppress = false) : Suppress(Suppress) { }
10346
10347
    virtual void diagnoseNotICE(Sema &S, SourceLocation Loc, SourceRange SR) =0;
10348
    virtual void diagnoseFold(Sema &S, SourceLocation Loc, SourceRange SR);
10349
634k
    virtual ~VerifyICEDiagnoser() { }
10350
  };
10351
10352
  /// VerifyIntegerConstantExpression - Verifies that an expression is an ICE,
10353
  /// and reports the appropriate diagnostics. Returns false on success.
10354
  /// Can optionally return the value of the expression.
10355
  ExprResult VerifyIntegerConstantExpression(Expr *E, llvm::APSInt *Result,
10356
                                             VerifyICEDiagnoser &Diagnoser,
10357
                                             bool AllowFold = true);
10358
  ExprResult VerifyIntegerConstantExpression(Expr *E, llvm::APSInt *Result,
10359
                                             unsigned DiagID,
10360
                                             bool AllowFold = true);
10361
  ExprResult VerifyIntegerConstantExpression(Expr *E,
10362
                                             llvm::APSInt *Result = nullptr);
10363
10364
  /// VerifyBitField - verifies that a bit field expression is an ICE and has
10365
  /// the correct width, and that the field type is valid.
10366
  /// Returns false on success.
10367
  /// Can optionally return whether the bit-field is of width 0
10368
  ExprResult VerifyBitField(SourceLocation FieldLoc, IdentifierInfo *FieldName,
10369
                            QualType FieldTy, bool IsMsStruct,
10370
                            Expr *BitWidth, bool *ZeroWidth = nullptr);
10371
10372
private:
10373
  unsigned ForceCUDAHostDeviceDepth = 0;
10374
10375
public:
10376
  /// Increments our count of the number of times we've seen a pragma forcing
10377
  /// functions to be __host__ __device__.  So long as this count is greater
10378
  /// than zero, all functions encountered will be __host__ __device__.
10379
  void PushForceCUDAHostDevice();
10380
10381
  /// Decrements our count of the number of times we've seen a pragma forcing
10382
  /// functions to be __host__ __device__.  Returns false if the count is 0
10383
  /// before incrementing, so you can emit an error.
10384
  bool PopForceCUDAHostDevice();
10385
10386
  /// Diagnostics that are emitted only if we discover that the given function
10387
  /// must be codegen'ed.  Because handling these correctly adds overhead to
10388
  /// compilation, this is currently only enabled for CUDA compilations.
10389
  llvm::DenseMap<CanonicalDeclPtr<FunctionDecl>,
10390
                 std::vector<PartialDiagnosticAt>>
10391
      DeviceDeferredDiags;
10392
10393
  /// A pair of a canonical FunctionDecl and a SourceLocation.  When used as the
10394
  /// key in a hashtable, both the FD and location are hashed.
10395
  struct FunctionDeclAndLoc {
10396
    CanonicalDeclPtr<FunctionDecl> FD;
10397
    SourceLocation Loc;
10398
  };
10399
10400
  /// FunctionDecls and SourceLocations for which CheckCUDACall has emitted a
10401
  /// (maybe deferred) "bad call" diagnostic.  We use this to avoid emitting the
10402
  /// same deferred diag twice.
10403
  llvm::DenseSet<FunctionDeclAndLoc> LocsWithCUDACallDiags;
10404
10405
  /// An inverse call graph, mapping known-emitted functions to one of their
10406
  /// known-emitted callers (plus the location of the call).
10407
  ///
10408
  /// Functions that we can tell a priori must be emitted aren't added to this
10409
  /// map.
10410
  llvm::DenseMap</* Callee = */ CanonicalDeclPtr<FunctionDecl>,
10411
                 /* Caller = */ FunctionDeclAndLoc>
10412
      DeviceKnownEmittedFns;
10413
10414
  /// A partial call graph maintained during CUDA/OpenMP device code compilation
10415
  /// to support deferred diagnostics.
10416
  ///
10417
  /// Functions are only added here if, at the time they're considered, they are
10418
  /// not known-emitted.  As soon as we discover that a function is
10419
  /// known-emitted, we remove it and everything it transitively calls from this
10420
  /// set and add those functions to DeviceKnownEmittedFns.
10421
  llvm::DenseMap</* Caller = */ CanonicalDeclPtr<FunctionDecl>,
10422
                 /* Callees = */ llvm::MapVector<CanonicalDeclPtr<FunctionDecl>,
10423
                                                 SourceLocation>>
10424
      DeviceCallGraph;
10425
10426
  /// Diagnostic builder for CUDA/OpenMP devices errors which may or may not be
10427
  /// deferred.
10428
  ///
10429
  /// In CUDA, there exist constructs (e.g. variable-length arrays, try/catch)
10430
  /// which are not allowed to appear inside __device__ functions and are
10431
  /// allowed to appear in __host__ __device__ functions only if the host+device
10432
  /// function is never codegen'ed.
10433
  ///
10434
  /// To handle this, we use the notion of "deferred diagnostics", where we
10435
  /// attach a diagnostic to a FunctionDecl that's emitted iff it's codegen'ed.
10436
  ///
10437
  /// This class lets you emit either a regular diagnostic, a deferred
10438
  /// diagnostic, or no diagnostic at all, according to an argument you pass to
10439
  /// its constructor, thus simplifying the process of creating these "maybe
10440
  /// deferred" diagnostics.
10441
  class DeviceDiagBuilder {
10442
  public:
10443
    enum Kind {
10444
      /// Emit no diagnostics.
10445
      K_Nop,
10446
      /// Emit the diagnostic immediately (i.e., behave like Sema::Diag()).
10447
      K_Immediate,
10448
      /// Emit the diagnostic immediately, and, if it's a warning or error, also
10449
      /// emit a call stack showing how this function can be reached by an a
10450
      /// priori known-emitted function.
10451
      K_ImmediateWithCallStack,
10452
      /// Create a deferred diagnostic, which is emitted only if the function
10453
      /// it's attached to is codegen'ed.  Also emit a call stack as with
10454
      /// K_ImmediateWithCallStack.
10455
      K_Deferred
10456
    };
10457
10458
    DeviceDiagBuilder(Kind K, SourceLocation Loc, unsigned DiagID,
10459
                      FunctionDecl *Fn, Sema &S);
10460
    DeviceDiagBuilder(DeviceDiagBuilder &&D);
10461
11
    DeviceDiagBuilder(const DeviceDiagBuilder &) = default;
10462
    ~DeviceDiagBuilder();
10463
10464
    /// Convertible to bool: True if we immediately emitted an error, false if
10465
    /// we didn't emit an error or we created a deferred error.
10466
    ///
10467
    /// Example usage:
10468
    ///
10469
    ///   if (DeviceDiagBuilder(...) << foo << bar)
10470
    ///     return ExprError();
10471
    ///
10472
    /// But see CUDADiagIfDeviceCode() and CUDADiagIfHostCode() -- you probably
10473
    /// want to use these instead of creating a DeviceDiagBuilder yourself.
10474
62
    operator bool() const { return ImmediateDiag.hasValue(); }
10475
10476
    template <typename T>
10477
    friend const DeviceDiagBuilder &operator<<(const DeviceDiagBuilder &Diag,
10478
777
                                               const T &Value) {
10479
777
      if (Diag.ImmediateDiag.hasValue())
10480
578
        *Diag.ImmediateDiag << Value;
10481
199
      else if (Diag.PartialDiagId.hasValue())
10482
160
        Diag.S.DeviceDeferredDiags[Diag.Fn][*Diag.PartialDiagId].second
10483
160
            << Value;
10484
777
      return Diag;
10485
777
    }
clang::Sema::DeviceDiagBuilder const& clang::operator<<<clang::Sema::CUDAFunctionTarget>(clang::Sema::DeviceDiagBuilder const&, clang::Sema::CUDAFunctionTarget const&)
Line
Count
Source
10478
287
                                               const T &Value) {
10479
287
      if (Diag.ImmediateDiag.hasValue())
10480
195
        *Diag.ImmediateDiag << Value;
10481
92
      else if (Diag.PartialDiagId.hasValue())
10482
65
        Diag.S.DeviceDeferredDiags[Diag.Fn][*Diag.PartialDiagId].second
10483
65
            << Value;
10484
287
      return Diag;
10485
287
    }
clang::Sema::DeviceDiagBuilder const& clang::operator<<<clang::FunctionDecl*>(clang::Sema::DeviceDiagBuilder const&, clang::FunctionDecl* const&)
Line
Count
Source
10478
202
                                               const T &Value) {
10479
202
      if (Diag.ImmediateDiag.hasValue())
10480
162
        *Diag.ImmediateDiag << Value;
10481
40
      else if (Diag.PartialDiagId.hasValue())
10482
40
        Diag.S.DeviceDeferredDiags[Diag.Fn][*Diag.PartialDiagId].second
10483
40
            << Value;
10484
202
      return Diag;
10485
202
    }
clang::Sema::DeviceDiagBuilder const& clang::operator<<<char [6]>(clang::Sema::DeviceDiagBuilder const&, char const (&) [6])
Line
Count
Source
10478
21
                                               const T &Value) {
10479
21
      if (Diag.ImmediateDiag.hasValue())
10480
12
        *Diag.ImmediateDiag << Value;
10481
9
      else if (Diag.PartialDiagId.hasValue())
10482
4
        Diag.S.DeviceDeferredDiags[Diag.Fn][*Diag.PartialDiagId].second
10483
4
            << Value;
10484
21
      return Diag;
10485
21
    }
clang::Sema::DeviceDiagBuilder const& clang::operator<<<bool>(clang::Sema::DeviceDiagBuilder const&, bool const&)
Line
Count
Source
10478
10
                                               const T &Value) {
10479
10
      if (Diag.ImmediateDiag.hasValue())
10480
10
        *Diag.ImmediateDiag << Value;
10481
0
      else if (Diag.PartialDiagId.hasValue())
10482
0
        Diag.S.DeviceDeferredDiags[Diag.Fn][*Diag.PartialDiagId].second
10483
0
            << Value;
10484
10
      return Diag;
10485
10
    }
clang::Sema::DeviceDiagBuilder const& clang::operator<<<unsigned int>(clang::Sema::DeviceDiagBuilder const&, unsigned int const&)
Line
Count
Source
10478
8
                                               const T &Value) {
10479
8
      if (Diag.ImmediateDiag.hasValue())
10480
4
        *Diag.ImmediateDiag << Value;
10481
4
      else if (Diag.PartialDiagId.hasValue())
10482
4
        Diag.S.DeviceDeferredDiags[Diag.Fn][*Diag.PartialDiagId].second
10483
4
            << Value;
10484
8
      return Diag;
10485
8
    }
clang::Sema::DeviceDiagBuilder const& clang::operator<<<clang::QualType>(clang::Sema::DeviceDiagBuilder const&, clang::QualType const&)
Line
Count
Source
10478
8
                                               const T &Value) {
10479
8
      if (Diag.ImmediateDiag.hasValue())
10480
4
        *Diag.ImmediateDiag << Value;
10481
4
      else if (Diag.PartialDiagId.hasValue())
10482
4
        Diag.S.DeviceDeferredDiags[Diag.Fn][*Diag.PartialDiagId].second
10483
4
            << Value;
10484
8
      return Diag;
10485
8
    }
clang::Sema::DeviceDiagBuilder const& clang::operator<<<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >(clang::Sema::DeviceDiagBuilder const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)
Line
Count
Source
10478
171
                                               const T &Value) {
10479
171
      if (Diag.ImmediateDiag.hasValue())
10480
145
        *Diag.ImmediateDiag << Value;
10481
26
      else if (Diag.PartialDiagId.hasValue())
10482
24
        Diag.S.DeviceDeferredDiags[Diag.Fn][*Diag.PartialDiagId].second
10483
24
            << Value;
10484
171
      return Diag;
10485
171
    }
clang::Sema::DeviceDiagBuilder const& clang::operator<<<clang::SourceRange>(clang::Sema::DeviceDiagBuilder const&, clang::SourceRange const&)
Line
Count
Source
10478
24
                                               const T &Value) {
10479
24
      if (Diag.ImmediateDiag.hasValue())
10480
20
        *Diag.ImmediateDiag << Value;
10481
4
      else if (Diag.PartialDiagId.hasValue())
10482
4
        Diag.S.DeviceDeferredDiags[Diag.Fn][*Diag.PartialDiagId].second
10483
4
            << Value;
10484
24
      return Diag;
10485
24
    }
clang::Sema::DeviceDiagBuilder const& clang::operator<<<char [4]>(clang::Sema::DeviceDiagBuilder const&, char const (&) [4])
Line
Count
Source
10478
17
                                               const T &Value) {
10479
17
      if (Diag.ImmediateDiag.hasValue())
10480
9
        *Diag.ImmediateDiag << Value;
10481
8
      else if (Diag.PartialDiagId.hasValue())
10482
3
        Diag.S.DeviceDeferredDiags[Diag.Fn][*Diag.PartialDiagId].second
10483
3
            << Value;
10484
17
      return Diag;
10485
17
    }
clang::Sema::DeviceDiagBuilder const& clang::operator<<<llvm::StringRef>(clang::Sema::DeviceDiagBuilder const&, llvm::StringRef const&)
Line
Count
Source
10478
18
                                               const T &Value) {
10479
18
      if (Diag.ImmediateDiag.hasValue())
10480
6
        *Diag.ImmediateDiag << Value;
10481
12
      else if (Diag.PartialDiagId.hasValue())
10482
12
        Diag.S.DeviceDeferredDiags[Diag.Fn][*Diag.PartialDiagId].second
10483
12
            << Value;
10484
18
      return Diag;
10485
18
    }
clang::Sema::DeviceDiagBuilder const& clang::operator<<<clang::FixItHint>(clang::Sema::DeviceDiagBuilder const&, clang::FixItHint const&)
Line
Count
Source
10478
11
                                               const T &Value) {
10479
11
      if (Diag.ImmediateDiag.hasValue())
10480
11
        *Diag.ImmediateDiag << Value;
10481
0
      else if (Diag.PartialDiagId.hasValue())
10482
0
        Diag.S.DeviceDeferredDiags[Diag.Fn][*Diag.PartialDiagId].second
10483
0
            << Value;
10484
11
      return Diag;
10485
11
    }
10486
10487
  private:
10488
    Sema &S;
10489
    SourceLocation Loc;
10490
    unsigned DiagID;
10491
    FunctionDecl *Fn;
10492
    bool ShowCallStack;
10493
10494
    // Invariant: At most one of these Optionals has a value.
10495
    // FIXME: Switch these to a Variant once that exists.
10496
    llvm::Optional<SemaDiagnosticBuilder> ImmediateDiag;
10497
    llvm::Optional<unsigned> PartialDiagId;
10498
  };
10499
10500
  /// Indicate that this function (and thus everything it transtively calls)
10501
  /// will be codegen'ed, and emit any deferred diagnostics on this function and
10502
  /// its (transitive) callees.
10503
  void markKnownEmitted(
10504
      Sema &S, FunctionDecl *OrigCaller, FunctionDecl *OrigCallee,
10505
      SourceLocation OrigLoc,
10506
      const llvm::function_ref<bool(Sema &, FunctionDecl *)> IsKnownEmitted);
10507
10508
  /// Creates a DeviceDiagBuilder that emits the diagnostic if the current context
10509
  /// is "used as device code".
10510
  ///
10511
  /// - If CurContext is a __host__ function, does not emit any diagnostics.
10512
  /// - If CurContext is a __device__ or __global__ function, emits the
10513
  ///   diagnostics immediately.
10514
  /// - If CurContext is a __host__ __device__ function and we are compiling for
10515
  ///   the device, creates a diagnostic which is emitted if and when we realize
10516
  ///   that the function will be codegen'ed.
10517
  ///
10518
  /// Example usage:
10519
  ///
10520
  ///  // Variable-length arrays are not allowed in CUDA device code.
10521
  ///  if (CUDADiagIfDeviceCode(Loc, diag::err_cuda_vla) << CurrentCUDATarget())
10522
  ///    return ExprError();
10523
  ///  // Otherwise, continue parsing as normal.
10524
  DeviceDiagBuilder CUDADiagIfDeviceCode(SourceLocation Loc, unsigned DiagID);
10525
10526
  /// Creates a DeviceDiagBuilder that emits the diagnostic if the current context
10527
  /// is "used as host code".
10528
  ///
10529
  /// Same as CUDADiagIfDeviceCode, with "host" and "device" switched.
10530
  DeviceDiagBuilder CUDADiagIfHostCode(SourceLocation Loc, unsigned DiagID);
10531
10532
  /// Creates a DeviceDiagBuilder that emits the diagnostic if the current
10533
  /// context is "used as device code".
10534
  ///
10535
  /// - If CurContext is a `declare target` function or it is known that the
10536
  /// function is emitted for the device, emits the diagnostics immediately.
10537
  /// - If CurContext is a non-`declare target` function and we are compiling
10538
  ///   for the device, creates a diagnostic which is emitted if and when we
10539
  ///   realize that the function will be codegen'ed.
10540
  ///
10541
  /// Example usage:
10542
  ///
10543
  ///  // Variable-length arrays are not allowed in NVPTX device code.
10544
  ///  if (diagIfOpenMPDeviceCode(Loc, diag::err_vla_unsupported))
10545
  ///    return ExprError();
10546
  ///  // Otherwise, continue parsing as normal.
10547
  DeviceDiagBuilder diagIfOpenMPDeviceCode(SourceLocation Loc, unsigned DiagID);
10548
10549
  DeviceDiagBuilder targetDiag(SourceLocation Loc, unsigned DiagID);
10550
10551
  enum CUDAFunctionTarget {
10552
    CFT_Device,
10553
    CFT_Global,
10554
    CFT_Host,
10555
    CFT_HostDevice,
10556
    CFT_InvalidTarget
10557
  };
10558
10559
  /// Determines whether the given function is a CUDA device/host/kernel/etc.
10560
  /// function.
10561
  ///
10562
  /// Use this rather than examining the function's attributes yourself -- you
10563
  /// will get it wrong.  Returns CFT_Host if D is null.
10564
  CUDAFunctionTarget IdentifyCUDATarget(const FunctionDecl *D,
10565
                                        bool IgnoreImplicitHDAttr = false);
10566
  CUDAFunctionTarget IdentifyCUDATarget(const ParsedAttributesView &Attrs);
10567
10568
  /// Gets the CUDA target for the current context.
10569
148
  CUDAFunctionTarget CurrentCUDATarget() {
10570
148
    return IdentifyCUDATarget(dyn_cast<FunctionDecl>(CurContext));
10571
148
  }
10572
10573
  // CUDA function call preference. Must be ordered numerically from
10574
  // worst to best.
10575
  enum CUDAFunctionPreference {
10576
    CFP_Never,      // Invalid caller/callee combination.
10577
    CFP_WrongSide,  // Calls from host-device to host or device
10578
                    // function that do not match current compilation
10579
                    // mode.
10580
    CFP_HostDevice, // Any calls to host/device functions.
10581
    CFP_SameSide,   // Calls from host-device to host or device
10582
                    // function matching current compilation mode.
10583
    CFP_Native,     // host-to-host or device-to-device calls.
10584
  };
10585
10586
  /// Identifies relative preference of a given Caller/Callee
10587
  /// combination, based on their host/device attributes.
10588
  /// \param Caller function which needs address of \p Callee.
10589
  ///               nullptr in case of global context.
10590
  /// \param Callee target function
10591
  ///
10592
  /// \returns preference value for particular Caller/Callee combination.
10593
  CUDAFunctionPreference IdentifyCUDAPreference(const FunctionDecl *Caller,
10594
                                                const FunctionDecl *Callee);
10595
10596
  /// Determines whether Caller may invoke Callee, based on their CUDA
10597
  /// host/device attributes.  Returns false if the call is not allowed.
10598
  ///
10599
  /// Note: Will return true for CFP_WrongSide calls.  These may appear in
10600
  /// semantically correct CUDA programs, but only if they're never codegen'ed.
10601
  bool IsAllowedCUDACall(const FunctionDecl *Caller,
10602
2.24k
                         const FunctionDecl *Callee) {
10603
2.24k
    return IdentifyCUDAPreference(Caller, Callee) != CFP_Never;
10604
2.24k
  }
10605
10606
  /// May add implicit CUDAHostAttr and CUDADeviceAttr attributes to FD,
10607
  /// depending on FD and the current compilation settings.
10608
  void maybeAddCUDAHostDeviceAttrs(FunctionDecl *FD,
10609
                                   const LookupResult &Previous);
10610
10611
public:
10612
  /// Check whether we're allowed to call Callee from the current context.
10613
  ///
10614
  /// - If the call is never allowed in a semantically-correct program
10615
  ///   (CFP_Never), emits an error and returns false.
10616
  ///
10617
  /// - If the call is allowed in semantically-correct programs, but only if
10618
  ///   it's never codegen'ed (CFP_WrongSide), creates a deferred diagnostic to
10619
  ///   be emitted if and when the caller is codegen'ed, and returns true.
10620
  ///
10621
  ///   Will only create deferred diagnostics for a given SourceLocation once,
10622
  ///   so you can safely call this multiple times without generating duplicate
10623
  ///   deferred errors.
10624
  ///
10625
  /// - Otherwise, returns true without emitting any diagnostics.
10626
  bool CheckCUDACall(SourceLocation Loc, FunctionDecl *Callee);
10627
10628
  /// Set __device__ or __host__ __device__ attributes on the given lambda
10629
  /// operator() method.
10630
  ///
10631
  /// CUDA lambdas declared inside __device__ or __global__ functions inherit
10632
  /// the __device__ attribute.  Similarly, lambdas inside __host__ __device__
10633
  /// functions become __host__ __device__ themselves.
10634
  void CUDASetLambdaAttrs(CXXMethodDecl *Method);
10635
10636
  /// Finds a function in \p Matches with highest calling priority
10637
  /// from \p Caller context and erases all functions with lower
10638
  /// calling priority.
10639
  void EraseUnwantedCUDAMatches(
10640
      const FunctionDecl *Caller,
10641
      SmallVectorImpl<std::pair<DeclAccessPair, FunctionDecl *>> &Matches);
10642
10643
  /// Given a implicit special member, infer its CUDA target from the
10644
  /// calls it needs to make to underlying base/field special members.
10645
  /// \param ClassDecl the class for which the member is being created.
10646
  /// \param CSM the kind of special member.
10647
  /// \param MemberDecl the special member itself.
10648
  /// \param ConstRHS true if this is a copy operation with a const object on
10649
  ///        its RHS.
10650
  /// \param Diagnose true if this call should emit diagnostics.
10651
  /// \return true if there was an error inferring.
10652
  /// The result of this call is implicit CUDA target attribute(s) attached to
10653
  /// the member declaration.
10654
  bool inferCUDATargetForImplicitSpecialMember(CXXRecordDecl *ClassDecl,
10655
                                               CXXSpecialMember CSM,
10656
                                               CXXMethodDecl *MemberDecl,
10657
                                               bool ConstRHS,
10658
                                               bool Diagnose);
10659
10660
  /// \return true if \p CD can be considered empty according to CUDA
10661
  /// (E.2.3.1 in CUDA 7.5 Programming guide).
10662
  bool isEmptyCudaConstructor(SourceLocation Loc, CXXConstructorDecl *CD);
10663
  bool isEmptyCudaDestructor(SourceLocation Loc, CXXDestructorDecl *CD);
10664
10665
  // \brief Checks that initializers of \p Var satisfy CUDA restrictions. In
10666
  // case of error emits appropriate diagnostic and invalidates \p Var.
10667
  //
10668
  // \details CUDA allows only empty constructors as initializers for global
10669
  // variables (see E.2.3.1, CUDA 7.5). The same restriction also applies to all
10670
  // __shared__ variables whether they are local or not (they all are implicitly
10671
  // static in CUDA). One exception is that CUDA allows constant initializers
10672
  // for __constant__ and __device__ variables.
10673
  void checkAllowedCUDAInitializer(VarDecl *VD);
10674
10675
  /// Check whether NewFD is a valid overload for CUDA. Emits
10676
  /// diagnostics and invalidates NewFD if not.
10677
  void checkCUDATargetOverload(FunctionDecl *NewFD,
10678
                               const LookupResult &Previous);
10679
  /// Copies target attributes from the template TD to the function FD.
10680
  void inheritCUDATargetAttrs(FunctionDecl *FD, const FunctionTemplateDecl &TD);
10681
10682
  /// Returns the name of the launch configuration function.  This is the name
10683
  /// of the function that will be called to configure kernel call, with the
10684
  /// parameters specified via <<<>>>.
10685
  std::string getCudaConfigureFuncName() const;
10686
10687
  /// \name Code completion
10688
  //@{
10689
  /// Describes the context in which code completion occurs.
10690
  enum ParserCompletionContext {
10691
    /// Code completion occurs at top-level or namespace context.
10692
    PCC_Namespace,
10693
    /// Code completion occurs within a class, struct, or union.
10694
    PCC_Class,
10695
    /// Code completion occurs within an Objective-C interface, protocol,
10696
    /// or category.
10697
    PCC_ObjCInterface,
10698
    /// Code completion occurs within an Objective-C implementation or
10699
    /// category implementation
10700
    PCC_ObjCImplementation,
10701
    /// Code completion occurs within the list of instance variables
10702
    /// in an Objective-C interface, protocol, category, or implementation.
10703
    PCC_ObjCInstanceVariableList,
10704
    /// Code completion occurs following one or more template
10705
    /// headers.
10706
    PCC_Template,
10707
    /// Code completion occurs following one or more template
10708
    /// headers within a class.
10709
    PCC_MemberTemplate,
10710
    /// Code completion occurs within an expression.
10711
    PCC_Expression,
10712
    /// Code completion occurs within a statement, which may
10713
    /// also be an expression or a declaration.
10714
    PCC_Statement,
10715
    /// Code completion occurs at the beginning of the
10716
    /// initialization statement (or expression) in a for loop.
10717
    PCC_ForInit,
10718
    /// Code completion occurs within the condition of an if,
10719
    /// while, switch, or for statement.
10720
    PCC_Condition,
10721
    /// Code completion occurs within the body of a function on a
10722
    /// recovery path, where we do not have a specific handle on our position
10723
    /// in the grammar.
10724
    PCC_RecoveryInFunction,
10725
    /// Code completion occurs where only a type is permitted.
10726
    PCC_Type,
10727
    /// Code completion occurs in a parenthesized expression, which
10728
    /// might also be a type cast.
10729
    PCC_ParenthesizedExpression,
10730
    /// Code completion occurs within a sequence of declaration
10731
    /// specifiers within a function, method, or block.
10732
    PCC_LocalDeclarationSpecifiers
10733
  };
10734
10735
  void CodeCompleteModuleImport(SourceLocation ImportLoc, ModuleIdPath Path);
10736
  void CodeCompleteOrdinaryName(Scope *S,
10737
                                ParserCompletionContext CompletionContext);
10738
  void CodeCompleteDeclSpec(Scope *S, DeclSpec &DS,
10739
                            bool AllowNonIdentifiers,
10740
                            bool AllowNestedNameSpecifiers);
10741
10742
  struct CodeCompleteExpressionData;
10743
  void CodeCompleteExpression(Scope *S,
10744
                              const CodeCompleteExpressionData &Data);
10745
  void CodeCompleteExpression(Scope *S, QualType PreferredType,
10746
                              bool IsParenthesized = false);
10747
  void CodeCompleteMemberReferenceExpr(Scope *S, Expr *Base, Expr *OtherOpBase,
10748
                                       SourceLocation OpLoc, bool IsArrow,
10749
                                       bool IsBaseExprStatement,
10750
                                       QualType PreferredType);
10751
  void CodeCompletePostfixExpression(Scope *S, ExprResult LHS,
10752
                                     QualType PreferredType);
10753
  void CodeCompleteTag(Scope *S, unsigned TagSpec);
10754
  void CodeCompleteTypeQualifiers(DeclSpec &DS);
10755
  void CodeCompleteFunctionQualifiers(DeclSpec &DS, Declarator &D,
10756
                                      const VirtSpecifiers *VS = nullptr);
10757
  void CodeCompleteBracketDeclarator(Scope *S);
10758
  void CodeCompleteCase(Scope *S);
10759
  /// Reports signatures for a call to CodeCompleteConsumer and returns the
10760
  /// preferred type for the current argument. Returned type can be null.
10761
  QualType ProduceCallSignatureHelp(Scope *S, Expr *Fn, ArrayRef<Expr *> Args,
10762
                                    SourceLocation OpenParLoc);
10763
  QualType ProduceConstructorSignatureHelp(Scope *S, QualType Type,
10764
                                           SourceLocation Loc,
10765
                                           ArrayRef<Expr *> Args,
10766
                                           SourceLocation OpenParLoc);
10767
  QualType ProduceCtorInitMemberSignatureHelp(Scope *S, Decl *ConstructorDecl,
10768
                                              CXXScopeSpec SS,
10769
                                              ParsedType TemplateTypeTy,
10770
                                              ArrayRef<Expr *> ArgExprs,
10771
                                              IdentifierInfo *II,
10772
                                              SourceLocation OpenParLoc);
10773
  void CodeCompleteInitializer(Scope *S, Decl *D);
10774
  void CodeCompleteAfterIf(Scope *S);
10775
10776
  void CodeCompleteQualifiedId(Scope *S, CXXScopeSpec &SS, bool EnteringContext,
10777
                               QualType BaseType, QualType PreferredType);
10778
  void CodeCompleteUsing(Scope *S);
10779
  void CodeCompleteUsingDirective(Scope *S);
10780
  void CodeCompleteNamespaceDecl(Scope *S);
10781
  void CodeCompleteNamespaceAliasDecl(Scope *S);
10782
  void CodeCompleteOperatorName(Scope *S);
10783
  void CodeCompleteConstructorInitializer(
10784
                                Decl *Constructor,
10785
                                ArrayRef<CXXCtorInitializer *> Initializers);
10786
10787
  void CodeCompleteLambdaIntroducer(Scope *S, LambdaIntroducer &Intro,
10788
                                    bool AfterAmpersand);
10789
10790
  void CodeCompleteObjCAtDirective(Scope *S);
10791
  void CodeCompleteObjCAtVisibility(Scope *S);
10792
  void CodeCompleteObjCAtStatement(Scope *S);
10793
  void CodeCompleteObjCAtExpression(Scope *S);
10794
  void CodeCompleteObjCPropertyFlags(Scope *S, ObjCDeclSpec &ODS);
10795
  void CodeCompleteObjCPropertyGetter(Scope *S);
10796
  void CodeCompleteObjCPropertySetter(Scope *S);
10797
  void CodeCompleteObjCPassingType(Scope *S, ObjCDeclSpec &DS,
10798
                                   bool IsParameter);
10799
  void CodeCompleteObjCMessageReceiver(Scope *S);
10800
  void CodeCompleteObjCSuperMessage(Scope *S, SourceLocation SuperLoc,
10801
                                    ArrayRef<IdentifierInfo *> SelIdents,
10802
                                    bool AtArgumentExpression);
10803
  void CodeCompleteObjCClassMessage(Scope *S, ParsedType Receiver,
10804
                                    ArrayRef<IdentifierInfo *> SelIdents,
10805
                                    bool AtArgumentExpression,
10806
                                    bool IsSuper = false);
10807
  void CodeCompleteObjCInstanceMessage(Scope *S, Expr *Receiver,
10808
                                       ArrayRef<IdentifierInfo *> SelIdents,
10809
                                       bool AtArgumentExpression,
10810
                                       ObjCInterfaceDecl *Super = nullptr);
10811
  void CodeCompleteObjCForCollection(Scope *S,
10812
                                     DeclGroupPtrTy IterationVar);
10813
  void CodeCompleteObjCSelector(Scope *S,
10814
                                ArrayRef<IdentifierInfo *> SelIdents);
10815
  void CodeCompleteObjCProtocolReferences(
10816
                                         ArrayRef<IdentifierLocPair> Protocols);
10817
  void CodeCompleteObjCProtocolDecl(Scope *S);
10818
  void CodeCompleteObjCInterfaceDecl(Scope *S);
10819
  void CodeCompleteObjCSuperclass(Scope *S,
10820
                                  IdentifierInfo *ClassName,
10821
                                  SourceLocation ClassNameLoc);
10822
  void CodeCompleteObjCImplementationDecl(Scope *S);
10823
  void CodeCompleteObjCInterfaceCategory(Scope *S,
10824
                                         IdentifierInfo *ClassName,
10825
                                         SourceLocation ClassNameLoc);
10826
  void CodeCompleteObjCImplementationCategory(Scope *S,
10827
                                              IdentifierInfo *ClassName,
10828
                                              SourceLocation ClassNameLoc);
10829
  void CodeCompleteObjCPropertyDefinition(Scope *S);
10830
  void CodeCompleteObjCPropertySynthesizeIvar(Scope *S,
10831
                                              IdentifierInfo *PropertyName);
10832
  void CodeCompleteObjCMethodDecl(Scope *S, Optional<bool> IsInstanceMethod,
10833
                                  ParsedType ReturnType);
10834
  void CodeCompleteObjCMethodDeclSelector(Scope *S,
10835
                                          bool IsInstanceMethod,
10836
                                          bool AtParameterName,
10837
                                          ParsedType ReturnType,
10838
                                          ArrayRef<IdentifierInfo *> SelIdents);
10839
  void CodeCompleteObjCClassPropertyRefExpr(Scope *S, IdentifierInfo &ClassName,
10840
                                            SourceLocation ClassNameLoc,
10841
                                            bool IsBaseExprStatement);
10842
  void CodeCompletePreprocessorDirective(bool InConditional);
10843
  void CodeCompleteInPreprocessorConditionalExclusion(Scope *S);
10844
  void CodeCompletePreprocessorMacroName(bool IsDefinition);
10845
  void CodeCompletePreprocessorExpression();
10846
  void CodeCompletePreprocessorMacroArgument(Scope *S,
10847
                                             IdentifierInfo *Macro,
10848
                                             MacroInfo *MacroInfo,
10849
                                             unsigned Argument);
10850
  void CodeCompleteIncludedFile(llvm::StringRef Dir, bool IsAngled);
10851
  void CodeCompleteNaturalLanguage();
10852
  void CodeCompleteAvailabilityPlatformName();
10853
  void GatherGlobalCodeCompletions(CodeCompletionAllocator &Allocator,
10854
                                   CodeCompletionTUInfo &CCTUInfo,
10855
                  SmallVectorImpl<CodeCompletionResult> &Results);
10856
  //@}
10857
10858
  //===--------------------------------------------------------------------===//
10859
  // Extra semantic analysis beyond the C type system
10860
10861
public:
10862
  SourceLocation getLocationOfStringLiteralByte(const StringLiteral *SL,
10863
                                                unsigned ByteNo) const;
10864
10865
private:
10866
  void CheckArrayAccess(const Expr *BaseExpr, const Expr *IndexExpr,
10867
                        const ArraySubscriptExpr *ASE=nullptr,
10868
                        bool AllowOnePastEnd=true, bool IndexNegated=false);
10869
  void CheckArrayAccess(const Expr *E);
10870
  // Used to grab the relevant information from a FormatAttr and a
10871
  // FunctionDeclaration.
10872
  struct FormatStringInfo {
10873
    unsigned FormatIdx;
10874
    unsigned FirstDataArg;
10875
    bool HasVAListArg;
10876
  };
10877
10878
  static bool getFormatStringInfo(const FormatAttr *Format, bool IsCXXMember,
10879
                                  FormatStringInfo *FSI);
10880
  bool CheckFunctionCall(FunctionDecl *FDecl, CallExpr *TheCall,
10881
                         const FunctionProtoType *Proto);
10882
  bool CheckObjCMethodCall(ObjCMethodDecl *Method, SourceLocation loc,
10883
                           ArrayRef<const Expr *> Args);
10884
  bool CheckPointerCall(NamedDecl *NDecl, CallExpr *TheCall,
10885
                        const FunctionProtoType *Proto);
10886
  bool CheckOtherCall(CallExpr *TheCall, const FunctionProtoType *Proto);
10887
  void CheckConstructorCall(FunctionDecl *FDecl,
10888
                            ArrayRef<const Expr *> Args,
10889
                            const FunctionProtoType *Proto,
10890
                            SourceLocation Loc);
10891
10892
  void checkCall(NamedDecl *FDecl, const FunctionProtoType *Proto,
10893
                 const Expr *ThisArg, ArrayRef<const Expr *> Args,
10894
                 bool IsMemberFunction, SourceLocation Loc, SourceRange Range,
10895
                 VariadicCallType CallType);
10896
10897
  bool CheckObjCString(Expr *Arg);
10898
  ExprResult CheckOSLogFormatStringArg(Expr *Arg);
10899
10900
  ExprResult CheckBuiltinFunctionCall(FunctionDecl *FDecl,
10901
                                      unsigned BuiltinID, CallExpr *TheCall);
10902
  void checkFortifiedBuiltinMemoryFunction(FunctionDecl *FD, CallExpr *TheCall);
10903
10904
  bool CheckARMBuiltinExclusiveCall(unsigned BuiltinID, CallExpr *TheCall,
10905
                                    unsigned MaxWidth);
10906
  bool CheckNeonBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall);
10907
  bool CheckARMBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall);
10908
10909
  bool CheckAArch64BuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall);
10910
  bool CheckHexagonBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall);
10911
  bool CheckHexagonBuiltinCpu(unsigned BuiltinID, CallExpr *TheCall);
10912
  bool CheckHexagonBuiltinArgument(unsigned BuiltinID, CallExpr *TheCall);
10913
  bool CheckMipsBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall);
10914
  bool CheckSystemZBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall);
10915
  bool CheckX86BuiltinRoundingOrSAE(unsigned BuiltinID, CallExpr *TheCall);
10916
  bool CheckX86BuiltinGatherScatterScale(unsigned BuiltinID, CallExpr *TheCall);
10917
  bool CheckX86BuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall);
10918
  bool CheckPPCBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall);
10919
10920
  bool SemaBuiltinVAStart(unsigned BuiltinID, CallExpr *TheCall);
10921
  bool SemaBuiltinVAStartARMMicrosoft(CallExpr *Call);
10922
  bool SemaBuiltinUnorderedCompare(CallExpr *TheCall);
10923
  bool SemaBuiltinFPClassification(CallExpr *TheCall, unsigned NumArgs);
10924
  bool SemaBuiltinVSX(CallExpr *TheCall);
10925
  bool SemaBuiltinOSLogFormat(CallExpr *TheCall);
10926
10927
public:
10928
  // Used by C++ template instantiation.
10929
  ExprResult SemaBuiltinShuffleVector(CallExpr *TheCall);
10930
  ExprResult SemaConvertVectorExpr(Expr *E, TypeSourceInfo *TInfo,
10931
                                   SourceLocation BuiltinLoc,
10932
                                   SourceLocation RParenLoc);
10933
10934
private:
10935
  bool SemaBuiltinPrefetch(CallExpr *TheCall);
10936
  bool SemaBuiltinAllocaWithAlign(CallExpr *TheCall);
10937
  bool SemaBuiltinAssume(CallExpr *TheCall);
10938
  bool SemaBuiltinAssumeAligned(CallExpr *TheCall);
10939
  bool SemaBuiltinLongjmp(CallExpr *TheCall);
10940
  bool SemaBuiltinSetjmp(CallExpr *TheCall);
10941
  ExprResult SemaBuiltinAtomicOverloaded(ExprResult TheCallResult);
10942
  ExprResult SemaBuiltinNontemporalOverloaded(ExprResult TheCallResult);
10943
  ExprResult SemaAtomicOpsOverloaded(ExprResult TheCallResult,
10944
                                     AtomicExpr::AtomicOp Op);
10945
  ExprResult SemaBuiltinOperatorNewDeleteOverloaded(ExprResult TheCallResult,
10946
                                                    bool IsDelete);
10947
  bool SemaBuiltinConstantArg(CallExpr *TheCall, int ArgNum,
10948
                              llvm::APSInt &Result);
10949
  bool SemaBuiltinConstantArgRange(CallExpr *TheCall, int ArgNum, int Low,
10950
                                   int High, bool RangeIsError = true);
10951
  bool SemaBuiltinConstantArgMultiple(CallExpr *TheCall, int ArgNum,
10952
                                      unsigned Multiple);
10953
  bool SemaBuiltinARMSpecialReg(unsigned BuiltinID, CallExpr *TheCall,
10954
                                int ArgNum, unsigned ExpectedFieldNum,
10955
                                bool AllowName);
10956
  bool SemaBuiltinARMMemoryTaggingCall(unsigned BuiltinID, CallExpr *TheCall);
10957
public:
10958
  enum FormatStringType {
10959
    FST_Scanf,
10960
    FST_Printf,
10961
    FST_NSString,
10962
    FST_Strftime,
10963
    FST_Strfmon,
10964
    FST_Kprintf,
10965
    FST_FreeBSDKPrintf,
10966
    FST_OSTrace,
10967
    FST_OSLog,
10968
    FST_Unknown
10969
  };
10970
  static FormatStringType GetFormatStringType(const FormatAttr *Format);
10971
10972
  bool FormatStringHasSArg(const StringLiteral *FExpr);
10973
10974
  static bool GetFormatNSStringIdx(const FormatAttr *Format, unsigned &Idx);
10975
10976
private:
10977
  bool CheckFormatArguments(const FormatAttr *Format,
10978
                            ArrayRef<const Expr *> Args,
10979
                            bool IsCXXMember,
10980
                            VariadicCallType CallType,
10981
                            SourceLocation Loc, SourceRange Range,
10982
                            llvm::SmallBitVector &CheckedVarArgs);
10983
  bool CheckFormatArguments(ArrayRef<const Expr *> Args,
10984
                            bool HasVAListArg, unsigned format_idx,
10985
                            unsigned firstDataArg, FormatStringType Type,
10986
                            VariadicCallType CallType,
10987
                            SourceLocation Loc, SourceRange range,
10988
                            llvm::SmallBitVector &CheckedVarArgs);
10989
10990
  void CheckAbsoluteValueFunction(const CallExpr *Call,
10991
                                  const FunctionDecl *FDecl);
10992
10993
  void CheckMaxUnsignedZero(const CallExpr *Call, const FunctionDecl *FDecl);
10994
10995
  void CheckMemaccessArguments(const CallExpr *Call,
10996
                               unsigned BId,
10997
                               IdentifierInfo *FnName);
10998
10999
  void CheckStrlcpycatArguments(const CallExpr *Call,
11000
                                IdentifierInfo *FnName);
11001
11002
  void CheckStrncatArguments(const CallExpr *Call,
11003
                             IdentifierInfo *FnName);
11004
11005
  void CheckReturnValExpr(Expr *RetValExp, QualType lhsType,
11006
                          SourceLocation ReturnLoc,
11007
                          bool isObjCMethod = false,
11008
                          const AttrVec *Attrs = nullptr,
11009
                          const FunctionDecl *FD = nullptr);
11010
11011
public:
11012
  void CheckFloatComparison(SourceLocation Loc, Expr *LHS, Expr *RHS);
11013
11014
private:
11015
  void CheckImplicitConversions(Expr *E, SourceLocation CC = SourceLocation());
11016
  void CheckBoolLikeConversion(Expr *E, SourceLocation CC);
11017
  void CheckForIntOverflow(Expr *E);
11018
  void CheckUnsequencedOperations(Expr *E);
11019
11020
  /// Perform semantic checks on a completed expression. This will either
11021
  /// be a full-expression or a default argument expression.
11022
  void CheckCompletedExpr(Expr *E, SourceLocation CheckLoc = SourceLocation(),
11023
                          bool IsConstexpr = false);
11024
11025
  void CheckBitFieldInitialization(SourceLocation InitLoc, FieldDecl *Field,
11026
                                   Expr *Init);
11027
11028
  /// Check if there is a field shadowing.
11029
  void CheckShadowInheritedFields(const SourceLocation &Loc,
11030
                                  DeclarationName FieldName,
11031
                                  const CXXRecordDecl *RD,
11032
                                  bool DeclIsField = true);
11033
11034
  /// Check if the given expression contains 'break' or 'continue'
11035
  /// statement that produces control flow different from GCC.
11036
  void CheckBreakContinueBinding(Expr *E);
11037
11038
  /// Check whether receiver is mutable ObjC container which
11039
  /// attempts to add itself into the container
11040
  void CheckObjCCircularContainer(ObjCMessageExpr *Message);
11041
11042
  void AnalyzeDeleteExprMismatch(const CXXDeleteExpr *DE);
11043
  void AnalyzeDeleteExprMismatch(FieldDecl *Field, SourceLocation DeleteLoc,
11044
                                 bool DeleteWasArrayForm);
11045
public:
11046
  /// Register a magic integral constant to be used as a type tag.
11047
  void RegisterTypeTagForDatatype(const IdentifierInfo *ArgumentKind,
11048
                                  uint64_t MagicValue, QualType Type,
11049
                                  bool LayoutCompatible, bool MustBeNull);
11050
11051
  struct TypeTagData {
11052
449
    TypeTagData() {}
11053
11054
    TypeTagData(QualType Type, bool LayoutCompatible, bool MustBeNull) :
11055
        Type(Type), LayoutCompatible(LayoutCompatible),
11056
        MustBeNull(MustBeNull)
11057
49
    {}
11058
11059
    QualType Type;
11060
11061
    /// If true, \c Type should be compared with other expression's types for
11062
    /// layout-compatibility.
11063
    unsigned LayoutCompatible : 1;
11064
    unsigned MustBeNull : 1;
11065
  };
11066
11067
  /// A pair of ArgumentKind identifier and magic value.  This uniquely
11068
  /// identifies the magic value.
11069
  typedef std::pair<const IdentifierInfo *, uint64_t> TypeTagMagicValue;
11070
11071
private:
11072
  /// A map from magic value to type information.
11073
  std::unique_ptr<llvm::DenseMap<TypeTagMagicValue, TypeTagData>>
11074
      TypeTagForDatatypeMagicValues;
11075
11076
  /// Peform checks on a call of a function with argument_with_type_tag
11077
  /// or pointer_with_type_tag attributes.
11078
  void CheckArgumentWithTypeTag(const ArgumentWithTypeTagAttr *Attr,
11079
                                const ArrayRef<const Expr *> ExprArgs,
11080
                                SourceLocation CallSiteLoc);
11081
11082
  /// Check if we are taking the address of a packed field
11083
  /// as this may be a problem if the pointer value is dereferenced.
11084
  void CheckAddressOfPackedMember(Expr *rhs);
11085
11086
  /// The parser's current scope.
11087
  ///
11088
  /// The parser maintains this state here.
11089
  Scope *CurScope;
11090
11091
  mutable IdentifierInfo *Ident_super;
11092
  mutable IdentifierInfo *Ident___float128;
11093
11094
  /// Nullability type specifiers.
11095
  IdentifierInfo *Ident__Nonnull = nullptr;
11096
  IdentifierInfo *Ident__Nullable = nullptr;
11097
  IdentifierInfo *Ident__Null_unspecified = nullptr;
11098
11099
  IdentifierInfo *Ident_NSError = nullptr;
11100
11101
  /// The handler for the FileChanged preprocessor events.
11102
  ///
11103
  /// Used for diagnostics that implement custom semantic analysis for #include
11104
  /// directives, like -Wpragma-pack.
11105
  sema::SemaPPCallbacks *SemaPPCallbackHandler;
11106
11107
protected:
11108
  friend class Parser;
11109
  friend class InitializationSequence;
11110
  friend class ASTReader;
11111
  friend class ASTDeclReader;
11112
  friend class ASTWriter;
11113
11114
public:
11115
  /// Retrieve the keyword associated
11116
  IdentifierInfo *getNullabilityKeyword(NullabilityKind nullability);
11117
11118
  /// The struct behind the CFErrorRef pointer.
11119
  RecordDecl *CFError = nullptr;
11120
11121
  /// Retrieve the identifier "NSError".
11122
  IdentifierInfo *getNSErrorIdent();
11123
11124
  /// Retrieve the parser's current scope.
11125
  ///
11126
  /// This routine must only be used when it is certain that semantic analysis
11127
  /// and the parser are in precisely the same context, which is not the case
11128
  /// when, e.g., we are performing any kind of template instantiation.
11129
  /// Therefore, the only safe places to use this scope are in the parser
11130
  /// itself and in routines directly invoked from the parser and *never* from
11131
  /// template substitution or instantiation.
11132
210M
  Scope *getCurScope() const { return CurScope; }
11133
11134
746k
  void incrementMSManglingNumber() const {
11135
746k
    return CurScope->incrementMSManglingNumber();
11136
746k
  }
11137
11138
  IdentifierInfo *getSuperIdentifier() const;
11139
  IdentifierInfo *getFloat128Identifier() const;
11140
11141
  Decl *getObjCDeclContext() const;
11142
11143
4.71M
  DeclContext *getCurLexicalContext() const {
11144
4.71M
    return OriginalLexicalContext ? 
OriginalLexicalContext478
:
CurContext4.71M
;
11145
4.71M
  }
11146
11147
36.1k
  const DeclContext *getCurObjCLexicalContext() const {
11148
36.1k
    const DeclContext *DC = getCurLexicalContext();
11149
36.1k
    // A category implicitly has the attribute of the interface.
11150
36.1k
    if (const ObjCCategoryDecl *CatD = dyn_cast<ObjCCategoryDecl>(DC))
11151
0
      DC = CatD->getClassInterface();
11152
36.1k
    return DC;
11153
36.1k
  }
11154
11155
  /// To be used for checking whether the arguments being passed to
11156
  /// function exceeds the number of parameters expected for it.
11157
  static bool TooManyArguments(size_t NumParams, size_t NumArgs,
11158
9.54M
                               bool PartialOverloading = false) {
11159
9.54M
    // We check whether we're just after a comma in code-completion.
11160
9.54M
    if (NumArgs > 0 && 
PartialOverloading8.11M
)
11161
212
      return NumArgs + 1 > NumParams; // If so, we view as an extra argument.
11162
9.54M
    return NumArgs > NumParams;
11163
9.54M
  }
11164
11165
  // Emitting members of dllexported classes is delayed until the class
11166
  // (including field initializers) is fully parsed.
11167
  SmallVector<CXXRecordDecl*, 4> DelayedDllExportClasses;
11168
11169
private:
11170
  class SavePendingParsedClassStateRAII {
11171
  public:
11172
1.10M
    SavePendingParsedClassStateRAII(Sema &S) : S(S) { swapSavedState(); }
11173
11174
1.10M
    ~SavePendingParsedClassStateRAII() {
11175
1.10M
      assert(S.DelayedOverridingExceptionSpecChecks.empty() &&
11176
1.10M
             "there shouldn't be any pending delayed exception spec checks");
11177
1.10M
      assert(S.DelayedEquivalentExceptionSpecChecks.empty() &&
11178
1.10M
             "there shouldn't be any pending delayed exception spec checks");
11179
1.10M
      assert(S.DelayedDllExportClasses.empty() &&
11180
1.10M
             "there shouldn't be any pending delayed DLL export classes");
11181
1.10M
      swapSavedState();
11182
1.10M
    }
11183
11184
  private:
11185
    Sema &S;
11186
    decltype(DelayedOverridingExceptionSpecChecks)
11187
        SavedOverridingExceptionSpecChecks;
11188
    decltype(DelayedEquivalentExceptionSpecChecks)
11189
        SavedEquivalentExceptionSpecChecks;
11190
    decltype(DelayedDllExportClasses) SavedDllExportClasses;
11191
11192
2.21M
    void swapSavedState() {
11193
2.21M
      SavedOverridingExceptionSpecChecks.swap(
11194
2.21M
          S.DelayedOverridingExceptionSpecChecks);
11195
2.21M
      SavedEquivalentExceptionSpecChecks.swap(
11196
2.21M
          S.DelayedEquivalentExceptionSpecChecks);
11197
2.21M
      SavedDllExportClasses.swap(S.DelayedDllExportClasses);
11198
2.21M
    }
11199
  };
11200
11201
  /// Helper class that collects misaligned member designations and
11202
  /// their location info for delayed diagnostics.
11203
  struct MisalignedMember {
11204
    Expr *E;
11205
    RecordDecl *RD;
11206
    ValueDecl *MD;
11207
    CharUnits Alignment;
11208
11209
0
    MisalignedMember() : E(), RD(), MD(), Alignment() {}
11210
    MisalignedMember(Expr *E, RecordDecl *RD, ValueDecl *MD,
11211
                     CharUnits Alignment)
11212
73.6k
        : E(E), RD(RD), MD(MD), Alignment(Alignment) {}
11213
    explicit MisalignedMember(Expr *E)
11214
73.6k
        : MisalignedMember(E, nullptr, nullptr, CharUnits()) {}
Unexecuted instantiation: clang::Sema::MisalignedMember::MisalignedMember(clang::Expr*)
clang::Sema::MisalignedMember::MisalignedMember(clang::Expr*)
Line
Count
Source
11214
73.6k
        : MisalignedMember(E, nullptr, nullptr, CharUnits()) {}
11215
11216
54
    bool operator==(const MisalignedMember &m) { return this->E == m.E; }
11217
  };
11218
  /// Small set of gathered accesses to potentially misaligned members
11219
  /// due to the packed attribute.
11220
  SmallVector<MisalignedMember, 4> MisalignedMembers;
11221
11222
  /// Adds an expression to the set of gathered misaligned members.
11223
  void AddPotentialMisalignedMembers(Expr *E, RecordDecl *RD, ValueDecl *MD,
11224
                                     CharUnits Alignment);
11225
11226
public:
11227
  /// Diagnoses the current set of gathered accesses. This typically
11228
  /// happens at full expression level. The set is cleared after emitting the
11229
  /// diagnostics.
11230
  void DiagnoseMisalignedMembers();
11231
11232
  /// This function checks if the expression is in the sef of potentially
11233
  /// misaligned members and it is converted to some pointer type T with lower
11234
  /// or equal alignment requirements. If so it removes it. This is used when
11235
  /// we do not want to diagnose such misaligned access (e.g. in conversions to
11236
  /// void*).
11237
  void DiscardMisalignedMemberAddress(const Type *T, Expr *E);
11238
11239
  /// This function calls Action when it determines that E designates a
11240
  /// misaligned member due to the packed attribute. This is used to emit
11241
  /// local diagnostics like in reference binding.
11242
  void RefersToMemberWithReducedAlignment(
11243
      Expr *E,
11244
      llvm::function_ref<void(Expr *, RecordDecl *, FieldDecl *, CharUnits)>
11245
          Action);
11246
11247
  /// Describes the reason a calling convention specification was ignored, used
11248
  /// for diagnostics.
11249
  enum class CallingConventionIgnoredReason {
11250
    ForThisTarget = 0,
11251
    VariadicFunction,
11252
    ConstructorDestructor,
11253
    BuiltinFunction
11254
  };
11255
};
11256
11257
/// RAII object that enters a new expression evaluation context.
11258
class EnterExpressionEvaluationContext {
11259
  Sema &Actions;
11260
  bool Entered = true;
11261
11262
public:
11263
  EnterExpressionEvaluationContext(
11264
      Sema &Actions, Sema::ExpressionEvaluationContext NewContext,
11265
      Decl *LambdaContextDecl = nullptr,
11266
      Sema::ExpressionEvaluationContextRecord::ExpressionKind ExprContext =
11267
          Sema::ExpressionEvaluationContextRecord::EK_Other,
11268
      bool ShouldEnter = true)
11269
41.6M
      : Actions(Actions), Entered(ShouldEnter) {
11270
41.6M
    if (Entered)
11271
40.5M
      Actions.PushExpressionEvaluationContext(NewContext, LambdaContextDecl,
11272
40.5M
                                              ExprContext);
11273
41.6M
  }
11274
  EnterExpressionEvaluationContext(
11275
      Sema &Actions, Sema::ExpressionEvaluationContext NewContext,
11276
      Sema::ReuseLambdaContextDecl_t,
11277
      Sema::ExpressionEvaluationContextRecord::ExpressionKind ExprContext =
11278
          Sema::ExpressionEvaluationContextRecord::EK_Other)
11279
251k
      : Actions(Actions) {
11280
251k
    Actions.PushExpressionEvaluationContext(
11281
251k
        NewContext, Sema::ReuseLambdaContextDecl, ExprContext);
11282
251k
  }
11283
11284
  enum InitListTag { InitList };
11285
  EnterExpressionEvaluationContext(Sema &Actions, InitListTag,
11286
                                   bool ShouldEnter = true)
11287
13.1M
      : Actions(Actions), Entered(false) {
11288
13.1M
    // In C++11 onwards, narrowing checks are performed on the contents of
11289
13.1M
    // braced-init-lists, even when they occur within unevaluated operands.
11290
13.1M
    // Therefore we still need to instantiate constexpr functions used in such
11291
13.1M
    // a context.
11292
13.1M
    if (ShouldEnter && 
Actions.isUnevaluatedContext()220k
&&
11293
13.1M
        
Actions.getLangOpts().CPlusPlus1111.2k
) {
11294
11.2k
      Actions.PushExpressionEvaluationContext(
11295
11.2k
          Sema::ExpressionEvaluationContext::UnevaluatedList);
11296
11.2k
      Entered = true;
11297
11.2k
    }
11298
13.1M
  }
11299
11300
55.1M
  ~EnterExpressionEvaluationContext() {
11301
55.1M
    if (Entered)
11302
40.8M
      Actions.PopExpressionEvaluationContext();
11303
55.1M
  }
11304
};
11305
11306
DeductionFailureInfo
11307
MakeDeductionFailureInfo(ASTContext &Context, Sema::TemplateDeductionResult TDK,
11308
                         sema::TemplateDeductionInfo &Info);
11309
11310
/// Contains a late templated function.
11311
/// Will be parsed at the end of the translation unit, used by Sema & Parser.
11312
struct LateParsedTemplate {
11313
  CachedTokens Toks;
11314
  /// The template function declaration to be late parsed.
11315
  Decl *D;
11316
};
11317
} // end namespace clang
11318
11319
namespace llvm {
11320
// Hash a FunctionDeclAndLoc by looking at both its FunctionDecl and its
11321
// SourceLocation.
11322
template <> struct DenseMapInfo<clang::Sema::FunctionDeclAndLoc> {
11323
  using FunctionDeclAndLoc = clang::Sema::FunctionDeclAndLoc;
11324
  using FDBaseInfo = DenseMapInfo<clang::CanonicalDeclPtr<clang::FunctionDecl>>;
11325
11326
273
  static FunctionDeclAndLoc getEmptyKey() {
11327
273
    return {FDBaseInfo::getEmptyKey(), clang::SourceLocation()};
11328
273
  }
11329
11330
153
  static FunctionDeclAndLoc getTombstoneKey() {
11331
153
    return {FDBaseInfo::getTombstoneKey(), clang::SourceLocation()};
11332
153
  }
11333
11334
134
  static unsigned getHashValue(const FunctionDeclAndLoc &FDL) {
11335
134
    return hash_combine(FDBaseInfo::getHashValue(FDL.FD),
11336
134
                        FDL.Loc.getRawEncoding());
11337
134
  }
11338
11339
  static bool isEqual(const FunctionDeclAndLoc &LHS,
11340
1.70k
                      const FunctionDeclAndLoc &RHS) {
11341
1.70k
    return LHS.FD == RHS.FD && 
LHS.Loc == RHS.Loc1.35k
;
11342
1.70k
  }
11343
};
11344
} // namespace llvm
11345
11346
#endif