https://github.com/smallp-o-p updated 
https://github.com/llvm/llvm-project/pull/118186

>From 3b7cf6e65bdfedf8d15e393c9c2f819c4ed70386 Mon Sep 17 00:00:00 2001
From: William Tran-Viet <wtranv...@proton.me>
Date: Sat, 30 Nov 2024 15:53:32 -0500
Subject: [PATCH 1/3] Fix double-quotes in diagnostic when attempting to access
 a ext_vector of bools

---
 clang/lib/Sema/SemaExprMember.cpp  | 4 +++-
 clang/test/SemaCXX/vector-bool.cpp | 8 ++++----
 2 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/clang/lib/Sema/SemaExprMember.cpp 
b/clang/lib/Sema/SemaExprMember.cpp
index 434768b99d631e..3d843bb84d9d8b 100644
--- a/clang/lib/Sema/SemaExprMember.cpp
+++ b/clang/lib/Sema/SemaExprMember.cpp
@@ -1655,8 +1655,10 @@ static ExprResult LookupMemberExpr(Sema &S, LookupResult 
&R,
     // We disallow element access for ext_vector_type bool.  There is no way to
     // materialize a reference to a vector element as a pointer (each element 
is
     // one bit in the vector).
+    assert(MemberName.isIdentifier() &&
+           "Ext vector component name not an identifier!");
     S.Diag(R.getNameLoc(), diag::err_ext_vector_component_name_illegal)
-        << MemberName
+        << MemberName.getAsIdentifierInfo()->getName()
         << (BaseExpr.get() ? BaseExpr.get()->getSourceRange() : SourceRange());
     return ExprError();
   }
diff --git a/clang/test/SemaCXX/vector-bool.cpp 
b/clang/test/SemaCXX/vector-bool.cpp
index e99d420e73fab2..cd638056f348b0 100644
--- a/clang/test/SemaCXX/vector-bool.cpp
+++ b/clang/test/SemaCXX/vector-bool.cpp
@@ -85,10 +85,10 @@ void foo(const bool& X);
 
 // Disallow element-wise access.
 bool* ElementRefs() {
-  eight_bools.y = false; // expected-error@88 {{illegal vector component name 
''y''}}
-  &eight_bools.z;        // expected-error@89 {{illegal vector component name 
''z''}}
-  foo(eight_bools.w);    // expected-error@90 {{illegal vector component name 
''w''}}
-  foo(eight_bools.wyx);  // expected-error@91 {{illegal vector component name 
''wyx''}}
+  eight_bools.y = false; // expected-error@88 {{illegal vector component name 
'y'}}
+  &eight_bools.z;        // expected-error@89 {{illegal vector component name 
'z'}}
+  foo(eight_bools.w);    // expected-error@90 {{illegal vector component name 
'w'}}
+  foo(eight_bools.wyx);  // expected-error@91 {{illegal vector component name 
'wyx'}}
 }
 
 void Sizeof() {

>From 664ac70ca6b752eaaca6ee64897885a8e19d84c5 Mon Sep 17 00:00:00 2001
From: William Tran-Viet <wtranv...@proton.me>
Date: Fri, 13 Dec 2024 22:50:24 -0500
Subject: [PATCH 2/3] Remove quotation marks from
 err_ext_vector_component_name_illegal

---
 clang/include/clang/Basic/DiagnosticSemaKinds.td | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index eb05a6a77978af..3fe837de467cd0 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -3423,7 +3423,7 @@ def warn_typecheck_vector_element_sizes_not_equal : 
Warning<
 def err_ext_vector_component_exceeds_length : Error<
   "vector component access exceeds type %0">;
 def err_ext_vector_component_name_illegal : Error<
-  "illegal vector component name '%0'">;
+  "illegal vector component name %0">;
 def err_attribute_address_space_negative : Error<
   "address space is negative">;
 def err_attribute_address_space_too_high : Error<

>From eb073bee82aefba5e6064d97c3e4ebb55032303c Mon Sep 17 00:00:00 2001
From: William Tran-Viet <wtranv...@proton.me>
Date: Fri, 13 Dec 2024 23:32:53 -0500
Subject: [PATCH 3/3] Pass single quotes directly when reporting illegal vector
 component in CheckExtVector(), and offset the diagnostic arrow so it points
 to the offending component, rather than the '.' at the start of the component
 identifier.

---
 clang/lib/Sema/SemaExprMember.cpp | 318 ++++++++++++++----------------
 1 file changed, 145 insertions(+), 173 deletions(-)

diff --git a/clang/lib/Sema/SemaExprMember.cpp 
b/clang/lib/Sema/SemaExprMember.cpp
index 3d843bb84d9d8b..f2adb8d88c0191 100644
--- a/clang/lib/Sema/SemaExprMember.cpp
+++ b/clang/lib/Sema/SemaExprMember.cpp
@@ -25,7 +25,7 @@
 using namespace clang;
 using namespace sema;
 
-typedef llvm::SmallPtrSet<const CXXRecordDecl*, 4> BaseSet;
+typedef llvm::SmallPtrSet<const CXXRecordDecl *, 4> BaseSet;
 
 /// Determines if the given class is provably not derived from all of
 /// the prospective base classes.
@@ -196,9 +196,8 @@ static IMAKind ClassifyImplicitMemberAccess(Sema &SemaRef,
   // non-static non-type member of some class C [...]
   // ...if C is not X or a base class of X, the class member access expression
   // is ill-formed.
-  if (R.getNamingClass() &&
-      contextClass->getCanonicalDecl() !=
-        R.getNamingClass()->getCanonicalDecl()) {
+  if (R.getNamingClass() && contextClass->getCanonicalDecl() !=
+                                R.getNamingClass()->getCanonicalDecl()) {
     // If the naming class is not the current context, this was a qualified
     // member name lookup, and it's sufficient to check that we have the naming
     // class as a base class.
@@ -210,21 +209,21 @@ static IMAKind ClassifyImplicitMemberAccess(Sema &SemaRef,
   // declaring classes, it can't be an implicit member reference (in
   // which case it's an error if any of those members are selected).
   if (isProvablyNotDerivedFrom(SemaRef, contextClass, Classes))
-    return hasNonInstance ? IMA_Mixed_Unrelated :
-           AbstractInstanceResult ? AbstractInstanceResult :
-                                    IMA_Error_Unrelated;
+    return hasNonInstance           ? IMA_Mixed_Unrelated
+           : AbstractInstanceResult ? AbstractInstanceResult
+                                    : IMA_Error_Unrelated;
 
   return (hasNonInstance ? IMA_Mixed : IMA_Instance);
 }
 
 /// Diagnose a reference to a field with no object available.
-static void diagnoseInstanceReference(Sema &SemaRef,
-                                      const CXXScopeSpec &SS,
+static void diagnoseInstanceReference(Sema &SemaRef, const CXXScopeSpec &SS,
                                       NamedDecl *Rep,
                                       const DeclarationNameInfo &nameInfo) {
   SourceLocation Loc = nameInfo.getLoc();
   SourceRange Range(Loc);
-  if (SS.isSet()) Range.setBegin(SS.getRange().getBegin());
+  if (SS.isSet())
+    Range.setBegin(SS.getRange().getBegin());
 
   // Look through using shadow decls and aliases.
   Rep = Rep->getUnderlyingDecl();
@@ -263,10 +262,10 @@ static void diagnoseInstanceReference(Sema &SemaRef,
     // Unqualified lookup in a non-static member function found a member of an
     // enclosing class.
     SemaRef.Diag(Loc, diag::err_nested_non_static_member_use)
-      << IsField << RepClass << nameInfo.getName() << ContextClass << Range;
+        << IsField << RepClass << nameInfo.getName() << ContextClass << Range;
   else if (IsField)
     SemaRef.Diag(Loc, diag::err_invalid_non_static_member_use)
-      << nameInfo.getName() << Range;
+        << nameInfo.getName() << Range;
   else if (!InExplicitObjectMethod)
     SemaRef.Diag(Loc, diag::err_member_call_without_object)
         << Range << /*static*/ 0;
@@ -313,7 +312,7 @@ ExprResult Sema::BuildPossibleImplicitMemberExpr(
         /*IsKnownInstance=*/Classification == IMA_Instance, S);
   case IMA_Field_Uneval_Context:
     Diag(R.getNameLoc(), diag::warn_cxx98_compat_non_static_member_use)
-      << R.getLookupNameInfo().getName();
+        << R.getLookupNameInfo().getName();
     [[fallthrough]];
   case IMA_Static:
   case IMA_Abstract:
@@ -343,8 +342,7 @@ ExprResult Sema::BuildPossibleImplicitMemberExpr(
 }
 
 /// Determine whether input char is from rgba component set.
-static bool
-IsRGBA(char c) {
+static bool IsRGBA(char c) {
   switch (c) {
   case 'r':
   case 'g':
@@ -359,8 +357,7 @@ IsRGBA(char c) {
 // OpenCL v1.1, s6.1.7
 // The component swizzle length must be in accordance with the acceptable
 // vector sizes.
-static bool IsValidOpenCLComponentSwizzleLength(unsigned len)
-{
+static bool IsValidOpenCLComponentSwizzleLength(unsigned len) {
   return (len >= 1 && len <= 4) || len == 8 || len == 16;
 }
 
@@ -368,10 +365,10 @@ static bool IsValidOpenCLComponentSwizzleLength(unsigned 
len)
 ///
 /// VK should be set in advance to the value kind of the base
 /// expression.
-static QualType
-CheckExtVectorComponent(Sema &S, QualType baseType, ExprValueKind &VK,
-                        SourceLocation OpLoc, const IdentifierInfo *CompName,
-                        SourceLocation CompLoc) {
+static QualType CheckExtVectorComponent(Sema &S, QualType baseType,
+                                        ExprValueKind &VK, SourceLocation 
OpLoc,
+                                        const IdentifierInfo *CompName,
+                                        SourceLocation CompLoc) {
   // FIXME: Share logic with ExtVectorElementExpr::containsDuplicateElements,
   // see FIXME there.
   //
@@ -408,7 +405,8 @@ CheckExtVectorComponent(Sema &S, QualType baseType, 
ExprValueKind &VK,
       // Ensure that xyzw and rgba components don't intermingle.
       if (HasRGBA != IsRGBA(*compStr))
         break;
-      if (HasIndex[Idx]) HasRepeated = true;
+      if (HasIndex[Idx])
+        HasRepeated = true;
       HasIndex[Idx] = true;
       compStr++;
     } while (*compStr && (Idx = vecType->getPointAccessorIdx(*compStr)) != -1);
@@ -423,9 +421,11 @@ CheckExtVectorComponent(Sema &S, QualType baseType, 
ExprValueKind &VK,
       }
     }
   } else {
-    if (HexSwizzle) compStr++;
+    if (HexSwizzle)
+      compStr++;
     while ((Idx = vecType->getNumericAccessorIdx(*compStr)) != -1) {
-      if (HasIndex[Idx]) HasRepeated = true;
+      if (HasIndex[Idx])
+        HasRepeated = true;
       HasIndex[Idx] = true;
       compStr++;
     }
@@ -434,8 +434,10 @@ CheckExtVectorComponent(Sema &S, QualType baseType, 
ExprValueKind &VK,
   if (!HalvingSwizzle && *compStr) {
     // We didn't get to the end of the string. This means the component names
     // didn't come from the same set *or* we encountered an illegal name.
-    S.Diag(OpLoc, diag::err_ext_vector_component_name_illegal)
-      << StringRef(compStr, 1) << SourceRange(CompLoc);
+    size_t Offset = compStr - CompName->getNameStart() + 1;
+    S.Diag(OpLoc.getLocWithOffset(Offset),
+           diag::err_ext_vector_component_name_illegal)
+        << StringRef({'\'', *compStr, '\''}) << SourceRange(CompLoc);
     return QualType();
   }
 
@@ -450,7 +452,7 @@ CheckExtVectorComponent(Sema &S, QualType baseType, 
ExprValueKind &VK,
     while (*compStr) {
       if (!vecType->isAccessorWithinNumElements(*compStr++, HexSwizzle)) {
         S.Diag(OpLoc, diag::err_ext_vector_component_exceeds_length)
-          << baseType << SourceRange(CompLoc);
+            << baseType << SourceRange(CompLoc);
         return QualType();
       }
     }
@@ -466,7 +468,7 @@ CheckExtVectorComponent(Sema &S, QualType baseType, 
ExprValueKind &VK,
 
     if (IsValidOpenCLComponentSwizzleLength(SwizzleLength) == false) {
       S.Diag(OpLoc, diag::err_opencl_ext_vector_component_invalid_length)
-        << SwizzleLength << SourceRange(CompLoc);
+          << SwizzleLength << SourceRange(CompLoc);
       return QualType();
     }
   }
@@ -491,8 +493,8 @@ CheckExtVectorComponent(Sema &S, QualType baseType, 
ExprValueKind &VK,
   // Now look up the TypeDefDecl from the vector type. Without this,
   // diagostics look bad. We want extended vector types to appear built-in.
   for (Sema::ExtVectorDeclsType::iterator
-         I = S.ExtVectorDecls.begin(S.getExternalSource()),
-         E = S.ExtVectorDecls.end();
+           I = S.ExtVectorDecls.begin(S.getExternalSource()),
+           E = S.ExtVectorDecls.end();
        I != E; ++I) {
     if ((*I)->getUnderlyingType() == VT)
       return S.Context.getTypedefType(*I);
@@ -501,10 +503,9 @@ CheckExtVectorComponent(Sema &S, QualType baseType, 
ExprValueKind &VK,
   return VT; // should never get here (a typedef type should always be found).
 }
 
-static Decl *FindGetterSetterNameDeclFromProtocolList(const 
ObjCProtocolDecl*PDecl,
-                                                IdentifierInfo *Member,
-                                                const Selector &Sel,
-                                                ASTContext &Context) {
+static Decl *FindGetterSetterNameDeclFromProtocolList(
+    const ObjCProtocolDecl *PDecl, IdentifierInfo *Member, const Selector &Sel,
+    ASTContext &Context) {
   if (Member)
     if (ObjCPropertyDecl *PD = PDecl->FindPropertyDeclaration(
             Member, ObjCPropertyQueryKind::OBJC_PR_query_instance))
@@ -513,8 +514,8 @@ static Decl *FindGetterSetterNameDeclFromProtocolList(const 
ObjCProtocolDecl*PDe
     return OMD;
 
   for (const auto *I : PDecl->protocols()) {
-    if (Decl *D = FindGetterSetterNameDeclFromProtocolList(I, Member, Sel,
-                                                           Context))
+    if (Decl *D =
+            FindGetterSetterNameDeclFromProtocolList(I, Member, Sel, Context))
       return D;
   }
   return nullptr;
@@ -550,14 +551,11 @@ static Decl *FindGetterSetterNameDecl(const 
ObjCObjectPointerType *QIdTy,
   return GDecl;
 }
 
-ExprResult
-Sema::ActOnDependentMemberExpr(Expr *BaseExpr, QualType BaseType,
-                               bool IsArrow, SourceLocation OpLoc,
-                               const CXXScopeSpec &SS,
-                               SourceLocation TemplateKWLoc,
-                               NamedDecl *FirstQualifierInScope,
-                               const DeclarationNameInfo &NameInfo,
-                               const TemplateArgumentListInfo *TemplateArgs) {
+ExprResult Sema::ActOnDependentMemberExpr(
+    Expr *BaseExpr, QualType BaseType, bool IsArrow, SourceLocation OpLoc,
+    const CXXScopeSpec &SS, SourceLocation TemplateKWLoc,
+    NamedDecl *FirstQualifierInScope, const DeclarationNameInfo &NameInfo,
+    const TemplateArgumentListInfo *TemplateArgs) {
   // Even in dependent contexts, try to diagnose base expressions with
   // obviously wrong types, e.g.:
   //
@@ -569,11 +567,11 @@ Sema::ActOnDependentMemberExpr(Expr *BaseExpr, QualType 
BaseType,
   // allows this, while still reporting an error if T is a struct pointer.
   if (!IsArrow) {
     const PointerType *PT = BaseType->getAs<PointerType>();
-    if (PT && (!getLangOpts().ObjC ||
-               PT->getPointeeType()->isRecordType())) {
+    if (PT && (!getLangOpts().ObjC || PT->getPointeeType()->isRecordType())) {
       assert(BaseExpr && "cannot happen with implicit member accesses");
       Diag(OpLoc, diag::err_typecheck_member_reference_struct_union)
-        << BaseType << BaseExpr->getSourceRange() << NameInfo.getSourceRange();
+          << BaseType << BaseExpr->getSourceRange()
+          << NameInfo.getSourceRange();
       return ExprError();
     }
   }
@@ -596,27 +594,23 @@ Sema::ActOnDependentMemberExpr(Expr *BaseExpr, QualType 
BaseType,
 /// We know that the given qualified member reference points only to
 /// declarations which do not belong to the static type of the base
 /// expression.  Diagnose the problem.
-static void DiagnoseQualifiedMemberReference(Sema &SemaRef,
-                                             Expr *BaseExpr,
-                                             QualType BaseType,
-                                             const CXXScopeSpec &SS,
-                                             NamedDecl *rep,
-                                       const DeclarationNameInfo &nameInfo) {
+static void DiagnoseQualifiedMemberReference(
+    Sema &SemaRef, Expr *BaseExpr, QualType BaseType, const CXXScopeSpec &SS,
+    NamedDecl *rep, const DeclarationNameInfo &nameInfo) {
   // If this is an implicit member access, use a different set of
   // diagnostics.
   if (!BaseExpr)
     return diagnoseInstanceReference(SemaRef, SS, rep, nameInfo);
 
   SemaRef.Diag(nameInfo.getLoc(), diag::err_qualified_member_of_unrelated)
-    << SS.getRange() << rep << BaseType;
+      << SS.getRange() << rep << BaseType;
 }
 
-bool Sema::CheckQualifiedMemberReference(Expr *BaseExpr,
-                                         QualType BaseType,
+bool Sema::CheckQualifiedMemberReference(Expr *BaseExpr, QualType BaseType,
                                          const CXXScopeSpec &SS,
                                          const LookupResult &R) {
   CXXRecordDecl *BaseRecord =
-    cast_or_null<CXXRecordDecl>(computeDeclContext(BaseType));
+      cast_or_null<CXXRecordDecl>(computeDeclContext(BaseType));
   if (!BaseRecord) {
     // We can't check this yet because the base type is still
     // dependent.
@@ -697,7 +691,7 @@ class RecordMemberExprValidatorCCC final : public 
CorrectionCandidateCallback {
   const RecordDecl *const Record;
 };
 
-}
+} // namespace
 
 static bool LookupMemberExprInRecord(Sema &SemaRef, LookupResult &R,
                                      Expr *BaseExpr, QualType RTy,
@@ -792,7 +786,8 @@ ExprResult Sema::BuildMemberReferenceExpr(
   if (!Base) {
     TypoExpr *TE = nullptr;
     QualType RecordTy = BaseType;
-    if (IsArrow) RecordTy = RecordTy->castAs<PointerType>()->getPointeeType();
+    if (IsArrow)
+      RecordTy = RecordTy->castAs<PointerType>()->getPointeeType();
     if (LookupMemberExprInRecord(*this, R, nullptr, RecordTy, OpLoc, IsArrow,
                                  SS, TemplateArgs != nullptr, TemplateKWLoc,
                                  TE))
@@ -800,7 +795,7 @@ ExprResult Sema::BuildMemberReferenceExpr(
     if (TE)
       return TE;
 
-  // Explicit member accesses.
+    // Explicit member accesses.
   } else {
     ExprResult BaseResult = Base;
     ExprResult Result =
@@ -827,19 +822,15 @@ ExprResult Sema::BuildMemberReferenceExpr(
   if (SS.isInvalid())
     return ExprError();
 
-  return BuildMemberReferenceExpr(Base, BaseType,
-                                  OpLoc, IsArrow, SS, TemplateKWLoc,
-                                  FirstQualifierInScope, R, TemplateArgs, S,
-                                  false, ExtraArgs);
+  return BuildMemberReferenceExpr(Base, BaseType, OpLoc, IsArrow, SS,
+                                  TemplateKWLoc, FirstQualifierInScope, R,
+                                  TemplateArgs, S, false, ExtraArgs);
 }
 
-ExprResult
-Sema::BuildAnonymousStructUnionMemberReference(const CXXScopeSpec &SS,
-                                               SourceLocation loc,
-                                               IndirectFieldDecl 
*indirectField,
-                                               DeclAccessPair foundDecl,
-                                               Expr *baseObjectExpr,
-                                               SourceLocation opLoc) {
+ExprResult Sema::BuildAnonymousStructUnionMemberReference(
+    const CXXScopeSpec &SS, SourceLocation loc,
+    IndirectFieldDecl *indirectField, DeclAccessPair foundDecl,
+    Expr *baseObjectExpr, SourceLocation opLoc) {
   // First, build the expression that refers to the base object.
 
   // Case 1:  the base of the indirect field is not a field.
@@ -857,9 +848,10 @@ Sema::BuildAnonymousStructUnionMemberReference(const 
CXXScopeSpec &SS,
 
     DeclarationNameInfo baseNameInfo(DeclarationName(), loc);
 
-    ExprResult result
-      = BuildDeclarationNameExpr(EmptySS, baseNameInfo, baseVariable);
-    if (result.isInvalid()) return ExprError();
+    ExprResult result =
+        BuildDeclarationNameExpr(EmptySS, baseNameInfo, baseVariable);
+    if (result.isInvalid())
+      return ExprError();
 
     baseObjectExpr = result.get();
   }
@@ -871,8 +863,8 @@ Sema::BuildAnonymousStructUnionMemberReference(const 
CXXScopeSpec &SS,
   // Build the implicit member references to the field of the
   // anonymous struct/union.
   Expr *result = baseObjectExpr;
-  IndirectFieldDecl::chain_iterator
-  FI = indirectField->chain_begin(), FEnd = indirectField->chain_end();
+  IndirectFieldDecl::chain_iterator FI = indirectField->chain_begin(),
+                                    FEnd = indirectField->chain_end();
 
   // Case 2: the base of the indirect field is a field and the user
   // wrote a member expression.
@@ -914,17 +906,15 @@ Sema::BuildAnonymousStructUnionMemberReference(const 
CXXScopeSpec &SS,
   return result;
 }
 
-static ExprResult
-BuildMSPropertyRefExpr(Sema &S, Expr *BaseExpr, bool IsArrow,
-                       const CXXScopeSpec &SS,
-                       MSPropertyDecl *PD,
-                       const DeclarationNameInfo &NameInfo) {
+static ExprResult BuildMSPropertyRefExpr(Sema &S, Expr *BaseExpr, bool IsArrow,
+                                         const CXXScopeSpec &SS,
+                                         MSPropertyDecl *PD,
+                                         const DeclarationNameInfo &NameInfo) {
   // Property names are always simple identifiers and therefore never
   // require any interesting additional storage.
-  return new (S.Context) MSPropertyRefExpr(BaseExpr, PD, IsArrow,
-                                           S.Context.PseudoObjectTy, VK_LValue,
-                                           SS.getWithLocInContext(S.Context),
-                                           NameInfo.getLoc());
+  return new (S.Context) MSPropertyRefExpr(
+      BaseExpr, PD, IsArrow, S.Context.PseudoObjectTy, VK_LValue,
+      SS.getWithLocInContext(S.Context), NameInfo.getLoc());
 }
 
 MemberExpr *Sema::BuildMemberExpr(
@@ -968,17 +958,12 @@ static bool IsInFnTryBlockHandler(const Scope *S) {
   return false;
 }
 
-ExprResult
-Sema::BuildMemberReferenceExpr(Expr *BaseExpr, QualType BaseExprType,
-                               SourceLocation OpLoc, bool IsArrow,
-                               const CXXScopeSpec &SS,
-                               SourceLocation TemplateKWLoc,
-                               NamedDecl *FirstQualifierInScope,
-                               LookupResult &R,
-                               const TemplateArgumentListInfo *TemplateArgs,
-                               const Scope *S,
-                               bool SuppressQualifierCheck,
-                               ActOnMemberAccessExtraArgs *ExtraArgs) {
+ExprResult Sema::BuildMemberReferenceExpr(
+    Expr *BaseExpr, QualType BaseExprType, SourceLocation OpLoc, bool IsArrow,
+    const CXXScopeSpec &SS, SourceLocation TemplateKWLoc,
+    NamedDecl *FirstQualifierInScope, LookupResult &R,
+    const TemplateArgumentListInfo *TemplateArgs, const Scope *S,
+    bool SuppressQualifierCheck, ActOnMemberAccessExtraArgs *ExtraArgs) {
   assert(!SS.isInvalid() && "nested-name-specifier cannot be invalid");
   // If the member wasn't found in the current instantiation, or if the
   // arrow operator was used with a dependent non-pointer object expression,
@@ -1025,8 +1010,7 @@ Sema::BuildMemberReferenceExpr(Expr *BaseExpr, QualType 
BaseExprType,
   const auto *FD = getCurFunctionDecl();
   if (S && BaseExpr && FD &&
       (isa<CXXDestructorDecl>(FD) || isa<CXXConstructorDecl>(FD)) &&
-      isa<CXXThisExpr>(BaseExpr->IgnoreImpCasts()) &&
-      IsInFnTryBlockHandler(S))
+      isa<CXXThisExpr>(BaseExpr->IgnoreImpCasts()) && IsInFnTryBlockHandler(S))
     Diag(MemberLoc, diag::warn_cdtor_function_try_handler_mem_expr)
         << isa<CXXDestructorDecl>(FD);
 
@@ -1087,13 +1071,10 @@ Sema::BuildMemberReferenceExpr(Expr *BaseExpr, QualType 
BaseExprType,
     // pick a member.
     R.suppressDiagnostics();
 
-    UnresolvedMemberExpr *MemExpr
-      = UnresolvedMemberExpr::Create(Context, R.isUnresolvableResult(),
-                                     BaseExpr, BaseExprType,
-                                     IsArrow, OpLoc,
-                                     SS.getWithLocInContext(Context),
-                                     TemplateKWLoc, MemberNameInfo,
-                                     TemplateArgs, R.begin(), R.end());
+    UnresolvedMemberExpr *MemExpr = UnresolvedMemberExpr::Create(
+        Context, R.isUnresolvableResult(), BaseExpr, BaseExprType, IsArrow,
+        OpLoc, SS.getWithLocInContext(Context), TemplateKWLoc, MemberNameInfo,
+        TemplateArgs, R.begin(), R.end());
 
     return MemExpr;
   }
@@ -1117,7 +1098,8 @@ Sema::BuildMemberReferenceExpr(Expr *BaseExpr, QualType 
BaseExprType,
       // We might have a variable template specialization (or maybe one day a
       // member concept-id).
       if (TemplateArgs || TemplateKWLoc.isValid())
-        return BuildTemplateIdExpr(SS, TemplateKWLoc, R, /*ADL*/false, 
TemplateArgs);
+        return BuildTemplateIdExpr(SS, TemplateKWLoc, R, /*ADL*/ false,
+                                   TemplateArgs);
 
       return BuildDeclarationNameExpr(SS, R.getLookupNameInfo(), MemberDecl,
                                       FoundDecl, TemplateArgs);
@@ -1144,8 +1126,7 @@ Sema::BuildMemberReferenceExpr(Expr *BaseExpr, QualType 
BaseExprType,
     // We may have found a field within an anonymous union or struct
     // (C++ [class.union]).
     return BuildAnonymousStructUnionMemberReference(SS, MemberLoc, FD,
-                                                    FoundDecl, BaseExpr,
-                                                    OpLoc);
+                                                    FoundDecl, BaseExpr, 
OpLoc);
 
   if (VarDecl *Var = dyn_cast<VarDecl>(MemberDecl)) {
     return BuildMemberExpr(BaseExpr, IsArrow, OpLoc,
@@ -1187,8 +1168,8 @@ Sema::BuildMemberReferenceExpr(Expr *BaseExpr, QualType 
BaseExprType,
       return ExprError();
     }
 
-    DeclResult VDecl = CheckVarTemplateId(VarTempl, TemplateKWLoc,
-                                          MemberNameInfo.getLoc(), 
*TemplateArgs);
+    DeclResult VDecl = CheckVarTemplateId(
+        VarTempl, TemplateKWLoc, MemberNameInfo.getLoc(), *TemplateArgs);
     if (VDecl.isInvalid())
       return ExprError();
 
@@ -1212,13 +1193,13 @@ Sema::BuildMemberReferenceExpr(Expr *BaseExpr, QualType 
BaseExprType,
   // We found something that we didn't expect. Complain.
   if (isa<TypeDecl>(MemberDecl))
     Diag(MemberLoc, diag::err_typecheck_member_reference_type)
-      << MemberName << BaseType << int(IsArrow);
+        << MemberName << BaseType << int(IsArrow);
   else
     Diag(MemberLoc, diag::err_typecheck_member_reference_unknown)
-      << MemberName << BaseType << int(IsArrow);
+        << MemberName << BaseType << int(IsArrow);
 
   Diag(MemberDecl->getLocation(), diag::note_member_declared_here)
-    << MemberName;
+      << MemberName;
   R.suppressDiagnostics();
   return ExprError();
 }
@@ -1230,9 +1211,10 @@ Sema::BuildMemberReferenceExpr(Expr *BaseExpr, QualType 
BaseExprType,
 /// this translation unit tried to typedef to id/Class;  we store
 /// it to the side and then re-use it in places like this.
 static bool ShouldTryAgainWithRedefinitionType(Sema &S, ExprResult &base) {
-  const ObjCObjectPointerType *opty
-    = base.get()->getType()->getAs<ObjCObjectPointerType>();
-  if (!opty) return false;
+  const ObjCObjectPointerType *opty =
+      base.get()->getType()->getAs<ObjCObjectPointerType>();
+  if (!opty)
+    return false;
 
   const ObjCObjectType *ty = opty->getObjectType();
 
@@ -1255,17 +1237,14 @@ static bool ShouldTryAgainWithRedefinitionType(Sema &S, 
ExprResult &base) {
   return true;
 }
 
-static bool isRecordType(QualType T) {
-  return T->isRecordType();
-}
+static bool isRecordType(QualType T) { return T->isRecordType(); }
 static bool isPointerToRecordType(QualType T) {
   if (const PointerType *PT = T->getAs<PointerType>())
     return PT->getPointeeType()->isRecordType();
   return false;
 }
 
-ExprResult
-Sema::PerformMemberExprBaseConversion(Expr *Base, bool IsArrow) {
+ExprResult Sema::PerformMemberExprBaseConversion(Expr *Base, bool IsArrow) {
   if (IsArrow && !Base->getType()->isFunctionType())
     return DefaultFunctionArrayLvalueConversion(Base);
 
@@ -1370,8 +1349,7 @@ static ExprResult LookupMemberExpr(Sema &S, LookupResult 
&R,
   if (const ObjCObjectType *OTy = BaseType->getAs<ObjCObjectType>()) {
     if (!SS.isEmpty() && !SS.isInvalid()) {
       S.Diag(SS.getRange().getBegin(), diag::err_qualified_objc_access)
-        << 1 << SS.getScopeRep()
-        << FixItHint::CreateRemoval(SS.getRange());
+          << 1 << SS.getScopeRep() << FixItHint::CreateRemoval(SS.getRange());
       SS.clear();
     }
 
@@ -1393,8 +1371,8 @@ static ExprResult LookupMemberExpr(Sema &S, LookupResult 
&R,
         return new (S.Context) ObjCIsaExpr(BaseExpr.get(), IsArrow, MemberLoc,
                                            OpLoc, 
S.Context.getObjCClassType());
       if (ShouldTryAgainWithRedefinitionType(S, BaseExpr))
-        return LookupMemberExpr(S, R, BaseExpr, IsArrow, OpLoc, SS,
-                                ObjCImpDecl, HasTemplateArgs, TemplateKWLoc);
+        return LookupMemberExpr(S, R, BaseExpr, IsArrow, OpLoc, SS, 
ObjCImpDecl,
+                                HasTemplateArgs, TemplateKWLoc);
       goto fail;
     }
 
@@ -1464,7 +1442,7 @@ static ExprResult LookupMemberExpr(Sema &S, LookupResult 
&R,
         IV->getAccessControl() != ObjCIvarDecl::Package) {
       ObjCInterfaceDecl *ClassOfMethodDecl = nullptr;
       if (ObjCMethodDecl *MD = S.getCurMethodDecl())
-        ClassOfMethodDecl =  MD->getClassInterface();
+        ClassOfMethodDecl = MD->getClassInterface();
       else if (ObjCImpDecl && S.getCurFunctionDecl()) {
         // Case of a c-function declared inside an objc implementation.
         // FIXME: For a c-style function nested inside an objc implementation
@@ -1473,10 +1451,10 @@ static ExprResult LookupMemberExpr(Sema &S, 
LookupResult &R,
         // need be passed down in the AST node and somehow calculated from the
         // AST for a function decl.
         if (ObjCImplementationDecl *IMPD =
-              dyn_cast<ObjCImplementationDecl>(ObjCImpDecl))
+                dyn_cast<ObjCImplementationDecl>(ObjCImpDecl))
           ClassOfMethodDecl = IMPD->getClassInterface();
-        else if (ObjCCategoryImplDecl* CatImplClass =
-                   dyn_cast<ObjCCategoryImplDecl>(ObjCImpDecl))
+        else if (ObjCCategoryImplDecl *CatImplClass =
+                     dyn_cast<ObjCCategoryImplDecl>(ObjCImpDecl))
           ClassOfMethodDecl = CatImplClass->getClassInterface();
       }
       if (!S.getLangOpts().DebuggerSupport) {
@@ -1484,7 +1462,7 @@ static ExprResult LookupMemberExpr(Sema &S, LookupResult 
&R,
           if (!declaresSameEntity(ClassDeclared, IDecl) ||
               !declaresSameEntity(ClassOfMethodDecl, ClassDeclared))
             S.Diag(MemberLoc, diag::err_private_ivar_access)
-              << IV->getDeclName();
+                << IV->getDeclName();
         } else if (!IDecl->isSuperClassOf(ClassOfMethodDecl))
           // @protected
           S.Diag(MemberLoc, diag::err_protected_ivar_access)
@@ -1514,9 +1492,9 @@ static ExprResult LookupMemberExpr(Sema &S, LookupResult 
&R,
         S.Diag(MemberLoc, diag::warn_direct_ivar_access) << IV->getDeclName();
     }
 
-    ObjCIvarRefExpr *Result = new (S.Context) ObjCIvarRefExpr(
-        IV, IV->getUsageType(BaseType), MemberLoc, OpLoc, BaseExpr.get(),
-        IsArrow);
+    ObjCIvarRefExpr *Result = new (S.Context)
+        ObjCIvarRefExpr(IV, IV->getUsageType(BaseType), MemberLoc, OpLoc,
+                        BaseExpr.get(), IsArrow);
 
     if (IV->getType().getObjCLifetime() == Qualifiers::OCL_Weak) {
       if (!S.isUnevaluatedContext() &&
@@ -1541,8 +1519,8 @@ static ExprResult LookupMemberExpr(Sema &S, LookupResult 
&R,
     if (BaseExpr.isInvalid())
       return ExprError();
 
-    assert(S.Context.hasSameUnqualifiedType(BaseType,
-                                            BaseExpr.get()->getType()));
+    assert(
+        S.Context.hasSameUnqualifiedType(BaseType, BaseExpr.get()->getType()));
 
     IdentifierInfo *Member = MemberName.getAsIdentifierInfo();
 
@@ -1565,10 +1543,8 @@ static ExprResult LookupMemberExpr(Sema &S, LookupResult 
&R,
         }
 
         if (ObjCMethodDecl *OMD = dyn_cast<ObjCMethodDecl>(PMDecl)) {
-          Selector SetterSel =
-            SelectorTable::constructSetterSelector(S.PP.getIdentifierTable(),
-                                                   S.PP.getSelectorTable(),
-                                                   Member);
+          Selector SetterSel = SelectorTable::constructSetterSelector(
+              S.PP.getIdentifierTable(), S.PP.getSelectorTable(), Member);
           ObjCMethodDecl *SMD = nullptr;
           if (Decl *SDecl = FindGetterSetterNameDecl(OPT,
                                                      /*Property id*/ nullptr,
@@ -1583,11 +1559,11 @@ static ExprResult LookupMemberExpr(Sema &S, 
LookupResult &R,
       // Use of id.member can only be for a property reference. Do not
       // use the 'id' redefinition in this case.
       if (IsArrow && ShouldTryAgainWithRedefinitionType(S, BaseExpr))
-        return LookupMemberExpr(S, R, BaseExpr, IsArrow, OpLoc, SS,
-                                ObjCImpDecl, HasTemplateArgs, TemplateKWLoc);
+        return LookupMemberExpr(S, R, BaseExpr, IsArrow, OpLoc, SS, 
ObjCImpDecl,
+                                HasTemplateArgs, TemplateKWLoc);
 
       return ExprError(S.Diag(MemberLoc, diag::err_property_not_found)
-                         << MemberName << BaseType);
+                       << MemberName << BaseType);
     }
 
     // 'Class', unqualified only.
@@ -1617,10 +1593,8 @@ static ExprResult LookupMemberExpr(Sema &S, LookupResult 
&R,
         Getter = IFace->lookupPrivateMethod(Sel, false);
       // If we found a getter then this may be a valid dot-reference, we
       // will look for the matching setter, in case it is needed.
-      Selector SetterSel =
-        SelectorTable::constructSetterSelector(S.PP.getIdentifierTable(),
-                                               S.PP.getSelectorTable(),
-                                               Member);
+      Selector SetterSel = SelectorTable::constructSetterSelector(
+          S.PP.getIdentifierTable(), S.PP.getSelectorTable(), Member);
       ObjCMethodDecl *Setter = IFace->lookupClassMethod(SetterSel);
       if (!Setter) {
         // If this reference is in an @implementation, also check for 'private'
@@ -1638,11 +1612,11 @@ static ExprResult LookupMemberExpr(Sema &S, 
LookupResult &R,
       }
 
       if (ShouldTryAgainWithRedefinitionType(S, BaseExpr))
-        return LookupMemberExpr(S, R, BaseExpr, IsArrow, OpLoc, SS,
-                                ObjCImpDecl, HasTemplateArgs, TemplateKWLoc);
+        return LookupMemberExpr(S, R, BaseExpr, IsArrow, OpLoc, SS, 
ObjCImpDecl,
+                                HasTemplateArgs, TemplateKWLoc);
 
       return ExprError(S.Diag(MemberLoc, diag::err_property_not_found)
-                         << MemberName << BaseType);
+                       << MemberName << BaseType);
     }
 
     // Normal property access.
@@ -1655,10 +1629,8 @@ static ExprResult LookupMemberExpr(Sema &S, LookupResult 
&R,
     // We disallow element access for ext_vector_type bool.  There is no way to
     // materialize a reference to a vector element as a pointer (each element 
is
     // one bit in the vector).
-    assert(MemberName.isIdentifier() &&
-           "Ext vector component name not an identifier!");
     S.Diag(R.getNameLoc(), diag::err_ext_vector_component_name_illegal)
-        << MemberName.getAsIdentifierInfo()->getName()
+        << MemberName
         << (BaseExpr.get() ? BaseExpr.get()->getSourceRange() : SourceRange());
     return ExprError();
   }
@@ -1668,8 +1640,8 @@ static ExprResult LookupMemberExpr(Sema &S, LookupResult 
&R,
     // FIXME: this expr should store IsArrow.
     IdentifierInfo *Member = MemberName.getAsIdentifierInfo();
     ExprValueKind VK = (IsArrow ? VK_LValue : BaseExpr.get()->getValueKind());
-    QualType ret = CheckExtVectorComponent(S, BaseType, VK, OpLoc,
-                                           Member, MemberLoc);
+    QualType ret =
+        CheckExtVectorComponent(S, BaseType, VK, OpLoc, Member, MemberLoc);
     if (ret.isNull())
       return ExprError();
     Qualifiers BaseQ =
@@ -1686,12 +1658,12 @@ static ExprResult LookupMemberExpr(Sema &S, 
LookupResult &R,
       !S.Context.getObjCSelRedefinitionType()->isObjCSelType()) {
     BaseExpr = S.ImpCastExprToType(
         BaseExpr.get(), S.Context.getObjCSelRedefinitionType(), CK_BitCast);
-    return LookupMemberExpr(S, R, BaseExpr, IsArrow, OpLoc, SS,
-                            ObjCImpDecl, HasTemplateArgs, TemplateKWLoc);
+    return LookupMemberExpr(S, R, BaseExpr, IsArrow, OpLoc, SS, ObjCImpDecl,
+                            HasTemplateArgs, TemplateKWLoc);
   }
 
   // Failure cases.
- fail:
+fail:
 
   // Recover from dot accesses to pointers, e.g.:
   //   type *foo;
@@ -1712,8 +1684,8 @@ static ExprResult LookupMemberExpr(Sema &S, LookupResult 
&R,
 
       // Recurse as an -> access.
       IsArrow = true;
-      return LookupMemberExpr(S, R, BaseExpr, IsArrow, OpLoc, SS,
-                              ObjCImpDecl, HasTemplateArgs, TemplateKWLoc);
+      return LookupMemberExpr(S, R, BaseExpr, IsArrow, OpLoc, SS, ObjCImpDecl,
+                              HasTemplateArgs, TemplateKWLoc);
     }
   }
 
@@ -1726,8 +1698,8 @@ static ExprResult LookupMemberExpr(Sema &S, LookupResult 
&R,
     if (BaseExpr.isInvalid())
       return ExprError();
     BaseExpr = S.DefaultFunctionArrayConversion(BaseExpr.get());
-    return LookupMemberExpr(S, R, BaseExpr, IsArrow, OpLoc, SS,
-                            ObjCImpDecl, HasTemplateArgs, TemplateKWLoc);
+    return LookupMemberExpr(S, R, BaseExpr, IsArrow, OpLoc, SS, ObjCImpDecl,
+                            HasTemplateArgs, TemplateKWLoc);
   }
 
   // HLSL supports implicit conversion of scalar types to single element vector
@@ -1741,7 +1713,7 @@ static ExprResult LookupMemberExpr(Sema &S, LookupResult 
&R,
   }
 
   S.Diag(OpLoc, diag::err_typecheck_member_reference_struct_union)
-    << BaseType << BaseExpr.get()->getSourceRange() << MemberLoc;
+      << BaseType << BaseExpr.get()->getSourceRange() << MemberLoc;
 
   return ExprError();
 }
@@ -1762,20 +1734,20 @@ ExprResult Sema::ActOnMemberAccessExpr(Scope *S, Expr 
*Base,
   // Decompose the name into its component parts.
   DeclarationNameInfo NameInfo;
   const TemplateArgumentListInfo *TemplateArgs;
-  DecomposeUnqualifiedId(Id, TemplateArgsBuffer,
-                         NameInfo, TemplateArgs);
+  DecomposeUnqualifiedId(Id, TemplateArgsBuffer, NameInfo, TemplateArgs);
 
   bool IsArrow = (OpKind == tok::arrow);
 
   if (getLangOpts().HLSL && IsArrow)
     return ExprError(Diag(OpLoc, diag::err_hlsl_operator_unsupported) << 2);
 
-  NamedDecl *FirstQualifierInScope
-    = (!SS.isSet() ? nullptr : FindFirstQualifierInScope(S, SS.getScopeRep()));
+  NamedDecl *FirstQualifierInScope =
+      (!SS.isSet() ? nullptr : FindFirstQualifierInScope(S, SS.getScopeRep()));
 
   // This is a postfix expression, so get rid of ParenListExprs.
   ExprResult Result = MaybeConvertParenListExprToParenExpr(S, Base);
-  if (Result.isInvalid()) return ExprError();
+  if (Result.isInvalid())
+    return ExprError();
   Base = Result.get();
 
   ActOnMemberAccessExtraArgs ExtraArgs = {S, Id, ObjCImpDecl};
@@ -1847,7 +1819,8 @@ Sema::BuildFieldReferenceExpr(Expr *BaseExpr, bool 
IsArrow,
     VK = VK_LValue;
   } else {
     QualType BaseType = BaseExpr->getType();
-    if (IsArrow) BaseType = BaseType->castAs<PointerType>()->getPointeeType();
+    if (IsArrow)
+      BaseType = BaseType->castAs<PointerType>()->getPointeeType();
 
     Qualifiers BaseQuals = BaseType.getQualifiers();
 
@@ -1856,7 +1829,8 @@ Sema::BuildFieldReferenceExpr(Expr *BaseExpr, bool 
IsArrow,
 
     // CVR attributes from the base are picked up by members,
     // except that 'mutable' members don't pick up 'const'.
-    if (Field->isMutable()) BaseQuals.removeConst();
+    if (Field->isMutable())
+      BaseQuals.removeConst();
 
     Qualifiers MemberQuals =
         Context.getCanonicalType(MemberType).getQualifiers();
@@ -1887,8 +1861,7 @@ Sema::BuildFieldReferenceExpr(Expr *BaseExpr, bool 
IsArrow,
 
   // Build a reference to a private copy for non-static data members in
   // non-static member functions, privatized by OpenMP constructs.
-  if (getLangOpts().OpenMP && IsArrow &&
-      !CurContext->isDependentContext() &&
+  if (getLangOpts().OpenMP && IsArrow && !CurContext->isDependentContext() &&
       isa<CXXThisExpr>(Base.get()->IgnoreParenImpCasts())) {
     if (auto *PrivateCopy = OpenMP().isOpenMPCapturedDecl(Field)) {
       return OpenMP().getOpenMPCapturedExpr(PrivateCopy, VK, OK,
@@ -1904,8 +1877,7 @@ Sema::BuildFieldReferenceExpr(Expr *BaseExpr, bool 
IsArrow,
 
 ExprResult
 Sema::BuildImplicitMemberExpr(const CXXScopeSpec &SS,
-                              SourceLocation TemplateKWLoc,
-                              LookupResult &R,
+                              SourceLocation TemplateKWLoc, LookupResult &R,
                               const TemplateArgumentListInfo *TemplateArgs,
                               bool IsKnownInstance, const Scope *S) {
   assert(!R.empty() && !R.isAmbiguous());

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to