Skip to content

Commit 6888753

Browse files
authored
Merge branch 'main' into SPV_INTEL_long_composites-2-more-instr
2 parents 6a4198c + a1163d8 commit 6888753

File tree

51 files changed

+870
-179
lines changed

Some content is hidden

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

51 files changed

+870
-179
lines changed

clang-tools-extra/test/clang-tidy/checkers/bugprone/chained-comparison.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %check_clang_tidy %s bugprone-chained-comparison %t
1+
// RUN: %check_clang_tidy --extra-arg=-Wno-error=parentheses %s bugprone-chained-comparison %t
22

33
void badly_chained_1(int x, int y, int z)
44
{

clang-tools-extra/test/clang-tidy/checkers/bugprone/chained-comparison.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %check_clang_tidy -std=c++98-or-later %s bugprone-chained-comparison %t
1+
// RUN: %check_clang_tidy -std=c++98-or-later --extra-arg=-Wno-error=parentheses %s bugprone-chained-comparison %t
22

33
void badly_chained_1(int x, int y, int z)
44
{

clang/docs/ReleaseNotes.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,8 @@ Improvements to Clang's diagnostics
147147
- The ``-Wunsafe-buffer-usage`` warning has been updated to warn
148148
about unsafe libc function calls. Those new warnings are emitted
149149
under the subgroup ``-Wunsafe-buffer-usage-in-libc-call``.
150+
- Diagnostics on chained comparisons (``a < b < c``) are now an error by default. This can be disabled with
151+
``-Wno-error=parentheses``.
150152

151153
Improvements to Clang's time-trace
152154
----------------------------------

clang/include/clang/Basic/DiagnosticDriverKinds.td

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,11 @@ def err_cpu_unsupported_isa
279279
def err_arch_unsupported_isa
280280
: Error<"architecture '%0' does not support '%1' execution mode">;
281281

282+
def err_zos_target_release_discontinued
283+
: Error<"z/OS target level \"%0\" is discontinued">;
284+
def err_zos_target_unrecognized_release
285+
: Error<"z/OS target level \"%0\" is invalid">;
286+
282287
def err_drv_I_dash_not_supported : Error<
283288
"'%0' not supported, please use -iquote instead">;
284289
def err_drv_unknown_argument : Error<"unknown argument: '%0'">;

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7126,7 +7126,7 @@ def note_precedence_conditional_first : Note<
71267126

71277127
def warn_consecutive_comparison : Warning<
71287128
"comparisons like 'X<=Y<=Z' don't have their mathematical meaning">,
7129-
InGroup<Parentheses>;
7129+
InGroup<Parentheses>, DefaultError;
71307130

71317131
def warn_enum_constant_in_bool_context : Warning<
71327132
"converting the enum constant to a boolean">,

clang/include/clang/Driver/Options.td

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4728,6 +4728,7 @@ def mwatchsimulator_version_min_EQ : Joined<["-"], "mwatchsimulator-version-min=
47284728
def march_EQ : Joined<["-"], "march=">, Group<m_Group>,
47294729
Flags<[TargetSpecific]>, Visibility<[ClangOption, CLOption, DXCOption, FlangOption]>,
47304730
HelpText<"For a list of available architectures for the target use '-mcpu=help'">;
4731+
def mzos_target_EQ : Joined<["-"], "mzos-target=">, Group<m_Group>, Visibility<[ClangOption, CC1Option]>, HelpText<"Set the z/OS release of the runtime environment">;
47314732
def masm_EQ : Joined<["-"], "masm=">, Group<m_Group>, Visibility<[ClangOption, FlangOption]>;
47324733
def inline_asm_EQ : Joined<["-"], "inline-asm=">, Group<m_Group>,
47334734
Visibility<[ClangOption, CC1Option]>,

clang/lib/Basic/Targets/SystemZ.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include "clang/Basic/LangOptions.h"
1616
#include "clang/Basic/MacroBuilder.h"
1717
#include "clang/Basic/TargetBuiltins.h"
18+
#include "llvm/ADT/StringExtras.h"
1819
#include "llvm/ADT/StringSwitch.h"
1920

2021
using namespace clang;
@@ -178,6 +179,21 @@ void SystemZTargetInfo::getTargetDefines(const LangOptions &Opts,
178179
Builder.defineMacro("__VX__");
179180
if (Opts.ZVector)
180181
Builder.defineMacro("__VEC__", "10305");
182+
183+
/* Set __TARGET_LIB__ only if a value was given. If no value was given */
184+
/* we rely on the LE headers to define __TARGET_LIB__. */
185+
if (!getTriple().getOSVersion().empty()) {
186+
llvm::VersionTuple V = getTriple().getOSVersion();
187+
// Create string with form: 0xPVRRMMMM, where P=4
188+
std::string Str("0x");
189+
unsigned int Librel = 0x40000000;
190+
Librel |= V.getMajor() << 24;
191+
Librel |= (V.getMinor() ? V.getMinor().value() : 1) << 16;
192+
Librel |= V.getSubminor() ? V.getSubminor().value() : 0;
193+
Str += llvm::utohexstr(Librel);
194+
195+
Builder.defineMacro("__TARGET_LIB__", Str.c_str());
196+
}
181197
}
182198

183199
llvm::SmallVector<Builtin::InfosShard>

clang/lib/Driver/Driver.cpp

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -564,6 +564,72 @@ DerivedArgList *Driver::TranslateInputArgs(const InputArgList &Args) const {
564564
return DAL;
565565
}
566566

567+
static void setZosTargetVersion(const Driver &D, llvm::Triple &Target,
568+
StringRef ArgTarget) {
569+
570+
static bool BeSilent = false;
571+
auto IsTooOldToBeSupported = [](int v, int r) -> bool {
572+
return ((v < 2) || ((v == 2) && (r < 4)));
573+
};
574+
575+
/* expect CURRENT, zOSV2R[45], or 0xnnnnnnnn */
576+
if (ArgTarget.equals_insensitive("CURRENT")) {
577+
/* If the user gives CURRENT, then we rely on the LE to set */
578+
/* __TARGET_LIB__. There's nothing more we need to do. */
579+
} else {
580+
unsigned int Version = 0;
581+
unsigned int Release = 0;
582+
unsigned int Modification = 0;
583+
bool IsOk = true;
584+
llvm::Regex ZOsvRegex("[zZ][oO][sS][vV]([0-9])[rR]([0-9])");
585+
llvm::Regex HexRegex(
586+
"0x4" /* product */
587+
"([0-9a-fA-F])" /* version */
588+
"([0-9a-fA-F][0-9a-fA-F])" /* release */
589+
"([0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F])" /* modification */);
590+
SmallVector<StringRef> Matches;
591+
592+
if (ZOsvRegex.match(ArgTarget, &Matches)) {
593+
Matches[1].getAsInteger(10, Version);
594+
Matches[2].getAsInteger(10, Release);
595+
Modification = 0;
596+
if (IsTooOldToBeSupported(Version, Release)) {
597+
if (!BeSilent)
598+
D.Diag(diag::err_zos_target_release_discontinued) << ArgTarget;
599+
IsOk = false;
600+
}
601+
} else if (HexRegex.match(ArgTarget, &Matches)) {
602+
Matches[1].getAsInteger(16, Version);
603+
Matches[2].getAsInteger(16, Release);
604+
Matches[3].getAsInteger(16, Modification);
605+
if (IsTooOldToBeSupported(Version, Release)) {
606+
if (!BeSilent)
607+
D.Diag(diag::err_zos_target_release_discontinued) << ArgTarget;
608+
IsOk = false;
609+
}
610+
} else {
611+
/* something else: need to report an error */
612+
if (!BeSilent)
613+
D.Diag(diag::err_zos_target_unrecognized_release) << ArgTarget;
614+
IsOk = false;
615+
}
616+
617+
if (IsOk) {
618+
llvm::VersionTuple V(Version, Release, Modification);
619+
llvm::VersionTuple TV = Target.getOSVersion();
620+
// The goal is to pick the minimally supported version of
621+
// the OS. Pick the lesser as the target.
622+
if (TV.empty() || V < TV) {
623+
SmallString<16> Str;
624+
Str = llvm::Triple::getOSTypeName(Target.getOS());
625+
Str += V.getAsString();
626+
Target.setOSName(Str);
627+
}
628+
}
629+
}
630+
BeSilent = true;
631+
}
632+
567633
/// Compute target triple from args.
568634
///
569635
/// This routine provides the logic to compute a target triple from various
@@ -689,6 +755,12 @@ static llvm::Triple computeTargetTriple(const Driver &D,
689755
}
690756
}
691757

758+
if (Target.isOSzOS()) {
759+
if ((A = Args.getLastArg(options::OPT_mzos_target_EQ))) {
760+
setZosTargetVersion(D, Target, A->getValue());
761+
}
762+
}
763+
692764
// Handle -miamcu flag.
693765
if (Args.hasFlag(options::OPT_miamcu, options::OPT_mno_iamcu, false)) {
694766
if (Target.get32BitArchVariant().getArch() != llvm::Triple::x86)

clang/lib/Driver/ToolChain.cpp

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -854,9 +854,25 @@ ToolChain::getTargetSubDirPath(StringRef BaseDir) const {
854854
return {};
855855
};
856856

857-
if (auto Path = getPathForTriple(getTriple()))
857+
const llvm::Triple &T = getTriple();
858+
if (auto Path = getPathForTriple(T))
858859
return *Path;
859860

861+
if (T.isOSzOS() &&
862+
(!T.getOSVersion().empty() || !T.getEnvironmentVersion().empty())) {
863+
// Build the triple without version information
864+
const llvm::Triple &TripleWithoutVersion =
865+
(T.hasEnvironment()
866+
? llvm::Triple(
867+
T.getArchName(), T.getVendorName(),
868+
llvm::Triple::getOSTypeName(T.getOS()),
869+
llvm::Triple::getEnvironmentTypeName(T.getEnvironment()))
870+
: llvm::Triple(T.getArchName(), T.getVendorName(),
871+
llvm::Triple::getOSTypeName(T.getOS())));
872+
if (auto Path = getPathForTriple(TripleWithoutVersion))
873+
return *Path;
874+
}
875+
860876
// When building with per target runtime directories, various ways of naming
861877
// the Arm architecture may have been normalised to simply "arm".
862878
// For example "armv8l" (Armv8 AArch32 little endian) is replaced with "arm".
@@ -872,14 +888,14 @@ ToolChain::getTargetSubDirPath(StringRef BaseDir) const {
872888
//
873889
// M profile Arm is bare metal and we know they will not be using the per
874890
// target runtime directory layout.
875-
if (getTriple().getArch() == Triple::arm && !getTriple().isArmMClass()) {
876-
llvm::Triple ArmTriple = getTriple();
891+
if (T.getArch() == Triple::arm && !T.isArmMClass()) {
892+
llvm::Triple ArmTriple = T;
877893
ArmTriple.setArch(Triple::arm);
878894
if (auto Path = getPathForTriple(ArmTriple))
879895
return *Path;
880896
}
881897

882-
if (getTriple().isAndroid())
898+
if (T.isAndroid())
883899
return getFallbackAndroidTargetPath(BaseDir);
884900

885901
return {};

clang/lib/Driver/ToolChains/AIX.cpp

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,32 @@ void aix::Linker::ConstructJob(Compilation &C, const JobAction &JA,
230230
// '-bnocdtors' that '-Wl' might forward.
231231
CmdArgs.push_back("-bcdtors:all:0:s");
232232

233+
if (Args.hasArg(options::OPT_rpath)) {
234+
for (const auto &bopt : Args.getAllArgValues(options::OPT_b))
235+
// Check -b opts prefix for "libpath:" or exact match for "nolibpath"
236+
if (!bopt.rfind("libpath:", 0) || bopt == "nolibpath")
237+
D.Diag(diag::err_drv_cannot_mix_options) << "-rpath" << "-b" + bopt;
238+
239+
for (const auto &wlopt : Args.getAllArgValues(options::OPT_Wl_COMMA))
240+
// Check -Wl, opts prefix for "-blibpath:" or exact match for
241+
// "-bnolibpath"
242+
if (!wlopt.rfind("-blibpath:", 0) || wlopt == "-bnolibpath")
243+
D.Diag(diag::err_drv_cannot_mix_options) << "-rpath" << "-Wl," + wlopt;
244+
245+
for (const auto &xopt : Args.getAllArgValues(options::OPT_Xlinker))
246+
// Check -Xlinker opts prefix for "-blibpath:" or exact match for
247+
// "-bnolibpath"
248+
if (!xopt.rfind("-blibpath:", 0) || xopt == "-bnolibpath")
249+
D.Diag(diag::err_drv_cannot_mix_options)
250+
<< "-rpath" << "-Xlinker " + xopt;
251+
252+
std::string BlibPathStr = "";
253+
for (const auto &dir : Args.getAllArgValues(options::OPT_rpath))
254+
BlibPathStr += dir + ":";
255+
BlibPathStr += "/usr/lib:/lib";
256+
CmdArgs.push_back(Args.MakeArgString(Twine("-blibpath:") + BlibPathStr));
257+
}
258+
233259
// Specify linker input file(s).
234260
AddLinkerInputs(ToolChain, Inputs, Args, CmdArgs, JA);
235261

0 commit comments

Comments
 (0)