Skip to content

Commit 7aaea58

Browse files
author
Jenkins
committed
merge main into amd-staging
Change-Id: I5cc305d89ac840aada74db0ab7797f7c3e7c662d
2 parents 5087fac + 761bf33 commit 7aaea58

File tree

153 files changed

+3673
-1659
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

153 files changed

+3673
-1659
lines changed

clang/docs/ExternalClangExamples.rst

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ List of projects and tools
3434
etc."
3535

3636
`<https://rprichard.github.io/CxxCodeBrowser/>`_
37-
"A C/C++ source code indexer and navigator"
37+
"A C/C++ source code indexer and navigator."
3838

3939
`<https://github.com/etaoins/qconnectlint>`_
4040
"qconnectlint is a Clang tool for statically verifying the consistency
@@ -98,3 +98,6 @@ List of projects and tools
9898
uses of reserved identifiers to ensuring that code adheres to lifecycle
9999
protocols for certain LibreOffice-specific classes. They may serve as
100100
examples for writing RecursiveASTVisitor-based plugins."
101+
102+
`<https://github.com/banach-space/clang-tutor>`_
103+
"A collection of out-of-tree Clang plugins for teaching and learning."

clang/include/clang/Sema/Sema.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10639,9 +10639,9 @@ class Sema final : public SemaBase {
1063910639
/// BuildOverloadedArrowExpr - Build a call to an overloaded @c operator->
1064010640
/// (if one exists), where @c Base is an expression of class type and
1064110641
/// @c Member is the name of the member we're trying to find.
10642-
ExprResult BuildOverloadedArrowExpr(Expr *Base, SourceLocation OpLoc,
10643-
bool *NoArrowOperatorFound,
10644-
bool &IsDependent);
10642+
ExprResult BuildOverloadedArrowExpr(Scope *S, Expr *Base,
10643+
SourceLocation OpLoc,
10644+
bool *NoArrowOperatorFound = nullptr);
1064510645

1064610646
ExprResult BuildCXXMemberCallExpr(Expr *Exp, NamedDecl *FoundDecl,
1064710647
CXXConversionDecl *Method,

clang/lib/Basic/Targets/SystemZ.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ static const unsigned ZOSAddressMap[] = {
4848
class LLVM_LIBRARY_VISIBILITY SystemZTargetInfo : public TargetInfo {
4949

5050
static const char *const GCCRegNames[];
51-
std::string CPU;
5251
int ISARevision;
5352
bool HasTransactionalExecution;
5453
bool HasVector;
@@ -58,7 +57,7 @@ class LLVM_LIBRARY_VISIBILITY SystemZTargetInfo : public TargetInfo {
5857

5958
public:
6059
SystemZTargetInfo(const llvm::Triple &Triple, const TargetOptions &)
61-
: TargetInfo(Triple), CPU("z10"), ISARevision(8),
60+
: TargetInfo(Triple), ISARevision(getISARevision("z10")),
6261
HasTransactionalExecution(false), HasVector(false), SoftFloat(false),
6362
UnalignedSymbols(false) {
6463
IntMaxType = SignedLong;
@@ -168,8 +167,7 @@ class LLVM_LIBRARY_VISIBILITY SystemZTargetInfo : public TargetInfo {
168167
}
169168

170169
bool setCPU(const std::string &Name) override {
171-
CPU = Name;
172-
ISARevision = getISARevision(CPU);
170+
ISARevision = getISARevision(Name);
173171
return ISARevision != -1;
174172
}
175173

clang/lib/Driver/SanitizerArgs.cpp

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -929,10 +929,16 @@ SanitizerArgs::SanitizerArgs(const ToolChain &TC,
929929
DiagnoseErrors);
930930
}
931931

932-
SharedRuntime =
933-
Args.hasFlag(options::OPT_shared_libsan, options::OPT_static_libsan,
934-
TC.getTriple().isAndroid() || TC.getTriple().isOSFuchsia() ||
935-
TC.getTriple().isOSDarwin());
932+
SharedRuntime = Args.hasFlag(
933+
options::OPT_shared_libsan, options::OPT_static_libsan,
934+
TC.getTriple().isAndroid() || TC.getTriple().isOSFuchsia() ||
935+
TC.getTriple().isOSDarwin() || TC.getTriple().isOSWindows());
936+
if (!SharedRuntime && TC.getTriple().isOSWindows()) {
937+
Arg *A =
938+
Args.getLastArg(options::OPT_shared_libsan, options::OPT_static_libsan);
939+
D.Diag(clang::diag::err_drv_unsupported_opt_for_target)
940+
<< A->getSpelling() << TC.getTriple().str();
941+
}
936942

937943
ImplicitCfiRuntime = TC.getTriple().isAndroid();
938944

clang/lib/Driver/ToolChains/Arch/SystemZ.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ systemz::FloatABI systemz::getSystemZFloatABI(const Driver &D,
3434
return ABI;
3535
}
3636

37-
std::string systemz::getSystemZTargetCPU(const ArgList &Args) {
37+
std::string systemz::getSystemZTargetCPU(const ArgList &Args,
38+
const llvm::Triple &T) {
3839
if (const Arg *A = Args.getLastArg(clang::driver::options::OPT_march_EQ)) {
3940
llvm::StringRef CPUName = A->getValue();
4041

@@ -48,6 +49,8 @@ std::string systemz::getSystemZTargetCPU(const ArgList &Args) {
4849

4950
return std::string(CPUName);
5051
}
52+
if (T.isOSzOS())
53+
return "zEC12";
5154
return CLANG_SYSTEMZ_DEFAULT_ARCH;
5255
}
5356

clang/lib/Driver/ToolChains/Arch/SystemZ.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ enum class FloatABI {
2727

2828
FloatABI getSystemZFloatABI(const Driver &D, const llvm::opt::ArgList &Args);
2929

30-
std::string getSystemZTargetCPU(const llvm::opt::ArgList &Args);
30+
std::string getSystemZTargetCPU(const llvm::opt::ArgList &Args,
31+
const llvm::Triple &T);
3132

3233
void getSystemZTargetFeatures(const Driver &D, const llvm::opt::ArgList &Args,
3334
std::vector<llvm::StringRef> &Features);

clang/lib/Driver/ToolChains/CommonArgs.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -685,7 +685,7 @@ std::string tools::getCPUName(const Driver &D, const ArgList &Args,
685685
return getLanaiTargetCPU(Args);
686686

687687
case llvm::Triple::systemz:
688-
return systemz::getSystemZTargetCPU(Args);
688+
return systemz::getSystemZTargetCPU(Args, T);
689689

690690
case llvm::Triple::r600:
691691
case llvm::Triple::amdgcn:

clang/lib/Driver/ToolChains/Gnu.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -997,7 +997,8 @@ void tools::gnutools::Assembler::ConstructJob(Compilation &C,
997997
case llvm::Triple::systemz: {
998998
// Always pass an -march option, since our default of z10 is later
999999
// than the GNU assembler's default.
1000-
std::string CPUName = systemz::getSystemZTargetCPU(Args);
1000+
std::string CPUName =
1001+
systemz::getSystemZTargetCPU(Args, getToolChain().getTriple());
10011002
CmdArgs.push_back(Args.MakeArgString("-march=" + CPUName));
10021003
break;
10031004
}

clang/lib/Driver/ToolChains/MSVC.cpp

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -201,10 +201,10 @@ void visualstudio::Linker::ConstructJob(Compilation &C, const JobAction &JA,
201201
if (TC.getSanitizerArgs(Args).needsAsanRt()) {
202202
CmdArgs.push_back(Args.MakeArgString("-debug"));
203203
CmdArgs.push_back(Args.MakeArgString("-incremental:no"));
204-
if (TC.getSanitizerArgs(Args).needsSharedRt() ||
205-
Args.hasArg(options::OPT__SLASH_MD, options::OPT__SLASH_MDd)) {
206-
for (const auto &Lib : {"asan_dynamic", "asan_dynamic_runtime_thunk"})
207-
CmdArgs.push_back(TC.getCompilerRTArgString(Args, Lib));
204+
CmdArgs.push_back(TC.getCompilerRTArgString(Args, "asan_dynamic"));
205+
auto defines = Args.getAllArgValues(options::OPT_D);
206+
if (Args.hasArg(options::OPT__SLASH_MD, options::OPT__SLASH_MDd) ||
207+
find(begin(defines), end(defines), "_DLL") != end(defines)) {
208208
// Make sure the dynamic runtime thunk is not optimized out at link time
209209
// to ensure proper SEH handling.
210210
CmdArgs.push_back(Args.MakeArgString(
@@ -213,19 +213,15 @@ void visualstudio::Linker::ConstructJob(Compilation &C, const JobAction &JA,
213213
: "-include:__asan_seh_interceptor"));
214214
// Make sure the linker consider all object files from the dynamic runtime
215215
// thunk.
216-
CmdArgs.push_back(Args.MakeArgString(std::string("-wholearchive:") +
216+
CmdArgs.push_back(Args.MakeArgString(
217+
std::string("-wholearchive:") +
217218
TC.getCompilerRT(Args, "asan_dynamic_runtime_thunk")));
218-
} else if (DLL) {
219-
CmdArgs.push_back(TC.getCompilerRTArgString(Args, "asan_dll_thunk"));
220219
} else {
221-
for (const auto &Lib : {"asan", "asan_cxx"}) {
222-
CmdArgs.push_back(TC.getCompilerRTArgString(Args, Lib));
223-
// Make sure the linker consider all object files from the static lib.
224-
// This is necessary because instrumented dlls need access to all the
225-
// interface exported by the static lib in the main executable.
226-
CmdArgs.push_back(Args.MakeArgString(std::string("-wholearchive:") +
227-
TC.getCompilerRT(Args, Lib)));
228-
}
220+
// Make sure the linker consider all object files from the static runtime
221+
// thunk.
222+
CmdArgs.push_back(Args.MakeArgString(
223+
std::string("-wholearchive:") +
224+
TC.getCompilerRT(Args, "asan_static_runtime_thunk")));
229225
}
230226
}
231227

clang/lib/Sema/SemaExprCXX.cpp

Lines changed: 16 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7966,6 +7966,18 @@ ExprResult Sema::ActOnStartCXXMemberReference(Scope *S, Expr *Base,
79667966

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

79707982
// C++ [over.match.oper]p8:
79717983
// [...] When operator->returns, the operator-> is applied to the value
@@ -7980,8 +7992,7 @@ ExprResult Sema::ActOnStartCXXMemberReference(Scope *S, Expr *Base,
79807992
SmallVector<FunctionDecl*, 8> OperatorArrows;
79817993
CTypes.insert(Context.getCanonicalType(BaseType));
79827994

7983-
while (
7984-
isa<InjectedClassNameType, RecordType>(BaseType.getCanonicalType())) {
7995+
while (BaseType->isRecordType()) {
79857996
if (OperatorArrows.size() >= getLangOpts().ArrowDepth) {
79867997
Diag(OpLoc, diag::err_operator_arrow_depth_exceeded)
79877998
<< StartingType << getLangOpts().ArrowDepth << Base->getSourceRange();
@@ -7991,26 +8002,15 @@ ExprResult Sema::ActOnStartCXXMemberReference(Scope *S, Expr *Base,
79918002
return ExprError();
79928003
}
79938004

7994-
bool IsDependent;
79958005
Result = BuildOverloadedArrowExpr(
7996-
Base, OpLoc,
8006+
S, Base, OpLoc,
79978007
// When in a template specialization and on the first loop iteration,
79988008
// potentially give the default diagnostic (with the fixit in a
79998009
// separate note) instead of having the error reported back to here
80008010
// and giving a diagnostic with a fixit attached to the error itself.
80018011
(FirstIteration && CurFD && CurFD->isFunctionTemplateSpecialization())
80028012
? nullptr
8003-
: &NoArrowOperatorFound,
8004-
IsDependent);
8005-
8006-
if (IsDependent) {
8007-
// BuildOverloadedArrowExpr sets IsDependent to indicate that we need
8008-
// to build a dependent overloaded arrow expression.
8009-
assert(BaseType->isDependentType());
8010-
BaseType = Context.DependentTy;
8011-
break;
8012-
}
8013-
8013+
: &NoArrowOperatorFound);
80148014
if (Result.isInvalid()) {
80158015
if (NoArrowOperatorFound) {
80168016
if (FirstIteration) {
@@ -8030,7 +8030,6 @@ ExprResult Sema::ActOnStartCXXMemberReference(Scope *S, Expr *Base,
80308030
}
80318031
return ExprError();
80328032
}
8033-
80348033
Base = Result.get();
80358034
if (CXXOperatorCallExpr *OpCall = dyn_cast<CXXOperatorCallExpr>(Base))
80368035
OperatorArrows.push_back(OpCall->getDirectCallee());
@@ -8068,7 +8067,7 @@ ExprResult Sema::ActOnStartCXXMemberReference(Scope *S, Expr *Base,
80688067
// it's legal for the type to be incomplete if this is a pseudo-destructor
80698068
// call. We'll do more incomplete-type checks later in the lookup process,
80708069
// so just skip this check for ObjC types.
8071-
if (!isa<InjectedClassNameType, RecordType>(BaseType.getCanonicalType())) {
8070+
if (!BaseType->isRecordType()) {
80728071
ObjectType = ParsedType::make(BaseType);
80738072
MayBePseudoDestructor = true;
80748073
return Base;
@@ -8086,10 +8085,6 @@ ExprResult Sema::ActOnStartCXXMemberReference(Scope *S, Expr *Base,
80868085
return CreateRecoveryExpr(Base->getBeginLoc(), Base->getEndLoc(), {Base});
80878086
}
80888087

8089-
// We can't implicitly declare the destructor for a templated class.
8090-
if (BaseType->isDependentType())
8091-
MayBePseudoDestructor = true;
8092-
80938088
// C++ [basic.lookup.classref]p2:
80948089
// If the id-expression in a class member access (5.2.5) is an
80958090
// unqualified-id, and the type of the object expression is of a class

clang/lib/Sema/SemaOverload.cpp

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -15878,14 +15878,12 @@ Sema::BuildCallToObjectOfClassType(Scope *S, Expr *Obj,
1587815878
return CheckForImmediateInvocation(MaybeBindToTemporary(TheCall), Method);
1587915879
}
1588015880

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

15887-
IsDependent = false;
15888-
1588915887
if (checkPlaceholderForOverload(*this, Base))
1589015888
return ExprError();
1589115889

@@ -15906,19 +15904,7 @@ ExprResult Sema::BuildOverloadedArrowExpr(Expr *Base, SourceLocation OpLoc,
1590615904
return ExprError();
1590715905

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

1592415910
for (LookupResult::iterator Oper = R.begin(), OperEnd = R.end();

clang/lib/Sema/TreeTransform.h

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16583,14 +16583,10 @@ ExprResult TreeTransform<Derived>::RebuildCXXOperatorCallExpr(
1658316583
} else if (Op == OO_Arrow) {
1658416584
// It is possible that the type refers to a RecoveryExpr created earlier
1658516585
// in the tree transformation.
16586-
if (First->containsErrors())
16586+
if (First->getType()->isDependentType())
1658716587
return ExprError();
16588-
bool IsDependent;
1658916588
// -> is never a builtin operation.
16590-
ExprResult Result = SemaRef.BuildOverloadedArrowExpr(
16591-
First, OpLoc, /*NoArrowOperatorFound=*/nullptr, IsDependent);
16592-
assert(!IsDependent);
16593-
return Result;
16589+
return SemaRef.BuildOverloadedArrowExpr(nullptr, First, OpLoc);
1659416590
} else if (Second == nullptr || isPostIncDec) {
1659516591
if (!First->getType()->isOverloadableType() ||
1659616592
(Op == OO_Amp && getSema().isQualifiedMemberAccess(First))) {

clang/test/CXX/temp/temp.res/temp.dep/temp.dep.type/p4.cpp

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -485,19 +485,16 @@ namespace N4 {
485485
template<typename T>
486486
struct A {
487487
void not_instantiated(A a, A<T> b, T c) {
488-
a->x; // expected-error {{member reference type 'A<T>' is not a pointer; did you mean to use '.'?}}
489-
b->x; // expected-error {{member reference type 'A<T>' is not a pointer; did you mean to use '.'?}}
488+
a->x;
489+
b->x;
490490
c->x;
491491
}
492492

493493
void instantiated(A a, A<T> b, T c) {
494-
// FIXME: We should only emit a single diagnostic suggesting to use '.'!
495-
a->x; // expected-error {{member reference type 'A<T>' is not a pointer; did you mean to use '.'?}}
496-
// expected-error@-1 {{member reference type 'A<int>' is not a pointer; did you mean to use '.'?}}
497-
// expected-error@-2 {{no member named 'x' in 'N4::A<int>'}}
498-
b->x; // expected-error {{member reference type 'A<T>' is not a pointer; did you mean to use '.'?}}
499-
// expected-error@-1 {{member reference type 'A<int>' is not a pointer; did you mean to use '.'?}}
500-
// expected-error@-2 {{no member named 'x' in 'N4::A<int>'}}
494+
a->x; // expected-error {{member reference type 'A<int>' is not a pointer; did you mean to use '.'?}}
495+
// expected-error@-1 {{no member named 'x' in 'N4::A<int>'}}
496+
b->x; // expected-error {{member reference type 'A<int>' is not a pointer; did you mean to use '.'?}}
497+
// expected-error@-1 {{no member named 'x' in 'N4::A<int>'}}
501498
c->x; // expected-error {{member reference type 'int' is not a pointer}}
502499
}
503500
};
@@ -544,10 +541,11 @@ namespace N4 {
544541
a->T::f();
545542
a->T::g();
546543

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

553551
void instantiated(D a) {

clang/test/Driver/cl-link.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,15 @@
1313
// ASAN: link.exe
1414
// ASAN: "-debug"
1515
// ASAN: "-incremental:no"
16-
// ASAN: "{{[^"]*}}clang_rt.asan.lib"
17-
// ASAN: "-wholearchive:{{.*}}clang_rt.asan.lib"
18-
// ASAN: "{{[^"]*}}clang_rt.asan_cxx.lib"
19-
// ASAN: "-wholearchive:{{.*}}clang_rt.asan_cxx.lib"
16+
// ASAN: "{{[^"]*}}clang_rt.asan_dynamic.lib"
17+
// ASAN: "-wholearchive:{{.*}}clang_rt.asan_static_runtime_thunk.lib"
2018
// ASAN: "{{.*}}cl-link{{.*}}.obj"
2119

2220
// RUN: %clang_cl -m32 -arch:IA32 --target=i386-pc-win32 /MD /Tc%s -fuse-ld=link -### -fsanitize=address 2>&1 | FileCheck --check-prefix=ASAN-MD %s
2321
// ASAN-MD: link.exe
2422
// ASAN-MD: "-debug"
2523
// ASAN-MD: "-incremental:no"
2624
// ASAN-MD: "{{.*}}clang_rt.asan_dynamic.lib"
27-
// ASAN-MD: "{{[^"]*}}clang_rt.asan_dynamic_runtime_thunk.lib"
2825
// ASAN-MD: "-include:___asan_seh_interceptor"
2926
// ASAN-MD: "-wholearchive:{{.*}}clang_rt.asan_dynamic_runtime_thunk.lib"
3027
// ASAN-MD: "{{.*}}cl-link{{.*}}.obj"
@@ -40,7 +37,8 @@
4037
// ASAN-DLL: "-dll"
4138
// ASAN-DLL: "-debug"
4239
// ASAN-DLL: "-incremental:no"
43-
// ASAN-DLL: "{{.*}}clang_rt.asan_dll_thunk.lib"
40+
// ASAN-DLL: "{{.*}}clang_rt.asan_dynamic.lib"
41+
// ASAN-DLL: "-wholearchive:{{.*}}clang_rt.asan_static_runtime_thunk.lib"
4442
// ASAN-DLL: "{{.*}}cl-link{{.*}}.obj"
4543

4644
// RUN: %clang_cl /Zi /Tc%s -fuse-ld=link -### 2>&1 | FileCheck --check-prefix=DEBUG %s

0 commit comments

Comments
 (0)