clang  16.0.0git
SemaCXXScopeSpec.cpp
Go to the documentation of this file.
1 //===--- SemaCXXScopeSpec.cpp - Semantic Analysis for C++ scope specifiers-===//
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 implements C++ semantic analysis for scope specifiers.
10 //
11 //===----------------------------------------------------------------------===//
12 
13 #include "TypeLocBuilder.h"
14 #include "clang/AST/ASTContext.h"
15 #include "clang/AST/DeclTemplate.h"
16 #include "clang/AST/ExprCXX.h"
19 #include "clang/Sema/DeclSpec.h"
20 #include "clang/Sema/Lookup.h"
22 #include "clang/Sema/Template.h"
23 #include "llvm/ADT/STLExtras.h"
24 using namespace clang;
25 
26 /// Find the current instantiation that associated with the given type.
28  DeclContext *CurContext) {
29  if (T.isNull())
30  return nullptr;
31 
32  const Type *Ty = T->getCanonicalTypeInternal().getTypePtr();
33  if (const RecordType *RecordTy = dyn_cast<RecordType>(Ty)) {
34  CXXRecordDecl *Record = cast<CXXRecordDecl>(RecordTy->getDecl());
35  if (!Record->isDependentContext() ||
36  Record->isCurrentInstantiation(CurContext))
37  return Record;
38 
39  return nullptr;
40  } else if (isa<InjectedClassNameType>(Ty))
41  return cast<InjectedClassNameType>(Ty)->getDecl();
42  else
43  return nullptr;
44 }
45 
46 /// Compute the DeclContext that is associated with the given type.
47 ///
48 /// \param T the type for which we are attempting to find a DeclContext.
49 ///
50 /// \returns the declaration context represented by the type T,
51 /// or NULL if the declaration context cannot be computed (e.g., because it is
52 /// dependent and not the current instantiation).
54  if (!T->isDependentType())
55  if (const TagType *Tag = T->getAs<TagType>())
56  return Tag->getDecl();
57 
59 }
60 
61 /// Compute the DeclContext that is associated with the given
62 /// scope specifier.
63 ///
64 /// \param SS the C++ scope specifier as it appears in the source
65 ///
66 /// \param EnteringContext when true, we will be entering the context of
67 /// this scope specifier, so we can retrieve the declaration context of a
68 /// class template or class template partial specialization even if it is
69 /// not the current instantiation.
70 ///
71 /// \returns the declaration context represented by the scope specifier @p SS,
72 /// or NULL if the declaration context cannot be computed (e.g., because it is
73 /// dependent and not the current instantiation).
75  bool EnteringContext) {
76  if (!SS.isSet() || SS.isInvalid())
77  return nullptr;
78 
79  NestedNameSpecifier *NNS = SS.getScopeRep();
80  if (NNS->isDependent()) {
81  // If this nested-name-specifier refers to the current
82  // instantiation, return its DeclContext.
83  if (CXXRecordDecl *Record = getCurrentInstantiationOf(NNS))
84  return Record;
85 
86  if (EnteringContext) {
87  const Type *NNSType = NNS->getAsType();
88  if (!NNSType) {
89  return nullptr;
90  }
91 
92  // Look through type alias templates, per C++0x [temp.dep.type]p1.
93  NNSType = Context.getCanonicalType(NNSType);
94  if (const TemplateSpecializationType *SpecType
95  = NNSType->getAs<TemplateSpecializationType>()) {
96  // We are entering the context of the nested name specifier, so try to
97  // match the nested name specifier to either a primary class template
98  // or a class template partial specialization.
99  if (ClassTemplateDecl *ClassTemplate
100  = dyn_cast_or_null<ClassTemplateDecl>(
101  SpecType->getTemplateName().getAsTemplateDecl())) {
103  = Context.getCanonicalType(QualType(SpecType, 0));
104 
105  // If the type of the nested name specifier is the same as the
106  // injected class name of the named class template, we're entering
107  // into that class template definition.
108  QualType Injected
109  = ClassTemplate->getInjectedClassNameSpecialization();
110  if (Context.hasSameType(Injected, ContextType))
111  return ClassTemplate->getTemplatedDecl();
112 
113  // If the type of the nested name specifier is the same as the
114  // type of one of the class template's class template partial
115  // specializations, we're entering into the definition of that
116  // class template partial specialization.
118  = ClassTemplate->findPartialSpecialization(ContextType)) {
119  // A declaration of the partial specialization must be visible.
120  // We can always recover here, because this only happens when we're
121  // entering the context, and that can't happen in a SFINAE context.
122  assert(!isSFINAEContext() &&
123  "partial specialization scope specifier in SFINAE context?");
124  if (!hasReachableDefinition(PartialSpec))
127  /*Recover*/true);
128  return PartialSpec;
129  }
130  }
131  } else if (const RecordType *RecordT = NNSType->getAs<RecordType>()) {
132  // The nested name specifier refers to a member of a class template.
133  return RecordT->getDecl();
134  }
135  }
136 
137  return nullptr;
138  }
139 
140  switch (NNS->getKind()) {
142  llvm_unreachable("Dependent nested-name-specifier has no DeclContext");
143 
145  return NNS->getAsNamespace();
146 
148  return NNS->getAsNamespaceAlias()->getNamespace();
149 
152  const TagType *Tag = NNS->getAsType()->getAs<TagType>();
153  assert(Tag && "Non-tag type in nested-name-specifier");
154  return Tag->getDecl();
155  }
156 
159 
161  return NNS->getAsRecordDecl();
162  }
163 
164  llvm_unreachable("Invalid NestedNameSpecifier::Kind!");
165 }
166 
168  if (!SS.isSet() || SS.isInvalid())
169  return false;
170 
171  return SS.getScopeRep()->isDependent();
172 }
173 
174 /// If the given nested name specifier refers to the current
175 /// instantiation, return the declaration that corresponds to that
176 /// current instantiation (C++0x [temp.dep.type]p1).
177 ///
178 /// \param NNS a dependent nested name specifier.
180  assert(getLangOpts().CPlusPlus && "Only callable in C++");
181  assert(NNS->isDependent() && "Only dependent nested-name-specifier allowed");
182 
183  if (!NNS->getAsType())
184  return nullptr;
185 
186  QualType T = QualType(NNS->getAsType(), 0);
188 }
189 
190 /// Require that the context specified by SS be complete.
191 ///
192 /// If SS refers to a type, this routine checks whether the type is
193 /// complete enough (or can be made complete enough) for name lookup
194 /// into the DeclContext. A type that is not yet completed can be
195 /// considered "complete enough" if it is a class/struct/union/enum
196 /// that is currently being defined. Or, if we have a type that names
197 /// a class template specialization that is not a complete type, we
198 /// will attempt to instantiate that class template.
200  DeclContext *DC) {
201  assert(DC && "given null context");
202 
203  TagDecl *tag = dyn_cast<TagDecl>(DC);
204 
205  // If this is a dependent type, then we consider it complete.
206  // FIXME: This is wrong; we should require a (visible) definition to
207  // exist in this case too.
208  if (!tag || tag->isDependentContext())
209  return false;
210 
211  // Grab the tag definition, if there is one.
213  tag = type->getAsTagDecl();
214 
215  // If we're currently defining this type, then lookup into the
216  // type is okay: don't complain that it isn't complete yet.
217  if (tag->isBeingDefined())
218  return false;
219 
221  if (loc.isInvalid()) loc = SS.getRange().getBegin();
222 
223  // The type must be complete.
224  if (RequireCompleteType(loc, type, diag::err_incomplete_nested_name_spec,
225  SS.getRange())) {
226  SS.SetInvalid(SS.getRange());
227  return true;
228  }
229 
230  if (auto *EnumD = dyn_cast<EnumDecl>(tag))
231  // Fixed enum types and scoped enum instantiations are complete, but they
232  // aren't valid as scopes until we see or instantiate their definition.
233  return RequireCompleteEnumDecl(EnumD, loc, &SS);
234 
235  return false;
236 }
237 
238 /// Require that the EnumDecl is completed with its enumerators defined or
239 /// instantiated. SS, if provided, is the ScopeRef parsed.
240 ///
242  CXXScopeSpec *SS) {
243  if (EnumD->isCompleteDefinition()) {
244  // If we know about the definition but it is not visible, complain.
245  NamedDecl *SuggestedDef = nullptr;
246  if (!hasReachableDefinition(EnumD, &SuggestedDef,
247  /*OnlyNeedComplete*/ false)) {
248  // If the user is going to see an error here, recover by making the
249  // definition visible.
250  bool TreatAsComplete = !isSFINAEContext();
252  /*Recover*/ TreatAsComplete);
253  return !TreatAsComplete;
254  }
255  return false;
256  }
257 
258  // Try to instantiate the definition, if this is a specialization of an
259  // enumeration temploid.
260  if (EnumDecl *Pattern = EnumD->getInstantiatedFromMemberEnum()) {
263  if (InstantiateEnum(L, EnumD, Pattern,
266  if (SS)
267  SS->SetInvalid(SS->getRange());
268  return true;
269  }
270  return false;
271  }
272  }
273 
274  if (SS) {
275  Diag(L, diag::err_incomplete_nested_name_spec)
276  << QualType(EnumD->getTypeForDecl(), 0) << SS->getRange();
277  SS->SetInvalid(SS->getRange());
278  } else {
279  Diag(L, diag::err_incomplete_enum) << QualType(EnumD->getTypeForDecl(), 0);
280  Diag(EnumD->getLocation(), diag::note_declared_at);
281  }
282 
283  return true;
284 }
285 
287  CXXScopeSpec &SS) {
288  SS.MakeGlobal(Context, CCLoc);
289  return false;
290 }
291 
293  SourceLocation ColonColonLoc,
294  CXXScopeSpec &SS) {
295  CXXRecordDecl *RD = nullptr;
296  for (Scope *S = getCurScope(); S; S = S->getParent()) {
297  if (S->isFunctionScope()) {
298  if (CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(S->getEntity()))
299  RD = MD->getParent();
300  break;
301  }
302  if (S->isClassScope()) {
303  RD = cast<CXXRecordDecl>(S->getEntity());
304  break;
305  }
306  }
307 
308  if (!RD) {
309  Diag(SuperLoc, diag::err_invalid_super_scope);
310  return true;
311  } else if (RD->isLambda()) {
312  Diag(SuperLoc, diag::err_super_in_lambda_unsupported);
313  return true;
314  } else if (RD->getNumBases() == 0) {
315  Diag(SuperLoc, diag::err_no_base_classes) << RD->getName();
316  return true;
317  }
318 
319  SS.MakeSuper(Context, RD, SuperLoc, ColonColonLoc);
320  return false;
321 }
322 
323 /// Determines whether the given declaration is an valid acceptable
324 /// result for name lookup of a nested-name-specifier.
325 /// \param SD Declaration checked for nested-name-specifier.
326 /// \param IsExtension If not null and the declaration is accepted as an
327 /// extension, the pointed variable is assigned true.
329  bool *IsExtension) {
330  if (!SD)
331  return false;
332 
333  SD = SD->getUnderlyingDecl();
334 
335  // Namespace and namespace aliases are fine.
336  if (isa<NamespaceDecl>(SD))
337  return true;
338 
339  if (!isa<TypeDecl>(SD))
340  return false;
341 
342  // Determine whether we have a class (or, in C++11, an enum) or
343  // a typedef thereof. If so, build the nested-name-specifier.
344  QualType T = Context.getTypeDeclType(cast<TypeDecl>(SD));
345  if (T->isDependentType())
346  return true;
347  if (const TypedefNameDecl *TD = dyn_cast<TypedefNameDecl>(SD)) {
348  if (TD->getUnderlyingType()->isRecordType())
349  return true;
350  if (TD->getUnderlyingType()->isEnumeralType()) {
351  if (Context.getLangOpts().CPlusPlus11)
352  return true;
353  if (IsExtension)
354  *IsExtension = true;
355  }
356  } else if (isa<RecordDecl>(SD)) {
357  return true;
358  } else if (isa<EnumDecl>(SD)) {
359  if (Context.getLangOpts().CPlusPlus11)
360  return true;
361  if (IsExtension)
362  *IsExtension = true;
363  }
364 
365  return false;
366 }
367 
368 /// If the given nested-name-specifier begins with a bare identifier
369 /// (e.g., Base::), perform name lookup for that identifier as a
370 /// nested-name-specifier within the given scope, and return the result of that
371 /// name lookup.
373  if (!S || !NNS)
374  return nullptr;
375 
376  while (NNS->getPrefix())
377  NNS = NNS->getPrefix();
378 
380  return nullptr;
381 
382  LookupResult Found(*this, NNS->getAsIdentifier(), SourceLocation(),
384  LookupName(Found, S);
385  assert(!Found.isAmbiguous() && "Cannot handle ambiguities here yet");
386 
387  if (!Found.isSingleResult())
388  return nullptr;
389 
390  NamedDecl *Result = Found.getFoundDecl();
392  return Result;
393 
394  return nullptr;
395 }
396 
398  NestedNameSpecInfo &IdInfo) {
399  QualType ObjectType = GetTypeFromParser(IdInfo.ObjectType);
400  LookupResult Found(*this, IdInfo.Identifier, IdInfo.IdentifierLoc,
402 
403  // Determine where to perform name lookup
404  DeclContext *LookupCtx = nullptr;
405  bool isDependent = false;
406  if (!ObjectType.isNull()) {
407  // This nested-name-specifier occurs in a member access expression, e.g.,
408  // x->B::f, and we are looking into the type of the object.
409  assert(!SS.isSet() && "ObjectType and scope specifier cannot coexist");
410  LookupCtx = computeDeclContext(ObjectType);
411  isDependent = ObjectType->isDependentType();
412  } else if (SS.isSet()) {
413  // This nested-name-specifier occurs after another nested-name-specifier,
414  // so long into the context associated with the prior nested-name-specifier.
415  LookupCtx = computeDeclContext(SS, false);
416  isDependent = isDependentScopeSpecifier(SS);
417  Found.setContextRange(SS.getRange());
418  }
419 
420  if (LookupCtx) {
421  // Perform "qualified" name lookup into the declaration context we
422  // computed, which is either the type of the base of a member access
423  // expression or the declaration context associated with a prior
424  // nested-name-specifier.
425 
426  // The declaration context must be complete.
427  if (!LookupCtx->isDependentContext() &&
428  RequireCompleteDeclContext(SS, LookupCtx))
429  return false;
430 
431  LookupQualifiedName(Found, LookupCtx);
432  } else if (isDependent) {
433  return false;
434  } else {
435  LookupName(Found, S);
436  }
437  Found.suppressDiagnostics();
438 
439  return Found.getAsSingle<NamespaceDecl>();
440 }
441 
442 namespace {
443 
444 // Callback to only accept typo corrections that can be a valid C++ member
445 // initializer: either a non-static field member or a base class.
446 class NestedNameSpecifierValidatorCCC final
447  : public CorrectionCandidateCallback {
448 public:
449  explicit NestedNameSpecifierValidatorCCC(Sema &SRef)
450  : SRef(SRef) {}
451 
452  bool ValidateCandidate(const TypoCorrection &candidate) override {
453  return SRef.isAcceptableNestedNameSpecifier(candidate.getCorrectionDecl());
454  }
455 
456  std::unique_ptr<CorrectionCandidateCallback> clone() override {
457  return std::make_unique<NestedNameSpecifierValidatorCCC>(*this);
458  }
459 
460  private:
461  Sema &SRef;
462 };
463 
464 }
465 
466 /// Build a new nested-name-specifier for "identifier::", as described
467 /// by ActOnCXXNestedNameSpecifier.
468 ///
469 /// \param S Scope in which the nested-name-specifier occurs.
470 /// \param IdInfo Parser information about an identifier in the
471 /// nested-name-spec.
472 /// \param EnteringContext If true, enter the context specified by the
473 /// nested-name-specifier.
474 /// \param SS Optional nested name specifier preceding the identifier.
475 /// \param ScopeLookupResult Provides the result of name lookup within the
476 /// scope of the nested-name-specifier that was computed at template
477 /// definition time.
478 /// \param ErrorRecoveryLookup Specifies if the method is called to improve
479 /// error recovery and what kind of recovery is performed.
480 /// \param IsCorrectedToColon If not null, suggestion of replace '::' -> ':'
481 /// are allowed. The bool value pointed by this parameter is set to
482 /// 'true' if the identifier is treated as if it was followed by ':',
483 /// not '::'.
484 /// \param OnlyNamespace If true, only considers namespaces in lookup.
485 ///
486 /// This routine differs only slightly from ActOnCXXNestedNameSpecifier, in
487 /// that it contains an extra parameter \p ScopeLookupResult, which provides
488 /// the result of name lookup within the scope of the nested-name-specifier
489 /// that was computed at template definition time.
490 ///
491 /// If ErrorRecoveryLookup is true, then this call is used to improve error
492 /// recovery. This means that it should not emit diagnostics, it should
493 /// just return true on failure. It also means it should only return a valid
494 /// scope if it *knows* that the result is correct. It should not return in a
495 /// dependent context, for example. Nor will it extend \p SS with the scope
496 /// specifier.
498  bool EnteringContext, CXXScopeSpec &SS,
499  NamedDecl *ScopeLookupResult,
500  bool ErrorRecoveryLookup,
501  bool *IsCorrectedToColon,
502  bool OnlyNamespace) {
503  if (IdInfo.Identifier->isEditorPlaceholder())
504  return true;
505  LookupResult Found(*this, IdInfo.Identifier, IdInfo.IdentifierLoc,
506  OnlyNamespace ? LookupNamespaceName
508  QualType ObjectType = GetTypeFromParser(IdInfo.ObjectType);
509 
510  // Determine where to perform name lookup
511  DeclContext *LookupCtx = nullptr;
512  bool isDependent = false;
513  if (IsCorrectedToColon)
514  *IsCorrectedToColon = false;
515  if (!ObjectType.isNull()) {
516  // This nested-name-specifier occurs in a member access expression, e.g.,
517  // x->B::f, and we are looking into the type of the object.
518  assert(!SS.isSet() && "ObjectType and scope specifier cannot coexist");
519  LookupCtx = computeDeclContext(ObjectType);
520  isDependent = ObjectType->isDependentType();
521  } else if (SS.isSet()) {
522  // This nested-name-specifier occurs after another nested-name-specifier,
523  // so look into the context associated with the prior nested-name-specifier.
524  LookupCtx = computeDeclContext(SS, EnteringContext);
525  isDependent = isDependentScopeSpecifier(SS);
526  Found.setContextRange(SS.getRange());
527  }
528 
529  bool ObjectTypeSearchedInScope = false;
530  if (LookupCtx) {
531  // Perform "qualified" name lookup into the declaration context we
532  // computed, which is either the type of the base of a member access
533  // expression or the declaration context associated with a prior
534  // nested-name-specifier.
535 
536  // The declaration context must be complete.
537  if (!LookupCtx->isDependentContext() &&
538  RequireCompleteDeclContext(SS, LookupCtx))
539  return true;
540 
541  LookupQualifiedName(Found, LookupCtx);
542 
543  if (!ObjectType.isNull() && Found.empty()) {
544  // C++ [basic.lookup.classref]p4:
545  // If the id-expression in a class member access is a qualified-id of
546  // the form
547  //
548  // class-name-or-namespace-name::...
549  //
550  // the class-name-or-namespace-name following the . or -> operator is
551  // looked up both in the context of the entire postfix-expression and in
552  // the scope of the class of the object expression. If the name is found
553  // only in the scope of the class of the object expression, the name
554  // shall refer to a class-name. If the name is found only in the
555  // context of the entire postfix-expression, the name shall refer to a
556  // class-name or namespace-name. [...]
557  //
558  // Qualified name lookup into a class will not find a namespace-name,
559  // so we do not need to diagnose that case specifically. However,
560  // this qualified name lookup may find nothing. In that case, perform
561  // unqualified name lookup in the given scope (if available) or
562  // reconstruct the result from when name lookup was performed at template
563  // definition time.
564  if (S)
565  LookupName(Found, S);
566  else if (ScopeLookupResult)
567  Found.addDecl(ScopeLookupResult);
568 
569  ObjectTypeSearchedInScope = true;
570  }
571  } else if (!isDependent) {
572  // Perform unqualified name lookup in the current scope.
573  LookupName(Found, S);
574  }
575 
576  if (Found.isAmbiguous())
577  return true;
578 
579  // If we performed lookup into a dependent context and did not find anything,
580  // that's fine: just build a dependent nested-name-specifier.
581  if (Found.empty() && isDependent &&
582  !(LookupCtx && LookupCtx->isRecord() &&
583  (!cast<CXXRecordDecl>(LookupCtx)->hasDefinition() ||
584  !cast<CXXRecordDecl>(LookupCtx)->hasAnyDependentBases()))) {
585  // Don't speculate if we're just trying to improve error recovery.
586  if (ErrorRecoveryLookup)
587  return true;
588 
589  // We were not able to compute the declaration context for a dependent
590  // base object type or prior nested-name-specifier, so this
591  // nested-name-specifier refers to an unknown specialization. Just build
592  // a dependent nested-name-specifier.
593  SS.Extend(Context, IdInfo.Identifier, IdInfo.IdentifierLoc, IdInfo.CCLoc);
594  return false;
595  }
596 
597  if (Found.empty() && !ErrorRecoveryLookup) {
598  // If identifier is not found as class-name-or-namespace-name, but is found
599  // as other entity, don't look for typos.
601  if (LookupCtx)
602  LookupQualifiedName(R, LookupCtx);
603  else if (S && !isDependent)
604  LookupName(R, S);
605  if (!R.empty()) {
606  // Don't diagnose problems with this speculative lookup.
608  // The identifier is found in ordinary lookup. If correction to colon is
609  // allowed, suggest replacement to ':'.
610  if (IsCorrectedToColon) {
611  *IsCorrectedToColon = true;
612  Diag(IdInfo.CCLoc, diag::err_nested_name_spec_is_not_class)
613  << IdInfo.Identifier << getLangOpts().CPlusPlus
614  << FixItHint::CreateReplacement(IdInfo.CCLoc, ":");
615  if (NamedDecl *ND = R.getAsSingle<NamedDecl>())
616  Diag(ND->getLocation(), diag::note_declared_at);
617  return true;
618  }
619  // Replacement '::' -> ':' is not allowed, just issue respective error.
620  Diag(R.getNameLoc(), OnlyNamespace
621  ? unsigned(diag::err_expected_namespace_name)
622  : unsigned(diag::err_expected_class_or_namespace))
623  << IdInfo.Identifier << getLangOpts().CPlusPlus;
624  if (NamedDecl *ND = R.getAsSingle<NamedDecl>())
625  Diag(ND->getLocation(), diag::note_entity_declared_at)
626  << IdInfo.Identifier;
627  return true;
628  }
629  }
630 
631  if (Found.empty() && !ErrorRecoveryLookup && !getLangOpts().MSVCCompat) {
632  // We haven't found anything, and we're not recovering from a
633  // different kind of error, so look for typos.
634  DeclarationName Name = Found.getLookupName();
635  Found.clear();
636  NestedNameSpecifierValidatorCCC CCC(*this);
637  if (TypoCorrection Corrected = CorrectTypo(
638  Found.getLookupNameInfo(), Found.getLookupKind(), S, &SS, CCC,
639  CTK_ErrorRecovery, LookupCtx, EnteringContext)) {
640  if (LookupCtx) {
641  bool DroppedSpecifier =
642  Corrected.WillReplaceSpecifier() &&
643  Name.getAsString() == Corrected.getAsString(getLangOpts());
644  if (DroppedSpecifier)
645  SS.clear();
646  diagnoseTypo(Corrected, PDiag(diag::err_no_member_suggest)
647  << Name << LookupCtx << DroppedSpecifier
648  << SS.getRange());
649  } else
650  diagnoseTypo(Corrected, PDiag(diag::err_undeclared_var_use_suggest)
651  << Name);
652 
653  if (Corrected.getCorrectionSpecifier())
654  SS.MakeTrivial(Context, Corrected.getCorrectionSpecifier(),
655  SourceRange(Found.getNameLoc()));
656 
657  if (NamedDecl *ND = Corrected.getFoundDecl())
658  Found.addDecl(ND);
659  Found.setLookupName(Corrected.getCorrection());
660  } else {
661  Found.setLookupName(IdInfo.Identifier);
662  }
663  }
664 
665  NamedDecl *SD =
666  Found.isSingleResult() ? Found.getRepresentativeDecl() : nullptr;
667  bool IsExtension = false;
668  bool AcceptSpec = isAcceptableNestedNameSpecifier(SD, &IsExtension);
669  if (!AcceptSpec && IsExtension) {
670  AcceptSpec = true;
671  Diag(IdInfo.IdentifierLoc, diag::ext_nested_name_spec_is_enum);
672  }
673  if (AcceptSpec) {
674  if (!ObjectType.isNull() && !ObjectTypeSearchedInScope &&
676  // C++03 [basic.lookup.classref]p4:
677  // [...] If the name is found in both contexts, the
678  // class-name-or-namespace-name shall refer to the same entity.
679  //
680  // We already found the name in the scope of the object. Now, look
681  // into the current scope (the scope of the postfix-expression) to
682  // see if we can find the same name there. As above, if there is no
683  // scope, reconstruct the result from the template instantiation itself.
684  //
685  // Note that C++11 does *not* perform this redundant lookup.
686  NamedDecl *OuterDecl;
687  if (S) {
688  LookupResult FoundOuter(*this, IdInfo.Identifier, IdInfo.IdentifierLoc,
690  LookupName(FoundOuter, S);
691  OuterDecl = FoundOuter.getAsSingle<NamedDecl>();
692  } else
693  OuterDecl = ScopeLookupResult;
694 
695  if (isAcceptableNestedNameSpecifier(OuterDecl) &&
696  OuterDecl->getCanonicalDecl() != SD->getCanonicalDecl() &&
697  (!isa<TypeDecl>(OuterDecl) || !isa<TypeDecl>(SD) ||
699  Context.getTypeDeclType(cast<TypeDecl>(OuterDecl)),
700  Context.getTypeDeclType(cast<TypeDecl>(SD))))) {
701  if (ErrorRecoveryLookup)
702  return true;
703 
704  Diag(IdInfo.IdentifierLoc,
705  diag::err_nested_name_member_ref_lookup_ambiguous)
706  << IdInfo.Identifier;
707  Diag(SD->getLocation(), diag::note_ambig_member_ref_object_type)
708  << ObjectType;
709  Diag(OuterDecl->getLocation(), diag::note_ambig_member_ref_scope);
710 
711  // Fall through so that we'll pick the name we found in the object
712  // type, since that's probably what the user wanted anyway.
713  }
714  }
715 
716  if (auto *TD = dyn_cast_or_null<TypedefNameDecl>(SD))
717  MarkAnyDeclReferenced(TD->getLocation(), TD, /*OdrUse=*/false);
718 
719  // If we're just performing this lookup for error-recovery purposes,
720  // don't extend the nested-name-specifier. Just return now.
721  if (ErrorRecoveryLookup)
722  return false;
723 
724  // The use of a nested name specifier may trigger deprecation warnings.
725  DiagnoseUseOfDecl(SD, IdInfo.CCLoc);
726 
727  if (NamespaceDecl *Namespace = dyn_cast<NamespaceDecl>(SD)) {
728  SS.Extend(Context, Namespace, IdInfo.IdentifierLoc, IdInfo.CCLoc);
729  return false;
730  }
731 
732  if (NamespaceAliasDecl *Alias = dyn_cast<NamespaceAliasDecl>(SD)) {
733  SS.Extend(Context, Alias, IdInfo.IdentifierLoc, IdInfo.CCLoc);
734  return false;
735  }
736 
737  QualType T =
738  Context.getTypeDeclType(cast<TypeDecl>(SD->getUnderlyingDecl()));
739 
740  if (T->isEnumeralType())
741  Diag(IdInfo.IdentifierLoc, diag::warn_cxx98_compat_enum_nested_name_spec);
742 
743  TypeLocBuilder TLB;
744  if (const auto *USD = dyn_cast<UsingShadowDecl>(SD)) {
745  T = Context.getUsingType(USD, T);
746  TLB.pushTypeSpec(T).setNameLoc(IdInfo.IdentifierLoc);
747  } else if (isa<InjectedClassNameType>(T)) {
748  InjectedClassNameTypeLoc InjectedTL
749  = TLB.push<InjectedClassNameTypeLoc>(T);
750  InjectedTL.setNameLoc(IdInfo.IdentifierLoc);
751  } else if (isa<RecordType>(T)) {
752  RecordTypeLoc RecordTL = TLB.push<RecordTypeLoc>(T);
753  RecordTL.setNameLoc(IdInfo.IdentifierLoc);
754  } else if (isa<TypedefType>(T)) {
755  TypedefTypeLoc TypedefTL = TLB.push<TypedefTypeLoc>(T);
756  TypedefTL.setNameLoc(IdInfo.IdentifierLoc);
757  } else if (isa<EnumType>(T)) {
758  EnumTypeLoc EnumTL = TLB.push<EnumTypeLoc>(T);
759  EnumTL.setNameLoc(IdInfo.IdentifierLoc);
760  } else if (isa<TemplateTypeParmType>(T)) {
761  TemplateTypeParmTypeLoc TemplateTypeTL
762  = TLB.push<TemplateTypeParmTypeLoc>(T);
763  TemplateTypeTL.setNameLoc(IdInfo.IdentifierLoc);
764  } else if (isa<UnresolvedUsingType>(T)) {
765  UnresolvedUsingTypeLoc UnresolvedTL
766  = TLB.push<UnresolvedUsingTypeLoc>(T);
767  UnresolvedTL.setNameLoc(IdInfo.IdentifierLoc);
768  } else if (isa<SubstTemplateTypeParmType>(T)) {
771  TL.setNameLoc(IdInfo.IdentifierLoc);
772  } else if (isa<SubstTemplateTypeParmPackType>(T)) {
775  TL.setNameLoc(IdInfo.IdentifierLoc);
776  } else {
777  llvm_unreachable("Unhandled TypeDecl node in nested-name-specifier");
778  }
779 
781  IdInfo.CCLoc);
782  return false;
783  }
784 
785  // Otherwise, we have an error case. If we don't want diagnostics, just
786  // return an error now.
787  if (ErrorRecoveryLookup)
788  return true;
789 
790  // If we didn't find anything during our lookup, try again with
791  // ordinary name lookup, which can help us produce better error
792  // messages.
793  if (Found.empty()) {
794  Found.clear(LookupOrdinaryName);
795  LookupName(Found, S);
796  }
797 
798  // In Microsoft mode, if we are within a templated function and we can't
799  // resolve Identifier, then extend the SS with Identifier. This will have
800  // the effect of resolving Identifier during template instantiation.
801  // The goal is to be able to resolve a function call whose
802  // nested-name-specifier is located inside a dependent base class.
803  // Example:
804  //
805  // class C {
806  // public:
807  // static void foo2() { }
808  // };
809  // template <class T> class A { public: typedef C D; };
810  //
811  // template <class T> class B : public A<T> {
812  // public:
813  // void foo() { D::foo2(); }
814  // };
815  if (getLangOpts().MSVCCompat) {
816  DeclContext *DC = LookupCtx ? LookupCtx : CurContext;
817  if (DC->isDependentContext() && DC->isFunctionOrMethod()) {
818  CXXRecordDecl *ContainingClass = dyn_cast<CXXRecordDecl>(DC->getParent());
819  if (ContainingClass && ContainingClass->hasAnyDependentBases()) {
820  Diag(IdInfo.IdentifierLoc,
821  diag::ext_undeclared_unqual_id_with_dependent_base)
822  << IdInfo.Identifier << ContainingClass;
823  SS.Extend(Context, IdInfo.Identifier, IdInfo.IdentifierLoc,
824  IdInfo.CCLoc);
825  return false;
826  }
827  }
828  }
829 
830  if (!Found.empty()) {
831  if (TypeDecl *TD = Found.getAsSingle<TypeDecl>()) {
832  Diag(IdInfo.IdentifierLoc, diag::err_expected_class_or_namespace)
833  << Context.getTypeDeclType(TD) << getLangOpts().CPlusPlus;
834  } else if (Found.getAsSingle<TemplateDecl>()) {
835  ParsedType SuggestedType;
836  DiagnoseUnknownTypeName(IdInfo.Identifier, IdInfo.IdentifierLoc, S, &SS,
837  SuggestedType);
838  } else {
839  Diag(IdInfo.IdentifierLoc, diag::err_expected_class_or_namespace)
840  << IdInfo.Identifier << getLangOpts().CPlusPlus;
841  if (NamedDecl *ND = Found.getAsSingle<NamedDecl>())
842  Diag(ND->getLocation(), diag::note_entity_declared_at)
843  << IdInfo.Identifier;
844  }
845  } else if (SS.isSet())
846  Diag(IdInfo.IdentifierLoc, diag::err_no_member) << IdInfo.Identifier
847  << LookupCtx << SS.getRange();
848  else
849  Diag(IdInfo.IdentifierLoc, diag::err_undeclared_var_use)
850  << IdInfo.Identifier;
851 
852  return true;
853 }
854 
856  bool EnteringContext, CXXScopeSpec &SS,
857  bool *IsCorrectedToColon,
858  bool OnlyNamespace) {
859  if (SS.isInvalid())
860  return true;
861 
862  return BuildCXXNestedNameSpecifier(S, IdInfo, EnteringContext, SS,
863  /*ScopeLookupResult=*/nullptr, false,
864  IsCorrectedToColon, OnlyNamespace);
865 }
866 
868  const DeclSpec &DS,
869  SourceLocation ColonColonLoc) {
870  if (SS.isInvalid() || DS.getTypeSpecType() == DeclSpec::TST_error)
871  return true;
872 
873  assert(DS.getTypeSpecType() == DeclSpec::TST_decltype);
874 
876  if (T.isNull())
877  return true;
878 
879  if (!T->isDependentType() && !T->getAs<TagType>()) {
880  Diag(DS.getTypeSpecTypeLoc(), diag::err_expected_class_or_namespace)
881  << T << getLangOpts().CPlusPlus;
882  return true;
883  }
884 
885  TypeLocBuilder TLB;
886  DecltypeTypeLoc DecltypeTL = TLB.push<DecltypeTypeLoc>(T);
887  DecltypeTL.setDecltypeLoc(DS.getTypeSpecTypeLoc());
888  DecltypeTL.setRParenLoc(DS.getTypeofParensRange().getEnd());
890  ColonColonLoc);
891  return false;
892 }
893 
894 /// IsInvalidUnlessNestedName - This method is used for error recovery
895 /// purposes to determine whether the specified identifier is only valid as
896 /// a nested name specifier, for example a namespace name. It is
897 /// conservatively correct to always return false from this method.
898 ///
899 /// The arguments are the same as those passed to ActOnCXXNestedNameSpecifier.
901  NestedNameSpecInfo &IdInfo,
902  bool EnteringContext) {
903  if (SS.isInvalid())
904  return false;
905 
906  return !BuildCXXNestedNameSpecifier(S, IdInfo, EnteringContext, SS,
907  /*ScopeLookupResult=*/nullptr, true);
908 }
909 
911  CXXScopeSpec &SS,
912  SourceLocation TemplateKWLoc,
913  TemplateTy OpaqueTemplate,
914  SourceLocation TemplateNameLoc,
915  SourceLocation LAngleLoc,
916  ASTTemplateArgsPtr TemplateArgsIn,
917  SourceLocation RAngleLoc,
918  SourceLocation CCLoc,
919  bool EnteringContext) {
920  if (SS.isInvalid())
921  return true;
922 
923  TemplateName Template = OpaqueTemplate.get();
924 
925  // Translate the parser's template argument list in our AST format.
926  TemplateArgumentListInfo TemplateArgs(LAngleLoc, RAngleLoc);
927  translateTemplateArguments(TemplateArgsIn, TemplateArgs);
928 
930  if (DTN && DTN->isIdentifier()) {
931  // Handle a dependent template specialization for which we cannot resolve
932  // the template name.
933  assert(DTN->getQualifier() == SS.getScopeRep());
935  ETK_None, DTN->getQualifier(), DTN->getIdentifier(),
936  TemplateArgs.arguments());
937 
938  // Create source-location information for this type.
939  TypeLocBuilder Builder;
941  = Builder.push<DependentTemplateSpecializationTypeLoc>(T);
944  SpecTL.setTemplateKeywordLoc(TemplateKWLoc);
945  SpecTL.setTemplateNameLoc(TemplateNameLoc);
946  SpecTL.setLAngleLoc(LAngleLoc);
947  SpecTL.setRAngleLoc(RAngleLoc);
948  for (unsigned I = 0, N = TemplateArgs.size(); I != N; ++I)
949  SpecTL.setArgLocInfo(I, TemplateArgs[I].getLocInfo());
950 
951  SS.Extend(Context, TemplateKWLoc, Builder.getTypeLocInContext(Context, T),
952  CCLoc);
953  return false;
954  }
955 
956  // If we assumed an undeclared identifier was a template name, try to
957  // typo-correct it now.
958  if (Template.getAsAssumedTemplateName() &&
959  resolveAssumedTemplateNameAsType(S, Template, TemplateNameLoc))
960  return true;
961 
962  TemplateDecl *TD = Template.getAsTemplateDecl();
963  if (Template.getAsOverloadedTemplate() || DTN ||
964  isa<FunctionTemplateDecl>(TD) || isa<VarTemplateDecl>(TD)) {
965  SourceRange R(TemplateNameLoc, RAngleLoc);
966  if (SS.getRange().isValid())
967  R.setBegin(SS.getRange().getBegin());
968 
969  Diag(CCLoc, diag::err_non_type_template_in_nested_name_specifier)
970  << (TD && isa<VarTemplateDecl>(TD)) << Template << R;
971  NoteAllFoundTemplates(Template);
972  return true;
973  }
974 
975  // We were able to resolve the template name to an actual template.
976  // Build an appropriate nested-name-specifier.
977  QualType T = CheckTemplateIdType(Template, TemplateNameLoc, TemplateArgs);
978  if (T.isNull())
979  return true;
980 
981  // Alias template specializations can produce types which are not valid
982  // nested name specifiers.
983  if (!T->isDependentType() && !T->getAs<TagType>()) {
984  Diag(TemplateNameLoc, diag::err_nested_name_spec_non_tag) << T;
985  NoteAllFoundTemplates(Template);
986  return true;
987  }
988 
989  // Provide source-location information for the template specialization type.
990  TypeLocBuilder Builder;
992  = Builder.push<TemplateSpecializationTypeLoc>(T);
993  SpecTL.setTemplateKeywordLoc(TemplateKWLoc);
994  SpecTL.setTemplateNameLoc(TemplateNameLoc);
995  SpecTL.setLAngleLoc(LAngleLoc);
996  SpecTL.setRAngleLoc(RAngleLoc);
997  for (unsigned I = 0, N = TemplateArgs.size(); I != N; ++I)
998  SpecTL.setArgLocInfo(I, TemplateArgs[I].getLocInfo());
999 
1000 
1001  SS.Extend(Context, TemplateKWLoc, Builder.getTypeLocInContext(Context, T),
1002  CCLoc);
1003  return false;
1004 }
1005 
1006 namespace {
1007  /// A structure that stores a nested-name-specifier annotation,
1008  /// including both the nested-name-specifier
1009  struct NestedNameSpecifierAnnotation {
1010  NestedNameSpecifier *NNS;
1011  };
1012 }
1013 
1015  if (SS.isEmpty() || SS.isInvalid())
1016  return nullptr;
1017 
1018  void *Mem = Context.Allocate(
1019  (sizeof(NestedNameSpecifierAnnotation) + SS.location_size()),
1020  alignof(NestedNameSpecifierAnnotation));
1021  NestedNameSpecifierAnnotation *Annotation
1022  = new (Mem) NestedNameSpecifierAnnotation;
1023  Annotation->NNS = SS.getScopeRep();
1024  memcpy(Annotation + 1, SS.location_data(), SS.location_size());
1025  return Annotation;
1026 }
1027 
1029  SourceRange AnnotationRange,
1030  CXXScopeSpec &SS) {
1031  if (!AnnotationPtr) {
1032  SS.SetInvalid(AnnotationRange);
1033  return;
1034  }
1035 
1036  NestedNameSpecifierAnnotation *Annotation
1037  = static_cast<NestedNameSpecifierAnnotation *>(AnnotationPtr);
1038  SS.Adopt(NestedNameSpecifierLoc(Annotation->NNS, Annotation + 1));
1039 }
1040 
1042  assert(SS.isSet() && "Parser passed invalid CXXScopeSpec.");
1043 
1044  // Don't enter a declarator context when the current context is an Objective-C
1045  // declaration.
1046  if (isa<ObjCContainerDecl>(CurContext) || isa<ObjCMethodDecl>(CurContext))
1047  return false;
1048 
1049  NestedNameSpecifier *Qualifier = SS.getScopeRep();
1050 
1051  // There are only two places a well-formed program may qualify a
1052  // declarator: first, when defining a namespace or class member
1053  // out-of-line, and second, when naming an explicitly-qualified
1054  // friend function. The latter case is governed by
1055  // C++03 [basic.lookup.unqual]p10:
1056  // In a friend declaration naming a member function, a name used
1057  // in the function declarator and not part of a template-argument
1058  // in a template-id is first looked up in the scope of the member
1059  // function's class. If it is not found, or if the name is part of
1060  // a template-argument in a template-id, the look up is as
1061  // described for unqualified names in the definition of the class
1062  // granting friendship.
1063  // i.e. we don't push a scope unless it's a class member.
1064 
1065  switch (Qualifier->getKind()) {
1069  // These are always namespace scopes. We never want to enter a
1070  // namespace scope from anything but a file context.
1072 
1077  // These are never namespace scopes.
1078  return true;
1079  }
1080 
1081  llvm_unreachable("Invalid NestedNameSpecifier::Kind!");
1082 }
1083 
1084 /// ActOnCXXEnterDeclaratorScope - Called when a C++ scope specifier (global
1085 /// scope or nested-name-specifier) is parsed, part of a declarator-id.
1086 /// After this method is called, according to [C++ 3.4.3p3], names should be
1087 /// looked up in the declarator-id's scope, until the declarator is parsed and
1088 /// ActOnCXXExitDeclaratorScope is called.
1089 /// The 'SS' should be a non-empty valid CXXScopeSpec.
1091  assert(SS.isSet() && "Parser passed invalid CXXScopeSpec.");
1092 
1093  if (SS.isInvalid()) return true;
1094 
1095  DeclContext *DC = computeDeclContext(SS, true);
1096  if (!DC) return true;
1097 
1098  // Before we enter a declarator's context, we need to make sure that
1099  // it is a complete declaration context.
1100  if (!DC->isDependentContext() && RequireCompleteDeclContext(SS, DC))
1101  return true;
1102 
1103  EnterDeclaratorContext(S, DC);
1104 
1105  // Rebuild the nested name specifier for the new scope.
1106  if (DC->isDependentContext())
1108 
1109  return false;
1110 }
1111 
1112 /// ActOnCXXExitDeclaratorScope - Called when a declarator that previously
1113 /// invoked ActOnCXXEnterDeclaratorScope(), is finished. 'SS' is the same
1114 /// CXXScopeSpec that was passed to ActOnCXXEnterDeclaratorScope as well.
1115 /// Used to indicate that names should revert to being looked up in the
1116 /// defining scope.
1118  assert(SS.isSet() && "Parser passed invalid CXXScopeSpec.");
1119  if (SS.isInvalid())
1120  return;
1121  assert(!SS.isInvalid() && computeDeclContext(SS, true) &&
1122  "exiting declarator scope we never really entered");
1124 }
clang::SourceRange::setBegin
void setBegin(SourceLocation b)
Definition: SourceLocation.h:222
clang::DependentTemplateSpecializationTypeLoc::setTemplateKeywordLoc
void setTemplateKeywordLoc(SourceLocation Loc)
Definition: TypeLoc.h:2439
clang::DecltypeTypeLoc::setRParenLoc
void setRParenLoc(SourceLocation Loc)
Definition: TypeLoc.h:2040
clang::TemplateSpecializationTypeLoc
Definition: TypeLoc.h:1606
clang::Sema::resolveAssumedTemplateNameAsType
bool resolveAssumedTemplateNameAsType(Scope *S, TemplateName &Name, SourceLocation NameLoc, bool Diagnose=true)
Definition: SemaTemplate.cpp:4040
clang::Sema::CurContext
DeclContext * CurContext
CurContext - This is the current declaration context of parsing.
Definition: Sema.h:421
clang::Sema::isDependentScopeSpecifier
bool isDependentScopeSpecifier(const CXXScopeSpec &SS)
Definition: SemaCXXScopeSpec.cpp:167
clang::OpaquePtr::get
PtrTy get() const
Definition: Ownership.h:80
clang::Sema::LookupNamespaceName
@ LookupNamespaceName
Look up a namespace name within a C++ using directive or namespace alias definition,...
Definition: Sema.h:4270
clang::Sema::MissingImportKind::PartialSpecialization
@ PartialSpecialization
clang::NestedNameSpecifier::Identifier
@ Identifier
An identifier, stored as an IdentifierInfo*.
Definition: NestedNameSpecifier.h:81
clang::Sema::NoteAllFoundTemplates
void NoteAllFoundTemplates(TemplateName Name)
Definition: SemaTemplate.cpp:3569
clang::Sema::RebuildNestedNameSpecifierInCurrentInstantiation
bool RebuildNestedNameSpecifierInCurrentInstantiation(CXXScopeSpec &SS)
Definition: SemaTemplate.cpp:11176
clang::NestedNameSpecifier::getAsRecordDecl
CXXRecordDecl * getAsRecordDecl() const
Retrieve the record declaration stored in this nested name specifier.
Definition: NestedNameSpecifier.cpp:185
clang::ASTContext::getTypeDeclType
QualType getTypeDeclType(const TypeDecl *Decl, const TypeDecl *PrevDecl=nullptr) const
Return the unique reference to the type for the specified type declaration.
Definition: ASTContext.h:1583
clang::Sema::ActOnCXXNestedNameSpecifier
bool ActOnCXXNestedNameSpecifier(Scope *S, NestedNameSpecInfo &IdInfo, bool EnteringContext, CXXScopeSpec &SS, bool *IsCorrectedToColon=nullptr, bool OnlyNamespace=false)
The parser has parsed a nested-name-specifier 'identifier::'.
Definition: SemaCXXScopeSpec.cpp:855
TypeLocBuilder.h
clang::NestedNameSpecifier::Super
@ Super
Microsoft's '__super' specifier, stored as a CXXRecordDecl* of the class it appeared in.
Definition: NestedNameSpecifier.h:101
clang::CXXRecordDecl::hasAnyDependentBases
bool hasAnyDependentBases() const
Determine whether this class has any dependent base classes which are not the current instantiation.
Definition: DeclCXX.cpp:567
clang::Sema::DiagnoseUseOfDecl
bool DiagnoseUseOfDecl(NamedDecl *D, ArrayRef< SourceLocation > Locs, const ObjCInterfaceDecl *UnknownObjCClass=nullptr, bool ObjCPropertyAccess=false, bool AvoidPartialAvailabilityChecks=false, ObjCInterfaceDecl *ClassReciever=nullptr, bool SkipTrailingRequiresClause=false)
Determine whether the use of this declaration is valid, and emit any corresponding diagnostics.
Definition: SemaExpr.cpp:221
clang::DecltypeTypeLoc
Definition: TypeLoc.h:2030
clang::LookupResult::setLookupName
void setLookupName(DeclarationName Name)
Sets the name to look up.
Definition: Lookup.h:248
clang::MemberSpecializationInfo
Provides information a specialization of a member of a class template, which may be a member function...
Definition: DeclTemplate.h:630
clang::CXXScopeSpec::Adopt
void Adopt(NestedNameSpecifierLoc Other)
Adopt an existing nested-name-specifier (with source-range information).
Definition: DeclSpec.cpp:132
clang::SourceRange
A trivial tuple used to represent a source range.
Definition: SourceLocation.h:210
clang::TemplateSpecializationTypeLoc::setTemplateKeywordLoc
void setTemplateKeywordLoc(SourceLocation Loc)
Definition: TypeLoc.h:1616
clang::DeclContext
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
Definition: DeclBase.h:1389
clang::LookupResult::isSingleResult
bool isSingleResult() const
Determines if this names a single result which is not an unresolved value using decl.
Definition: Lookup.h:308
clang::TypoCorrection
Simple class containing the result of Sema::CorrectTypo.
Definition: TypoCorrection.h:42
clang::NamespaceAliasDecl
Represents a C++ namespace alias.
Definition: DeclCXX.h:3021
clang::NestedNameSpecifier::isDependent
bool isDependent() const
Whether this nested name specifier refers to a dependent type or not.
Definition: NestedNameSpecifier.cpp:234
SemaInternal.h
clang::Sema::RequireCompleteDeclContext
bool RequireCompleteDeclContext(CXXScopeSpec &SS, DeclContext *DC)
Require that the context specified by SS be complete.
Definition: SemaCXXScopeSpec.cpp:199
clang::NestedNameSpecifier::NamespaceAlias
@ NamespaceAlias
A namespace alias, stored as a NamespaceAliasDecl*.
Definition: NestedNameSpecifier.h:87
Lookup.h
clang::SourceLocation
Encodes a location in the source.
Definition: SourceLocation.h:86
clang::DeclSpec::TST_error
static const TST TST_error
Definition: DeclSpec.h:306
clang::NamedDecl
This represents a decl that may have a name.
Definition: Decl.h:247
clang::SourceRange::getBegin
SourceLocation getBegin() const
Definition: SourceLocation.h:219
clang::NamedDecl::getUnderlyingDecl
NamedDecl * getUnderlyingDecl()
Looks through UsingDecls and ObjCCompatibleAliasDecls for the underlying named decl.
Definition: Decl.h:459
clang::LookupResult::clear
LLVM_ATTRIBUTE_REINITIALIZES void clear()
Clears out any current state.
Definition: Lookup.h:580
clang::DeclSpec::getRepAsExpr
Expr * getRepAsExpr() const
Definition: DeclSpec.h:513
clang::QualType
A (possibly-)qualified type.
Definition: Type.h:737
clang::TypeDecl::getTypeForDecl
const Type * getTypeForDecl() const
Definition: Decl.h:3257
clang::TemplateName::getAsTemplateDecl
TemplateDecl * getAsTemplateDecl() const
Retrieve the underlying template declaration that this template name refers to, if known.
Definition: TemplateName.cpp:146
clang::CXXScopeSpec::location_size
unsigned location_size() const
Retrieve the size of the data associated with source-location information.
Definition: DeclSpec.h:223
clang::NestedNameSpecifier
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
Definition: NestedNameSpecifier.h:50
clang::LookupResult
Represents the results of name lookup.
Definition: Lookup.h:46
clang::ast_matchers::type
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
Definition: ASTMatchersInternal.cpp:773
clang::Sema::Diag
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID, bool DeferHint=false)
Emit a diagnostic.
Definition: Sema.cpp:1881
clang::DependentTemplateSpecializationTypeLoc::setRAngleLoc
void setRAngleLoc(SourceLocation Loc)
Definition: TypeLoc.h:2463
memcpy
__DEVICE__ void * memcpy(void *__a, const void *__b, size_t __c)
Definition: __clang_cuda_device_functions.h:1549
clang::TemplateSpecializationType
Represents a type template specialization; the template must be a class template, a type alias templa...
Definition: Type.h:5354
clang::SourceRange::isValid
bool isValid() const
Definition: SourceLocation.h:225
clang::Sema::CheckTemplateIdType
QualType CheckTemplateIdType(TemplateName Template, SourceLocation TemplateLoc, TemplateArgumentListInfo &TemplateArgs)
Definition: SemaTemplate.cpp:3817
clang::Sema::LookupQualifiedName
bool LookupQualifiedName(LookupResult &R, DeclContext *LookupCtx, bool InUnqualifiedLookup=false)
Perform qualified name lookup into a given context.
Definition: SemaLookup.cpp:2404
clang::TemplateName::getAsOverloadedTemplate
OverloadedTemplateStorage * getAsOverloadedTemplate() const
Retrieve the underlying, overloaded function template declarations that this template name refers to,...
Definition: TemplateName.cpp:167
clang::TagType
Definition: Type.h:4792
DeclSpec.h
clang::CXXScopeSpec
Represents a C++ nested-name-specifier or a global scope specifier.
Definition: DeclSpec.h:65
clang::ClassTemplatePartialSpecializationDecl
Definition: DeclTemplate.h:2101
clang::Sema::ActOnCXXGlobalScopeSpecifier
bool ActOnCXXGlobalScopeSpecifier(SourceLocation CCLoc, CXXScopeSpec &SS)
The parser has parsed a global nested-name-specifier '::'.
Definition: SemaCXXScopeSpec.cpp:286
clang::ASTContext::getUsingType
QualType getUsingType(const UsingShadowDecl *Found, QualType Underlying) const
Definition: ASTContext.cpp:4732
clang::DeclarationName
The name of a declaration.
Definition: DeclarationName.h:144
clang::ASTContext::getTranslationUnitDecl
TranslationUnitDecl * getTranslationUnitDecl() const
Definition: ASTContext.h:1089
clang::LookupResult::getNameLoc
SourceLocation getNameLoc() const
Gets the location of the identifier.
Definition: Lookup.h:632
clang::DeclSpec::getTypeSpecTypeLoc
SourceLocation getTypeSpecTypeLoc() const
Definition: DeclSpec.h:533
clang::CXXScopeSpec::MakeSuper
void MakeSuper(ASTContext &Context, CXXRecordDecl *RD, SourceLocation SuperLoc, SourceLocation ColonColonLoc)
Turns this (empty) nested-name-specifier into '__super' nested-name-specifier.
Definition: DeclSpec.cpp:114
clang::EnumDecl
Represents an enum.
Definition: Decl.h:3705
clang::Sema::Context
ASTContext & Context
Definition: Sema.h:409
clang::Type
The base class of the type hierarchy.
Definition: Type.h:1565
clang::LookupResult::addDecl
void addDecl(NamedDecl *D)
Add a declaration to these results with its natural access.
Definition: Lookup.h:452
clang::CXXScopeSpec::clear
void clear()
Definition: DeclSpec.h:213
clang::CXXScopeSpec::isSet
bool isSet() const
Deprecated.
Definition: DeclSpec.h:211
clang::Sema::getLangOpts
const LangOptions & getLangOpts() const
Definition: Sema.h:1630
clang::Sema::hasReachableDefinition
bool hasReachableDefinition(NamedDecl *D, NamedDecl **Suggested, bool OnlyNeedComplete=false)
Determine if D has a reachable definition.
Definition: SemaType.cpp:8838
clang::ASTContext::Allocate
void * Allocate(size_t Size, unsigned Align=8) const
Definition: ASTContext.h:734
clang::TemplateSpecializationTypeLoc::setLAngleLoc
void setLAngleLoc(SourceLocation Loc)
Definition: TypeLoc.h:1624
clang::Sema::RequireCompleteType
bool RequireCompleteType(SourceLocation Loc, QualType T, CompleteTypeKind Kind, TypeDiagnoser &Diagnoser)
Ensure that the type T is a complete type.
Definition: SemaType.cpp:8699
llvm::MutableArrayRef
Definition: LLVM.h:35
clang::TypeLocBuilder::push
TyLocType push(QualType T)
Pushes space for a new TypeLoc of the given type.
Definition: TypeLocBuilder.h:99
Template.h
clang::Sema::NestedNameSpecInfo::IdentifierLoc
SourceLocation IdentifierLoc
The location of the identifier.
Definition: Sema.h:6889
clang::NestedNameSpecifier::Namespace
@ Namespace
A namespace, stored as a NamespaceDecl*.
Definition: NestedNameSpecifier.h:84
clang::TypeLocBuilder::pushTypeSpec
TypeSpecTypeLoc pushTypeSpec(QualType T)
Pushes space for a typespec TypeLoc.
Definition: TypeLocBuilder.h:73
clang::DependentTemplateSpecializationTypeLoc::setArgLocInfo
void setArgLocInfo(unsigned i, TemplateArgumentLocInfo AI)
Definition: TypeLoc.h:2471
clang::Sema::ShouldEnterDeclaratorScope
bool ShouldEnterDeclaratorScope(Scope *S, const CXXScopeSpec &SS)
Definition: SemaCXXScopeSpec.cpp:1041
clang::RecordType
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
Definition: Type.h:4816
clang::NestedNameSpecifier::getAsIdentifier
IdentifierInfo * getAsIdentifier() const
Retrieve the identifier stored in this nested name specifier.
Definition: NestedNameSpecifier.h:176
clang::SubstTemplateTypeParmPackTypeLoc
Wrapper for substituted template type parameters.
Definition: TypeLoc.h:849
clang::Sema::SaveNestedNameSpecifierAnnotation
void * SaveNestedNameSpecifierAnnotation(CXXScopeSpec &SS)
Given a C++ nested-name-specifier, produce an annotation value that the parser can use later to recon...
Definition: SemaCXXScopeSpec.cpp:1014
DeclTemplate.h
clang::DependentTemplateSpecializationTypeLoc::setQualifierLoc
void setQualifierLoc(NestedNameSpecifierLoc QualifierLoc)
Definition: TypeLoc.h:2419
clang::TemplateArgumentListInfo
A convenient class for passing around template argument information.
Definition: TemplateBase.h:563
clang::Sema::MarkAnyDeclReferenced
void MarkAnyDeclReferenced(SourceLocation Loc, Decl *D, bool MightBeOdrUse)
Perform marking for a reference to an arbitrary declaration.
Definition: SemaExpr.cpp:19787
clang::Sema::ActOnCXXExitDeclaratorScope
void ActOnCXXExitDeclaratorScope(Scope *S, const CXXScopeSpec &SS)
ActOnCXXExitDeclaratorScope - Called when a declarator that previously invoked ActOnCXXEnterDeclarato...
Definition: SemaCXXScopeSpec.cpp:1117
clang::CXXRecordDecl::isCurrentInstantiation
bool isCurrentInstantiation(const DeclContext *CurContext) const
Determine whether this dependent class is a current instantiation, when viewed from within the given ...
Definition: CXXInheritance.cpp:116
clang::DeclSpec::getTypeSpecType
TST getTypeSpecType() const
Definition: DeclSpec.h:495
clang::Scope
Scope - A scope is a transient data structure that is used while parsing the program.
Definition: Scope.h:40
clang::CXXScopeSpec::SetInvalid
void SetInvalid(SourceRange R)
Indicate that this nested-name-specifier is invalid.
Definition: DeclSpec.h:201
clang::Sema::EnterDeclaratorContext
void EnterDeclaratorContext(Scope *S, DeclContext *DC)
EnterDeclaratorContext - Used when we must lookup names in the context of a declarator's nested name ...
Definition: SemaDecl.cpp:1377
clang::CXXScopeSpec::Extend
void Extend(ASTContext &Context, SourceLocation TemplateKWLoc, TypeLoc TL, SourceLocation ColonColonLoc)
Extend the current nested-name-specifier by another nested-name-specifier component of the form 'type...
Definition: DeclSpec.cpp:54
clang::Sema::LookupName
bool LookupName(LookupResult &R, Scope *S, bool AllowBuiltinCreation=false, bool ForceNoCPlusPlus=false)
Perform unqualified name lookup starting from a given scope.
Definition: SemaLookup.cpp:2165
clang::SourceRange::getEnd
SourceLocation getEnd() const
Definition: SourceLocation.h:220
ContextType
enum clang::format::@1192::AnnotatingParser::Context::@327 ContextType
clang::CPlusPlus
@ CPlusPlus
Definition: LangStandard.h:53
NestedNameSpecifier.h
clang::ASTContext::getDependentTemplateSpecializationType
QualType getDependentTemplateSpecializationType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier *NNS, const IdentifierInfo *Name, ArrayRef< TemplateArgumentLoc > Args) const
Definition: ASTContext.cpp:5156
clang::DependentTemplateName::isIdentifier
bool isIdentifier() const
Determine whether this template name refers to an identifier.
Definition: TemplateName.h:548
clang::Type::getAs
const T * getAs() const
Member-template getAs<specific type>'.
Definition: Type.h:7386
clang::CXXRecordDecl::getNumBases
unsigned getNumBases() const
Retrieves the number of base classes of this class.
Definition: DeclCXX.h:591
clang::Sema::FindFirstQualifierInScope
NamedDecl * FindFirstQualifierInScope(Scope *S, NestedNameSpecifier *NNS)
If the given nested-name-specifier begins with a bare identifier (e.g., Base::), perform name lookup ...
Definition: SemaCXXScopeSpec.cpp:372
clang::Sema::NestedNameSpecInfo::ObjectType
ParsedType ObjectType
The type of the object, if we're parsing nested-name-specifier in a member access expression.
Definition: Sema.h:6883
clang::Decl::getCanonicalDecl
virtual Decl * getCanonicalDecl()
Retrieves the "canonical" declaration of the given declaration.
Definition: DeclBase.h:943
clang::EnumDecl::getMemberSpecializationInfo
MemberSpecializationInfo * getMemberSpecializationInfo() const
If this enumeration is an instantiation of a member enumeration of a class template specialization,...
Definition: Decl.h:3964
clang::Sema::PDiag
PartialDiagnostic PDiag(unsigned DiagID=0)
Build a partial diagnostic.
Definition: SemaInternal.h:24
clang::Sema::GetTypeFromParser
static QualType GetTypeFromParser(ParsedType Ty, TypeSourceInfo **TInfo=nullptr)
Definition: SemaType.cpp:3103
clang::TemplateName::getAsAssumedTemplateName
AssumedTemplateStorage * getAsAssumedTemplateName() const
Retrieve information on a name that has been assumed to be a template-name in order to permit a call ...
Definition: TemplateName.cpp:175
clang::InjectedClassNameTypeLoc
Wrapper for source info for injected class names of class templates.
Definition: TypeLoc.h:690
ASTContext.h
clang::Sema::NestedNameSpecInfo::Identifier
IdentifierInfo * Identifier
The identifier preceding the '::'.
Definition: Sema.h:6886
getCurrentInstantiationOf
static CXXRecordDecl * getCurrentInstantiationOf(QualType T, DeclContext *CurContext)
Find the current instantiation that associated with the given type.
Definition: SemaCXXScopeSpec.cpp:27
clang::RecordTypeLoc
Wrapper for source info for record types.
Definition: TypeLoc.h:727
clang::TagDecl
Represents the declaration of a struct/union/class/enum.
Definition: Decl.h:3423
clang::Type::getCanonicalTypeInternal
QualType getCanonicalTypeInternal() const
Definition: Type.h:2584
clang::ASTContext::getCanonicalType
CanQualType getCanonicalType(QualType T) const
Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...
Definition: ASTContext.h:2528
clang::TypeDecl
Represents a declaration of a type.
Definition: Decl.h:3233
clang::NestedNameSpecifier::Global
@ Global
The global specifier '::'. There is no stored value.
Definition: NestedNameSpecifier.h:97
clang::NestedNameSpecifierLoc
A C++ nested-name-specifier augmented with source location information.
Definition: NestedNameSpecifier.h:243
clang::LookupResult::getLookupName
DeclarationName getLookupName() const
Gets the name to look up.
Definition: Lookup.h:243
ExprCXX.h
clang::DeclContext::isRecord
bool isRecord() const
Definition: DeclBase.h:2002
clang::TagDecl::isCompleteDefinition
bool isCompleteDefinition() const
Return true if this decl has its body fully specified.
Definition: Decl.h:3528
clang::DependentTemplateSpecializationTypeLoc::setTemplateNameLoc
void setTemplateNameLoc(SourceLocation Loc)
Definition: TypeLoc.h:2447
clang::Sema::BuildCXXNestedNameSpecifier
bool BuildCXXNestedNameSpecifier(Scope *S, NestedNameSpecInfo &IdInfo, bool EnteringContext, CXXScopeSpec &SS, NamedDecl *ScopeLookupResult, bool ErrorRecoveryLookup, bool *IsCorrectedToColon=nullptr, bool OnlyNamespace=false)
Build a new nested-name-specifier for "identifier::", as described by ActOnCXXNestedNameSpecifier.
Definition: SemaCXXScopeSpec.cpp:497
clang::Type::isEnumeralType
bool isEnumeralType() const
Definition: Type.h:6977
clang::Sema::diagnoseMissingImport
void diagnoseMissingImport(SourceLocation Loc, NamedDecl *Decl, MissingImportKind MIK, bool Recover=true)
Diagnose that the specified declaration needs to be visible but isn't, and suggest a module import th...
Definition: SemaLookup.cpp:5648
clang::DependentTemplateSpecializationTypeLoc::setLAngleLoc
void setLAngleLoc(SourceLocation Loc)
Definition: TypeLoc.h:2455
clang::NestedNameSpecifier::TypeSpecWithTemplate
@ TypeSpecWithTemplate
A type that was preceded by the 'template' keyword, stored as a Type*.
Definition: NestedNameSpecifier.h:94
clang::CXXScopeSpec::getWithLocInContext
NestedNameSpecifierLoc getWithLocInContext(ASTContext &Context) const
Retrieve a nested-name-specifier with location information, copied into the given AST context.
Definition: DeclSpec.cpp:152
clang::TypeLocBuilder
Definition: TypeLocBuilder.h:22
clang::DependentTemplateSpecializationTypeLoc::setElaboratedKeywordLoc
void setElaboratedKeywordLoc(SourceLocation Loc)
Definition: TypeLoc.h:2407
clang::TagType::getDecl
TagDecl * getDecl() const
Definition: Type.cpp:3537
clang::DependentTemplateSpecializationTypeLoc
Definition: TypeLoc.h:2397
clang::ETK_None
@ ETK_None
No keyword precedes the qualified type name.
Definition: Type.h:5573
clang::Sema::IsInvalidUnlessNestedName
bool IsInvalidUnlessNestedName(Scope *S, CXXScopeSpec &SS, NestedNameSpecInfo &IdInfo, bool EnteringContext)
IsInvalidUnlessNestedName - This method is used for error recovery purposes to determine whether the ...
Definition: SemaCXXScopeSpec.cpp:900
clang::LookupResult::setContextRange
void setContextRange(SourceRange SR)
Sets a 'context' source range.
Definition: Lookup.h:619
clang::Sema::CorrectTypo
TypoCorrection CorrectTypo(const DeclarationNameInfo &Typo, Sema::LookupNameKind LookupKind, Scope *S, CXXScopeSpec *SS, CorrectionCandidateCallback &CCC, CorrectTypoKind Mode, DeclContext *MemberContext=nullptr, bool EnteringContext=false, const ObjCObjectPointerType *OPT=nullptr, bool RecordFailure=true)
Try to "correct" a typo in the source code by finding visible declarations whose names are similar to...
Definition: SemaLookup.cpp:5325
clang::OpaquePtr< QualType >
clang::DependentTemplateName
Represents a dependent template name that cannot be resolved prior to template instantiation.
Definition: TemplateName.h:489
clang::Sema::ActOnCXXEnterDeclaratorScope
bool ActOnCXXEnterDeclaratorScope(Scope *S, CXXScopeSpec &SS)
ActOnCXXEnterDeclaratorScope - Called when a C++ scope specifier (global scope or nested-name-specifi...
Definition: SemaCXXScopeSpec.cpp:1090
clang::Sema::diagnoseTypo
void diagnoseTypo(const TypoCorrection &Correction, const PartialDiagnostic &TypoDiag, bool ErrorRecovery=true)
Definition: SemaLookup.cpp:5622
clang::Sema::getTemplateInstantiationArgs
MultiLevelTemplateArgumentList getTemplateInstantiationArgs(const NamedDecl *D, bool Final=false, const TemplateArgumentList *Innermost=nullptr, bool RelativeToPrimary=false, const FunctionDecl *Pattern=nullptr, bool ForConstraintInstantiation=false, bool SkipForSpecialization=false)
Retrieve the template argument list(s) that should be used to instantiate the definition of the given...
Definition: SemaTemplateInstantiate.cpp:284
clang::NamespaceAliasDecl::getNamespace
NamespaceDecl * getNamespace()
Retrieve the namespace declaration aliased by this directive.
Definition: DeclCXX.h:3094
clang::TemplateArgumentListInfo::arguments
llvm::ArrayRef< TemplateArgumentLoc > arguments() const
Definition: TemplateBase.h:591
clang::CXXRecordDecl
Represents a C++ struct/union/class.
Definition: DeclCXX.h:254
clang::TemplateSpecializationTypeLoc::setTemplateNameLoc
void setTemplateNameLoc(SourceLocation Loc)
Definition: TypeLoc.h:1657
clang::EnumDecl::getInstantiatedFromMemberEnum
EnumDecl * getInstantiatedFromMemberEnum() const
Returns the enumeration (declared within the template) from which this enumeration type was instantia...
Definition: Decl.cpp:4625
clang::NestedNameSpecifier::getAsNamespaceAlias
NamespaceAliasDecl * getAsNamespaceAlias() const
Retrieve the namespace alias stored in this nested name specifier.
Definition: NestedNameSpecifier.cpp:177
clang::DeclContext::getRedeclContext
DeclContext * getRedeclContext()
getRedeclContext - Retrieve the context in which an entity conflicts with other entities of the same ...
Definition: DeclBase.cpp:1828
clang::Sema::computeDeclContext
DeclContext * computeDeclContext(QualType T)
Compute the DeclContext that is associated with the given type.
Definition: SemaCXXScopeSpec.cpp:53
clang::Sema::CTK_ErrorRecovery
@ CTK_ErrorRecovery
Definition: Sema.h:4485
clang::SubstTemplateTypeParmTypeLoc
Wrapper for substituted template type parameters.
Definition: TypeLoc.h:842
clang::Type::isDependentType
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
Definition: Type.h:2304
clang::Sema::getCurrentInstantiationOf
CXXRecordDecl * getCurrentInstantiationOf(NestedNameSpecifier *NNS)
If the given nested name specifier refers to the current instantiation, return the declaration that c...
Definition: SemaCXXScopeSpec.cpp:179
clang::LookupResult::suppressDiagnostics
void suppressDiagnostics()
Suppress the diagnostics that would normally fire because of this lookup.
Definition: Lookup.h:609
clang::LookupResult::empty
bool empty() const
Return true if no decls were found.
Definition: Lookup.h:339
clang::NestedNameSpecifier::getAsNamespace
NamespaceDecl * getAsNamespace() const
Retrieve the namespace stored in this nested name specifier.
Definition: NestedNameSpecifier.cpp:169
clang::TagDecl::isBeingDefined
bool isBeingDefined() const
Return true if this decl is currently being defined.
Definition: Decl.h:3548
clang::ClassTemplateDecl
Declaration of a class template.
Definition: DeclTemplate.h:2273
clang::UnresolvedUsingTypeLoc
Wrapper for source info for unresolved typename using decls.
Definition: TypeLoc.h:701
clang::DecltypeTypeLoc::setDecltypeLoc
void setDecltypeLoc(SourceLocation Loc)
Definition: TypeLoc.h:2037
clang::TemplateName
Represents a C++ template name within the type system.
Definition: TemplateName.h:201
clang::CXXScopeSpec::location_data
char * location_data() const
Retrieve the data associated with the source-location information.
Definition: DeclSpec.h:219
clang::TemplateArgumentListInfo::size
unsigned size() const
Definition: TemplateBase.h:585
clang::DeclContext::getParent
DeclContext * getParent()
getParent - Returns the containing DeclContext.
Definition: DeclBase.h:1923
clang::EnumTypeLoc
Wrapper for source info for enum types.
Definition: TypeLoc.h:735
clang::TemplateDecl
The base class of all kinds of template declarations (e.g., class, function, etc.).
Definition: DeclTemplate.h:408
clang::Sema::ActOnCXXNestedNameSpecifierDecltype
bool ActOnCXXNestedNameSpecifierDecltype(CXXScopeSpec &SS, const DeclSpec &DS, SourceLocation ColonColonLoc)
Definition: SemaCXXScopeSpec.cpp:867
clang::QualType::isNull
bool isNull() const
Return true if this QualType doesn't point to a type yet.
Definition: Type.h:802
clang::DependentTemplateName::getIdentifier
const IdentifierInfo * getIdentifier() const
Returns the identifier to which this template name refers.
Definition: TemplateName.h:551
clang::Sema
Sema - This implements semantic analysis and AST building for C.
Definition: Sema.h:358
clang::CXXScopeSpec::MakeGlobal
void MakeGlobal(ASTContext &Context, SourceLocation ColonColonLoc)
Turn this (empty) nested-name-specifier into the global nested-name-specifier '::'.
Definition: DeclSpec.cpp:104
clang::TSK_ExplicitSpecialization
@ TSK_ExplicitSpecialization
This template specialization was declared or defined by an explicit specialization (C++ [temp....
Definition: Specifiers.h:186
clang::DeclSpec::TST_decltype
static const TST TST_decltype
Definition: DeclSpec.h:294
clang::TemplateTypeParmTypeLoc
Wrapper for template type parameters.
Definition: TypeLoc.h:743
clang::TemplateSpecializationTypeLoc::setArgLocInfo
void setArgLocInfo(unsigned i, TemplateArgumentLocInfo AI)
Definition: TypeLoc.h:1640
clang::TypeLocBuilder::getTypeLocInContext
TypeLoc getTypeLocInContext(ASTContext &Context, QualType T)
Copies the type-location information to the given AST context and returns a TypeLoc referring into th...
Definition: TypeLocBuilder.h:120
clang::DeclContext::isFileContext
bool isFileContext() const
Definition: DeclBase.h:1993
clang::Sema::isAcceptableNestedNameSpecifier
bool isAcceptableNestedNameSpecifier(const NamedDecl *SD, bool *CanCorrect=nullptr)
Determines whether the given declaration is an valid acceptable result for name lookup of a nested-na...
Definition: SemaCXXScopeSpec.cpp:328
clang::Sema::DiagnoseUnknownTypeName
void DiagnoseUnknownTypeName(IdentifierInfo *&II, SourceLocation IILoc, Scope *S, CXXScopeSpec *SS, ParsedType &SuggestedType, bool IsTemplateName=false)
Definition: SemaDecl.cpp:719
clang::Sema::BuildDecltypeType
QualType BuildDecltypeType(Expr *E, bool AsUnevaluated=true)
If AsUnevaluated is false, E is treated as though it were an evaluated context, such as when building...
Definition: SemaType.cpp:9273
clang::Sema::InstantiateEnum
bool InstantiateEnum(SourceLocation PointOfInstantiation, EnumDecl *Instantiation, EnumDecl *Pattern, const MultiLevelTemplateArgumentList &TemplateArgs, TemplateSpecializationKind TSK)
Instantiate the definition of an enum from a given pattern.
Definition: SemaTemplateInstantiate.cpp:3302
clang::Sema::isNonTypeNestedNameSpecifier
bool isNonTypeNestedNameSpecifier(Scope *S, CXXScopeSpec &SS, NestedNameSpecInfo &IdInfo)
Definition: SemaCXXScopeSpec.cpp:397
clang::Sema::getCurScope
Scope * getCurScope() const
Retrieve the parser's current scope.
Definition: Sema.h:13634
clang::Sema::ActOnSuperScopeSpecifier
bool ActOnSuperScopeSpecifier(SourceLocation SuperLoc, SourceLocation ColonColonLoc, CXXScopeSpec &SS)
The parser has parsed a '__super' nested-name-specifier.
Definition: SemaCXXScopeSpec.cpp:292
clang::TemplateSpecializationTypeLoc::setRAngleLoc
void setRAngleLoc(SourceLocation Loc)
Definition: TypeLoc.h:1632
clang::SourceLocation::isInvalid
bool isInvalid() const
Definition: SourceLocation.h:111
clang::Sema::LookupNestedNameSpecifierName
@ LookupNestedNameSpecifierName
Look up of a name that precedes the '::' scope resolution operator in C++.
Definition: Sema.h:4266
PartialDiagnostic.h
clang
Definition: CalledOnceCheck.h:17
clang::NestedNameSpecifier::getAsType
const Type * getAsType() const
Retrieve the type stored in this nested name specifier.
Definition: NestedNameSpecifier.h:196
clang::Sema::translateTemplateArguments
void translateTemplateArguments(const ASTTemplateArgsPtr &In, TemplateArgumentListInfo &Out)
Translates template arguments as provided by the parser into template arguments used by semantic anal...
Definition: SemaTemplate.cpp:959
clang::Sema::NestedNameSpecInfo::CCLoc
SourceLocation CCLoc
The location of the '::'.
Definition: Sema.h:6892
clang::TypoCorrection::getCorrectionDecl
NamedDecl * getCorrectionDecl() const
Gets the pointer to the declaration of the typo correction.
Definition: TypoCorrection.h:151
clang::CXXScopeSpec::getScopeRep
NestedNameSpecifier * getScopeRep() const
Retrieve the representation of the nested-name-specifier.
Definition: DeclSpec.h:78
clang::CorrectionCandidateCallback
Base class for callback objects used by Sema::CorrectTypo to check the validity of a potential typo c...
Definition: TypoCorrection.h:281
clang::Sema::RestoreNestedNameSpecifierAnnotation
void RestoreNestedNameSpecifierAnnotation(void *Annotation, SourceRange AnnotationRange, CXXScopeSpec &SS)
Given an annotation pointer for a nested-name-specifier, restore the nested-name-specifier structure.
Definition: SemaCXXScopeSpec.cpp:1028
clang::DeclSpec::getTypeofParensRange
SourceRange getTypeofParensRange() const
Definition: DeclSpec.h:543
clang::CXXScopeSpec::getLastQualifierNameLoc
SourceLocation getLastQualifierNameLoc() const
Retrieve the location of the name in the last qualifier in this nested name specifier.
Definition: DeclSpec.cpp:145
clang::NestedNameSpecifier::getPrefix
NestedNameSpecifier * getPrefix() const
Return the prefix of this nested name specifier.
Definition: NestedNameSpecifier.h:169
clang::DeclContext::isDependentContext
bool isDependentContext() const
Determines whether this context is dependent on a template parameter.
Definition: DeclBase.cpp:1173
clang::LookupResult::getLookupKind
Sema::LookupNameKind getLookupKind() const
Gets the kind of lookup to perform.
Definition: Lookup.h:253
clang::Sema::isSFINAEContext
Optional< sema::TemplateDeductionInfo * > isSFINAEContext() const
Determines whether we are currently in a context where template argument substitution failures are no...
Definition: SemaTemplateInstantiate.cpp:1010
clang::TemplateName::getAsDependentTemplateName
DependentTemplateName * getAsDependentTemplateName() const
Retrieve the underlying dependent template name structure, if any.
Definition: TemplateName.cpp:205
clang::Sema::ExitDeclaratorContext
void ExitDeclaratorContext(Scope *S)
Definition: SemaDecl.cpp:1412
clang::TypedefNameDecl
Base class for declarations which introduce a typedef-name.
Definition: Decl.h:3275
clang::LookupResult::getFoundDecl
NamedDecl * getFoundDecl() const
Fetch the unique decl found by this lookup.
Definition: Lookup.h:543
clang::LookupResult::getAsSingle
DeclClass * getAsSingle() const
Definition: Lookup.h:533
clang::TypeSpecTypeLoc::setNameLoc
void setNameLoc(SourceLocation Loc)
Definition: TypeLoc.h:527
clang::QualType::getTypePtr
const Type * getTypePtr() const
Retrieves a pointer to the underlying (unqualified) type.
Definition: Type.h:6622
clang::Sema::MissingImportKind::Definition
@ Definition
clang::Sema::RequireCompleteEnumDecl
bool RequireCompleteEnumDecl(EnumDecl *D, SourceLocation L, CXXScopeSpec *SS=nullptr)
Require that the EnumDecl is completed with its enumerators defined or instantiated.
Definition: SemaCXXScopeSpec.cpp:241
clang::CPlusPlus11
@ CPlusPlus11
Definition: LangStandard.h:54
clang::CXXScopeSpec::MakeTrivial
void MakeTrivial(ASTContext &Context, NestedNameSpecifier *Qualifier, SourceRange R)
Make a new nested-name-specifier from incomplete source-location information.
Definition: DeclSpec.cpp:126
clang::NestedNameSpecifier::TypeSpec
@ TypeSpec
A type, stored as a Type*.
Definition: NestedNameSpecifier.h:90
clang::CXXRecordDecl::isLambda
bool isLambda() const
Determine whether this class describes a lambda function object.
Definition: DeclCXX.h:1000
clang::ASTContext::hasSameType
bool hasSameType(QualType T1, QualType T2) const
Determine whether the given types T1 and T2 are equivalent.
Definition: ASTContext.h:2544
clang::Sema::LookupOrdinaryName
@ LookupOrdinaryName
Ordinary name lookup, which finds ordinary names (functions, variables, typedefs, etc....
Definition: Sema.h:4247
clang::MemberSpecializationInfo::getTemplateSpecializationKind
TemplateSpecializationKind getTemplateSpecializationKind() const
Determine what kind of template specialization this is.
Definition: DeclTemplate.h:652
clang::CXXScopeSpec::isEmpty
bool isEmpty() const
No scope specifier.
Definition: DeclSpec.h:191
clang::Sema::NestedNameSpecInfo
Keeps information about an identifier in a nested-name-spec.
Definition: Sema.h:6880
clang::DependentTemplateName::getQualifier
NestedNameSpecifier * getQualifier() const
Return the nested name specifier that qualifies this name.
Definition: TemplateName.h:545
clang::CXXScopeSpec::getRange
SourceRange getRange() const
Definition: DeclSpec.h:70
clang::NestedNameSpecifier::getKind
SpecifierKind getKind() const
Determine what kind of nested name specifier is stored.
Definition: NestedNameSpecifier.cpp:143
clang::TSK_ImplicitInstantiation
@ TSK_ImplicitInstantiation
This template specialization was implicitly instantiated from a template.
Definition: Specifiers.h:182
clang::DeclContext::isFunctionOrMethod
bool isFunctionOrMethod() const
Definition: DeclBase.h:1975
clang::Decl::getLocation
SourceLocation getLocation() const
Definition: DeclBase.h:432
clang::NamespaceDecl
Represent a C++ namespace.
Definition: Decl.h:542
clang::LookupResult::getLookupNameInfo
const DeclarationNameInfo & getLookupNameInfo() const
Gets the name info to look up.
Definition: Lookup.h:233
clang::IdentifierInfo::isEditorPlaceholder
bool isEditorPlaceholder() const
Return true if this identifier is an editor placeholder.
Definition: IdentifierTable.h:454
clang::ASTContext::getLangOpts
const LangOptions & getLangOpts() const
Definition: ASTContext.h:791
clang::LookupResult::getRepresentativeDecl
NamedDecl * getRepresentativeDecl() const
Fetches a representative decl. Useful for lazy diagnostics.
Definition: Lookup.h:550
clang::FixItHint::CreateReplacement
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:134
clang::DeclSpec
Captures information about "declaration specifiers".
Definition: DeclSpec.h:230
clang::CXXMethodDecl
Represents a static or instance method of a struct/union/class.
Definition: DeclCXX.h:1983
clang::CXXScopeSpec::isInvalid
bool isInvalid() const
An error occurred during parsing of the scope specifier.
Definition: DeclSpec.h:196
clang::LookupResult::isAmbiguous
bool isAmbiguous() const
Definition: Lookup.h:301
clang::TypedefTypeLoc
Wrapper for source info for typedefs.
Definition: TypeLoc.h:679
clang::NamedDecl::getName
StringRef getName() const
Get the name of identifier for this declaration as a StringRef.
Definition: Decl.h:274