clang  3.8.0
Sema.cpp
Go to the documentation of this file.
1 //===--- Sema.cpp - AST Builder and Semantic Analysis Implementation ------===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file implements the actions class which performs semantic analysis and
11 // builds an AST out of a parse stream.
12 //
13 //===----------------------------------------------------------------------===//
14 
16 #include "clang/AST/ASTContext.h"
18 #include "clang/AST/DeclCXX.h"
19 #include "clang/AST/DeclFriend.h"
20 #include "clang/AST/DeclObjC.h"
21 #include "clang/AST/Expr.h"
22 #include "clang/AST/ExprCXX.h"
23 #include "clang/AST/StmtCXX.h"
27 #include "clang/Basic/TargetInfo.h"
28 #include "clang/Lex/HeaderSearch.h"
29 #include "clang/Lex/Preprocessor.h"
36 #include "clang/Sema/Scope.h"
37 #include "clang/Sema/ScopeInfo.h"
40 #include "llvm/ADT/APFloat.h"
41 #include "llvm/ADT/DenseMap.h"
42 #include "llvm/ADT/SmallSet.h"
43 using namespace clang;
44 using namespace sema;
45 
47  return Lexer::getLocForEndOfToken(Loc, Offset, SourceMgr, LangOpts);
48 }
49 
50 ModuleLoader &Sema::getModuleLoader() const { return PP.getModuleLoader(); }
51 
53  const Preprocessor &PP) {
54  PrintingPolicy Policy = Context.getPrintingPolicy();
55  Policy.Bool = Context.getLangOpts().Bool;
56  if (!Policy.Bool) {
57  if (const MacroInfo *
58  BoolMacro = PP.getMacroInfo(&Context.Idents.get("bool"))) {
59  Policy.Bool = BoolMacro->isObjectLike() &&
60  BoolMacro->getNumTokens() == 1 &&
61  BoolMacro->getReplacementToken(0).is(tok::kw__Bool);
62  }
63  }
64 
65  return Policy;
66 }
67 
69  TUScope = S;
70  PushDeclContext(S, Context.getTranslationUnitDecl());
71 }
72 
73 Sema::Sema(Preprocessor &pp, ASTContext &ctxt, ASTConsumer &consumer,
74  TranslationUnitKind TUKind,
75  CodeCompleteConsumer *CodeCompleter)
76  : ExternalSource(nullptr),
77  isMultiplexExternalSource(false), FPFeatures(pp.getLangOpts()),
78  LangOpts(pp.getLangOpts()), PP(pp), Context(ctxt), Consumer(consumer),
79  Diags(PP.getDiagnostics()), SourceMgr(PP.getSourceManager()),
80  CollectStats(false), CodeCompleter(CodeCompleter),
81  CurContext(nullptr), OriginalLexicalContext(nullptr),
82  PackContext(nullptr), MSStructPragmaOn(false),
83  MSPointerToMemberRepresentationMethod(
84  LangOpts.getMSPointerToMemberRepresentationMethod()),
85  VtorDispModeStack(1, MSVtorDispAttr::Mode(LangOpts.VtorDispMode)),
86  DataSegStack(nullptr), BSSSegStack(nullptr), ConstSegStack(nullptr),
87  CodeSegStack(nullptr), CurInitSeg(nullptr), VisContext(nullptr),
88  IsBuildingRecoveryCallExpr(false),
89  ExprNeedsCleanups(false), LateTemplateParser(nullptr),
90  LateTemplateParserCleanup(nullptr),
91  OpaqueParser(nullptr), IdResolver(pp), StdInitializerList(nullptr),
92  CXXTypeInfoDecl(nullptr), MSVCGuidDecl(nullptr),
93  NSNumberDecl(nullptr), NSValueDecl(nullptr),
94  NSStringDecl(nullptr), StringWithUTF8StringMethod(nullptr),
95  ValueWithBytesObjCTypeMethod(nullptr),
96  NSArrayDecl(nullptr), ArrayWithObjectsMethod(nullptr),
97  NSDictionaryDecl(nullptr), DictionaryWithObjectsMethod(nullptr),
98  MSAsmLabelNameCounter(0),
99  GlobalNewDeleteDeclared(false),
100  TUKind(TUKind),
101  NumSFINAEErrors(0),
102  CachedFakeTopLevelModule(nullptr),
103  AccessCheckingSFINAE(false), InNonInstantiationSFINAEContext(false),
104  NonInstantiationEntries(0), ArgumentPackSubstitutionIndex(-1),
105  CurrentInstantiationScope(nullptr), DisableTypoCorrection(false),
106  TyposCorrected(0), AnalysisWarnings(*this), ThreadSafetyDeclCache(nullptr),
107  VarDataSharingAttributesStack(nullptr), CurScope(nullptr),
108  Ident_super(nullptr), Ident___float128(nullptr)
109 {
110  TUScope = nullptr;
111 
112  LoadedExternalKnownNamespaces = false;
113  for (unsigned I = 0; I != NSAPI::NumNSNumberLiteralMethods; ++I)
114  NSNumberLiteralMethods[I] = nullptr;
115 
116  if (getLangOpts().ObjC1)
117  NSAPIObj.reset(new NSAPI(Context));
118 
119  if (getLangOpts().CPlusPlus)
120  FieldCollector.reset(new CXXFieldCollector());
121 
122  // Tell diagnostics how to render things from the AST library.
124 
125  ExprEvalContexts.emplace_back(PotentiallyEvaluated, 0, false, nullptr, false);
126 
127  FunctionScopes.push_back(new FunctionScopeInfo(Diags));
128 
129  // Initilization of data sharing attributes stack for OpenMP
130  InitDataSharingAttributesStack();
131 }
132 
134  DeclarationName DN = &Context.Idents.get(Name);
135  if (IdResolver.begin(DN) == IdResolver.end())
137 }
138 
140  if (SemaConsumer *SC = dyn_cast<SemaConsumer>(&Consumer))
141  SC->InitializeSema(*this);
142 
143  // Tell the external Sema source about this Sema object.
144  if (ExternalSemaSource *ExternalSema
145  = dyn_cast_or_null<ExternalSemaSource>(Context.getExternalSource()))
146  ExternalSema->InitializeSema(*this);
147 
148  // This needs to happen after ExternalSemaSource::InitializeSema(this) or we
149  // will not be able to merge any duplicate __va_list_tag decls correctly.
150  VAListTagName = PP.getIdentifierInfo("__va_list_tag");
151 
152  if (!TUScope)
153  return;
154 
155  // Initialize predefined 128-bit integer types, if needed.
157  // If either of the 128-bit integer types are unavailable to name lookup,
158  // define them now.
159  DeclarationName Int128 = &Context.Idents.get("__int128_t");
160  if (IdResolver.begin(Int128) == IdResolver.end())
162 
163  DeclarationName UInt128 = &Context.Idents.get("__uint128_t");
164  if (IdResolver.begin(UInt128) == IdResolver.end())
166  }
167 
168 
169  // Initialize predefined Objective-C types:
170  if (getLangOpts().ObjC1) {
171  // If 'SEL' does not yet refer to any declarations, make it refer to the
172  // predefined 'SEL'.
173  DeclarationName SEL = &Context.Idents.get("SEL");
174  if (IdResolver.begin(SEL) == IdResolver.end())
176 
177  // If 'id' does not yet refer to any declarations, make it refer to the
178  // predefined 'id'.
179  DeclarationName Id = &Context.Idents.get("id");
180  if (IdResolver.begin(Id) == IdResolver.end())
182 
183  // Create the built-in typedef for 'Class'.
184  DeclarationName Class = &Context.Idents.get("Class");
185  if (IdResolver.begin(Class) == IdResolver.end())
187 
188  // Create the built-in forward declaratino for 'Protocol'.
189  DeclarationName Protocol = &Context.Idents.get("Protocol");
190  if (IdResolver.begin(Protocol) == IdResolver.end())
192  }
193 
194  // Initialize Microsoft "predefined C++ types".
195  if (getLangOpts().MSVCCompat) {
196  if (getLangOpts().CPlusPlus &&
197  IdResolver.begin(&Context.Idents.get("type_info")) == IdResolver.end())
199  TUScope);
200 
202  }
203 
204  // Initialize predefined OpenCL types.
205  if (getLangOpts().OpenCL) {
207  addImplicitTypedef("image1d_array_t", Context.OCLImage1dArrayTy);
208  addImplicitTypedef("image1d_buffer_t", Context.OCLImage1dBufferTy);
210  addImplicitTypedef("image2d_array_t", Context.OCLImage2dArrayTy);
214  if (getLangOpts().OpenCLVersion >= 200) {
215  addImplicitTypedef("image2d_depth_t", Context.OCLImage2dDepthTy);
216  addImplicitTypedef("image2d_array_depth_t",
218  addImplicitTypedef("image2d_msaa_t", Context.OCLImage2dMSAATy);
219  addImplicitTypedef("image2d_array_msaa_t", Context.OCLImage2dArrayMSAATy);
220  addImplicitTypedef("image2d_msaa_depth_t", Context.OCLImage2dMSAADepthTy);
221  addImplicitTypedef("image2d_array_msaa_depth_t",
223  addImplicitTypedef("clk_event_t", Context.OCLClkEventTy);
226  addImplicitTypedef("reserve_id_t", Context.OCLReserveIDTy);
228  addImplicitTypedef("atomic_uint",
231  addImplicitTypedef("atomic_ulong",
233  addImplicitTypedef("atomic_float",
235  addImplicitTypedef("atomic_double",
237  // OpenCLC v2.0, s6.13.11.6 requires that atomic_flag is implemented as
238  // 32-bit integer and OpenCLC v2.0, s6.1.1 int is always 32-bit wide.
240  addImplicitTypedef("atomic_intptr_t",
242  addImplicitTypedef("atomic_uintptr_t",
244  addImplicitTypedef("atomic_size_t",
246  addImplicitTypedef("atomic_ptrdiff_t",
248  }
249  }
250 
252  DeclarationName MSVaList = &Context.Idents.get("__builtin_ms_va_list");
253  if (IdResolver.begin(MSVaList) == IdResolver.end())
255  }
256 
257  DeclarationName BuiltinVaList = &Context.Idents.get("__builtin_va_list");
258  if (IdResolver.begin(BuiltinVaList) == IdResolver.end())
260 }
261 
263  llvm::DeleteContainerSeconds(LateParsedTemplateMap);
265  if (VisContext) FreeVisContext();
266  // Kill all the active scopes.
267  for (unsigned I = 1, E = FunctionScopes.size(); I != E; ++I)
268  delete FunctionScopes[I];
269  if (FunctionScopes.size() == 1)
270  delete FunctionScopes[0];
271 
272  // Tell the SemaConsumer to forget about us; we're going out of scope.
273  if (SemaConsumer *SC = dyn_cast<SemaConsumer>(&Consumer))
274  SC->ForgetSema();
275 
276  // Detach from the external Sema source.
277  if (ExternalSemaSource *ExternalSema
278  = dyn_cast_or_null<ExternalSemaSource>(Context.getExternalSource()))
279  ExternalSema->ForgetSema();
280 
281  // If Sema's ExternalSource is the multiplexer - we own it.
282  if (isMultiplexExternalSource)
283  delete ExternalSource;
284 
286 
287  // Destroys data sharing attributes stack for OpenMP
288  DestroyDataSharingAttributesStack();
289 
290  assert(DelayedTypos.empty() && "Uncorrected typos!");
291 }
292 
293 /// makeUnavailableInSystemHeader - There is an error in the current
294 /// context. If we're still in a system header, and we can plausibly
295 /// make the relevant declaration unavailable instead of erroring, do
296 /// so and return true.
298  UnavailableAttr::ImplicitReason reason) {
299  // If we're not in a function, it's an error.
300  FunctionDecl *fn = dyn_cast<FunctionDecl>(CurContext);
301  if (!fn) return false;
302 
303  // If we're in template instantiation, it's an error.
304  if (!ActiveTemplateInstantiations.empty())
305  return false;
306 
307  // If that function's not in a system header, it's an error.
309  return false;
310 
311  // If the function is already unavailable, it's not an error.
312  if (fn->hasAttr<UnavailableAttr>()) return true;
313 
314  fn->addAttr(UnavailableAttr::CreateImplicit(Context, "", reason, loc));
315  return true;
316 }
317 
320 }
321 
322 ///\brief Registers an external source. If an external source already exists,
323 /// creates a multiplex external source and appends to it.
324 ///
325 ///\param[in] E - A non-null external sema source.
326 ///
328  assert(E && "Cannot use with NULL ptr");
329 
330  if (!ExternalSource) {
331  ExternalSource = E;
332  return;
333  }
334 
335  if (isMultiplexExternalSource)
336  static_cast<MultiplexExternalSemaSource*>(ExternalSource)->addSource(*E);
337  else {
338  ExternalSource = new MultiplexExternalSemaSource(*ExternalSource, *E);
339  isMultiplexExternalSource = true;
340  }
341 }
342 
343 /// \brief Print out statistics about the semantic analysis.
344 void Sema::PrintStats() const {
345  llvm::errs() << "\n*** Semantic Analysis Stats:\n";
346  llvm::errs() << NumSFINAEErrors << " SFINAE diagnostics trapped.\n";
347 
348  BumpAlloc.PrintStats();
350 }
351 
353  QualType SrcType,
354  SourceLocation Loc) {
355  Optional<NullabilityKind> ExprNullability = SrcType->getNullability(Context);
356  if (!ExprNullability || *ExprNullability != NullabilityKind::Nullable)
357  return;
358 
359  Optional<NullabilityKind> TypeNullability = DstType->getNullability(Context);
360  if (!TypeNullability || *TypeNullability != NullabilityKind::NonNull)
361  return;
362 
363  Diag(Loc, diag::warn_nullability_lost) << SrcType << DstType;
364 }
365 
366 /// ImpCastExprToType - If Expr is not of type 'Type', insert an implicit cast.
367 /// If there is already an implicit cast, merge into the existing one.
368 /// The result is of the given category.
371  const CXXCastPath *BasePath,
372  CheckedConversionKind CCK) {
373 #ifndef NDEBUG
374  if (VK == VK_RValue && !E->isRValue()) {
375  switch (Kind) {
376  default:
377  llvm_unreachable("can't implicitly cast lvalue to rvalue with this cast "
378  "kind");
379  case CK_LValueToRValue:
382  case CK_ToVoid:
383  break;
384  }
385  }
386  assert((VK == VK_RValue || !E->isRValue()) && "can't cast rvalue to lvalue");
387 #endif
388 
389  diagnoseNullableToNonnullConversion(Ty, E->getType(), E->getLocStart());
390 
391  QualType ExprTy = Context.getCanonicalType(E->getType());
393 
394  if (ExprTy == TypeTy)
395  return E;
396 
397  if (ImplicitCastExpr *ImpCast = dyn_cast<ImplicitCastExpr>(E)) {
398  if (ImpCast->getCastKind() == Kind && (!BasePath || BasePath->empty())) {
399  ImpCast->setType(Ty);
400  ImpCast->setValueKind(VK);
401  return E;
402  }
403  }
404 
405  return ImplicitCastExpr::Create(Context, Ty, Kind, E, BasePath, VK);
406 }
407 
408 /// ScalarTypeToBooleanCastKind - Returns the cast kind corresponding
409 /// to the conversion from scalar type ScalarTy to the Boolean type.
411  switch (ScalarTy->getScalarTypeKind()) {
412  case Type::STK_Bool: return CK_NoOp;
421  }
422  return CK_Invalid;
423 }
424 
425 /// \brief Used to prune the decls of Sema's UnusedFileScopedDecls vector.
426 static bool ShouldRemoveFromUnused(Sema *SemaRef, const DeclaratorDecl *D) {
427  if (D->getMostRecentDecl()->isUsed())
428  return true;
429 
430  if (D->isExternallyVisible())
431  return true;
432 
433  if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
434  // UnusedFileScopedDecls stores the first declaration.
435  // The declaration may have become definition so check again.
436  const FunctionDecl *DeclToCheck;
437  if (FD->hasBody(DeclToCheck))
438  return !SemaRef->ShouldWarnIfUnusedFileScopedDecl(DeclToCheck);
439 
440  // Later redecls may add new information resulting in not having to warn,
441  // so check again.
442  DeclToCheck = FD->getMostRecentDecl();
443  if (DeclToCheck != FD)
444  return !SemaRef->ShouldWarnIfUnusedFileScopedDecl(DeclToCheck);
445  }
446 
447  if (const VarDecl *VD = dyn_cast<VarDecl>(D)) {
448  // If a variable usable in constant expressions is referenced,
449  // don't warn if it isn't used: if the value of a variable is required
450  // for the computation of a constant expression, it doesn't make sense to
451  // warn even if the variable isn't odr-used. (isReferenced doesn't
452  // precisely reflect that, but it's a decent approximation.)
453  if (VD->isReferenced() &&
454  VD->isUsableInConstantExpressions(SemaRef->Context))
455  return true;
456 
457  // UnusedFileScopedDecls stores the first declaration.
458  // The declaration may have become definition so check again.
459  const VarDecl *DeclToCheck = VD->getDefinition();
460  if (DeclToCheck)
461  return !SemaRef->ShouldWarnIfUnusedFileScopedDecl(DeclToCheck);
462 
463  // Later redecls may add new information resulting in not having to warn,
464  // so check again.
465  DeclToCheck = VD->getMostRecentDecl();
466  if (DeclToCheck != VD)
467  return !SemaRef->ShouldWarnIfUnusedFileScopedDecl(DeclToCheck);
468  }
469 
470  return false;
471 }
472 
473 /// Obtains a sorted list of functions that are undefined but ODR-used.
475  SmallVectorImpl<std::pair<NamedDecl *, SourceLocation> > &Undefined) {
477  I = UndefinedButUsed.begin(), E = UndefinedButUsed.end();
478  I != E; ++I) {
479  NamedDecl *ND = I->first;
480 
481  // Ignore attributes that have become invalid.
482  if (ND->isInvalidDecl()) continue;
483 
484  // __attribute__((weakref)) is basically a definition.
485  if (ND->hasAttr<WeakRefAttr>()) continue;
486 
487  if (FunctionDecl *FD = dyn_cast<FunctionDecl>(ND)) {
488  if (FD->isDefined())
489  continue;
490  if (FD->isExternallyVisible() &&
491  !FD->getMostRecentDecl()->isInlined())
492  continue;
493  } else {
494  if (cast<VarDecl>(ND)->hasDefinition() != VarDecl::DeclarationOnly)
495  continue;
496  if (ND->isExternallyVisible())
497  continue;
498  }
499 
500  Undefined.push_back(std::make_pair(ND, I->second));
501  }
502 
503  // Sort (in order of use site) so that we're not dependent on the iteration
504  // order through an llvm::DenseMap.
506  std::sort(Undefined.begin(), Undefined.end(),
507  [&SM](const std::pair<NamedDecl *, SourceLocation> &l,
508  const std::pair<NamedDecl *, SourceLocation> &r) {
509  if (l.second.isValid() && !r.second.isValid())
510  return true;
511  if (!l.second.isValid() && r.second.isValid())
512  return false;
513  if (l.second != r.second)
514  return SM.isBeforeInTranslationUnit(l.second, r.second);
515  return SM.isBeforeInTranslationUnit(l.first->getLocation(),
516  r.first->getLocation());
517  });
518 }
519 
520 /// checkUndefinedButUsed - Check for undefined objects with internal linkage
521 /// or that are inline.
522 static void checkUndefinedButUsed(Sema &S) {
523  if (S.UndefinedButUsed.empty()) return;
524 
525  // Collect all the still-undefined entities with internal linkage.
527  S.getUndefinedButUsed(Undefined);
528  if (Undefined.empty()) return;
529 
530  for (SmallVectorImpl<std::pair<NamedDecl *, SourceLocation> >::iterator
531  I = Undefined.begin(), E = Undefined.end(); I != E; ++I) {
532  NamedDecl *ND = I->first;
533 
534  if (ND->hasAttr<DLLImportAttr>() || ND->hasAttr<DLLExportAttr>()) {
535  // An exported function will always be emitted when defined, so even if
536  // the function is inline, it doesn't have to be emitted in this TU. An
537  // imported function implies that it has been exported somewhere else.
538  continue;
539  }
540 
541  if (!ND->isExternallyVisible()) {
542  S.Diag(ND->getLocation(), diag::warn_undefined_internal)
543  << isa<VarDecl>(ND) << ND;
544  } else {
545  assert(cast<FunctionDecl>(ND)->getMostRecentDecl()->isInlined() &&
546  "used object requires definition but isn't inline or internal?");
547  S.Diag(ND->getLocation(), diag::warn_undefined_inline) << ND;
548  }
549  if (I->second.isValid())
550  S.Diag(I->second, diag::note_used_here);
551  }
552 }
553 
555  if (!ExternalSource)
556  return;
557 
559  ExternalSource->ReadWeakUndeclaredIdentifiers(WeakIDs);
560  for (auto &WeakID : WeakIDs)
561  WeakUndeclaredIdentifiers.insert(WeakID);
562 }
563 
564 
565 typedef llvm::DenseMap<const CXXRecordDecl*, bool> RecordCompleteMap;
566 
567 /// \brief Returns true, if all methods and nested classes of the given
568 /// CXXRecordDecl are defined in this translation unit.
569 ///
570 /// Should only be called from ActOnEndOfTranslationUnit so that all
571 /// definitions are actually read.
573  RecordCompleteMap &MNCComplete) {
574  RecordCompleteMap::iterator Cache = MNCComplete.find(RD);
575  if (Cache != MNCComplete.end())
576  return Cache->second;
577  if (!RD->isCompleteDefinition())
578  return false;
579  bool Complete = true;
581  E = RD->decls_end();
582  I != E && Complete; ++I) {
583  if (const CXXMethodDecl *M = dyn_cast<CXXMethodDecl>(*I))
584  Complete = M->isDefined() || (M->isPure() && !isa<CXXDestructorDecl>(M));
585  else if (const FunctionTemplateDecl *F = dyn_cast<FunctionTemplateDecl>(*I))
586  // If the template function is marked as late template parsed at this
587  // point, it has not been instantiated and therefore we have not
588  // performed semantic analysis on it yet, so we cannot know if the type
589  // can be considered complete.
590  Complete = !F->getTemplatedDecl()->isLateTemplateParsed() &&
591  F->getTemplatedDecl()->isDefined();
592  else if (const CXXRecordDecl *R = dyn_cast<CXXRecordDecl>(*I)) {
593  if (R->isInjectedClassName())
594  continue;
595  if (R->hasDefinition())
596  Complete = MethodsAndNestedClassesComplete(R->getDefinition(),
597  MNCComplete);
598  else
599  Complete = false;
600  }
601  }
602  MNCComplete[RD] = Complete;
603  return Complete;
604 }
605 
606 /// \brief Returns true, if the given CXXRecordDecl is fully defined in this
607 /// translation unit, i.e. all methods are defined or pure virtual and all
608 /// friends, friend functions and nested classes are fully defined in this
609 /// translation unit.
610 ///
611 /// Should only be called from ActOnEndOfTranslationUnit so that all
612 /// definitions are actually read.
613 static bool IsRecordFullyDefined(const CXXRecordDecl *RD,
614  RecordCompleteMap &RecordsComplete,
615  RecordCompleteMap &MNCComplete) {
616  RecordCompleteMap::iterator Cache = RecordsComplete.find(RD);
617  if (Cache != RecordsComplete.end())
618  return Cache->second;
619  bool Complete = MethodsAndNestedClassesComplete(RD, MNCComplete);
621  E = RD->friend_end();
622  I != E && Complete; ++I) {
623  // Check if friend classes and methods are complete.
624  if (TypeSourceInfo *TSI = (*I)->getFriendType()) {
625  // Friend classes are available as the TypeSourceInfo of the FriendDecl.
626  if (CXXRecordDecl *FriendD = TSI->getType()->getAsCXXRecordDecl())
627  Complete = MethodsAndNestedClassesComplete(FriendD, MNCComplete);
628  else
629  Complete = false;
630  } else {
631  // Friend functions are available through the NamedDecl of FriendDecl.
632  if (const FunctionDecl *FD =
633  dyn_cast<FunctionDecl>((*I)->getFriendDecl()))
634  Complete = FD->isDefined();
635  else
636  // This is a template friend, give up.
637  Complete = false;
638  }
639  }
640  RecordsComplete[RD] = Complete;
641  return Complete;
642 }
643 
645  if (ExternalSource)
646  ExternalSource->ReadUnusedLocalTypedefNameCandidates(
649  if (TD->isReferenced())
650  continue;
651  Diag(TD->getLocation(), diag::warn_unused_local_typedef)
652  << isa<TypeAliasDecl>(TD) << TD->getDeclName();
653  }
654  UnusedLocalTypedefNameCandidates.clear();
655 }
656 
657 /// ActOnEndOfTranslationUnit - This is called at the very end of the
658 /// translation unit when EOF is reached and all but the top-level scope is
659 /// popped.
661  assert(DelayedDiagnostics.getCurrentPool() == nullptr
662  && "reached end of translation unit with a pool attached?");
663 
664  // If code completion is enabled, don't perform any end-of-translation-unit
665  // work.
667  return;
668 
669  // Complete translation units and modules define vtables and perform implicit
670  // instantiations. PCH files do not.
671  if (TUKind != TU_Prefix) {
673 
674  // If DefinedUsedVTables ends up marking any virtual member functions it
675  // might lead to more pending template instantiations, which we then need
676  // to instantiate.
678 
679  // C++: Perform implicit template instantiations.
680  //
681  // FIXME: When we perform these implicit instantiations, we do not
682  // carefully keep track of the point of instantiation (C++ [temp.point]).
683  // This means that name lookup that occurs within the template
684  // instantiation will always happen at the end of the translation unit,
685  // so it will find some names that are not required to be found. This is
686  // valid, but we could do better by diagnosing if an instantiation uses a
687  // name that was not visible at its first point of instantiation.
688  if (ExternalSource) {
689  // Load pending instantiations from the external source.
691  ExternalSource->ReadPendingInstantiations(Pending);
693  Pending.begin(), Pending.end());
694  }
696 
699 
701  }
702 
703  // All delayed member exception specs should be checked or we end up accepting
704  // incompatible declarations.
705  // FIXME: This is wrong for TUKind == TU_Prefix. In that case, we need to
706  // write out the lists to the AST file (if any).
707  assert(DelayedDefaultedMemberExceptionSpecs.empty());
708  assert(DelayedExceptionSpecChecks.empty());
709 
710  // All dllexport classes should have been processed already.
711  assert(DelayedDllExportClasses.empty());
712 
713  // Remove file scoped decls that turned out to be used.
715  std::remove_if(UnusedFileScopedDecls.begin(nullptr, true),
717  std::bind1st(std::ptr_fun(ShouldRemoveFromUnused), this)),
719 
720  if (TUKind == TU_Prefix) {
721  // Translation unit prefixes don't need any of the checking below.
722  TUScope = nullptr;
723  return;
724  }
725 
726  // Check for #pragma weak identifiers that were never declared
728  for (auto WeakID : WeakUndeclaredIdentifiers) {
729  if (WeakID.second.getUsed())
730  continue;
731 
732  Decl *PrevDecl = LookupSingleName(TUScope, WeakID.first, SourceLocation(),
734  if (PrevDecl != nullptr &&
735  !(isa<FunctionDecl>(PrevDecl) || isa<VarDecl>(PrevDecl)))
736  Diag(WeakID.second.getLocation(), diag::warn_attribute_wrong_decl_type)
737  << "'weak'" << ExpectedVariableOrFunction;
738  else
739  Diag(WeakID.second.getLocation(), diag::warn_weak_identifier_undeclared)
740  << WeakID.first;
741  }
742 
743  if (LangOpts.CPlusPlus11 &&
744  !Diags.isIgnored(diag::warn_delegating_ctor_cycle, SourceLocation()))
746 
747  if (TUKind == TU_Module) {
748  // If we are building a module, resolve all of the exported declarations
749  // now.
750  if (Module *CurrentModule = PP.getCurrentModule()) {
752 
754  Stack.push_back(CurrentModule);
755  while (!Stack.empty()) {
756  Module *Mod = Stack.pop_back_val();
757 
758  // Resolve the exported declarations and conflicts.
759  // FIXME: Actually complain, once we figure out how to teach the
760  // diagnostic client to deal with complaints in the module map at this
761  // point.
762  ModMap.resolveExports(Mod, /*Complain=*/false);
763  ModMap.resolveUses(Mod, /*Complain=*/false);
764  ModMap.resolveConflicts(Mod, /*Complain=*/false);
765 
766  // Queue the submodules, so their exports will also be resolved.
767  Stack.append(Mod->submodule_begin(), Mod->submodule_end());
768  }
769  }
770 
771  // Warnings emitted in ActOnEndOfTranslationUnit() should be emitted for
772  // modules when they are built, not every time they are used.
774 
775  // Modules don't need any of the checking below.
776  TUScope = nullptr;
777  return;
778  }
779 
780  // C99 6.9.2p2:
781  // A declaration of an identifier for an object that has file
782  // scope without an initializer, and without a storage-class
783  // specifier or with the storage-class specifier static,
784  // constitutes a tentative definition. If a translation unit
785  // contains one or more tentative definitions for an identifier,
786  // and the translation unit contains no external definition for
787  // that identifier, then the behavior is exactly as if the
788  // translation unit contains a file scope declaration of that
789  // identifier, with the composite type as of the end of the
790  // translation unit, with an initializer equal to 0.
791  llvm::SmallSet<VarDecl *, 32> Seen;
793  T = TentativeDefinitions.begin(ExternalSource),
794  TEnd = TentativeDefinitions.end();
795  T != TEnd; ++T)
796  {
797  VarDecl *VD = (*T)->getActingDefinition();
798 
799  // If the tentative definition was completed, getActingDefinition() returns
800  // null. If we've already seen this variable before, insert()'s second
801  // return value is false.
802  if (!VD || VD->isInvalidDecl() || !Seen.insert(VD).second)
803  continue;
804 
805  if (const IncompleteArrayType *ArrayT
807  // Set the length of the array to 1 (C99 6.9.2p5).
808  Diag(VD->getLocation(), diag::warn_tentative_incomplete_array);
809  llvm::APInt One(Context.getTypeSize(Context.getSizeType()), true);
810  QualType T = Context.getConstantArrayType(ArrayT->getElementType(),
811  One, ArrayType::Normal, 0);
812  VD->setType(T);
813  } else if (RequireCompleteType(VD->getLocation(), VD->getType(),
814  diag::err_tentative_def_incomplete_type))
815  VD->setInvalidDecl();
816 
818 
819  // Notify the consumer that we've completed a tentative definition.
820  if (!VD->isInvalidDecl())
822 
823  }
824 
825  // If there were errors, disable 'unused' warnings since they will mostly be
826  // noise.
827  if (!Diags.hasErrorOccurred()) {
828  // Output warning for unused file scoped decls.
830  I = UnusedFileScopedDecls.begin(ExternalSource),
831  E = UnusedFileScopedDecls.end(); I != E; ++I) {
832  if (ShouldRemoveFromUnused(this, *I))
833  continue;
834 
835  if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(*I)) {
836  const FunctionDecl *DiagD;
837  if (!FD->hasBody(DiagD))
838  DiagD = FD;
839  if (DiagD->isDeleted())
840  continue; // Deleted functions are supposed to be unused.
841  if (DiagD->isReferenced()) {
842  if (isa<CXXMethodDecl>(DiagD))
843  Diag(DiagD->getLocation(), diag::warn_unneeded_member_function)
844  << DiagD->getDeclName();
845  else {
846  if (FD->getStorageClass() == SC_Static &&
847  !FD->isInlineSpecified() &&
849  SourceMgr.getExpansionLoc(FD->getLocation())))
850  Diag(DiagD->getLocation(),
851  diag::warn_unneeded_static_internal_decl)
852  << DiagD->getDeclName();
853  else
854  Diag(DiagD->getLocation(), diag::warn_unneeded_internal_decl)
855  << /*function*/0 << DiagD->getDeclName();
856  }
857  } else {
858  Diag(DiagD->getLocation(),
859  isa<CXXMethodDecl>(DiagD) ? diag::warn_unused_member_function
860  : diag::warn_unused_function)
861  << DiagD->getDeclName();
862  }
863  } else {
864  const VarDecl *DiagD = cast<VarDecl>(*I)->getDefinition();
865  if (!DiagD)
866  DiagD = cast<VarDecl>(*I);
867  if (DiagD->isReferenced()) {
868  Diag(DiagD->getLocation(), diag::warn_unneeded_internal_decl)
869  << /*variable*/1 << DiagD->getDeclName();
870  } else if (DiagD->getType().isConstQualified()) {
871  Diag(DiagD->getLocation(), diag::warn_unused_const_variable)
872  << DiagD->getDeclName();
873  } else {
874  Diag(DiagD->getLocation(), diag::warn_unused_variable)
875  << DiagD->getDeclName();
876  }
877  }
878  }
879 
880  if (ExternalSource)
881  ExternalSource->ReadUndefinedButUsed(UndefinedButUsed);
882  checkUndefinedButUsed(*this);
883 
885  }
886 
887  if (!Diags.isIgnored(diag::warn_unused_private_field, SourceLocation())) {
888  RecordCompleteMap RecordsComplete;
889  RecordCompleteMap MNCComplete;
891  E = UnusedPrivateFields.end(); I != E; ++I) {
892  const NamedDecl *D = *I;
893  const CXXRecordDecl *RD = dyn_cast<CXXRecordDecl>(D->getDeclContext());
894  if (RD && !RD->isUnion() &&
895  IsRecordFullyDefined(RD, RecordsComplete, MNCComplete)) {
896  Diag(D->getLocation(), diag::warn_unused_private_field)
897  << D->getDeclName();
898  }
899  }
900  }
901 
902  if (!Diags.isIgnored(diag::warn_mismatched_delete_new, SourceLocation())) {
903  if (ExternalSource)
905  for (const auto &DeletedFieldInfo : DeleteExprs) {
906  for (const auto &DeleteExprLoc : DeletedFieldInfo.second) {
907  AnalyzeDeleteExprMismatch(DeletedFieldInfo.first, DeleteExprLoc.first,
908  DeleteExprLoc.second);
909  }
910  }
911  }
912 
913  // Check we've noticed that we're no longer parsing the initializer for every
914  // variable. If we miss cases, then at best we have a performance issue and
915  // at worst a rejects-valid bug.
916  assert(ParsingInitForAutoVars.empty() &&
917  "Didn't unmark var as having its initializer parsed");
918 
919  TUScope = nullptr;
920 }
921 
922 
923 //===----------------------------------------------------------------------===//
924 // Helper functions.
925 //===----------------------------------------------------------------------===//
926 
928  DeclContext *DC = CurContext;
929 
930  while (true) {
931  if (isa<BlockDecl>(DC) || isa<EnumDecl>(DC) || isa<CapturedDecl>(DC)) {
932  DC = DC->getParent();
933  } else if (isa<CXXMethodDecl>(DC) &&
934  cast<CXXMethodDecl>(DC)->getOverloadedOperator() == OO_Call &&
935  cast<CXXRecordDecl>(DC->getParent())->isLambda()) {
936  DC = DC->getParent()->getParent();
937  }
938  else break;
939  }
940 
941  return DC;
942 }
943 
944 /// getCurFunctionDecl - If inside of a function body, this returns a pointer
945 /// to the function decl for the function being parsed. If we're currently
946 /// in a 'block', this returns the containing context.
949  return dyn_cast<FunctionDecl>(DC);
950 }
951 
954  while (isa<RecordDecl>(DC))
955  DC = DC->getParent();
956  return dyn_cast<ObjCMethodDecl>(DC);
957 }
958 
961  if (isa<ObjCMethodDecl>(DC) || isa<FunctionDecl>(DC))
962  return cast<NamedDecl>(DC);
963  return nullptr;
964 }
965 
966 void Sema::EmitCurrentDiagnostic(unsigned DiagID) {
967  // FIXME: It doesn't make sense to me that DiagID is an incoming argument here
968  // and yet we also use the current diag ID on the DiagnosticsEngine. This has
969  // been made more painfully obvious by the refactor that introduced this
970  // function, but it is possible that the incoming argument can be
971  // eliminnated. If it truly cannot be (for example, there is some reentrancy
972  // issue I am not seeing yet), then there should at least be a clarifying
973  // comment somewhere.
976  Diags.getCurrentDiagID())) {
978  // We'll report the diagnostic below.
979  break;
980 
982  // Count this failure so that we know that template argument deduction
983  // has failed.
984  ++NumSFINAEErrors;
985 
986  // Make a copy of this suppressed diagnostic and store it with the
987  // template-deduction information.
988  if (*Info && !(*Info)->hasSFINAEDiagnostic()) {
989  Diagnostic DiagInfo(&Diags);
990  (*Info)->addSFINAEDiagnostic(DiagInfo.getLocation(),
992  }
993 
995  Diags.Clear();
996  return;
997 
999  // Per C++ Core Issue 1170, access control is part of SFINAE.
1000  // Additionally, the AccessCheckingSFINAE flag can be used to temporarily
1001  // make access control a part of SFINAE for the purposes of checking
1002  // type traits.
1004  break;
1005 
1007 
1008  // Suppress this diagnostic.
1009  ++NumSFINAEErrors;
1010 
1011  // Make a copy of this suppressed diagnostic and store it with the
1012  // template-deduction information.
1013  if (*Info && !(*Info)->hasSFINAEDiagnostic()) {
1014  Diagnostic DiagInfo(&Diags);
1015  (*Info)->addSFINAEDiagnostic(DiagInfo.getLocation(),
1017  }
1018 
1020  Diags.Clear();
1021 
1022  // Now the diagnostic state is clear, produce a C++98 compatibility
1023  // warning.
1024  Diag(Loc, diag::warn_cxx98_compat_sfinae_access_control);
1025 
1026  // The last diagnostic which Sema produced was ignored. Suppress any
1027  // notes attached to it.
1029  return;
1030  }
1031 
1033  // Make a copy of this suppressed diagnostic and store it with the
1034  // template-deduction information;
1035  if (*Info) {
1036  Diagnostic DiagInfo(&Diags);
1037  (*Info)->addSuppressedDiagnostic(DiagInfo.getLocation(),
1039  }
1040 
1041  // Suppress this diagnostic.
1043  Diags.Clear();
1044  return;
1045  }
1046  }
1047 
1048  // Set up the context's printing policy based on our current state.
1050 
1051  // Emit the diagnostic.
1053  return;
1054 
1055  // If this is not a note, and we're in a template instantiation
1056  // that is different from the last template instantiation where
1057  // we emitted an error, print a template instantiation
1058  // backtrace.
1059  if (!DiagnosticIDs::isBuiltinNote(DiagID) &&
1060  !ActiveTemplateInstantiations.empty() &&
1065  }
1066 }
1067 
1071  PD.Emit(Builder);
1072 
1073  return Builder;
1074 }
1075 
1076 /// \brief Looks through the macro-expansion chain for the given
1077 /// location, looking for a macro expansion with the given name.
1078 /// If one is found, returns true and sets the location to that
1079 /// expansion loc.
1080 bool Sema::findMacroSpelling(SourceLocation &locref, StringRef name) {
1081  SourceLocation loc = locref;
1082  if (!loc.isMacroID()) return false;
1083 
1084  // There's no good way right now to look at the intermediate
1085  // expansions, so just jump to the expansion location.
1086  loc = getSourceManager().getExpansionLoc(loc);
1087 
1088  // If that's written with the name, stop here.
1089  SmallVector<char, 16> buffer;
1090  if (getPreprocessor().getSpelling(loc, buffer) == name) {
1091  locref = loc;
1092  return true;
1093  }
1094  return false;
1095 }
1096 
1097 /// \brief Determines the active Scope associated with the given declaration
1098 /// context.
1099 ///
1100 /// This routine maps a declaration context to the active Scope object that
1101 /// represents that declaration context in the parser. It is typically used
1102 /// from "scope-less" code (e.g., template instantiation, lazy creation of
1103 /// declarations) that injects a name for name-lookup purposes and, therefore,
1104 /// must update the Scope.
1105 ///
1106 /// \returns The scope corresponding to the given declaraion context, or NULL
1107 /// if no such scope is open.
1109 
1110  if (!Ctx)
1111  return nullptr;
1112 
1113  Ctx = Ctx->getPrimaryContext();
1114  for (Scope *S = getCurScope(); S; S = S->getParent()) {
1115  // Ignore scopes that cannot have declarations. This is important for
1116  // out-of-line definitions of static class members.
1117  if (S->getFlags() & (Scope::DeclScope | Scope::TemplateParamScope))
1118  if (DeclContext *Entity = S->getEntity())
1119  if (Ctx == Entity->getPrimaryContext())
1120  return S;
1121  }
1122 
1123  return nullptr;
1124 }
1125 
1126 /// \brief Enter a new function scope
1128  if (FunctionScopes.size() == 1) {
1129  // Use the "top" function scope rather than having to allocate
1130  // memory for a new scope.
1131  FunctionScopes.back()->Clear();
1132  FunctionScopes.push_back(FunctionScopes.back());
1133  return;
1134  }
1135 
1137 }
1138 
1139 void Sema::PushBlockScope(Scope *BlockScope, BlockDecl *Block) {
1141  BlockScope, Block));
1142 }
1143 
1145  LambdaScopeInfo *const LSI = new LambdaScopeInfo(getDiagnostics());
1146  FunctionScopes.push_back(LSI);
1147  return LSI;
1148 }
1149 
1151  if (LambdaScopeInfo *const LSI = getCurLambda()) {
1152  LSI->AutoTemplateParameterDepth = Depth;
1153  return;
1154  }
1155  llvm_unreachable(
1156  "Remove assertion if intentionally called in a non-lambda context.");
1157 }
1158 
1160  const Decl *D, const BlockExpr *blkExpr) {
1161  FunctionScopeInfo *Scope = FunctionScopes.pop_back_val();
1162  assert(!FunctionScopes.empty() && "mismatched push/pop!");
1163 
1164  // Issue any analysis-based warnings.
1165  if (WP && D)
1166  AnalysisWarnings.IssueWarnings(*WP, Scope, D, blkExpr);
1167  else
1168  for (const auto &PUD : Scope->PossiblyUnreachableDiags)
1169  Diag(PUD.Loc, PUD.PD);
1170 
1171  if (FunctionScopes.back() != Scope)
1172  delete Scope;
1173 }
1174 
1177 }
1178 
1180  FunctionScopeInfo *CurFunction = getCurFunction();
1181  assert(!CurFunction->CompoundScopes.empty() && "mismatched push/pop");
1182 
1183  CurFunction->CompoundScopes.pop_back();
1184 }
1185 
1186 /// \brief Determine whether any errors occurred within this function/method/
1187 /// block.
1190 }
1191 
1193  if (FunctionScopes.empty())
1194  return nullptr;
1195 
1196  auto CurBSI = dyn_cast<BlockScopeInfo>(FunctionScopes.back());
1197  if (CurBSI && CurBSI->TheDecl &&
1198  !CurBSI->TheDecl->Encloses(CurContext)) {
1199  // We have switched contexts due to template instantiation.
1200  assert(!ActiveTemplateInstantiations.empty());
1201  return nullptr;
1202  }
1203 
1204  return CurBSI;
1205 }
1206 
1208  if (FunctionScopes.empty())
1209  return nullptr;
1210 
1211  auto CurLSI = dyn_cast<LambdaScopeInfo>(FunctionScopes.back());
1212  if (CurLSI && CurLSI->Lambda &&
1213  !CurLSI->Lambda->Encloses(CurContext)) {
1214  // We have switched contexts due to template instantiation.
1215  assert(!ActiveTemplateInstantiations.empty());
1216  return nullptr;
1217  }
1218 
1219  return CurLSI;
1220 }
1221 // We have a generic lambda if we parsed auto parameters, or we have
1222 // an associated template parameter list.
1224  if (LambdaScopeInfo *LSI = getCurLambda()) {
1225  return (LSI->AutoTemplateParams.size() ||
1226  LSI->GLTemplateParameterList) ? LSI : nullptr;
1227  }
1228  return nullptr;
1229 }
1230 
1231 
1233  if (!LangOpts.RetainCommentsFromSystemHeaders &&
1234  SourceMgr.isInSystemHeader(Comment.getBegin()))
1235  return;
1236  RawComment RC(SourceMgr, Comment, false,
1238  if (RC.isAlmostTrailingComment()) {
1239  SourceRange MagicMarkerRange(Comment.getBegin(),
1240  Comment.getBegin().getLocWithOffset(3));
1241  StringRef MagicMarkerText;
1242  switch (RC.getKind()) {
1244  MagicMarkerText = "///<";
1245  break;
1247  MagicMarkerText = "/**<";
1248  break;
1249  default:
1250  llvm_unreachable("if this is an almost Doxygen comment, "
1251  "it should be ordinary");
1252  }
1253  Diag(Comment.getBegin(), diag::warn_not_a_doxygen_trailing_member_comment) <<
1254  FixItHint::CreateReplacement(MagicMarkerRange, MagicMarkerText);
1255  }
1256  Context.addComment(RC);
1257 }
1258 
1259 // Pin this vtable to this file.
1261 
1263 
1265  SmallVectorImpl<NamespaceDecl *> &Namespaces) {
1266 }
1267 
1269  llvm::DenseMap<NamedDecl *, SourceLocation> &Undefined) {
1270 }
1271 
1273  FieldDecl *, llvm::SmallVector<std::pair<SourceLocation, bool>, 4>> &) {}
1274 
1275 void PrettyDeclStackTraceEntry::print(raw_ostream &OS) const {
1276  SourceLocation Loc = this->Loc;
1277  if (!Loc.isValid() && TheDecl) Loc = TheDecl->getLocation();
1278  if (Loc.isValid()) {
1279  Loc.print(OS, S.getSourceManager());
1280  OS << ": ";
1281  }
1282  OS << Message;
1283 
1284  if (TheDecl && isa<NamedDecl>(TheDecl)) {
1285  std::string Name = cast<NamedDecl>(TheDecl)->getNameAsString();
1286  if (!Name.empty())
1287  OS << " '" << Name << '\'';
1288  }
1289 
1290  OS << '\n';
1291 }
1292 
1293 /// \brief Figure out if an expression could be turned into a call.
1294 ///
1295 /// Use this when trying to recover from an error where the programmer may have
1296 /// written just the name of a function instead of actually calling it.
1297 ///
1298 /// \param E - The expression to examine.
1299 /// \param ZeroArgCallReturnTy - If the expression can be turned into a call
1300 /// with no arguments, this parameter is set to the type returned by such a
1301 /// call; otherwise, it is set to an empty QualType.
1302 /// \param OverloadSet - If the expression is an overloaded function
1303 /// name, this parameter is populated with the decls of the various overloads.
1304 bool Sema::tryExprAsCall(Expr &E, QualType &ZeroArgCallReturnTy,
1305  UnresolvedSetImpl &OverloadSet) {
1306  ZeroArgCallReturnTy = QualType();
1307  OverloadSet.clear();
1308 
1309  const OverloadExpr *Overloads = nullptr;
1310  bool IsMemExpr = false;
1311  if (E.getType() == Context.OverloadTy) {
1312  OverloadExpr::FindResult FR = OverloadExpr::find(const_cast<Expr*>(&E));
1313 
1314  // Ignore overloads that are pointer-to-member constants.
1315  if (FR.HasFormOfMemberPointer)
1316  return false;
1317 
1318  Overloads = FR.Expression;
1319  } else if (E.getType() == Context.BoundMemberTy) {
1320  Overloads = dyn_cast<UnresolvedMemberExpr>(E.IgnoreParens());
1321  IsMemExpr = true;
1322  }
1323 
1324  bool Ambiguous = false;
1325 
1326  if (Overloads) {
1327  for (OverloadExpr::decls_iterator it = Overloads->decls_begin(),
1328  DeclsEnd = Overloads->decls_end(); it != DeclsEnd; ++it) {
1329  OverloadSet.addDecl(*it);
1330 
1331  // Check whether the function is a non-template, non-member which takes no
1332  // arguments.
1333  if (IsMemExpr)
1334  continue;
1335  if (const FunctionDecl *OverloadDecl
1336  = dyn_cast<FunctionDecl>((*it)->getUnderlyingDecl())) {
1337  if (OverloadDecl->getMinRequiredArguments() == 0) {
1338  if (!ZeroArgCallReturnTy.isNull() && !Ambiguous) {
1339  ZeroArgCallReturnTy = QualType();
1340  Ambiguous = true;
1341  } else
1342  ZeroArgCallReturnTy = OverloadDecl->getReturnType();
1343  }
1344  }
1345  }
1346 
1347  // If it's not a member, use better machinery to try to resolve the call
1348  if (!IsMemExpr)
1349  return !ZeroArgCallReturnTy.isNull();
1350  }
1351 
1352  // Attempt to call the member with no arguments - this will correctly handle
1353  // member templates with defaults/deduction of template arguments, overloads
1354  // with default arguments, etc.
1355  if (IsMemExpr && !E.isTypeDependent()) {
1356  bool Suppress = getDiagnostics().getSuppressAllDiagnostics();
1359  None, SourceLocation());
1361  if (R.isUsable()) {
1362  ZeroArgCallReturnTy = R.get()->getType();
1363  return true;
1364  }
1365  return false;
1366  }
1367 
1368  if (const DeclRefExpr *DeclRef = dyn_cast<DeclRefExpr>(E.IgnoreParens())) {
1369  if (const FunctionDecl *Fun = dyn_cast<FunctionDecl>(DeclRef->getDecl())) {
1370  if (Fun->getMinRequiredArguments() == 0)
1371  ZeroArgCallReturnTy = Fun->getReturnType();
1372  return true;
1373  }
1374  }
1375 
1376  // We don't have an expression that's convenient to get a FunctionDecl from,
1377  // but we can at least check if the type is "function of 0 arguments".
1378  QualType ExprTy = E.getType();
1379  const FunctionType *FunTy = nullptr;
1380  QualType PointeeTy = ExprTy->getPointeeType();
1381  if (!PointeeTy.isNull())
1382  FunTy = PointeeTy->getAs<FunctionType>();
1383  if (!FunTy)
1384  FunTy = ExprTy->getAs<FunctionType>();
1385 
1386  if (const FunctionProtoType *FPT =
1387  dyn_cast_or_null<FunctionProtoType>(FunTy)) {
1388  if (FPT->getNumParams() == 0)
1389  ZeroArgCallReturnTy = FunTy->getReturnType();
1390  return true;
1391  }
1392  return false;
1393 }
1394 
1395 /// \brief Give notes for a set of overloads.
1396 ///
1397 /// A companion to tryExprAsCall. In cases when the name that the programmer
1398 /// wrote was an overloaded function, we may be able to make some guesses about
1399 /// plausible overloads based on their return types; such guesses can be handed
1400 /// off to this method to be emitted as notes.
1401 ///
1402 /// \param Overloads - The overloads to note.
1403 /// \param FinalNoteLoc - If we've suppressed printing some overloads due to
1404 /// -fshow-overloads=best, this is the location to attach to the note about too
1405 /// many candidates. Typically this will be the location of the original
1406 /// ill-formed expression.
1407 static void noteOverloads(Sema &S, const UnresolvedSetImpl &Overloads,
1408  const SourceLocation FinalNoteLoc) {
1409  int ShownOverloads = 0;
1410  int SuppressedOverloads = 0;
1411  for (UnresolvedSetImpl::iterator It = Overloads.begin(),
1412  DeclsEnd = Overloads.end(); It != DeclsEnd; ++It) {
1413  // FIXME: Magic number for max shown overloads stolen from
1414  // OverloadCandidateSet::NoteCandidates.
1415  if (ShownOverloads >= 4 && S.Diags.getShowOverloads() == Ovl_Best) {
1416  ++SuppressedOverloads;
1417  continue;
1418  }
1419 
1420  NamedDecl *Fn = (*It)->getUnderlyingDecl();
1421  S.Diag(Fn->getLocation(), diag::note_possible_target_of_call);
1422  ++ShownOverloads;
1423  }
1424 
1425  if (SuppressedOverloads)
1426  S.Diag(FinalNoteLoc, diag::note_ovl_too_many_candidates)
1427  << SuppressedOverloads;
1428 }
1429 
1431  const UnresolvedSetImpl &Overloads,
1432  bool (*IsPlausibleResult)(QualType)) {
1433  if (!IsPlausibleResult)
1434  return noteOverloads(S, Overloads, Loc);
1435 
1436  UnresolvedSet<2> PlausibleOverloads;
1437  for (OverloadExpr::decls_iterator It = Overloads.begin(),
1438  DeclsEnd = Overloads.end(); It != DeclsEnd; ++It) {
1439  const FunctionDecl *OverloadDecl = cast<FunctionDecl>(*It);
1440  QualType OverloadResultTy = OverloadDecl->getReturnType();
1441  if (IsPlausibleResult(OverloadResultTy))
1442  PlausibleOverloads.addDecl(It.getDecl());
1443  }
1444  noteOverloads(S, PlausibleOverloads, Loc);
1445 }
1446 
1447 /// Determine whether the given expression can be called by just
1448 /// putting parentheses after it. Notably, expressions with unary
1449 /// operators can't be because the unary operator will start parsing
1450 /// outside the call.
1451 static bool IsCallableWithAppend(Expr *E) {
1452  E = E->IgnoreImplicit();
1453  return (!isa<CStyleCastExpr>(E) &&
1454  !isa<UnaryOperator>(E) &&
1455  !isa<BinaryOperator>(E) &&
1456  !isa<CXXOperatorCallExpr>(E));
1457 }
1458 
1460  bool ForceComplain,
1461  bool (*IsPlausibleResult)(QualType)) {
1462  SourceLocation Loc = E.get()->getExprLoc();
1463  SourceRange Range = E.get()->getSourceRange();
1464 
1465  QualType ZeroArgCallTy;
1466  UnresolvedSet<4> Overloads;
1467  if (tryExprAsCall(*E.get(), ZeroArgCallTy, Overloads) &&
1468  !ZeroArgCallTy.isNull() &&
1469  (!IsPlausibleResult || IsPlausibleResult(ZeroArgCallTy))) {
1470  // At this point, we know E is potentially callable with 0
1471  // arguments and that it returns something of a reasonable type,
1472  // so we can emit a fixit and carry on pretending that E was
1473  // actually a CallExpr.
1474  SourceLocation ParenInsertionLoc = getLocForEndOfToken(Range.getEnd());
1475  Diag(Loc, PD)
1476  << /*zero-arg*/ 1 << Range
1477  << (IsCallableWithAppend(E.get())
1478  ? FixItHint::CreateInsertion(ParenInsertionLoc, "()")
1479  : FixItHint());
1480  notePlausibleOverloads(*this, Loc, Overloads, IsPlausibleResult);
1481 
1482  // FIXME: Try this before emitting the fixit, and suppress diagnostics
1483  // while doing so.
1484  E = ActOnCallExpr(nullptr, E.get(), Range.getEnd(), None,
1485  Range.getEnd().getLocWithOffset(1));
1486  return true;
1487  }
1488 
1489  if (!ForceComplain) return false;
1490 
1491  Diag(Loc, PD) << /*not zero-arg*/ 0 << Range;
1492  notePlausibleOverloads(*this, Loc, Overloads, IsPlausibleResult);
1493  E = ExprError();
1494  return true;
1495 }
1496 
1498  if (!Ident_super)
1499  Ident_super = &Context.Idents.get("super");
1500  return Ident_super;
1501 }
1502 
1504  if (!Ident___float128)
1505  Ident___float128 = &Context.Idents.get("__float128");
1506  return Ident___float128;
1507 }
1508 
1510  CapturedRegionKind K) {
1512  getDiagnostics(), S, CD, RD, CD->getContextParam(), K);
1513  CSI->ReturnType = Context.VoidTy;
1514  FunctionScopes.push_back(CSI);
1515 }
1516 
1518  if (FunctionScopes.empty())
1519  return nullptr;
1520 
1521  return dyn_cast<CapturedRegionScopeInfo>(FunctionScopes.back());
1522 }
1523 
1524 const llvm::MapVector<FieldDecl *, Sema::DeleteLocs> &
1526  return DeleteExprs;
1527 }
void FreePackedContext()
FreePackedContext - Deallocate and null out PackContext.
Definition: SemaAttr.cpp:110
Defines the clang::ASTContext interface.
SourceLocation getEnd() const
UnusedFileScopedDeclsType UnusedFileScopedDecls
The set of file scoped decls seen so far that have not been used and must warn if not used...
Definition: Sema.h:493
FunctionDecl - An instance of this class is created to represent a function declaration or definition...
Definition: Decl.h:1483
CK_LValueToRValue - A conversion which causes the extraction of an r-value from the operand gl-value...
llvm::SmallSetVector< const TypedefNameDecl *, 4 > UnusedLocalTypedefNameCandidates
Set containing all typedefs that are likely unused.
Definition: Sema.h:455
Scope * getCurScope() const
Retrieve the parser's current scope.
Definition: Sema.h:9197
IdentifierInfo * getSuperIdentifier() const
Definition: Sema.cpp:1497
CanQualType OCLQueueTy
Definition: ASTContext.h:907
Smart pointer class that efficiently represents Objective-C method names.
A (possibly-)qualified type.
Definition: Type.h:575
ASTConsumer & Consumer
Definition: Sema.h:296
bool ShouldWarnIfUnusedFileScopedDecl(const DeclaratorDecl *D) const
Definition: SemaDecl.cpp:1378
TypedefDecl * getUInt128Decl() const
Retrieve the declaration for the 128-bit unsigned integer type.
Definition: ASTContext.cpp:963
bool isMacroID() const
CanQualType OCLImage1dBufferTy
Definition: ASTContext.h:901
void Initialize()
Perform initialization that occurs after the parser has been initialized but before it parses anythin...
Definition: Sema.cpp:139
ASTConsumer - This is an abstract interface that should be implemented by clients that read ASTs...
Definition: ASTConsumer.h:36
LateParsedTemplateMapT LateParsedTemplateMap
Definition: Sema.h:521
DeclContext * getFunctionLevelDeclContext()
Definition: Sema.cpp:927
static const CastKind CK_Invalid
Defines the clang::FileManager interface and associated types.
RecordDecl * buildImplicitRecord(StringRef Name, RecordDecl::TagKind TK=TTK_Struct) const
Create a new implicit TU-level CXXRecordDecl or RecordDecl declaration.
Definition: ASTContext.cpp:931
Ordinary name lookup, which finds ordinary names (functions, variables, typedefs, etc...
Definition: Sema.h:2636
A class which encapsulates the logic for delaying diagnostics during parsing and other processing...
Definition: Sema.h:549
const LangOptions & getLangOpts() const
Definition: Sema.h:1041
void getUndefinedButUsed(SmallVectorImpl< std::pair< NamedDecl *, SourceLocation > > &Undefined)
Obtain a sorted list of functions that are undefined but ODR-used.
Definition: Sema.cpp:474
submodule_iterator submodule_begin()
Definition: Basic/Module.h:474
CanQualType OCLImage2dMSAADepthTy
Definition: ASTContext.h:904
FunctionType - C99 6.7.5.3 - Function Declarators.
Definition: Type.h:2847
CXXFieldCollector - Used to keep track of CXXFieldDecls during parsing of C++ classes.
CanQualType getSizeType() const
Return the unique type for "size_t" (C99 7.17), defined in <stddef.h>.
QualType ReturnType
ReturnType - The target type of return statements in this context, or null if unknown.
Definition: ScopeInfo.h:511
IdentifierInfo * getIdentifierInfo(StringRef Name) const
Return information about the specified preprocessor identifier token.
Definition: Preprocessor.h:927
The current expression is potentially evaluated at run time, which means that code may be generated t...
Definition: Sema.h:781
static void notePlausibleOverloads(Sema &S, SourceLocation Loc, const UnresolvedSetImpl &Overloads, bool(*IsPlausibleResult)(QualType))
Definition: Sema.cpp:1430
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID)
Emit a diagnostic.
Definition: Sema.h:1118
Decl - This represents one declaration (or definition), e.g.
Definition: DeclBase.h:77
Module * getCurrentModule()
Retrieves the module that we're currently building, if any.
ExprResult BuildCallToMemberFunction(Scope *S, Expr *MemExpr, SourceLocation LParenLoc, MultiExprArg Args, SourceLocation RParenLoc)
BuildCallToMemberFunction - Build a call to a member function.
VarDecl * getDefinition(ASTContext &)
Get the real (not just tentative) definition for this declaration.
Definition: Decl.cpp:2002
std::deque< PendingImplicitInstantiation > PendingInstantiations
The queue of implicit template instantiations that are required but have not yet been performed...
Definition: Sema.h:6906
Scope * TUScope
Translation Unit Scope - useful to Objective-C actions that need to lookup file scope declarations in...
Definition: Sema.h:680
The translation unit is a prefix to a translation unit, and is not complete.
Definition: LangOptions.h:183
bool hasErrorOccurred() const
Definition: Diagnostic.h:573
PtrTy get() const
Definition: Ownership.h:163
virtual void ReadMethodPool(Selector Sel)
Load the contents of the global method pool for a given selector.
Definition: Sema.cpp:1262
CanQualType LongTy
Definition: ASTContext.h:889
const IncompleteArrayType * getAsIncompleteArrayType(QualType T) const
Definition: ASTContext.h:2100
Any normal BCPL comments.
SourceLocation getLocForEndOfToken(SourceLocation Loc, unsigned Offset=0)
Calls Lexer::getLocForEndOfToken()
Definition: Sema.cpp:46
A container of type source information.
Definition: Decl.h:61
IdentifierInfo * getFloat128Identifier() const
Definition: Sema.cpp:1503
The diagnostic should not be reported, but it should cause template argument deduction to fail...
void LoadExternalWeakUndeclaredIdentifiers()
Load weak undeclared identifiers from the external source.
Definition: Sema.cpp:554
bool resolveUses(Module *Mod, bool Complain)
Resolve all of the unresolved uses in the given module.
Definition: ModuleMap.cpp:891
Retains information about a function, method, or block that is currently being parsed.
Definition: ScopeInfo.h:80
ModuleLoader & getModuleLoader() const
Retrieve the module loader associated with the preprocessor.
Definition: Sema.cpp:50
VarDecl - An instance of this class is created to represent a variable declaration or definition...
Definition: Decl.h:699
TypedefDecl * getBuiltinVaListDecl() const
Retrieve the C type declaration corresponding to the predefined __builtin_va_list type...
DiagnosticsEngine & Diags
Definition: Sema.h:297
virtual void ReadWeakUndeclaredIdentifiers(SmallVectorImpl< std::pair< IdentifierInfo *, WeakInfo > > &WI)
Read the set of weak, undeclared identifiers known to the external Sema source.
uint64_t getTypeSize(QualType T) const
Return the size of the specified (complete) type T, in bits.
Definition: ASTContext.h:1793
ObjCMethodDecl - Represents an instance or class method declaration.
Definition: DeclObjC.h:113
NamedDecl * getUnderlyingDecl()
Looks through UsingDecls and ObjCCompatibleAliasDecls for the underlying named decl.
Definition: Decl.h:319
SmallVector< CXXRecordDecl *, 4 > DelayedDllExportClasses
Definition: Sema.h:9234
Expr * IgnoreImplicit() LLVM_READONLY
IgnoreImplicit - Skip past any implicit AST nodes which might surround this expression.
Definition: Expr.h:716
ModuleMap & getModuleMap()
Retrieve the module map.
Definition: HeaderSearch.h:591
Describes how types, statements, expressions, and declarations should be printed. ...
Definition: PrettyPrinter.h:35
decl_iterator decls_end() const
Definition: DeclBase.h:1441
Defines the clang::Expr interface and subclasses for C++ expressions.
iterator begin(Source *source, bool LocalOnly=false)
iterator begin(DeclarationName Name)
begin - Returns an iterator for decls with the name 'Name'.
ExprResult ActOnCallExpr(Scope *S, Expr *Fn, SourceLocation LParenLoc, MultiExprArg ArgExprs, SourceLocation RParenLoc, Expr *ExecConfig=nullptr, bool IsExecConfig=false)
ActOnCallExpr - Handle a call to Fn with the specified array of arguments.
Definition: SemaExpr.cpp:5002
void threadSafetyCleanup(BeforeSet *Cache)
CanQualType OCLSamplerTy
Definition: ASTContext.h:906
void CheckDelayedMemberExceptionSpecs()
RecordDecl - Represents a struct/union/class.
Definition: Decl.h:3166
ActiveTemplateInstantiation LastTemplateInstantiationErrorContext
The last template from which a template instantiation error or warning was produced.
Definition: Sema.h:6636
void FreeVisContext()
FreeVisContext - Deallocate and null out VisContext.
Definition: SemaAttr.cpp:536
ObjCInterfaceDecl * getObjCProtocolDecl() const
Retrieve the Objective-C class declaration corresponding to the predefined Protocol class...
An iterator over the friend declarations of a class.
Definition: DeclFriend.h:173
void PrintInstantiationStack()
Prints the current instantiation stack through a series of notes.
One of these records is kept for each identifier that is lexed.
std::unique_ptr< NSAPI > NSAPIObj
Caches identifiers/selectors for NSFoundation APIs.
Definition: Sema.h:700
virtual void ReadUnusedLocalTypedefNameCandidates(llvm::SmallSetVector< const TypedefNameDecl *, 4 > &Decls)
Read the set of potentially unused typedefs known to the source.
bool hasAnyUnrecoverableErrorsInThisFunction() const
Determine whether any errors occurred within this function/method/ block.
Definition: Sema.cpp:1188
sema::DelayedDiagnosticPool * getCurrentPool() const
Returns the current delayed-diagnostics pool.
Definition: Sema.h:564
class LLVM_ALIGNAS(8) DependentTemplateSpecializationType const IdentifierInfo * Name
Represents a template specialization type whose template cannot be resolved, e.g. ...
Definition: Type.h:4381
CanQualType OCLImage2dArrayMSAADepthTy
Definition: ASTContext.h:904
bool hasAttr() const
Definition: DeclBase.h:498
bool resolveConflicts(Module *Mod, bool Complain)
Resolve all of the unresolved conflicts in the given module.
Definition: ModuleMap.cpp:904
sema::LambdaScopeInfo * getCurGenericLambda()
Retrieve the current generic lambda info, if any.
Definition: Sema.cpp:1223
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition: ASTContext.h:91
CanQualType OCLImage2dArrayTy
Definition: ASTContext.h:902
sema::BlockScopeInfo * getCurBlock()
Retrieve the current block, if any.
Definition: Sema.cpp:1192
QualType getReturnType() const
Definition: Decl.h:1956
FieldDecl - An instance of this class is created by Sema::ActOnField to represent a member of a struc...
Definition: Decl.h:2209
void erase(iterator From, iterator To)
bool isCompleteDefinition() const
isCompleteDefinition - Return true if this decl has its body fully specified.
Definition: Decl.h:2788
threadSafety::BeforeSet * ThreadSafetyDeclCache
Definition: Sema.h:6892
bool isReferenced() const
Whether any declaration of this entity was referenced.
Definition: DeclBase.cpp:353
void ActOnEndOfTranslationUnit()
ActOnEndOfTranslationUnit - This is called at the very end of the translation unit when EOF is reache...
Definition: Sema.cpp:660
const MacroInfo * getMacroInfo(const IdentifierInfo *II) const
Definition: Preprocessor.h:851
CanQualType OCLEventTy
Definition: ASTContext.h:906
The iterator over UnresolvedSets.
Definition: UnresolvedSet.h:28
Represents a C++ member access expression for which lookup produced a set of overloaded functions...
Definition: ExprCXX.h:3268
void setPrintingPolicy(const clang::PrintingPolicy &Policy)
Definition: ASTContext.h:549
bool DefineUsedVTables()
Define all of the vtables that have been used in this translation unit and reference any virtual memb...
CanQualType OCLReserveIDTy
Definition: ASTContext.h:907
Describes a module or submodule.
Definition: Basic/Module.h:47
llvm::BumpPtrAllocator BumpAlloc
Definition: Sema.h:919
IdentifierTable & Idents
Definition: ASTContext.h:451
static void noteOverloads(Sema &S, const UnresolvedSetImpl &Overloads, const SourceLocation FinalNoteLoc)
Give notes for a set of overloads.
Definition: Sema.cpp:1407
bool AccessCheckingSFINAE
When true, access checking violations are treated as SFINAE failures rather than hard errors...
Definition: Sema.h:5495
An r-value expression (a pr-value in the C++11 taxonomy) produces a temporary value.
Definition: Specifiers.h:102
Values of this type can be null.
iterator end()
end - Returns an iterator that has 'finished'.
DiagnosticErrorTrap ErrorTrap
Used to determine if errors occurred in this function or block.
Definition: ScopeInfo.h:137
An abstract interface that should be implemented by clients that read ASTs and then require further s...
Definition: SemaConsumer.h:26
Converts a floating point complex to bool by comparing against 0+0i.
VarDecl * getActingDefinition()
Get the tentative definition that acts as the real definition in a TU.
Definition: Decl.cpp:1985
CK_IntegralToBoolean - Integral to boolean.
static bool MethodsAndNestedClassesComplete(const CXXRecordDecl *RD, RecordCompleteMap &MNCComplete)
Returns true, if all methods and nested classes of the given CXXRecordDecl are defined in this transl...
Definition: Sema.cpp:572
friend_iterator friend_end() const
Definition: DeclFriend.h:227
bool hasUnrecoverableErrorOccurred() const
Determine whether any unrecoverable errors have occurred since this object instance was created...
Definition: Diagnostic.h:839
bool findMacroSpelling(SourceLocation &loc, StringRef name)
Looks through the macro-expansion chain for the given location, looking for a macro expansion with th...
Definition: Sema.cpp:1080
const TargetInfo & getTargetInfo() const
Definition: ASTContext.h:580
SourceLocation getLocWithOffset(int Offset) const
Return a source location with the specified offset from this SourceLocation.
CanQualType OCLImage2dTy
Definition: ASTContext.h:902
const LangOptions & getLangOpts() const
Definition: ASTContext.h:596
ObjCMethodDecl * getCurMethodDecl()
getCurMethodDecl - If inside of a method body, this returns a pointer to the method decl for the meth...
Definition: Sema.cpp:952
const SourceLocation & getLocation() const
Definition: Diagnostic.h:1147
unsigned getDiagID() const
uint32_t Offset
Definition: CacheTokens.cpp:44
QualType getReturnType() const
Definition: Type.h:2977
std::pair< SourceLocation, bool > DeleteExprLoc
Delete-expressions to be analyzed at the end of translation unit.
Definition: Sema.h:462
HeaderSearch & getHeaderSearchInfo() const
Definition: Preprocessor.h:688
void PerformPendingInstantiations(bool LocalOnly=false)
Performs template instantiation for all implicit template instantiations we have seen until this poin...
A set of unresolved declarations.
Definition: UnresolvedSet.h:55
void IssueWarnings(Policy P, FunctionScopeInfo *fscope, const Decl *D, const BlockExpr *blkExpr)
QualType getIntPtrType() const
Return a type compatible with "intptr_t" (C99 7.18.1.4), as defined by the target.
void CheckDelegatingCtorCycles()
TypedefDecl * getObjCIdDecl() const
Retrieve the typedef corresponding to the predefined id type in Objective-C.
CheckedConversionKind
The kind of conversion being performed.
Definition: Sema.h:8197
~ExternalSemaSource() override
Definition: Sema.cpp:1260
Values of this type can never be null.
void addExternalSource(ExternalSemaSource *E)
Registers an external source.
Definition: Sema.cpp:327
Scope - A scope is a transient data structure that is used while parsing the program.
Definition: Scope.h:38
static const unsigned NumNSNumberLiteralMethods
Definition: NSAPI.h:187
submodule_iterator submodule_end()
Definition: Basic/Module.h:476
void emitAndClearUnusedLocalTypedefWarnings()
Definition: Sema.cpp:644
virtual ASTMutationListener * GetASTMutationListener()
If the consumer is interested in entities getting modified after their initial creation, it should return a pointer to an ASTMutationListener here.
Definition: ASTConsumer.h:137
void CheckCompleteVariableDeclaration(VarDecl *var)
Definition: SemaDecl.cpp:9957
Preprocessor & PP
Definition: Sema.h:294
sema::AnalysisBasedWarnings AnalysisWarnings
Worker object for performing CFG-based warnings.
Definition: Sema.h:6891
This represents the body of a CapturedStmt, and serves as its DeclContext.
Definition: Decl.h:3560
decl_iterator decls_begin() const
Definition: DeclBase.cpp:1167
detail::InMemoryDirectory::const_iterator I
void PushCompoundScope()
Definition: Sema.cpp:1175
CanQualType OCLImage3dTy
Definition: ASTContext.h:905
TypedefDecl * getObjCClassDecl() const
Retrieve the typedef declaration corresponding to the predefined Objective-C 'Class' type...
QualType getType() const
Definition: Decl.h:530
const LangOptions & LangOpts
Definition: Sema.h:293
Contains information about the compound statement currently being parsed.
Definition: ScopeInfo.h:53
bool EmitCurrentDiagnostic(bool Force=false)
Emit the current diagnostic and clear the diagnostic state.
Definition: Diagnostic.cpp:362
void Emit(const DiagnosticBuilder &DB) const
static bool IsCallableWithAppend(Expr *E)
Determine whether the given expression can be called by just putting parentheses after it...
Definition: Sema.cpp:1451
bool isUnion() const
Definition: Decl.h:2856
void setLastDiagnosticIgnored()
Pretend that the last diagnostic issued was ignored, so any subsequent notes will be suppressed...
Definition: Diagnostic.h:498
Sema - This implements semantic analysis and AST building for C.
Definition: Sema.h:259
Represents a prototype with parameter type info, e.g.
Definition: Type.h:3041
TentativeDefinitionsType TentativeDefinitions
All the tentative definitions encountered in the TU.
Definition: Sema.h:485
const llvm::MapVector< FieldDecl *, DeleteLocs > & getMismatchingDeleteExpressions() const
Retrieves list of suspicious delete-expressions that will be checked at the end of translation unit...
Definition: Sema.cpp:1525
Retains information about a captured region.
Definition: ScopeInfo.h:596
unsigned getCurrentDiagID() const
Definition: Diagnostic.h:809
Represents a ValueDecl that came out of a declarator.
Definition: Decl.h:577
CastKind
CastKind - The kind of operation required for a conversion.
static ImplicitCastExpr * Create(const ASTContext &Context, QualType T, CastKind Kind, Expr *Operand, const CXXCastPath *BasePath, ExprValueKind Cat)
Definition: Expr.cpp:1759
void PopCompoundScope()
Definition: Sema.cpp:1179
virtual void ReadMismatchingDeleteExpressions(llvm::MapVector< FieldDecl *, llvm::SmallVector< std::pair< SourceLocation, bool >, 4 >> &)
Definition: Sema.cpp:1272
ASTContext * Context
std::vector< bool > & Stack
QualType getAtomicType(QualType T) const
Return the uniqued reference to the atomic type for the specified type.
CK_FunctionToPointerDecay - Function to pointer decay.
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee...
Definition: Type.cpp:415
SourceManager & SM
CanQualType OCLNDRangeTy
Definition: ASTContext.h:907
virtual void ReadKnownNamespaces(SmallVectorImpl< NamespaceDecl * > &Namespaces)
Load the set of namespaces that are known to the external source, which will be used during typo corr...
Definition: Sema.cpp:1264
int * Depth
CommentOptions CommentOpts
Options for parsing comments.
Definition: LangOptions.h:110
Retains information about a block that is currently being parsed.
Definition: ScopeInfo.h:569
bool isDeleted() const
Whether this function has been deleted.
Definition: Decl.h:1820
Any normal C comment.
An abstract interface that should be implemented by external AST sources that also provide informatio...
BlockDecl - This represents a block literal declaration, which is like an unnamed FunctionDecl...
Definition: Decl.h:3369
static bool ShouldRemoveFromUnused(Sema *SemaRef, const DeclaratorDecl *D)
Used to prune the decls of Sema's UnusedFileScopedDecls vector.
Definition: Sema.cpp:426
Expr - This represents one expression.
Definition: Expr.h:104
Show just the "best" overload candidates.
CK_PointerToBoolean - Pointer to boolean conversion.
static SourceLocation getLocForEndOfToken(SourceLocation Loc, unsigned Offset, const SourceManager &SM, const LangOptions &LangOpts)
Computes the source location just past the end of the token at this source location.
Definition: Lexer.cpp:759
ExprValueKind
The categorization of expression values, currently following the C++11 scheme.
Definition: Specifiers.h:99
bool isAlmostTrailingComment() const LLVM_READONLY
Returns true if it is a probable typo:
bool isBeforeInTranslationUnit(SourceLocation LHS, SourceLocation RHS) const
Determines the order of 2 source locations in the translation unit.
llvm::SmallPtrSet< const Decl *, 4 > ParsingInitForAutoVars
ParsingInitForAutoVars - a set of declarations with auto types for which we are currently parsing the...
Definition: Sema.h:475
CanQualType OCLImage1dTy
Definition: ASTContext.h:901
decls_iterator decls_end() const
Definition: ExprCXX.h:2492
friend_iterator friend_begin() const
Definition: DeclFriend.h:223
static FindResult find(Expr *E)
Finds the overloaded expression in the given expression E of OverloadTy.
Definition: ExprCXX.h:2464
void addImplicitTypedef(StringRef Name, QualType T)
Definition: Sema.cpp:133
SourceManager & SourceMgr
Definition: Format.cpp:1352
BlockExpr - Adaptor class for mixing a BlockDecl with expressions.
Definition: Expr.h:4580
void setInvalidDecl(bool Invalid=true)
setInvalidDecl - Indicates the Decl had a semantic error.
Definition: DeclBase.cpp:111
TranslationUnitDecl * getTranslationUnitDecl() const
Definition: ASTContext.h:875
CanQualType OCLImage2dArrayMSAATy
Definition: ASTContext.h:903
Defines the clang::Preprocessor interface.
llvm::MapVector< IdentifierInfo *, WeakInfo > WeakUndeclaredIdentifiers
WeakUndeclaredIdentifiers - Identifiers contained in #pragma weak before declared.
Definition: Sema.h:656
Defines the classes clang::DelayedDiagnostic and clang::AccessedEntity.
DeclContext * getDeclContext()
Definition: DeclBase.h:393
void PopFunctionScopeInfo(const sema::AnalysisBasedWarnings::Policy *WP=nullptr, const Decl *D=nullptr, const BlockExpr *blkExpr=nullptr)
Definition: Sema.cpp:1159
bool resolveExports(Module *Mod, bool Complain)
Resolve all of the unresolved exports in the given module.
Definition: ModuleMap.cpp:878
An abstract interface that should be implemented by listeners that want to be notified when an AST en...
bool isInSystemHeader(SourceLocation Loc) const
Returns if a SourceLocation is in a system header.
bool RequireCompleteType(SourceLocation Loc, QualType T, TypeDiagnoser &Diagnoser)
Ensure that the type T is a complete type.
Definition: SemaType.cpp:6518
llvm::DenseMap< NamedDecl *, SourceLocation > UndefinedButUsed
UndefinedInternals - all the used, undefined objects which require a definition in this translation u...
Definition: Sema.h:942
ASTMutationListener * getASTMutationListener() const
Definition: Sema.cpp:318
void Clear()
Clear out the current diagnostic.
Definition: Diagnostic.h:705
CanQualType OCLImage2dMSAATy
Definition: ASTContext.h:903
SmallVector< sema::FunctionScopeInfo *, 4 > FunctionScopes
Stack containing information about each of the nested function, block, and method scopes that are cur...
Definition: Sema.h:434
PartialDiagnostic::StorageAllocator & getDiagAllocator()
Definition: ASTContext.h:576
DeclContext * getParent()
getParent - Returns the containing DeclContext.
Definition: DeclBase.h:1200
CanQualType OCLImage2dArrayDepthTy
Definition: ASTContext.h:903
bool isExternallyVisible() const
Definition: Decl.h:280
SmallVector< ActiveTemplateInstantiation, 16 > ActiveTemplateInstantiations
List of active template instantiations.
Definition: Sema.h:6601
DeclarationName getDeclName() const
getDeclName - Get the actual, stored name of the declaration, which may be a special name...
Definition: Decl.h:190
DiagnosticsEngine & getDiagnostics() const
Definition: Sema.h:1045
void PushOnScopeChains(NamedDecl *D, Scope *S, bool AddToContext=true)
Add this decl to the scope shadowed decl chains.
Definition: SemaDecl.cpp:1203
sema::LambdaScopeInfo * PushLambdaScope()
Definition: Sema.cpp:1144
NamedDecl * LookupSingleName(Scope *S, DeclarationName Name, SourceLocation Loc, LookupNameKind NameKind, RedeclarationKind Redecl=NotForRedeclaration)
Look up a name, looking for a single declaration.
unsigned NumSFINAEErrors
The number of SFINAE diagnostics that have been trapped.
Definition: Sema.h:922
const clang::PrintingPolicy & getPrintingPolicy() const
Definition: ASTContext.h:545
CK_ArrayToPointerDecay - Array to pointer decay.
llvm::DenseMap< const CXXRecordDecl *, bool > RecordCompleteMap
Definition: Sema.cpp:565
An abstract interface that should be implemented by external AST sources that also provide informatio...
void * PackContext
PackContext - Manages the stack for #pragma pack.
Definition: Sema.h:319
decls_iterator decls_begin() const
Definition: ExprCXX.h:2491
void addAttr(Attr *A)
Definition: DeclBase.h:449
bool isInMainFile(SourceLocation Loc) const
Returns whether the PresumedLoc for a given SourceLocation is in the main file.
unsigned Bool
Whether we can use 'bool' rather than '_Bool', even if the language doesn't actually have 'bool' (bec...
void PushBlockScope(Scope *BlockScope, BlockDecl *Block)
Definition: Sema.cpp:1139
CanQualType OverloadTy
Definition: ASTContext.h:896
#define false
Definition: stdbool.h:33
Kind
A reference to an overloaded function set, either an UnresolvedLookupExpr or an UnresolvedMemberExpr...
Definition: ExprCXX.h:2402
void print(raw_ostream &OS, const SourceManager &SM) const
Encodes a location in the source.
IdentifierInfo & get(StringRef Name)
Return the identifier token info for the specified named identifier.
ExternalASTSource * getExternalSource() const
Retrieve a pointer to the external AST source associated with this AST context, if any...
Definition: ASTContext.h:932
const TemplateArgument * iterator
Definition: Type.h:4070
bool isValid() const
Return true if this is a valid SourceLocation object.
bool getSuppressAllDiagnostics() const
Definition: Diagnostic.h:468
bool makeUnavailableInSystemHeader(SourceLocation loc, UnavailableAttr::ImplicitReason reason)
makeUnavailableInSystemHeader - There is an error in the current context.
Definition: Sema.cpp:297
Represents a static or instance method of a struct/union/class.
Definition: DeclCXX.h:1701
void DiagnoseUseOfUnimplementedSelectors()
CanQualType FloatTy
Definition: ASTContext.h:892
ASTConsumer & getASTConsumer() const
Definition: Sema.h:1049
CanQualType VoidTy
Definition: ASTContext.h:881
void addDecl(NamedDecl *D)
Definition: UnresolvedSet.h:77
void SetArgToStringFn(ArgToStringFnTy Fn, void *Cookie)
Definition: Diagnostic.h:618
void EmitCurrentDiagnostic(unsigned DiagID)
Cause the active diagnostic on the DiagosticsEngine to be emitted.
Definition: Sema.cpp:966
This declaration is only a declaration.
Definition: Decl.h:997
bool hasBuiltinMSVaList() const
Returns whether or not type __builtin_ms_va_list type is available on this target.
ImplicitCastExpr - Allows us to explicitly represent implicit type conversions, which have no direct ...
Definition: Expr.h:2712
bool isRValue() const
Definition: Expr.h:247
The diagnostic should be suppressed entirely.
SourceLocation getBegin() const
bool isTypeDependent() const
isTypeDependent - Determines whether this expression is type-dependent (C++ [temp.dep.expr]), which means that its type could change from one template instantiation to the next.
Definition: Expr.h:164
static bool IsRecordFullyDefined(const CXXRecordDecl *RD, RecordCompleteMap &RecordsComplete, RecordCompleteMap &MNCComplete)
Returns true, if the given CXXRecordDecl is fully defined in this translation unit, i.e.
Definition: Sema.cpp:613
std::unique_ptr< CXXFieldCollector > FieldCollector
FieldCollector - Collects CXXFieldDecls during parsing of C++ classes.
Definition: Sema.h:446
TypedefDecl * getInt128Decl() const
Retrieve the declaration for the 128-bit signed integer type.
Definition: ASTContext.cpp:957
sema::FunctionScopeInfo * getCurFunction() const
Definition: Sema.h:1167
sema::CapturedRegionScopeInfo * getCurCapturedRegion()
Retrieve the current captured region, if any.
Definition: Sema.cpp:1517
static bool isBuiltinNote(unsigned DiagID)
Determine whether the given built-in diagnostic ID is a Note.
bool isIgnored(unsigned DiagID, SourceLocation Loc) const
Determine whether the diagnostic is known to be ignored.
Definition: Diagnostic.h:645
SourceLocation getExprLoc() const LLVM_READONLY
getExprLoc - Return the preferred location for the arrow when diagnosing a problem with a generic exp...
Definition: Expr.cpp:193
decl_iterator - Iterates through the declarations stored within this context.
Definition: DeclBase.h:1398
Base class for declarations which introduce a typedef-name.
Definition: Decl.h:2526
Abstract interface for a consumer of code-completion information.
QualType getType() const
Definition: Expr.h:125
sema::LambdaScopeInfo * getCurLambda()
Retrieve the current lambda scope info, if any.
Definition: Sema.cpp:1207
if(T->getSizeExpr()) TRY_TO(TraverseStmt(T-> getSizeExpr()))
Represents a template argument.
Definition: TemplateBase.h:40
TypedefDecl * buildImplicitTypedef(QualType T, StringRef Name) const
Create a new implicit TU-level typedef declaration.
Definition: ASTContext.cpp:947
LateTemplateParserCleanupCB * LateTemplateParserCleanup
Definition: Sema.h:527
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
Definition: DeclBase.h:1121
ObjCMethodDecl * NSNumberLiteralMethods[NSAPI::NumNSNumberLiteralMethods]
The Objective-C NSNumber methods used to create NSNumber literals.
Definition: Sema.h:715
Converts an integral complex to bool by comparing against 0+0i.
ExprResult ImpCastExprToType(Expr *E, QualType Type, CastKind CK, ExprValueKind VK=VK_RValue, const CXXCastPath *BasePath=nullptr, CheckedConversionKind CCK=CCK_ImplicitConversion)
ImpCastExprToType - If Expr is not of type 'Type', insert an implicit cast.
Definition: Sema.cpp:369
bool isInvalidDecl() const
Definition: DeclBase.h:509
void RecordParsingTemplateParameterDepth(unsigned Depth)
This is used to inform Sema what the current TemplateParameterDepth is during Parsing.
Definition: Sema.cpp:1150
This is a scope that corresponds to the template parameters of a C++ template.
Definition: Scope.h:75
DeclarationName - The name of a declaration.
bool tryToRecoverWithCall(ExprResult &E, const PartialDiagnostic &PD, bool ForceComplain=false, bool(*IsPlausibleResult)(QualType)=nullptr)
Try to recover by turning the given expression into a call.
Definition: Sema.cpp:1459
bool isUsed(bool CheckUsedAttr=true) const
Whether this declaration was used, meaning that a definition is required.
Definition: DeclBase.cpp:332
A set of unresolved declarations.
detail::InMemoryDirectory::const_iterator E
IdentifierResolver IdResolver
Definition: Sema.h:675
virtual bool hasInt128Type() const
Determine whether the __int128 type is supported on this target.
CanQualType getCanonicalType(QualType T) const
Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...
Definition: ASTContext.h:1946
CK_MemberPointerToBoolean - Member pointer to boolean.
static CastKind ScalarTypeToBooleanCastKind(QualType ScalarTy)
ScalarTypeToBooleanCastKind - Returns the cast kind corresponding to the conversion from scalar type ...
Definition: Sema.cpp:410
Abstract interface for a module loader.
Definition: ModuleLoader.h:56
NamedDecl * getCurFunctionOrMethodDecl()
getCurFunctionOrMethodDecl - Return the Decl for the current ObjC method or C function we're in...
Definition: Sema.cpp:959
llvm::MapVector< FieldDecl *, DeleteLocs > DeleteExprs
Definition: Sema.h:464
Encapsulates the data about a macro definition (e.g.
Definition: MacroInfo.h:34
DeclarationName VAListTagName
VAListTagName - The declaration name corresponding to __va_list_tag.
Definition: Sema.h:315
void FormatASTNodeDiagnosticArgument(DiagnosticsEngine::ArgumentKind Kind, intptr_t Val, StringRef Modifier, StringRef Argument, ArrayRef< DiagnosticsEngine::ArgumentValue > PrevArgs, SmallVectorImpl< char > &Output, void *Cookie, ArrayRef< intptr_t > QualTypeVals)
DiagnosticsEngine argument formatting function for diagnostics that involve AST nodes.
QualType getPointerDiffType() const
Return the unique type for "ptrdiff_t" (C99 7.17) defined in <stddef.h>.
SourceManager & getSourceManager() const
Definition: Sema.h:1046
const T * getAs() const
Member-template getAs<specific type>'.
Definition: Type.h:5675
PrintingPolicy getPrintingPolicy() const
Retrieve a suitable printing policy.
Definition: Sema.h:1853
CanQualType UnsignedLongTy
Definition: ASTContext.h:890
FunctionDecl * getCurFunctionDecl()
getCurFunctionDecl - If inside of a function body, this returns a pointer to the function decl for th...
Definition: Sema.cpp:947
void * OpaqueParser
Definition: Sema.h:528
void print(raw_ostream &OS) const override
Definition: Sema.cpp:1275
CanQualType BoundMemberTy
Definition: ASTContext.h:896
SmallVector< ExpressionEvaluationContextRecord, 8 > ExprEvalContexts
A stack of expression evaluation contexts.
Definition: Sema.h:860
bool isCodeCompletionEnabled() const
Determine if we are performing code completion.
void addComment(const RawComment &RC)
Definition: ASTContext.h:688
CanQualType OCLImage2dDepthTy
Definition: ASTContext.h:902
ImplicitParamDecl * getContextParam() const
Retrieve the parameter containing captured variables.
Definition: Decl.h:3611
static FixItHint CreateInsertion(SourceLocation InsertionLoc, StringRef Code, bool BeforePreviousInsertions=false)
Create a code modification hint that inserts the given code string at a specific location.
Definition: Diagnostic.h:78
Implements a partial diagnostic that can be emitted anwyhere in a DiagnosticBuilder stream...
The "class" keyword.
Definition: Type.h:4182
bool isUsable() const
Definition: Ownership.h:160
This is a scope that can contain a declaration.
Definition: Scope.h:57
SourceManager & getSourceManager()
Definition: ASTContext.h:553
The type-property cache.
Definition: Type.cpp:3238
void ActOnTranslationUnitScope(Scope *S)
Definition: Sema.cpp:68
Scope * getScopeForContext(DeclContext *Ctx)
Determines the active Scope associated with the given declaration context.
Definition: Sema.cpp:1108
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate.h) and friends (in DeclFriend.h).
void setSuppressAllDiagnostics(bool Val=true)
Suppress all diagnostics, to silence the front end when we know that we don't want any more diagnosti...
Definition: Diagnostic.h:465
void * VisContext
VisContext - Manages the stack for #pragma GCC visibility.
Definition: Sema.h:398
virtual void ReadUndefinedButUsed(llvm::DenseMap< NamedDecl *, SourceLocation > &Undefined)
Load the set of used but not defined functions or variables with internal linkage, or used but not defined internal functions.
Definition: Sema.cpp:1268
SmallVector< PossiblyUnreachableDiag, 4 > PossiblyUnreachableDiags
A list of PartialDiagnostics created but delayed within the current function scope.
Definition: ScopeInfo.h:163
static SFINAEResponse getDiagnosticSFINAEResponse(unsigned DiagID)
Determines whether the given built-in diagnostic ID is for an error that is suppressed if it occurs d...
Represents a C++ struct/union/class.
Definition: DeclCXX.h:285
BoundNodesTreeBuilder *const Builder
CommentKind getKind() const LLVM_READONLY
Represents a C array with an unspecified size.
Definition: Type.h:2530
Optional< sema::TemplateDeductionInfo * > isSFINAEContext() const
Determines whether we are currently in a context where template argument substitution failures are no...
OverloadsShown getShowOverloads() const
Definition: Diagnostic.h:492
CanQualType OCLImage1dArrayTy
Definition: ASTContext.h:901
DeclContext * CurContext
CurContext - This is the current declaration context of parsing.
Definition: Sema.h:307
TranslationUnitKind
Describes the kind of translation unit being processed.
Definition: LangOptions.h:178
static FixItHint CreateReplacement(CharSourceRange RemoveRange, StringRef Code)
Create a code modification hint that replaces the given source range with the given code string...
Definition: Diagnostic.h:115
bool tryExprAsCall(Expr &E, QualType &ZeroArgCallReturnTy, UnresolvedSetImpl &NonTemplateOverloads)
Figure out if an expression could be turned into a call.
Definition: Sema.cpp:1304
A little helper class (which is basically a smart pointer that forwards info from DiagnosticsEngine) ...
Definition: Diagnostic.h:1137
TranslationUnitKind TUKind
The kind of translation unit we are processing.
Definition: Sema.h:917
Defines the clang::TargetInfo interface.
ExprResult ExprError()
Definition: Ownership.h:267
The diagnostic should be reported.
CanQualType IntTy
Definition: ASTContext.h:889
void PrintStats() const
Print out statistics about the semantic analysis.
Definition: Sema.cpp:344
void ActOnComment(SourceRange Comment)
Definition: Sema.cpp:1232
virtual void ReadPendingInstantiations(SmallVectorImpl< std::pair< ValueDecl *, SourceLocation > > &Pending)
Read the set of pending instantiations known to the external Sema source.
decl_type * getMostRecentDecl()
Returns the most recent (re)declaration of this declaration.
Definition: Redeclarable.h:166
CK_NoOp - A conversion which does not affect the type other than (possibly) adding qualifiers...
The diagnostic is an access-control diagnostic, which will be substitution failures in some contexts ...
A reference to a declared variable, function, enum, etc.
Definition: Expr.h:922
NamedDecl * getMostRecentDecl()
Definition: Decl.h:332
QualType getUIntPtrType() const
Return a type compatible with "uintptr_t" (C99 7.18.1.4), as defined by the target.
QualType getConstantArrayType(QualType EltTy, const llvm::APInt &ArySize, ArrayType::ArraySizeModifier ASM, unsigned IndexTypeQuals) const
Return the unique reference to the type for a constant array of the specified element type...
DeclContext * getPrimaryContext()
getPrimaryContext - There may be many different declarations of the same entity (including forward de...
Definition: DeclBase.cpp:953
SourceManager & SourceMgr
Definition: Sema.h:298
CapturedRegionKind
The different kinds of captured statement.
Definition: CapturedStmt.h:17
Annotates a diagnostic with some code that should be inserted, removed, or replaced to fix the proble...
Definition: Diagnostic.h:52
SourceLocation getCurrentDiagLoc() const
Definition: Diagnostic.h:811
TypedefDecl * getObjCSelDecl() const
Retrieve the typedef corresponding to the predefined 'SEL' type in Objective-C.
TypedefDecl * getBuiltinMSVaListDecl() const
Retrieve the C type declaration corresponding to the predefined __builtin_ms_va_list type...
SmallVector< CompoundScopeInfo, 4 > CompoundScopes
The stack of currently active compound stamement scopes in the function.
Definition: ScopeInfo.h:158
virtual void CompleteTentativeDefinition(VarDecl *D)
CompleteTentativeDefinition - Callback invoked at the end of a translation unit to notify the consume...
Definition: ASTConsumer.h:121
A trivial tuple used to represent a source range.
SourceLocation getLocation() const
Definition: DeclBase.h:384
ASTContext & Context
Definition: Sema.h:295
void diagnoseNullableToNonnullConversion(QualType DstType, QualType SrcType, SourceLocation Loc)
Warn if we're implicitly casting from a _Nullable pointer type to a _Nonnull one. ...
Definition: Sema.cpp:352
NamedDecl - This represents a decl with a name.
Definition: Decl.h:145
void PushCapturedRegionScope(Scope *RegionScope, CapturedDecl *CD, RecordDecl *RD, CapturedRegionKind K)
Definition: Sema.cpp:1509
SourceLocation getExpansionLoc(SourceLocation Loc) const
Given a SourceLocation object Loc, return the expansion location referenced by the ID...
bool isConstQualified() const
Determine whether this type is const-qualified.
Definition: Type.h:5148
CanQualType DoubleTy
Definition: ASTContext.h:892
SmallVector< std::pair< const CXXMethodDecl *, const CXXMethodDecl * >, 2 > DelayedExceptionSpecChecks
All the overriding functions seen during a class definition that had their exception spec checks dela...
Definition: Sema.h:507
bool isNull() const
Return true if this QualType doesn't point to a type yet.
Definition: Type.h:642
CK_ToVoid - Cast to void, discarding the computed value.
void setType(QualType newType)
Definition: Decl.h:531
Optional< NullabilityKind > getNullability(const ASTContext &context) const
Determine the nullability of the given type.
Definition: Type.cpp:3476
static void checkUndefinedButUsed(Sema &S)
checkUndefinedButUsed - Check for undefined objects with internal linkage or that are inline...
Definition: Sema.cpp:522
SmallVector< std::pair< CXXMethodDecl *, const FunctionProtoType * >, 2 > DelayedDefaultedMemberExceptionSpecs
All the members seen during a class definition which were both explicitly defaulted and had explicitl...
Definition: Sema.h:517
This class handles loading and caching of source files into memory.
Preprocessor & getPreprocessor() const
Definition: Sema.h:1047
Declaration of a template function.
Definition: DeclTemplate.h:830
void PushFunctionScope()
Enter a new function scope.
Definition: Sema.cpp:1127
NamedDeclSetType UnusedPrivateFields
Set containing all declared private fields that are not used.
Definition: Sema.h:451
ScalarTypeKind getScalarTypeKind() const
Given that this is a scalar type, classify it.
Definition: Type.cpp:1823
CanQualType OCLClkEventTy
Definition: ASTContext.h:906
Helper class that creates diagnostics with optional template instantiation stacks.
Definition: Sema.h:1071
Expr * IgnoreParens() LLVM_READONLY
IgnoreParens - Ignore parentheses.
Definition: Expr.cpp:2433
Engages in a tight little dance with the lexer to efficiently preprocess tokens.
Definition: Preprocessor.h:96
CanQualType UnsignedIntTy
Definition: ASTContext.h:890
bool ParseAllComments
Treat ordinary comments as documentation comments.
The translation unit is a module.
Definition: LangOptions.h:185
CK_FloatingToBoolean - Floating point to boolean.