clang  14.0.0git
SemaExprMember.cpp
Go to the documentation of this file.
1 //===--- SemaExprMember.cpp - Semantic Analysis for Expressions -----------===//
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 semantic analysis member access expressions.
10 //
11 //===----------------------------------------------------------------------===//
12 #include "clang/Sema/Overload.h"
13 #include "clang/AST/ASTLambda.h"
14 #include "clang/AST/DeclCXX.h"
15 #include "clang/AST/DeclObjC.h"
16 #include "clang/AST/DeclTemplate.h"
17 #include "clang/AST/ExprCXX.h"
18 #include "clang/AST/ExprObjC.h"
19 #include "clang/Lex/Preprocessor.h"
20 #include "clang/Sema/Lookup.h"
21 #include "clang/Sema/Scope.h"
22 #include "clang/Sema/ScopeInfo.h"
24 
25 using namespace clang;
26 using namespace sema;
27 
29 
30 /// Determines if the given class is provably not derived from all of
31 /// the prospective base classes.
32 static bool isProvablyNotDerivedFrom(Sema &SemaRef, CXXRecordDecl *Record,
33  const BaseSet &Bases) {
34  auto BaseIsNotInSet = [&Bases](const CXXRecordDecl *Base) {
35  return !Bases.count(Base->getCanonicalDecl());
36  };
37  return BaseIsNotInSet(Record) && Record->forallBases(BaseIsNotInSet);
38 }
39 
40 enum IMAKind {
41  /// The reference is definitely not an instance member access.
43 
44  /// The reference may be an implicit instance member access.
46 
47  /// The reference may be to an instance member, but it might be invalid if
48  /// so, because the context is not an instance method.
50 
51  /// The reference may be to an instance member, but it is invalid if
52  /// so, because the context is from an unrelated class.
54 
55  /// The reference is definitely an implicit instance member access.
57 
58  /// The reference may be to an unresolved using declaration.
60 
61  /// The reference is a contextually-permitted abstract member reference.
63 
64  /// The reference may be to an unresolved using declaration and the
65  /// context is not an instance method.
67 
68  // The reference refers to a field which is not a member of the containing
69  // class, which is allowed because we're in C++11 mode and the context is
70  // unevaluated.
72 
73  /// All possible referrents are instance members and the current
74  /// context is not an instance method.
76 
77  /// All possible referrents are instance members of an unrelated
78  /// class.
80 };
81 
82 /// The given lookup names class member(s) and is not being used for
83 /// an address-of-member expression. Classify the type of access
84 /// according to whether it's possible that this reference names an
85 /// instance member. This is best-effort in dependent contexts; it is okay to
86 /// conservatively answer "yes", in which case some errors will simply
87 /// not be caught until template-instantiation.
89  const LookupResult &R) {
90  assert(!R.empty() && (*R.begin())->isCXXClassMember());
91 
93 
94  bool isStaticContext = SemaRef.CXXThisTypeOverride.isNull() &&
95  (!isa<CXXMethodDecl>(DC) || cast<CXXMethodDecl>(DC)->isStatic());
96 
97  if (R.isUnresolvableResult())
98  return isStaticContext ? IMA_Unresolved_StaticContext : IMA_Unresolved;
99 
100  // Collect all the declaring classes of instance members we find.
101  bool hasNonInstance = false;
102  bool isField = false;
103  BaseSet Classes;
104  for (NamedDecl *D : R) {
105  // Look through any using decls.
106  D = D->getUnderlyingDecl();
107 
108  if (D->isCXXInstanceMember()) {
109  isField |= isa<FieldDecl>(D) || isa<MSPropertyDecl>(D) ||
110  isa<IndirectFieldDecl>(D);
111 
112  CXXRecordDecl *R = cast<CXXRecordDecl>(D->getDeclContext());
113  Classes.insert(R->getCanonicalDecl());
114  } else
115  hasNonInstance = true;
116  }
117 
118  // If we didn't find any instance members, it can't be an implicit
119  // member reference.
120  if (Classes.empty())
121  return IMA_Static;
122 
123  // C++11 [expr.prim.general]p12:
124  // An id-expression that denotes a non-static data member or non-static
125  // member function of a class can only be used:
126  // (...)
127  // - if that id-expression denotes a non-static data member and it
128  // appears in an unevaluated operand.
129  //
130  // This rule is specific to C++11. However, we also permit this form
131  // in unevaluated inline assembly operands, like the operand to a SIZE.
132  IMAKind AbstractInstanceResult = IMA_Static; // happens to be 'false'
133  assert(!AbstractInstanceResult);
134  switch (SemaRef.ExprEvalContexts.back().Context) {
137  if (isField && SemaRef.getLangOpts().CPlusPlus11)
138  AbstractInstanceResult = IMA_Field_Uneval_Context;
139  break;
140 
142  AbstractInstanceResult = IMA_Abstract;
143  break;
144 
150  break;
151  }
152 
153  // If the current context is not an instance method, it can't be
154  // an implicit member reference.
155  if (isStaticContext) {
156  if (hasNonInstance)
158 
159  return AbstractInstanceResult ? AbstractInstanceResult
161  }
162 
163  CXXRecordDecl *contextClass;
164  if (CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(DC))
165  contextClass = MD->getParent()->getCanonicalDecl();
166  else
167  contextClass = cast<CXXRecordDecl>(DC);
168 
169  // [class.mfct.non-static]p3:
170  // ...is used in the body of a non-static member function of class X,
171  // if name lookup (3.4.1) resolves the name in the id-expression to a
172  // non-static non-type member of some class C [...]
173  // ...if C is not X or a base class of X, the class member access expression
174  // is ill-formed.
175  if (R.getNamingClass() &&
176  contextClass->getCanonicalDecl() !=
177  R.getNamingClass()->getCanonicalDecl()) {
178  // If the naming class is not the current context, this was a qualified
179  // member name lookup, and it's sufficient to check that we have the naming
180  // class as a base class.
181  Classes.clear();
182  Classes.insert(R.getNamingClass()->getCanonicalDecl());
183  }
184 
185  // If we can prove that the current context is unrelated to all the
186  // declaring classes, it can't be an implicit member reference (in
187  // which case it's an error if any of those members are selected).
188  if (isProvablyNotDerivedFrom(SemaRef, contextClass, Classes))
189  return hasNonInstance ? IMA_Mixed_Unrelated :
190  AbstractInstanceResult ? AbstractInstanceResult :
192 
193  return (hasNonInstance ? IMA_Mixed : IMA_Instance);
194 }
195 
196 /// Diagnose a reference to a field with no object available.
197 static void diagnoseInstanceReference(Sema &SemaRef,
198  const CXXScopeSpec &SS,
199  NamedDecl *Rep,
200  const DeclarationNameInfo &nameInfo) {
201  SourceLocation Loc = nameInfo.getLoc();
202  SourceRange Range(Loc);
203  if (SS.isSet()) Range.setBegin(SS.getRange().getBegin());
204 
205  // Look through using shadow decls and aliases.
206  Rep = Rep->getUnderlyingDecl();
207 
208  DeclContext *FunctionLevelDC = SemaRef.getFunctionLevelDeclContext();
209  CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(FunctionLevelDC);
210  CXXRecordDecl *ContextClass = Method ? Method->getParent() : nullptr;
211  CXXRecordDecl *RepClass = dyn_cast<CXXRecordDecl>(Rep->getDeclContext());
212 
213  bool InStaticMethod = Method && Method->isStatic();
214  bool IsField = isa<FieldDecl>(Rep) || isa<IndirectFieldDecl>(Rep);
215 
216  if (IsField && InStaticMethod)
217  // "invalid use of member 'x' in static member function"
218  SemaRef.Diag(Loc, diag::err_invalid_member_use_in_static_method)
219  << Range << nameInfo.getName();
220  else if (ContextClass && RepClass && SS.isEmpty() && !InStaticMethod &&
221  !RepClass->Equals(ContextClass) && RepClass->Encloses(ContextClass))
222  // Unqualified lookup in a non-static member function found a member of an
223  // enclosing class.
224  SemaRef.Diag(Loc, diag::err_nested_non_static_member_use)
225  << IsField << RepClass << nameInfo.getName() << ContextClass << Range;
226  else if (IsField)
227  SemaRef.Diag(Loc, diag::err_invalid_non_static_member_use)
228  << nameInfo.getName() << Range;
229  else
230  SemaRef.Diag(Loc, diag::err_member_call_without_object)
231  << Range;
232 }
233 
234 /// Builds an expression which might be an implicit member expression.
236  const CXXScopeSpec &SS, SourceLocation TemplateKWLoc, LookupResult &R,
237  const TemplateArgumentListInfo *TemplateArgs, const Scope *S,
238  UnresolvedLookupExpr *AsULE) {
239  switch (ClassifyImplicitMemberAccess(*this, R)) {
240  case IMA_Instance:
241  return BuildImplicitMemberExpr(SS, TemplateKWLoc, R, TemplateArgs, true, S);
242 
243  case IMA_Mixed:
244  case IMA_Mixed_Unrelated:
245  case IMA_Unresolved:
246  return BuildImplicitMemberExpr(SS, TemplateKWLoc, R, TemplateArgs, false,
247  S);
248 
250  Diag(R.getNameLoc(), diag::warn_cxx98_compat_non_static_member_use)
251  << R.getLookupNameInfo().getName();
252  LLVM_FALLTHROUGH;
253  case IMA_Static:
254  case IMA_Abstract:
257  if (TemplateArgs || TemplateKWLoc.isValid())
258  return BuildTemplateIdExpr(SS, TemplateKWLoc, R, false, TemplateArgs);
259  return AsULE ? AsULE : BuildDeclarationNameExpr(SS, R, false);
260 
262  case IMA_Error_Unrelated:
264  R.getLookupNameInfo());
265  return ExprError();
266  }
267 
268  llvm_unreachable("unexpected instance member access kind");
269 }
270 
271 /// Determine whether input char is from rgba component set.
272 static bool
273 IsRGBA(char c) {
274  switch (c) {
275  case 'r':
276  case 'g':
277  case 'b':
278  case 'a':
279  return true;
280  default:
281  return false;
282  }
283 }
284 
285 // OpenCL v1.1, s6.1.7
286 // The component swizzle length must be in accordance with the acceptable
287 // vector sizes.
288 static bool IsValidOpenCLComponentSwizzleLength(unsigned len)
289 {
290  return (len >= 1 && len <= 4) || len == 8 || len == 16;
291 }
292 
293 /// Check an ext-vector component access expression.
294 ///
295 /// VK should be set in advance to the value kind of the base
296 /// expression.
297 static QualType
299  SourceLocation OpLoc, const IdentifierInfo *CompName,
300  SourceLocation CompLoc) {
301  // FIXME: Share logic with ExtVectorElementExpr::containsDuplicateElements,
302  // see FIXME there.
303  //
304  // FIXME: This logic can be greatly simplified by splitting it along
305  // halving/not halving and reworking the component checking.
306  const ExtVectorType *vecType = baseType->getAs<ExtVectorType>();
307 
308  // The vector accessor can't exceed the number of elements.
309  const char *compStr = CompName->getNameStart();
310 
311  // This flag determines whether or not the component is one of the four
312  // special names that indicate a subset of exactly half the elements are
313  // to be selected.
314  bool HalvingSwizzle = false;
315 
316  // This flag determines whether or not CompName has an 's' char prefix,
317  // indicating that it is a string of hex values to be used as vector indices.
318  bool HexSwizzle = (*compStr == 's' || *compStr == 'S') && compStr[1];
319 
320  bool HasRepeated = false;
321  bool HasIndex[16] = {};
322 
323  int Idx;
324 
325  // Check that we've found one of the special components, or that the component
326  // names must come from the same set.
327  if (!strcmp(compStr, "hi") || !strcmp(compStr, "lo") ||
328  !strcmp(compStr, "even") || !strcmp(compStr, "odd")) {
329  HalvingSwizzle = true;
330  } else if (!HexSwizzle &&
331  (Idx = vecType->getPointAccessorIdx(*compStr)) != -1) {
332  bool HasRGBA = IsRGBA(*compStr);
333  do {
334  // Ensure that xyzw and rgba components don't intermingle.
335  if (HasRGBA != IsRGBA(*compStr))
336  break;
337  if (HasIndex[Idx]) HasRepeated = true;
338  HasIndex[Idx] = true;
339  compStr++;
340  } while (*compStr && (Idx = vecType->getPointAccessorIdx(*compStr)) != -1);
341 
342  // Emit a warning if an rgba selector is used earlier than OpenCL C 3.0.
343  if (HasRGBA || (*compStr && IsRGBA(*compStr))) {
344  if (S.getLangOpts().OpenCL &&
346  const char *DiagBegin = HasRGBA ? CompName->getNameStart() : compStr;
347  S.Diag(OpLoc, diag::ext_opencl_ext_vector_type_rgba_selector)
348  << StringRef(DiagBegin, 1) << SourceRange(CompLoc);
349  }
350  }
351  } else {
352  if (HexSwizzle) compStr++;
353  while ((Idx = vecType->getNumericAccessorIdx(*compStr)) != -1) {
354  if (HasIndex[Idx]) HasRepeated = true;
355  HasIndex[Idx] = true;
356  compStr++;
357  }
358  }
359 
360  if (!HalvingSwizzle && *compStr) {
361  // We didn't get to the end of the string. This means the component names
362  // didn't come from the same set *or* we encountered an illegal name.
363  S.Diag(OpLoc, diag::err_ext_vector_component_name_illegal)
364  << StringRef(compStr, 1) << SourceRange(CompLoc);
365  return QualType();
366  }
367 
368  // Ensure no component accessor exceeds the width of the vector type it
369  // operates on.
370  if (!HalvingSwizzle) {
371  compStr = CompName->getNameStart();
372 
373  if (HexSwizzle)
374  compStr++;
375 
376  while (*compStr) {
377  if (!vecType->isAccessorWithinNumElements(*compStr++, HexSwizzle)) {
378  S.Diag(OpLoc, diag::err_ext_vector_component_exceeds_length)
379  << baseType << SourceRange(CompLoc);
380  return QualType();
381  }
382  }
383  }
384 
385  // OpenCL mode requires swizzle length to be in accordance with accepted
386  // sizes. Clang however supports arbitrary lengths for other languages.
387  if (S.getLangOpts().OpenCL && !HalvingSwizzle) {
388  unsigned SwizzleLength = CompName->getLength();
389 
390  if (HexSwizzle)
391  SwizzleLength--;
392 
393  if (IsValidOpenCLComponentSwizzleLength(SwizzleLength) == false) {
394  S.Diag(OpLoc, diag::err_opencl_ext_vector_component_invalid_length)
395  << SwizzleLength << SourceRange(CompLoc);
396  return QualType();
397  }
398  }
399 
400  // The component accessor looks fine - now we need to compute the actual type.
401  // The vector type is implied by the component accessor. For example,
402  // vec4.b is a float, vec4.xy is a vec2, vec4.rgb is a vec3, etc.
403  // vec4.s0 is a float, vec4.s23 is a vec3, etc.
404  // vec4.hi, vec4.lo, vec4.e, and vec4.o all return vec2.
405  unsigned CompSize = HalvingSwizzle ? (vecType->getNumElements() + 1) / 2
406  : CompName->getLength();
407  if (HexSwizzle)
408  CompSize--;
409 
410  if (CompSize == 1)
411  return vecType->getElementType();
412 
413  if (HasRepeated)
414  VK = VK_PRValue;
415 
416  QualType VT = S.Context.getExtVectorType(vecType->getElementType(), CompSize);
417  // Now look up the TypeDefDecl from the vector type. Without this,
418  // diagostics look bad. We want extended vector types to appear built-in.
419  for (Sema::ExtVectorDeclsType::iterator
421  E = S.ExtVectorDecls.end();
422  I != E; ++I) {
423  if ((*I)->getUnderlyingType() == VT)
424  return S.Context.getTypedefType(*I);
425  }
426 
427  return VT; // should never get here (a typedef type should always be found).
428 }
429 
431  IdentifierInfo *Member,
432  const Selector &Sel,
433  ASTContext &Context) {
434  if (Member)
435  if (ObjCPropertyDecl *PD = PDecl->FindPropertyDeclaration(
437  return PD;
438  if (ObjCMethodDecl *OMD = PDecl->getInstanceMethod(Sel))
439  return OMD;
440 
441  for (const auto *I : PDecl->protocols()) {
443  Context))
444  return D;
445  }
446  return nullptr;
447 }
448 
450  IdentifierInfo *Member,
451  const Selector &Sel,
452  ASTContext &Context) {
453  // Check protocols on qualified interfaces.
454  Decl *GDecl = nullptr;
455  for (const auto *I : QIdTy->quals()) {
456  if (Member)
457  if (ObjCPropertyDecl *PD = I->FindPropertyDeclaration(
459  GDecl = PD;
460  break;
461  }
462  // Also must look for a getter or setter name which uses property syntax.
463  if (ObjCMethodDecl *OMD = I->getInstanceMethod(Sel)) {
464  GDecl = OMD;
465  break;
466  }
467  }
468  if (!GDecl) {
469  for (const auto *I : QIdTy->quals()) {
470  // Search in the protocol-qualifier list of current protocol.
471  GDecl = FindGetterSetterNameDeclFromProtocolList(I, Member, Sel, Context);
472  if (GDecl)
473  return GDecl;
474  }
475  }
476  return GDecl;
477 }
478 
481  bool IsArrow, SourceLocation OpLoc,
482  const CXXScopeSpec &SS,
483  SourceLocation TemplateKWLoc,
484  NamedDecl *FirstQualifierInScope,
485  const DeclarationNameInfo &NameInfo,
486  const TemplateArgumentListInfo *TemplateArgs) {
487  // Even in dependent contexts, try to diagnose base expressions with
488  // obviously wrong types, e.g.:
489  //
490  // T* t;
491  // t.f;
492  //
493  // In Obj-C++, however, the above expression is valid, since it could be
494  // accessing the 'f' property if T is an Obj-C interface. The extra check
495  // allows this, while still reporting an error if T is a struct pointer.
496  if (!IsArrow) {
497  const PointerType *PT = BaseType->getAs<PointerType>();
498  if (PT && (!getLangOpts().ObjC ||
499  PT->getPointeeType()->isRecordType())) {
500  assert(BaseExpr && "cannot happen with implicit member accesses");
501  Diag(OpLoc, diag::err_typecheck_member_reference_struct_union)
502  << BaseType << BaseExpr->getSourceRange() << NameInfo.getSourceRange();
503  return ExprError();
504  }
505  }
506 
507  assert(BaseType->isDependentType() ||
508  NameInfo.getName().isDependentName() ||
509  isDependentScopeSpecifier(SS));
510 
511  // Get the type being accessed in BaseType. If this is an arrow, the BaseExpr
512  // must have pointer type, and the accessed type is the pointee.
514  Context, BaseExpr, BaseType, IsArrow, OpLoc,
515  SS.getWithLocInContext(Context), TemplateKWLoc, FirstQualifierInScope,
516  NameInfo, TemplateArgs);
517 }
518 
519 /// We know that the given qualified member reference points only to
520 /// declarations which do not belong to the static type of the base
521 /// expression. Diagnose the problem.
523  Expr *BaseExpr,
524  QualType BaseType,
525  const CXXScopeSpec &SS,
526  NamedDecl *rep,
527  const DeclarationNameInfo &nameInfo) {
528  // If this is an implicit member access, use a different set of
529  // diagnostics.
530  if (!BaseExpr)
531  return diagnoseInstanceReference(SemaRef, SS, rep, nameInfo);
532 
533  SemaRef.Diag(nameInfo.getLoc(), diag::err_qualified_member_of_unrelated)
534  << SS.getRange() << rep << BaseType;
535 }
536 
537 // Check whether the declarations we found through a nested-name
538 // specifier in a member expression are actually members of the base
539 // type. The restriction here is:
540 //
541 // C++ [expr.ref]p2:
542 // ... In these cases, the id-expression shall name a
543 // member of the class or of one of its base classes.
544 //
545 // So it's perfectly legitimate for the nested-name specifier to name
546 // an unrelated class, and for us to find an overload set including
547 // decls from classes which are not superclasses, as long as the decl
548 // we actually pick through overload resolution is from a superclass.
550  QualType BaseType,
551  const CXXScopeSpec &SS,
552  const LookupResult &R) {
553  CXXRecordDecl *BaseRecord =
554  cast_or_null<CXXRecordDecl>(computeDeclContext(BaseType));
555  if (!BaseRecord) {
556  // We can't check this yet because the base type is still
557  // dependent.
558  assert(BaseType->isDependentType());
559  return false;
560  }
561 
562  for (LookupResult::iterator I = R.begin(), E = R.end(); I != E; ++I) {
563  // If this is an implicit member reference and we find a
564  // non-instance member, it's not an error.
565  if (!BaseExpr && !(*I)->isCXXInstanceMember())
566  return false;
567 
568  // Note that we use the DC of the decl, not the underlying decl.
569  DeclContext *DC = (*I)->getDeclContext()->getNonTransparentContext();
570  if (!DC->isRecord())
571  continue;
572 
573  CXXRecordDecl *MemberRecord = cast<CXXRecordDecl>(DC)->getCanonicalDecl();
574  if (BaseRecord->getCanonicalDecl() == MemberRecord ||
575  !BaseRecord->isProvablyNotDerivedFrom(MemberRecord))
576  return false;
577  }
578 
579  DiagnoseQualifiedMemberReference(*this, BaseExpr, BaseType, SS,
581  R.getLookupNameInfo());
582  return true;
583 }
584 
585 namespace {
586 
587 // Callback to only accept typo corrections that are either a ValueDecl or a
588 // FunctionTemplateDecl and are declared in the current record or, for a C++
589 // classes, one of its base classes.
590 class RecordMemberExprValidatorCCC final : public CorrectionCandidateCallback {
591 public:
592  explicit RecordMemberExprValidatorCCC(const RecordType *RTy)
593  : Record(RTy->getDecl()) {
594  // Don't add bare keywords to the consumer since they will always fail
595  // validation by virtue of not being associated with any decls.
596  WantTypeSpecifiers = false;
597  WantExpressionKeywords = false;
598  WantCXXNamedCasts = false;
599  WantFunctionLikeCasts = false;
600  WantRemainingKeywords = false;
601  }
602 
603  bool ValidateCandidate(const TypoCorrection &candidate) override {
604  NamedDecl *ND = candidate.getCorrectionDecl();
605  // Don't accept candidates that cannot be member functions, constants,
606  // variables, or templates.
607  if (!ND || !(isa<ValueDecl>(ND) || isa<FunctionTemplateDecl>(ND)))
608  return false;
609 
610  // Accept candidates that occur in the current record.
611  if (Record->containsDecl(ND))
612  return true;
613 
614  if (const auto *RD = dyn_cast<CXXRecordDecl>(Record)) {
615  // Accept candidates that occur in any of the current class' base classes.
616  for (const auto &BS : RD->bases()) {
617  if (const auto *BSTy = BS.getType()->getAs<RecordType>()) {
618  if (BSTy->getDecl()->containsDecl(ND))
619  return true;
620  }
621  }
622  }
623 
624  return false;
625  }
626 
627  std::unique_ptr<CorrectionCandidateCallback> clone() override {
628  return std::make_unique<RecordMemberExprValidatorCCC>(*this);
629  }
630 
631 private:
632  const RecordDecl *const Record;
633 };
634 
635 }
636 
637 static bool LookupMemberExprInRecord(Sema &SemaRef, LookupResult &R,
638  Expr *BaseExpr,
639  const RecordType *RTy,
640  SourceLocation OpLoc, bool IsArrow,
641  CXXScopeSpec &SS, bool HasTemplateArgs,
642  SourceLocation TemplateKWLoc,
643  TypoExpr *&TE) {
644  SourceRange BaseRange = BaseExpr ? BaseExpr->getSourceRange() : SourceRange();
645  RecordDecl *RDecl = RTy->getDecl();
646  if (!SemaRef.isThisOutsideMemberFunctionBody(QualType(RTy, 0)) &&
647  SemaRef.RequireCompleteType(OpLoc, QualType(RTy, 0),
648  diag::err_typecheck_incomplete_tag,
649  BaseRange))
650  return true;
651 
652  if (HasTemplateArgs || TemplateKWLoc.isValid()) {
653  // LookupTemplateName doesn't expect these both to exist simultaneously.
654  QualType ObjectType = SS.isSet() ? QualType() : QualType(RTy, 0);
655 
656  bool MOUS;
657  return SemaRef.LookupTemplateName(R, nullptr, SS, ObjectType, false, MOUS,
658  TemplateKWLoc);
659  }
660 
661  DeclContext *DC = RDecl;
662  if (SS.isSet()) {
663  // If the member name was a qualified-id, look into the
664  // nested-name-specifier.
665  DC = SemaRef.computeDeclContext(SS, false);
666 
667  if (SemaRef.RequireCompleteDeclContext(SS, DC)) {
668  SemaRef.Diag(SS.getRange().getEnd(), diag::err_typecheck_incomplete_tag)
669  << SS.getRange() << DC;
670  return true;
671  }
672 
673  assert(DC && "Cannot handle non-computable dependent contexts in lookup");
674 
675  if (!isa<TypeDecl>(DC)) {
676  SemaRef.Diag(R.getNameLoc(), diag::err_qualified_member_nonclass)
677  << DC << SS.getRange();
678  return true;
679  }
680  }
681 
682  // The record definition is complete, now look up the member.
683  SemaRef.LookupQualifiedName(R, DC, SS);
684 
685  if (!R.empty())
686  return false;
687 
688  DeclarationName Typo = R.getLookupName();
689  SourceLocation TypoLoc = R.getNameLoc();
690 
691  struct QueryState {
692  Sema &SemaRef;
693  DeclarationNameInfo NameInfo;
694  Sema::LookupNameKind LookupKind;
696  };
697  QueryState Q = {R.getSema(), R.getLookupNameInfo(), R.getLookupKind(),
698  R.redeclarationKind()};
699  RecordMemberExprValidatorCCC CCC(RTy);
700  TE = SemaRef.CorrectTypoDelayed(
701  R.getLookupNameInfo(), R.getLookupKind(), nullptr, &SS, CCC,
702  [=, &SemaRef](const TypoCorrection &TC) {
703  if (TC) {
704  assert(!TC.isKeyword() &&
705  "Got a keyword as a correction for a member!");
706  bool DroppedSpecifier =
707  TC.WillReplaceSpecifier() &&
708  Typo.getAsString() == TC.getAsString(SemaRef.getLangOpts());
709  SemaRef.diagnoseTypo(TC, SemaRef.PDiag(diag::err_no_member_suggest)
710  << Typo << DC << DroppedSpecifier
711  << SS.getRange());
712  } else {
713  SemaRef.Diag(TypoLoc, diag::err_no_member) << Typo << DC << BaseRange;
714  }
715  },
716  [=](Sema &SemaRef, TypoExpr *TE, TypoCorrection TC) mutable {
717  LookupResult R(Q.SemaRef, Q.NameInfo, Q.LookupKind, Q.Redecl);
718  R.clear(); // Ensure there's no decls lingering in the shared state.
719  R.suppressDiagnostics();
720  R.setLookupName(TC.getCorrection());
721  for (NamedDecl *ND : TC)
722  R.addDecl(ND);
723  R.resolveKind();
724  return SemaRef.BuildMemberReferenceExpr(
725  BaseExpr, BaseExpr->getType(), OpLoc, IsArrow, SS, SourceLocation(),
726  nullptr, R, nullptr, nullptr);
727  },
729 
730  return false;
731 }
732 
734  ExprResult &BaseExpr, bool &IsArrow,
735  SourceLocation OpLoc, CXXScopeSpec &SS,
736  Decl *ObjCImpDecl, bool HasTemplateArgs,
737  SourceLocation TemplateKWLoc);
738 
741  SourceLocation OpLoc, bool IsArrow,
742  CXXScopeSpec &SS,
743  SourceLocation TemplateKWLoc,
744  NamedDecl *FirstQualifierInScope,
745  const DeclarationNameInfo &NameInfo,
746  const TemplateArgumentListInfo *TemplateArgs,
747  const Scope *S,
748  ActOnMemberAccessExtraArgs *ExtraArgs) {
749  if (BaseType->isDependentType() ||
750  (SS.isSet() && isDependentScopeSpecifier(SS)))
751  return ActOnDependentMemberExpr(Base, BaseType,
752  IsArrow, OpLoc,
753  SS, TemplateKWLoc, FirstQualifierInScope,
754  NameInfo, TemplateArgs);
755 
756  LookupResult R(*this, NameInfo, LookupMemberName);
757 
758  // Implicit member accesses.
759  if (!Base) {
760  TypoExpr *TE = nullptr;
761  QualType RecordTy = BaseType;
762  if (IsArrow) RecordTy = RecordTy->castAs<PointerType>()->getPointeeType();
764  *this, R, nullptr, RecordTy->getAs<RecordType>(), OpLoc, IsArrow,
765  SS, TemplateArgs != nullptr, TemplateKWLoc, TE))
766  return ExprError();
767  if (TE)
768  return TE;
769 
770  // Explicit member accesses.
771  } else {
773  ExprResult Result =
774  LookupMemberExpr(*this, R, BaseResult, IsArrow, OpLoc, SS,
775  ExtraArgs ? ExtraArgs->ObjCImpDecl : nullptr,
776  TemplateArgs != nullptr, TemplateKWLoc);
777 
778  if (BaseResult.isInvalid())
779  return ExprError();
780  Base = BaseResult.get();
781 
782  if (Result.isInvalid())
783  return ExprError();
784 
785  if (Result.get())
786  return Result;
787 
788  // LookupMemberExpr can modify Base, and thus change BaseType
789  BaseType = Base->getType();
790  }
791 
792  return BuildMemberReferenceExpr(Base, BaseType,
793  OpLoc, IsArrow, SS, TemplateKWLoc,
794  FirstQualifierInScope, R, TemplateArgs, S,
795  false, ExtraArgs);
796 }
797 
800  SourceLocation loc,
801  IndirectFieldDecl *indirectField,
802  DeclAccessPair foundDecl,
803  Expr *baseObjectExpr,
804  SourceLocation opLoc) {
805  // First, build the expression that refers to the base object.
806 
807  // Case 1: the base of the indirect field is not a field.
808  VarDecl *baseVariable = indirectField->getVarDecl();
809  CXXScopeSpec EmptySS;
810  if (baseVariable) {
811  assert(baseVariable->getType()->isRecordType());
812 
813  // In principle we could have a member access expression that
814  // accesses an anonymous struct/union that's a static member of
815  // the base object's class. However, under the current standard,
816  // static data members cannot be anonymous structs or unions.
817  // Supporting this is as easy as building a MemberExpr here.
818  assert(!baseObjectExpr && "anonymous struct/union is static data member?");
819 
820  DeclarationNameInfo baseNameInfo(DeclarationName(), loc);
821 
822  ExprResult result
823  = BuildDeclarationNameExpr(EmptySS, baseNameInfo, baseVariable);
824  if (result.isInvalid()) return ExprError();
825 
826  baseObjectExpr = result.get();
827  }
828 
829  assert((baseVariable || baseObjectExpr) &&
830  "referencing anonymous struct/union without a base variable or "
831  "expression");
832 
833  // Build the implicit member references to the field of the
834  // anonymous struct/union.
835  Expr *result = baseObjectExpr;
837  FI = indirectField->chain_begin(), FEnd = indirectField->chain_end();
838 
839  // Case 2: the base of the indirect field is a field and the user
840  // wrote a member expression.
841  if (!baseVariable) {
842  FieldDecl *field = cast<FieldDecl>(*FI);
843 
844  bool baseObjectIsPointer = baseObjectExpr->getType()->isPointerType();
845 
846  // Make a nameInfo that properly uses the anonymous name.
847  DeclarationNameInfo memberNameInfo(field->getDeclName(), loc);
848 
849  // Build the first member access in the chain with full information.
850  result =
851  BuildFieldReferenceExpr(result, baseObjectIsPointer, SourceLocation(),
852  SS, field, foundDecl, memberNameInfo)
853  .get();
854  if (!result)
855  return ExprError();
856  }
857 
858  // In all cases, we should now skip the first declaration in the chain.
859  ++FI;
860 
861  while (FI != FEnd) {
862  FieldDecl *field = cast<FieldDecl>(*FI++);
863 
864  // FIXME: these are somewhat meaningless
865  DeclarationNameInfo memberNameInfo(field->getDeclName(), loc);
866  DeclAccessPair fakeFoundDecl =
867  DeclAccessPair::make(field, field->getAccess());
868 
869  result =
870  BuildFieldReferenceExpr(result, /*isarrow*/ false, SourceLocation(),
871  (FI == FEnd ? SS : EmptySS), field,
872  fakeFoundDecl, memberNameInfo)
873  .get();
874  }
875 
876  return result;
877 }
878 
879 static ExprResult
880 BuildMSPropertyRefExpr(Sema &S, Expr *BaseExpr, bool IsArrow,
881  const CXXScopeSpec &SS,
882  MSPropertyDecl *PD,
883  const DeclarationNameInfo &NameInfo) {
884  // Property names are always simple identifiers and therefore never
885  // require any interesting additional storage.
886  return new (S.Context) MSPropertyRefExpr(BaseExpr, PD, IsArrow,
889  NameInfo.getLoc());
890 }
891 
893  Expr *Base, bool IsArrow, SourceLocation OpLoc, const CXXScopeSpec *SS,
894  SourceLocation TemplateKWLoc, ValueDecl *Member, DeclAccessPair FoundDecl,
895  bool HadMultipleCandidates, const DeclarationNameInfo &MemberNameInfo,
897  const TemplateArgumentListInfo *TemplateArgs) {
900  return BuildMemberExpr(Base, IsArrow, OpLoc, NNS, TemplateKWLoc, Member,
901  FoundDecl, HadMultipleCandidates, MemberNameInfo, Ty,
902  VK, OK, TemplateArgs);
903 }
904 
906  Expr *Base, bool IsArrow, SourceLocation OpLoc, NestedNameSpecifierLoc NNS,
907  SourceLocation TemplateKWLoc, ValueDecl *Member, DeclAccessPair FoundDecl,
908  bool HadMultipleCandidates, const DeclarationNameInfo &MemberNameInfo,
910  const TemplateArgumentListInfo *TemplateArgs) {
911  assert((!IsArrow || Base->isPRValue()) &&
912  "-> base must be a pointer prvalue");
913  MemberExpr *E =
914  MemberExpr::Create(Context, Base, IsArrow, OpLoc, NNS, TemplateKWLoc,
915  Member, FoundDecl, MemberNameInfo, TemplateArgs, Ty,
917  E->setHadMultipleCandidates(HadMultipleCandidates);
919 
920  // C++ [except.spec]p17:
921  // An exception-specification is considered to be needed when:
922  // - in an expression the function is the unique lookup result or the
923  // selected member of a set of overloaded functions
924  if (auto *FPT = Ty->getAs<FunctionProtoType>()) {
925  if (isUnresolvedExceptionSpec(FPT->getExceptionSpecType())) {
926  if (auto *NewFPT = ResolveExceptionSpec(MemberNameInfo.getLoc(), FPT))
927  E->setType(Context.getQualifiedType(NewFPT, Ty.getQualifiers()));
928  }
929  }
930 
931  return E;
932 }
933 
934 /// Determine if the given scope is within a function-try-block handler.
935 static bool IsInFnTryBlockHandler(const Scope *S) {
936  // Walk the scope stack until finding a FnTryCatchScope, or leave the
937  // function scope. If a FnTryCatchScope is found, check whether the TryScope
938  // flag is set. If it is not, it's a function-try-block handler.
939  for (; S != S->getFnParent(); S = S->getParent()) {
940  if (S->getFlags() & Scope::FnTryCatchScope)
941  return (S->getFlags() & Scope::TryScope) != Scope::TryScope;
942  }
943  return false;
944 }
945 
948  SourceLocation OpLoc, bool IsArrow,
949  const CXXScopeSpec &SS,
950  SourceLocation TemplateKWLoc,
951  NamedDecl *FirstQualifierInScope,
952  LookupResult &R,
953  const TemplateArgumentListInfo *TemplateArgs,
954  const Scope *S,
955  bool SuppressQualifierCheck,
956  ActOnMemberAccessExtraArgs *ExtraArgs) {
957  QualType BaseType = BaseExprType;
958  if (IsArrow) {
959  assert(BaseType->isPointerType());
960  BaseType = BaseType->castAs<PointerType>()->getPointeeType();
961  }
962  R.setBaseObjectType(BaseType);
963 
964  // C++1z [expr.ref]p2:
965  // For the first option (dot) the first expression shall be a glvalue [...]
966  if (!IsArrow && BaseExpr && BaseExpr->isPRValue()) {
967  ExprResult Converted = TemporaryMaterializationConversion(BaseExpr);
968  if (Converted.isInvalid())
969  return ExprError();
970  BaseExpr = Converted.get();
971  }
972 
973  const DeclarationNameInfo &MemberNameInfo = R.getLookupNameInfo();
974  DeclarationName MemberName = MemberNameInfo.getName();
975  SourceLocation MemberLoc = MemberNameInfo.getLoc();
976 
977  if (R.isAmbiguous())
978  return ExprError();
979 
980  // [except.handle]p10: Referring to any non-static member or base class of an
981  // object in the handler for a function-try-block of a constructor or
982  // destructor for that object results in undefined behavior.
983  const auto *FD = getCurFunctionDecl();
984  if (S && BaseExpr && FD &&
985  (isa<CXXDestructorDecl>(FD) || isa<CXXConstructorDecl>(FD)) &&
986  isa<CXXThisExpr>(BaseExpr->IgnoreImpCasts()) &&
988  Diag(MemberLoc, diag::warn_cdtor_function_try_handler_mem_expr)
989  << isa<CXXDestructorDecl>(FD);
990 
991  if (R.empty()) {
992  // Rederive where we looked up.
993  DeclContext *DC = (SS.isSet()
994  ? computeDeclContext(SS, false)
995  : BaseType->castAs<RecordType>()->getDecl());
996 
997  if (ExtraArgs) {
998  ExprResult RetryExpr;
999  if (!IsArrow && BaseExpr) {
1000  SFINAETrap Trap(*this, true);
1001  ParsedType ObjectType;
1002  bool MayBePseudoDestructor = false;
1003  RetryExpr = ActOnStartCXXMemberReference(getCurScope(), BaseExpr,
1004  OpLoc, tok::arrow, ObjectType,
1005  MayBePseudoDestructor);
1006  if (RetryExpr.isUsable() && !Trap.hasErrorOccurred()) {
1007  CXXScopeSpec TempSS(SS);
1008  RetryExpr = ActOnMemberAccessExpr(
1009  ExtraArgs->S, RetryExpr.get(), OpLoc, tok::arrow, TempSS,
1010  TemplateKWLoc, ExtraArgs->Id, ExtraArgs->ObjCImpDecl);
1011  }
1012  if (Trap.hasErrorOccurred())
1013  RetryExpr = ExprError();
1014  }
1015  if (RetryExpr.isUsable()) {
1016  Diag(OpLoc, diag::err_no_member_overloaded_arrow)
1017  << MemberName << DC << FixItHint::CreateReplacement(OpLoc, "->");
1018  return RetryExpr;
1019  }
1020  }
1021 
1022  Diag(R.getNameLoc(), diag::err_no_member)
1023  << MemberName << DC
1024  << (BaseExpr ? BaseExpr->getSourceRange() : SourceRange());
1025  return ExprError();
1026  }
1027 
1028  // Diagnose lookups that find only declarations from a non-base
1029  // type. This is possible for either qualified lookups (which may
1030  // have been qualified with an unrelated type) or implicit member
1031  // expressions (which were found with unqualified lookup and thus
1032  // may have come from an enclosing scope). Note that it's okay for
1033  // lookup to find declarations from a non-base type as long as those
1034  // aren't the ones picked by overload resolution.
1035  if ((SS.isSet() || !BaseExpr ||
1036  (isa<CXXThisExpr>(BaseExpr) &&
1037  cast<CXXThisExpr>(BaseExpr)->isImplicit())) &&
1038  !SuppressQualifierCheck &&
1039  CheckQualifiedMemberReference(BaseExpr, BaseType, SS, R))
1040  return ExprError();
1041 
1042  // Construct an unresolved result if we in fact got an unresolved
1043  // result.
1044  if (R.isOverloadedResult() || R.isUnresolvableResult()) {
1045  // Suppress any lookup-related diagnostics; we'll do these when we
1046  // pick a member.
1047  R.suppressDiagnostics();
1048 
1049  UnresolvedMemberExpr *MemExpr
1051  BaseExpr, BaseExprType,
1052  IsArrow, OpLoc,
1054  TemplateKWLoc, MemberNameInfo,
1055  TemplateArgs, R.begin(), R.end());
1056 
1057  return MemExpr;
1058  }
1059 
1060  assert(R.isSingleResult());
1061  DeclAccessPair FoundDecl = R.begin().getPair();
1062  NamedDecl *MemberDecl = R.getFoundDecl();
1063 
1064  // FIXME: diagnose the presence of template arguments now.
1065 
1066  // If the decl being referenced had an error, return an error for this
1067  // sub-expr without emitting another error, in order to avoid cascading
1068  // error cases.
1069  if (MemberDecl->isInvalidDecl())
1070  return ExprError();
1071 
1072  // Handle the implicit-member-access case.
1073  if (!BaseExpr) {
1074  // If this is not an instance member, convert to a non-member access.
1075  if (!MemberDecl->isCXXInstanceMember()) {
1076  // We might have a variable template specialization (or maybe one day a
1077  // member concept-id).
1078  if (TemplateArgs || TemplateKWLoc.isValid())
1079  return BuildTemplateIdExpr(SS, TemplateKWLoc, R, /*ADL*/false, TemplateArgs);
1080 
1081  return BuildDeclarationNameExpr(SS, R.getLookupNameInfo(), MemberDecl,
1082  FoundDecl, TemplateArgs);
1083  }
1084  SourceLocation Loc = R.getNameLoc();
1085  if (SS.getRange().isValid())
1086  Loc = SS.getRange().getBegin();
1087  BaseExpr = BuildCXXThisExpr(Loc, BaseExprType, /*IsImplicit=*/true);
1088  }
1089 
1090  // Check the use of this member.
1091  if (DiagnoseUseOfDecl(MemberDecl, MemberLoc))
1092  return ExprError();
1093 
1094  if (FieldDecl *FD = dyn_cast<FieldDecl>(MemberDecl))
1095  return BuildFieldReferenceExpr(BaseExpr, IsArrow, OpLoc, SS, FD, FoundDecl,
1096  MemberNameInfo);
1097 
1098  if (MSPropertyDecl *PD = dyn_cast<MSPropertyDecl>(MemberDecl))
1099  return BuildMSPropertyRefExpr(*this, BaseExpr, IsArrow, SS, PD,
1100  MemberNameInfo);
1101 
1102  if (IndirectFieldDecl *FD = dyn_cast<IndirectFieldDecl>(MemberDecl))
1103  // We may have found a field within an anonymous union or struct
1104  // (C++ [class.union]).
1105  return BuildAnonymousStructUnionMemberReference(SS, MemberLoc, FD,
1106  FoundDecl, BaseExpr,
1107  OpLoc);
1108 
1109  if (VarDecl *Var = dyn_cast<VarDecl>(MemberDecl)) {
1110  return BuildMemberExpr(BaseExpr, IsArrow, OpLoc, &SS, TemplateKWLoc, Var,
1111  FoundDecl, /*HadMultipleCandidates=*/false,
1112  MemberNameInfo, Var->getType().getNonReferenceType(),
1114  }
1115 
1116  if (CXXMethodDecl *MemberFn = dyn_cast<CXXMethodDecl>(MemberDecl)) {
1117  ExprValueKind valueKind;
1118  QualType type;
1119  if (MemberFn->isInstance()) {
1120  valueKind = VK_PRValue;
1122  } else {
1123  valueKind = VK_LValue;
1124  type = MemberFn->getType();
1125  }
1126 
1127  return BuildMemberExpr(BaseExpr, IsArrow, OpLoc, &SS, TemplateKWLoc,
1128  MemberFn, FoundDecl, /*HadMultipleCandidates=*/false,
1129  MemberNameInfo, type, valueKind, OK_Ordinary);
1130  }
1131  assert(!isa<FunctionDecl>(MemberDecl) && "member function not C++ method?");
1132 
1133  if (EnumConstantDecl *Enum = dyn_cast<EnumConstantDecl>(MemberDecl)) {
1134  return BuildMemberExpr(BaseExpr, IsArrow, OpLoc, &SS, TemplateKWLoc, Enum,
1135  FoundDecl, /*HadMultipleCandidates=*/false,
1136  MemberNameInfo, Enum->getType(), VK_PRValue,
1137  OK_Ordinary);
1138  }
1139 
1140  if (VarTemplateDecl *VarTempl = dyn_cast<VarTemplateDecl>(MemberDecl)) {
1141  if (!TemplateArgs) {
1142  diagnoseMissingTemplateArguments(TemplateName(VarTempl), MemberLoc);
1143  return ExprError();
1144  }
1145 
1146  DeclResult VDecl = CheckVarTemplateId(VarTempl, TemplateKWLoc,
1147  MemberNameInfo.getLoc(), *TemplateArgs);
1148  if (VDecl.isInvalid())
1149  return ExprError();
1150 
1151  // Non-dependent member, but dependent template arguments.
1152  if (!VDecl.get())
1153  return ActOnDependentMemberExpr(
1154  BaseExpr, BaseExpr->getType(), IsArrow, OpLoc, SS, TemplateKWLoc,
1155  FirstQualifierInScope, MemberNameInfo, TemplateArgs);
1156 
1157  VarDecl *Var = cast<VarDecl>(VDecl.get());
1158  if (!Var->getTemplateSpecializationKind())
1160 
1161  return BuildMemberExpr(
1162  BaseExpr, IsArrow, OpLoc, &SS, TemplateKWLoc, Var, FoundDecl,
1163  /*HadMultipleCandidates=*/false, MemberNameInfo,
1165  }
1166 
1167  // We found something that we didn't expect. Complain.
1168  if (isa<TypeDecl>(MemberDecl))
1169  Diag(MemberLoc, diag::err_typecheck_member_reference_type)
1170  << MemberName << BaseType << int(IsArrow);
1171  else
1172  Diag(MemberLoc, diag::err_typecheck_member_reference_unknown)
1173  << MemberName << BaseType << int(IsArrow);
1174 
1175  Diag(MemberDecl->getLocation(), diag::note_member_declared_here)
1176  << MemberName;
1177  R.suppressDiagnostics();
1178  return ExprError();
1179 }
1180 
1181 /// Given that normal member access failed on the given expression,
1182 /// and given that the expression's type involves builtin-id or
1183 /// builtin-Class, decide whether substituting in the redefinition
1184 /// types would be profitable. The redefinition type is whatever
1185 /// this translation unit tried to typedef to id/Class; we store
1186 /// it to the side and then re-use it in places like this.
1188  const ObjCObjectPointerType *opty
1189  = base.get()->getType()->getAs<ObjCObjectPointerType>();
1190  if (!opty) return false;
1191 
1192  const ObjCObjectType *ty = opty->getObjectType();
1193 
1194  QualType redef;
1195  if (ty->isObjCId()) {
1196  redef = S.Context.getObjCIdRedefinitionType();
1197  } else if (ty->isObjCClass()) {
1199  } else {
1200  return false;
1201  }
1202 
1203  // Do the substitution as long as the redefinition type isn't just a
1204  // possibly-qualified pointer to builtin-id or builtin-Class again.
1205  opty = redef->getAs<ObjCObjectPointerType>();
1206  if (opty && !opty->getObjectType()->getInterface())
1207  return false;
1208 
1209  base = S.ImpCastExprToType(base.get(), redef, CK_BitCast);
1210  return true;
1211 }
1212 
1213 static bool isRecordType(QualType T) {
1214  return T->isRecordType();
1215 }
1217  if (const PointerType *PT = T->getAs<PointerType>())
1218  return PT->getPointeeType()->isRecordType();
1219  return false;
1220 }
1221 
1222 /// Perform conversions on the LHS of a member access expression.
1223 ExprResult
1225  if (IsArrow && !Base->getType()->isFunctionType())
1227 
1228  return CheckPlaceholderExpr(Base);
1229 }
1230 
1231 /// Look up the given member of the given non-type-dependent
1232 /// expression. This can return in one of two ways:
1233 /// * If it returns a sentinel null-but-valid result, the caller will
1234 /// assume that lookup was performed and the results written into
1235 /// the provided structure. It will take over from there.
1236 /// * Otherwise, the returned expression will be produced in place of
1237 /// an ordinary member expression.
1238 ///
1239 /// The ObjCImpDecl bit is a gross hack that will need to be properly
1240 /// fixed for ObjC++.
1242  ExprResult &BaseExpr, bool &IsArrow,
1243  SourceLocation OpLoc, CXXScopeSpec &SS,
1244  Decl *ObjCImpDecl, bool HasTemplateArgs,
1245  SourceLocation TemplateKWLoc) {
1246  assert(BaseExpr.get() && "no base expression");
1247 
1248  // Perform default conversions.
1249  BaseExpr = S.PerformMemberExprBaseConversion(BaseExpr.get(), IsArrow);
1250  if (BaseExpr.isInvalid())
1251  return ExprError();
1252 
1253  QualType BaseType = BaseExpr.get()->getType();
1254  assert(!BaseType->isDependentType());
1255 
1256  DeclarationName MemberName = R.getLookupName();
1257  SourceLocation MemberLoc = R.getNameLoc();
1258 
1259  // For later type-checking purposes, turn arrow accesses into dot
1260  // accesses. The only access type we support that doesn't follow
1261  // the C equivalence "a->b === (*a).b" is ObjC property accesses,
1262  // and those never use arrows, so this is unaffected.
1263  if (IsArrow) {
1264  if (const PointerType *Ptr = BaseType->getAs<PointerType>())
1265  BaseType = Ptr->getPointeeType();
1266  else if (const ObjCObjectPointerType *Ptr
1267  = BaseType->getAs<ObjCObjectPointerType>())
1268  BaseType = Ptr->getPointeeType();
1269  else if (BaseType->isRecordType()) {
1270  // Recover from arrow accesses to records, e.g.:
1271  // struct MyRecord foo;
1272  // foo->bar
1273  // This is actually well-formed in C++ if MyRecord has an
1274  // overloaded operator->, but that should have been dealt with
1275  // by now--or a diagnostic message already issued if a problem
1276  // was encountered while looking for the overloaded operator->.
1277  if (!S.getLangOpts().CPlusPlus) {
1278  S.Diag(OpLoc, diag::err_typecheck_member_reference_suggestion)
1279  << BaseType << int(IsArrow) << BaseExpr.get()->getSourceRange()
1280  << FixItHint::CreateReplacement(OpLoc, ".");
1281  }
1282  IsArrow = false;
1283  } else if (BaseType->isFunctionType()) {
1284  goto fail;
1285  } else {
1286  S.Diag(MemberLoc, diag::err_typecheck_member_reference_arrow)
1287  << BaseType << BaseExpr.get()->getSourceRange();
1288  return ExprError();
1289  }
1290  }
1291 
1292  // Handle field access to simple records.
1293  if (const RecordType *RTy = BaseType->getAs<RecordType>()) {
1294  TypoExpr *TE = nullptr;
1295  if (LookupMemberExprInRecord(S, R, BaseExpr.get(), RTy, OpLoc, IsArrow, SS,
1296  HasTemplateArgs, TemplateKWLoc, TE))
1297  return ExprError();
1298 
1299  // Returning valid-but-null is how we indicate to the caller that
1300  // the lookup result was filled in. If typo correction was attempted and
1301  // failed, the lookup result will have been cleared--that combined with the
1302  // valid-but-null ExprResult will trigger the appropriate diagnostics.
1303  return ExprResult(TE);
1304  }
1305 
1306  // Handle ivar access to Objective-C objects.
1307  if (const ObjCObjectType *OTy = BaseType->getAs<ObjCObjectType>()) {
1308  if (!SS.isEmpty() && !SS.isInvalid()) {
1309  S.Diag(SS.getRange().getBegin(), diag::err_qualified_objc_access)
1310  << 1 << SS.getScopeRep()
1312  SS.clear();
1313  }
1314 
1315  IdentifierInfo *Member = MemberName.getAsIdentifierInfo();
1316 
1317  // There are three cases for the base type:
1318  // - builtin id (qualified or unqualified)
1319  // - builtin Class (qualified or unqualified)
1320  // - an interface
1321  ObjCInterfaceDecl *IDecl = OTy->getInterface();
1322  if (!IDecl) {
1323  if (S.getLangOpts().ObjCAutoRefCount &&
1324  (OTy->isObjCId() || OTy->isObjCClass()))
1325  goto fail;
1326  // There's an implicit 'isa' ivar on all objects.
1327  // But we only actually find it this way on objects of type 'id',
1328  // apparently.
1329  if (OTy->isObjCId() && Member->isStr("isa"))
1330  return new (S.Context) ObjCIsaExpr(BaseExpr.get(), IsArrow, MemberLoc,
1331  OpLoc, S.Context.getObjCClassType());
1332  if (ShouldTryAgainWithRedefinitionType(S, BaseExpr))
1333  return LookupMemberExpr(S, R, BaseExpr, IsArrow, OpLoc, SS,
1334  ObjCImpDecl, HasTemplateArgs, TemplateKWLoc);
1335  goto fail;
1336  }
1337 
1338  if (S.RequireCompleteType(OpLoc, BaseType,
1339  diag::err_typecheck_incomplete_tag,
1340  BaseExpr.get()))
1341  return ExprError();
1342 
1343  ObjCInterfaceDecl *ClassDeclared = nullptr;
1344  ObjCIvarDecl *IV = IDecl->lookupInstanceVariable(Member, ClassDeclared);
1345 
1346  if (!IV) {
1347  // Attempt to correct for typos in ivar names.
1348  DeclFilterCCC<ObjCIvarDecl> Validator{};
1349  Validator.IsObjCIvarLookup = IsArrow;
1350  if (TypoCorrection Corrected = S.CorrectTypo(
1351  R.getLookupNameInfo(), Sema::LookupMemberName, nullptr, nullptr,
1352  Validator, Sema::CTK_ErrorRecovery, IDecl)) {
1353  IV = Corrected.getCorrectionDeclAs<ObjCIvarDecl>();
1354  S.diagnoseTypo(
1355  Corrected,
1356  S.PDiag(diag::err_typecheck_member_reference_ivar_suggest)
1357  << IDecl->getDeclName() << MemberName);
1358 
1359  // Figure out the class that declares the ivar.
1360  assert(!ClassDeclared);
1361 
1362  Decl *D = cast<Decl>(IV->getDeclContext());
1363  if (auto *Category = dyn_cast<ObjCCategoryDecl>(D))
1364  D = Category->getClassInterface();
1365 
1366  if (auto *Implementation = dyn_cast<ObjCImplementationDecl>(D))
1367  ClassDeclared = Implementation->getClassInterface();
1368  else if (auto *Interface = dyn_cast<ObjCInterfaceDecl>(D))
1369  ClassDeclared = Interface;
1370 
1371  assert(ClassDeclared && "cannot query interface");
1372  } else {
1373  if (IsArrow &&
1374  IDecl->FindPropertyDeclaration(
1376  S.Diag(MemberLoc, diag::err_property_found_suggest)
1377  << Member << BaseExpr.get()->getType()
1378  << FixItHint::CreateReplacement(OpLoc, ".");
1379  return ExprError();
1380  }
1381 
1382  S.Diag(MemberLoc, diag::err_typecheck_member_reference_ivar)
1383  << IDecl->getDeclName() << MemberName
1384  << BaseExpr.get()->getSourceRange();
1385  return ExprError();
1386  }
1387  }
1388 
1389  assert(ClassDeclared);
1390 
1391  // If the decl being referenced had an error, return an error for this
1392  // sub-expr without emitting another error, in order to avoid cascading
1393  // error cases.
1394  if (IV->isInvalidDecl())
1395  return ExprError();
1396 
1397  // Check whether we can reference this field.
1398  if (S.DiagnoseUseOfDecl(IV, MemberLoc))
1399  return ExprError();
1400  if (IV->getAccessControl() != ObjCIvarDecl::Public &&
1402  ObjCInterfaceDecl *ClassOfMethodDecl = nullptr;
1403  if (ObjCMethodDecl *MD = S.getCurMethodDecl())
1404  ClassOfMethodDecl = MD->getClassInterface();
1405  else if (ObjCImpDecl && S.getCurFunctionDecl()) {
1406  // Case of a c-function declared inside an objc implementation.
1407  // FIXME: For a c-style function nested inside an objc implementation
1408  // class, there is no implementation context available, so we pass
1409  // down the context as argument to this routine. Ideally, this context
1410  // need be passed down in the AST node and somehow calculated from the
1411  // AST for a function decl.
1412  if (ObjCImplementationDecl *IMPD =
1413  dyn_cast<ObjCImplementationDecl>(ObjCImpDecl))
1414  ClassOfMethodDecl = IMPD->getClassInterface();
1415  else if (ObjCCategoryImplDecl* CatImplClass =
1416  dyn_cast<ObjCCategoryImplDecl>(ObjCImpDecl))
1417  ClassOfMethodDecl = CatImplClass->getClassInterface();
1418  }
1419  if (!S.getLangOpts().DebuggerSupport) {
1420  if (IV->getAccessControl() == ObjCIvarDecl::Private) {
1421  if (!declaresSameEntity(ClassDeclared, IDecl) ||
1422  !declaresSameEntity(ClassOfMethodDecl, ClassDeclared))
1423  S.Diag(MemberLoc, diag::err_private_ivar_access)
1424  << IV->getDeclName();
1425  } else if (!IDecl->isSuperClassOf(ClassOfMethodDecl))
1426  // @protected
1427  S.Diag(MemberLoc, diag::err_protected_ivar_access)
1428  << IV->getDeclName();
1429  }
1430  }
1431  bool warn = true;
1432  if (S.getLangOpts().ObjCWeak) {
1433  Expr *BaseExp = BaseExpr.get()->IgnoreParenImpCasts();
1434  if (UnaryOperator *UO = dyn_cast<UnaryOperator>(BaseExp))
1435  if (UO->getOpcode() == UO_Deref)
1436  BaseExp = UO->getSubExpr()->IgnoreParenCasts();
1437 
1438  if (DeclRefExpr *DE = dyn_cast<DeclRefExpr>(BaseExp))
1439  if (DE->getType().getObjCLifetime() == Qualifiers::OCL_Weak) {
1440  S.Diag(DE->getLocation(), diag::err_arc_weak_ivar_access);
1441  warn = false;
1442  }
1443  }
1444  if (warn) {
1445  if (ObjCMethodDecl *MD = S.getCurMethodDecl()) {
1446  ObjCMethodFamily MF = MD->getMethodFamily();
1447  warn = (MF != OMF_init && MF != OMF_dealloc &&
1448  MF != OMF_finalize &&
1449  !S.IvarBacksCurrentMethodAccessor(IDecl, MD, IV));
1450  }
1451  if (warn)
1452  S.Diag(MemberLoc, diag::warn_direct_ivar_access) << IV->getDeclName();
1453  }
1454 
1455  ObjCIvarRefExpr *Result = new (S.Context) ObjCIvarRefExpr(
1456  IV, IV->getUsageType(BaseType), MemberLoc, OpLoc, BaseExpr.get(),
1457  IsArrow);
1458 
1459  if (IV->getType().getObjCLifetime() == Qualifiers::OCL_Weak) {
1460  if (!S.isUnevaluatedContext() &&
1461  !S.Diags.isIgnored(diag::warn_arc_repeated_use_of_weak, MemberLoc))
1462  S.getCurFunction()->recordUseOfWeak(Result);
1463  }
1464 
1465  return Result;
1466  }
1467 
1468  // Objective-C property access.
1469  const ObjCObjectPointerType *OPT;
1470  if (!IsArrow && (OPT = BaseType->getAs<ObjCObjectPointerType>())) {
1471  if (!SS.isEmpty() && !SS.isInvalid()) {
1472  S.Diag(SS.getRange().getBegin(), diag::err_qualified_objc_access)
1473  << 0 << SS.getScopeRep() << FixItHint::CreateRemoval(SS.getRange());
1474  SS.clear();
1475  }
1476 
1477  // This actually uses the base as an r-value.
1478  BaseExpr = S.DefaultLvalueConversion(BaseExpr.get());
1479  if (BaseExpr.isInvalid())
1480  return ExprError();
1481 
1482  assert(S.Context.hasSameUnqualifiedType(BaseType,
1483  BaseExpr.get()->getType()));
1484 
1485  IdentifierInfo *Member = MemberName.getAsIdentifierInfo();
1486 
1487  const ObjCObjectType *OT = OPT->getObjectType();
1488 
1489  // id, with and without qualifiers.
1490  if (OT->isObjCId()) {
1491  // Check protocols on qualified interfaces.
1493  if (Decl *PMDecl =
1494  FindGetterSetterNameDecl(OPT, Member, Sel, S.Context)) {
1495  if (ObjCPropertyDecl *PD = dyn_cast<ObjCPropertyDecl>(PMDecl)) {
1496  // Check the use of this declaration
1497  if (S.DiagnoseUseOfDecl(PD, MemberLoc))
1498  return ExprError();
1499 
1500  return new (S.Context)
1502  OK_ObjCProperty, MemberLoc, BaseExpr.get());
1503  }
1504 
1505  if (ObjCMethodDecl *OMD = dyn_cast<ObjCMethodDecl>(PMDecl)) {
1506  Selector SetterSel =
1508  S.PP.getSelectorTable(),
1509  Member);
1510  ObjCMethodDecl *SMD = nullptr;
1511  if (Decl *SDecl = FindGetterSetterNameDecl(OPT,
1512  /*Property id*/ nullptr,
1513  SetterSel, S.Context))
1514  SMD = dyn_cast<ObjCMethodDecl>(SDecl);
1515 
1516  return new (S.Context)
1518  OK_ObjCProperty, MemberLoc, BaseExpr.get());
1519  }
1520  }
1521  // Use of id.member can only be for a property reference. Do not
1522  // use the 'id' redefinition in this case.
1523  if (IsArrow && ShouldTryAgainWithRedefinitionType(S, BaseExpr))
1524  return LookupMemberExpr(S, R, BaseExpr, IsArrow, OpLoc, SS,
1525  ObjCImpDecl, HasTemplateArgs, TemplateKWLoc);
1526 
1527  return ExprError(S.Diag(MemberLoc, diag::err_property_not_found)
1528  << MemberName << BaseType);
1529  }
1530 
1531  // 'Class', unqualified only.
1532  if (OT->isObjCClass()) {
1533  // Only works in a method declaration (??!).
1534  ObjCMethodDecl *MD = S.getCurMethodDecl();
1535  if (!MD) {
1536  if (ShouldTryAgainWithRedefinitionType(S, BaseExpr))
1537  return LookupMemberExpr(S, R, BaseExpr, IsArrow, OpLoc, SS,
1538  ObjCImpDecl, HasTemplateArgs, TemplateKWLoc);
1539 
1540  goto fail;
1541  }
1542 
1543  // Also must look for a getter name which uses property syntax.
1545  ObjCInterfaceDecl *IFace = MD->getClassInterface();
1546  if (!IFace)
1547  goto fail;
1548 
1549  ObjCMethodDecl *Getter;
1550  if ((Getter = IFace->lookupClassMethod(Sel))) {
1551  // Check the use of this method.
1552  if (S.DiagnoseUseOfDecl(Getter, MemberLoc))
1553  return ExprError();
1554  } else
1555  Getter = IFace->lookupPrivateMethod(Sel, false);
1556  // If we found a getter then this may be a valid dot-reference, we
1557  // will look for the matching setter, in case it is needed.
1558  Selector SetterSel =
1560  S.PP.getSelectorTable(),
1561  Member);
1562  ObjCMethodDecl *Setter = IFace->lookupClassMethod(SetterSel);
1563  if (!Setter) {
1564  // If this reference is in an @implementation, also check for 'private'
1565  // methods.
1566  Setter = IFace->lookupPrivateMethod(SetterSel, false);
1567  }
1568 
1569  if (Setter && S.DiagnoseUseOfDecl(Setter, MemberLoc))
1570  return ExprError();
1571 
1572  if (Getter || Setter) {
1573  return new (S.Context) ObjCPropertyRefExpr(
1574  Getter, Setter, S.Context.PseudoObjectTy, VK_LValue,
1575  OK_ObjCProperty, MemberLoc, BaseExpr.get());
1576  }
1577 
1578  if (ShouldTryAgainWithRedefinitionType(S, BaseExpr))
1579  return LookupMemberExpr(S, R, BaseExpr, IsArrow, OpLoc, SS,
1580  ObjCImpDecl, HasTemplateArgs, TemplateKWLoc);
1581 
1582  return ExprError(S.Diag(MemberLoc, diag::err_property_not_found)
1583  << MemberName << BaseType);
1584  }
1585 
1586  // Normal property access.
1587  return S.HandleExprPropertyRefExpr(OPT, BaseExpr.get(), OpLoc, MemberName,
1588  MemberLoc, SourceLocation(), QualType(),
1589  false);
1590  }
1591 
1592  // Handle 'field access' to vectors, such as 'V.xx'.
1593  if (BaseType->isExtVectorType()) {
1594  // FIXME: this expr should store IsArrow.
1595  IdentifierInfo *Member = MemberName.getAsIdentifierInfo();
1596  ExprValueKind VK;
1597  if (IsArrow)
1598  VK = VK_LValue;
1599  else {
1600  if (PseudoObjectExpr *POE = dyn_cast<PseudoObjectExpr>(BaseExpr.get()))
1601  VK = POE->getSyntacticForm()->getValueKind();
1602  else
1603  VK = BaseExpr.get()->getValueKind();
1604  }
1605 
1606  QualType ret = CheckExtVectorComponent(S, BaseType, VK, OpLoc,
1607  Member, MemberLoc);
1608  if (ret.isNull())
1609  return ExprError();
1610  Qualifiers BaseQ =
1611  S.Context.getCanonicalType(BaseExpr.get()->getType()).getQualifiers();
1612  ret = S.Context.getQualifiedType(ret, BaseQ);
1613 
1614  return new (S.Context)
1615  ExtVectorElementExpr(ret, VK, BaseExpr.get(), *Member, MemberLoc);
1616  }
1617 
1618  // Adjust builtin-sel to the appropriate redefinition type if that's
1619  // not just a pointer to builtin-sel again.
1620  if (IsArrow && BaseType->isSpecificBuiltinType(BuiltinType::ObjCSel) &&
1622  BaseExpr = S.ImpCastExprToType(
1623  BaseExpr.get(), S.Context.getObjCSelRedefinitionType(), CK_BitCast);
1624  return LookupMemberExpr(S, R, BaseExpr, IsArrow, OpLoc, SS,
1625  ObjCImpDecl, HasTemplateArgs, TemplateKWLoc);
1626  }
1627 
1628  // Failure cases.
1629  fail:
1630 
1631  // Recover from dot accesses to pointers, e.g.:
1632  // type *foo;
1633  // foo.bar
1634  // This is actually well-formed in two cases:
1635  // - 'type' is an Objective C type
1636  // - 'bar' is a pseudo-destructor name which happens to refer to
1637  // the appropriate pointer type
1638  if (const PointerType *Ptr = BaseType->getAs<PointerType>()) {
1639  if (!IsArrow && Ptr->getPointeeType()->isRecordType() &&
1641  S.Diag(OpLoc, diag::err_typecheck_member_reference_suggestion)
1642  << BaseType << int(IsArrow) << BaseExpr.get()->getSourceRange()
1643  << FixItHint::CreateReplacement(OpLoc, "->");
1644 
1645  // Recurse as an -> access.
1646  IsArrow = true;
1647  return LookupMemberExpr(S, R, BaseExpr, IsArrow, OpLoc, SS,
1648  ObjCImpDecl, HasTemplateArgs, TemplateKWLoc);
1649  }
1650  }
1651 
1652  // If the user is trying to apply -> or . to a function name, it's probably
1653  // because they forgot parentheses to call that function.
1654  if (S.tryToRecoverWithCall(
1655  BaseExpr, S.PDiag(diag::err_member_reference_needs_call),
1656  /*complain*/ false,
1657  IsArrow ? &isPointerToRecordType : &isRecordType)) {
1658  if (BaseExpr.isInvalid())
1659  return ExprError();
1660  BaseExpr = S.DefaultFunctionArrayConversion(BaseExpr.get());
1661  return LookupMemberExpr(S, R, BaseExpr, IsArrow, OpLoc, SS,
1662  ObjCImpDecl, HasTemplateArgs, TemplateKWLoc);
1663  }
1664 
1665  S.Diag(OpLoc, diag::err_typecheck_member_reference_struct_union)
1666  << BaseType << BaseExpr.get()->getSourceRange() << MemberLoc;
1667 
1668  return ExprError();
1669 }
1670 
1671 /// The main callback when the parser finds something like
1672 /// expression . [nested-name-specifier] identifier
1673 /// expression -> [nested-name-specifier] identifier
1674 /// where 'identifier' encompasses a fairly broad spectrum of
1675 /// possibilities, including destructor and operator references.
1676 ///
1677 /// \param OpKind either tok::arrow or tok::period
1678 /// \param ObjCImpDecl the current Objective-C \@implementation
1679 /// decl; this is an ugly hack around the fact that Objective-C
1680 /// \@implementations aren't properly put in the context chain
1682  SourceLocation OpLoc,
1683  tok::TokenKind OpKind,
1684  CXXScopeSpec &SS,
1685  SourceLocation TemplateKWLoc,
1686  UnqualifiedId &Id,
1687  Decl *ObjCImpDecl) {
1688  if (SS.isSet() && SS.isInvalid())
1689  return ExprError();
1690 
1691  // Warn about the explicit constructor calls Microsoft extension.
1692  if (getLangOpts().MicrosoftExt &&
1694  Diag(Id.getSourceRange().getBegin(),
1695  diag::ext_ms_explicit_constructor_call);
1696 
1697  TemplateArgumentListInfo TemplateArgsBuffer;
1698 
1699  // Decompose the name into its component parts.
1700  DeclarationNameInfo NameInfo;
1701  const TemplateArgumentListInfo *TemplateArgs;
1702  DecomposeUnqualifiedId(Id, TemplateArgsBuffer,
1703  NameInfo, TemplateArgs);
1704 
1705  DeclarationName Name = NameInfo.getName();
1706  bool IsArrow = (OpKind == tok::arrow);
1707 
1708  NamedDecl *FirstQualifierInScope
1709  = (!SS.isSet() ? nullptr : FindFirstQualifierInScope(S, SS.getScopeRep()));
1710 
1711  // This is a postfix expression, so get rid of ParenListExprs.
1713  if (Result.isInvalid()) return ExprError();
1714  Base = Result.get();
1715 
1716  if (Base->getType()->isDependentType() || Name.isDependentName() ||
1718  return ActOnDependentMemberExpr(Base, Base->getType(), IsArrow, OpLoc, SS,
1719  TemplateKWLoc, FirstQualifierInScope,
1720  NameInfo, TemplateArgs);
1721  }
1722 
1723  ActOnMemberAccessExtraArgs ExtraArgs = {S, Id, ObjCImpDecl};
1725  Base, Base->getType(), OpLoc, IsArrow, SS, TemplateKWLoc,
1726  FirstQualifierInScope, NameInfo, TemplateArgs, S, &ExtraArgs);
1727 
1728  if (!Res.isInvalid() && isa<MemberExpr>(Res.get()))
1729  CheckMemberAccessOfNoDeref(cast<MemberExpr>(Res.get()));
1730 
1731  return Res;
1732 }
1733 
1734 void Sema::CheckMemberAccessOfNoDeref(const MemberExpr *E) {
1735  if (isUnevaluatedContext())
1736  return;
1737 
1738  QualType ResultTy = E->getType();
1739 
1740  // Member accesses have four cases:
1741  // 1: non-array member via "->": dereferences
1742  // 2: non-array member via ".": nothing interesting happens
1743  // 3: array member access via "->": nothing interesting happens
1744  // (this returns an array lvalue and does not actually dereference memory)
1745  // 4: array member access via ".": *adds* a layer of indirection
1746  if (ResultTy->isArrayType()) {
1747  if (!E->isArrow()) {
1748  // This might be something like:
1749  // (*structPtr).arrayMember
1750  // which behaves roughly like:
1751  // &(*structPtr).pointerMember
1752  // in that the apparent dereference in the base expression does not
1753  // actually happen.
1754  CheckAddressOfNoDeref(E->getBase());
1755  }
1756  } else if (E->isArrow()) {
1757  if (const auto *Ptr = dyn_cast<PointerType>(
1759  if (Ptr->getPointeeType()->hasAttr(attr::NoDeref))
1760  ExprEvalContexts.back().PossibleDerefs.insert(E);
1761  }
1762  }
1763 }
1764 
1765 ExprResult
1766 Sema::BuildFieldReferenceExpr(Expr *BaseExpr, bool IsArrow,
1767  SourceLocation OpLoc, const CXXScopeSpec &SS,
1768  FieldDecl *Field, DeclAccessPair FoundDecl,
1769  const DeclarationNameInfo &MemberNameInfo) {
1770  // x.a is an l-value if 'a' has a reference type. Otherwise:
1771  // x.a is an l-value/x-value/pr-value if the base is (and note
1772  // that *x is always an l-value), except that if the base isn't
1773  // an ordinary object then we must have an rvalue.
1774  ExprValueKind VK = VK_LValue;
1776  if (!IsArrow) {
1777  if (BaseExpr->getObjectKind() == OK_Ordinary)
1778  VK = BaseExpr->getValueKind();
1779  else
1780  VK = VK_PRValue;
1781  }
1782  if (VK != VK_PRValue && Field->isBitField())
1783  OK = OK_BitField;
1784 
1785  // Figure out the type of the member; see C99 6.5.2.3p3, C++ [expr.ref]
1786  QualType MemberType = Field->getType();
1787  if (const ReferenceType *Ref = MemberType->getAs<ReferenceType>()) {
1788  MemberType = Ref->getPointeeType();
1789  VK = VK_LValue;
1790  } else {
1791  QualType BaseType = BaseExpr->getType();
1792  if (IsArrow) BaseType = BaseType->castAs<PointerType>()->getPointeeType();
1793 
1794  Qualifiers BaseQuals = BaseType.getQualifiers();
1795 
1796  // GC attributes are never picked up by members.
1797  BaseQuals.removeObjCGCAttr();
1798 
1799  // CVR attributes from the base are picked up by members,
1800  // except that 'mutable' members don't pick up 'const'.
1801  if (Field->isMutable()) BaseQuals.removeConst();
1802 
1803  Qualifiers MemberQuals =
1804  Context.getCanonicalType(MemberType).getQualifiers();
1805 
1806  assert(!MemberQuals.hasAddressSpace());
1807 
1808  Qualifiers Combined = BaseQuals + MemberQuals;
1809  if (Combined != MemberQuals)
1810  MemberType = Context.getQualifiedType(MemberType, Combined);
1811 
1812  // Pick up NoDeref from the base in case we end up using AddrOf on the
1813  // result. E.g. the expression
1814  // &someNoDerefPtr->pointerMember
1815  // should be a noderef pointer again.
1816  if (BaseType->hasAttr(attr::NoDeref))
1817  MemberType =
1818  Context.getAttributedType(attr::NoDeref, MemberType, MemberType);
1819  }
1820 
1821  auto *CurMethod = dyn_cast<CXXMethodDecl>(CurContext);
1822  if (!(CurMethod && CurMethod->isDefaulted()))
1823  UnusedPrivateFields.remove(Field);
1824 
1826  FoundDecl, Field);
1827  if (Base.isInvalid())
1828  return ExprError();
1829 
1830  // Build a reference to a private copy for non-static data members in
1831  // non-static member functions, privatized by OpenMP constructs.
1832  if (getLangOpts().OpenMP && IsArrow &&
1834  isa<CXXThisExpr>(Base.get()->IgnoreParenImpCasts())) {
1835  if (auto *PrivateCopy = isOpenMPCapturedDecl(Field)) {
1836  return getOpenMPCapturedExpr(PrivateCopy, VK, OK,
1837  MemberNameInfo.getLoc());
1838  }
1839  }
1840 
1841  return BuildMemberExpr(Base.get(), IsArrow, OpLoc, &SS,
1842  /*TemplateKWLoc=*/SourceLocation(), Field, FoundDecl,
1843  /*HadMultipleCandidates=*/false, MemberNameInfo,
1844  MemberType, VK, OK);
1845 }
1846 
1847 /// Builds an implicit member access expression. The current context
1848 /// is known to be an instance method, and the given unqualified lookup
1849 /// set is known to contain only instance members, at least one of which
1850 /// is from an appropriate type.
1851 ExprResult
1853  SourceLocation TemplateKWLoc,
1854  LookupResult &R,
1855  const TemplateArgumentListInfo *TemplateArgs,
1856  bool IsKnownInstance, const Scope *S) {
1857  assert(!R.empty() && !R.isAmbiguous());
1858 
1859  SourceLocation loc = R.getNameLoc();
1860 
1861  // If this is known to be an instance access, go ahead and build an
1862  // implicit 'this' expression now.
1863  QualType ThisTy = getCurrentThisType();
1864  assert(!ThisTy.isNull() && "didn't correctly pre-flight capture of 'this'");
1865 
1866  Expr *baseExpr = nullptr; // null signifies implicit access
1867  if (IsKnownInstance) {
1868  SourceLocation Loc = R.getNameLoc();
1869  if (SS.getRange().isValid())
1870  Loc = SS.getRange().getBegin();
1871  baseExpr = BuildCXXThisExpr(loc, ThisTy, /*IsImplicit=*/true);
1872  }
1873 
1874  return BuildMemberReferenceExpr(baseExpr, ThisTy,
1875  /*OpLoc*/ SourceLocation(),
1876  /*IsArrow*/ true,
1877  SS, TemplateKWLoc,
1878  /*FirstQualifierInScope*/ nullptr,
1879  R, TemplateArgs, S);
1880 }
clang::CorrectionCandidateCallback::IsObjCIvarLookup
bool IsObjCIvarLookup
Definition: TypoCorrection.h:336
clang::UnqualifiedId
Represents a C++ unqualified-id that has been parsed.
Definition: DeclSpec.h:951
clang::ObjCInterfaceDecl
Represents an ObjC class declaration.
Definition: DeclObjC.h:1151
clang::Sema::BuildDeclarationNameExpr
ExprResult BuildDeclarationNameExpr(const CXXScopeSpec &SS, LookupResult &R, bool NeedsADL, bool AcceptInvalidDecl=false)
Definition: SemaExpr.cpp:3151
clang::Sema::CurContext
DeclContext * CurContext
CurContext - This is the current declaration context of parsing.
Definition: Sema.h:423
clang::Expr::getValueKind
ExprValueKind getValueKind() const
getValueKind - The value kind that this expression produces.
Definition: Expr.h:430
clang::ASTContext::getQualifiedType
QualType getQualifiedType(SplitQualType split) const
Un-split a SplitQualType.
Definition: ASTContext.h:2086
clang::ASTContext::getTypedefType
QualType getTypedefType(const TypedefNameDecl *Decl, QualType Underlying=QualType()) const
Return the unique reference to the type for the specified typedef-name decl.
Definition: ASTContext.cpp:4582
clang::Sema::LookupTemplateName
bool LookupTemplateName(LookupResult &R, Scope *S, CXXScopeSpec &SS, QualType ObjectType, bool EnteringContext, bool &MemberOfUnknownSpecialization, RequiredTemplateKind RequiredTemplate=SourceLocation(), AssumedTemplateKind *ATK=nullptr, bool AllowTypoCorrection=true)
Definition: SemaTemplate.cpp:370
clang::Type::isRecordType
bool isRecordType() const
Definition: Type.h:6763
clang::Sema::isDependentScopeSpecifier
bool isDependentScopeSpecifier(const CXXScopeSpec &SS)
Definition: SemaCXXScopeSpec.cpp:167
clang::Sema::CorrectTypoDelayed
TypoExpr * CorrectTypoDelayed(const DeclarationNameInfo &Typo, Sema::LookupNameKind LookupKind, Scope *S, CXXScopeSpec *SS, CorrectionCandidateCallback &CCC, TypoDiagnosticGenerator TDG, TypoRecoveryCallback TRC, CorrectTypoKind Mode, DeclContext *MemberContext=nullptr, bool EnteringContext=false, const ObjCObjectPointerType *OPT=nullptr)
Try to "correct" a typo in the source code by finding visible declarations whose names are similar to...
Definition: SemaLookup.cpp:5148
clang::QualType::getObjCLifetime
Qualifiers::ObjCLifetime getObjCLifetime() const
Returns lifetime attribute of this type.
Definition: Type.h:1120
IMA_Instance
@ IMA_Instance
The reference is definitely an implicit instance member access.
Definition: SemaExprMember.cpp:56
clang::Sema::CheckPlaceholderExpr
ExprResult CheckPlaceholderExpr(Expr *E)
Check for operands with placeholder types and complain if found.
Definition: SemaExpr.cpp:19703
IMA_Field_Uneval_Context
@ IMA_Field_Uneval_Context
Definition: SemaExprMember.cpp:71
clang::ObjCProtocolDecl::protocols
protocol_range protocols() const
Definition: DeclObjC.h:2115
clang::Type::hasAttr
bool hasAttr(attr::Kind AK) const
Determine whether this type had the specified attribute applied to it (looking through top-level type...
Definition: Type.cpp:1770
clang::IndirectFieldDecl::chain_begin
chain_iterator chain_begin() const
Definition: Decl.h:3114
clang::UnresolvedSetIterator::getPair
const DeclAccessPair & getPair() const
Definition: UnresolvedSet.h:54
clang::VarDecl::setTemplateSpecializationKind
void setTemplateSpecializationKind(TemplateSpecializationKind TSK, SourceLocation PointOfInstantiation=SourceLocation())
For a static data member that was instantiated from a static data member of a class template,...
Definition: Decl.cpp:2714
clang::OK_Ordinary
@ OK_Ordinary
An ordinary object is located at an address in memory.
Definition: Specifiers.h:136
clang::NamedDecl::isCXXInstanceMember
bool isCXXInstanceMember() const
Determine whether the given declaration is an instance member of a C++ class.
Definition: Decl.cpp:1844
type
clang::CXXMethodDecl::isStatic
bool isStatic() const
Definition: DeclCXX.cpp:2091
clang::LangOptions::getOpenCLCompatibleVersion
unsigned getOpenCLCompatibleVersion() const
Return the OpenCL version that kernel language is compatible with.
Definition: LangOptions.cpp:55
clang::SourceRange
A trivial tuple used to represent a source range.
Definition: SourceLocation.h:212
clang::ObjCMethodFamily
ObjCMethodFamily
A family of Objective-C methods.
Definition: IdentifierTable.h:686
clang::LookupResult::end
iterator end() const
Definition: Lookup.h:336
clang::DeclContext
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
Definition: DeclBase.h:1347
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::IndirectFieldDecl::chain_end
chain_iterator chain_end() const
Definition: Decl.h:3115
clang::Sema::MarkMemberReferenced
void MarkMemberReferenced(MemberExpr *E)
Perform reference-marking and odr-use handling for a MemberExpr.
Definition: SemaExpr.cpp:18778
clang::ObjCImplementationDecl
ObjCImplementationDecl - Represents a class definition - this is where method definitions are specifi...
Definition: DeclObjC.h:2546
clang::Sema::isOpenMPCapturedDecl
VarDecl * isOpenMPCapturedDecl(ValueDecl *D, bool CheckScopeInfo=false, unsigned StopAt=0)
Check if the specified variable is used in one of the private clauses (private, firstprivate,...
Definition: SemaOpenMP.cpp:2186
clang::Sema::getCurFunction
sema::FunctionScopeInfo * getCurFunction() const
Definition: Sema.h:1899
IMA_Static
@ IMA_Static
The reference is definitely not an instance member access.
Definition: SemaExprMember.cpp:42
Diag
static DiagnosticBuilder Diag(DiagnosticsEngine *Diags, const LangOptions &Features, FullSourceLoc TokLoc, const char *TokBegin, const char *TokRangeBegin, const char *TokRangeEnd, unsigned DiagID)
Produce a diagnostic highlighting some portion of a literal.
Definition: LiteralSupport.cpp:78
clang::Qualifiers::OCL_Weak
@ OCL_Weak
Reading or writing from this object requires a barrier call.
Definition: Type.h:176
SemaInternal.h
clang::Sema::ExpressionEvaluationContext::UnevaluatedAbstract
@ UnevaluatedAbstract
The current expression occurs within an unevaluated operand that unconditionally permits abstract ref...
clang::ExtVectorType::getPointAccessorIdx
static int getPointAccessorIdx(char c)
Definition: Type.h:3357
clang::Sema::RequireCompleteDeclContext
bool RequireCompleteDeclContext(CXXScopeSpec &SS, DeclContext *DC)
Require that the context specified by SS be complete.
Definition: SemaCXXScopeSpec.cpp:199
Lookup.h
clang::SourceLocation
Encodes a location in the source.
Definition: SourceLocation.h:88
clang::MSPropertyRefExpr
A member reference to an MSPropertyDecl.
Definition: ExprCXX.h:923
clang::QualType::getQualifiers
Qualifiers getQualifiers() const
Retrieve the set of qualifiers applied to this type.
Definition: Type.h:6452
clang::Sema::ActOnStartCXXMemberReference
ExprResult ActOnStartCXXMemberReference(Scope *S, Expr *Base, SourceLocation OpLoc, tok::TokenKind OpKind, ParsedType &ObjectType, bool &MayBePseudoDestructor)
Definition: SemaExprCXX.cpp:7282
clang::DiagnosticsEngine::isIgnored
bool isIgnored(unsigned DiagID, SourceLocation Loc) const
Determine whether the diagnostic is known to be ignored.
Definition: Diagnostic.h:909
clang::NamedDecl
This represents a decl that may have a name.
Definition: Decl.h:249
clang::SourceRange::getBegin
SourceLocation getBegin() const
Definition: SourceLocation.h:221
clang::Sema::TemporaryMaterializationConversion
ExprResult TemporaryMaterializationConversion(Expr *E)
If E is a prvalue denoting an unmaterialized temporary, materialize it as an xvalue.
Definition: SemaInit.cpp:7950
clang::MemberExpr::Create
static MemberExpr * Create(const ASTContext &C, Expr *Base, bool IsArrow, SourceLocation OperatorLoc, NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc, ValueDecl *MemberDecl, DeclAccessPair FoundDecl, DeclarationNameInfo MemberNameInfo, const TemplateArgumentListInfo *TemplateArgs, QualType T, ExprValueKind VK, ExprObjectKind OK, NonOdrUseReason NOUR)
Definition: Expr.cpp:1646
clang::NamedDecl::getUnderlyingDecl
NamedDecl * getUnderlyingDecl()
Looks through UsingDecls and ObjCCompatibleAliasDecls for the underlying named decl.
Definition: Decl.h:459
clang::QualType::getNonReferenceType
QualType getNonReferenceType() const
If Type is a reference type (e.g., const int&), returns the type that the reference refers to ("const...
Definition: Type.h:6621
clang::ASTContext::PseudoObjectTy
CanQualType PseudoObjectTy
Definition: ASTContext.h:1105
clang::ASTContext::getObjCSelRedefinitionType
QualType getObjCSelRedefinitionType() const
Retrieve the type that 'SEL' has been defined to, which may be different from the built-in 'SEL' if '...
Definition: ASTContext.h:1820
clang::Stmt::getSourceRange
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation tokens are not useful in isolation - they are low level value objects created/interpre...
Definition: Stmt.cpp:324
clang::UnresolvedMemberExpr
Represents a C++ member access expression for which lookup produced a set of overloaded functions.
Definition: ExprCXX.h:3810
clang::QualType
A (possibly-)qualified type.
Definition: Type.h:673
clang::Expr::getObjectKind
ExprObjectKind getObjectKind() const
getObjectKind - The object kind that this expression produces.
Definition: Expr.h:437
clang::ObjCIvarDecl::getAccessControl
AccessControl getAccessControl() const
Definition: DeclObjC.h:1970
clang::ObjCInterfaceDecl::lookupClassMethod
ObjCMethodDecl * lookupClassMethod(Selector Sel) const
Lookup a class method for a given selector.
Definition: DeclObjC.h:1831
clang::OMF_finalize
@ OMF_finalize
Definition: IdentifierTable.h:704
clang::OMF_init
@ OMF_init
Definition: IdentifierTable.h:696
clang::UnresolvedSetIterator
The iterator over UnresolvedSets.
Definition: UnresolvedSet.h:32
clang::FieldDecl
Represents a member of a struct/union/class.
Definition: Decl.h:2835
clang::LookupResult
Represents the results of name lookup.
Definition: Lookup.h:46
clang::Qualifiers
The collection of all-type qualifiers we support.
Definition: Type.h:145
clang::Sema::BuildMemberReferenceExpr
ExprResult BuildMemberReferenceExpr(Expr *Base, QualType BaseType, SourceLocation OpLoc, bool IsArrow, CXXScopeSpec &SS, SourceLocation TemplateKWLoc, NamedDecl *FirstQualifierInScope, const DeclarationNameInfo &NameInfo, const TemplateArgumentListInfo *TemplateArgs, const Scope *S, ActOnMemberAccessExtraArgs *ExtraArgs=nullptr)
Definition: SemaExprMember.cpp:740
clang::ast_matchers::type
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
Definition: ASTMatchersInternal.cpp:772
clang::isUnresolvedExceptionSpec
bool isUnresolvedExceptionSpec(ExceptionSpecificationType ESpecType)
Definition: ExceptionSpecificationType.h:49
clang::Sema::Diag
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID, bool DeferHint=false)
Emit a diagnostic.
Definition: Sema.cpp:1834
DeclCXX.h
clang::Type::isObjCSelType
bool isObjCSelType() const
Definition: Type.h:6840
int
__device__ int
Definition: __clang_hip_libdevice_declares.h:63
clang::ObjCMethodDecl::getClassInterface
ObjCInterfaceDecl * getClassInterface()
Definition: DeclObjC.cpp:1168
clang::Sema::ActOnMemberAccessExpr
ExprResult ActOnMemberAccessExpr(Scope *S, Expr *Base, SourceLocation OpLoc, tok::TokenKind OpKind, CXXScopeSpec &SS, SourceLocation TemplateKWLoc, UnqualifiedId &Member, Decl *ObjCImpDecl)
The main callback when the parser finds something like expression .
Definition: SemaExprMember.cpp:1681
clang::ExprObjectKind
ExprObjectKind
A further classification of the kind of object referenced by an l-value or x-value.
Definition: Specifiers.h:134
clang::SourceRange::isValid
bool isValid() const
Definition: SourceLocation.h:227
clang::Sema::ExpressionEvaluationContext::DiscardedStatement
@ DiscardedStatement
The current expression occurs within a discarded statement.
clang::Sema::LookupQualifiedName
bool LookupQualifiedName(LookupResult &R, DeclContext *LookupCtx, bool InUnqualifiedLookup=false)
Perform qualified name lookup into a given context.
Definition: SemaLookup.cpp:2152
clang::Sema::ActOnMemberAccessExtraArgs::S
Scope * S
Definition: Sema.h:5382
llvm::SmallPtrSet
Definition: ASTContext.h:82
clang::UnaryOperator
UnaryOperator - This represents the unary-expression's (except sizeof and alignof),...
Definition: Expr.h:2157
clang::Expr::isPRValue
bool isPRValue() const
Definition: Expr.h:271
clang::Sema::ExpressionEvaluationContext::PotentiallyEvaluatedIfUsed
@ PotentiallyEvaluatedIfUsed
The current expression is potentially evaluated, but any declarations referenced inside that expressi...
IMA_Mixed_StaticContext
@ IMA_Mixed_StaticContext
The reference may be to an instance member, but it might be invalid if so, because the context is not...
Definition: SemaExprMember.cpp:49
clang::CXXScopeSpec
Represents a C++ nested-name-specifier or a global scope specifier.
Definition: DeclSpec.h:64
clang::ASTContext::getObjCIdRedefinitionType
QualType getObjCIdRedefinitionType() const
Retrieve the type that id has been defined to, which may be different from the built-in id if id has ...
Definition: ASTContext.h:1794
ASTLambda.h
clang::DeclarationName::getAsIdentifierInfo
IdentifierInfo * getAsIdentifierInfo() const
Retrieve the IdentifierInfo * stored in this declaration name, or null if this declaration name isn't...
Definition: DeclarationName.h:410
clang::Sema::ActOnMemberAccessExtraArgs::Id
UnqualifiedId & Id
Definition: Sema.h:5383
clang::ObjCIvarDecl::Public
@ Public
Definition: DeclObjC.h:1929
clang::Sema::ExprEvalContexts
SmallVector< ExpressionEvaluationContextRecord, 8 > ExprEvalContexts
A stack of expression evaluation contexts.
Definition: Sema.h:1322
FindGetterSetterNameDecl
static Decl * FindGetterSetterNameDecl(const ObjCObjectPointerType *QIdTy, IdentifierInfo *Member, const Selector &Sel, ASTContext &Context)
Definition: SemaExprMember.cpp:449
clang::ObjCObjectType::getInterface
ObjCInterfaceDecl * getInterface() const
Gets the interface declaration for this object type, if the base type really is an interface.
Definition: Type.h:6052
clang::Expr::IgnoreImpCasts
Expr * IgnoreImpCasts() LLVM_READONLY
Skip past any implicit casts which might surround this expression until reaching a fixed point.
Definition: Expr.cpp:2899
clang::DeclarationName
The name of a declaration.
Definition: DeclarationName.h:145
clang::LookupResult::begin
iterator begin() const
Definition: Lookup.h:335
clang::LookupResult::getNameLoc
SourceLocation getNameLoc() const
Gets the location of the identifier.
Definition: Lookup.h:606
clang::ObjCObjectPointerType::getObjectType
const ObjCObjectType * getObjectType() const
Gets the type pointed to by this ObjC pointer.
Definition: Type.h:6110
clang::Preprocessor::getIdentifierTable
IdentifierTable & getIdentifierTable()
Definition: Preprocessor.h:967
clang::Sema::isUnevaluatedContext
bool isUnevaluatedContext() const
Determines whether we are currently in a context that is not evaluated as per C++ [expr] p5.
Definition: Sema.h:9129
clang::sema::FunctionScopeInfo::recordUseOfWeak
void recordUseOfWeak(const ExprT *E, bool IsRead=true)
Record that a weak object was accessed.
Definition: ScopeInfo.h:1034
diagnoseInstanceReference
static void diagnoseInstanceReference(Sema &SemaRef, const CXXScopeSpec &SS, NamedDecl *Rep, const DeclarationNameInfo &nameInfo)
Diagnose a reference to a field with no object available.
Definition: SemaExprMember.cpp:197
clang::Sema::Context
ASTContext & Context
Definition: Sema.h:411
Preprocessor.h
Overload.h
clang::Sema::BuildFieldReferenceExpr
ExprResult BuildFieldReferenceExpr(Expr *BaseExpr, bool IsArrow, SourceLocation OpLoc, const CXXScopeSpec &SS, FieldDecl *Field, DeclAccessPair FoundDecl, const DeclarationNameInfo &MemberNameInfo)
Definition: SemaExprMember.cpp:1766
clang::DeclContext::getNonTransparentContext
DeclContext * getNonTransparentContext()
Definition: DeclBase.cpp:1220
clang::ExprError
ExprResult ExprError()
Definition: Ownership.h:278
clang::CXXScopeSpec::clear
void clear()
Definition: DeclSpec.h:212
clang::ObjCObjectType
Represents a class type in Objective C.
Definition: Type.h:5816
clang::Sema::SFINAETrap
RAII class used to determine whether SFINAE has trapped any errors that occur during template argumen...
Definition: Sema.h:9151
clang::Type::isExtVectorType
bool isExtVectorType() const
Definition: Type.h:6779
DeclObjC.h
clang::ASTContext::getAttributedType
QualType getAttributedType(attr::Kind attrKind, QualType modifiedType, QualType equivalentType)
Definition: ASTContext.cpp:4622
clang::CXXScopeSpec::isSet
bool isSet() const
Deprecated.
Definition: DeclSpec.h:210
clang::LookupResult::isUnresolvableResult
bool isUnresolvableResult() const
Definition: Lookup.h:317
clang::ObjCPropertyRefExpr
ObjCPropertyRefExpr - A dot-syntax expression to access an ObjC property.
Definition: ExprObjC.h:614
clang::ASTContext::BoundMemberTy
CanQualType BoundMemberTy
Definition: ASTContext.h:1103
clang::Sema::getLangOpts
const LangOptions & getLangOpts() const
Definition: Sema.h:1569
clang::IndirectFieldDecl::chain_iterator
ArrayRef< NamedDecl * >::const_iterator chain_iterator
Definition: Decl.h:3109
clang::ObjCObjectPointerType::quals
qual_range quals() const
Definition: Type.h:6192
clang::Sema::LookupMemberName
@ LookupMemberName
Member name lookup, which finds the names of class/struct/union members.
Definition: Sema.h:3980
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:8416
IMA_Unresolved_StaticContext
@ IMA_Unresolved_StaticContext
The reference may be to an unresolved using declaration and the context is not an instance method.
Definition: SemaExprMember.cpp:66
clang::Sema::BuildAnonymousStructUnionMemberReference
ExprResult BuildAnonymousStructUnionMemberReference(const CXXScopeSpec &SS, SourceLocation nameLoc, IndirectFieldDecl *indirectField, DeclAccessPair FoundDecl=DeclAccessPair::make(nullptr, AS_none), Expr *baseObjectExpr=nullptr, SourceLocation opLoc=SourceLocation())
Definition: SemaExprMember.cpp:799
clang::ASTContext::getExtVectorType
QualType getExtVectorType(QualType VectorType, unsigned NumElts) const
Return the unique reference to an extended vector type of the specified element type and size.
Definition: ASTContext.cpp:4040
clang::Sema::ExpressionEvaluationContext::UnevaluatedList
@ UnevaluatedList
The current expression occurs within a braced-init-list within an unevaluated operand.
clang::Sema::CheckVarTemplateId
DeclResult CheckVarTemplateId(VarTemplateDecl *Template, SourceLocation TemplateLoc, SourceLocation TemplateNameLoc, const TemplateArgumentListInfo &TemplateArgs)
Get the specialization of the given variable template corresponding to the specified argument list,...
Definition: SemaTemplate.cpp:4483
clang::RecordType
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
Definition: Type.h:4613
DeclTemplate.h
clang::UnresolvedLookupExpr
A reference to a name which we were able to look up during parsing but could not resolve to a specifi...
Definition: ExprCXX.h:3073
clang::TemplateArgumentListInfo
A convenient class for passing around template argument information.
Definition: TemplateBase.h:564
clang::Decl::getAccess
AccessSpecifier getAccess() const
Definition: DeclBase.h:478
IsInFnTryBlockHandler
static bool IsInFnTryBlockHandler(const Scope *S)
Determine if the given scope is within a function-try-block handler.
Definition: SemaExprMember.cpp:935
clang::DeclAccessPair::make
static DeclAccessPair make(NamedDecl *D, AccessSpecifier AS)
Definition: DeclAccessPair.h:35
clang::Sema::HandleExprPropertyRefExpr
ExprResult HandleExprPropertyRefExpr(const ObjCObjectPointerType *OPT, Expr *BaseExpr, SourceLocation OpLoc, DeclarationName MemberName, SourceLocation MemberLoc, SourceLocation SuperLoc, QualType SuperType, bool Super)
HandleExprPropertyRefExpr - Handle foo.bar where foo is a pointer to an objective C interface.
Definition: SemaExprObjC.cpp:1976
DiagnoseQualifiedMemberReference
static void DiagnoseQualifiedMemberReference(Sema &SemaRef, Expr *BaseExpr, QualType BaseType, const CXXScopeSpec &SS, NamedDecl *rep, const DeclarationNameInfo &nameInfo)
We know that the given qualified member reference points only to declarations which do not belong to ...
Definition: SemaExprMember.cpp:522
Id
int Id
Definition: ASTDiff.cpp:191
clang::MemberExpr::setHadMultipleCandidates
void setHadMultipleCandidates(bool V=true)
Sets the flag telling whether this expression refers to a method that was resolved from an overloaded...
Definition: Expr.h:3372
IMA_Abstract
@ IMA_Abstract
The reference is a contextually-permitted abstract member reference.
Definition: SemaExprMember.cpp:62
clang::Scope
Scope - A scope is a transient data structure that is used while parsing the program.
Definition: Scope.h:40
clang::MemberExpr::isArrow
bool isArrow() const
Definition: Expr.h:3346
clang::DeclarationName::CXXDestructorName
@ CXXDestructorName
Definition: DeclarationName.h:207
clang::SourceRange::getEnd
SourceLocation getEnd() const
Definition: SourceLocation.h:222
clang::DeclAccessPair
A POD class for pairing a NamedDecl* with an access specifier.
Definition: DeclAccessPair.h:29
clang::OMF_dealloc
@ OMF_dealloc
Definition: IdentifierTable.h:703
clang::Sema::DefaultFunctionArrayConversion
ExprResult DefaultFunctionArrayConversion(Expr *E, bool Diagnose=true)
DefaultFunctionArrayConversion (C99 6.3.2.1p3, C99 6.3.2.1p4).
Definition: SemaExpr.cpp:499
clang::ASTContext
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition: ASTContext.h:212
clang::ExprResult
ActionResult< Expr * > ExprResult
Definition: Ownership.h:262
clang::ObjCInterfaceDecl::lookupPrivateMethod
ObjCMethodDecl * lookupPrivateMethod(const Selector &Sel, bool Instance=true) const
Lookup a method in the classes implementation hierarchy.
Definition: DeclObjC.cpp:741
clang::DeclaratorContext::Member
@ Member
clang::LazyVector::end
iterator end()
Definition: ExternalASTSource.h:545
clang::Qualifiers::removeConst
void removeConst()
Definition: Type.h:264
clang::Preprocessor::getSelectorTable
SelectorTable & getSelectorTable()
Definition: Preprocessor.h:969
clang::Type::getAs
const T * getAs() const
Member-template getAs<specific type>'.
Definition: Type.h:7162
clang::Sema::SFINAETrap::hasErrorOccurred
bool hasErrorOccurred() const
Determine whether any SFINAE errors have been trapped.
Definition: Sema.h:9182
clang::OK_BitField
@ OK_BitField
A bitfield object is a bitfield on a C or C++ record.
Definition: Specifiers.h:139
clang::Decl::isInvalidDecl
bool isInvalidDecl() const
Definition: DeclBase.h:558
clang::Sema::getFunctionLevelDeclContext
DeclContext * getFunctionLevelDeclContext()
Definition: Sema.cpp:1393
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::ExpressionEvaluationContext::Unevaluated
@ Unevaluated
The current expression and its subexpressions occur within an unevaluated operand (C++11 [expr]p7),...
IsRGBA
static bool IsRGBA(char c)
Determine whether input char is from rgba component set.
Definition: SemaExprMember.cpp:273
clang::ObjCInterfaceDecl::lookupInstanceVariable
ObjCIvarDecl * lookupInstanceVariable(IdentifierInfo *IVarName, ObjCInterfaceDecl *&ClassDeclared)
Definition: DeclObjC.cpp:622
clang::Sema::ActOnMemberAccessExtraArgs::ObjCImpDecl
Decl * ObjCImpDecl
Definition: Sema.h:5384
clang::CanQual::getQualifiers
Qualifiers getQualifiers() const
Retrieve all qualifiers.
Definition: CanonicalType.h:129
clang::IdentifierInfo::getLength
unsigned getLength() const
Efficiently return the length of this identifier info.
Definition: IdentifierTable.h:192
clang::Sema::Diags
DiagnosticsEngine & Diags
Definition: Sema.h:413
clang::PseudoObjectExpr
PseudoObjectExpr - An expression which accesses a pseudo-object l-value.
Definition: Expr.h:6095
clang::Sema::PDiag
PartialDiagnostic PDiag(unsigned DiagID=0)
Build a partial diagnostic.
Definition: SemaInternal.h:24
clang::Type::isFunctionType
bool isFunctionType() const
Definition: Type.h:6669
clang::Sema::ActOnDependentMemberExpr
ExprResult ActOnDependentMemberExpr(Expr *Base, QualType BaseType, bool IsArrow, SourceLocation OpLoc, const CXXScopeSpec &SS, SourceLocation TemplateKWLoc, NamedDecl *FirstQualifierInScope, const DeclarationNameInfo &NameInfo, const TemplateArgumentListInfo *TemplateArgs)
Definition: SemaExprMember.cpp:480
clang::UnqualifiedIdKind::IK_ConstructorName
@ IK_ConstructorName
A constructor name.
clang::VarDecl
Represents a variable declaration or definition.
Definition: Decl.h:876
clang::ASTContext::getObjCClassType
QualType getObjCClassType() const
Represents the Objective-C Class type.
Definition: ASTContext.h:2015
Category
int Category
Definition: Format.cpp:2336
IMA_Unresolved
@ IMA_Unresolved
The reference may be to an unresolved using declaration.
Definition: SemaExprMember.cpp:59
clang::Type::getPointeeType
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee.
Definition: Type.cpp:625
clang::Sema::DefaultFunctionArrayLvalueConversion
ExprResult DefaultFunctionArrayLvalueConversion(Expr *E, bool Diagnose=true)
Definition: SemaExpr.cpp:733
clang::ObjCIvarDecl::Private
@ Private
Definition: DeclObjC.h:1929
clang::ObjCCategoryImplDecl
ObjCCategoryImplDecl - An object of this class encapsulates a category @implementation declaration.
Definition: DeclObjC.h:2493
clang::ASTContext::getCanonicalType
CanQualType getCanonicalType(QualType T) const
Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...
Definition: ASTContext.h:2468
clang::EnumConstantDecl
An instance of this object exists for each enum constant that is defined.
Definition: Decl.h:3050
clang::CXXRecordDecl::forallBases
bool forallBases(ForallBasesCallback BaseMatches) const
Determines if the given callback holds for all the direct or indirect base classes of this type.
Definition: CXXInheritance.cpp:127
ExprObjC.h
clang::NestedNameSpecifierLoc
A C++ nested-name-specifier augmented with source location information.
Definition: NestedNameSpecifier.h:243
clang::Qualifiers::hasAddressSpace
bool hasAddressSpace() const
Definition: Type.h:360
clang::LookupResult::getLookupName
DeclarationName getLookupName() const
Gets the name to look up.
Definition: Lookup.h:243
ExprCXX.h
Base
clang::DeclContext::isRecord
bool isRecord() const
Definition: DeclBase.h:1939
clang::Sema::getCurFunctionDecl
FunctionDecl * getCurFunctionDecl()
getCurFunctionDecl - If inside of a function body, this returns a pointer to the function decl for th...
Definition: Sema.cpp:1414
clang::Sema::ResolveExceptionSpec
const FunctionProtoType * ResolveExceptionSpec(SourceLocation Loc, const FunctionProtoType *FPT)
Definition: SemaExceptionSpec.cpp:209
ClassifyImplicitMemberAccess
static IMAKind ClassifyImplicitMemberAccess(Sema &SemaRef, const LookupResult &R)
The given lookup names class member(s) and is not being used for an address-of-member expression.
Definition: SemaExprMember.cpp:88
IMA_Mixed
@ IMA_Mixed
The reference may be an implicit instance member access.
Definition: SemaExprMember.cpp:45
clang::Sema::getOpenMPCapturedExpr
ExprResult getOpenMPCapturedExpr(VarDecl *Capture, ExprValueKind VK, ExprObjectKind OK, SourceLocation Loc)
Definition: SemaOpenMP.cpp:15731
clang::Sema::BuildMemberExpr
MemberExpr * BuildMemberExpr(Expr *Base, bool IsArrow, SourceLocation OpLoc, const CXXScopeSpec *SS, SourceLocation TemplateKWLoc, ValueDecl *Member, DeclAccessPair FoundDecl, bool HadMultipleCandidates, const DeclarationNameInfo &MemberNameInfo, QualType Ty, ExprValueKind VK, ExprObjectKind OK, const TemplateArgumentListInfo *TemplateArgs=nullptr)
Definition: SemaExprMember.cpp:892
isPointerToRecordType
static bool isPointerToRecordType(QualType T)
Definition: SemaExprMember.cpp:1216
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:151
clang::Sema::MaybeConvertParenListExprToParenExpr
ExprResult MaybeConvertParenListExprToParenExpr(Scope *S, Expr *ME)
This is not an AltiVec-style cast or or C++ direct-initialization, so turn the ParenListExpr into a s...
Definition: SemaExpr.cpp:7794
clang::Sema::LookupNameKind
LookupNameKind
Describes the kind of name lookup to perform.
Definition: Sema.h:3968
clang::DeclarationName::isDependentName
bool isDependentName() const
Determines whether the name itself is dependent, e.g., because it involves a C++ type that is itself ...
Definition: DeclarationName.cpp:222
clang::DeclarationNameInfo::getName
DeclarationName getName() const
getName - Returns the embedded declaration name.
Definition: DeclarationName.h:781
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:5013
FindGetterSetterNameDeclFromProtocolList
static Decl * FindGetterSetterNameDeclFromProtocolList(const ObjCProtocolDecl *PDecl, IdentifierInfo *Member, const Selector &Sel, ASTContext &Context)
Definition: SemaExprMember.cpp:430
clang::OpaquePtr< QualType >
clang::Sema::UnusedPrivateFields
NamedDeclSetType UnusedPrivateFields
Set containing all declared private fields that are not used.
Definition: Sema.h:828
clang::VK_LValue
@ VK_LValue
An l-value expression is a reference to an object with independent storage.
Definition: Specifiers.h:124
clang::Sema::diagnoseTypo
void diagnoseTypo(const TypoCorrection &Correction, const PartialDiagnostic &TypoDiag, bool ErrorRecovery=true)
Definition: SemaLookup.cpp:5310
clang::Type::castAs
const T * castAs() const
Member-template castAs<specific type>.
Definition: Type.h:7227
clang::Sema::PerformObjectMemberConversion
ExprResult PerformObjectMemberConversion(Expr *From, NestedNameSpecifier *Qualifier, NamedDecl *FoundDecl, NamedDecl *Member)
Cast a base object to a member's actual type.
Definition: SemaExpr.cpp:2930
clang::QualType::getDesugaredType
QualType getDesugaredType(const ASTContext &Context) const
Return the specified type with any "sugar" removed from the type.
Definition: Type.h:979
clang::Expr::IgnoreParenCasts
Expr * IgnoreParenCasts() LLVM_READONLY
Skip past any parentheses and casts which might surround this expression until reaching a fixed point...
Definition: Expr.cpp:2924
clang::ObjCObjectPointerType
Represents a pointer to an Objective C object.
Definition: Type.h:6073
clang::MemberExpr::getBase
Expr * getBase() const
Definition: Expr.h:3239
clang::Sema::BuildImplicitMemberExpr
ExprResult BuildImplicitMemberExpr(const CXXScopeSpec &SS, SourceLocation TemplateKWLoc, LookupResult &R, const TemplateArgumentListInfo *TemplateArgs, bool IsDefiniteInstance, const Scope *S)
Builds an implicit member access expression.
Definition: SemaExprMember.cpp:1852
clang::CXXRecordDecl
Represents a C++ struct/union/class.
Definition: DeclCXX.h:255
IMA_Error_StaticContext
@ IMA_Error_StaticContext
All possible referrents are instance members and the current context is not an instance method.
Definition: SemaExprMember.cpp:75
clang::Sema::getExternalSource
ExternalSemaSource * getExternalSource() const
Definition: Sema.h:1579
clang::tok::TokenKind
TokenKind
Provides a simple uniform namespace for tokens from all C languages.
Definition: TokenKinds.h:25
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:4210
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:2174
clang::VK_PRValue
@ VK_PRValue
A pr-value expression (in the C++11 taxonomy) produces a temporary value.
Definition: Specifiers.h:120
clang::LookupResult::suppressDiagnostics
void suppressDiagnostics()
Suppress the diagnostics that would normally fire because of this lookup.
Definition: Lookup.h:583
clang::Sema::ImpCastExprToType
ExprResult ImpCastExprToType(Expr *E, QualType Type, CastKind CK, ExprValueKind VK=VK_PRValue, const CXXCastPath *BasePath=nullptr, CheckedConversionKind CCK=CCK_ImplicitConversion)
ImpCastExprToType - If Expr is not of type 'Type', insert an implicit cast.
Definition: Sema.cpp:600
clang::LookupResult::empty
bool empty() const
Return true if no decls were found.
Definition: Lookup.h:339
clang::Sema::CheckQualifiedMemberReference
bool CheckQualifiedMemberReference(Expr *BaseExpr, QualType BaseType, const CXXScopeSpec &SS, const LookupResult &R)
Definition: SemaExprMember.cpp:549
clang::Type::isPointerType
bool isPointerType() const
Definition: Type.h:6673
clang::ObjCObjectType::isObjCClass
bool isObjCClass() const
Definition: Type.h:5885
clang::ActionResult::get
PtrTy get() const
Definition: Ownership.h:169
clang::ValueDecl
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
Definition: Decl.h:676
clang::Sema::tryToRecoverWithCall
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:2495
BuildMSPropertyRefExpr
static ExprResult BuildMSPropertyRefExpr(Sema &S, Expr *BaseExpr, bool IsArrow, const CXXScopeSpec &SS, MSPropertyDecl *PD, const DeclarationNameInfo &NameInfo)
Definition: SemaExprMember.cpp:880
clang::TemplateName
Represents a C++ template name within the type system.
Definition: TemplateName.h:192
clang::Sema::RedeclarationKind
RedeclarationKind
Specifies whether (or how) name lookup is being performed for a redeclaration (vs.
Definition: Sema.h:4022
isProvablyNotDerivedFrom
static bool isProvablyNotDerivedFrom(Sema &SemaRef, CXXRecordDecl *Record, const BaseSet &Bases)
Determines if the given class is provably not derived from all of the prospective base classes.
Definition: SemaExprMember.cpp:32
IMA_Error_Unrelated
@ IMA_Error_Unrelated
All possible referrents are instance members of an unrelated class.
Definition: SemaExprMember.cpp:79
clang::FunctionProtoType
Represents a prototype with parameter type info, e.g.
Definition: Type.h:3885
clang::DeclContext::getParent
DeclContext * getParent()
getParent - Returns the containing DeclContext.
Definition: DeclBase.h:1860
clang::SelectorTable::constructSetterSelector
static Selector constructSetterSelector(IdentifierTable &Idents, SelectorTable &SelTable, const IdentifierInfo *Name)
Return the default setter selector for the given identifier.
Definition: IdentifierTable.cpp:682
BaseSet
llvm::SmallPtrSet< const CXXRecordDecl *, 4 > BaseSet
Definition: SemaExprMember.cpp:28
clang::QualType::isNull
bool isNull() const
Return true if this QualType doesn't point to a type yet.
Definition: Type.h:738
clang::Decl
Decl - This represents one declaration (or definition), e.g.
Definition: DeclBase.h:89
clang::LookupResult::setBaseObjectType
void setBaseObjectType(QualType T)
Sets the base object type for this lookup.
Definition: Lookup.h:420
Scope.h
clang::Expr::IgnoreParenImpCasts
Expr * IgnoreParenImpCasts() LLVM_READONLY
Skip past any parentheses and implicit casts which might surround this expression until reaching a fi...
Definition: Expr.cpp:2919
clang::ObjCPropertyDecl
Represents one property declaration in an Objective-C interface.
Definition: DeclObjC.h:732
CheckExtVectorComponent
static QualType CheckExtVectorComponent(Sema &S, QualType baseType, ExprValueKind &VK, SourceLocation OpLoc, const IdentifierInfo *CompName, SourceLocation CompLoc)
Check an ext-vector component access expression.
Definition: SemaExprMember.cpp:298
clang::Sema::DefaultLvalueConversion
ExprResult DefaultLvalueConversion(Expr *E)
Definition: SemaExpr.cpp:623
clang::ExtVectorType::isAccessorWithinNumElements
bool isAccessorWithinNumElements(char c, bool isNumericAccessor) const
Definition: Type.h:3402
clang::Sema
Sema - This implements semantic analysis and AST building for C.
Definition: Sema.h:355
clang::ActionResult::isInvalid
bool isInvalid() const
Definition: Ownership.h:165
clang::Sema::DiagnoseUseOfDecl
bool DiagnoseUseOfDecl(NamedDecl *D, ArrayRef< SourceLocation > Locs, const ObjCInterfaceDecl *UnknownObjCClass=nullptr, bool ObjCPropertyAccess=false, bool AvoidPartialAvailabilityChecks=false, ObjCInterfaceDecl *ClassReciever=nullptr)
Determine whether the use of this declaration is valid, and emit any corresponding diagnostics.
Definition: SemaExpr.cpp:218
clang::VarDecl::getTemplateSpecializationKind
TemplateSpecializationKind getTemplateSpecializationKind() const
If this variable is an instantiation of a variable template or a static data member of a class templa...
Definition: Decl.cpp:2630
clang::Sema::IvarBacksCurrentMethodAccessor
bool IvarBacksCurrentMethodAccessor(ObjCInterfaceDecl *IFace, ObjCMethodDecl *Method, ObjCIvarDecl *IV)
IvarBacksCurrentMethodAccessor - This routine returns 'true' if 'IV' is an ivar synthesized for 'Meth...
Definition: SemaObjCProperty.cpp:1837
clang::LazyVector::begin
iterator begin(Source *source, bool LocalOnly=false)
Definition: ExternalASTSource.h:536
clang::DeclContext::Encloses
bool Encloses(const DeclContext *DC) const
Determine whether this declaration context encloses the declaration context DC.
Definition: DeclBase.cpp:1210
clang::Sema::getCurMethodDecl
ObjCMethodDecl * getCurMethodDecl()
getCurMethodDecl - If inside of a method body, this returns a pointer to the method decl for the meth...
Definition: Sema.cpp:1419
clang::ExprValueKind
ExprValueKind
The categorization of expression values, currently following the C++11 scheme.
Definition: Specifiers.h:117
clang::IdentifierInfo
One of these records is kept for each identifier that is lexed.
Definition: IdentifierTable.h:84
clang::Sema::isThisOutsideMemberFunctionBody
bool isThisOutsideMemberFunctionBody(QualType BaseType)
Determine whether the given type is the type of *this that is used outside of the body of a member fu...
Definition: SemaExprCXX.cpp:1397
clang::Qualifiers::removeObjCGCAttr
void removeObjCGCAttr()
Definition: Type.h:313
clang::Sema::BuildPossibleImplicitMemberExpr
ExprResult BuildPossibleImplicitMemberExpr(const CXXScopeSpec &SS, SourceLocation TemplateKWLoc, LookupResult &R, const TemplateArgumentListInfo *TemplateArgs, const Scope *S, UnresolvedLookupExpr *AsULE=nullptr)
Builds an expression which might be an implicit member expression.
Definition: SemaExprMember.cpp:235
clang::IdentifierInfo::getNameStart
const char * getNameStart() const
Return the beginning of the actual null-terminated string for this identifier.
Definition: IdentifierTable.h:189
clang::ActionResult< Expr * >
clang::SelectorTable::getNullarySelector
Selector getNullarySelector(IdentifierInfo *ID)
Definition: IdentifierTable.h:913
clang::DeclFilterCCC
Simple template class for restricting typo correction candidates to ones having a single Decl* of the...
Definition: TypoCorrection.h:366
clang::Sema::ExpressionEvaluationContext::ConstantEvaluated
@ ConstantEvaluated
The current context is "potentially evaluated" in C++11 terms, but the expression is evaluated at com...
clang::ExtVectorElementExpr
ExtVectorElementExpr - This represents access to specific elements of a vector, and may occur on the ...
Definition: Expr.h:5905
clang::ObjCMethodDecl
ObjCMethodDecl - Represents an instance or class method declaration.
Definition: DeclObjC.h:139
clang::Sema::ExtVectorDecls
ExtVectorDeclsType ExtVectorDecls
ExtVectorDecls - This is a list all the extended vector types.
Definition: Sema.h:820
clang::OK_ObjCProperty
@ OK_ObjCProperty
An Objective-C property is a logical field of an Objective-C object which is read and written via Obj...
Definition: Specifiers.h:146
clang::TypoExpr
TypoExpr - Internal placeholder for expressions where typo correction still needs to be performed and...
Definition: Expr.h:6358
clang::PointerType
PointerType - C99 6.7.5.1 - Pointer Declarators.
Definition: Type.h:2640
ScopeInfo.h
clang::ObjCPropertyQueryKind::OBJC_PR_query_instance
@ OBJC_PR_query_instance
isRecordType
static bool isRecordType(QualType T)
Definition: SemaExprMember.cpp:1213
IMAKind
IMAKind
Definition: SemaExprMember.cpp:40
clang::Sema::CXXThisTypeOverride
QualType CXXThisTypeOverride
When non-NULL, the C++ 'this' expression is allowed despite the current context not being a non-stati...
Definition: Sema.h:6236
clang::Sema::getCurScope
Scope * getCurScope() const
Retrieve the parser's current scope.
Definition: Sema.h:12904
clang::DeclarationName::getNameKind
NameKind getNameKind() const
Determine what kind of name this is.
Definition: DeclarationName.h:384
clang::IndirectFieldDecl::getVarDecl
VarDecl * getVarDecl() const
Definition: Decl.h:3124
clang::Expr::setType
void setType(QualType t)
Definition: Expr.h:142
IMA_Mixed_Unrelated
@ IMA_Mixed_Unrelated
The reference may be to an instance member, but it is invalid if so, because the context is from an u...
Definition: SemaExprMember.cpp:53
clang
Definition: CalledOnceCheck.h:17
clang::ObjCContainerDecl::getInstanceMethod
ObjCMethodDecl * getInstanceMethod(Selector Sel, bool AllowHidden=false) const
Definition: DeclObjC.h:1066
clang::IndirectFieldDecl
Represents a field injected from an anonymous union/struct into the parent scope.
Definition: Decl.h:3089
clang::Sema::PerformMemberExprBaseConversion
ExprResult PerformMemberExprBaseConversion(Expr *Base, bool IsArrow)
Perform conversions on the LHS of a member access expression.
Definition: SemaExprMember.cpp:1224
clang::VectorType::getElementType
QualType getElementType() const
Definition: Type.h:3270
clang::Selector
Smart pointer class that efficiently represents Objective-C method names.
Definition: IdentifierTable.h:748
clang::Type::isArrayType
bool isArrayType() const
Definition: Type.h:6739
clang::ExtVectorType::getNumericAccessorIdx
static int getNumericAccessorIdx(char c)
Definition: Type.h:3367
clang::ASTContext::getObjCClassRedefinitionType
QualType getObjCClassRedefinitionType() const
Retrieve the type that Class has been defined to, which may be different from the built-in Class if C...
Definition: ASTContext.h:1807
clang::ObjCIvarDecl
ObjCIvarDecl - Represents an ObjC instance variable.
Definition: DeclObjC.h:1924
clang::MSPropertyDecl
An instance of this class represents the declaration of a property member.
Definition: DeclCXX.h:4087
clang::CXXRecordDecl::getCanonicalDecl
CXXRecordDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
Definition: DeclCXX.h:494
clang::ObjCIsaExpr
ObjCIsaExpr - Represent X->isa and X.isa when X is an ObjC 'id' type.
Definition: ExprObjC.h:1482
clang::TypoCorrection::getCorrectionDecl
NamedDecl * getCorrectionDecl() const
Gets the pointer to the declaration of the typo correction.
Definition: TypoCorrection.h:151
clang::ObjCProtocolDecl
Represents an Objective-C protocol declaration.
Definition: DeclObjC.h:2050
clang::Expr::getType
QualType getType() const
Definition: Expr.h:141
clang::CXXScopeSpec::getScopeRep
NestedNameSpecifier * getScopeRep() const
Retrieve the representation of the nested-name-specifier.
Definition: DeclSpec.h:77
clang::SourceLocation::isValid
bool isValid() const
Return true if this is a valid SourceLocation object.
Definition: SourceLocation.h:112
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::ActOnMemberAccessExtraArgs
Definition: Sema.h:5381
clang::NamedDecl::getDeclName
DeclarationName getDeclName() const
Get the actual, stored name of the declaration, which may be a special name.
Definition: Decl.h:313
clang::FixItHint::CreateRemoval
static FixItHint CreateRemoval(CharSourceRange RemoveRange)
Create a code modification hint that removes the given source range.
Definition: Diagnostic.h:122
LookupMemberExpr
static ExprResult LookupMemberExpr(Sema &S, LookupResult &R, ExprResult &BaseExpr, bool &IsArrow, SourceLocation OpLoc, CXXScopeSpec &SS, Decl *ObjCImpDecl, bool HasTemplateArgs, SourceLocation TemplateKWLoc)
Look up the given member of the given non-type-dependent expression.
Definition: SemaExprMember.cpp:1241
clang::DeclContext::isDependentContext
bool isDependentContext() const
Determines whether this context is dependent on a template parameter.
Definition: DeclBase.cpp:1142
clang::LookupResult::getLookupKind
Sema::LookupNameKind getLookupKind() const
Gets the kind of lookup to perform.
Definition: Lookup.h:253
IsValidOpenCLComponentSwizzleLength
static bool IsValidOpenCLComponentSwizzleLength(unsigned len)
Definition: SemaExprMember.cpp:288
clang::DeclarationNameInfo::getSourceRange
SourceRange getSourceRange() const LLVM_READONLY
getSourceRange - The range of the declaration name.
Definition: DeclarationName.h:863
clang::ObjCContainerDecl::FindPropertyDeclaration
ObjCPropertyDecl * FindPropertyDeclaration(const IdentifierInfo *PropertyId, ObjCPropertyQueryKind QueryKind) const
FindPropertyDeclaration - Finds declaration of the property given its name in 'PropertyId' and return...
Definition: DeclObjC.cpp:237
clang::ObjCObjectType::isObjCId
bool isObjCId() const
Definition: Type.h:5881
clang::Sema::BuildTemplateIdExpr
ExprResult BuildTemplateIdExpr(const CXXScopeSpec &SS, SourceLocation TemplateKWLoc, LookupResult &R, bool RequiresADL, const TemplateArgumentListInfo *TemplateArgs)
Definition: SemaTemplate.cpp:4703
clang::LookupResult::getFoundDecl
NamedDecl * getFoundDecl() const
Fetch the unique decl found by this lookup.
Definition: Lookup.h:517
c
__device__ __2f16 float c
Definition: __clang_hip_libdevice_declares.h:315
clang::MemberExpr
MemberExpr - [C99 6.5.2.3] Structure and Union Members.
Definition: Expr.h:3162
clang::CXXDependentScopeMemberExpr::Create
static CXXDependentScopeMemberExpr * Create(const ASTContext &Ctx, Expr *Base, QualType BaseType, bool IsArrow, SourceLocation OperatorLoc, NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc, NamedDecl *FirstQualifierFoundInScope, DeclarationNameInfo MemberNameInfo, const TemplateArgumentListInfo *TemplateArgs)
Definition: ExprCXX.cpp:1404
clang::ObjCInterfaceDecl::isSuperClassOf
bool isSuperClassOf(const ObjCInterfaceDecl *I) const
isSuperClassOf - Return true if this class is the specified class or is a super class of the specifie...
Definition: DeclObjC.h:1789
clang::RecordType::getDecl
RecordDecl * getDecl() const
Definition: Type.h:4623
clang::ExtVectorType
ExtVectorType - Extended vector type.
Definition: Type.h:3350
clang::Sema::diagnoseMissingTemplateArguments
void diagnoseMissingTemplateArguments(TemplateName Name, SourceLocation Loc)
Definition: SemaTemplate.cpp:4658
clang::ReferenceType
Base for LValueReferenceType and RValueReferenceType.
Definition: Type.h:2751
clang::PointerType::getPointeeType
QualType getPointeeType() const
Definition: Type.h:2650
clang::LookupResult::getSema
Sema & getSema() const
Get the Sema object that this lookup result is searching with.
Definition: Lookup.h:612
clang::VectorType::getNumElements
unsigned getNumElements() const
Definition: Type.h:3271
clang::Sema::getNonOdrUseReasonInCurrentContext
NonOdrUseReason getNonOdrUseReasonInCurrentContext(ValueDecl *D)
If D cannot be odr-used in the current expression evaluation context, return a reason explaining why.
Definition: SemaExpr.cpp:1980
clang::Scope::TryScope
@ TryScope
This is the scope of a C++ try statement.
Definition: Scope.h:101
clang::CXXRecordDecl::isProvablyNotDerivedFrom
bool isProvablyNotDerivedFrom(const CXXRecordDecl *Base) const
Determine whether this class is provably not derived from the type Base.
Definition: CXXInheritance.cpp:109
clang::Scope::FnTryCatchScope
@ FnTryCatchScope
This is the scope for a function-level C++ try or catch scope.
Definition: Scope.h:104
clang::ObjCIvarDecl::getUsageType
QualType getUsageType(QualType objectType) const
Retrieve the type of this instance variable when viewed as a member of a specific object type.
Definition: DeclObjC.cpp:1857
clang::ValueDecl::getType
QualType getType() const
Definition: Decl.h:687
clang::VarTemplateDecl
Declaration of a variable template.
Definition: DeclTemplate.h:3079
clang::ASTContext::hasSameUnqualifiedType
bool hasSameUnqualifiedType(QualType T1, QualType T2) const
Determine whether the given types are equivalent after cvr-qualifiers have been removed.
Definition: ASTContext.h:2508
clang::Sema::DecomposeUnqualifiedId
void DecomposeUnqualifiedId(const UnqualifiedId &Id, TemplateArgumentListInfo &Buffer, DeclarationNameInfo &NameInfo, const TemplateArgumentListInfo *&TemplateArgs)
Decomposes the given name into a DeclarationNameInfo, its location, and possibly a list of template a...
Definition: SemaExpr.cpp:2078
clang::Expr
This represents one expression.
Definition: Expr.h:109
clang::CXXScopeSpec::isEmpty
bool isEmpty() const
No scope specifier.
Definition: DeclSpec.h:190
clang::Type::isSpecificBuiltinType
bool isSpecificBuiltinType(unsigned K) const
Test for a particular builtin type.
Definition: Type.h:6925
clang::CXXScopeSpec::getRange
SourceRange getRange() const
Definition: DeclSpec.h:69
clang::Sema::getCurrentThisType
QualType getCurrentThisType()
Try to retrieve the type of the 'this' pointer.
Definition: SemaExprCXX.cpp:1185
clang::TSK_ImplicitInstantiation
@ TSK_ImplicitInstantiation
This template specialization was implicitly instantiated from a template.
Definition: Specifiers.h:179
clang::Sema::PP
Preprocessor & PP
Definition: Sema.h:410
clang::DeclarationNameInfo::getLoc
SourceLocation getLoc() const
getLoc - Returns the main location of the declaration name.
Definition: DeclarationName.h:787
clang::DeclarationNameInfo
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspnd...
Definition: DeclarationName.h:758
clang::UnresolvedMemberExpr::Create
static UnresolvedMemberExpr * Create(const ASTContext &Context, bool HasUnresolvedUsing, Expr *Base, QualType BaseType, bool IsArrow, SourceLocation OperatorLoc, NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc, const DeclarationNameInfo &MemberNameInfo, const TemplateArgumentListInfo *TemplateArgs, UnresolvedSetIterator Begin, UnresolvedSetIterator End)
Definition: ExprCXX.cpp:1496
clang::Decl::getLocation
SourceLocation getLocation() const
Definition: DeclBase.h:430
clang::DeclRefExpr
A reference to a declared variable, function, enum, etc.
Definition: Expr.h:1217
ShouldTryAgainWithRedefinitionType
static bool ShouldTryAgainWithRedefinitionType(Sema &S, ExprResult &base)
Given that normal member access failed on the given expression, and given that the expression's type ...
Definition: SemaExprMember.cpp:1187
clang::RecordDecl
Represents a struct/union/class.
Definition: Decl.h:3859
clang::DeclContext::Equals
bool Equals(const DeclContext *DC) const
Determine whether this declaration context is equivalent to the declaration context DC.
Definition: DeclBase.h:1984
clang::LookupResult::getLookupNameInfo
const DeclarationNameInfo & getLookupNameInfo() const
Gets the name info to look up.
Definition: Lookup.h:233
clang::ObjCIvarRefExpr
ObjCIvarRefExpr - A reference to an ObjC instance variable.
Definition: ExprObjC.h:548
clang::ActionResult::isUsable
bool isUsable() const
Definition: Ownership.h:166
clang::LookupResult::getRepresentativeDecl
NamedDecl * getRepresentativeDecl() const
Fetches a representative decl. Useful for lazy diagnostics.
Definition: Lookup.h:524
clang::LookupResult::isOverloadedResult
bool isOverloadedResult() const
Determines if the results are overloaded.
Definition: Lookup.h:313
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:133
LookupMemberExprInRecord
static bool LookupMemberExprInRecord(Sema &SemaRef, LookupResult &R, Expr *BaseExpr, const RecordType *RTy, SourceLocation OpLoc, bool IsArrow, CXXScopeSpec &SS, bool HasTemplateArgs, SourceLocation TemplateKWLoc, TypoExpr *&TE)
Definition: SemaExprMember.cpp:637
clang::Sema::BuildCXXThisExpr
Expr * BuildCXXThisExpr(SourceLocation Loc, QualType Type, bool IsImplicit)
Build a CXXThisExpr and mark it referenced in the current context.
Definition: SemaExprCXX.cpp:1386
clang::declaresSameEntity
bool declaresSameEntity(const Decl *D1, const Decl *D2)
Determine whether two declarations declare the same entity.
Definition: DeclBase.h:1198
clang::Sema::ExpressionEvaluationContext::ImmediateFunctionContext
@ ImmediateFunctionContext
In addition of being constant evaluated, the current expression occurs in an immediate function conte...
clang::CXXMethodDecl::getParent
const CXXRecordDecl * getParent() const
Return the parent of this method declaration, which is the class in which this method is defined.
Definition: DeclCXX.h:2063
clang::CXXMethodDecl
Represents a static or instance method of a struct/union/class.
Definition: DeclCXX.h:1948
clang::CXXScopeSpec::isInvalid
bool isInvalid() const
An error occurred during parsing of the scope specifier.
Definition: DeclSpec.h:195
clang::ObjCIvarDecl::Package
@ Package
Definition: DeclObjC.h:1929
clang::LookupResult::isAmbiguous
bool isAmbiguous() const
Definition: Lookup.h:301
clang::Decl::getDeclContext
DeclContext * getDeclContext()
Definition: DeclBase.h:439
clang::LookupResult::redeclarationKind
Sema::RedeclarationKind redeclarationKind() const
Definition: Lookup.h:268
clang::Sema::ExpressionEvaluationContext::PotentiallyEvaluated
@ PotentiallyEvaluated
The current expression is potentially evaluated at run time, which means that code may be generated t...