Skip to content

Commit

Permalink
Integrate LLVM at llvm/llvm-project@5f74671c8587
Browse files Browse the repository at this point in the history
Updates LLVM usage to match
[5f74671c8587](llvm/llvm-project@5f74671c8587)

PiperOrigin-RevId: 672766395
  • Loading branch information
tensorflower-gardener committed Sep 10, 2024
1 parent 572b731 commit 5d4c6c5
Show file tree
Hide file tree
Showing 6 changed files with 667 additions and 16 deletions.
213 changes: 213 additions & 0 deletions third_party/llvm/generated.patch
Original file line number Diff line number Diff line change
@@ -1 +1,214 @@
Auto generated patch. Do not edit or delete it, even if empty.
diff -ruN --strip-trailing-cr a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -10639,9 +10639,9 @@
/// BuildOverloadedArrowExpr - Build a call to an overloaded @c operator->
/// (if one exists), where @c Base is an expression of class type and
/// @c Member is the name of the member we're trying to find.
- ExprResult BuildOverloadedArrowExpr(Expr *Base, SourceLocation OpLoc,
- bool *NoArrowOperatorFound,
- bool &IsDependent);
+ ExprResult BuildOverloadedArrowExpr(Scope *S, Expr *Base,
+ SourceLocation OpLoc,
+ bool *NoArrowOperatorFound = nullptr);

ExprResult BuildCXXMemberCallExpr(Expr *Exp, NamedDecl *FoundDecl,
CXXConversionDecl *Method,
diff -ruN --strip-trailing-cr a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp
--- a/clang/lib/Sema/SemaExprCXX.cpp
+++ b/clang/lib/Sema/SemaExprCXX.cpp
@@ -7966,6 +7966,18 @@

QualType BaseType = Base->getType();
MayBePseudoDestructor = false;
+ if (BaseType->isDependentType()) {
+ // If we have a pointer to a dependent type and are using the -> operator,
+ // the object type is the type that the pointer points to. We might still
+ // have enough information about that type to do something useful.
+ if (OpKind == tok::arrow)
+ if (const PointerType *Ptr = BaseType->getAs<PointerType>())
+ BaseType = Ptr->getPointeeType();
+
+ ObjectType = ParsedType::make(BaseType);
+ MayBePseudoDestructor = true;
+ return Base;
+ }

// C++ [over.match.oper]p8:
// [...] When operator->returns, the operator-> is applied to the value
@@ -7980,8 +7992,7 @@
SmallVector<FunctionDecl*, 8> OperatorArrows;
CTypes.insert(Context.getCanonicalType(BaseType));

- while (
- isa<InjectedClassNameType, RecordType>(BaseType.getCanonicalType())) {
+ while (BaseType->isRecordType()) {
if (OperatorArrows.size() >= getLangOpts().ArrowDepth) {
Diag(OpLoc, diag::err_operator_arrow_depth_exceeded)
<< StartingType << getLangOpts().ArrowDepth << Base->getSourceRange();
@@ -7991,26 +8002,15 @@
return ExprError();
}

- bool IsDependent;
Result = BuildOverloadedArrowExpr(
- Base, OpLoc,
+ S, Base, OpLoc,
// When in a template specialization and on the first loop iteration,
// potentially give the default diagnostic (with the fixit in a
// separate note) instead of having the error reported back to here
// and giving a diagnostic with a fixit attached to the error itself.
(FirstIteration && CurFD && CurFD->isFunctionTemplateSpecialization())
? nullptr
- : &NoArrowOperatorFound,
- IsDependent);
-
- if (IsDependent) {
- // BuildOverloadedArrowExpr sets IsDependent to indicate that we need
- // to build a dependent overloaded arrow expression.
- assert(BaseType->isDependentType());
- BaseType = Context.DependentTy;
- break;
- }
-
+ : &NoArrowOperatorFound);
if (Result.isInvalid()) {
if (NoArrowOperatorFound) {
if (FirstIteration) {
@@ -8030,7 +8030,6 @@
}
return ExprError();
}
-
Base = Result.get();
if (CXXOperatorCallExpr *OpCall = dyn_cast<CXXOperatorCallExpr>(Base))
OperatorArrows.push_back(OpCall->getDirectCallee());
@@ -8068,7 +8067,7 @@
// it's legal for the type to be incomplete if this is a pseudo-destructor
// call. We'll do more incomplete-type checks later in the lookup process,
// so just skip this check for ObjC types.
- if (!isa<InjectedClassNameType, RecordType>(BaseType.getCanonicalType())) {
+ if (!BaseType->isRecordType()) {
ObjectType = ParsedType::make(BaseType);
MayBePseudoDestructor = true;
return Base;
@@ -8086,10 +8085,6 @@
return CreateRecoveryExpr(Base->getBeginLoc(), Base->getEndLoc(), {Base});
}

- // We can't implicitly declare the destructor for a templated class.
- if (BaseType->isDependentType())
- MayBePseudoDestructor = true;
-
// C++ [basic.lookup.classref]p2:
// If the id-expression in a class member access (5.2.5) is an
// unqualified-id, and the type of the object expression is of a class
diff -ruN --strip-trailing-cr a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp
--- a/clang/lib/Sema/SemaOverload.cpp
+++ b/clang/lib/Sema/SemaOverload.cpp
@@ -15878,14 +15878,12 @@
return CheckForImmediateInvocation(MaybeBindToTemporary(TheCall), Method);
}

-ExprResult Sema::BuildOverloadedArrowExpr(Expr *Base, SourceLocation OpLoc,
- bool *NoArrowOperatorFound,
- bool &IsDependent) {
- assert(Base->getType()->getAsRecordDecl() &&
+ExprResult
+Sema::BuildOverloadedArrowExpr(Scope *S, Expr *Base, SourceLocation OpLoc,
+ bool *NoArrowOperatorFound) {
+ assert(Base->getType()->isRecordType() &&
"left-hand side must have class type");

- IsDependent = false;
-
if (checkPlaceholderForOverload(*this, Base))
return ExprError();

@@ -15906,19 +15904,7 @@
return ExprError();

LookupResult R(*this, OpName, OpLoc, LookupOrdinaryName);
- LookupParsedName(R, /*S=*/nullptr, /*SS=*/nullptr, Base->getType());
-
- // If the expression is dependent and we either:
- // - found a member of the current instantiation named 'operator->', or
- // - found nothing, and the lookup context has no dependent base classes
- //
- // then we should build a dependent class member access expression.
- if (R.wasNotFoundInCurrentInstantiation() ||
- (Base->isTypeDependent() && !R.empty())) {
- IsDependent = true;
- return Base;
- }
-
+ LookupQualifiedName(R, Base->getType()->castAs<RecordType>()->getDecl());
R.suppressAccessDiagnostics();

for (LookupResult::iterator Oper = R.begin(), OperEnd = R.end();
diff -ruN --strip-trailing-cr a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h
--- a/clang/lib/Sema/TreeTransform.h
+++ b/clang/lib/Sema/TreeTransform.h
@@ -16583,14 +16583,10 @@
} else if (Op == OO_Arrow) {
// It is possible that the type refers to a RecoveryExpr created earlier
// in the tree transformation.
- if (First->containsErrors())
+ if (First->getType()->isDependentType())
return ExprError();
- bool IsDependent;
// -> is never a builtin operation.
- ExprResult Result = SemaRef.BuildOverloadedArrowExpr(
- First, OpLoc, /*NoArrowOperatorFound=*/nullptr, IsDependent);
- assert(!IsDependent);
- return Result;
+ return SemaRef.BuildOverloadedArrowExpr(nullptr, First, OpLoc);
} else if (Second == nullptr || isPostIncDec) {
if (!First->getType()->isOverloadableType() ||
(Op == OO_Amp && getSema().isQualifiedMemberAccess(First))) {
diff -ruN --strip-trailing-cr a/clang/test/CXX/temp/temp.res/temp.dep/temp.dep.type/p4.cpp b/clang/test/CXX/temp/temp.res/temp.dep/temp.dep.type/p4.cpp
--- a/clang/test/CXX/temp/temp.res/temp.dep/temp.dep.type/p4.cpp
+++ b/clang/test/CXX/temp/temp.res/temp.dep/temp.dep.type/p4.cpp
@@ -484,19 +484,16 @@
template<typename T>
struct A {
void not_instantiated(A a, A<T> b, T c) {
- a->x; // expected-error {{member reference type 'A<T>' is not a pointer; did you mean to use '.'?}}
- b->x; // expected-error {{member reference type 'A<T>' is not a pointer; did you mean to use '.'?}}
+ a->x;
+ b->x;
c->x;
}

void instantiated(A a, A<T> b, T c) {
- // FIXME: We should only emit a single diagnostic suggesting to use '.'!
- a->x; // expected-error {{member reference type 'A<T>' is not a pointer; did you mean to use '.'?}}
- // expected-error@-1 {{member reference type 'A<int>' is not a pointer; did you mean to use '.'?}}
- // expected-error@-2 {{no member named 'x' in 'N4::A<int>'}}
- b->x; // expected-error {{member reference type 'A<T>' is not a pointer; did you mean to use '.'?}}
- // expected-error@-1 {{member reference type 'A<int>' is not a pointer; did you mean to use '.'?}}
- // expected-error@-2 {{no member named 'x' in 'N4::A<int>'}}
+ a->x; // expected-error {{member reference type 'A<int>' is not a pointer; did you mean to use '.'?}}
+ // expected-error@-1 {{no member named 'x' in 'N4::A<int>'}}
+ b->x; // expected-error {{member reference type 'A<int>' is not a pointer; did you mean to use '.'?}}
+ // expected-error@-1 {{no member named 'x' in 'N4::A<int>'}}
c->x; // expected-error {{member reference type 'int' is not a pointer}}
}
};
@@ -543,10 +540,11 @@
a->T::f();
a->T::g();

- a->U::x;
- a->U::y;
- a->U::f();
- a->U::g();
+ // FIXME: 'U' should be a dependent name, and its lookup context should be 'a.operator->()'!
+ a->U::x; // expected-error {{use of undeclared identifier 'U'}}
+ a->U::y; // expected-error {{use of undeclared identifier 'U'}}
+ a->U::f(); // expected-error {{use of undeclared identifier 'U'}}
+ a->U::g(); // expected-error {{use of undeclared identifier 'U'}}
}

void instantiated(D a) {
4 changes: 2 additions & 2 deletions third_party/llvm/workspace.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ load("//third_party:repo.bzl", "tf_http_archive")

def repo(name):
"""Imports LLVM."""
LLVM_COMMIT = "2d338bed00b2bba713bceb4915400063b95929b2"
LLVM_SHA256 = "2e481f2cd4ec80421c0d644043cd929db55c82a3e9639083269b189cbae0f992"
LLVM_COMMIT = "5f74671c85877e03622e8d308aee15ed73ccee7c"
LLVM_SHA256 = "238645e6972ca01dbaecbc4d7f1efb13a7643eaa0f1a84c965f6f33f1e003692"

tf_http_archive(
name = name,
Expand Down
Loading

0 comments on commit 5d4c6c5

Please sign in to comment.