[PATCH] D97370: [clang][cli] Remove marshalling from Opt{In, Out}FFlag

2021-02-25 Thread Jan Svoboda via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGd8a8e5d6240a: [clang][cli] Remove marshalling from 
Opt{In,Out}FFlag (authored by jansvoboda11).

Changed prior to commit:
  https://reviews.llvm.org/D97370?vs=326028&id=326306#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D97370/new/

https://reviews.llvm.org/D97370

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Frontend/CompilerInvocation.cpp

Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -1383,9 +1383,6 @@
   GenerateArg(Args, OPT_ftime_report, SA);
   }
 
-  if (Opts.FunctionSections)
-GenerateArg(Args, OPT_ffunction_sections, SA);
-
   if (Opts.PrepareForLTO && !Opts.PrepareForThinLTO)
 GenerateArg(Args, OPT_flto, SA);
 
@@ -1676,9 +1673,6 @@
 }
   }
 
-  // Basic Block Sections implies Function Sections.
-  Opts.FunctionSections = Args.hasArg(OPT_ffunction_sections);
-
   Opts.PrepareForLTO = Args.hasArg(OPT_flto, OPT_flto_EQ);
   Opts.PrepareForThinLTO = false;
   if (Arg *A = Args.getLastArg(OPT_flto_EQ)) {
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -267,32 +267,26 @@
   : KeyPathAndMacro<"MigratorOpts.", base, "MIGRATOR_"> {}
 
 // A boolean option which is opt-in in CC1. The positive option exists in CC1 and
-// Args.hasArg(OPT_ffoo) is used to check that the flag is enabled.
+// Args.hasArg(OPT_ffoo) can be used to check that the flag is enabled.
 // This is useful if the option is usually disabled.
+// Use this only when the option cannot be declared via BoolFOption.
 multiclass OptInFFlag flags=[],
-  KeyPathAndMacro kpm = EmptyKPM,
-  list enablers = []> {
+  string help="", list flags=[]> {
   def f#NAME : Flag<["-"], "f"#name>, Flags,
-   Group, HelpText,
-   MarshallingInfoFlag,
-   ImpliedByAnyOf;
+   Group, HelpText;
   def fno_#NAME : Flag<["-"], "fno-"#name>, Flags,
-   Group, HelpText;
+  Group, HelpText;
 }
 
 // A boolean option which is opt-out in CC1. The negative option exists in CC1 and
-// Args.hasArg(OPT_fno_foo) is used to check that the flag is disabled.
+// Args.hasArg(OPT_fno_foo) can be used to check that the flag is disabled.
+// Use this only when the option cannot be declared via BoolFOption.
 multiclass OptOutFFlag flags=[],
-   KeyPathAndMacro kpm = EmptyKPM,
-   list disablers = []> {
+   string help="", list flags=[]> {
   def f#NAME : Flag<["-"], "f"#name>, Flags,
Group, HelpText;
   def fno_#NAME : Flag<["-"], "fno-"#name>, Flags,
-   Group, HelpText,
-   MarshallingInfoFlag,
-   ImpliedByAnyOf;
+  Group, HelpText;
 }
 
 //===--===//
@@ -891,9 +885,10 @@
   NegFlag>;
 def : Flag<["-"], "fcuda-rdc">, Alias;
 def : Flag<["-"], "fno-cuda-rdc">, Alias;
-defm cuda_short_ptr : OptInFFlag<"cuda-short-ptr",
-  "Use 32-bit pointers for accessing const/local/shared address spaces", "", "",
-  [], TargetOpts<"NVPTXUseShortPointers">>;
+defm cuda_short_ptr : BoolFOption<"cuda-short-ptr",
+  TargetOpts<"NVPTXUseShortPointers">, DefaultFalse,
+  PosFlag,
+  NegFlag>;
 def rocm_path_EQ : Joined<["--"], "rocm-path=">, Group,
   HelpText<"ROCm installation path, used for finding and automatically linking required bitcode libraries.">;
 def rocm_device_lib_path_EQ : Joined<["--"], "rocm-device-lib-path=">, Group,
@@ -1379,8 +1374,11 @@
   Values<"ignore,maytrap,strict">, NormalizedValuesScope<"LangOptions">,
   NormalizedValues<["FPE_Ignore", "FPE_MayTrap", "FPE_Strict"]>,
   MarshallingInfoEnum, "FPE_Ignore">;
-defm fast_math : OptInFFlag<"fast-math", "Allow aggressive, lossy floating-point optimizations", "", "", [],
-  LangOpts<"FastMath">, [cl_fast_relaxed_math.KeyPath]>;
+defm fast_math : BoolFOption<"fast-math",
+  LangOpts<"FastMath">, DefaultFalse,
+  PosFlag,
+  NegFlag>;
 def menable_unsafe_fp_math : Flag<["-"], "menable-unsafe-fp-math">, Flags<[CC1Option]>,
   HelpText<"Allow unsafe floating-point math optimizations which may decrease precision">,
   MarshallingInfoFlag>,
@@ -1397,7 +1395,10 @@
   CodeGenOpts<"NoUseJumpTables">, DefaultFalse,
   NegFlag, PosFlag,
   BothFlags<[], " jump tables for lowering switches">>;
-defm force_enable_int128 : OptInFFlag<"force-enable-int128", "Enable", "Disable", " support for int128_t type", [], TargetOpts<"ForceEnableInt128">>;
+defm force_enable_int128 : BoolFOption<"force-enable-int128",
+  TargetOpts<"ForceEnableInt

[clang] d8a8e5d - [clang][cli] Remove marshalling from Opt{In, Out}FFlag

2021-02-25 Thread Jan Svoboda via cfe-commits

Author: Jan Svoboda
Date: 2021-02-25T08:53:58+01:00
New Revision: d8a8e5d6240a1db809cd95106910358e69bbf299

URL: 
https://github.com/llvm/llvm-project/commit/d8a8e5d6240a1db809cd95106910358e69bbf299
DIFF: 
https://github.com/llvm/llvm-project/commit/d8a8e5d6240a1db809cd95106910358e69bbf299.diff

LOG: [clang][cli] Remove marshalling from Opt{In,Out}FFlag

We can now express all marshalling semantics in `Opt{In,Out}FFlag` via 
`BoolFOption`.

This patch moves remaining `Opt{In,Out}FFlag` instances using marshalling to 
`BoolFOption` and removes marshalling capabilities from `Opt{In,Out}FFlag` 
entirely.

This simplifies the decisions developers have to make when creating new boolean 
options:
  * For simple cc1 flag pairs, use `Bool{,F,G}Option`.
  * For cc1 flag pairs that require complex marshalling logic, use 
`Opt{In,Out}FFlag` and implement marshalling manually.

Reviewed By: dexonsmith

Differential Revision: https://reviews.llvm.org/D97370

Added: 


Modified: 
clang/include/clang/Driver/Options.td
clang/lib/Frontend/CompilerInvocation.cpp

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 57def483e6de..9fb353c36271 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -267,32 +267,26 @@ class MigratorOpts
   : KeyPathAndMacro<"MigratorOpts.", base, "MIGRATOR_"> {}
 
 // A boolean option which is opt-in in CC1. The positive option exists in CC1 
and
-// Args.hasArg(OPT_ffoo) is used to check that the flag is enabled.
+// Args.hasArg(OPT_ffoo) can be used to check that the flag is enabled.
 // This is useful if the option is usually disabled.
+// Use this only when the option cannot be declared via BoolFOption.
 multiclass OptInFFlag flags=[],
-  KeyPathAndMacro kpm = EmptyKPM,
-  list enablers = []> {
+  string help="", list flags=[]> {
   def f#NAME : Flag<["-"], "f"#name>, Flags,
-   Group, HelpText,
-   MarshallingInfoFlag,
-   ImpliedByAnyOf;
+   Group, HelpText;
   def fno_#NAME : Flag<["-"], "fno-"#name>, Flags,
-   Group, HelpText;
+  Group, HelpText;
 }
 
 // A boolean option which is opt-out in CC1. The negative option exists in CC1 
and
-// Args.hasArg(OPT_fno_foo) is used to check that the flag is disabled.
+// Args.hasArg(OPT_fno_foo) can be used to check that the flag is disabled.
+// Use this only when the option cannot be declared via BoolFOption.
 multiclass OptOutFFlag flags=[],
-   KeyPathAndMacro kpm = EmptyKPM,
-   list disablers = []> {
+   string help="", list flags=[]> {
   def f#NAME : Flag<["-"], "f"#name>, Flags,
Group, HelpText;
   def fno_#NAME : Flag<["-"], "fno-"#name>, Flags,
-   Group, HelpText,
-   MarshallingInfoFlag,
-   ImpliedByAnyOf;
+  Group, HelpText;
 }
 
 
//===--===//
@@ -891,9 +885,10 @@ defm gpu_rdc : BoolFOption<"gpu-rdc",
   NegFlag>;
 def : Flag<["-"], "fcuda-rdc">, Alias;
 def : Flag<["-"], "fno-cuda-rdc">, Alias;
-defm cuda_short_ptr : OptInFFlag<"cuda-short-ptr",
-  "Use 32-bit pointers for accessing const/local/shared address spaces", "", 
"",
-  [], TargetOpts<"NVPTXUseShortPointers">>;
+defm cuda_short_ptr : BoolFOption<"cuda-short-ptr",
+  TargetOpts<"NVPTXUseShortPointers">, DefaultFalse,
+  PosFlag,
+  NegFlag>;
 def rocm_path_EQ : Joined<["--"], "rocm-path=">, Group,
   HelpText<"ROCm installation path, used for finding and automatically linking 
required bitcode libraries.">;
 def rocm_device_lib_path_EQ : Joined<["--"], "rocm-device-lib-path=">, 
Group,
@@ -1379,8 +1374,11 @@ def ffp_exception_behavior_EQ : Joined<["-"], 
"ffp-exception-behavior=">, Group<
   Values<"ignore,maytrap,strict">, NormalizedValuesScope<"LangOptions">,
   NormalizedValues<["FPE_Ignore", "FPE_MayTrap", "FPE_Strict"]>,
   MarshallingInfoEnum, "FPE_Ignore">;
-defm fast_math : OptInFFlag<"fast-math", "Allow aggressive, lossy 
floating-point optimizations", "", "", [],
-  LangOpts<"FastMath">, [cl_fast_relaxed_math.KeyPath]>;
+defm fast_math : BoolFOption<"fast-math",
+  LangOpts<"FastMath">, DefaultFalse,
+  PosFlag,
+  NegFlag>;
 def menable_unsafe_fp_math : Flag<["-"], "menable-unsafe-fp-math">, 
Flags<[CC1Option]>,
   HelpText<"Allow unsafe floating-point math optimizations which may decrease 
precision">,
   MarshallingInfoFlag>,
@@ -1397,7 +1395,10 @@ defm jump_tables : BoolFOption<"jump-tables",
   CodeGenOpts<"NoUseJumpTables">, DefaultFalse,
   NegFlag, PosFlag,
   BothFlags<[], " jump tables for lowering switches">>;
-defm force_enable_int128 : OptInFFlag<"force-enable-int128", "Enable", 
"Disable", " support for int128_t type", [], Ta

[PATCH] D92244: [OpenCL] Prevent adding vendor extensions for all targets

2021-02-25 Thread Alexey Sotkin via Phabricator via cfe-commits
AlexeySotkin accepted this revision.
AlexeySotkin added a comment.
This revision is now accepted and ready to land.

LGTM, Thanks.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92244/new/

https://reviews.llvm.org/D92244

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


[PATCH] D96843: [Clang][RISCV] Add vsetvl and vsetvlmax.

2021-02-25 Thread Zakk Chen via Phabricator via cfe-commits
khchen updated this revision to Diff 326310.
khchen added a comment.

Rebase.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D96843/new/

https://reviews.llvm.org/D96843

Files:
  clang/include/clang/Basic/riscv_vector.td
  clang/lib/Basic/Targets/RISCV.cpp
  clang/test/CodeGen/RISCV/rvv-intrinsics/vsetvl.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vsetvlmax.c
  clang/utils/TableGen/RISCVVEmitter.cpp

Index: clang/utils/TableGen/RISCVVEmitter.cpp
===
--- clang/utils/TableGen/RISCVVEmitter.cpp
+++ clang/utils/TableGen/RISCVVEmitter.cpp
@@ -129,6 +129,9 @@
   bool HasMaskedOffOperand;
   bool HasVL;
   bool HasGeneric;
+  bool HasAutoDef;
+  bool HasManualCodegen;
+  std::string ManualCodegen;
   RVVTypePtr OutputType; // Builtin output type
   RVVTypes InputTypes;   // Builtin input types
   // The types we use to obtain the specific LLVM intrinsic. They are index of
@@ -143,8 +146,9 @@
   RVVIntrinsic(StringRef Name, StringRef Suffix, StringRef MangledName,
StringRef IRName, bool HasSideEffects, bool IsMask,
bool HasMaskedOffOperand, bool HasVL, bool HasGeneric,
+   bool HasAutoDef, bool HasManualCodegen, StringRef ManualCodegen,
const RVVTypes &Types,
-   const std::vector &RVVIntrinsicTypes);
+   const std::vector &IntrinsicTypes);
   ~RVVIntrinsic() = default;
 
   StringRef getName() const { return Name; }
@@ -153,6 +157,7 @@
   bool hasMaskedOffOperand() const { return HasMaskedOffOperand; }
   bool hasVL() const { return HasVL; }
   bool hasGeneric() const { return HasGeneric; }
+  bool hasAutoDef() const { return HasAutoDef; }
   size_t getNumOperand() const { return InputTypes.size(); }
   StringRef getIRName() const { return IRName; }
   uint8_t getRISCV_Extensions() const { return RISCV_Extensions; }
@@ -174,6 +179,7 @@
 class RVVEmitter {
 private:
   RecordKeeper &Records;
+  std::string HeaderCode;
   // Concat BasicType, LMUL and Proto as key
   StringMap LegalTypes;
   StringSet<> IllegalTypes;
@@ -603,11 +609,14 @@
StringRef NewMangledName, StringRef IRName,
bool HasSideEffects, bool IsMask,
bool HasMaskedOffOperand, bool HasVL,
-   bool HasGeneric, const RVVTypes &OutInTypes,
+   bool HasGeneric, bool HasAutoDef,
+   bool HasManualCodegen, StringRef ManualCodegen,
+   const RVVTypes &OutInTypes,
const std::vector &NewIntrinsicTypes)
 : IRName(IRName), HasSideEffects(HasSideEffects),
   HasMaskedOffOperand(HasMaskedOffOperand), HasVL(HasVL),
-  HasGeneric(HasGeneric) {
+  HasGeneric(HasGeneric), HasAutoDef(HasAutoDef),
+  HasManualCodegen(HasManualCodegen), ManualCodegen(ManualCodegen.str()) {
 
   // Init Name and MangledName
   Name = NewName.str();
@@ -670,6 +679,10 @@
 void RVVIntrinsic::emitCodeGenSwitchBody(raw_ostream &OS) const {
 
   OS << "  ID = Intrinsic::riscv_" + getIRName() + ";\n";
+  if (HasManualCodegen) {
+OS << ManualCodegen;
+return;
+  }
   OS << "  IntrinsicTypes = {";
   for (const auto &Idx : IntrinsicTypes) {
 if (Idx == -1)
@@ -759,6 +772,11 @@
   std::vector> Defs;
   createRVVIntrinsics(Defs);
 
+  // Print header code
+  if (HeaderCode.size()) {
+OS << HeaderCode;
+  }
+
   auto printType = [&](auto T) {
 OS << "typedef " << T->getClangBuiltinStr() << " " << T->getTypeStr()
<< ";\n";
@@ -880,7 +898,6 @@
 
 void RVVEmitter::createRVVIntrinsics(
 std::vector> &Out) {
-
   std::vector RV = Records.getAllDerivedDefinitions("RVVBuiltin");
   for (auto *R : RV) {
 StringRef Name = R->getValueAsString("Name");
@@ -894,11 +911,19 @@
 bool HasGeneric = R->getValueAsBit("HasGeneric");
 bool HasSideEffects = R->getValueAsBit("HasSideEffects");
 std::vector Log2LMULList = R->getValueAsListOfInts("Log2LMUL");
+bool HasManualCodegen = R->getValueAsBit("HasManualCodegen");
+StringRef ManualCodegen = R->getValueAsString("ManualCodegen");
+StringRef ManualCodegenMask = R->getValueAsString("ManualCodegenMask");
 std::vector IntrinsicTypes =
 R->getValueAsListOfInts("IntrinsicTypes");
 StringRef IRName = R->getValueAsString("IRName");
 StringRef IRNameMask = R->getValueAsString("IRNameMask");
 
+StringRef HeaderCodeStr = R->getValueAsString("HeaderCode");
+bool HasAutoDef = HeaderCodeStr.empty();
+if (HeaderCodeStr.size()) {
+  HeaderCode += HeaderCodeStr.str();
+}
 // Parse prototype and create a list of primitive type with transformers
 // (operand) in ProtoSeq. ProtoSeq[0] is output operand.
 SmallVector ProtoSeq;
@@ -925,7 +950,7 @@
   ProtoMaskSeq.push_back("z");
 }
 
-// Create intrinsics for each type and LMUL.
+// Create Intrinsics

[clang-tools-extra] b218f7c - [clangd] NFC, remove an extra "class" keyword.

2021-02-25 Thread Haojian Wu via cfe-commits

Author: Haojian Wu
Date: 2021-02-25T09:32:36+01:00
New Revision: b218f7c4baada3d22bf22bd3ca6e849bb2ce9289

URL: 
https://github.com/llvm/llvm-project/commit/b218f7c4baada3d22bf22bd3ca6e849bb2ce9289
DIFF: 
https://github.com/llvm/llvm-project/commit/b218f7c4baada3d22bf22bd3ca6e849bb2ce9289.diff

LOG: [clangd] NFC, remove an extra "class" keyword.

Added: 


Modified: 
clang-tools-extra/clangd/ClangdLSPServer.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/ClangdLSPServer.cpp 
b/clang-tools-extra/clangd/ClangdLSPServer.cpp
index d29014f3e7ca..f2ec8189b92c 100644
--- a/clang-tools-extra/clangd/ClangdLSPServer.cpp
+++ b/clang-tools-extra/clangd/ClangdLSPServer.cpp
@@ -1431,7 +1431,7 @@ void ClangdLSPServer::onAST(const ASTParams &Params,
   Server->getAST(Params.textDocument.uri.file(), Params.range, std::move(CB));
 }
 
-ClangdLSPServer::ClangdLSPServer(class Transport &Transp,
+ClangdLSPServer::ClangdLSPServer(Transport &Transp,
  const ThreadsafeFS &TFS,
  const ClangdLSPServer::Options &Opts)
 : ShouldProfile(/*Period=*/std::chrono::minutes(5),



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


[PATCH] D97138: [clang][flang] Improve the consistency of the code-base

2021-02-25 Thread Shao-Ce Sun via Phabricator via cfe-commits
achieveartificialintelligence updated this revision to Diff 326313.
achieveartificialintelligence edited the summary of this revision.

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D97138/new/

https://reviews.llvm.org/D97138

Files:
  clang/tools/driver/driver.cpp
  flang/tools/flang-driver/driver.cpp

Index: flang/tools/flang-driver/driver.cpp
===
--- flang/tools/flang-driver/driver.cpp
+++ flang/tools/flang-driver/driver.cpp
@@ -66,27 +66,27 @@
   return 1;
 }
 
-int main(int argc_, const char **argv_) {
+int main(int argc, const char **argv) {
 
   // Initialize variables to call the driver
-  llvm::InitLLVM x(argc_, argv_);
-  llvm::SmallVector argv(argv_, argv_ + argc_);
+  llvm::InitLLVM x(argc, argv);
+  llvm::SmallVector args(argv, argv + argc);
 
   clang::driver::ParsedClangName targetandMode("flang", "--driver-mode=flang");
-  std::string driverPath = GetExecutablePath(argv[0]);
+  std::string driverPath = GetExecutablePath(args[0]);
 
   // Check if flang-new is in the frontend mode
   auto firstArg = std::find_if(
-  argv.begin() + 1, argv.end(), [](const char *a) { return a != nullptr; });
-  if (firstArg != argv.end()) {
-if (llvm::StringRef(argv[1]).startswith("-cc1")) {
-  llvm::errs() << "error: unknown integrated tool '" << argv[1] << "'. "
+  args.begin() + 1, args.end(), [](const char *a) { return a != nullptr; });
+  if (firstArg != args.end()) {
+if (llvm::StringRef(args[1]).startswith("-cc1")) {
+  llvm::errs() << "error: unknown integrated tool '" << args[1] << "'. "
<< "Valid tools include '-fc1'.\n";
   return 1;
 }
 // Call flang-new frontend
-if (llvm::StringRef(argv[1]).startswith("-fc1")) {
-  return ExecuteFC1Tool(argv);
+if (llvm::StringRef(args[1]).startswith("-fc1")) {
+  return ExecuteFC1Tool(args);
 }
   }
 
@@ -94,14 +94,14 @@
 
   // Create DiagnosticsEngine for the compiler driver
   llvm::IntrusiveRefCntPtr diagOpts =
-  CreateAndPopulateDiagOpts(argv);
+  CreateAndPopulateDiagOpts(args);
   llvm::IntrusiveRefCntPtr diagID(
   new clang::DiagnosticIDs());
   Fortran::frontend::TextDiagnosticPrinter *diagClient =
   new Fortran::frontend::TextDiagnosticPrinter(llvm::errs(), &*diagOpts);
 
   diagClient->set_prefix(
-  std::string(llvm::sys::path::stem(GetExecutablePath(argv[0];
+  std::string(llvm::sys::path::stem(GetExecutablePath(args[0];
 
   clang::DiagnosticsEngine diags(diagID, &*diagOpts, diagClient);
 
@@ -110,7 +110,7 @@
   llvm::sys::getDefaultTargetTriple(), diags, "flang LLVM compiler");
   theDriver.setTargetAndMode(targetandMode);
   std::unique_ptr c(
-  theDriver.BuildCompilation(argv));
+  theDriver.BuildCompilation(args));
   llvm::SmallVector, 4>
   failingCommands;
 
Index: clang/tools/driver/driver.cpp
===
--- clang/tools/driver/driver.cpp
+++ clang/tools/driver/driver.cpp
@@ -340,25 +340,25 @@
   return 1;
 }
 
-int main(int argc_, const char **argv_) {
+int main(int Argc, const char **Argv) {
   noteBottomOfStack();
-  llvm::InitLLVM X(argc_, argv_);
+  llvm::InitLLVM X(Argc, Argv);
   llvm::setBugReportMsg("PLEASE submit a bug report to " BUG_REPORT_URL
 " and include the crash backtrace, preprocessed "
 "source, and associated run script.\n");
-  SmallVector argv(argv_, argv_ + argc_);
+  SmallVector Args(Argv, Argv + Argc);
 
   if (llvm::sys::Process::FixupStandardFileDescriptors())
 return 1;
 
   llvm::InitializeAllTargets();
-  auto TargetAndMode = ToolChain::getTargetAndModeFromProgramName(argv[0]);
+  auto TargetAndMode = ToolChain::getTargetAndModeFromProgramName(Args[0]);
 
   llvm::BumpPtrAllocator A;
   llvm::StringSaver Saver(A);
 
   // Parse response files using the GNU syntax, unless we're in CL mode. There
-  // are two ways to put clang in CL compatibility mode: argv[0] is either
+  // are two ways to put clang in CL compatibility mode: Args[0] is either
   // clang-cl or cl, or --driver-mode=cl is on the command line. The normal
   // command line parsing can't happen until after response file parsing, so we
   // have to manually search for a --driver-mode=cl argument the hard way.
@@ -366,20 +366,20 @@
   // response files written by clang will tokenize the same way in either mode.
   bool ClangCLMode = false;
   if (StringRef(TargetAndMode.DriverMode).equals("--driver-mode=cl") ||
-  llvm::find_if(argv, [](const char *F) {
+  llvm::find_if(Args, [](const char *F) {
 return F && strcmp(F, "--driver-mode=cl") == 0;
-  }) != argv.end()) {
+  }) != Args.end()) {
 ClangCLMode = true;
   }
   enum { Default, POSIX, Windows } RSPQuoting = Default;
-  for (const char *F : argv) {
+  for (const char *F : Args) {
 if (strcmp(F, "--rsp-quoting=posix") == 0)
   RSPQuoting = POSIX;
 else 

[PATCH] D97138: [clang][flang] Improve the consistency of the code-base

2021-02-25 Thread Shao-Ce Sun via Phabricator via cfe-commits
achieveartificialintelligence marked an inline comment as done.
achieveartificialintelligence added a comment.

Thanks @aganea. And I have a question that, should I use `argc` & `argv` or 
`argC` & `argV` in the flang part now ?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D97138/new/

https://reviews.llvm.org/D97138

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


[PATCH] D97052: [OpenCL] Prevent adding extension pragma by default

2021-02-25 Thread Anton Zabaznov via Phabricator via cfe-commits
azabaznov added inline comments.



Comment at: clang/include/clang/Basic/OpenCLExtensions.def:71
+OPENCL_EXTENSION(cl_khr_int64_extended_atomics, true, 100)
+OPENCL_COREFEATURE(cl_khr_3d_image_writes, true, 100, OCL_C_20)
 

Anastasia wrote:
> azabaznov wrote:
> > Anastasia wrote:
> > > azabaznov wrote:
> > > > I think core and optional core features do not require pragma too. So 
> > > > for example 3d image writes or fp64 do not require pragma in OpenCL C 
> > > > 2.0. Isn't that so?
> > > Well to be honest nothing seems to need pragma but we have to accept it 
> > > for the backward compatibility. :)
> > > 
> > > In case of the core features if pragma would have been useful we would 
> > > have to still accept it for the backward compatibility even if the 
> > > feature became core.
> > I'm just wondering if this new field needed in the file to maintain 
> > backward compatibility. Maybe we can highlight OpenCL C 3.0 features with 
> > some other way? Is it seems that check for name starting with "__opencl_c" 
> > is a bad idea?
> Not sure I understand you here but I don't think that we should add extension 
> pragmas any longer at all even for the new extensions. FYI I am planning to 
> add guidelines for that in https://reviews.llvm.org/D97072. Maybe it helps to 
> clarify the idea?
I mean that you could modify `OpenCLOptions::isWithPragma` that it will check 
if extension/feature was introduced in OpenCL C 3.0. If that's the case then no 
pragma needed. This new field `pragma` looks redundant as it is set to true 
only for OpenCL C 3.0 features. However, it may be more cosmetic concern...



Comment at: clang/lib/Parse/ParsePragma.cpp:785
+  // Therefore, it should never be added by default.
+  Opt.acceptsPragma(Name);
 }

Anastasia wrote:
> azabaznov wrote:
> > Anastasia wrote:
> > > svenvh wrote:
> > > > I fail to understand why this is needed, so perhaps this needs a bit 
> > > > more explanation.  Extensions that should continue to support pragmas 
> > > > already have their `WithPragma` field set to `true` via 
> > > > `OpenCLExtensions.def`.  Why do we need to dynamically modify the field?
> > > It is a bit twisty here to be honest. Because we have also introduced the 
> > > pragma `begin` and `end` that would add pragma `enable`/`disable` by 
> > > default. So any extension added dynamically using `begin`/`end` would 
> > > have to accept the pragma `enable`/`disable`. 
> > > 
> > > https://clang.llvm.org/docs/UsersManual.html#opencl-extensions
> > > 
> > > But in the subsequent patches, I hope to remove this because I just don't 
> > > see where it is useful but it is very confusing.
> > Is it ok not to track this situation here:
> > 
> > ```
> > #pragma OPENCL EXTENSION __opencl_c_feature : begin
> > #pragma OPENCL EXTENSION __opencl_c_feature: end
> > ```
> > 
> > This is some of a corner case, but still...
> I see. I am not sure what should happen here - I guess we should give an 
> error? Although for earlier versions than OpenCL 3.0 this should probably be 
> accepted?
> 
> Perhaps we can create a PR for this for now...
Oh, I think we can ignore this as double underscored identifiers are reserved. 
It's not expected that users will declare new features.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D97052/new/

https://reviews.llvm.org/D97052

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


[PATCH] D97361: [clang-tidy] Add readability-redundant-using check

2021-02-25 Thread Yang Fan via Phabricator via cfe-commits
nullptr.cpp updated this revision to Diff 326320.
nullptr.cpp retitled this revision from "[clang-tidy] Add misc-redundant-using 
check" to "[clang-tidy] Add readability-redundant-using check".
nullptr.cpp added a comment.

Modify according to suggestions


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D97361/new/

https://reviews.llvm.org/D97361

Files:
  clang-tools-extra/clang-tidy/readability/CMakeLists.txt
  clang-tools-extra/clang-tidy/readability/ReadabilityTidyModule.cpp
  clang-tools-extra/clang-tidy/readability/RedundantUsingCheck.cpp
  clang-tools-extra/clang-tidy/readability/RedundantUsingCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  clang-tools-extra/docs/clang-tidy/checks/readability-redundant-using.rst
  clang-tools-extra/test/clang-tidy/checkers/readability-redundant-using.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/readability-redundant-using.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/readability-redundant-using.cpp
@@ -0,0 +1,114 @@
+// RUN: %check_clang_tidy %s readability-redundant-using %t
+
+namespace n1 {
+using namespace n1;
+// CHECK-MESSAGES: :[[@LINE-1]]:17: warning: using directive 'n1' is redundant, already in namespace 'n1' [readability-redundant-using]
+// CHECK-MESSAGES: :[[@LINE-2]]:17: note: remove the using directive
+// CHECK-FIXES: {{^}}
+} // namespace n1
+
+namespace n2 {
+using namespace n1; // ok
+}
+
+namespace n3 {
+namespace n = n3;
+using namespace n;
+// CHECK-MESSAGES: :[[@LINE-1]]:17: warning: using directive 'n' is redundant, already in namespace 'n3' [readability-redundant-using]
+// CHECK-MESSAGES: :[[@LINE-2]]:17: note: remove the using directive
+// CHECK-FIXES: {{^}}
+} // namespace n3
+
+namespace n4 {
+namespace inner {
+using namespace n4;
+// CHECK-MESSAGES: :[[@LINE-1]]:17: warning: using directive 'n4' is redundant, already in namespace 'n4' [readability-redundant-using]
+// CHECK-MESSAGES: :[[@LINE-2]]:17: note: remove the using directive
+// CHECK-FIXES: {{^}}
+
+using namespace n4::inner;
+// CHECK-MESSAGES: :[[@LINE-1]]:21: warning: using directive 'inner' is redundant, already in namespace 'inner' [readability-redundant-using]
+// CHECK-MESSAGES: :[[@LINE-2]]:21: note: remove the using directive
+// CHECK-FIXES: {{^}}
+
+namespace n = n4::inner;
+using namespace n;
+// CHECK-MESSAGES: :[[@LINE-1]]:17: warning: using directive 'n' is redundant, already in namespace 'inner' [readability-redundant-using]
+// CHECK-MESSAGES: :[[@LINE-2]]:17: note: remove the using directive
+// CHECK-FIXES: {{^}}
+} // namespace inner
+} // namespace n4
+
+namespace n5 {
+namespace inner {
+using namespace n4::inner; // ok
+}
+} // namespace n5
+
+namespace n6 {
+void func();
+
+using n6::func;
+// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: using declaration 'func' is redundant, already in namespace 'n6' [readability-redundant-using]
+// CHECK-MESSAGES: :[[@LINE-2]]:11: note: remove the using declaration
+// CHECK-FIXES: {{^}}
+} // namespace n6
+
+namespace n7 {
+using n6::func; // ok
+}
+
+namespace n8 {
+void func();
+
+namespace n = n8;
+using n::func;
+// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: using declaration 'func' is redundant, already in namespace 'n8' [readability-redundant-using]
+// CHECK-MESSAGES: :[[@LINE-2]]:10: note: remove the using declaration
+// CHECK-FIXES: {{^}}
+} // namespace n8
+
+namespace n9 {
+void outerFunc();
+
+namespace inner {
+using n9::outerFunc;
+// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: using declaration 'outerFunc' is redundant, already in namespace 'n9' [readability-redundant-using]
+// CHECK-MESSAGES: :[[@LINE-2]]:11: note: remove the using declaration
+// CHECK-FIXES: {{^}}
+
+void innerFunc();
+using inner::innerFunc;
+// CHECK-MESSAGES: :[[@LINE-1]]:14: warning: using declaration 'innerFunc' is redundant, already in namespace 'inner' [readability-redundant-using]
+// CHECK-MESSAGES: :[[@LINE-2]]:14: note: remove the using declaration
+// CHECK-FIXES: {{^}}
+
+using n9::inner::innerFunc;
+// CHECK-MESSAGES: :[[@LINE-1]]:18: warning: using declaration 'innerFunc' is redundant, already in namespace 'inner' [readability-redundant-using]
+// CHECK-MESSAGES: :[[@LINE-2]]:18: note: remove the using declaration
+// CHECK-FIXES: {{^}}
+
+namespace n = n9::inner;
+using n::innerFunc;
+// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: using declaration 'innerFunc' is redundant, already in namespace 'inner' [readability-redundant-using]
+// CHECK-MESSAGES: :[[@LINE-2]]:10: note: remove the using declaration
+// CHECK-FIXES: {{^}}
+} // namespace inner
+} // namespace n9
+
+namespace n10 {
+namespace inner {
+using n9::inner::innerFunc; // ok
+}
+} // namespace n10
+
+namespace n11 {
+void func();
+}
+
+namespace n11 {
+using n11::func;
+// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: using declaration 'func' is redundant, already in 

[PATCH] D97058: [OpenCL] Refactor diagnostic for OpenCL extension/feature

2021-02-25 Thread Anton Zabaznov via Phabricator via cfe-commits
azabaznov added a comment.

> FYI, I would even be ok if we remove the need for enabling non-core

AFAIU this can be done not for every extension to maintain backward 
compatibility. In this case I think https://reviews.llvm.org/D97052 can be 
useful.

Also, I imagine that implicit type definition is not  needed if no pragma 
required.




Comment at: clang/lib/Sema/Sema.cpp:360
 
 setOpenCLExtensionForType(Context.DoubleTy, "cl_khr_fp64");
 

Anastasia wrote:
> I think the same should apply to `double` not only `atomic_double`?
I think `double` is created in a place where it's not possible to guard it with 
OpenCL extensions support. I will double-check.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D97058/new/

https://reviews.llvm.org/D97058

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


[PATCH] D97052: [OpenCL] Prevent adding extension pragma by default

2021-02-25 Thread Anton Zabaznov via Phabricator via cfe-commits
azabaznov added a comment.

I see the update regaring this functionality on github issue: 
https://github.com/KhronosGroup/OpenCL-Docs/issues/82#issuecomment-785496025. 
Is it a right way to reflect this information in`OpenCLExtensions.def`?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D97052/new/

https://reviews.llvm.org/D97052

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


[PATCH] D97137: Bug fix of clang-format, the AlignConsecutiveDeclarations option doesn't handle pointer properly

2021-02-25 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks added a comment.

In D97137#2584417 , @darwin wrote:

> Hi guys, thanks for accepting the change. But I don't have commit access of 
> LLVM. Can someone commit it for me?

Can and will do. Need the name and email for the commit.

But I will wait a bit, if someone raises a concern.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D97137/new/

https://reviews.llvm.org/D97137

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


[clang] a25e4a6 - [clang][cli] Store additional optimization remarks info

2021-02-25 Thread Jan Svoboda via cfe-commits

Author: Jan Svoboda
Date: 2021-02-25T11:02:49+01:00
New Revision: a25e4a6da3fe43f631782b1668e0ac023f6b5848

URL: 
https://github.com/llvm/llvm-project/commit/a25e4a6da3fe43f631782b1668e0ac023f6b5848
DIFF: 
https://github.com/llvm/llvm-project/commit/a25e4a6da3fe43f631782b1668e0ac023f6b5848.diff

LOG: [clang][cli] Store additional optimization remarks info

After a revision of D96274 changed `DiagnosticOptions` to not store all remark 
arguments **as-written**, it is no longer possible to reconstruct the arguments 
accurately from the class.

This is caused by the fact that for `-Rpass=regexp` and friends, 
`DiagnosticOptions` store only the group name `pass` and not `regexp`. This is 
the same representation used for the plain `-Rpass` argument.

Note that each argument must be generated exactly once in 
`CompilerInvocation::generateCC1CommandLine`, otherwise each subsequent call 
would produce more arguments than the previous one. Currently this works out 
because of the way `RoundTrip` splits the responsibilities for certain 
arguments based on what arguments were queried during parsing. However, this 
invariant breaks when we move to single round-trip for the whole 
`CompilerInvocation`.

This patch ensures that for one `-Rpass=regexp` argument, we don't generate two 
arguments (`-Rpass` from `DiagnosticOptions` and `-Rpass=regexp` from 
`CodeGenOptions`) by shifting the responsibility for handling both cases to 
`CodeGenOptions`. To distinguish between the cases correctly, additional 
information is stored in `CodeGenOptions`.

The `CodeGenOptions` parser of `-Rpass[=regexp]` arguments also looks at 
`-Rno-pass` and `-R[no-]everything`, which is necessary for generating the 
correct argument regardless of the ordering of 
`CodeGenOptions`/`DiagnosticOptions` parsing/generation.

Reviewed By: dexonsmith

Differential Revision: https://reviews.llvm.org/D96847

Added: 


Modified: 
clang/include/clang/Basic/CodeGenOptions.h
clang/lib/CodeGen/CodeGenAction.cpp
clang/lib/Frontend/CompilerInvocation.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/CodeGenOptions.h 
b/clang/include/clang/Basic/CodeGenOptions.h
index bf260c444b2e..878d55402e32 100644
--- a/clang/include/clang/Basic/CodeGenOptions.h
+++ b/clang/include/clang/Basic/CodeGenOptions.h
@@ -287,37 +287,52 @@ class CodeGenOptions : public CodeGenOptionsBase {
   /// -fsymbol-partition (see https://lld.llvm.org/Partitions.html).
   std::string SymbolPartition;
 
-  /// Regular expression and the string it was created from.
-  struct RemarkPattern {
+  enum RemarkKind {
+RK_Missing,// Remark argument not present on the command line.
+RK_Enabled,// Remark enabled via '-Rgroup'.
+RK_EnabledEverything,  // Remark enabled via '-Reverything'.
+RK_Disabled,   // Remark disabled via '-Rno-group'.
+RK_DisabledEverything, // Remark disabled via '-Rno-everything'.
+RK_WithPattern,// Remark pattern specified via '-Rgroup=regexp'.
+  };
+
+  /// Optimization remark with an optional regular expression pattern.
+  struct OptRemark {
+RemarkKind Kind;
 std::string Pattern;
 std::shared_ptr Regex;
 
-explicit operator bool() const { return Regex != nullptr; }
+/// By default, optimization remark is missing.
+OptRemark() : Kind(RK_Missing), Pattern(""), Regex(nullptr) {}
+
+/// Returns true iff the optimization remark holds a valid regular
+/// expression.
+bool hasValidPattern() const { return Regex != nullptr; }
 
-llvm::Regex *operator->() const { return Regex.get(); }
+/// Matches the given string against the regex, if there is some.
+bool patternMatches(StringRef String) const {
+  return hasValidPattern() && Regex->match(String);
+}
   };
 
-  /// Regular expression to select optimizations for which we should enable
-  /// optimization remarks. Transformation passes whose name matches this
-  /// expression (and support this feature), will emit a diagnostic
-  /// whenever they perform a transformation. This is enabled by the
-  /// -Rpass=regexp flag.
-  RemarkPattern OptimizationRemarkPattern;
-
-  /// Regular expression to select optimizations for which we should enable
-  /// missed optimization remarks. Transformation passes whose name matches 
this
-  /// expression (and support this feature), will emit a diagnostic
-  /// whenever they tried but failed to perform a transformation. This is
-  /// enabled by the -Rpass-missed=regexp flag.
-  RemarkPattern OptimizationRemarkMissedPattern;
-
-  /// Regular expression to select optimizations for which we should enable
-  /// optimization analyses. Transformation passes whose name matches this
-  /// expression (and support this feature), will emit a diagnostic
-  /// whenever they want to explain why they decided to apply or not apply
-  /// a given transformation. This is enabled by t

[clang] d748908 - [clang][cli] Round-trip the whole CompilerInvocation

2021-02-25 Thread Jan Svoboda via cfe-commits

Author: Jan Svoboda
Date: 2021-02-25T11:02:49+01:00
New Revision: d748908fa02b11c7840a7f03c7a52223126bdba9

URL: 
https://github.com/llvm/llvm-project/commit/d748908fa02b11c7840a7f03c7a52223126bdba9
DIFF: 
https://github.com/llvm/llvm-project/commit/d748908fa02b11c7840a7f03c7a52223126bdba9.diff

LOG: [clang][cli] Round-trip the whole CompilerInvocation

Finally, this patch moves from round-tripping one `CompilerInvocation` at a 
time to round-tripping the invocation as a whole.

This patch includes only the code required to make round-tripping the whole 
invocation work. More cleanups will be done in a follow-up patch.

Depends on D96847, D97041 & D97042.

Reviewed By: dexonsmith

Differential Revision: https://reviews.llvm.org/D96280

Added: 


Modified: 
clang/include/clang/Basic/DiagnosticDriverKinds.td
clang/include/clang/Frontend/CompilerInvocation.h
clang/lib/Frontend/CompilerInvocation.cpp
clang/test/Frontend/round-trip-cc1-args.c

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticDriverKinds.td 
b/clang/include/clang/Basic/DiagnosticDriverKinds.td
index 2440240608fd..6f50774d8f1c 100644
--- a/clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ b/clang/include/clang/Basic/DiagnosticDriverKinds.td
@@ -532,10 +532,10 @@ def err_drv_invalid_object_mode : Error<"OBJECT_MODE 
setting %0 is not recognize
 def err_aix_default_altivec_abi : Error<
   "The default Altivec ABI on AIX is not yet supported, use '-mabi=vec-extabi' 
for the extended Altivec ABI">;
 
-def note_cc1_round_trip_original : Note<"Original arguments in %0 round-trip: 
%1">;
-def note_cc1_round_trip_generated : Note<"Generated arguments #%1 in %0 
round-trip: %2">;
-def remark_cc1_round_trip_generated : Remark<"Generated arguments #%1 in %0 
round-trip: %2">, InGroup;
-def err_cc1_round_trip_fail_then_ok : Error<"Original arguments parse failed, 
then succeeded in %0 round-trip">;
-def err_cc1_round_trip_ok_then_fail : Error<"Generated arguments parse failed 
in %0 round-trip">;
-def err_cc1_round_trip_mismatch : Error<"Generated arguments do not match in 
%0 round-trip">;
+def note_cc1_round_trip_original : Note<"Original arguments in round-trip: 
%0">;
+def note_cc1_round_trip_generated : Note<"Generated arguments #%0 in 
round-trip: %1">;
+def remark_cc1_round_trip_generated : Remark<"Generated arguments #%0 in 
round-trip: %1">, InGroup;
+def err_cc1_round_trip_fail_then_ok : Error<"Original arguments parse failed, 
then succeeded in round-trip">;
+def err_cc1_round_trip_ok_then_fail : Error<"Generated arguments parse failed 
in round-trip">;
+def err_cc1_round_trip_mismatch : Error<"Generated arguments do not match in 
round-trip">;
 }

diff  --git a/clang/include/clang/Frontend/CompilerInvocation.h 
b/clang/include/clang/Frontend/CompilerInvocation.h
index 0ecb586bcf8c..cd3780d9f454 100644
--- a/clang/include/clang/Frontend/CompilerInvocation.h
+++ b/clang/include/clang/Frontend/CompilerInvocation.h
@@ -239,6 +239,10 @@ class CompilerInvocation : public CompilerInvocationBase {
   /// @}
 
 private:
+  static bool CreateFromArgsImpl(CompilerInvocation &Res,
+ ArrayRef CommandLineArgs,
+ DiagnosticsEngine &Diags, const char *Argv0);
+
   /// Parse command line options from DiagnosticOptions.
   static bool ParseDiagnosticArgsRoundTrip(CompilerInvocation &Res,
DiagnosticOptions &Opts,

diff  --git a/clang/lib/Frontend/CompilerInvocation.cpp 
b/clang/lib/Frontend/CompilerInvocation.cpp
index 20ac5109084f..828e9c9cc6fc 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -423,9 +423,11 @@ static T extractMaskValue(T KeyPath) {
 
 static const StringRef GetInputKindName(InputKind IK);
 
-static void FixupInvocation(CompilerInvocation &Invocation,
-DiagnosticsEngine &Diags, const InputArgList &Args,
+static bool FixupInvocation(CompilerInvocation &Invocation,
+DiagnosticsEngine &Diags, const ArgList &Args,
 InputKind IK) {
+  unsigned NumErrorsBefore = Diags.getNumErrors();
+
   LangOptions &LangOpts = *Invocation.getLangOpts();
   CodeGenOptions &CodeGenOpts = Invocation.getCodeGenOpts();
   TargetOptions &TargetOpts = Invocation.getTargetOpts();
@@ -502,6 +504,8 @@ static void FixupInvocation(CompilerInvocation &Invocation,
 Diags.Report(diag::err_drv_argument_only_allowed_with)
 << Args.getLastArg(OPT_fprofile_remapping_file_EQ)->getAsString(Args)
 << "-fno-legacy-pass-manager";
+
+  return Diags.getNumErrors() == NumErrorsBefore;
 }
 
 
//===--===//
@@ -569,27 +573,29 @@ static void GenerateArg(SmallVectorImpl 
&Args,
 Opt.getKind(), 0, Value);
 }
 
-// Parse subset o

[PATCH] D96847: [clang][cli] Store additional optimization remarks info

2021-02-25 Thread Jan Svoboda via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa25e4a6da3fe: [clang][cli] Store additional optimization 
remarks info (authored by jansvoboda11).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D96847/new/

https://reviews.llvm.org/D96847

Files:
  clang/include/clang/Basic/CodeGenOptions.h
  clang/lib/CodeGen/CodeGenAction.cpp
  clang/lib/Frontend/CompilerInvocation.cpp

Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -1162,20 +1162,69 @@
<< "a filename";
 }
 
-/// Create a new Regex instance out of the string value in \p RpassArg.
-/// It returns the string and a pointer to the newly generated Regex instance.
-static CodeGenOptions::RemarkPattern
-GenerateOptimizationRemarkRegex(DiagnosticsEngine &Diags, ArgList &Args,
-Arg *RpassArg) {
-  StringRef Val = RpassArg->getValue();
-  std::string RegexError;
-  std::shared_ptr Pattern = std::make_shared(Val);
-  if (!Pattern->isValid(RegexError)) {
-Diags.Report(diag::err_drv_optimization_remark_pattern)
-<< RegexError << RpassArg->getAsString(Args);
-Pattern.reset();
-  }
-  return {std::string(Val), Pattern};
+/// Generate a remark argument. This is an inverse of `ParseOptimizationRemark`.
+static void
+GenerateOptimizationRemark(SmallVectorImpl &Args,
+   CompilerInvocation::StringAllocator SA,
+   OptSpecifier OptEQ, StringRef Name,
+   const CodeGenOptions::OptRemark &Remark) {
+  if (Remark.hasValidPattern()) {
+GenerateArg(Args, OptEQ, Remark.Pattern, SA);
+  } else if (Remark.Kind == CodeGenOptions::RK_Enabled) {
+GenerateArg(Args, OPT_R_Joined, Name, SA);
+  } else if (Remark.Kind == CodeGenOptions::RK_Disabled) {
+GenerateArg(Args, OPT_R_Joined, StringRef("no-") + Name, SA);
+  }
+};
+
+/// Parse a remark command line argument. It may be missing, disabled/enabled by
+/// '-R[no-]group' or specified with a regular expression by '-Rgroup=regexp'.
+/// On top of that, it can be disabled/enabled globally by '-R[no-]everything'.
+static CodeGenOptions::OptRemark
+ParseOptimizationRemark(DiagnosticsEngine &Diags, ArgList &Args,
+OptSpecifier OptEQ, StringRef Name) {
+  CodeGenOptions::OptRemark Result;
+
+  auto InitializeResultPattern = [&Diags, &Args, &Result](const Arg *A) {
+Result.Pattern = A->getValue();
+
+std::string RegexError;
+Result.Regex = std::make_shared(Result.Pattern);
+if (!Result.Regex->isValid(RegexError)) {
+  Diags.Report(diag::err_drv_optimization_remark_pattern)
+  << RegexError << A->getAsString(Args);
+  return false;
+}
+
+return true;
+  };
+
+  for (Arg *A : Args) {
+if (A->getOption().matches(OPT_R_Joined)) {
+  StringRef Value = A->getValue();
+
+  if (Value == Name)
+Result.Kind = CodeGenOptions::RK_Enabled;
+  else if (Value == "everything")
+Result.Kind = CodeGenOptions::RK_EnabledEverything;
+  else if (Value.split('-') == std::make_pair(StringRef("no"), Name))
+Result.Kind = CodeGenOptions::RK_Disabled;
+  else if (Value == "no-everything")
+Result.Kind = CodeGenOptions::RK_DisabledEverything;
+} else if (A->getOption().matches(OptEQ)) {
+  Result.Kind = CodeGenOptions::RK_WithPattern;
+  if (!InitializeResultPattern(A))
+return CodeGenOptions::OptRemark();
+}
+  }
+
+  if (Result.Kind == CodeGenOptions::RK_Disabled ||
+  Result.Kind == CodeGenOptions::RK_DisabledEverything) {
+Result.Pattern = "";
+Result.Regex = nullptr;
+  }
+
+  return Result;
 }
 
 static bool parseDiagnosticLevelMask(StringRef FlagName,
@@ -1480,16 +1529,14 @@
   if (!Opts.OptRecordFormat.empty())
 GenerateArg(Args, OPT_opt_record_format, Opts.OptRecordFormat, SA);
 
-  if (Opts.OptimizationRemarkPattern)
-GenerateArg(Args, OPT_Rpass_EQ, Opts.OptimizationRemarkPattern.Pattern, SA);
+  GenerateOptimizationRemark(Args, SA, OPT_Rpass_EQ, "pass",
+ Opts.OptimizationRemark);
 
-  if (Opts.OptimizationRemarkMissedPattern)
-GenerateArg(Args, OPT_Rpass_missed_EQ,
-Opts.OptimizationRemarkMissedPattern.Pattern, SA);
+  GenerateOptimizationRemark(Args, SA, OPT_Rpass_missed_EQ, "pass-missed",
+ Opts.OptimizationRemarkMissed);
 
-  if (Opts.OptimizationRemarkAnalysisPattern)
-GenerateArg(Args, OPT_Rpass_analysis_EQ,
-Opts.OptimizationRemarkAnalysisPattern.Pattern, SA);
+  GenerateOptimizationRemark(Args, SA, OPT_Rpass_analysis_EQ, "pass-analysis",
+ Opts.OptimizationRemarkAnalysis);
 

[PATCH] D96280: [clang][cli] Round-trip the whole CompilerInvocation

2021-02-25 Thread Jan Svoboda via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGd748908fa02b: [clang][cli] Round-trip the whole 
CompilerInvocation (authored by jansvoboda11).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D96280/new/

https://reviews.llvm.org/D96280

Files:
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/include/clang/Frontend/CompilerInvocation.h
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/Frontend/round-trip-cc1-args.c

Index: clang/test/Frontend/round-trip-cc1-args.c
===
--- clang/test/Frontend/round-trip-cc1-args.c
+++ clang/test/Frontend/round-trip-cc1-args.c
@@ -4,4 +4,4 @@
 
 // CHECK-WITHOUT-ROUND-TRIP-NOT: remark:
 // CHECK-ROUND-TRIP-WITHOUT-REMARKS-NOT: remark:
-// CHECK-ROUND-TRIP-WITH-REMARKS: remark: Generated arguments {{.*}} in {{.*}} round-trip: {{.*}}
+// CHECK-ROUND-TRIP-WITH-REMARKS: remark: Generated arguments #{{.*}} in round-trip: {{.*}}
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -423,9 +423,11 @@
 
 static const StringRef GetInputKindName(InputKind IK);
 
-static void FixupInvocation(CompilerInvocation &Invocation,
-DiagnosticsEngine &Diags, const InputArgList &Args,
+static bool FixupInvocation(CompilerInvocation &Invocation,
+DiagnosticsEngine &Diags, const ArgList &Args,
 InputKind IK) {
+  unsigned NumErrorsBefore = Diags.getNumErrors();
+
   LangOptions &LangOpts = *Invocation.getLangOpts();
   CodeGenOptions &CodeGenOpts = Invocation.getCodeGenOpts();
   TargetOptions &TargetOpts = Invocation.getTargetOpts();
@@ -502,6 +504,8 @@
 Diags.Report(diag::err_drv_argument_only_allowed_with)
 << Args.getLastArg(OPT_fprofile_remapping_file_EQ)->getAsString(Args)
 << "-fno-legacy-pass-manager";
+
+  return Diags.getNumErrors() == NumErrorsBefore;
 }
 
 //===--===//
@@ -569,27 +573,29 @@
 Opt.getKind(), 0, Value);
 }
 
-// Parse subset of command line arguments into a member of CompilerInvocation.
-using ParseFn = llvm::function_ref;
+// Parse command line arguments into CompilerInvocation.
+using ParseFn =
+llvm::function_ref,
+DiagnosticsEngine &, const char *)>;
 
-// Generate part of command line arguments from a member of CompilerInvocation.
+// Generate command line arguments from CompilerInvocation.
 using GenerateFn = llvm::function_ref &,
 CompilerInvocation::StringAllocator)>;
 
-// Swap between dummy/real instance of a CompilerInvocation member.
-using SwapOptsFn = llvm::function_ref;
-
-// Performs round-trip of command line arguments if OriginalArgs contain
-// "-round-trip-args". Effectively runs the Parse function for a part of
-// CompilerInvocation on command line arguments that were already once parsed
-// and generated. This is used to check the Generate function produces arguments
-// that are semantically equivalent to those that were used to create
-// CompilerInvocation.
-static bool RoundTrip(ParseFn Parse, GenerateFn Generate, SwapOptsFn SwapOpts,
-  CompilerInvocation &Res, ArgList &OriginalArgs,
-  DiagnosticsEngine &Diags, StringRef OptsName) {
+// May perform round-trip of command line arguments. By default, the round-trip
+// is enabled if CLANG_ROUND_TRIP_CC1_ARGS was defined during build. This can be
+// overwritten at run-time via the "-round-trip-args" and "-no-round-trip-args"
+// command line flags.
+// During round-trip, the command line arguments are parsed into a dummy
+// instance of CompilerInvocation which is used to generate the command line
+// arguments again. The real CompilerInvocation instance is then created by
+// parsing the generated arguments, not the original ones.
+static bool RoundTrip(ParseFn Parse, GenerateFn Generate,
+  CompilerInvocation &RealInvocation,
+  CompilerInvocation &DummyInvocation,
+  ArrayRef CommandLineArgs,
+  DiagnosticsEngine &Diags, const char *Argv0) {
   // FIXME: Switch to '#ifndef NDEBUG' when possible.
 #ifdef CLANG_ROUND_TRIP_CC1_ARGS
   bool DoRoundTripDefault = true;
@@ -597,16 +603,21 @@
   bool DoRoundTripDefault = false;
 #endif
 
-  bool DoRoundTrip = OriginalArgs.hasFlag(
-  OPT_round_trip_args, OPT_no_round_trip_args, DoRoundTripDefault);
+  bool DoRoundTrip = DoRoundTripDefault;
+  for (const auto *Arg : CommandLineArgs) {
+if (Arg == StringRef("-round-trip-args"))
+  DoRoundTrip = true;
+if (Arg == StringRef("-no-round-trip-args"))
+  DoRoundTrip = false;
+  }
 
-  // If round-trip was not requested, sim

[PATCH] D95246: [test] Use host platform specific error message substitution in lit tests

2021-02-25 Thread James Henderson via Phabricator via cfe-commits
jhenderson added a comment.

@ASDenysPetrov, if you run "ninja -v llvm-ar", what is the output of the line 
that actually builds the llvm-ar executable? That'll tell us which libraries 
are in use, which should hopefully point to the difference to our own 
environments. For example, the last line of output for this on my Linux machine 
is:

  [811/811] : && /usr/bin/c++ -fPIC -fvisibility-inlines-hidden 
-Werror=date-time -Wall -Wextra -Wno-unused-parameter -Wwrite-strings 
-Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long 
-Wimplicit-fallthrough -Wno-maybe-uninitialized -Wno-noexcept-type 
-Wdelete-non-virtual-dtor -Wno-comment -fdiagnostics-color -ffunction-sections 
-fdata-sections -O3 
-Wl,-rpath-link,/home/binutils/llvm/llvm-project/build/./lib  -Wl,-O3 
-Wl,--gc-sections tools/llvm-ar/CMakeFiles/llvm-ar.dir/llvm-ar.cpp.o -o 
bin/llvm-ar  -Wl,-rpath,"\$ORIGIN/../lib"  lib/libLLVMAArch64AsmParser.a  
lib/libLLVMAMDGPUAsmParser.a  lib/libLLVMARMAsmParser.a  
lib/libLLVMAVRAsmParser.a  lib/libLLVMBPFAsmParser.a  
lib/libLLVMHexagonAsmParser.a  lib/libLLVMLanaiAsmParser.a  
lib/libLLVMMipsAsmParser.a  lib/libLLVMMSP430AsmParser.a  
lib/libLLVMPowerPCAsmParser.a  lib/libLLVMRISCVAsmParser.a  
lib/libLLVMSparcAsmParser.a  lib/libLLVMSystemZAsmParser.a  
lib/libLLVMWebAssemblyAsmParser.a  lib/libLLVMX86AsmParser.a  
lib/libLLVMAArch64Desc.a  lib/libLLVMAMDGPUDesc.a  lib/libLLVMARMDesc.a  
lib/libLLVMAVRDesc.a  lib/libLLVMBPFDesc.a  lib/libLLVMHexagonDesc.a  
lib/libLLVMLanaiDesc.a  lib/libLLVMMipsDesc.a  lib/libLLVMMSP430Desc.a  
lib/libLLVMNVPTXDesc.a  lib/libLLVMPowerPCDesc.a  lib/libLLVMRISCVDesc.a  
lib/libLLVMSparcDesc.a  lib/libLLVMSystemZDesc.a  lib/libLLVMWebAssemblyDesc.a  
lib/libLLVMX86Desc.a  lib/libLLVMXCoreDesc.a  lib/libLLVMAArch64Info.a  
lib/libLLVMAMDGPUInfo.a  lib/libLLVMARMInfo.a  lib/libLLVMAVRInfo.a  
lib/libLLVMBPFInfo.a  lib/libLLVMHexagonInfo.a  lib/libLLVMLanaiInfo.a  
lib/libLLVMMipsInfo.a  lib/libLLVMMSP430Info.a  lib/libLLVMNVPTXInfo.a  
lib/libLLVMPowerPCInfo.a  lib/libLLVMRISCVInfo.a  lib/libLLVMSparcInfo.a  
lib/libLLVMSystemZInfo.a  lib/libLLVMWebAssemblyInfo.a  lib/libLLVMX86Info.a  
lib/libLLVMXCoreInfo.a  lib/libLLVMBinaryFormat.a  lib/libLLVMCore.a  
lib/libLLVMDlltoolDriver.a  lib/libLLVMLibDriver.a  lib/libLLVMObject.a  
lib/libLLVMSupport.a  -lpthread  lib/libLLVMAArch64Utils.a  
lib/libLLVMAMDGPUUtils.a  lib/libLLVMARMUtils.a  lib/libLLVMMCDisassembler.a  
lib/libLLVMMCParser.a  lib/libLLVMMC.a  lib/libLLVMDebugInfoCodeView.a  
lib/libLLVMDebugInfoMSF.a  lib/libLLVMTextAPI.a  lib/libLLVMOption.a  
lib/libLLVMBitReader.a  lib/libLLVMCore.a  lib/libLLVMBinaryFormat.a  
lib/libLLVMRemarks.a  lib/libLLVMBitstreamReader.a  lib/libLLVMSupport.a  -lrt  
-ldl  -lpthread  -lm  /usr/lib/x86_64-linux-gnu/libz.so  
/usr/lib/x86_64-linux-gnu/libtinfo.so  lib/libLLVMDemangle.a && :

This shows, for example, that the `libz.so` my build uses is located in 
`/usr/lib/x86_64-linux-gnu`. By having your equivalent path, we can hopefully 
confirm that the issue is caused by a different set of system libraries being 
used.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D95246/new/

https://reviews.llvm.org/D95246

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


[PATCH] D95246: [test] Use host platform specific error message substitution in lit tests

2021-02-25 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov added a comment.

> This shows, for example, that the `libz.so` my build uses is located in 
> `/usr/lib/x86_64-linux-gnu`. By having your equivalent path, we can hopefully 
> confirm that the issue is caused by a different set of system libraries being 
> used.

Hi, @jhenderson
I changed `llvm-ar.cpp` then ran `ninja -v llvm-ar` and got this:

  [1/2] D:\WORK\Utilities\MSYS2\mingw64\bin\c++.exe -DGTEST_HAS_RTTI=0 -D_DEBUG 
-D_FILE_OFFSET_BITS=64 -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS 
-D__STDC_LIMIT_MACROS -Itools/llvm-ar 
-ID:/WORK/LLVM/llvm-project/llvm/tools/llvm-ar -Iinclude 
-ID:/WORK/LLVM/llvm-project/llvm/include -Wa,-mbig-obj -Werror=date-time -Wall 
-Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual 
-Wno-missing-field-initializers -pedantic -Wno-long-long -Wimplicit-fallthrough 
-Wno-maybe-uninitialized -Wno-class-memaccess -Wno-redundant-move 
-Wno-noexcept-type -Wdelete-non-virtual-dtor -Wsuggest-override -Wno-comment  
-O2   -fno-exceptions -fno-rtti -UNDEBUG -std=c++14 -MD -MT 
tools/llvm-ar/CMakeFiles/llvm-ar.dir/llvm-ar.cpp.obj -MF 
tools\llvm-ar\CMakeFiles\llvm-ar.dir\llvm-ar.cpp.obj.d -o 
tools/llvm-ar/CMakeFiles/llvm-ar.dir/llvm-ar.cpp.obj -c 
D:/WORK/LLVM/llvm-project/llvm/tools/llvm-ar/llvm-ar.cpp
  [2/2] cmd.exe /C "cd . && D:\WORK\Utilities\MSYS2\mingw64\bin\c++.exe 
-Wa,-mbig-obj -Werror=date-time -Wall -Wextra -Wno-unused-parameter 
-Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -pedantic 
-Wno-long-long -Wimplicit-fallthrough -Wno-maybe-uninitialized 
-Wno-class-memaccess -Wno-redundant-move -Wno-noexcept-type 
-Wdelete-non-virtual-dtor -Wsuggest-override -Wno-comment  -O2 
-Wl,--stack,16777216 tools/llvm-ar/CMakeFiles/llvm-ar.dir/llvm-ar.cpp.obj -o 
bin\llvm-ar.exe -Wl,--out-implib,lib\libllvm-ar.dll.a 
-Wl,--major-image-version,0,--minor-image-version,0  lib/libLLVMX86AsmParser.a  
lib/libLLVMX86Desc.a  lib/libLLVMX86Info.a  lib/libLLVMBinaryFormat.a  
lib/libLLVMCore.a  lib/libLLVMDlltoolDriver.a  lib/libLLVMLibDriver.a  
lib/libLLVMObject.a  lib/libLLVMSupport.a  lib/libLLVMMCDisassembler.a  
lib/libLLVMMCParser.a  lib/libLLVMMC.a  lib/libLLVMDebugInfoCodeView.a  
lib/libLLVMDebugInfoMSF.a  lib/libLLVMTextAPI.a  lib/libLLVMOption.a  
lib/libLLVMBitReader.a  lib/libLLVMCore.a  lib/libLLVMBinaryFormat.a  
lib/libLLVMRemarks.a  lib/libLLVMBitstreamReader.a  lib/libLLVMSupport.a  
-lpsapi  -lshell32  -lole32  -luuid  -ladvapi32  
D:/WORK/Utilities/MSYS2/mingw64/lib/libz.dll.a  lib/libLLVMDemangle.a  
-lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid 
-lcomdlg32 -ladvapi32 && cd ."

As you can `libz` is here `D:/WORK/Utilities/MSYS2/mingw64/lib/libz.dll.a`


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D95246/new/

https://reviews.llvm.org/D95246

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


[PATCH] D96976: [analyzer] Fix reinterpret_cast handling for pointer-to-member

2021-02-25 Thread Balázs Benics via Phabricator via cfe-commits
steakhal added a comment.

In D96976#2585498 , @RedDocMD wrote:

> @steakhal, could you please review this?

The longer I stare at it the more questions I have. However, I don't know how 
member pointers work in the analyzer and I'm not really in the mood to dive 
deep into that territory.

Could you elaborate on what approach did you choose and more importantly, why 
that approach?
Why do we need a graph search here?
What cases do you try to resolve? I mean, there is a single test-case, which 
has reinterpret casts back and forth (literally), and it's not immediately 
clear to me why are you doing those gymnastics.
Maybe worth creating other test-cases as well. Probably covering multiple 
inheritance or virtual inheritance?

Your code has shared pointers, which is interesting, but I would favor unique 
pointers unless you can defend this use-case.
Also, in general, we prefer algorithms to raw for or while loops if they are 
semantically equivalent.
Besides all of these, I can see a few copy-pasted lines here and there. I'm not 
saying that it's bad, I'm just highlighting this fact.

I can not confirm the implementation and accept the patch.
Improving the summary, helping reviewers with helpful notes here and there 
could give the boost you need to get this reviewed.
BTW, the review process takes ages in the analyzer community. We should also 
improve on that ofc, but the first step is always done by you (and here I mean 
not specifically you but we all).




Comment at: clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp:554-555
+}
+// Explicitly proceed with default handler for this case cascade.
+state = handleLVectorSplat(state, LCtx, CastE, Bldr, Pred);
+continue;

I know that you just copy-pasted this, but what is this xD



Comment at: clang/test/Analysis/reinterpret-cast-pointer-to-member.cpp:5
 
 // TODO: The following test will work properly once reinterpret_cast on 
pointer-to-member is handled properly
 namespace testReinterpretCasting {

I assume this is resolved by now.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D96976/new/

https://reviews.llvm.org/D96976

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


[PATCH] D97445: [clang][sema] Ignore xor-used-as-pow if both sides are macros

2021-02-25 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 added a comment.

No problem, +1


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D97445/new/

https://reviews.llvm.org/D97445

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


[clang] a54f160 - Prefer /usr/bin/env xxx over /usr/bin/xxx where xxx = perl, python, awk

2021-02-25 Thread Raphael Isemann via cfe-commits

Author: Harmen Stoppels
Date: 2021-02-25T11:32:27+01:00
New Revision: a54f160b3a98b91cd241a555d904a6b6453affc4

URL: 
https://github.com/llvm/llvm-project/commit/a54f160b3a98b91cd241a555d904a6b6453affc4
DIFF: 
https://github.com/llvm/llvm-project/commit/a54f160b3a98b91cd241a555d904a6b6453affc4.diff

LOG: Prefer /usr/bin/env xxx over /usr/bin/xxx where xxx = perl, python, awk

Allow users to use a non-system version of perl, python and awk, which is useful
in certain package managers.

Reviewed By: JDevlieghere, MaskRay

Differential Revision: https://reviews.llvm.org/D95119

Added: 


Modified: 
clang/test/make_test_dirs.pl
clang/tools/scan-build/bin/set-xcode-analyzer
clang/utils/TestUtils/pch-test.pl
clang/utils/analyzer/reducer.pl
clang/utils/analyzer/update_plist_test.pl
clang/www/demo/index.cgi
debuginfo-tests/llgdb-tests/test_debuginfo.pl
lldb/docs/use/python-reference.rst
lldb/scripts/disasm-gdb-remote.pl
llvm/utils/GenLibDeps.pl
llvm/utils/codegen-diff
llvm/utils/findsym.pl
llvm/utils/llvm-compilers-check
llvm/utils/llvm-native-gxx
openmp/runtime/tools/check-execstack.pl
openmp/runtime/tools/check-instruction-set.pl
openmp/runtime/tools/message-converter.pl
polly/lib/External/isl/doc/mypod2latex

Removed: 




diff  --git a/clang/test/make_test_dirs.pl b/clang/test/make_test_dirs.pl
index 3a524d2adb1b..c2af9c485f93 100755
--- a/clang/test/make_test_dirs.pl
+++ b/clang/test/make_test_dirs.pl
@@ -1,9 +1,10 @@
-#!/usr/bin/perl -w
+#!/usr/bin/env perl
 #
 # Simple little Perl script that takes the cxx-sections.data file as
 # input and generates a directory structure that mimics the standard's
 # structure.
 use English;
+use warnings;
 
 $current_indent_level = -4;
 while ($line = ) {

diff  --git a/clang/tools/scan-build/bin/set-xcode-analyzer 
b/clang/tools/scan-build/bin/set-xcode-analyzer
index 9faaec1e8e6e..f8c3f775ef7d 100755
--- a/clang/tools/scan-build/bin/set-xcode-analyzer
+++ b/clang/tools/scan-build/bin/set-xcode-analyzer
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/env python
 
 # [PR 11661] Note that we hardwire to /usr/bin/python because we
 # want to the use the system version of Python on Mac OS X.

diff  --git a/clang/utils/TestUtils/pch-test.pl 
b/clang/utils/TestUtils/pch-test.pl
index e4311e965bb7..cff8255b85a3 100755
--- a/clang/utils/TestUtils/pch-test.pl
+++ b/clang/utils/TestUtils/pch-test.pl
@@ -1,10 +1,11 @@
-#!/usr/bin/perl -w
+#!/usr/bin/env perl
 
 # This tiny little script, which should be run from the clang
 # directory (with clang in your patch), tries to take each
 # compilable Clang test and build a PCH file from that test, then read
 # and dump the contents of the PCH file just created.
 use POSIX;
+use warnings;
 
 $exitcode = 0;
 sub testfiles($$) {

diff  --git a/clang/utils/analyzer/reducer.pl b/clang/utils/analyzer/reducer.pl
index 872f61b33a77..75c0bf6ce7a6 100755
--- a/clang/utils/analyzer/reducer.pl
+++ b/clang/utils/analyzer/reducer.pl
@@ -1,5 +1,6 @@
-#!/usr/bin/perl -w
+#!/usr/bin/env perl
 use strict;
+use warnings;
 use File::Temp qw/ tempdir /;
 my $prog = "reducer";
 
@@ -31,8 +32,9 @@
 my $commandStr = "@$command";
 
 print OUT < 
 #
 
+use warnings;
+
 # Give first option a name.
 my $Directory = $ARGV[0];
 my $Symbol = $ARGV[1];

diff  --git a/llvm/utils/llvm-compilers-check b/llvm/utils/llvm-compilers-check
index 1fd0b93b..3b132454d20b 100755
--- a/llvm/utils/llvm-compilers-check
+++ b/llvm/utils/llvm-compilers-check
@@ -1,4 +1,4 @@
-#!/usr/bin/python3
+#!/usr/bin/env python3
 ##===- utils/llvmbuild - Build the LLVM project 
*-python-*-===##
 #
 # Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.

diff  --git a/llvm/utils/llvm-native-gxx b/llvm/utils/llvm-native-gxx
index db547f654e2f..3c8a703b5b63 100755
--- a/llvm/utils/llvm-native-gxx
+++ b/llvm/utils/llvm-native-gxx
@@ -1,4 +1,4 @@
-#!/usr/bin/perl
+#!/usr/bin/env perl
 # Wrapper around LLVM tools to generate a native .o from llvm-gxx using an
 # LLVM back-end (CBE by default).
 

diff  --git a/openmp/runtime/tools/check-execstack.pl 
b/openmp/runtime/tools/check-execstack.pl
index e4a8e7c883ab..7a710072f972 100755
--- a/openmp/runtime/tools/check-execstack.pl
+++ b/openmp/runtime/tools/check-execstack.pl
@@ -1,4 +1,4 @@
-#!/usr/bin/perl
+#!/usr/bin/env perl
 
 #
 
#//===--===//

diff  --git a/openmp/runtime/tools/check-instruction-set.pl 
b/openmp/runtime/tools/check-instruction-set.pl
index 65c315d59236..6edfb55e99ff 100755
--- a/openmp/runtime/tools/check-instruction-set.pl
+++ b/openmp/runtime/tools/check-instruction-set.pl
@@ -1,4 +1,4 @@
-#!/usr/bin/perl
+#!/usr/bin/env perl
 
 #
 
#//===--===//

diff  --git a/openmp/runtime/tools/message-converte

[PATCH] D95246: [test] Use host platform specific error message substitution in lit tests

2021-02-25 Thread James Henderson via Phabricator via cfe-commits
jhenderson added a comment.

In D95246#2587123 , @ASDenysPetrov 
wrote:

>> This shows, for example, that the `libz.so` my build uses is located in 
>> `/usr/lib/x86_64-linux-gnu`. By having your equivalent path, we can 
>> hopefully confirm that the issue is caused by a different set of system 
>> libraries being used.
>
> Hi, @jhenderson
> I changed `llvm-ar.cpp` then ran `ninja -v llvm-ar` and got this:
>
>   [1/2] D:\WORK\Utilities\MSYS2\mingw64\bin\c++.exe -DGTEST_HAS_RTTI=0 
> -D_DEBUG -D_FILE_OFFSET_BITS=64 -D__STDC_CONSTANT_MACROS 
> -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -Itools/llvm-ar 
> -ID:/WORK/LLVM/llvm-project/llvm/tools/llvm-ar -Iinclude 
> -ID:/WORK/LLVM/llvm-project/llvm/include -Wa,-mbig-obj -Werror=date-time 
> -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual 
> -Wno-missing-field-initializers -pedantic -Wno-long-long 
> -Wimplicit-fallthrough -Wno-maybe-uninitialized -Wno-class-memaccess 
> -Wno-redundant-move -Wno-noexcept-type -Wdelete-non-virtual-dtor 
> -Wsuggest-override -Wno-comment  -O2   -fno-exceptions -fno-rtti -UNDEBUG 
> -std=c++14 -MD -MT tools/llvm-ar/CMakeFiles/llvm-ar.dir/llvm-ar.cpp.obj -MF 
> tools\llvm-ar\CMakeFiles\llvm-ar.dir\llvm-ar.cpp.obj.d -o 
> tools/llvm-ar/CMakeFiles/llvm-ar.dir/llvm-ar.cpp.obj -c 
> D:/WORK/LLVM/llvm-project/llvm/tools/llvm-ar/llvm-ar.cpp
>   [2/2] cmd.exe /C "cd . && D:\WORK\Utilities\MSYS2\mingw64\bin\c++.exe 
> -Wa,-mbig-obj -Werror=date-time -Wall -Wextra -Wno-unused-parameter 
> -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -pedantic 
> -Wno-long-long -Wimplicit-fallthrough -Wno-maybe-uninitialized 
> -Wno-class-memaccess -Wno-redundant-move -Wno-noexcept-type 
> -Wdelete-non-virtual-dtor -Wsuggest-override -Wno-comment  -O2 
> -Wl,--stack,16777216 tools/llvm-ar/CMakeFiles/llvm-ar.dir/llvm-ar.cpp.obj -o 
> bin\llvm-ar.exe -Wl,--out-implib,lib\libllvm-ar.dll.a 
> -Wl,--major-image-version,0,--minor-image-version,0  
> lib/libLLVMX86AsmParser.a  lib/libLLVMX86Desc.a  lib/libLLVMX86Info.a  
> lib/libLLVMBinaryFormat.a  lib/libLLVMCore.a  lib/libLLVMDlltoolDriver.a  
> lib/libLLVMLibDriver.a  lib/libLLVMObject.a  lib/libLLVMSupport.a  
> lib/libLLVMMCDisassembler.a  lib/libLLVMMCParser.a  lib/libLLVMMC.a  
> lib/libLLVMDebugInfoCodeView.a  lib/libLLVMDebugInfoMSF.a  
> lib/libLLVMTextAPI.a  lib/libLLVMOption.a  lib/libLLVMBitReader.a  
> lib/libLLVMCore.a  lib/libLLVMBinaryFormat.a  lib/libLLVMRemarks.a  
> lib/libLLVMBitstreamReader.a  lib/libLLVMSupport.a  -lpsapi  -lshell32  
> -lole32  -luuid  -ladvapi32  D:/WORK/Utilities/MSYS2/mingw64/lib/libz.dll.a  
> lib/libLLVMDemangle.a  -lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 
> -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32 && cd ."
>
> As you can `libz` is here `D:/WORK/Utilities/MSYS2/mingw64/lib/libz.dll.a`

Thanks (for clarity, `libz` isn't what I'm looking for, it was just an example 
of how this information might be useful). As it is, I think we might need more 
information still - that commandline hides which files are actually used 
slightly. Could you try explicitly running the c++ command that is being 
requested, but with the `-Wl,--trace` option added too. That will tell the 
linker to print what files it opens when it runs the link, and should give us 
an hint as to which system library is different for your usage than ours.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D95246/new/

https://reviews.llvm.org/D95246

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


[PATCH] D95246: [test] Use host platform specific error message substitution in lit tests

2021-02-25 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov added a comment.

@jhenderson

> Thanks (for clarity, `libz` isn't what I'm looking for, it was just an 
> example of how this information might be useful). As it is, I think we might 
> need more information still - that commandline hides which files are actually 
> used slightly. Could you try explicitly running the c++ command that is being 
> requested, but with the `-Wl,--trace` option added too. That will tell the 
> linker to print what files it opens when it runs the link, and should give us 
> an hint as to which system library is different for your usage than ours.

I added `-W --trace` to the end of cmdline. The output is in the file: 
F15646704: trace_output.txt 


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D95246/new/

https://reviews.llvm.org/D95246

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


[clang-tools-extra] f0e4610 - Support standalone build of clang-tidy unittest

2021-02-25 Thread via cfe-commits

Author: serge-sans-paille
Date: 2021-02-25T11:51:12+01:00
New Revision: f0e461057221ad334cd194211ef4fa31364054e3

URL: 
https://github.com/llvm/llvm-project/commit/f0e461057221ad334cd194211ef4fa31364054e3
DIFF: 
https://github.com/llvm/llvm-project/commit/f0e461057221ad334cd194211ef4fa31364054e3.diff

LOG: Support standalone build of clang-tidy unittest

Apply the same pattern as the one used in clangd/unittests/CMakeLists.txt

Differential Revision: https://reviews.llvm.org/D96788

Added: 


Modified: 
clang-tools-extra/unittests/clang-tidy/CMakeLists.txt

Removed: 




diff  --git a/clang-tools-extra/unittests/clang-tidy/CMakeLists.txt 
b/clang-tools-extra/unittests/clang-tidy/CMakeLists.txt
index 05d330dd8033..4a8d50f01473 100644
--- a/clang-tools-extra/unittests/clang-tidy/CMakeLists.txt
+++ b/clang-tools-extra/unittests/clang-tidy/CMakeLists.txt
@@ -3,6 +3,15 @@ set(LLVM_LINK_COMPONENTS
   Support
   )
 
+if(CLANG_BUILT_STANDALONE)
+  # LLVMTestingSupport library is needed for clang-tidy tests.
+  if (EXISTS ${LLVM_MAIN_SRC_DIR}/lib/Testing/Support
+  AND NOT TARGET LLVMTestingSupport)
+add_subdirectory(${LLVM_MAIN_SRC_DIR}/lib/Testing/Support
+  lib/Testing/Support)
+  endif()
+endif()
+
 get_filename_component(CLANG_LINT_SOURCE_DIR
   ${CMAKE_CURRENT_SOURCE_DIR}/../../clang-tidy REALPATH)
 include_directories(${CLANG_LINT_SOURCE_DIR})



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


[PATCH] D96788: Support standalone build of clang-tidy unittest

2021-02-25 Thread serge via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf0e461057221: Support standalone build of clang-tidy 
unittest (authored by serge-sans-paille).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D96788/new/

https://reviews.llvm.org/D96788

Files:
  clang-tools-extra/unittests/clang-tidy/CMakeLists.txt


Index: clang-tools-extra/unittests/clang-tidy/CMakeLists.txt
===
--- clang-tools-extra/unittests/clang-tidy/CMakeLists.txt
+++ clang-tools-extra/unittests/clang-tidy/CMakeLists.txt
@@ -3,6 +3,15 @@
   Support
   )
 
+if(CLANG_BUILT_STANDALONE)
+  # LLVMTestingSupport library is needed for clang-tidy tests.
+  if (EXISTS ${LLVM_MAIN_SRC_DIR}/lib/Testing/Support
+  AND NOT TARGET LLVMTestingSupport)
+add_subdirectory(${LLVM_MAIN_SRC_DIR}/lib/Testing/Support
+  lib/Testing/Support)
+  endif()
+endif()
+
 get_filename_component(CLANG_LINT_SOURCE_DIR
   ${CMAKE_CURRENT_SOURCE_DIR}/../../clang-tidy REALPATH)
 include_directories(${CLANG_LINT_SOURCE_DIR})


Index: clang-tools-extra/unittests/clang-tidy/CMakeLists.txt
===
--- clang-tools-extra/unittests/clang-tidy/CMakeLists.txt
+++ clang-tools-extra/unittests/clang-tidy/CMakeLists.txt
@@ -3,6 +3,15 @@
   Support
   )
 
+if(CLANG_BUILT_STANDALONE)
+  # LLVMTestingSupport library is needed for clang-tidy tests.
+  if (EXISTS ${LLVM_MAIN_SRC_DIR}/lib/Testing/Support
+  AND NOT TARGET LLVMTestingSupport)
+add_subdirectory(${LLVM_MAIN_SRC_DIR}/lib/Testing/Support
+  lib/Testing/Support)
+  endif()
+endif()
+
 get_filename_component(CLANG_LINT_SOURCE_DIR
   ${CMAKE_CURRENT_SOURCE_DIR}/../../clang-tidy REALPATH)
 include_directories(${CLANG_LINT_SOURCE_DIR})
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D96572: [Clang][ASan] Introduce `-fsanitize-address-destructor-kind=` driver & frontend option.

2021-02-25 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 accepted this revision.
jansvoboda11 added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D96572/new/

https://reviews.llvm.org/D96572

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


[PATCH] D97233: Support `#pragma clang section` directives on MachO targets

2021-02-25 Thread Tim Northover via Phabricator via cfe-commits
t.p.northover accepted this revision.
t.p.northover added a comment.
This revision is now accepted and ready to land.

Thanks. I think it looks good too now.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D97233/new/

https://reviews.llvm.org/D97233

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


[PATCH] D97457: [flang][driver] Add `-fdebug-dump-parsing-log`

2021-02-25 Thread Andrzej Warzynski via Phabricator via cfe-commits
awarzynski created this revision.
Herald added a reviewer: sscalpone.
Herald added subscribers: jansvoboda11, dang.
awarzynski requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Adds `-fdebug-dump-parsing-log` in the new driver. This option is
semantically identical to `-fdebug-instrumented-parse` in `f18` (the
former is added as an alias in `f18`).

As dumping the parsing log makes only sense for instrumented parses, we
set Fortran::parser::Options::instrumentedParse to `True` when
`-fdebug-dump-parsing-log` is used. This is consistent with `f18`. To
facilate tweaking the frontend based on the action being run,
`setUpFrontendBasedOnAction` in CompilerInvocation.cpp is introduced.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D97457

Files:
  clang/include/clang/Driver/Options.td
  flang/include/flang/Frontend/FrontendActions.h
  flang/include/flang/Frontend/FrontendOptions.h
  flang/lib/Frontend/CompilerInvocation.cpp
  flang/lib/Frontend/FrontendActions.cpp
  flang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
  flang/test/Flang-Driver/debug-parsing-log.f90
  flang/test/Flang-Driver/driver-help.f90
  flang/tools/f18/f18.cpp

Index: flang/tools/f18/f18.cpp
===
--- flang/tools/f18/f18.cpp
+++ flang/tools/f18/f18.cpp
@@ -536,7 +536,8 @@
   driver.debugModuleWriter = true;
 } else if (arg == "-fdebug-measure-parse-tree") {
   driver.measureTree = true;
-} else if (arg == "-fdebug-instrumented-parse") {
+} else if (arg == "-fdebug-instrumented-parse" ||
+arg == "-fdebug-dump-parsing-log") {
   options.instrumentedParse = true;
 } else if (arg == "-fdebug-no-semantics") {
   driver.debugNoSemantics = true;
Index: flang/test/Flang-Driver/driver-help.f90
===
--- flang/test/Flang-Driver/driver-help.f90
+++ flang/test/Flang-Driver/driver-help.f90
@@ -58,6 +58,8 @@
 ! HELP-FC1-NEXT: Enable the old style PARAMETER statement
 ! HELP-FC1-NEXT: -fbackslashSpecify that backslash in string introduces an escape character
 ! HELP-FC1-NEXT: -fdebug-dump-parse-tree Dump the parse tree
+! HELP-FC1-NEXT: -fdebug-dump-parsing-log
+! HELP-FC1-NEXT:   Run instrumented parse and dump the parsing log
 ! HELP-FC1-NEXT: -fdebug-dump-provenance Dump provenance
 ! HELP-FC1-NEXT: -fdebug-dump-symbolsDump symbols after the semantic analysis
 ! HELP-FC1-NEXT: -fdebug-measure-parse-tree
Index: flang/test/Flang-Driver/debug-parsing-log.f90
===
--- /dev/null
+++ flang/test/Flang-Driver/debug-parsing-log.f90
@@ -0,0 +1,24 @@
+! RUN: %flang_fc1 -fdebug-dump-parsing-log %s  2>&1 | FileCheck %s
+
+!-
+! EXPECTED OUTPUT
+!-
+! Below are just few lines extracted from the dump. The actual output is much _much_ bigger.
+
+! CHECK: MODULE statement
+! CHECK:   fail 1
+! CHECK: module
+! CHECK:   fail 1
+! CHECK: END PROGRAM statement
+! CHECK:   pass 1
+! CHECK: PROGRAM statement
+! CHECK:   fail 1
+! CHECK: main program
+! CHECK:   pass 1
+! CHECK: specification construct
+! CHECK:   fail 2
+
+!-
+! TEST INPUT
+!-
+END PROGRAM
Index: flang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
===
--- flang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
+++ flang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
@@ -52,6 +52,9 @@
   case DebugDumpProvenance:
 return std::make_unique();
 break;
+  case DebugDumpParsingLog:
+return std::make_unique();
+break;
   case DebugMeasureParseTree:
 return std::make_unique();
 break;
Index: flang/lib/Frontend/FrontendActions.cpp
===
--- flang/lib/Frontend/FrontendActions.cpp
+++ flang/lib/Frontend/FrontendActions.cpp
@@ -307,6 +307,15 @@
   }
 }
 
+void DebugDumpParsingLogAction::ExecuteAction() {
+  CompilerInstance &ci = this->instance();
+
+  // Parse
+  ci.parsing().Parse(llvm::errs());
+  // Dump parsing log
+  ci.parsing().DumpParsingLog(llvm::outs());
+}
+
 void EmitObjAction::ExecuteAction() {
   CompilerInstance &ci = this->instance();
   unsigned DiagID = ci.diagnostics().getCustomDiagID(
Index: flang/lib/Frontend/CompilerInvocation.cpp
===
--- flang/lib/Frontend/CompilerInvocation.cpp
+++ flang/lib/Frontend/CompilerInvocation.cpp
@@ -85,6 +85,15 @@
   return true;
 }
 
+// Tweak the frontend configuration based on the frontend action
+static void setUpFrontendBasedOnAction(FrontendOptions &opts) {
+  assert(opts.programAction_ != Fortran::frontend::InvalidAction &&
+  "Fortran frontend action not set!");
+
+  if (opts.programAction_ == DebugDumpParsingLog)
+opts.instrumentedParse_ = true;
+}
+

[PATCH] D95246: [test] Use host platform specific error message substitution in lit tests

2021-02-25 Thread James Henderson via Phabricator via cfe-commits
jhenderson added a comment.

In D95246#2587167 , @ASDenysPetrov 
wrote:

> @jhenderson
>
>> Thanks (for clarity, `libz` isn't what I'm looking for, it was just an 
>> example of how this information might be useful). As it is, I think we might 
>> need more information still - that commandline hides which files are 
>> actually used slightly. Could you try explicitly running the c++ command 
>> that is being requested, but with the `-Wl,--trace` option added too. That 
>> will tell the linker to print what files it opens when it runs the link, and 
>> should give us an hint as to which system library is different for your 
>> usage than ours.
>
> I added `-W --trace` to the end of cmdline. The output is in the file: 
> F15646704: trace_output.txt 

Sorry, but `-W --trace` is not the same as `-Wl,--trace`. The former is a pair 
of options used by the compiler (one of which describes the files used by the 
compiler). The latter is an option passed to the linker, and is what we need. 
Please try again!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D95246/new/

https://reviews.llvm.org/D95246

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


[PATCH] D97457: [flang][driver] Add `-fdebug-dump-parsing-log`

2021-02-25 Thread Chirag Khandelwal via Phabricator via cfe-commits
AMDChirag added inline comments.



Comment at: flang/lib/Frontend/CompilerInvocation.cpp:88-95
+// Tweak the frontend configuration based on the frontend action
+static void setUpFrontendBasedOnAction(FrontendOptions &opts) {
+  assert(opts.programAction_ != Fortran::frontend::InvalidAction &&
+  "Fortran frontend action not set!");
+
+  if (opts.programAction_ == DebugDumpParsingLog)
+opts.instrumentedParse_ = true;

Will this function be extended in the future?
If not, an entirely separate function for a couple statements seems rather 
overkill.



Comment at: flang/lib/Frontend/FrontendActions.cpp:313-316
+  // Parse
+  ci.parsing().Parse(llvm::errs());
+  // Dump parsing log
+  ci.parsing().DumpParsingLog(llvm::outs());

NIT: what's the point of these comments?
They are pretty much exactly the same as the function names.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D97457/new/

https://reviews.llvm.org/D97457

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


[PATCH] D95246: [test] Use host platform specific error message substitution in lit tests

2021-02-25 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov added a comment.

@jhenderson

> Sorry, but `-W --trace` is not the same as `-Wl,--trace`. The former is a 
> pair of options used by the compiler (one of which describes the files used 
> by the compiler). The latter is an option passed to the linker, and is what 
> we need. Please try again!

I used `-W`, because my `c++` doesn't know `-Wl` option.

  C:\Users\Denis>c++ -Wl
  c++: error: unrecognized command-line option '-Wl'; did you mean '-W'?
  c++: fatal error: no input files
  compilation terminated.

Could you provide exact cmd line me to use if I'm doing smth wrong?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D95246/new/

https://reviews.llvm.org/D95246

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


[PATCH] D95016: [Clang][RISCV] Add custom TableGen backend for riscv-vector intrinsics.

2021-02-25 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added inline comments.



Comment at: clang/utils/TableGen/RISCVVEmitter.cpp:70
+  // passing to the BUILTIN() macro in Builtins.def.
+  const std::string &builtin_str() const { return BuiltinStr; }
+

These method names should use CamelCase and start with "get"



Comment at: clang/utils/TableGen/RISCVVEmitter.cpp:102
+  // Compute and record a string for legal type.
+  void compute_builtin_str();
+  // Compute and record a builtin RVV vector type string.

These should use CamelCase per llvm coding style.

Might be better named init*Str instead of compute. compute makes me think they 
are going to return something, but that might just be me.



Comment at: clang/utils/TableGen/RISCVVEmitter.cpp:267
+RVVType::RVVType(BasicType BT, int Log2LMUL, StringRef prototype)
+: BT(BT), LMUL(LMULType(Log2LMUL)), IsFloat(false), IsBool(false),
+  IsSigned(true), IsImmediate(false), IsVoid(false), IsConstant(false),

You can initialize the bools to false with " = false" where they are declared 
in the class body then you don't need to mention them all here. Similar for 
Scale and ElementBitWidth.



Comment at: clang/utils/TableGen/RISCVVEmitter.cpp:270
+  IsPointer(false), IsSize_t(false), IsPtrdiff_t(false),
+  ElementBitwidth(~0U), Scale(0) {
+  applyBasicType();

Why is ElementBitwidth default ~0. Wouldn't 0 also be an invalid value?



Comment at: clang/utils/TableGen/RISCVVEmitter.cpp:333
+return;
+  } else if (IsSize_t) {
+S = "z";

You drop the else since the if above returned.



Comment at: clang/utils/TableGen/RISCVVEmitter.cpp:618
+  if (NewMangledName.empty())
+MangledName = Twine(NewName.split("_").first).str();
+  else

I don't think we need to go through Twine here. We should be able to call str() 
directly on first.



Comment at: clang/utils/TableGen/RISCVVEmitter.cpp:621
+MangledName = NewMangledName.str();
+  if (Suffix.size())
+Name += "_" + Suffix.str();

!Suffix.empty()



Comment at: clang/utils/TableGen/RISCVVEmitter.cpp:640
+  InputTypes.assign(OutInTypes.begin() + 1, OutInTypes.end());
+  for (unsigned i = 0; i < InputTypes.size(); ++i)
+CTypeOrder.push_back(i);

CTypeOrder.resize(InputTypes.size());
std::iota(CTypeOrder.begin(), CTypeOrder.end(), 0);



Comment at: clang/utils/TableGen/RISCVVEmitter.cpp:710
+void RVVIntrinsic::emitMangledFuncDef(raw_ostream &OS) const {
+  OS << Twine(OutputType->type_str() + Twine(" ")).str();
+  OS << getMangledName();

Can't we just print OutputType->type_str() and " " to OS separately? We 
shouldn't need to concat them into a Twine first.



Comment at: clang/utils/TableGen/RISCVVEmitter.cpp:714
+  // Emit function arguments
+  if (CTypeOrder.size() > 1) {
+OS << InputTypes[CTypeOrder[0]]->type_str() + " op0";

Why is this > 1 and not >= 1 or !CTypeOrder.empty()?



Comment at: clang/utils/TableGen/RISCVVEmitter.cpp:720
+  OS << "){\n";
+  OS << "  return " + getName() + "(";
+  // Emit parameter variables

Replace the + operators with <<



Comment at: clang/utils/TableGen/RISCVVEmitter.cpp:722
+  // Emit parameter variables
+  if (CTypeOrder.size() > 1) {
+OS << "op0";

Same here, why is this >1 and not >=1 or !CTypeOrder.empty()?



Comment at: clang/utils/TableGen/RISCVVEmitter.cpp:749
+
+  OS << "#ifndef _RISCV_VECTOR_H\n";
+  OS << "#define _RISCV_VECTOR_H\n\n";

Looks like other headers use 2 underscores at the beginning of their include 
guard.



Comment at: clang/utils/TableGen/RISCVVEmitter.cpp:757
+  OS << "#error \"Vector intrinsics require the vector extension.\"\n";
+  OS << "#else\n\n";
+

Can we just #endif here instead of the #else? If the error is emitted the 
preprocessor should stop and not process the rest of the file. Then we don't 
need to close it at the bottom of the file.



Comment at: clang/utils/TableGen/RISCVVEmitter.cpp:767
+  // Dump RVV boolean types.
+  auto dumpType = [&](auto T) {
+OS << "typedef " << T->clang_builtin_str() << " " << T->type_str() << 
";\n";

I'd recommend calling this printType.  dump made me think it was printing for 
debug like the dump() functions found in many LLVM classes.



Comment at: clang/utils/TableGen/RISCVVEmitter.cpp:799
+  // D implies F
+  OS << "#if defined(__riscv_f) || defined(__riscv_d)\n";
+  for (int Log2LMUL : Log2LMULs) {

I think we only need to check __riscv_f here?



Comment at: clang/utils/TableGen/RISCVVEmitter.cpp:836
+  return;
+OS << StringRef(
+"static inline __attribut

[PATCH] D95016: [Clang][RISCV] Add custom TableGen backend for riscv-vector intrinsics.

2021-02-25 Thread Zakk Chen via Phabricator via cfe-commits
khchen updated this revision to Diff 326300.
khchen marked 21 inline comments as done.
khchen added a comment.

1. Rename Dump to Print.
2. Address Craig's comments, thanks for your patient.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D95016/new/

https://reviews.llvm.org/D95016

Files:
  clang/include/clang/Basic/BuiltinsRISCV.def
  clang/include/clang/Basic/CMakeLists.txt
  clang/include/clang/Basic/riscv_vector.td
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/Headers/CMakeLists.txt
  clang/test/CodeGen/RISCV/rvv-intrinsics-generic/vadd.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-generic/vfadd.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vadd.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vfadd.c
  clang/test/CodeGen/RISCV/vadd.c
  clang/test/Headers/riscv-vector-header.c
  clang/utils/TableGen/CMakeLists.txt
  clang/utils/TableGen/RISCVVEmitter.cpp
  clang/utils/TableGen/TableGen.cpp
  clang/utils/TableGen/TableGenBackends.h
  llvm/docs/CommandGuide/tblgen.rst

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


[PATCH] D95016: [Clang][RISCV] Add custom TableGen backend for riscv-vector intrinsics.

2021-02-25 Thread Zakk Chen via Phabricator via cfe-commits
khchen added inline comments.



Comment at: clang/utils/TableGen/RISCVVEmitter.cpp:270
+  IsPointer(false), IsSize_t(false), IsPtrdiff_t(false),
+  ElementBitwidth(~0U), Scale(0) {
+  applyBasicType();

craig.topper wrote:
> Why is ElementBitwidth default ~0. Wouldn't 0 also be an invalid value?
I followed SVE did, but you are right, 0 is better.



Comment at: clang/utils/TableGen/RISCVVEmitter.cpp:714
+  // Emit function arguments
+  if (CTypeOrder.size() > 1) {
+OS << InputTypes[CTypeOrder[0]]->type_str() + " op0";

craig.topper wrote:
> Why is this > 1 and not >= 1 or !CTypeOrder.empty()?
Thanks, it's bug when I refactor code from output input vector to input only 
vector...



Comment at: clang/utils/TableGen/RISCVVEmitter.cpp:757
+  OS << "#error \"Vector intrinsics require the vector extension.\"\n";
+  OS << "#else\n\n";
+

craig.topper wrote:
> Can we just #endif here instead of the #else? If the error is emitted the 
> preprocessor should stop and not process the rest of the file. Then we don't 
> need to close it at the bottom of the file.
Good point. Thanks. I should think more when I copied code from SVE.



Comment at: clang/utils/TableGen/RISCVVEmitter.cpp:873
+  // Dump switch body when the ir name changes from previous iteration.
+  RVVIntrinsic *PrevDef = Defs.begin()->get();
+  for (auto &Def : Defs) {

craig.topper wrote:
> Can we remember the PrevIRName StringRef instead?
I don't think so. We need `PrevDef` to emitCodeGenSwitchBody.



Comment at: clang/utils/TableGen/RISCVVEmitter.cpp:1027
+return false;
+  bool NeedOR = false;
+  OS << "#if";

craig.topper wrote:
> I think you can use ListSeparator for this. It keeps track of the separator 
> string and whether the first item has been printed. It's most often used with 
> loops, but it should work here. I think there are many examples uses in 
> llvm/utils/TableGen
thanks, it's more elegant.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D95016/new/

https://reviews.llvm.org/D95016

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


[PATCH] D95016: [Clang][RISCV] Add custom TableGen backend for riscv-vector intrinsics.

2021-02-25 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added inline comments.



Comment at: clang/utils/TableGen/RISCVVEmitter.cpp:873
+  // Dump switch body when the ir name changes from previous iteration.
+  RVVIntrinsic *PrevDef = Defs.begin()->get();
+  for (auto &Def : Defs) {

khchen wrote:
> craig.topper wrote:
> > Can we remember the PrevIRName StringRef instead?
> I don't think so. We need `PrevDef` to emitCodeGenSwitchBody.
Of course we do. Sorry about that.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D95016/new/

https://reviews.llvm.org/D95016

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


[PATCH] D97423: Fix a test case that checks should check whether or not it is passed into lld

2021-02-25 Thread Albion Fung via Phabricator via cfe-commits
Conanap created this revision.
Conanap added reviewers: yaxunl, PowerPC, nemanjai, saghir.
Conanap added projects: LLVM, clang, PowerPC, AMDGPU.
Herald added a subscriber: steven.zhang.
Conanap requested review of this revision.

This test case was causing a PowerPC buildbot to fail as it happened to be 
named `lld-multistage`, which matches with the original regex and therefore 
fails the check-not. This should better represent the desired check.

Original differential: https://reviews.llvm.org/D96835


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D97423

Files:
  clang/test/Driver/hip-sanitize-options.hip


Index: clang/test/Driver/hip-sanitize-options.hip
===
--- clang/test/Driver/hip-sanitize-options.hip
+++ clang/test/Driver/hip-sanitize-options.hip
@@ -26,15 +26,15 @@
 // RUN:   %s 2>&1 | FileCheck -check-prefixes=FAIL %s
 
 // CHECK-NOT: {{"[^"]*clang[^"]*".* "-fcuda-is-device".* "-fsanitize=address"}}
-// CHECK-NOT: {{"[^"]*lld[^"]*".* ".*hip.bc"}}
+// CHECK-NOT: {{"[^"]*lld".* ".*hip.bc"}}
 // CHECK: {{"[^"]*clang[^"]*".* "-triple" "x86_64-unknown-linux-gnu".* 
"-fsanitize=address"}}
 
 // NORDC: {{"[^"]*clang[^"]*".* "-fcuda-is-device".* "-fsanitize=address".*}} 
"-o" "[[OUT:[^"]*.bc]]"
-// NORDC: {{"[^"]*lld[^"]*".*}} "[[OUT]]" {{".*asanrtl.bc" ".*hip.bc"}}
+// NORDC: {{"[^"]*lld".*}} "[[OUT]]" {{".*asanrtl.bc" ".*hip.bc"}}
 // NORDC: {{"[^"]*clang[^"]*".* "-triple" "x86_64-unknown-linux-gnu".* 
"-fsanitize=address"}}
 
 // RDC: {{"[^"]*clang[^"]*".* "-triple" "x86_64-unknown-linux-gnu".* 
"-fsanitize=address"}}
 // RDC: {{"[^"]*clang[^"]*".* "-emit-llvm-bc".* "-fcuda-is-device".* 
"-fsanitize=address".*}} "-o" "[[OUT:[^"]*.bc]]"
-// RDC: {{"[^"]*lld[^"]*".*}} "[[OUT]]" {{".*asanrtl.bc" ".*hip.bc"}}
+// RDC: {{"[^"]*lld".*}} "[[OUT]]" {{".*asanrtl.bc" ".*hip.bc"}}
 
 // FAIL: AMDGPU address sanitizer runtime library (asanrtl) is not found. 
Please install ROCm device library which supports address sanitizer


Index: clang/test/Driver/hip-sanitize-options.hip
===
--- clang/test/Driver/hip-sanitize-options.hip
+++ clang/test/Driver/hip-sanitize-options.hip
@@ -26,15 +26,15 @@
 // RUN:   %s 2>&1 | FileCheck -check-prefixes=FAIL %s
 
 // CHECK-NOT: {{"[^"]*clang[^"]*".* "-fcuda-is-device".* "-fsanitize=address"}}
-// CHECK-NOT: {{"[^"]*lld[^"]*".* ".*hip.bc"}}
+// CHECK-NOT: {{"[^"]*lld".* ".*hip.bc"}}
 // CHECK: {{"[^"]*clang[^"]*".* "-triple" "x86_64-unknown-linux-gnu".* "-fsanitize=address"}}
 
 // NORDC: {{"[^"]*clang[^"]*".* "-fcuda-is-device".* "-fsanitize=address".*}} "-o" "[[OUT:[^"]*.bc]]"
-// NORDC: {{"[^"]*lld[^"]*".*}} "[[OUT]]" {{".*asanrtl.bc" ".*hip.bc"}}
+// NORDC: {{"[^"]*lld".*}} "[[OUT]]" {{".*asanrtl.bc" ".*hip.bc"}}
 // NORDC: {{"[^"]*clang[^"]*".* "-triple" "x86_64-unknown-linux-gnu".* "-fsanitize=address"}}
 
 // RDC: {{"[^"]*clang[^"]*".* "-triple" "x86_64-unknown-linux-gnu".* "-fsanitize=address"}}
 // RDC: {{"[^"]*clang[^"]*".* "-emit-llvm-bc".* "-fcuda-is-device".* "-fsanitize=address".*}} "-o" "[[OUT:[^"]*.bc]]"
-// RDC: {{"[^"]*lld[^"]*".*}} "[[OUT]]" {{".*asanrtl.bc" ".*hip.bc"}}
+// RDC: {{"[^"]*lld".*}} "[[OUT]]" {{".*asanrtl.bc" ".*hip.bc"}}
 
 // FAIL: AMDGPU address sanitizer runtime library (asanrtl) is not found. Please install ROCm device library which supports address sanitizer
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D97423: Fix a test case that checks should check whether or not it is passed into lld

2021-02-25 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added inline comments.



Comment at: clang/test/Driver/hip-sanitize-options.hip:29
 // CHECK-NOT: {{"[^"]*clang[^"]*".* "-fcuda-is-device".* "-fsanitize=address"}}
-// CHECK-NOT: {{"[^"]*lld[^"]*".* ".*hip.bc"}}
+// CHECK-NOT: {{"[^"]*lld".* ".*hip.bc"}}
 // CHECK: {{"[^"]*clang[^"]*".* "-triple" "x86_64-unknown-linux-gnu".* 
"-fsanitize=address"}}

this may fail on windows since lld becomes lld.exe


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D97423/new/

https://reviews.llvm.org/D97423

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


[PATCH] D97423: Fix a test case that checks should check whether or not it is passed into lld

2021-02-25 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added inline comments.



Comment at: clang/test/Driver/hip-sanitize-options.hip:29
 // CHECK-NOT: {{"[^"]*clang[^"]*".* "-fcuda-is-device".* "-fsanitize=address"}}
-// CHECK-NOT: {{"[^"]*lld[^"]*".* ".*hip.bc"}}
+// CHECK-NOT: {{"[^"]*lld".* ".*hip.bc"}}
 // CHECK: {{"[^"]*clang[^"]*".* "-triple" "x86_64-unknown-linux-gnu".* 
"-fsanitize=address"}}

yaxunl wrote:
> this may fail on windows since lld becomes lld.exe
may be change to


```
{{"[^"]*lld[^"]*".* "-plugin-opt=.* ".*hip.bc"}}
```

similar as below


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D97423/new/

https://reviews.llvm.org/D97423

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


[PATCH] D95016: [Clang][RISCV] Add custom TableGen backend for riscv-vector intrinsics.

2021-02-25 Thread Zakk Chen via Phabricator via cfe-commits
khchen updated this revision to Diff 326309.
khchen added a comment.

refine comment


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D95016/new/

https://reviews.llvm.org/D95016

Files:
  clang/include/clang/Basic/BuiltinsRISCV.def
  clang/include/clang/Basic/CMakeLists.txt
  clang/include/clang/Basic/riscv_vector.td
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/Headers/CMakeLists.txt
  clang/test/CodeGen/RISCV/rvv-intrinsics-generic/vadd.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-generic/vfadd.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vadd.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vfadd.c
  clang/test/CodeGen/RISCV/vadd.c
  clang/test/Headers/riscv-vector-header.c
  clang/utils/TableGen/CMakeLists.txt
  clang/utils/TableGen/RISCVVEmitter.cpp
  clang/utils/TableGen/TableGen.cpp
  clang/utils/TableGen/TableGenBackends.h
  llvm/docs/CommandGuide/tblgen.rst

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


[PATCH] D97423: Fix a test case that checks should check whether or not it is passed into lld

2021-02-25 Thread Albion Fung via Phabricator via cfe-commits
Conanap updated this revision to Diff 326311.
Conanap marked 2 inline comments as done.
Conanap added a comment.

Added .exe check for windows


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D97423/new/

https://reviews.llvm.org/D97423

Files:
  clang/test/Driver/hip-sanitize-options.hip


Index: clang/test/Driver/hip-sanitize-options.hip
===
--- clang/test/Driver/hip-sanitize-options.hip
+++ clang/test/Driver/hip-sanitize-options.hip
@@ -26,15 +26,15 @@
 // RUN:   %s 2>&1 | FileCheck -check-prefixes=FAIL %s
 
 // CHECK-NOT: {{"[^"]*clang[^"]*".* "-fcuda-is-device".* "-fsanitize=address"}}
-// CHECK-NOT: {{"[^"]*lld[^"]*".* ".*hip.bc"}}
+// CHECK-NOT: {{"[^"]*lld(\.exe){0,1}".* ".*hip.bc"}}
 // CHECK: {{"[^"]*clang[^"]*".* "-triple" "x86_64-unknown-linux-gnu".* 
"-fsanitize=address"}}
 
 // NORDC: {{"[^"]*clang[^"]*".* "-fcuda-is-device".* "-fsanitize=address".*}} 
"-o" "[[OUT:[^"]*.bc]]"
-// NORDC: {{"[^"]*lld[^"]*".*}} "[[OUT]]" {{".*asanrtl.bc" ".*hip.bc"}}
+// NORDC: {{"[^"]*lld(\.exe){0,1}".*}} "[[OUT]]" {{".*asanrtl.bc" ".*hip.bc"}}
 // NORDC: {{"[^"]*clang[^"]*".* "-triple" "x86_64-unknown-linux-gnu".* 
"-fsanitize=address"}}
 
 // RDC: {{"[^"]*clang[^"]*".* "-triple" "x86_64-unknown-linux-gnu".* 
"-fsanitize=address"}}
 // RDC: {{"[^"]*clang[^"]*".* "-emit-llvm-bc".* "-fcuda-is-device".* 
"-fsanitize=address".*}} "-o" "[[OUT:[^"]*.bc]]"
-// RDC: {{"[^"]*lld[^"]*".*}} "[[OUT]]" {{".*asanrtl.bc" ".*hip.bc"}}
+// RDC: {{"[^"]*lld(\.exe){0,1}".*}} "[[OUT]]" {{".*asanrtl.bc" ".*hip.bc"}}
 
 // FAIL: AMDGPU address sanitizer runtime library (asanrtl) is not found. 
Please install ROCm device library which supports address sanitizer


Index: clang/test/Driver/hip-sanitize-options.hip
===
--- clang/test/Driver/hip-sanitize-options.hip
+++ clang/test/Driver/hip-sanitize-options.hip
@@ -26,15 +26,15 @@
 // RUN:   %s 2>&1 | FileCheck -check-prefixes=FAIL %s
 
 // CHECK-NOT: {{"[^"]*clang[^"]*".* "-fcuda-is-device".* "-fsanitize=address"}}
-// CHECK-NOT: {{"[^"]*lld[^"]*".* ".*hip.bc"}}
+// CHECK-NOT: {{"[^"]*lld(\.exe){0,1}".* ".*hip.bc"}}
 // CHECK: {{"[^"]*clang[^"]*".* "-triple" "x86_64-unknown-linux-gnu".* "-fsanitize=address"}}
 
 // NORDC: {{"[^"]*clang[^"]*".* "-fcuda-is-device".* "-fsanitize=address".*}} "-o" "[[OUT:[^"]*.bc]]"
-// NORDC: {{"[^"]*lld[^"]*".*}} "[[OUT]]" {{".*asanrtl.bc" ".*hip.bc"}}
+// NORDC: {{"[^"]*lld(\.exe){0,1}".*}} "[[OUT]]" {{".*asanrtl.bc" ".*hip.bc"}}
 // NORDC: {{"[^"]*clang[^"]*".* "-triple" "x86_64-unknown-linux-gnu".* "-fsanitize=address"}}
 
 // RDC: {{"[^"]*clang[^"]*".* "-triple" "x86_64-unknown-linux-gnu".* "-fsanitize=address"}}
 // RDC: {{"[^"]*clang[^"]*".* "-emit-llvm-bc".* "-fcuda-is-device".* "-fsanitize=address".*}} "-o" "[[OUT:[^"]*.bc]]"
-// RDC: {{"[^"]*lld[^"]*".*}} "[[OUT]]" {{".*asanrtl.bc" ".*hip.bc"}}
+// RDC: {{"[^"]*lld(\.exe){0,1}".*}} "[[OUT]]" {{".*asanrtl.bc" ".*hip.bc"}}
 
 // FAIL: AMDGPU address sanitizer runtime library (asanrtl) is not found. Please install ROCm device library which supports address sanitizer
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D95119: Prefer /usr/bin/env xxx over /usr/bin/xxx where xxx = perl, python, awk

2021-02-25 Thread Raphael Isemann via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa54f160b3a98: Prefer /usr/bin/env xxx over /usr/bin/xxx 
where xxx = perl, python, awk (authored by haampie, committed by teemperor).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D95119/new/

https://reviews.llvm.org/D95119

Files:
  clang/test/make_test_dirs.pl
  clang/tools/scan-build/bin/set-xcode-analyzer
  clang/utils/TestUtils/pch-test.pl
  clang/utils/analyzer/reducer.pl
  clang/utils/analyzer/update_plist_test.pl
  clang/www/demo/index.cgi
  debuginfo-tests/llgdb-tests/test_debuginfo.pl
  lldb/docs/use/python-reference.rst
  lldb/scripts/disasm-gdb-remote.pl
  llvm/utils/GenLibDeps.pl
  llvm/utils/codegen-diff
  llvm/utils/findsym.pl
  llvm/utils/llvm-compilers-check
  llvm/utils/llvm-native-gxx
  openmp/runtime/tools/check-execstack.pl
  openmp/runtime/tools/check-instruction-set.pl
  openmp/runtime/tools/message-converter.pl
  polly/lib/External/isl/doc/mypod2latex

Index: polly/lib/External/isl/doc/mypod2latex
===
--- polly/lib/External/isl/doc/mypod2latex
+++ polly/lib/External/isl/doc/mypod2latex
@@ -1,4 +1,4 @@
-#!/usr/bin/perl
+#!/usr/bin/env perl
 
 use strict;
 use Pod::LaTeX;
Index: openmp/runtime/tools/message-converter.pl
===
--- openmp/runtime/tools/message-converter.pl
+++ openmp/runtime/tools/message-converter.pl
@@ -1,4 +1,4 @@
-#!/usr/bin/perl
+#!/usr/bin/env perl
 
 #
 #//===--===//
Index: openmp/runtime/tools/check-instruction-set.pl
===
--- openmp/runtime/tools/check-instruction-set.pl
+++ openmp/runtime/tools/check-instruction-set.pl
@@ -1,4 +1,4 @@
-#!/usr/bin/perl
+#!/usr/bin/env perl
 
 #
 #//===--===//
Index: openmp/runtime/tools/check-execstack.pl
===
--- openmp/runtime/tools/check-execstack.pl
+++ openmp/runtime/tools/check-execstack.pl
@@ -1,4 +1,4 @@
-#!/usr/bin/perl
+#!/usr/bin/env perl
 
 #
 #//===--===//
Index: llvm/utils/llvm-native-gxx
===
--- llvm/utils/llvm-native-gxx
+++ llvm/utils/llvm-native-gxx
@@ -1,4 +1,4 @@
-#!/usr/bin/perl
+#!/usr/bin/env perl
 # Wrapper around LLVM tools to generate a native .o from llvm-gxx using an
 # LLVM back-end (CBE by default).
 
Index: llvm/utils/llvm-compilers-check
===
--- llvm/utils/llvm-compilers-check
+++ llvm/utils/llvm-compilers-check
@@ -1,4 +1,4 @@
-#!/usr/bin/python3
+#!/usr/bin/env python3
 ##===- utils/llvmbuild - Build the LLVM project *-python-*-===##
 #
 # Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
Index: llvm/utils/findsym.pl
===
--- llvm/utils/findsym.pl
+++ llvm/utils/findsym.pl
@@ -1,4 +1,4 @@
-#!/usr/bin/perl -w
+#!/usr/bin/env perl
 #
 # Program:  findsym.pl
 #
@@ -8,6 +8,8 @@
 # Syntax:   findsym.pl  
 #
 
+use warnings;
+
 # Give first option a name.
 my $Directory = $ARGV[0];
 my $Symbol = $ARGV[1];
Index: llvm/utils/codegen-diff
===
--- llvm/utils/codegen-diff
+++ llvm/utils/codegen-diff
@@ -1,4 +1,4 @@
-#!/usr/bin/perl
+#!/usr/bin/env perl
 
 use Getopt::Std;
 $DEBUG = 0;
Index: llvm/utils/GenLibDeps.pl
===
--- llvm/utils/GenLibDeps.pl
+++ llvm/utils/GenLibDeps.pl
@@ -1,4 +1,4 @@
-#!/usr/bin/perl -w
+#!/usr/bin/env perl
 #
 # Program:  GenLibDeps.pl
 #
Index: lldb/scripts/disasm-gdb-remote.pl
===
--- lldb/scripts/disasm-gdb-remote.pl
+++ lldb/scripts/disasm-gdb-remote.pl
@@ -1,4 +1,4 @@
-#!/usr/bin/perl
+#!/usr/bin/env perl
 
 use strict;
 
Index: lldb/docs/use/python-reference.rst
===
--- lldb/docs/use/python-reference.rst
+++ lldb/docs/use/python-reference.rst
@@ -607,7 +607,7 @@
 
 ::
 
-  #!/usr/bin/python
+  #!/usr/bin/env python
 
   import lldb
   import commands
@@ -715,7 +715,7 @@
 
 ::
 
-  #!/usr/bin/python
+  #!/usr/bin/env python
 
   import lldb
   import os
Index: debuginfo-tests/llgdb-tests/test_debuginfo.pl
===
--- debuginfo-tests/llgdb-tests/test_debuginfo.pl
+++ debuginfo-tests/llgdb-tests/test_debuginfo.pl
@@ -1,4 +1,4 @@
-#!/usr/bin/perl
+#!/usr/bin/env perl
 #
 # This script tests debugging information generated by a compiler.
 # Input argum

[PATCH] D97423: Fix a test case that checks should check whether or not it is passed into lld

2021-02-25 Thread Albion Fung via Phabricator via cfe-commits
Conanap added inline comments.



Comment at: clang/test/Driver/hip-sanitize-options.hip:29
 // CHECK-NOT: {{"[^"]*clang[^"]*".* "-fcuda-is-device".* "-fsanitize=address"}}
-// CHECK-NOT: {{"[^"]*lld[^"]*".* ".*hip.bc"}}
+// CHECK-NOT: {{"[^"]*lld".* ".*hip.bc"}}
 // CHECK: {{"[^"]*clang[^"]*".* "-triple" "x86_64-unknown-linux-gnu".* 
"-fsanitize=address"}}

yaxunl wrote:
> yaxunl wrote:
> > this may fail on windows since lld becomes lld.exe
> may be change to
> 
> 
> ```
> {{"[^"]*lld[^"]*".* "-plugin-opt=.* ".*hip.bc"}}
> ```
> 
> similar as below
Should be fixed now


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D97423/new/

https://reviews.llvm.org/D97423

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


[PATCH] D97461: [clang][cli] Implement '-cuid=' marshalling

2021-02-25 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 created this revision.
jansvoboda11 added reviewers: Bigcheese, dexonsmith.
Herald added a subscriber: dang.
jansvoboda11 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This patch adds marshalling to the `-cuid=` option introduced in D95007 
.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D97461

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Frontend/CompilerInvocation.cpp


Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -3632,11 +3632,6 @@
 }
   }
 
-
-  if (auto *A = Args.getLastArg(OPT_cuid_EQ)) {
-Opts.CUID = std::string(A->getValue());
-  }
-
   if (Opts.ObjC) {
 if (Arg *arg = Args.getLastArg(OPT_fobjc_runtime_EQ)) {
   StringRef value = arg->getValue();
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -934,7 +934,8 @@
"compilation unit but different for different compilation units. "
"It is used to externalize device-side static variables for single "
"source offloading languages CUDA and HIP so that they can be "
-   "accessed by the host code of the same compilation unit.">;
+   "accessed by the host code of the same compilation unit.">,
+  MarshallingInfoString>;
 def fuse_cuid_EQ : Joined<["-"], "fuse-cuid=">,
   HelpText<"Method to generate ID's for compilation units for single source "
"offloading languages CUDA and HIP: 'hash' (ID's generated by 
hashing "


Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -3632,11 +3632,6 @@
 }
   }
 
-
-  if (auto *A = Args.getLastArg(OPT_cuid_EQ)) {
-Opts.CUID = std::string(A->getValue());
-  }
-
   if (Opts.ObjC) {
 if (Arg *arg = Args.getLastArg(OPT_fobjc_runtime_EQ)) {
   StringRef value = arg->getValue();
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -934,7 +934,8 @@
"compilation unit but different for different compilation units. "
"It is used to externalize device-side static variables for single "
"source offloading languages CUDA and HIP so that they can be "
-   "accessed by the host code of the same compilation unit.">;
+   "accessed by the host code of the same compilation unit.">,
+  MarshallingInfoString>;
 def fuse_cuid_EQ : Joined<["-"], "fuse-cuid=">,
   HelpText<"Method to generate ID's for compilation units for single source "
"offloading languages CUDA and HIP: 'hash' (ID's generated by hashing "
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D97462: [clang][cli] Round-trip cc1 arguments in assert builds

2021-02-25 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 created this revision.
jansvoboda11 added reviewers: Bigcheese, dexonsmith.
Herald added a subscriber: mgorny.
jansvoboda11 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This patch enables cc1 argument round-trip for assert builds. It can be 
disabled by building clang with `-DCLANG_ROUND_TRIP_CC1_ARGS=OFF`.

This will be committed only if we reach consensus in 
https://lists.llvm.org/pipermail/cfe-dev/2021-February/067714.html.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D97462

Files:
  clang/CMakeLists.txt


Index: clang/CMakeLists.txt
===
--- clang/CMakeLists.txt
+++ clang/CMakeLists.txt
@@ -465,7 +465,8 @@
 
 option(CLANG_ENABLE_PROTO_FUZZER "Build Clang protobuf fuzzer." OFF)
 
-option(CLANG_ROUND_TRIP_CC1_ARGS "Round-trip command line arguments in -cc1." 
OFF)
+option(CLANG_ROUND_TRIP_CC1_ARGS
+  "Round-trip command line arguments in -cc1." ${LLVM_ENABLE_ASSERTIONS})
 
 if(NOT CLANG_ENABLE_STATIC_ANALYZER AND CLANG_ENABLE_ARCMT)
   message(FATAL_ERROR "Cannot disable static analyzer while enabling ARCMT or 
Z3")


Index: clang/CMakeLists.txt
===
--- clang/CMakeLists.txt
+++ clang/CMakeLists.txt
@@ -465,7 +465,8 @@
 
 option(CLANG_ENABLE_PROTO_FUZZER "Build Clang protobuf fuzzer." OFF)
 
-option(CLANG_ROUND_TRIP_CC1_ARGS "Round-trip command line arguments in -cc1." OFF)
+option(CLANG_ROUND_TRIP_CC1_ARGS
+  "Round-trip command line arguments in -cc1." ${LLVM_ENABLE_ASSERTIONS})
 
 if(NOT CLANG_ENABLE_STATIC_ANALYZER AND CLANG_ENABLE_ARCMT)
   message(FATAL_ERROR "Cannot disable static analyzer while enabling ARCMT or Z3")
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D97204: [RFC] Clang 64-bit source locations

2021-02-25 Thread Mikhail Maltsev via Phabricator via cfe-commits
miyuki added a comment.

In D97204#2586111 , @rsmith wrote:

> Thanks for doing this!
>
> The 8-9% memory hit is better than I'd feared, but still seems uncomfortably 
> large. I've left comments on a couple of places where I think we could 
> substantially reduce this.

Thanks, I'll try that.

> Can we avoid a libclang ABI break if we don't allow the use of 64-bit source 
> locations for builds with 32-bit pointers?

No, unfortunately in some structs libclang stores source locations in 'unsigned 
int' fields, e.g. CXToken. In CXSourceLocation and CXSourceRange some space can 
be saved by an extra indirection, so 64-bit locations could fit there, AFAICT.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D97204/new/

https://reviews.llvm.org/D97204

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


[PATCH] D95246: [test] Use host platform specific error message substitution in lit tests

2021-02-25 Thread James Henderson via Phabricator via cfe-commits
jhenderson added a comment.

In D95246#2587277 , @ASDenysPetrov 
wrote:

> @jhenderson
>
>> Sorry, but `-W --trace` is not the same as `-Wl,--trace`. The former is a 
>> pair of options used by the compiler (one of which describes the files used 
>> by the compiler). The latter is an option passed to the linker, and is what 
>> we need. Please try again!
>
> I used `-W`, because my `c++` doesn't know `-Wl` option.
>
>   C:\Users\Denis>c++ -Wl
>   c++: error: unrecognized command-line option '-Wl'; did you mean '-W'?
>   c++: fatal error: no input files
>   compilation terminated.
>
> Could you provide exact cmd line me to use if I'm doing smth wrong?

`-Wl` on its own isn't an option. It is used as a prefix to pass an option to 
the linker, so the exact string you pass to the compiler is `-Wl,--trace` (no 
spaces, comma required). The compiler sees the `-Wl,` prefix, removes it and 
then passes the remainder straight to the linker. You can see examples of this 
in your existing commandline with things like `-Wl,--stack,16777216`.

The cmdline should be:

  D:\WORK\Utilities\MSYS2\mingw64\bin\c++.exe -DGTEST_HAS_RTTI=0 -D_DEBUG 
-D_FILE_OFFSET_BITS=64 -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS 
-D__STDC_LIMIT_MACROS -Itools/llvm-ar 
-ID:/WORK/LLVM/llvm-project/llvm/tools/llvm-ar -Iinclude 
-ID:/WORK/LLVM/llvm-project/llvm/include -Wa,-mbig-obj -Werror=date-time -Wall 
-Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual 
-Wno-missing-field-initializers -pedantic -Wno-long-long -Wimplicit-fallthrough 
-Wno-maybe-uninitialized -Wno-class-memaccess -Wno-redundant-move 
-Wno-noexcept-type -Wdelete-non-virtual-dtor -Wsuggest-override -Wno-comment  
-O2   -fno-exceptions -fno-rtti -UNDEBUG -std=c++14 -MD -MT 
tools/llvm-ar/CMakeFiles/llvm-ar.dir/llvm-ar.cpp.obj -MF 
tools\llvm-ar\CMakeFiles\llvm-ar.dir\llvm-ar.cpp.obj.d -o 
tools/llvm-ar/CMakeFiles/llvm-ar.dir/llvm-ar.cpp.obj -c 
D:/WORK/LLVM/llvm-project/llvm/tools/llvm-ar/llvm-ar.cpp
  [2/2] cmd.exe /C "cd . && D:\WORK\Utilities\MSYS2\mingw64\bin\c++.exe 
-Wa,-mbig-obj -Werror=date-time -Wall -Wextra -Wno-unused-parameter 
-Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -pedantic 
-Wno-long-long -Wimplicit-fallthrough -Wno-maybe-uninitialized 
-Wno-class-memaccess -Wno-redundant-move -Wno-noexcept-type 
-Wdelete-non-virtual-dtor -Wsuggest-override -Wno-comment  -O2 
-Wl,--stack,16777216 tools/llvm-ar/CMakeFiles/llvm-ar.dir/llvm-ar.cpp.obj -o 
bin\llvm-ar.exe -Wl,--out-implib,lib\libllvm-ar.dll.a 
-Wl,--major-image-version,0,--minor-image-version,0  lib/libLLVMX86AsmParser.a  
lib/libLLVMX86Desc.a  lib/libLLVMX86Info.a  lib/libLLVMBinaryFormat.a  
lib/libLLVMCore.a  lib/libLLVMDlltoolDriver.a  lib/libLLVMLibDriver.a  
lib/libLLVMObject.a  lib/libLLVMSupport.a  lib/libLLVMMCDisassembler.a  
lib/libLLVMMCParser.a  lib/libLLVMMC.a  lib/libLLVMDebugInfoCodeView.a  
lib/libLLVMDebugInfoMSF.a  lib/libLLVMTextAPI.a  lib/libLLVMOption.a  
lib/libLLVMBitReader.a  lib/libLLVMCore.a  lib/libLLVMBinaryFormat.a  
lib/libLLVMRemarks.a  lib/libLLVMBitstreamReader.a  lib/libLLVMSupport.a  
-lpsapi  -lshell32  -lole32  -luuid  -ladvapi32  
D:/WORK/Utilities/MSYS2/mingw64/lib/libz.dll.a  lib/libLLVMDemangle.a  
-lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid 
-lcomdlg32 -ladvapi32 -Wl,--trace


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D95246/new/

https://reviews.llvm.org/D95246

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


[clang] fa7eb3e - [clang][cli] NFC: Remove intermediate command line parsing functions

2021-02-25 Thread Jan Svoboda via cfe-commits

Author: Jan Svoboda
Date: 2021-02-25T13:45:06+01:00
New Revision: fa7eb3e4a60c620b820ff6c616c678f659f4528e

URL: 
https://github.com/llvm/llvm-project/commit/fa7eb3e4a60c620b820ff6c616c678f659f4528e
DIFF: 
https://github.com/llvm/llvm-project/commit/fa7eb3e4a60c620b820ff6c616c678f659f4528e.diff

LOG: [clang][cli] NFC: Remove intermediate command line parsing functions

Patch D96280 moved command line round-tripping from each parsing functions into 
single `CreateFromArgs` function.

This patch cleans up the individual parsing functions, essentially merging 
`ParseXxxImpl` with `ParseXxx`, as the distinction is not necessary anymore.

Reviewed By: dexonsmith

Differential Revision: https://reviews.llvm.org/D96323

Added: 


Modified: 
clang/include/clang/Frontend/CompilerInvocation.h
clang/lib/Frontend/CompilerInvocation.cpp

Removed: 




diff  --git a/clang/include/clang/Frontend/CompilerInvocation.h 
b/clang/include/clang/Frontend/CompilerInvocation.h
index cd3780d9f454..05b7769f20ef 100644
--- a/clang/include/clang/Frontend/CompilerInvocation.h
+++ b/clang/include/clang/Frontend/CompilerInvocation.h
@@ -243,27 +243,14 @@ class CompilerInvocation : public CompilerInvocationBase {
  ArrayRef CommandLineArgs,
  DiagnosticsEngine &Diags, const char *Argv0);
 
-  /// Parse command line options from DiagnosticOptions.
-  static bool ParseDiagnosticArgsRoundTrip(CompilerInvocation &Res,
-   DiagnosticOptions &Opts,
-   llvm::opt::ArgList &Args,
-   DiagnosticsEngine *Diags = nullptr,
-   bool DefaultDiagColor = true);
-
   /// Generate command line options from DiagnosticOptions.
   static void GenerateDiagnosticArgs(const DiagnosticOptions &Opts,
  SmallVectorImpl &Args,
  StringAllocator SA, bool 
DefaultDiagColor);
 
   /// Parse command line options that map to LangOptions.
-  static bool ParseLangArgsImpl(LangOptions &Opts, llvm::opt::ArgList &Args,
-InputKind IK, const llvm::Triple &T,
-std::vector &Includes,
-DiagnosticsEngine &Diags);
-
-  static bool ParseLangArgs(CompilerInvocation &Res, LangOptions &Opts,
-llvm::opt::ArgList &Args, InputKind IK,
-const llvm::Triple &T,
+  static bool ParseLangArgs(LangOptions &Opts, llvm::opt::ArgList &Args,
+InputKind IK, const llvm::Triple &T,
 std::vector &Includes,
 DiagnosticsEngine &Diags);
 
@@ -273,16 +260,9 @@ class CompilerInvocation : public CompilerInvocationBase {
StringAllocator SA, const llvm::Triple &T);
 
   /// Parse command line options that map to CodeGenOptions.
-  static bool ParseCodeGenArgsImpl(CodeGenOptions &Opts,
-   llvm::opt::ArgList &Args, InputKind IK,
-   DiagnosticsEngine &Diags,
-   const llvm::Triple &T,
-   const std::string &OutputFile,
-   const LangOptions &LangOptsRef);
-
-  static bool ParseCodeGenArgs(CompilerInvocation &Res, CodeGenOptions &Opts,
-   llvm::opt::ArgList &Args, InputKind IK,
-   DiagnosticsEngine &Diags, const llvm::Triple &T,
+  static bool ParseCodeGenArgs(CodeGenOptions &Opts, llvm::opt::ArgList &Args,
+   InputKind IK, DiagnosticsEngine &Diags,
+   const llvm::Triple &T,
const std::string &OutputFile,
const LangOptions &LangOptsRef);
 
@@ -292,18 +272,6 @@ class CompilerInvocation : public CompilerInvocationBase {
   StringAllocator SA, const llvm::Triple &T,
   const std::string &OutputFile,
   const LangOptions *LangOpts);
-
-  /// Parse command line options that map to HeaderSearchOptions.
-  static void ParseHeaderSearchArgs(CompilerInvocation &Res,
-HeaderSearchOptions &Opts,
-llvm::opt::ArgList &Args,
-DiagnosticsEngine &Diags,
-const std::string &WorkingDir);
-
-  /// Generate command line options from HeaderSearchOptions.
-  static void GenerateHeaderSearchArgs(HeaderSearchOptions &Opts,
-   SmallVectorImpl &Args,
-  

[PATCH] D96323: [clang][cli] NFC: Remove intermediate command line parsing functions

2021-02-25 Thread Jan Svoboda via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGfa7eb3e4a60c: [clang][cli] NFC: Remove intermediate command 
line parsing functions (authored by jansvoboda11).

Changed prior to commit:
  https://reviews.llvm.org/D96323?vs=322312&id=326359#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D96323/new/

https://reviews.llvm.org/D96323

Files:
  clang/include/clang/Frontend/CompilerInvocation.h
  clang/lib/Frontend/CompilerInvocation.cpp

Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -848,8 +848,8 @@
   // Nothing to generate for FullCompilerInvocation.
 }
 
-static bool ParseAnalyzerArgsImpl(AnalyzerOptions &Opts, ArgList &Args,
-  DiagnosticsEngine &Diags) {
+static bool ParseAnalyzerArgs(AnalyzerOptions &Opts, ArgList &Args,
+  DiagnosticsEngine &Diags) {
   AnalyzerOptions *AnalyzerOpts = &Opts;
   bool Success = true;
 
@@ -1016,11 +1016,6 @@
   return Success;
 }
 
-static bool ParseAnalyzerArgs(CompilerInvocation &Res, AnalyzerOptions &Opts,
-  ArgList &Args, DiagnosticsEngine &Diags) {
-  return ParseAnalyzerArgsImpl(*Res.getAnalyzerOpts(), Args, Diags);
-}
-
 static StringRef getStringOption(AnalyzerOptions::ConfigTable &Config,
  StringRef OptionName, StringRef DefaultVal) {
   return Config.insert({OptionName, std::string(DefaultVal)}).first->second;
@@ -1543,12 +1538,12 @@
   }
 }
 
-bool CompilerInvocation::ParseCodeGenArgsImpl(CodeGenOptions &Opts,
-  ArgList &Args, InputKind IK,
-  DiagnosticsEngine &Diags,
-  const llvm::Triple &T,
-  const std::string &OutputFile,
-  const LangOptions &LangOptsRef) {
+bool CompilerInvocation::ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args,
+  InputKind IK,
+  DiagnosticsEngine &Diags,
+  const llvm::Triple &T,
+  const std::string &OutputFile,
+  const LangOptions &LangOptsRef) {
   unsigned NumErrorsBefore = Diags.getNumErrors();
 
   bool Success = true;
@@ -1950,14 +1945,6 @@
   return Success && Diags.getNumErrors() == NumErrorsBefore;
 }
 
-bool CompilerInvocation::ParseCodeGenArgs(
-CompilerInvocation &Res, CodeGenOptions &Opts, ArgList &Args, InputKind IK,
-DiagnosticsEngine &Diags, const llvm::Triple &T,
-const std::string &OutputFile, const LangOptions &LangOptsRef) {
-  return ParseCodeGenArgsImpl(Res.getCodeGenOpts(), Args, IK, Diags, T,
-  OutputFile, LangOptsRef);
-}
-
 static void
 GenerateDependencyOutputArgs(const DependencyOutputOptions &Opts,
  SmallVectorImpl &Args,
@@ -1997,10 +1984,10 @@
   }
 }
 
-static bool ParseDependencyOutputArgsImpl(
-DependencyOutputOptions &Opts, ArgList &Args,
-DiagnosticsEngine &Diags,
-frontend::ActionKind Action, bool ShowLineMarkers) {
+static bool ParseDependencyOutputArgs(DependencyOutputOptions &Opts,
+  ArgList &Args, DiagnosticsEngine &Diags,
+  frontend::ActionKind Action,
+  bool ShowLineMarkers) {
   unsigned NumErrorsBefore = Diags.getNumErrors();
   bool Success = true;
 
@@ -2065,15 +2052,6 @@
   return Success && Diags.getNumErrors() == NumErrorsBefore;
 }
 
-static bool ParseDependencyOutputArgs(CompilerInvocation &Res,
-  DependencyOutputOptions &Opts,
-  ArgList &Args, DiagnosticsEngine &Diags,
-  frontend::ActionKind Action,
-  bool ShowLineMarkers) {
-  return ParseDependencyOutputArgsImpl(Res.getDependencyOutputOpts(), Args,
-   Diags, Action, ShowLineMarkers);
-}
-
 static bool parseShowColorsArgs(const ArgList &Args, bool DefaultColor) {
   // Color diagnostics default to auto ("on" if terminal supports) in the driver
   // but default to off in cc1, needing an explicit OPT_fdiagnostics_color.
@@ -2330,15 +2308,6 @@
   return Success;
 }
 
-bool CompilerInvocation::ParseDiagnosticArgsRoundTrip(CompilerInvocation &Res,
-  DiagnosticOptions &Opts,
-  ArgList &Args,
-  

[clang] 0c8b26b - [clang] Remove a superfluous semicolon, silencing GCC warnings. NFC.

2021-02-25 Thread Martin Storsjö via cfe-commits

Author: Martin Storsjö
Date: 2021-02-25T14:54:19+02:00
New Revision: 0c8b26bf530b3fc65af9205c593583f26549da3e

URL: 
https://github.com/llvm/llvm-project/commit/0c8b26bf530b3fc65af9205c593583f26549da3e
DIFF: 
https://github.com/llvm/llvm-project/commit/0c8b26bf530b3fc65af9205c593583f26549da3e.diff

LOG: [clang] Remove a superfluous semicolon, silencing GCC warnings. NFC.

Added: 


Modified: 
clang/lib/Frontend/CompilerInvocation.cpp

Removed: 




diff  --git a/clang/lib/Frontend/CompilerInvocation.cpp 
b/clang/lib/Frontend/CompilerInvocation.cpp
index f53cc8bff28c..eb447541124a 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -1147,7 +1147,7 @@ GenerateOptimizationRemark(SmallVectorImpl 
&Args,
   } else if (Remark.Kind == CodeGenOptions::RK_Disabled) {
 GenerateArg(Args, OPT_R_Joined, StringRef("no-") + Name, SA);
   }
-};
+}
 
 /// Parse a remark command line argument. It may be missing, disabled/enabled 
by
 /// '-R[no-]group' or specified with a regular expression by '-Rgroup=regexp'.



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


[PATCH] D95246: [test] Use host platform specific error message substitution in lit tests

2021-02-25 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov added a comment.

@jhenderson
I think I'm done.
Here is output: F15648076: linker_trace_output.txt 

Is it OK now?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D95246/new/

https://reviews.llvm.org/D95246

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


[PATCH] D94640: adds more checks to -Wfree-nonheap-object

2021-02-25 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM, thank you for this!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D94640/new/

https://reviews.llvm.org/D94640

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


[PATCH] D97371: [clang][parser] Remove questionable ProhibitAttributes() call in objc parsing

2021-02-25 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added reviewers: rjmccall, erik.pilkington.
aaron.ballman added a comment.

Adding some more reviewers who know ObjC better than I do.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D97371/new/

https://reviews.llvm.org/D97371

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


[PATCH] D97445: [clang][sema] Ignore xor-used-as-pow if both sides are macros

2021-02-25 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM with a small nit, thanks!




Comment at: clang/lib/Sema/SemaExpr.cpp:12105
 
+  // Do not diagnose if both LHS and RHS are macros
+  if (XorLHS.get()->getExprLoc().isMacroID() &&




Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D97445/new/

https://reviews.llvm.org/D97445

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


[PATCH] D97138: [clang][flang] Improve the consistency of the code-base

2021-02-25 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea accepted this revision.
aganea added a comment.

In D97138#2586988 , 
@achieveartificialintelligence wrote:

> Thanks @aganea. And I have a question that, should I use `argc` & `argv` or 
> `argC` & `argV` in the flang part now ?

Looks good as it is now, thanks!


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D97138/new/

https://reviews.llvm.org/D97138

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


[clang] baebc11 - [clang][driver] Set the input type to Fortran when reading from stdin

2021-02-25 Thread Andrzej Warzynski via cfe-commits

Author: Andrzej Warzynski
Date: 2021-02-25T13:13:42Z
New Revision: baebc1162f810f7bf5de48919054f75a2f81e180

URL: 
https://github.com/llvm/llvm-project/commit/baebc1162f810f7bf5de48919054f75a2f81e180
DIFF: 
https://github.com/llvm/llvm-project/commit/baebc1162f810f7bf5de48919054f75a2f81e180.diff

LOG: [clang][driver] Set the input type to Fortran when reading from stdin

This patch makes sure that for the following invocation of the new Flang
driver, clangDriver sets the input type to Fortran:
```
flang-new -E -
```
This change does not affect `clang`, i.e. for the following invocation
the input type is set to C:
```
clang -E -
```

This change leverages the fact that for `flang-new` the driver is in
Flang mode.

Differential Revision: https://reviews.llvm.org/D96777

Added: 


Modified: 
clang/lib/Driver/Driver.cpp
flang/test/Flang-Driver/input-from-stdin.f90

Removed: 




diff  --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index 8c180140ae92..5aa0011d80ef 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -2191,15 +2191,20 @@ void Driver::BuildInputs(const ToolChain &TC, 
DerivedArgList &Args,
 
 // stdin must be handled specially.
 if (memcmp(Value, "-", 2) == 0) {
-  // If running with -E, treat as a C input (this changes the builtin
-  // macros, for example). This may be overridden by -ObjC below.
-  //
-  // Otherwise emit an error but still use a valid type to avoid
-  // spurious errors (e.g., no inputs).
-  if (!Args.hasArgNoClaim(options::OPT_E) && !CCCIsCPP())
-Diag(IsCLMode() ? clang::diag::err_drv_unknown_stdin_type_clang_cl
-: clang::diag::err_drv_unknown_stdin_type);
-  Ty = types::TY_C;
+  if (IsFlangMode()) {
+Ty = types::TY_Fortran;
+  } else {
+// If running with -E, treat as a C input (this changes the
+// builtin macros, for example). This may be overridden by -ObjC
+// below.
+//
+// Otherwise emit an error but still use a valid type to avoid
+// spurious errors (e.g., no inputs).
+if (!Args.hasArgNoClaim(options::OPT_E) && !CCCIsCPP())
+  Diag(IsCLMode() ? 
clang::diag::err_drv_unknown_stdin_type_clang_cl
+  : clang::diag::err_drv_unknown_stdin_type);
+Ty = types::TY_C;
+  }
 } else {
   // Otherwise lookup by extension.
   // Fallback is C if invoked as C preprocessor, C++ if invoked with

diff  --git a/flang/test/Flang-Driver/input-from-stdin.f90 
b/flang/test/Flang-Driver/input-from-stdin.f90
index 05f99a300c19..d95218abe278 100644
--- a/flang/test/Flang-Driver/input-from-stdin.f90
+++ b/flang/test/Flang-Driver/input-from-stdin.f90
@@ -5,19 +5,22 @@
 !--
 ! FLANG DRIVER (flang-new)
 !--
-! TODO: Add support for `flang-new -`
-! Currently `bin/flang-new  -E -` defaults to `-x c` and e.g. F90 is not 
allowed
-! in `-x ` (see `clang::driver::types::canTypeBeUserSpecified` in
-! Types.cpp)
+! Input type is implicit
+! RUN: cat %s | flang-new -E - | FileCheck %s --check-prefix=PP-NOT-DEFINED
+! RUN: cat %s | flang-new -DNEW -E - | FileCheck %s --check-prefix=PP-DEFINED
+
+! Input type is explicit
+! RUN: cat %s | flang-new -E -x f95-cpp-input - | FileCheck %s 
--check-prefix=PP-NOT-DEFINED
+! RUN: cat %s | flang-new -DNEW -E -x f95-cpp-input - | FileCheck %s 
--check-prefix=PP-DEFINED
 
 !---
 ! FLANG FRONTEND DRIVER (flang-new -fc1)
 !---
-! Test `-E` - for the corresponding frontend actions the driver relies on the 
prescanner API to handle file I/O
+! Test `-E`: for the corresponding frontend actions the driver relies on the 
prescanner API to handle file I/O
 ! RUN: cat %s | flang-new -fc1 -E | FileCheck %s --check-prefix=PP-NOT-DEFINED
 ! RUN: cat %s | flang-new -fc1 -DNEW -E | FileCheck %s 
--check-prefix=PP-DEFINED
 
-! Test `-test-io` - for the corresponding frontend action 
(`InputOutputTestAction`) the driver handles the file I/O on its own
+! Test `-test-io`: for the corresponding frontend action 
(`InputOutputTestAction`) the driver handles the file I/O on its own
 ! the corresponding action (`PrintPreprocessedAction`)
 ! RUN: cat %s | flang-new -fc1 -test-io | FileCheck %s --check-prefix=IO 
--match-full-lines
 ! RUN: cat %s | flang-new -fc1 -DNEW -test-io | FileCheck %s --check-prefix=IO 
--match-full-lines



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


[PATCH] D96777: [clang][driver] Set the input type to Fortran when reading from stdin

2021-02-25 Thread Andrzej Warzynski via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGbaebc1162f81: [clang][driver] Set the input type to Fortran 
when reading from stdin (authored by awarzynski).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D96777/new/

https://reviews.llvm.org/D96777

Files:
  clang/lib/Driver/Driver.cpp
  flang/test/Flang-Driver/input-from-stdin.f90


Index: flang/test/Flang-Driver/input-from-stdin.f90
===
--- flang/test/Flang-Driver/input-from-stdin.f90
+++ flang/test/Flang-Driver/input-from-stdin.f90
@@ -5,19 +5,22 @@
 !--
 ! FLANG DRIVER (flang-new)
 !--
-! TODO: Add support for `flang-new -`
-! Currently `bin/flang-new  -E -` defaults to `-x c` and e.g. F90 is not 
allowed
-! in `-x ` (see `clang::driver::types::canTypeBeUserSpecified` in
-! Types.cpp)
+! Input type is implicit
+! RUN: cat %s | flang-new -E - | FileCheck %s --check-prefix=PP-NOT-DEFINED
+! RUN: cat %s | flang-new -DNEW -E - | FileCheck %s --check-prefix=PP-DEFINED
+
+! Input type is explicit
+! RUN: cat %s | flang-new -E -x f95-cpp-input - | FileCheck %s 
--check-prefix=PP-NOT-DEFINED
+! RUN: cat %s | flang-new -DNEW -E -x f95-cpp-input - | FileCheck %s 
--check-prefix=PP-DEFINED
 
 !---
 ! FLANG FRONTEND DRIVER (flang-new -fc1)
 !---
-! Test `-E` - for the corresponding frontend actions the driver relies on the 
prescanner API to handle file I/O
+! Test `-E`: for the corresponding frontend actions the driver relies on the 
prescanner API to handle file I/O
 ! RUN: cat %s | flang-new -fc1 -E | FileCheck %s --check-prefix=PP-NOT-DEFINED
 ! RUN: cat %s | flang-new -fc1 -DNEW -E | FileCheck %s 
--check-prefix=PP-DEFINED
 
-! Test `-test-io` - for the corresponding frontend action 
(`InputOutputTestAction`) the driver handles the file I/O on its own
+! Test `-test-io`: for the corresponding frontend action 
(`InputOutputTestAction`) the driver handles the file I/O on its own
 ! the corresponding action (`PrintPreprocessedAction`)
 ! RUN: cat %s | flang-new -fc1 -test-io | FileCheck %s --check-prefix=IO 
--match-full-lines
 ! RUN: cat %s | flang-new -fc1 -DNEW -test-io | FileCheck %s --check-prefix=IO 
--match-full-lines
Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -2191,15 +2191,20 @@
 
 // stdin must be handled specially.
 if (memcmp(Value, "-", 2) == 0) {
-  // If running with -E, treat as a C input (this changes the builtin
-  // macros, for example). This may be overridden by -ObjC below.
-  //
-  // Otherwise emit an error but still use a valid type to avoid
-  // spurious errors (e.g., no inputs).
-  if (!Args.hasArgNoClaim(options::OPT_E) && !CCCIsCPP())
-Diag(IsCLMode() ? clang::diag::err_drv_unknown_stdin_type_clang_cl
-: clang::diag::err_drv_unknown_stdin_type);
-  Ty = types::TY_C;
+  if (IsFlangMode()) {
+Ty = types::TY_Fortran;
+  } else {
+// If running with -E, treat as a C input (this changes the
+// builtin macros, for example). This may be overridden by -ObjC
+// below.
+//
+// Otherwise emit an error but still use a valid type to avoid
+// spurious errors (e.g., no inputs).
+if (!Args.hasArgNoClaim(options::OPT_E) && !CCCIsCPP())
+  Diag(IsCLMode() ? 
clang::diag::err_drv_unknown_stdin_type_clang_cl
+  : clang::diag::err_drv_unknown_stdin_type);
+Ty = types::TY_C;
+  }
 } else {
   // Otherwise lookup by extension.
   // Fallback is C if invoked as C preprocessor, C++ if invoked with


Index: flang/test/Flang-Driver/input-from-stdin.f90
===
--- flang/test/Flang-Driver/input-from-stdin.f90
+++ flang/test/Flang-Driver/input-from-stdin.f90
@@ -5,19 +5,22 @@
 !--
 ! FLANG DRIVER (flang-new)
 !--
-! TODO: Add support for `flang-new -`
-! Currently `bin/flang-new  -E -` defaults to `-x c` and e.g. F90 is not allowed
-! in `-x ` (see `clang::driver::types::canTypeBeUserSpecified` in
-! Types.cpp)
+! Input type is implicit
+! RUN: cat %s | flang-new -E - | FileCheck %s --check-prefix=PP-NOT-DEFINED
+! RUN: cat %s | flang-new -DNEW -E - | FileCheck %s --check-prefix=PP-DEFINED
+
+! Input type is explicit
+! RUN: cat %s | flang-new -E -x f95-cpp-input - | FileCheck %s --check-prefix=PP-NOT-DEFINED
+! RUN: cat %s | flang-new -DNEW -E -x f95-cpp-input - | FileCheck %s --check-prefix=PP-DEFINED
 
 !---
 ! FLAN

[PATCH] D97138: [clang][flang] Improve the consistency of the code-base

2021-02-25 Thread Andrzej Warzynski via Phabricator via cfe-commits
awarzynski accepted this revision.
awarzynski added a comment.
This revision is now accepted and ready to land.

Thank you, this is a much appreciated improvement!


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D97138/new/

https://reviews.llvm.org/D97138

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


[clang] ad14ccc - [clang][flang] Improve the consistency of the code-base

2021-02-25 Thread Shao-Ce Sun via cfe-commits

Author: Shao-Ce Sun
Date: 2021-02-25T21:25:43+08:00
New Revision: ad14ccc8c22e1480db7bfc1a176311e6f572c588

URL: 
https://github.com/llvm/llvm-project/commit/ad14ccc8c22e1480db7bfc1a176311e6f572c588
DIFF: 
https://github.com/llvm/llvm-project/commit/ad14ccc8c22e1480db7bfc1a176311e6f572c588.diff

LOG: [clang][flang] Improve the consistency of the code-base

In clang:
Replace argc_ with Argc
Replace argv_ with Argv
Replace argv with Args
In flang:
Replace argc_ with argc
Replace argv_ with argv
Replace argv with args

Reviewed By: awarzynski, aganea

Differential Revision: https://reviews.llvm.org/D97138

Added: 


Modified: 
clang/tools/driver/driver.cpp
flang/tools/flang-driver/driver.cpp

Removed: 




diff  --git a/clang/tools/driver/driver.cpp b/clang/tools/driver/driver.cpp
index f67af6790fff..a13c1c4a3834 100644
--- a/clang/tools/driver/driver.cpp
+++ b/clang/tools/driver/driver.cpp
@@ -340,25 +340,25 @@ static int ExecuteCC1Tool(SmallVectorImpl 
&ArgV) {
   return 1;
 }
 
-int main(int argc_, const char **argv_) {
+int main(int Argc, const char **Argv) {
   noteBottomOfStack();
-  llvm::InitLLVM X(argc_, argv_);
+  llvm::InitLLVM X(Argc, Argv);
   llvm::setBugReportMsg("PLEASE submit a bug report to " BUG_REPORT_URL
 " and include the crash backtrace, preprocessed "
 "source, and associated run script.\n");
-  SmallVector argv(argv_, argv_ + argc_);
+  SmallVector Args(Argv, Argv + Argc);
 
   if (llvm::sys::Process::FixupStandardFileDescriptors())
 return 1;
 
   llvm::InitializeAllTargets();
-  auto TargetAndMode = ToolChain::getTargetAndModeFromProgramName(argv[0]);
+  auto TargetAndMode = ToolChain::getTargetAndModeFromProgramName(Args[0]);
 
   llvm::BumpPtrAllocator A;
   llvm::StringSaver Saver(A);
 
   // Parse response files using the GNU syntax, unless we're in CL mode. There
-  // are two ways to put clang in CL compatibility mode: argv[0] is either
+  // are two ways to put clang in CL compatibility mode: Args[0] is either
   // clang-cl or cl, or --driver-mode=cl is on the command line. The normal
   // command line parsing can't happen until after response file parsing, so we
   // have to manually search for a --driver-mode=cl argument the hard way.
@@ -366,20 +366,20 @@ int main(int argc_, const char **argv_) {
   // response files written by clang will tokenize the same way in either mode.
   bool ClangCLMode = false;
   if (StringRef(TargetAndMode.DriverMode).equals("--driver-mode=cl") ||
-  llvm::find_if(argv, [](const char *F) {
+  llvm::find_if(Args, [](const char *F) {
 return F && strcmp(F, "--driver-mode=cl") == 0;
-  }) != argv.end()) {
+  }) != Args.end()) {
 ClangCLMode = true;
   }
   enum { Default, POSIX, Windows } RSPQuoting = Default;
-  for (const char *F : argv) {
+  for (const char *F : Args) {
 if (strcmp(F, "--rsp-quoting=posix") == 0)
   RSPQuoting = POSIX;
 else if (strcmp(F, "--rsp-quoting=windows") == 0)
   RSPQuoting = Windows;
   }
 
-  // Determines whether we want nullptr markers in argv to indicate response
+  // Determines whether we want nullptr markers in Args to indicate response
   // files end-of-lines. We only use this for the /LINK driver argument with
   // clang-cl.exe on Windows.
   bool MarkEOLs = ClangCLMode;
@@ -390,31 +390,31 @@ int main(int argc_, const char **argv_) {
   else
 Tokenizer = &llvm::cl::TokenizeGNUCommandLine;
 
-  if (MarkEOLs && argv.size() > 1 && StringRef(argv[1]).startswith("-cc1"))
+  if (MarkEOLs && Args.size() > 1 && StringRef(Args[1]).startswith("-cc1"))
 MarkEOLs = false;
-  llvm::cl::ExpandResponseFiles(Saver, Tokenizer, argv, MarkEOLs);
+  llvm::cl::ExpandResponseFiles(Saver, Tokenizer, Args, MarkEOLs);
 
   // Handle -cc1 integrated tools, even if -cc1 was expanded from a response
   // file.
-  auto FirstArg = std::find_if(argv.begin() + 1, argv.end(),
+  auto FirstArg = std::find_if(Args.begin() + 1, Args.end(),
[](const char *A) { return A != nullptr; });
-  if (FirstArg != argv.end() && StringRef(*FirstArg).startswith("-cc1")) {
+  if (FirstArg != Args.end() && StringRef(*FirstArg).startswith("-cc1")) {
 // If -cc1 came from a response file, remove the EOL sentinels.
 if (MarkEOLs) {
-  auto newEnd = std::remove(argv.begin(), argv.end(), nullptr);
-  argv.resize(newEnd - argv.begin());
+  auto newEnd = std::remove(Args.begin(), Args.end(), nullptr);
+  Args.resize(newEnd - Args.begin());
 }
-return ExecuteCC1Tool(argv);
+return ExecuteCC1Tool(Args);
   }
 
   // Handle options that need handling before the real command line parsing in
   // Driver::BuildCompilation()
   bool CanonicalPrefixes = true;
-  for (int i = 1, size = argv.size(); i < size; ++i) {
+  for (int i = 1, size = Args.size(); i < size; ++i) {
 // Skip end-of-line response f

[PATCH] D97138: [clang][flang] Improve the consistency of the code-base

2021-02-25 Thread Shao-Ce Sun via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGad14ccc8c22e: [clang][flang] Improve the consistency of the 
code-base (authored by achieveartificialintelligence).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D97138/new/

https://reviews.llvm.org/D97138

Files:
  clang/tools/driver/driver.cpp
  flang/tools/flang-driver/driver.cpp

Index: flang/tools/flang-driver/driver.cpp
===
--- flang/tools/flang-driver/driver.cpp
+++ flang/tools/flang-driver/driver.cpp
@@ -66,27 +66,27 @@
   return 1;
 }
 
-int main(int argc_, const char **argv_) {
+int main(int argc, const char **argv) {
 
   // Initialize variables to call the driver
-  llvm::InitLLVM x(argc_, argv_);
-  llvm::SmallVector argv(argv_, argv_ + argc_);
+  llvm::InitLLVM x(argc, argv);
+  llvm::SmallVector args(argv, argv + argc);
 
   clang::driver::ParsedClangName targetandMode("flang", "--driver-mode=flang");
-  std::string driverPath = GetExecutablePath(argv[0]);
+  std::string driverPath = GetExecutablePath(args[0]);
 
   // Check if flang-new is in the frontend mode
   auto firstArg = std::find_if(
-  argv.begin() + 1, argv.end(), [](const char *a) { return a != nullptr; });
-  if (firstArg != argv.end()) {
-if (llvm::StringRef(argv[1]).startswith("-cc1")) {
-  llvm::errs() << "error: unknown integrated tool '" << argv[1] << "'. "
+  args.begin() + 1, args.end(), [](const char *a) { return a != nullptr; });
+  if (firstArg != args.end()) {
+if (llvm::StringRef(args[1]).startswith("-cc1")) {
+  llvm::errs() << "error: unknown integrated tool '" << args[1] << "'. "
<< "Valid tools include '-fc1'.\n";
   return 1;
 }
 // Call flang-new frontend
-if (llvm::StringRef(argv[1]).startswith("-fc1")) {
-  return ExecuteFC1Tool(argv);
+if (llvm::StringRef(args[1]).startswith("-fc1")) {
+  return ExecuteFC1Tool(args);
 }
   }
 
@@ -94,14 +94,14 @@
 
   // Create DiagnosticsEngine for the compiler driver
   llvm::IntrusiveRefCntPtr diagOpts =
-  CreateAndPopulateDiagOpts(argv);
+  CreateAndPopulateDiagOpts(args);
   llvm::IntrusiveRefCntPtr diagID(
   new clang::DiagnosticIDs());
   Fortran::frontend::TextDiagnosticPrinter *diagClient =
   new Fortran::frontend::TextDiagnosticPrinter(llvm::errs(), &*diagOpts);
 
   diagClient->set_prefix(
-  std::string(llvm::sys::path::stem(GetExecutablePath(argv[0];
+  std::string(llvm::sys::path::stem(GetExecutablePath(args[0];
 
   clang::DiagnosticsEngine diags(diagID, &*diagOpts, diagClient);
 
@@ -110,7 +110,7 @@
   llvm::sys::getDefaultTargetTriple(), diags, "flang LLVM compiler");
   theDriver.setTargetAndMode(targetandMode);
   std::unique_ptr c(
-  theDriver.BuildCompilation(argv));
+  theDriver.BuildCompilation(args));
   llvm::SmallVector, 4>
   failingCommands;
 
Index: clang/tools/driver/driver.cpp
===
--- clang/tools/driver/driver.cpp
+++ clang/tools/driver/driver.cpp
@@ -340,25 +340,25 @@
   return 1;
 }
 
-int main(int argc_, const char **argv_) {
+int main(int Argc, const char **Argv) {
   noteBottomOfStack();
-  llvm::InitLLVM X(argc_, argv_);
+  llvm::InitLLVM X(Argc, Argv);
   llvm::setBugReportMsg("PLEASE submit a bug report to " BUG_REPORT_URL
 " and include the crash backtrace, preprocessed "
 "source, and associated run script.\n");
-  SmallVector argv(argv_, argv_ + argc_);
+  SmallVector Args(Argv, Argv + Argc);
 
   if (llvm::sys::Process::FixupStandardFileDescriptors())
 return 1;
 
   llvm::InitializeAllTargets();
-  auto TargetAndMode = ToolChain::getTargetAndModeFromProgramName(argv[0]);
+  auto TargetAndMode = ToolChain::getTargetAndModeFromProgramName(Args[0]);
 
   llvm::BumpPtrAllocator A;
   llvm::StringSaver Saver(A);
 
   // Parse response files using the GNU syntax, unless we're in CL mode. There
-  // are two ways to put clang in CL compatibility mode: argv[0] is either
+  // are two ways to put clang in CL compatibility mode: Args[0] is either
   // clang-cl or cl, or --driver-mode=cl is on the command line. The normal
   // command line parsing can't happen until after response file parsing, so we
   // have to manually search for a --driver-mode=cl argument the hard way.
@@ -366,20 +366,20 @@
   // response files written by clang will tokenize the same way in either mode.
   bool ClangCLMode = false;
   if (StringRef(TargetAndMode.DriverMode).equals("--driver-mode=cl") ||
-  llvm::find_if(argv, [](const char *F) {
+  llvm::find_if(Args, [](const char *F) {
 return F && strcmp(F, "--driver-mode=cl") == 0;
-  }) != argv.end()) {
+  }) != Args.end()) {
 ClangCLMode = true;
   }
   enum { Default, POSIX, Windows } RS

[PATCH] D95246: [test] Use host platform specific error message substitution in lit tests

2021-02-25 Thread James Henderson via Phabricator via cfe-commits
jhenderson added a comment.

In D95246#2587410 , @ASDenysPetrov 
wrote:

> @jhenderson
> I think I'm done.
> Here is output: F15648076: linker_trace_output.txt 
> 
> Is it OK now?

Thanks, yes that does the trick. As I expected, you can see that all the 
libraries that are used are contained withing the msys2/mingw subdirectory, and 
therefore are not the standard Windows SDK files that you would typically use 
for a Windows build using Visual Studio. One of those will contain the 
definitions we are talking about.

@abhina.sreeskantharajan - I think you could this issue in one of two ways. One 
would be to detect when the tools/libraries used are within the msys2/mingw 
installation. Another way might be to actually build and run a miniature 
program at CMake time that prints out the messages, in such a way that CMake 
can inspect the output and use it to populate the lit configuration. Note: I am 
not a CMake expert, so don't know if this is strictly possible. The advantage 
of this approach is that you can remove the reliance on the system.platform 
call in python, and just always use the output of this simple program.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D95246/new/

https://reviews.llvm.org/D95246

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


[PATCH] D97362: [clang][parser] Allow attributes in explicit template instantiations

2021-02-25 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a reviewer: rsmith.
aaron.ballman added a comment.

I don't think that's dead code, but I do think it's unclear code that should be 
fixed.

The behavior for double square bracket attributes in C++ is correct in Clang 
and incorrect in GCC, according to: 
http://eel.is/c++draft/temp.explicit#3.sentence-3. Adding a comment to that 
effect would be reasonable so there's not confusion again in the future.

Based on empirical testing, I think the GNU-style attribute should continue to 
be accepted in that position as it has effect in GCC.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D97362/new/

https://reviews.llvm.org/D97362

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


[PATCH] D97423: Fix a test case that checks should check whether or not it is passed into lld

2021-02-25 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl accepted this revision.
yaxunl added a comment.
This revision is now accepted and ready to land.

LGTM. Thanks.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D97423/new/

https://reviews.llvm.org/D97423

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


[PATCH] D97415: [clang-tidy] Move Checkname out of Diagnostic Message

2021-02-25 Thread Nathan James via Phabricator via cfe-commits
njames93 created this revision.
njames93 added reviewers: alexfh, aaron.ballman.
Herald added subscribers: usaxena95, kadircet, arphaman, xazax.hun.
njames93 published this revision for review.
njames93 added a subscriber: NoQ.
njames93 added a comment.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

@NoQ This may have a little impact on D95403 , 
but from what I can see nothing mayor would conflict. It was fairly easy to fix 
up clang d integration.




Comment at: clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp:170-171
+  auto Res = DiagEngine->Report(Loc, ID);
+  // Repurpse the Flag value to store the check name. clang-tidy checks don't
+  // have command line flags so this field is safe ro use, but add a prefix 
just
+  // to be sure.




Repurpose the FlagValue field in DiagnosticEngine to store the Checkname.
This removes the need to remove the checkname from the message when we process 
the diagnostic later.

I looked at a few options and FlagValue seems the simplest way to implement 
this.
Its only ever read when there is a warning option for the given DiagnosticID, 
which will never happen for clang-tidy checks.

Removing the Checkname is also a necessary first step if we ever want to 
support tablegen diagnostics route for clang-tidy.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D97415

Files:
  clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
  clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h
  clang-tools-extra/clangd/Diagnostics.cpp
  clang-tools-extra/clangd/ParsedAST.cpp

Index: clang-tools-extra/clangd/ParsedAST.cpp
===
--- clang-tools-extra/clangd/ParsedAST.cpp
+++ clang-tools-extra/clangd/ParsedAST.cpp
@@ -323,9 +323,10 @@
   isBuiltinDiagnosticSuppressed(Info.getID(), Cfg.Diagnostics.Suppress))
 return DiagnosticsEngine::Ignored;
   if (!CTChecks.empty()) {
-std::string CheckName = CTContext->getCheckName(Info.getID());
-bool IsClangTidyDiag = !CheckName.empty();
-if (IsClangTidyDiag) {
+SmallString<64> Buffer;
+auto CheckName =
+tidy::ClangTidyContext::getDiagnosticName(Info, Buffer);
+if (!CheckName.empty()) {
   if (Cfg.Diagnostics.Suppress.contains(CheckName))
 return DiagnosticsEngine::Ignored;
   // Check for suppression comment. Skip the check for diagnostics not
Index: clang-tools-extra/clangd/Diagnostics.cpp
===
--- clang-tools-extra/clangd/Diagnostics.cpp
+++ clang-tools-extra/clangd/Diagnostics.cpp
@@ -517,24 +517,8 @@
   continue;
 }
 if (Tidy != nullptr) {
-  std::string TidyDiag = Tidy->getCheckName(Diag.ID);
-  if (!TidyDiag.empty()) {
-Diag.Name = std::move(TidyDiag);
+  if (!Diag.Name.empty()) {
 Diag.Source = Diag::ClangTidy;
-// clang-tidy bakes the name into diagnostic messages. Strip it out.
-// It would be much nicer to make clang-tidy not do this.
-auto CleanMessage = [&](std::string &Msg) {
-  StringRef Rest(Msg);
-  if (Rest.consume_back("]") && Rest.consume_back(Diag.Name) &&
-  Rest.consume_back(" ["))
-Msg.resize(Rest.size());
-};
-CleanMessage(Diag.Message);
-for (auto &Note : Diag.Notes)
-  CleanMessage(Note.Message);
-for (auto &Fix : Diag.Fixes)
-  CleanMessage(Fix.Message);
-continue;
   }
 }
   }
@@ -624,6 +608,7 @@
 LastDiagLoc.reset();
 LastDiagOriginallyError = OriginallyError;
 LastDiag->ID = Info.getID();
+LastDiag->Name = tidy::ClangTidyContext::getDiagnosticName(Info);
 fillNonLocationData(DiagLevel, Info, *LastDiag);
 LastDiag->InsideMainFile = true;
 // Put it at the start of the main file, for a lack of a better place.
@@ -734,6 +719,7 @@
 
 LastDiag = Diag();
 FillDiagBase(*LastDiag);
+LastDiag->Name = tidy::ClangTidyContext::getDiagnosticName(Info);
 LastDiagLoc.emplace(Info.getLocation(), Info.getSourceManager());
 LastDiagOriginallyError = OriginallyError;
 
Index: clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h
===
--- clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h
+++ clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h
@@ -123,7 +123,10 @@
 
   /// Returns the name of the clang-tidy check which produced this
   /// diagnostic ID.
-  std::string getCheckName(unsigned DiagnosticID) const;
+  static StringRef getDiagnosticName(const Diagnostic &Info,
+ SmallVectorImpl &Buffer);
+
+  static std::string getDiagnosticName(const Diagnostic &Info);
 
   /// Returns \c true if the check is enabled for the \c CurrentFile.
   ///
@@ -2

[PATCH] D96224: [clang-itdy] Simplify virtual near-miss check

2021-02-25 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel added a comment.

In D96224#2581501 , @njames93 wrote:

> Can you take a look at https://llvm.org/PR49330, I'm guessing this patch 
> introduced this regression.

+1 We've had to disable the check in the meantime.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D96224/new/

https://reviews.llvm.org/D96224

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


[PATCH] D97361: [clang-tidy] Add readability-redundant-using check

2021-02-25 Thread Balázs Kéri via Phabricator via cfe-commits
balazske added inline comments.



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/readability-redundant-using.cpp:114
+// CHECK-FIXES: {{^}}
+} // namespace n11

Add more tests?
```
namespace outer {
namespace inner {
void func();
} // namespace inner
using inner::func();
} // namespace outer

using namespace outer;
using namespace inner;
```



Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D97361/new/

https://reviews.llvm.org/D97361

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


[PATCH] D96976: [analyzer] Fix reinterpret_cast handling for pointer-to-member

2021-02-25 Thread Deep Majumder via Phabricator via cfe-commits
RedDocMD marked 2 inline comments as done.
RedDocMD added a comment.

Many thanks for you comments, @steakhal!
I will address the issues you have pointed out in this comment. To clean things 
up I should perhaps add some more clarification to the summary.

> Could you elaborate on what approach did you choose and more importantly, why 
> that approach?
> Why do we need a graph search here?

Pointer-to-members contain two things - a pointer to a NamedDecl to store the 
field/method being pointed to and a list of CXXBaseSpeciifier. This list is 
used to determine which sub-object the member lies in. This path needs to be 
determined and unfortunately with `reinterpret_cast`, the AST provides no 
structural assistance (unlike `static_cast`). Hence, it needs to be searched by 
searching through the BaseSpecifiers of the `CXXRecordDecl`.
As for the need of graph search, it is due to multiple-inheritance. For a given 
class, it may have two or more bases and we need to follow into both of them to 
find the path to the required sub-object.
Why do I use BFS? Because one branch of the (inverted) inheritance tree may be 
very deep yet not contain the required class. But DFS will first exhaust it and 
then go the other branch. BFS on the other hand will find the shortest path to 
the correct base optimally, and this shortest path is all we need.

> What cases do you try to resolve? I mean, there is a single test-case, which 
> has reinterpret casts back and forth (literally), and it's not immediately 
> clear to me why are you doing those gymnastics.
> Maybe worth creating other test-cases as well. Probably covering multiple 
> inheritance or virtual inheritance?

I will add a test case for multiple inheritance and perhaps replace existing 
tests with clearer tests. Virtual inheritance will not help since 
pointer-to-member to virtual base field/method is not allowed.
There are three cases which I have handled:

1. The required class is the class we are casting to
2. The required class is higher in the class hierarchy
3. The required class is lower in the class hierarchy
4. The required class is not related to the class being cast to.

For Case 1 and 2, a valid path can be calculated and so a pointer-to-member is 
created.
For Case 3 and 4, no valid path can be calculated and so it doesn't make sense 
to further pursue static analysis down this path.
Note that the required class is determined by the actual field/member we are 
pointing to and is not explicit in the `reinterpret_cast`.

> Your code has shared pointers, which is interesting, but I would favor unique 
> pointers unless you can defend this use-case.

The reason for not using `unique_ptr` is as follows:- each `BFSNode` holds a 
pointer to its parent. This cannot be a `unique_ptr` since there may be 
multiple children to a `BFSNode`. This must be a `shared_ptr` as a consequence.

> Also, in general, we prefer algorithms to raw for or while loops if they are 
> semantically equivalent.

I am not aware of any std/LLVM algorithm that perform BFS. If there are any, I 
would be glad to learn more about them.
I am going to replace the for loops with a range-for loop. Sorry about that one!

> Besides all of these, I can see a few copy-pasted lines here and there. I'm 
> not saying that it's bad, I'm just highlighting this fact.

Yes this was a conscious choice. The other alternative perhaps is to use 
fall-through, which I think would be confusing in this case since it will be 
obscured by the intermediate code.




Comment at: clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp:554-555
+}
+// Explicitly proceed with default handler for this case cascade.
+state = handleLVectorSplat(state, LCtx, CastE, Bldr, Pred);
+continue;

steakhal wrote:
> I know that you just copy-pasted this, but what is this xD
> I know that you just copy-pasted this, but what is this xD

Not entirely sure, but I think it performs tasks required to handle the 
pointer-to-member created or do the requisite default in the absence of a 
pointer-to-member.



Comment at: clang/test/Analysis/reinterpret-cast-pointer-to-member.cpp:5
 
 // TODO: The following test will work properly once reinterpret_cast on 
pointer-to-member is handled properly
 namespace testReinterpretCasting {

steakhal wrote:
> I assume this is resolved by now.
> I assume this is resolved by now.

Sorry, that was a lame mistake on my part.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D96976/new/

https://reviews.llvm.org/D96976

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


[PATCH] D95246: [test] Use host platform specific error message substitution in lit tests

2021-02-25 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan added a comment.

In D95246#2587452 , @jhenderson wrote:

> In D95246#2587410 , @ASDenysPetrov 
> wrote:
>
>> @jhenderson
>> I think I'm done.
>> Here is output: F15648076: linker_trace_output.txt 
>> 
>> Is it OK now?
>
> Thanks, yes that does the trick. As I expected, you can see that all the 
> libraries that are used are contained withing the msys2/mingw subdirectory, 
> and therefore are not the standard Windows SDK files that you would typically 
> use for a Windows build using Visual Studio. One of those will contain the 
> definitions we are talking about.
>
> @abhina.sreeskantharajan - I think you could this issue in one of two ways. 
> One would be to detect when the tools/libraries used are within the 
> msys2/mingw installation. Another way might be to actually build and run a 
> miniature program at CMake time that prints out the messages, in such a way 
> that CMake can inspect the output and use it to populate the lit 
> configuration. Note: I am not a CMake expert, so don't know if this is 
> strictly possible. The advantage of this approach is that you can remove the 
> reliance on the system.platform call in python, and just always use the 
> output of this simple program.

Thanks, I'm also not sure if the second way is possible. I had another idea but 
I will need @ASDenysPetrov to test it out.
Does the following python program print out the correct error string for you?

  import errno
  import os
  print ( os.strerror(errno.ENOENT))

If so, we can use this as the error message instead of hardcoding it per 
platform.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D95246/new/

https://reviews.llvm.org/D95246

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


[PATCH] D97457: [flang][driver] Add `-fdebug-dump-parsing-log`

2021-02-25 Thread Andrzej Warzynski via Phabricator via cfe-commits
awarzynski updated this revision to Diff 326372.
awarzynski added a comment.

Remove spurious comments


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D97457/new/

https://reviews.llvm.org/D97457

Files:
  clang/include/clang/Driver/Options.td
  flang/include/flang/Frontend/FrontendActions.h
  flang/include/flang/Frontend/FrontendOptions.h
  flang/lib/Frontend/CompilerInvocation.cpp
  flang/lib/Frontend/FrontendActions.cpp
  flang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
  flang/test/Flang-Driver/debug-parsing-log.f90
  flang/test/Flang-Driver/driver-help.f90
  flang/tools/f18/f18.cpp

Index: flang/tools/f18/f18.cpp
===
--- flang/tools/f18/f18.cpp
+++ flang/tools/f18/f18.cpp
@@ -536,7 +536,8 @@
   driver.debugModuleWriter = true;
 } else if (arg == "-fdebug-measure-parse-tree") {
   driver.measureTree = true;
-} else if (arg == "-fdebug-instrumented-parse") {
+} else if (arg == "-fdebug-instrumented-parse" ||
+arg == "-fdebug-dump-parsing-log") {
   options.instrumentedParse = true;
 } else if (arg == "-fdebug-no-semantics") {
   driver.debugNoSemantics = true;
Index: flang/test/Flang-Driver/driver-help.f90
===
--- flang/test/Flang-Driver/driver-help.f90
+++ flang/test/Flang-Driver/driver-help.f90
@@ -58,6 +58,8 @@
 ! HELP-FC1-NEXT: Enable the old style PARAMETER statement
 ! HELP-FC1-NEXT: -fbackslashSpecify that backslash in string introduces an escape character
 ! HELP-FC1-NEXT: -fdebug-dump-parse-tree Dump the parse tree
+! HELP-FC1-NEXT: -fdebug-dump-parsing-log
+! HELP-FC1-NEXT:   Run instrumented parse and dump the parsing log
 ! HELP-FC1-NEXT: -fdebug-dump-provenance Dump provenance
 ! HELP-FC1-NEXT: -fdebug-dump-symbolsDump symbols after the semantic analysis
 ! HELP-FC1-NEXT: -fdebug-measure-parse-tree
Index: flang/test/Flang-Driver/debug-parsing-log.f90
===
--- /dev/null
+++ flang/test/Flang-Driver/debug-parsing-log.f90
@@ -0,0 +1,24 @@
+! RUN: %flang_fc1 -fdebug-dump-parsing-log %s  2>&1 | FileCheck %s
+
+!-
+! EXPECTED OUTPUT
+!-
+! Below are just few lines extracted from the dump. The actual output is much _much_ bigger.
+
+! CHECK: MODULE statement
+! CHECK:   fail 1
+! CHECK: module
+! CHECK:   fail 1
+! CHECK: END PROGRAM statement
+! CHECK:   pass 1
+! CHECK: PROGRAM statement
+! CHECK:   fail 1
+! CHECK: main program
+! CHECK:   pass 1
+! CHECK: specification construct
+! CHECK:   fail 2
+
+!-
+! TEST INPUT
+!-
+END PROGRAM
Index: flang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
===
--- flang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
+++ flang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
@@ -52,6 +52,9 @@
   case DebugDumpProvenance:
 return std::make_unique();
 break;
+  case DebugDumpParsingLog:
+return std::make_unique();
+break;
   case DebugMeasureParseTree:
 return std::make_unique();
 break;
Index: flang/lib/Frontend/FrontendActions.cpp
===
--- flang/lib/Frontend/FrontendActions.cpp
+++ flang/lib/Frontend/FrontendActions.cpp
@@ -307,6 +307,13 @@
   }
 }
 
+void DebugDumpParsingLogAction::ExecuteAction() {
+  CompilerInstance &ci = this->instance();
+
+  ci.parsing().Parse(llvm::errs());
+  ci.parsing().DumpParsingLog(llvm::outs());
+}
+
 void EmitObjAction::ExecuteAction() {
   CompilerInstance &ci = this->instance();
   unsigned DiagID = ci.diagnostics().getCustomDiagID(
Index: flang/lib/Frontend/CompilerInvocation.cpp
===
--- flang/lib/Frontend/CompilerInvocation.cpp
+++ flang/lib/Frontend/CompilerInvocation.cpp
@@ -85,6 +85,15 @@
   return true;
 }
 
+// Tweak the frontend configuration based on the frontend action
+static void setUpFrontendBasedOnAction(FrontendOptions &opts) {
+  assert(opts.programAction_ != Fortran::frontend::InvalidAction &&
+  "Fortran frontend action not set!");
+
+  if (opts.programAction_ == DebugDumpParsingLog)
+opts.instrumentedParse_ = true;
+}
+
 static InputKind ParseFrontendArgs(FrontendOptions &opts,
 llvm::opt::ArgList &args, clang::DiagnosticsEngine &diags) {
 
@@ -125,6 +134,9 @@
 case clang::driver::options::OPT_fdebug_dump_provenance:
   opts.programAction_ = DebugDumpProvenance;
   break;
+case clang::driver::options::OPT_fdebug_dump_parsing_log:
+  opts.programAction_ = DebugDumpParsingLog;
+  break;
 case clang::driver::options::OPT_fdebug_measure_parse_tree:
   opts.programAction_ = DebugMeasureParseTree;
   break;
@@ -141,6 +153,8 @@
 }
   }
 
+  setUpFrontendBasedOnAction(opts);
+
   opts

[PATCH] D95246: [test] Use host platform specific error message substitution in lit tests

2021-02-25 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan added a comment.

I created the following review https://reviews.llvm.org/D97472 which I think 
should fix the error on all platforms. Let me know if this fixes the issue on 
MSYS2.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D95246/new/

https://reviews.llvm.org/D95246

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


[PATCH] D97361: [clang-tidy] Add readability-redundant-using check

2021-02-25 Thread Nathan James via Phabricator via cfe-commits
njames93 added a comment.

Can you override the `isLanguageVersionSupported` method to ensure this check 
only runs over c++ code.
Can you add some macro tests, typically we err on the side of caution and don't 
emit any fixes for macro code. You can use `SourceLocation::IsMacroID()` to 
detect macro expansions.
The description looks to have an error in the 2nd example, guess you are 
messing 'n' after the namespace.
How will this handle inline namespaces.

  namespace N {
  inline namespace M {
  void foo();
  void bar();
  } // namespace M
  inline namespace O {
  void bar();
  }
  using M::foo; // This is redundant.
  using M::bar; // This is gonna give you a hard time.
  } // namespace N




Comment at: clang-tools-extra/clang-tidy/readability/RedundantUsingCheck.cpp:62
+}
+void RedundantUsingCheck::diagUsing(int Type, const Decl *Using,
+const NamedDecl *ND,

nit: New line between methods.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D97361/new/

https://reviews.llvm.org/D97361

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


[PATCH] D97417: [clangd] use a compatible preamble for the first AST built

2021-02-25 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

@kadircet who was doing (or planning!) some measurements around this idea. 
Maybe it's possible to use this patch for them?

My guess about risks:

- currently, preamble patching covers relatively few extra headers in practice. 
Here we're likely to end up with larger divergences which might lead to really 
terrible AST build times (e.g. what if we're missing 30% of a 500MB preamble...)
- maybe extra resource consumption from the +5 cached preambles (e.g. in 
preamble-in-ram case), but I guess this number can just be tuned


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D97417/new/

https://reviews.llvm.org/D97417

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


[PATCH] D97318: [clang][CodeGen] Allow fp16 arg pass by register

2021-02-25 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl abandoned this revision.
yaxunl marked an inline comment as done.
yaxunl added inline comments.



Comment at: clang/lib/CodeGen/TargetInfo.cpp:2824
+  // which is equivalent to 16 bit integer. We need this to interop with
+  // gcc where 16 bit integer is used in place of _Float16 or __fp16.
+  Lo = Integer;

pengfei wrote:
> yaxunl wrote:
> > pengfei wrote:
> > > The GCC should take _Floatn as floating types, see 
> > > https://gcc.gnu.org/onlinedocs/gcc-8.2.0/gcc/Floating-Types.html#Floating-Types
> > > Can you provide the information how gcc uses as 16 bit integer for 
> > > _Float16?
> > GCC does not allow _Float16 or __fp16 to be used for x86_64.
> > 
> > HIP language allows _Float16 or __fp16 type to be used with x86_64. To be 
> > able to passing _Float16 or __fp16 values between C++ using gcc and HIP 
> > using clang, users often write code like this:
> > 
> > 
> > ```
> > struct half_t {
> > #ifdef __GNUC__
> > uint16_t x;
> > #else
> > _Float16 x;
> > #endif
> > };
> > 
> > void fun1(half_t x);
> > ```
> > And usually fun1 is defined in HIP and compiled by clang to object file, 
> > then they call it in C++ which is compiled by gcc. Then the caller will 
> > pass half_t by register. However clang passes half_t by stack. This causes 
> > issue.
> It looks to me this is a user scenario issue. You are using different types 
> between GCC and Clang. There's nothing surprised if they aren't 
> interoperable. You should use uint16_t in fun1 too instead of changing the 
> behavior of the floating type.
> Changing type behavior is dangerous, you will result in backward compatiblity 
> problems. That's also the reason why we need a well-defined ABI :)
That makes sense. Thanks.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D97318/new/

https://reviews.llvm.org/D97318

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


[PATCH] D96769: [OpenMP][AMDGPU] Skip backend and assemble phases for amdgcn

2021-02-25 Thread Pushpinder Singh via Phabricator via cfe-commits
pdhaliwal added a comment.

So, neither emit-llvm-bc or emit-llvm work well with save-temps. Therefore, I 
feel the current approach is still valid. This does not impact nvptx or any 
other target in any way. And I don't see how.

I see valid concern regarding assembly output. This patch will surely halt the 
device assembly output. I am working on that which require adding an extra llc 
step in AMDGPUOpenMPToolChain.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D96769/new/

https://reviews.llvm.org/D96769

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


[PATCH] D97437: Rewrite MSVC toolchain discovery with VFS

2021-02-25 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

Re test: Maybe some combination of `-ivfsoverlay` (as a `/clang:` flag I 
suppose) and `/winsysroot` can be used to test this?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D97437/new/

https://reviews.llvm.org/D97437

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


[PATCH] D97457: [flang][driver] Add `-fdebug-dump-parsing-log`

2021-02-25 Thread Andrzej Warzynski via Phabricator via cfe-commits
awarzynski marked an inline comment as done.
awarzynski added inline comments.



Comment at: flang/lib/Frontend/CompilerInvocation.cpp:88-95
+// Tweak the frontend configuration based on the frontend action
+static void setUpFrontendBasedOnAction(FrontendOptions &opts) {
+  assert(opts.programAction_ != Fortran::frontend::InvalidAction &&
+  "Fortran frontend action not set!");
+
+  if (opts.programAction_ == DebugDumpParsingLog)
+opts.instrumentedParse_ = true;

AMDChirag wrote:
> Will this function be extended in the future?
> If not, an entirely separate function for a couple statements seems rather 
> overkill.
> Will this function be extended in the future?

Yes.

Ideally we'd want _features_ and _actions_ to be orthogonal and to be 
controlled by dedicated flags. In this patch, we are adding an _action_ flag 
that toggles a _feature_ option. I think that that's a bit counter-intuitive, 
but not uncommon or unavoidable long-term.

Instead of adding comments, I prefer to introduce a dedicated method for this 
logic. It will make it easier for us to keep it in one place when new options 
like this are added.  Also, `ParseFrontendArgs` is already quite long and is 
only going to get longer.

Having said all that, we may decide in the future that there's a better way to 
split this logic. For now I mostly want to avoid extending `ParseFrontendArgs` 
too much. 



Comment at: flang/lib/Frontend/FrontendActions.cpp:313-316
+  // Parse
+  ci.parsing().Parse(llvm::errs());
+  // Dump parsing log
+  ci.parsing().DumpParsingLog(llvm::outs());

AMDChirag wrote:
> NIT: what's the point of these comments?
> They are pretty much exactly the same as the function names.
Good point, thank you!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D97457/new/

https://reviews.llvm.org/D97457

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


[PATCH] D97137: [clang-format] Fix AlignConsecutiveDeclarations handling of pointers

2021-02-25 Thread Marek Kurdej via Phabricator via cfe-commits
curdeius accepted this revision.
curdeius added a comment.

LGTM.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D97137/new/

https://reviews.llvm.org/D97137

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


[PATCH] D97457: [flang][driver] Add `-fdebug-dump-parsing-log`

2021-02-25 Thread Chirag Khandelwal via Phabricator via cfe-commits
AMDChirag added inline comments.



Comment at: flang/lib/Frontend/CompilerInvocation.cpp:88-95
+// Tweak the frontend configuration based on the frontend action
+static void setUpFrontendBasedOnAction(FrontendOptions &opts) {
+  assert(opts.programAction_ != Fortran::frontend::InvalidAction &&
+  "Fortran frontend action not set!");
+
+  if (opts.programAction_ == DebugDumpParsingLog)
+opts.instrumentedParse_ = true;

awarzynski wrote:
> AMDChirag wrote:
> > Will this function be extended in the future?
> > If not, an entirely separate function for a couple statements seems rather 
> > overkill.
> > Will this function be extended in the future?
> 
> Yes.
> 
> Ideally we'd want _features_ and _actions_ to be orthogonal and to be 
> controlled by dedicated flags. In this patch, we are adding an _action_ flag 
> that toggles a _feature_ option. I think that that's a bit counter-intuitive, 
> but not uncommon or unavoidable long-term.
> 
> Instead of adding comments, I prefer to introduce a dedicated method for this 
> logic. It will make it easier for us to keep it in one place when new options 
> like this are added.  Also, `ParseFrontendArgs` is already quite long and is 
> only going to get longer.
> 
> Having said all that, we may decide in the future that there's a better way 
> to split this logic. For now I mostly want to avoid extending 
> `ParseFrontendArgs` too much. 
Fair, thank you for explaining!

In such case, shouldn't the function call `setUpFrontendBasedOnAction(opts);` 
be placed after all the fields of the `opts` variable have been set?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D97457/new/

https://reviews.llvm.org/D97457

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


[clang] 2cc5846 - [clang][sema] Ignore xor-used-as-pow if both sides are macros

2021-02-25 Thread Timm Bäder via cfe-commits

Author: Timm Bäder
Date: 2021-02-25T16:31:07+01:00
New Revision: 2cc58463caf4c8a43c2954e4206d3647c762ba30

URL: 
https://github.com/llvm/llvm-project/commit/2cc58463caf4c8a43c2954e4206d3647c762ba30
DIFF: 
https://github.com/llvm/llvm-project/commit/2cc58463caf4c8a43c2954e4206d3647c762ba30.diff

LOG: [clang][sema] Ignore xor-used-as-pow if both sides are macros

This happens in codebases a lot, which use xor where both sides are
macros. Using xor in that case is not the common error-prone 2^6 code
that the warning was introduced for.

Don't diagnose such a use of xor.

Differential Revision: https://reviews.llvm.org/D97445

Added: 


Modified: 
clang/lib/Sema/SemaExpr.cpp
clang/test/SemaCXX/warn-xor-as-pow.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index e03183c1a42f..98097b6fb381 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -12102,6 +12102,11 @@ static void diagnoseXorMisusedAsPow(Sema &S, const 
ExprResult &XorLHS,
   if (Loc.isMacroID())
 return;
 
+  // Do not diagnose if both LHS and RHS are macros.
+  if (XorLHS.get()->getExprLoc().isMacroID() &&
+  XorRHS.get()->getExprLoc().isMacroID())
+return;
+
   bool Negative = false;
   bool ExplicitPlus = false;
   const auto *LHSInt = dyn_cast(XorLHS.get());

diff  --git a/clang/test/SemaCXX/warn-xor-as-pow.cpp 
b/clang/test/SemaCXX/warn-xor-as-pow.cpp
index 123d0ac5e031..88719bd1a9d7 100644
--- a/clang/test/SemaCXX/warn-xor-as-pow.cpp
+++ b/clang/test/SemaCXX/warn-xor-as-pow.cpp
@@ -65,6 +65,7 @@ void test(unsigned a, unsigned b) {
 
   res = 2 ^ 0x4;
   res = 2 ^ 04;
+  res = TWO ^ TEN;
   res = 0x2 ^ 10;
   res = 0X2 ^ 10;
   res = 02 ^ 10;



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


[PATCH] D97445: [clang][sema] Ignore xor-used-as-pow if both sides are macros

2021-02-25 Thread Timm Bäder via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG2cc58463caf4: [clang][sema] Ignore xor-used-as-pow if both 
sides are macros (authored by tbaeder).

Changed prior to commit:
  https://reviews.llvm.org/D97445?vs=326294&id=326386#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D97445/new/

https://reviews.llvm.org/D97445

Files:
  clang/lib/Sema/SemaExpr.cpp
  clang/test/SemaCXX/warn-xor-as-pow.cpp


Index: clang/test/SemaCXX/warn-xor-as-pow.cpp
===
--- clang/test/SemaCXX/warn-xor-as-pow.cpp
+++ clang/test/SemaCXX/warn-xor-as-pow.cpp
@@ -65,6 +65,7 @@
 
   res = 2 ^ 0x4;
   res = 2 ^ 04;
+  res = TWO ^ TEN;
   res = 0x2 ^ 10;
   res = 0X2 ^ 10;
   res = 02 ^ 10;
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -12102,6 +12102,11 @@
   if (Loc.isMacroID())
 return;
 
+  // Do not diagnose if both LHS and RHS are macros.
+  if (XorLHS.get()->getExprLoc().isMacroID() &&
+  XorRHS.get()->getExprLoc().isMacroID())
+return;
+
   bool Negative = false;
   bool ExplicitPlus = false;
   const auto *LHSInt = dyn_cast(XorLHS.get());


Index: clang/test/SemaCXX/warn-xor-as-pow.cpp
===
--- clang/test/SemaCXX/warn-xor-as-pow.cpp
+++ clang/test/SemaCXX/warn-xor-as-pow.cpp
@@ -65,6 +65,7 @@
 
   res = 2 ^ 0x4;
   res = 2 ^ 04;
+  res = TWO ^ TEN;
   res = 0x2 ^ 10;
   res = 0X2 ^ 10;
   res = 02 ^ 10;
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -12102,6 +12102,11 @@
   if (Loc.isMacroID())
 return;
 
+  // Do not diagnose if both LHS and RHS are macros.
+  if (XorLHS.get()->getExprLoc().isMacroID() &&
+  XorRHS.get()->getExprLoc().isMacroID())
+return;
+
   bool Negative = false;
   bool ExplicitPlus = false;
   const auto *LHSInt = dyn_cast(XorLHS.get());
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D97445: [clang][sema] Ignore xor-used-as-pow if both sides are macros

2021-02-25 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder added a comment.

Thanks everyone!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D97445/new/

https://reviews.llvm.org/D97445

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


[clang] 3b7104a - Fix a test case that should check whether or not it is passed into lld

2021-02-25 Thread Albion Fung via cfe-commits

Author: Albion Fung
Date: 2021-02-25T10:32:32-05:00
New Revision: 3b7104a2f2033d100aebb605c46fbe0495ea320b

URL: 
https://github.com/llvm/llvm-project/commit/3b7104a2f2033d100aebb605c46fbe0495ea320b
DIFF: 
https://github.com/llvm/llvm-project/commit/3b7104a2f2033d100aebb605c46fbe0495ea320b.diff

LOG: Fix a test case that should check whether or not it is passed into lld

This test case was causing a PowerPC buildbot to fail as it happened to
be named lld-multistage,
which matches with the original regex and therefore fails the check-not.
This should better represent the desired check.

Differential Revision: https://reviews.llvm.org/D97423

Added: 


Modified: 
clang/test/Driver/hip-sanitize-options.hip

Removed: 




diff  --git a/clang/test/Driver/hip-sanitize-options.hip 
b/clang/test/Driver/hip-sanitize-options.hip
index 6c9a6cc31723..19b09868213d 100644
--- a/clang/test/Driver/hip-sanitize-options.hip
+++ b/clang/test/Driver/hip-sanitize-options.hip
@@ -26,15 +26,15 @@
 // RUN:   %s 2>&1 | FileCheck -check-prefixes=FAIL %s
 
 // CHECK-NOT: {{"[^"]*clang[^"]*".* "-fcuda-is-device".* "-fsanitize=address"}}
-// CHECK-NOT: {{"[^"]*lld[^"]*".* ".*hip.bc"}}
+// CHECK-NOT: {{"[^"]*lld(\.exe){0,1}".* ".*hip.bc"}}
 // CHECK: {{"[^"]*clang[^"]*".* "-triple" "x86_64-unknown-linux-gnu".* 
"-fsanitize=address"}}
 
 // NORDC: {{"[^"]*clang[^"]*".* "-fcuda-is-device".* "-fsanitize=address".*}} 
"-o" "[[OUT:[^"]*.bc]]"
-// NORDC: {{"[^"]*lld[^"]*".*}} "[[OUT]]" {{".*asanrtl.bc" ".*hip.bc"}}
+// NORDC: {{"[^"]*lld(\.exe){0,1}".*}} "[[OUT]]" {{".*asanrtl.bc" ".*hip.bc"}}
 // NORDC: {{"[^"]*clang[^"]*".* "-triple" "x86_64-unknown-linux-gnu".* 
"-fsanitize=address"}}
 
 // RDC: {{"[^"]*clang[^"]*".* "-triple" "x86_64-unknown-linux-gnu".* 
"-fsanitize=address"}}
 // RDC: {{"[^"]*clang[^"]*".* "-emit-llvm-bc".* "-fcuda-is-device".* 
"-fsanitize=address".*}} "-o" "[[OUT:[^"]*.bc]]"
-// RDC: {{"[^"]*lld[^"]*".*}} "[[OUT]]" {{".*asanrtl.bc" ".*hip.bc"}}
+// RDC: {{"[^"]*lld(\.exe){0,1}".*}} "[[OUT]]" {{".*asanrtl.bc" ".*hip.bc"}}
 
 // FAIL: AMDGPU address sanitizer runtime library (asanrtl) is not found. 
Please install ROCm device library which supports address sanitizer



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


[PATCH] D97474: [PowerPC][AIX] Enable passing vectors in variadic functions (front-end).

2021-02-25 Thread Sean Fertile via Phabricator via cfe-commits
sfertile created this revision.
sfertile added reviewers: ZarkoCA, cebowleratibm, jasonliu.
sfertile added a project: PowerPC.
Herald added subscribers: shchenz, nemanjai.
sfertile requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D97474

Files:
  clang/lib/CodeGen/TargetInfo.cpp
  clang/test/CodeGen/aix-altivec-vaargs.c


Index: clang/test/CodeGen/aix-altivec-vaargs.c
===
--- /dev/null
+++ clang/test/CodeGen/aix-altivec-vaargs.c
@@ -0,0 +1,54 @@
+// REQUIRES: powerpc-registered-target
+// RUN: %clang_cc1 -triple powerpc-unknown-aix -emit-llvm -target-feature 
+altivec -target-cpu pwr7 -o - %s | FileCheck %s --check-prefixes=CHECK,AIX32
+// RUN: %clang_cc1 -triple powerpc64-unknown-aix -emit-llvm -target-feature 
+altivec -target-cpu pwr7 -o - %s | FileCheck %s --check-prefixes=CHECK,AIX64
+
+#include 
+
+vector double vector_varargs(int count, ...) {
+  va_list arg_list;
+  va_start(arg_list, count);
+
+  vector double ret;
+
+  for (int i = 0; i != count; ++i) {
+ret = va_arg(arg_list, vector double);
+  }
+
+  va_end(arg_list);
+  return ret;
+}
+
+// CHECK: %arg_list = alloca i8*
+// CHECK: %arg_list1 = bitcast i8** %arg_list to i8*
+// CHECK: call void @llvm.va_start(i8* %arg_list1)
+
+// AIX32:   for.body:
+// AIX32-NEXT:%argp.cur = load i8*, i8** %arg_list, align 4
+// AIX32-NEXT:%2 = ptrtoint i8* %argp.cur to i32
+// AIX32-NEXT:%3 = add i32 %2, 15
+// AIX32-NEXT:%4 = and i32 %3, -16
+// AIX32-NEXT:%argp.cur.aligned = inttoptr i32 %4 to i8*
+// AIX32-NEXT:%argp.next = getelementptr inbounds i8, i8* 
%argp.cur.aligned, i32 16
+// AIX32-NEXT:store i8* %argp.next, i8** %arg_list, align 4
+// AIX32-NEXT:%5 = bitcast i8* %argp.cur.aligned to <2 x double>*
+// AIX32-NEXT:%6 = load <2 x double>, <2 x double>* %5, align 16
+// AIX32-NEXT:store <2 x double> %6, <2 x double>* %ret, align 16
+// AIX32-NEXT:br label %for.inc
+
+// AIX64:   for.body:
+// AIX64-NEXT:%argp.cur = load i8*, i8** %arg_list, align 8
+// AIX64-NEXT:%2 = ptrtoint i8* %argp.cur to i64
+// AIX64-NEXT:%3 = add i64 %2, 15
+// AIX64-NEXT:%4 = and i64 %3, -16
+// AIX64-NEXT:%argp.cur.aligned = inttoptr i64 %4 to i8*
+// AIX64-NEXT:%argp.next = getelementptr inbounds i8, i8* 
%argp.cur.aligned, i64 16
+// AIX64-NEXT:store i8* %argp.next, i8** %arg_list, align 8
+// AIX64-NEXT:%5 = bitcast i8* %argp.cur.aligned to <2 x double>*
+// AIX64-NEXT:%6 = load <2 x double>, <2 x double>* %5, align 16
+// AIX64-NEXT:store <2 x double> %6, <2 x double>* %ret, align 16
+// AIX64-NEXT:br label %for.inc
+
+
+// CHECK:  for.end:
+// CHECK:%arg_list2 = bitcast i8** %arg_list to i8*
+// CHECK:call void @llvm.va_end(i8* %arg_list2)
Index: clang/lib/CodeGen/TargetInfo.cpp
===
--- clang/lib/CodeGen/TargetInfo.cpp
+++ clang/lib/CodeGen/TargetInfo.cpp
@@ -4563,10 +4563,6 @@
   if (Ty->isAnyComplexType())
 llvm::report_fatal_error("complex type is not supported on AIX yet");
 
-  if (Ty->isVectorType())
-llvm::report_fatal_error(
-"vector types are not yet supported for variadic functions on AIX");
-
   auto TypeInfo = getContext().getTypeInfoInChars(Ty);
   TypeInfo.Align = getParamTypeAlignment(Ty);
 


Index: clang/test/CodeGen/aix-altivec-vaargs.c
===
--- /dev/null
+++ clang/test/CodeGen/aix-altivec-vaargs.c
@@ -0,0 +1,54 @@
+// REQUIRES: powerpc-registered-target
+// RUN: %clang_cc1 -triple powerpc-unknown-aix -emit-llvm -target-feature +altivec -target-cpu pwr7 -o - %s | FileCheck %s --check-prefixes=CHECK,AIX32
+// RUN: %clang_cc1 -triple powerpc64-unknown-aix -emit-llvm -target-feature +altivec -target-cpu pwr7 -o - %s | FileCheck %s --check-prefixes=CHECK,AIX64
+
+#include 
+
+vector double vector_varargs(int count, ...) {
+  va_list arg_list;
+  va_start(arg_list, count);
+
+  vector double ret;
+
+  for (int i = 0; i != count; ++i) {
+ret = va_arg(arg_list, vector double);
+  }
+
+  va_end(arg_list);
+  return ret;
+}
+
+// CHECK: %arg_list = alloca i8*
+// CHECK: %arg_list1 = bitcast i8** %arg_list to i8*
+// CHECK: call void @llvm.va_start(i8* %arg_list1)
+
+// AIX32:   for.body:
+// AIX32-NEXT:%argp.cur = load i8*, i8** %arg_list, align 4
+// AIX32-NEXT:%2 = ptrtoint i8* %argp.cur to i32
+// AIX32-NEXT:%3 = add i32 %2, 15
+// AIX32-NEXT:%4 = and i32 %3, -16
+// AIX32-NEXT:%argp.cur.aligned = inttoptr i32 %4 to i8*
+// AIX32-NEXT:%argp.next = getelementptr inbounds i8, i8* %argp.cur.aligned, i32 16
+// AIX32-NEXT:store i8* %argp.next, i8** %arg_list, align 4
+// AIX32-NEXT:%5 = bitcast i8* %argp.cur.aligned to <2 x double>*
+/

[PATCH] D97437: Rewrite MSVC toolchain discovery with VFS

2021-02-25 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

(aside: Do you know if the sysroot vs clangd stuff works on non-win? I happened 
to see https://bugs.llvm.org/show_bug.cgi?id=27909)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D97437/new/

https://reviews.llvm.org/D97437

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


[PATCH] D96769: [OpenMP][AMDGPU] Skip backend and assemble phases for amdgcn

2021-02-25 Thread Pushpinder Singh via Phabricator via cfe-commits
pdhaliwal updated this revision to Diff 326392.
pdhaliwal added a comment.

Add extra llc step to produce assembly in the linker.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D96769/new/

https://reviews.llvm.org/D96769

Files:
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp
  clang/test/Driver/amdgpu-openmp-toolchain.c

Index: clang/test/Driver/amdgpu-openmp-toolchain.c
===
--- clang/test/Driver/amdgpu-openmp-toolchain.c
+++ clang/test/Driver/amdgpu-openmp-toolchain.c
@@ -1,3 +1,4 @@
+// REQUIRES: x86-registered-target
 // REQUIRES: amdgpu-registered-target
 // RUN:   env LIBRARY_PATH=%S/Inputs/hip_dev_lib %clang -### --target=x86_64-unknown-linux-gnu -fopenmp -fopenmp-targets=amdgcn-amd-amdhsa -Xopenmp-target=amdgcn-amd-amdhsa -march=gfx906 %s 2>&1 \
 // RUN:   | FileCheck %s
@@ -5,7 +6,7 @@
 // verify the tools invocations
 // CHECK: clang{{.*}}"-cc1" "-triple" "x86_64-unknown-linux-gnu"{{.*}}"-x" "c"{{.*}}
 // CHECK: clang{{.*}}"-cc1" "-triple" "x86_64-unknown-linux-gnu"{{.*}}"-x" "ir"{{.*}}
-// CHECK: clang{{.*}}"-cc1"{{.*}}"-triple" "amdgcn-amd-amdhsa"{{.*}}"-target-cpu" "gfx906" "-fcuda-is-device" "-emit-llvm-bc" "-mlink-builtin-bitcode"{{.*}}libomptarget-amdgcn-gfx906.bc"{{.*}}
+// CHECK: clang{{.*}}"-cc1"{{.*}}"-triple" "amdgcn-amd-amdhsa"{{.*}}"-target-cpu" "gfx906" "-fcuda-is-device" "-mlink-builtin-bitcode"{{.*}}libomptarget-amdgcn-gfx906.bc"{{.*}}
 // CHECK: llvm-link{{.*}}"-o" "{{.*}}amdgpu-openmp-toolchain-{{.*}}-gfx906-linked-{{.*}}.bc"
 // CHECK: llc{{.*}}amdgpu-openmp-toolchain-{{.*}}-gfx906-linked-{{.*}}.bc" "-mtriple=amdgcn-amd-amdhsa" "-mcpu=gfx906" "-filetype=obj" "-o"{{.*}}amdgpu-openmp-toolchain-{{.*}}-gfx906-{{.*}}.o"
 // CHECK: lld{{.*}}"-flavor" "gnu" "--no-undefined" "-shared" "-o"{{.*}}amdgpu-openmp-toolchain-{{.*}}.out" "{{.*}}amdgpu-openmp-toolchain-{{.*}}-gfx906-{{.*}}.o"
@@ -25,18 +26,35 @@
 // CHECK-PHASES: 6: preprocessor, {5}, cpp-output, (device-openmp)
 // CHECK-PHASES: 7: compiler, {6}, ir, (device-openmp)
 // CHECK-PHASES: 8: offload, "host-openmp (x86_64-unknown-linux-gnu)" {2}, "device-openmp (amdgcn-amd-amdhsa)" {7}, ir
-// CHECK-PHASES: 9: backend, {8}, assembler, (device-openmp)
-// CHECK-PHASES: 10: assembler, {9}, object, (device-openmp)
-// CHECK-PHASES: 11: linker, {10}, image, (device-openmp)
-// CHECK-PHASES: 12: offload, "device-openmp (amdgcn-amd-amdhsa)" {11}, image
-// CHECK-PHASES: 13: clang-offload-wrapper, {12}, ir, (host-openmp)
-// CHECK-PHASES: 14: backend, {13}, assembler, (host-openmp)
-// CHECK-PHASES: 15: assembler, {14}, object, (host-openmp)
-// CHECK-PHASES: 16: linker, {4, 15}, image, (host-openmp)
+// CHECK-PHASES: 9: linker, {8}, image, (device-openmp)
+// CHECK-PHASES: 10: offload, "device-openmp (amdgcn-amd-amdhsa)" {9}, image
+// CHECK-PHASES: 11: clang-offload-wrapper, {10}, ir, (host-openmp)
+// CHECK-PHASES: 12: backend, {11}, assembler, (host-openmp)
+// CHECK-PHASES: 13: assembler, {12}, object, (host-openmp)
+// CHECK-PHASES: 14: linker, {4, 13}, image, (host-openmp)
 
 // handling of --libomptarget-amdgcn-bc-path
 // RUN:   %clang -### --target=x86_64-unknown-linux-gnu -fopenmp -fopenmp-targets=amdgcn-amd-amdhsa -Xopenmp-target=amdgcn-amd-amdhsa -march=gfx803 --libomptarget-amdgcn-bc-path=%S/Inputs/hip_dev_lib/libomptarget-amdgcn-gfx803.bc %s 2>&1 | FileCheck %s --check-prefix=CHECK-LIBOMPTARGET
-// CHECK-LIBOMPTARGET: clang{{.*}}"-cc1"{{.*}}"-triple" "amdgcn-amd-amdhsa"{{.*}}"-target-cpu" "gfx803" "-fcuda-is-device" "-emit-llvm-bc" "-mlink-builtin-bitcode"{{.*}}Inputs/hip_dev_lib/libomptarget-amdgcn-gfx803.bc"{{.*}}
+// CHECK-LIBOMPTARGET: clang{{.*}}"-cc1"{{.*}}"-triple" "amdgcn-amd-amdhsa"{{.*}}"-target-cpu" "gfx803" "-fcuda-is-device" "-mlink-builtin-bitcode"{{.*}}Inputs/hip_dev_lib/libomptarget-amdgcn-gfx803.bc"{{.*}}
 
 // RUN:   %clang -### --target=x86_64-unknown-linux-gnu -fopenmp -fopenmp-targets=amdgcn-amd-amdhsa -Xopenmp-target=amdgcn-amd-amdhsa -march=gfx803 -nogpulib %s 2>&1 | FileCheck %s --check-prefix=CHECK-NOGPULIB
-// CHECK-NOGPULIB-NOT: clang{{.*}}"-cc1"{{.*}}"-triple" "amdgcn-amd-amdhsa"{{.*}}"-target-cpu" "gfx803" "-fcuda-is-device" "-emit-llvm-bc" "-mlink-builtin-bitcode"{{.*}}libomptarget-amdgcn-gfx803.bc"{{.*}}
+// CHECK-NOGPULIB-NOT: clang{{.*}}"-cc1"{{.*}}"-triple" "amdgcn-amd-amdhsa"{{.*}}"-target-cpu" "gfx803" "-fcuda-is-device" "-mlink-builtin-bitcode"{{.*}}libomptarget-amdgcn-gfx803.bc"{{.*}}
+
+// RUN:   %clang -### --target=x86_64-unknown-linux-gnu -ccc-print-bindings -save-temps -fopenmp -fopenmp-targets=amdgcn-amd-amdhsa -Xopenmp-target=amdgcn-amd-amdhsa -march=gfx803 -nogpulib %s 2>&1 | FileCheck %s --check-prefix=CHECK-PRINT-BINDINGS
+// CHECK-PRINT-BINDINGS: "x86_64-unknown-linux-gnu" - "clang", inputs: ["[[INPUT:.*]]"],
+// CHECK-PRINT-BINDINGS: "x86_64-unknown-linux-gnu" - "clang",{{.*}} output: "[[HOST_BC:.*]]"
+// CHECK-PRINT-BINDINGS: "x86_64-un

[PATCH] D96976: [analyzer] Fix reinterpret_cast handling for pointer-to-member

2021-02-25 Thread Deep Majumder via Phabricator via cfe-commits
RedDocMD updated this revision to Diff 326393.
RedDocMD marked 2 inline comments as done.
RedDocMD added a comment.

Removed explicit for-loop with range-for loop


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D96976/new/

https://reviews.llvm.org/D96976

Files:
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/BasicValueFactory.h
  clang/lib/StaticAnalyzer/Core/BasicValueFactory.cpp
  clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp
  clang/test/Analysis/reinterpret-cast-pointer-to-member.cpp

Index: clang/test/Analysis/reinterpret-cast-pointer-to-member.cpp
===
--- clang/test/Analysis/reinterpret-cast-pointer-to-member.cpp
+++ clang/test/Analysis/reinterpret-cast-pointer-to-member.cpp
@@ -1,5 +1,4 @@
 // RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -verify %s
-// XFAIL: asserts
 
 void clang_analyzer_eval(bool);
 
Index: clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp
===
--- clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp
+++ clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp
@@ -522,8 +522,7 @@
 continue;
   }
   case CK_DerivedToBaseMemberPointer:
-  case CK_BaseToDerivedMemberPointer:
-  case CK_ReinterpretMemberPointer: {
+  case CK_BaseToDerivedMemberPointer: {
 SVal V = state->getSVal(Ex, LCtx);
 if (auto PTMSV = V.getAs()) {
   SVal CastedPTMSV =
@@ -537,6 +536,25 @@
 state = handleLVectorSplat(state, LCtx, CastE, Bldr, Pred);
 continue;
   }
+  case CK_ReinterpretMemberPointer: {
+SVal V = state->getSVal(Ex, LCtx);
+if (auto PTMSV = V.getAs()) {
+  if (const auto *ReinterpretE =
+  llvm::dyn_cast(CastE)) {
+if (const PointerToMemberData *Data =
+getBasicVals().basesForReinterpretCast(ReinterpretE,
+   *PTMSV)) {
+  SVal CastedPTMSV = svalBuilder.makePointerToMember(Data);
+  state = state->BindExpr(CastE, LCtx, CastedPTMSV);
+  Bldr.generateNode(CastE, Pred, state);
+  continue;
+}
+  }
+}
+// Explicitly proceed with default handler for this case cascade.
+state = handleLVectorSplat(state, LCtx, CastE, Bldr, Pred);
+continue;
+  }
   // Various C++ casts that are not handled yet.
   case CK_ToUnion:
   case CK_VectorSplat: {
Index: clang/lib/StaticAnalyzer/Core/BasicValueFactory.cpp
===
--- clang/lib/StaticAnalyzer/Core/BasicValueFactory.cpp
+++ clang/lib/StaticAnalyzer/Core/BasicValueFactory.cpp
@@ -22,8 +22,11 @@
 #include "llvm/ADT/ImmutableList.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/SmallPtrSet.h"
+#include "llvm/ADT/SmallVector.h"
 #include 
 #include 
+#include 
+#include 
 #include 
 
 using namespace clang;
@@ -239,13 +242,115 @@
 
 return getPointerToMemberData(ND, ReducedBaseSpecList);
   }
-  // FIXME: Reinterpret casts on member-pointers are not handled properly by
-  // this code
   for (const CXXBaseSpecifier *I : llvm::reverse(PathRange))
 BaseSpecList = prependCXXBase(I, BaseSpecList);
   return getPointerToMemberData(ND, BaseSpecList);
 }
 
+struct BFSNode {
+  const CXXBaseSpecifier *BaseSpec;
+  std::shared_ptr Parent;
+
+  BFSNode(const CXXBaseSpecifier *BaseSpec,
+  std::shared_ptr Parent = nullptr)
+  : BaseSpec{BaseSpec}, Parent{Parent} {}
+};
+
+std::pair, bool>
+findPathToBase(const Type *Start, const Type *End) {
+  std::deque> queue;
+  llvm::SmallVector Path;
+  const CXXRecordDecl *StartDecl = Start->getAsCXXRecordDecl();
+  if (!StartDecl)
+return {Path, false};
+
+  for (const CXXBaseSpecifier &Base : StartDecl->bases())
+queue.push_back(std::make_shared(&Base));
+
+  while (!queue.empty()) {
+std::shared_ptr CurrNode = queue.front();
+queue.pop_front();
+const CXXBaseSpecifier *CurrBaseSpec = CurrNode->BaseSpec;
+const Type *CurrType = CurrBaseSpec->getType().getTypePtr();
+if (CurrType == End) {
+  BFSNode *Ptr = CurrNode.get();
+  while (Ptr) {
+Path.push_back(Ptr->BaseSpec);
+Ptr = Ptr->Parent.get();
+  }
+  std::reverse(Path.begin(), Path.end());
+  return {Path, true};
+}
+const CXXRecordDecl *CurrRecordDecl = CurrType->getAsCXXRecordDecl();
+assert(CurrRecordDecl &&
+   "Base of a CXX class/struct must be a CXX class/struct");
+for (const CXXBaseSpecifier &Base : CurrRecordDecl->bases())
+  queue.push_back(std::make_shared(&Base, CurrNode));
+  }
+
+  return {Path, false};
+}
+
+const CXXRecordDecl *retrieveCXXRecord(const NamedDecl *ND) {
+  if (const auto *FD = llvm::dyn_cast(ND)) {
+const RecordDecl *RD = FD->getParent();
+return llvm::dyn_cast(RD);
+  }
+

[PATCH] D96769: [OpenMP][AMDGPU] Skip backend and assemble phases for amdgcn

2021-02-25 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield added a comment.

Strictly speaking I suppose that's not a temporary file, since it isn't used 
for anything, but whenever I pass -save-temps I am likely to want to read the 
assembly. This looks like a great workaround to me. @jdoerfert?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D96769/new/

https://reviews.llvm.org/D96769

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


[PATCH] D96832: [Clang][Attributes] Allow not_tail_called attribute to be applied to virtual function.

2021-02-25 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM aside from a minor wording suggestion on the documentation.




Comment at: clang/include/clang/Basic/AttrDocs.td:4087-4088
 
-Marking virtual functions as ``not_tail_called`` is an error:
+Marking virtual functions as ``not_tail_called`` will not have effect on the
+overriding functions of derived classes:
 




Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D96832/new/

https://reviews.llvm.org/D96832

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


[PATCH] D97461: [clang][cli] Implement '-cuid=' marshalling

2021-02-25 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 updated this revision to Diff 326397.
jansvoboda11 added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D97461/new/

https://reviews.llvm.org/D97461

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Frontend/CompilerInvocation.cpp


Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -3585,11 +3585,6 @@
 }
   }
 
-
-  if (auto *A = Args.getLastArg(OPT_cuid_EQ)) {
-Opts.CUID = std::string(A->getValue());
-  }
-
   if (Opts.ObjC) {
 if (Arg *arg = Args.getLastArg(OPT_fobjc_runtime_EQ)) {
   StringRef value = arg->getValue();
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -934,7 +934,8 @@
"compilation unit but different for different compilation units. "
"It is used to externalize device-side static variables for single "
"source offloading languages CUDA and HIP so that they can be "
-   "accessed by the host code of the same compilation unit.">;
+   "accessed by the host code of the same compilation unit.">,
+  MarshallingInfoString>;
 def fuse_cuid_EQ : Joined<["-"], "fuse-cuid=">,
   HelpText<"Method to generate ID's for compilation units for single source "
"offloading languages CUDA and HIP: 'hash' (ID's generated by 
hashing "


Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -3585,11 +3585,6 @@
 }
   }
 
-
-  if (auto *A = Args.getLastArg(OPT_cuid_EQ)) {
-Opts.CUID = std::string(A->getValue());
-  }
-
   if (Opts.ObjC) {
 if (Arg *arg = Args.getLastArg(OPT_fobjc_runtime_EQ)) {
   StringRef value = arg->getValue();
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -934,7 +934,8 @@
"compilation unit but different for different compilation units. "
"It is used to externalize device-side static variables for single "
"source offloading languages CUDA and HIP so that they can be "
-   "accessed by the host code of the same compilation unit.">;
+   "accessed by the host code of the same compilation unit.">,
+  MarshallingInfoString>;
 def fuse_cuid_EQ : Joined<["-"], "fuse-cuid=">,
   HelpText<"Method to generate ID's for compilation units for single source "
"offloading languages CUDA and HIP: 'hash' (ID's generated by hashing "
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D97462: [clang][cli] Round-trip cc1 arguments in assert builds

2021-02-25 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 updated this revision to Diff 326398.
jansvoboda11 added a comment.

Rebase on top of D97461 


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D97462/new/

https://reviews.llvm.org/D97462

Files:
  clang/CMakeLists.txt


Index: clang/CMakeLists.txt
===
--- clang/CMakeLists.txt
+++ clang/CMakeLists.txt
@@ -465,7 +465,8 @@
 
 option(CLANG_ENABLE_PROTO_FUZZER "Build Clang protobuf fuzzer." OFF)
 
-option(CLANG_ROUND_TRIP_CC1_ARGS "Round-trip command line arguments in -cc1." 
OFF)
+option(CLANG_ROUND_TRIP_CC1_ARGS
+  "Round-trip command line arguments in -cc1." ${LLVM_ENABLE_ASSERTIONS})
 
 if(NOT CLANG_ENABLE_STATIC_ANALYZER AND CLANG_ENABLE_ARCMT)
   message(FATAL_ERROR "Cannot disable static analyzer while enabling ARCMT or 
Z3")


Index: clang/CMakeLists.txt
===
--- clang/CMakeLists.txt
+++ clang/CMakeLists.txt
@@ -465,7 +465,8 @@
 
 option(CLANG_ENABLE_PROTO_FUZZER "Build Clang protobuf fuzzer." OFF)
 
-option(CLANG_ROUND_TRIP_CC1_ARGS "Round-trip command line arguments in -cc1." OFF)
+option(CLANG_ROUND_TRIP_CC1_ARGS
+  "Round-trip command line arguments in -cc1." ${LLVM_ENABLE_ASSERTIONS})
 
 if(NOT CLANG_ENABLE_STATIC_ANALYZER AND CLANG_ENABLE_ARCMT)
   message(FATAL_ERROR "Cannot disable static analyzer while enabling ARCMT or Z3")
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D97446: Change some addUsedGlobal to addUsedOrCompilerUsedGlobal

2021-02-25 Thread Paul Robinson via Phabricator via cfe-commits
probinson added a comment.

> GNU ld has a rule "start_/stop_ references from a live input section retain 
> the associated C identifier name sections",

which LLD may change in the future (D96914 ).

The phrasing "may change" implies LLD could eliminate the rule; in fact D96914 
 will only add a way to opt-out of the rule.  
You can't eliminate the rule entirely without breaking a lot of useful cases.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D97446/new/

https://reviews.llvm.org/D97446

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


[PATCH] D97318: [clang][CodeGen] Allow fp16 arg pass by register

2021-02-25 Thread Michael Liao via Phabricator via cfe-commits
hliao added inline comments.



Comment at: clang/lib/CodeGen/TargetInfo.cpp:2821
+} else if (k == BuiltinType::Float16 || k == BuiltinType::Half) {
+  // AMD64 does not support operations on _Float16 or __fp16 other than
+  // load and store. For load/store operations, _Float16 and __fp16 is

pengfei wrote:
> This is still not correct I think. As Clang dos says, _Float16 is not support 
> (including load and store) unless ABI defines it.
> We cannot add it before there's clear definition in the ABI.
> See https://github.com/hjl-tools/x86-psABI/wiki/x86-64-psABI-1.0.pdf
That's quite outdated spec. Please check the latest one from 
https://gitlab.com/x86-psABIs/x86-64-ABI, which classify _Float16 as SSE.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D97318/new/

https://reviews.llvm.org/D97318

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


[PATCH] D97318: [clang][CodeGen] Allow fp16 arg pass by register

2021-02-25 Thread Michael Liao via Phabricator via cfe-commits
hliao added inline comments.



Comment at: clang/lib/CodeGen/TargetInfo.cpp:2821
+} else if (k == BuiltinType::Float16 || k == BuiltinType::Half) {
+  // AMD64 does not support operations on _Float16 or __fp16 other than
+  // load and store. For load/store operations, _Float16 and __fp16 is

hliao wrote:
> pengfei wrote:
> > This is still not correct I think. As Clang dos says, _Float16 is not 
> > support (including load and store) unless ABI defines it.
> > We cannot add it before there's clear definition in the ABI.
> > See https://github.com/hjl-tools/x86-psABI/wiki/x86-64-psABI-1.0.pdf
> That's quite outdated spec. Please check the latest one from 
> https://gitlab.com/x86-psABIs/x86-64-ABI, which classify _Float16 as SSE.
> That's quite outdated spec. Please check the latest one from 
> https://gitlab.com/x86-psABIs/x86-64-ABI, which classify _Float16 as SSE.

From the log

commit 71d1183e7bb95e9f8ad732e0f2b5a4f127796e2a (origin/usr/hjl/_Float16)
Author: H.J. Lu 
Date:   Wed Feb 20 05:45:39 2019 -0800

Add optional _Float16 support

Pass and return _Float16 values in XMM registers.

diff --git a/x86-64-ABI/low-level-sys-info.tex 
b/x86-64-ABI/low-level-sys-info.tex
index ca84fff..0b06c56 100644
--- a/x86-64-ABI/low-level-sys-info.tex
+++ b/x86-64-ABI/low-level-sys-info.tex
@@ -25,7 +25,8 @@ object, and the term \emph{\textindex{\sixteenbyte{}}} refers 
to a
 \subsubsection{Fundamental Types}
 
 Figure~\ref{basic-types} shows the correspondence between ISO C's
-scalar types and the processor's.  \code{__int128}, \code{__float80},
+scalar types and the processor's.  \code{__int128}, \code{_Float16},
+\code{__float80},
 \code{__float128}, \code{__m64}, \code{__m128}, \code{__m256} and
 \code{__m512} types are optional.



CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D97318/new/

https://reviews.llvm.org/D97318

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


[PATCH] D96832: [Clang][Attributes] Allow not_tail_called attribute to be applied to virtual function.

2021-02-25 Thread Arthur O'Dwyer via Phabricator via cfe-commits
Quuxplusone added inline comments.



Comment at: clang/include/clang/Basic/AttrDocs.td:4087-4088
 
-Marking virtual functions as ``not_tail_called`` is an error:
+Marking virtual functions as ``not_tail_called`` will not have effect on the
+overriding functions of derived classes:
 

aaron.ballman wrote:
> 
/will not have effect/will have no effect/
However, this phrasing is easy to interpret the wrong way around: actually 
marking a (base-class) virtual function //will// affect overriding functions in 
derived classes! You meant that marking the //overrider// wouldn't 
retroactively affect the //overridden// function from the base class.
I think the correct explanation would be more like this:

Generally, marking an overriding virtual function as ``not_tail_called`` is
not useful, because this attribute is a property of the static type. Calls
made through a pointer or reference to the base class type will respect
the ``no_tail_called`` attribute of the base class's member function,
regardless of the runtime destination of the call.

I think it'd also be correct and helpful to add:

Similarly, calls made through a function pointer will respect the
``no_tail_called`` attribute of the function pointer, not of its
runtime destination.

(I admit this is mildly redundant with the `foo2` example above.)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D96832/new/

https://reviews.llvm.org/D96832

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


[clang] 502b3bf - [AMDGPU] require s-memtime-inst for __builtin_amdgcn_s_memtime

2021-02-25 Thread Stanislav Mekhanoshin via cfe-commits

Author: Stanislav Mekhanoshin
Date: 2021-02-25T08:31:59-08:00
New Revision: 502b3bfc6a713e5b6640faf48e72de08d7cb0aba

URL: 
https://github.com/llvm/llvm-project/commit/502b3bfc6a713e5b6640faf48e72de08d7cb0aba
DIFF: 
https://github.com/llvm/llvm-project/commit/502b3bfc6a713e5b6640faf48e72de08d7cb0aba.diff

LOG: [AMDGPU] require s-memtime-inst for __builtin_amdgcn_s_memtime

Differential Revision: https://reviews.llvm.org/D97420

Added: 
clang/test/SemaOpenCL/builtins-amdgcn-error-gfx1030.cl

Modified: 
clang/include/clang/Basic/BuiltinsAMDGPU.def
clang/test/CodeGenOpenCL/builtins-amdgcn-ci.cl
clang/test/CodeGenOpenCL/builtins-amdgcn-gfx10.cl
clang/test/CodeGenOpenCL/builtins-amdgcn-gfx9.cl
clang/test/CodeGenOpenCL/builtins-amdgcn-vi.cl
clang/test/CodeGenOpenCL/builtins-amdgcn.cl

Removed: 




diff  --git a/clang/include/clang/Basic/BuiltinsAMDGPU.def 
b/clang/include/clang/Basic/BuiltinsAMDGPU.def
index 3544abe35896..415d8cb3e73a 100644
--- a/clang/include/clang/Basic/BuiltinsAMDGPU.def
+++ b/clang/include/clang/Basic/BuiltinsAMDGPU.def
@@ -44,6 +44,8 @@ BUILTIN(__builtin_amdgcn_grid_size_z, "Ui", "nc")
 BUILTIN(__builtin_amdgcn_mbcnt_hi, "UiUiUi", "nc")
 BUILTIN(__builtin_amdgcn_mbcnt_lo, "UiUiUi", "nc")
 
+TARGET_BUILTIN(__builtin_amdgcn_s_memtime, "LUi", "n", "s-memtime-inst")
+
 
//===--===//
 // Instruction builtins.
 
//===--===//
@@ -105,7 +107,6 @@ BUILTIN(__builtin_amdgcn_cubeid, "", "nc")
 BUILTIN(__builtin_amdgcn_cubesc, "", "nc")
 BUILTIN(__builtin_amdgcn_cubetc, "", "nc")
 BUILTIN(__builtin_amdgcn_cubema, "", "nc")
-BUILTIN(__builtin_amdgcn_s_memtime, "LUi", "n")
 BUILTIN(__builtin_amdgcn_s_sleep, "vIi", "n")
 BUILTIN(__builtin_amdgcn_s_incperflevel, "vIi", "n")
 BUILTIN(__builtin_amdgcn_s_decperflevel, "vIi", "n")

diff  --git a/clang/test/CodeGenOpenCL/builtins-amdgcn-ci.cl 
b/clang/test/CodeGenOpenCL/builtins-amdgcn-ci.cl
index b3bf3681b935..56da7eceb6de 100644
--- a/clang/test/CodeGenOpenCL/builtins-amdgcn-ci.cl
+++ b/clang/test/CodeGenOpenCL/builtins-amdgcn-ci.cl
@@ -5,6 +5,7 @@
 // RUN: %clang_cc1 -cl-std=CL2.0 -O0 -triple amdgcn-unknown-unknown 
-target-cpu gfx1010 -S -emit-llvm -o - %s | FileCheck %s
 
 typedef unsigned int uint;
+typedef unsigned long ulong;
 
 // CHECK-LABEL: @test_s_dcache_inv_vol
 // CHECK: call void @llvm.amdgcn.s.dcache.inv.vol(
@@ -27,6 +28,13 @@ void test_gws_sema_release_all(uint id)
   __builtin_amdgcn_ds_gws_sema_release_all(id);
 }
 
+// CHECK-LABEL: @test_s_memtime
+// CHECK: call i64 @llvm.amdgcn.s.memtime()
+void test_s_memtime(global ulong* out)
+{
+  *out = __builtin_amdgcn_s_memtime();
+}
+
 // CHECK-LABEL: @test_is_shared(
 // CHECK: [[CAST:%[0-9]+]] = bitcast i32* %{{[0-9]+}} to i8*
 // CHECK: call i1 @llvm.amdgcn.is.shared(i8* [[CAST]]

diff  --git a/clang/test/CodeGenOpenCL/builtins-amdgcn-gfx10.cl 
b/clang/test/CodeGenOpenCL/builtins-amdgcn-gfx10.cl
index a90d55fa8a78..a9bbaa9c3f54 100644
--- a/clang/test/CodeGenOpenCL/builtins-amdgcn-gfx10.cl
+++ b/clang/test/CodeGenOpenCL/builtins-amdgcn-gfx10.cl
@@ -4,6 +4,7 @@
 // RUN: %clang_cc1 -triple amdgcn-unknown-unknown -target-cpu gfx1012 -S 
-emit-llvm -o - %s | FileCheck %s
 
 typedef unsigned int uint;
+typedef unsigned long ulong;
 
 // CHECK-LABEL: @test_permlane16(
 // CHECK: call i32 @llvm.amdgcn.permlane16(i32 %a, i32 %b, i32 %c, i32 %d, i1 
false, i1 false)
@@ -22,3 +23,10 @@ void test_permlanex16(global uint* out, uint a, uint b, uint 
c, uint d) {
 void test_mov_dpp8(global uint* out, uint a) {
   *out = __builtin_amdgcn_mov_dpp8(a, 1);
 }
+
+// CHECK-LABEL: @test_s_memtime
+// CHECK: call i64 @llvm.amdgcn.s.memtime()
+void test_s_memtime(global ulong* out)
+{
+  *out = __builtin_amdgcn_s_memtime();
+}

diff  --git a/clang/test/CodeGenOpenCL/builtins-amdgcn-gfx9.cl 
b/clang/test/CodeGenOpenCL/builtins-amdgcn-gfx9.cl
index 344af2b27670..420506ec083c 100644
--- a/clang/test/CodeGenOpenCL/builtins-amdgcn-gfx9.cl
+++ b/clang/test/CodeGenOpenCL/builtins-amdgcn-gfx9.cl
@@ -3,6 +3,7 @@
 // RUN: %clang_cc1 -triple amdgcn-unknown-unknown -target-cpu gfx1010 -S 
-emit-llvm -o - %s | FileCheck %s
 
 #pragma OPENCL EXTENSION cl_khr_fp16 : enable
+typedef unsigned long ulong;
 
 // CHECK-LABEL: @test_fmed3_f16
 // CHECK: call half @llvm.amdgcn.fmed3.f16(half %a, half %b, half %c)
@@ -10,3 +11,10 @@ void test_fmed3_f16(global half* out, half a, half b, half c)
 {
   *out = __builtin_amdgcn_fmed3h(a, b, c);
 }
+
+// CHECK-LABEL: @test_s_memtime
+// CHECK: call i64 @llvm.amdgcn.s.memtime()
+void test_s_memtime(global ulong* out)
+{
+  *out = __builtin_amdgcn_s_memtime();
+}

diff  --git a/clang/test/CodeGenOpenCL/builtins-amdgcn-vi.cl 
b/clang/test/CodeGenOpenCL/builtins-amdgcn-vi.cl
index 4408b043296a..49faf069c8c6 100644
--- a/clang/test/CodeGe

[PATCH] D97318: [clang][CodeGen] Allow fp16 arg pass by register

2021-02-25 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl marked an inline comment as done.
yaxunl added a comment.

So should we revive this patch by classifying _Float16 as SSE, then it will 
conform to the ABI. And we should be compatible with gcc assuming it also 
follows the ABI. @pengfei


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D97318/new/

https://reviews.llvm.org/D97318

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


[PATCH] D96976: [analyzer] Fix reinterpret_cast handling for pointer-to-member

2021-02-25 Thread Deep Majumder via Phabricator via cfe-commits
RedDocMD updated this revision to Diff 326410.
RedDocMD added a comment.

Cleaned up tests, added test above class hierarchy


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D96976/new/

https://reviews.llvm.org/D96976

Files:
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/BasicValueFactory.h
  clang/lib/StaticAnalyzer/Core/BasicValueFactory.cpp
  clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp
  clang/test/Analysis/reinterpret-cast-pointer-to-member.cpp

Index: clang/test/Analysis/reinterpret-cast-pointer-to-member.cpp
===
--- clang/test/Analysis/reinterpret-cast-pointer-to-member.cpp
+++ clang/test/Analysis/reinterpret-cast-pointer-to-member.cpp
@@ -1,11 +1,11 @@
 // RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -verify %s
-// XFAIL: asserts
 
 void clang_analyzer_eval(bool);
 
-// TODO: The following test will work properly once reinterpret_cast on pointer-to-member is handled properly
 namespace testReinterpretCasting {
-struct Base {
+struct BaseOfBase {};
+
+struct Base : public BaseOfBase {
   int field;
 };
 
@@ -15,12 +15,28 @@
 
 struct Some {};
 
-void f() {
+void analyzableCasts() {
   int DoubleDerived::*ddf = &Base::field;
   int Base::*bf = reinterpret_cast(reinterpret_cast(reinterpret_cast(ddf)));
-  int Some::*sf = reinterpret_cast(ddf);
   Base base;
   base.field = 13;
   clang_analyzer_eval(base.*bf == 13); // expected-warning{{TRUE}}
 }
+
+void castOutsideHierarchy() {
+  int DoubleDerived::*ddf = &Base::field;
+  int Some::*sf = reinterpret_cast(ddf);
+  Some some;
+  some.*sf = 14;
+  clang_analyzer_eval(some.*sf == 14); // expected-warning{{UNKNOWN}}
+}
+
+void castAbove() {
+  int DoubleDerived::*ddf = &Base::field;
+  int BaseOfBase::*bbf = reinterpret_cast(ddf);
+  BaseOfBase bb;
+  bb.*bbf = 23;
+  clang_analyzer_eval(bb.*bbf == 23); // expected-warning{{UNKNOWN}}
+}
+
 } // namespace testReinterpretCasting
Index: clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp
===
--- clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp
+++ clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp
@@ -522,8 +522,7 @@
 continue;
   }
   case CK_DerivedToBaseMemberPointer:
-  case CK_BaseToDerivedMemberPointer:
-  case CK_ReinterpretMemberPointer: {
+  case CK_BaseToDerivedMemberPointer: {
 SVal V = state->getSVal(Ex, LCtx);
 if (auto PTMSV = V.getAs()) {
   SVal CastedPTMSV =
@@ -537,6 +536,25 @@
 state = handleLVectorSplat(state, LCtx, CastE, Bldr, Pred);
 continue;
   }
+  case CK_ReinterpretMemberPointer: {
+SVal V = state->getSVal(Ex, LCtx);
+if (auto PTMSV = V.getAs()) {
+  if (const auto *ReinterpretE =
+  llvm::dyn_cast(CastE)) {
+if (const PointerToMemberData *Data =
+getBasicVals().basesForReinterpretCast(ReinterpretE,
+   *PTMSV)) {
+  SVal CastedPTMSV = svalBuilder.makePointerToMember(Data);
+  state = state->BindExpr(CastE, LCtx, CastedPTMSV);
+  Bldr.generateNode(CastE, Pred, state);
+  continue;
+}
+  }
+}
+// Explicitly proceed with default handler for this case cascade.
+state = handleLVectorSplat(state, LCtx, CastE, Bldr, Pred);
+continue;
+  }
   // Various C++ casts that are not handled yet.
   case CK_ToUnion:
   case CK_VectorSplat: {
Index: clang/lib/StaticAnalyzer/Core/BasicValueFactory.cpp
===
--- clang/lib/StaticAnalyzer/Core/BasicValueFactory.cpp
+++ clang/lib/StaticAnalyzer/Core/BasicValueFactory.cpp
@@ -22,8 +22,11 @@
 #include "llvm/ADT/ImmutableList.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/SmallPtrSet.h"
+#include "llvm/ADT/SmallVector.h"
 #include 
 #include 
+#include 
+#include 
 #include 
 
 using namespace clang;
@@ -239,13 +242,115 @@
 
 return getPointerToMemberData(ND, ReducedBaseSpecList);
   }
-  // FIXME: Reinterpret casts on member-pointers are not handled properly by
-  // this code
   for (const CXXBaseSpecifier *I : llvm::reverse(PathRange))
 BaseSpecList = prependCXXBase(I, BaseSpecList);
   return getPointerToMemberData(ND, BaseSpecList);
 }
 
+struct BFSNode {
+  const CXXBaseSpecifier *BaseSpec;
+  std::shared_ptr Parent;
+
+  BFSNode(const CXXBaseSpecifier *BaseSpec,
+  std::shared_ptr Parent = nullptr)
+  : BaseSpec{BaseSpec}, Parent{Parent} {}
+};
+
+std::pair, bool>
+findPathToBase(const Type *Start, const Type *End) {
+  std::deque> queue;
+  llvm::SmallVector Path;
+  const CXXRecordDecl *StartDecl = Start->getAsCXXRecordDecl();
+  if (!StartDecl)
+return {Path, false};
+
+  for (const CXXBaseSpecifier &Base : StartDecl->bases())
+queue.push_bac

[PATCH] D96976: [analyzer] Fix reinterpret_cast handling for pointer-to-member

2021-02-25 Thread Deep Majumder via Phabricator via cfe-commits
RedDocMD updated this revision to Diff 326413.
RedDocMD added a comment.

Added test for multiple inheritance


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D96976/new/

https://reviews.llvm.org/D96976

Files:
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/BasicValueFactory.h
  clang/lib/StaticAnalyzer/Core/BasicValueFactory.cpp
  clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp
  clang/test/Analysis/reinterpret-cast-pointer-to-member.cpp

Index: clang/test/Analysis/reinterpret-cast-pointer-to-member.cpp
===
--- clang/test/Analysis/reinterpret-cast-pointer-to-member.cpp
+++ clang/test/Analysis/reinterpret-cast-pointer-to-member.cpp
@@ -1,11 +1,11 @@
 // RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -verify %s
-// XFAIL: asserts
 
 void clang_analyzer_eval(bool);
 
-// TODO: The following test will work properly once reinterpret_cast on pointer-to-member is handled properly
 namespace testReinterpretCasting {
-struct Base {
+struct BaseOfBase {};
+
+struct Base : public BaseOfBase {
   int field;
 };
 
@@ -15,12 +15,51 @@
 
 struct Some {};
 
-void f() {
+void analyzableCasts() {
   int DoubleDerived::*ddf = &Base::field;
   int Base::*bf = reinterpret_cast(reinterpret_cast(reinterpret_cast(ddf)));
-  int Some::*sf = reinterpret_cast(ddf);
   Base base;
   base.field = 13;
   clang_analyzer_eval(base.*bf == 13); // expected-warning{{TRUE}}
 }
+
+void castOutsideHierarchy() {
+  int DoubleDerived::*ddf = &Base::field;
+  int Some::*sf = reinterpret_cast(ddf);
+  Some some;
+  some.*sf = 14;
+  clang_analyzer_eval(some.*sf == 14); // expected-warning{{UNKNOWN}}
+}
+
+void castAbove() {
+  int DoubleDerived::*ddf = &Base::field;
+  int BaseOfBase::*bbf = reinterpret_cast(ddf);
+  BaseOfBase bb;
+  bb.*bbf = 23;
+  clang_analyzer_eval(bb.*bbf == 23); // expected-warning{{UNKNOWN}}
+}
+
+namespace testMultipleInheritance {
+struct A {};
+struct B : public A {};
+struct C {
+  int field;
+};
+struct D : public C {};
+struct E : public B, public D {};
+struct F : public E {};
+
+void testMultiple() {
+  int F::*f = &F::field;
+  int A::*a = reinterpret_cast(f);
+  int C::*c = reinterpret_cast(f);
+  A aobj;
+  C cobj;
+  aobj.*a = 13;
+  cobj.*c = 29;
+  clang_analyzer_eval(aobj.*a == 13); // expected-warning{{UNKNOWN}}
+  clang_analyzer_eval(cobj.*c == 29); // expected-warning{{TRUE}}
+}
+} // namespace testMultipleInheritance
+
 } // namespace testReinterpretCasting
Index: clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp
===
--- clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp
+++ clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp
@@ -522,8 +522,7 @@
 continue;
   }
   case CK_DerivedToBaseMemberPointer:
-  case CK_BaseToDerivedMemberPointer:
-  case CK_ReinterpretMemberPointer: {
+  case CK_BaseToDerivedMemberPointer: {
 SVal V = state->getSVal(Ex, LCtx);
 if (auto PTMSV = V.getAs()) {
   SVal CastedPTMSV =
@@ -537,6 +536,25 @@
 state = handleLVectorSplat(state, LCtx, CastE, Bldr, Pred);
 continue;
   }
+  case CK_ReinterpretMemberPointer: {
+SVal V = state->getSVal(Ex, LCtx);
+if (auto PTMSV = V.getAs()) {
+  if (const auto *ReinterpretE =
+  llvm::dyn_cast(CastE)) {
+if (const PointerToMemberData *Data =
+getBasicVals().basesForReinterpretCast(ReinterpretE,
+   *PTMSV)) {
+  SVal CastedPTMSV = svalBuilder.makePointerToMember(Data);
+  state = state->BindExpr(CastE, LCtx, CastedPTMSV);
+  Bldr.generateNode(CastE, Pred, state);
+  continue;
+}
+  }
+}
+// Explicitly proceed with default handler for this case cascade.
+state = handleLVectorSplat(state, LCtx, CastE, Bldr, Pred);
+continue;
+  }
   // Various C++ casts that are not handled yet.
   case CK_ToUnion:
   case CK_VectorSplat: {
Index: clang/lib/StaticAnalyzer/Core/BasicValueFactory.cpp
===
--- clang/lib/StaticAnalyzer/Core/BasicValueFactory.cpp
+++ clang/lib/StaticAnalyzer/Core/BasicValueFactory.cpp
@@ -22,8 +22,11 @@
 #include "llvm/ADT/ImmutableList.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/SmallPtrSet.h"
+#include "llvm/ADT/SmallVector.h"
 #include 
 #include 
+#include 
+#include 
 #include 
 
 using namespace clang;
@@ -239,13 +242,115 @@
 
 return getPointerToMemberData(ND, ReducedBaseSpecList);
   }
-  // FIXME: Reinterpret casts on member-pointers are not handled properly by
-  // this code
   for (const CXXBaseSpecifier *I : llvm::reverse(PathRange))
 BaseSpecList = prependCXXBase(I, BaseSpecList);
   return getPointerToMemberData(ND, BaseSpecList);
 }
 
+s

[PATCH] D96203: [clang][patch] Modify sanitizer options names: renaming blacklist to blocklist

2021-02-25 Thread Melanie Blower via Phabricator via cfe-commits
mibintc updated this revision to Diff 326412.
mibintc added a comment.

I rebased the patch and basically made no other changes. On the review there's 
a suggestion that 'blocklist' isn't the best word choice, do you have 
suggestions?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D96203/new/

https://reviews.llvm.org/D96203

Files:
  clang/include/clang/Basic/DiagnosticASTKinds.td
  clang/include/clang/Driver/Options.td
  clang/include/clang/Frontend/DependencyOutputOptions.h
  clang/lib/CodeGen/CGClass.cpp
  clang/lib/Driver/SanitizerArgs.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGen/asan-globals.cpp
  clang/test/CodeGen/sanitize-address-field-padding.cpp
  clang/test/Driver/Inputs/resource_dir/share/asan_blacklist.txt
  clang/test/Driver/Inputs/resource_dir/share/asan_blocklist.txt
  clang/test/Driver/Inputs/resource_dir/share/hwasan_blacklist.txt
  clang/test/Driver/Inputs/resource_dir/share/hwasan_blocklist.txt
  clang/test/Driver/Inputs/resource_dir/share/movit
  clang/test/Driver/Inputs/resource_dir/share/ubsan_blacklist.txt
  clang/test/Driver/Inputs/resource_dir/share/ubsan_blocklist.txt
  clang/test/Driver/Inputs/resource_dir/share/vtables_blacklist.txt
  clang/test/Driver/Inputs/resource_dir/share/vtables_blocklist.txt
  clang/test/Driver/fsanitize-blacklist.c
  clang/test/Driver/print-file-name.c
  
clang/test/Frontend/Inputs/resource_dir_with_sanitizer_blacklist/share/ubsan_blacklist.txt
  
clang/test/Frontend/Inputs/resource_dir_with_sanitizer_blacklist/share/ubsan_blocklist.txt
  clang/test/Frontend/dependency-gen.c
  clang/unittests/Driver/SanitizerArgsTest.cpp

Index: clang/unittests/Driver/SanitizerArgsTest.cpp
===
--- clang/unittests/Driver/SanitizerArgsTest.cpp
+++ clang/unittests/Driver/SanitizerArgsTest.cpp
@@ -92,30 +92,30 @@
   std::unique_ptr CompilationJob;
 };
 
-TEST_F(SanitizerArgsTest, Blacklists) {
+TEST_F(SanitizerArgsTest, Blocklists) {
   const std::string ResourceDir = "/opt/llvm/lib/resources";
-  const std::string UserBlacklist = "/source/my_blacklist.txt";
-  const std::string ASanBlacklist =
-  concatPaths({ResourceDir, "share", "asan_blacklist.txt"});
+  const std::string UserBlocklist = "/source/my_blocklist.txt";
+  const std::string ASanBlocklist =
+  concatPaths({ResourceDir, "share", "asan_blocklist.txt"});
 
   auto &Command = emulateSingleCompilation(
   /*ExtraArgs=*/{"-fsanitize=address", "-resource-dir", ResourceDir,
- std::string("-fsanitize-blacklist=") + UserBlacklist},
-  /*ExtraFiles=*/{ASanBlacklist, UserBlacklist});
+ std::string("-fsanitize-blocklist=") + UserBlocklist},
+  /*ExtraFiles=*/{ASanBlocklist, UserBlocklist});
 
-  // System blacklists are added based on resource-dir.
+  // System blocklists are added based on resource-dir.
   EXPECT_THAT(Command.getArguments(),
-  Contains(StrEq(std::string("-fsanitize-system-blacklist=") +
- ASanBlacklist)));
-  // User blacklists should also be added.
+  Contains(StrEq(std::string("-fsanitize-system-blocklist=") +
+ ASanBlocklist)));
+  // User blocklists should also be added.
   EXPECT_THAT(
   Command.getArguments(),
-  Contains(StrEq(std::string("-fsanitize-blacklist=") + UserBlacklist)));
+  Contains(StrEq(std::string("-fsanitize-blocklist=") + UserBlocklist)));
 }
 
 TEST_F(SanitizerArgsTest, XRayLists) {
   const std::string XRayWhitelist = "/source/xray_whitelist.txt";
-  const std::string XRayBlacklist = "/source/xray_blacklist.txt";
+  const std::string XRayBlocklist = "/source/xray_blocklist.txt";
   const std::string XRayAttrList = "/source/xray_attr_list.txt";
 
   auto &Command = emulateSingleCompilation(
@@ -123,17 +123,17 @@
   {
   "-fxray-instrument",
   "-fxray-always-instrument=" + XRayWhitelist,
-  "-fxray-never-instrument=" + XRayBlacklist,
+  "-fxray-never-instrument=" + XRayBlocklist,
   "-fxray-attr-list=" + XRayAttrList,
   },
-  /*ExtraFiles=*/{XRayWhitelist, XRayBlacklist, XRayAttrList});
+  /*ExtraFiles=*/{XRayWhitelist, XRayBlocklist, XRayAttrList});
 
-  // Blacklists exist in the filesystem, so they should be added to the
+  // Blocklists exist in the filesystem, so they should be added to the
   // compilation command, produced by the driver.
   EXPECT_THAT(Command.getArguments(),
   Contains(StrEq("-fxray-always-instrument=" + XRayWhitelist)));
   EXPECT_THAT(Command.getArguments(),
-  Contains(StrEq("-fxray-never-instrument=" + XRayBlacklist)));
+  Contains(StrEq("-fxray-never-instrument=" + XRayBlocklist)));
   EXPECT_THAT(Command.getArguments(),
   Contains(StrEq("-fxray-attr-list=" + XRayAttrList)));
 }
Index: clang/test/Frontend/dependency-gen.c

[PATCH] D96976: [analyzer] Fix reinterpret_cast handling for pointer-to-member

2021-02-25 Thread Deep Majumder via Phabricator via cfe-commits
RedDocMD updated this revision to Diff 326414.
RedDocMD added a comment.

Added some more comments to increase clarity


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D96976/new/

https://reviews.llvm.org/D96976

Files:
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/BasicValueFactory.h
  clang/lib/StaticAnalyzer/Core/BasicValueFactory.cpp
  clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp
  clang/test/Analysis/reinterpret-cast-pointer-to-member.cpp

Index: clang/test/Analysis/reinterpret-cast-pointer-to-member.cpp
===
--- clang/test/Analysis/reinterpret-cast-pointer-to-member.cpp
+++ clang/test/Analysis/reinterpret-cast-pointer-to-member.cpp
@@ -1,11 +1,11 @@
 // RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -verify %s
-// XFAIL: asserts
 
 void clang_analyzer_eval(bool);
 
-// TODO: The following test will work properly once reinterpret_cast on pointer-to-member is handled properly
 namespace testReinterpretCasting {
-struct Base {
+struct BaseOfBase {};
+
+struct Base : public BaseOfBase {
   int field;
 };
 
@@ -15,12 +15,51 @@
 
 struct Some {};
 
-void f() {
+void analyzableCasts() {
   int DoubleDerived::*ddf = &Base::field;
   int Base::*bf = reinterpret_cast(reinterpret_cast(reinterpret_cast(ddf)));
-  int Some::*sf = reinterpret_cast(ddf);
   Base base;
   base.field = 13;
   clang_analyzer_eval(base.*bf == 13); // expected-warning{{TRUE}}
 }
+
+void castOutsideHierarchy() {
+  int DoubleDerived::*ddf = &Base::field;
+  int Some::*sf = reinterpret_cast(ddf);
+  Some some;
+  some.*sf = 14;
+  clang_analyzer_eval(some.*sf == 14); // expected-warning{{UNKNOWN}}
+}
+
+void castAbove() {
+  int DoubleDerived::*ddf = &Base::field;
+  int BaseOfBase::*bbf = reinterpret_cast(ddf);
+  BaseOfBase bb;
+  bb.*bbf = 23;
+  clang_analyzer_eval(bb.*bbf == 23); // expected-warning{{UNKNOWN}}
+}
+
+namespace testMultipleInheritance {
+struct A {};
+struct B : public A {};
+struct C {
+  int field;
+};
+struct D : public C {};
+struct E : public B, public D {};
+struct F : public E {};
+
+void testMultiple() {
+  int F::*f = &F::field;
+  int A::*a = reinterpret_cast(f);
+  int C::*c = reinterpret_cast(f);
+  A aobj;
+  C cobj;
+  aobj.*a = 13;
+  cobj.*c = 29;
+  clang_analyzer_eval(aobj.*a == 13); // expected-warning{{UNKNOWN}}
+  clang_analyzer_eval(cobj.*c == 29); // expected-warning{{TRUE}}
+}
+} // namespace testMultipleInheritance
+
 } // namespace testReinterpretCasting
Index: clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp
===
--- clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp
+++ clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp
@@ -522,8 +522,7 @@
 continue;
   }
   case CK_DerivedToBaseMemberPointer:
-  case CK_BaseToDerivedMemberPointer:
-  case CK_ReinterpretMemberPointer: {
+  case CK_BaseToDerivedMemberPointer: {
 SVal V = state->getSVal(Ex, LCtx);
 if (auto PTMSV = V.getAs()) {
   SVal CastedPTMSV =
@@ -537,6 +536,25 @@
 state = handleLVectorSplat(state, LCtx, CastE, Bldr, Pred);
 continue;
   }
+  case CK_ReinterpretMemberPointer: {
+SVal V = state->getSVal(Ex, LCtx);
+if (auto PTMSV = V.getAs()) {
+  if (const auto *ReinterpretE =
+  llvm::dyn_cast(CastE)) {
+if (const PointerToMemberData *Data =
+getBasicVals().basesForReinterpretCast(ReinterpretE,
+   *PTMSV)) {
+  SVal CastedPTMSV = svalBuilder.makePointerToMember(Data);
+  state = state->BindExpr(CastE, LCtx, CastedPTMSV);
+  Bldr.generateNode(CastE, Pred, state);
+  continue;
+}
+  }
+}
+// Explicitly proceed with default handler for this case cascade.
+state = handleLVectorSplat(state, LCtx, CastE, Bldr, Pred);
+continue;
+  }
   // Various C++ casts that are not handled yet.
   case CK_ToUnion:
   case CK_VectorSplat: {
Index: clang/lib/StaticAnalyzer/Core/BasicValueFactory.cpp
===
--- clang/lib/StaticAnalyzer/Core/BasicValueFactory.cpp
+++ clang/lib/StaticAnalyzer/Core/BasicValueFactory.cpp
@@ -22,8 +22,11 @@
 #include "llvm/ADT/ImmutableList.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/SmallPtrSet.h"
+#include "llvm/ADT/SmallVector.h"
 #include 
 #include 
+#include 
+#include 
 #include 
 
 using namespace clang;
@@ -239,13 +242,128 @@
 
 return getPointerToMemberData(ND, ReducedBaseSpecList);
   }
-  // FIXME: Reinterpret casts on member-pointers are not handled properly by
-  // this code
   for (const CXXBaseSpecifier *I : llvm::reverse(PathRange))
 BaseSpecList = prependCXXBase(I, BaseSpecList);
   return getPointerToMemberData(ND, BaseSpecList)

[PATCH] D97415: [clang-tidy] Move Checkname out of Diagnostic Message

2021-02-25 Thread Nathan James via Phabricator via cfe-commits
njames93 updated this revision to Diff 326418.
njames93 marked an inline comment as done.
njames93 added a comment.

Typo.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D97415/new/

https://reviews.llvm.org/D97415

Files:
  clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
  clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h
  clang-tools-extra/clangd/Diagnostics.cpp
  clang-tools-extra/clangd/ParsedAST.cpp

Index: clang-tools-extra/clangd/ParsedAST.cpp
===
--- clang-tools-extra/clangd/ParsedAST.cpp
+++ clang-tools-extra/clangd/ParsedAST.cpp
@@ -323,9 +323,10 @@
   isBuiltinDiagnosticSuppressed(Info.getID(), Cfg.Diagnostics.Suppress))
 return DiagnosticsEngine::Ignored;
   if (!CTChecks.empty()) {
-std::string CheckName = CTContext->getCheckName(Info.getID());
-bool IsClangTidyDiag = !CheckName.empty();
-if (IsClangTidyDiag) {
+SmallString<64> Buffer;
+auto CheckName =
+tidy::ClangTidyContext::getDiagnosticName(Info, Buffer);
+if (!CheckName.empty()) {
   if (Cfg.Diagnostics.Suppress.contains(CheckName))
 return DiagnosticsEngine::Ignored;
   // Check for suppression comment. Skip the check for diagnostics not
Index: clang-tools-extra/clangd/Diagnostics.cpp
===
--- clang-tools-extra/clangd/Diagnostics.cpp
+++ clang-tools-extra/clangd/Diagnostics.cpp
@@ -517,24 +517,8 @@
   continue;
 }
 if (Tidy != nullptr) {
-  std::string TidyDiag = Tidy->getCheckName(Diag.ID);
-  if (!TidyDiag.empty()) {
-Diag.Name = std::move(TidyDiag);
+  if (!Diag.Name.empty()) {
 Diag.Source = Diag::ClangTidy;
-// clang-tidy bakes the name into diagnostic messages. Strip it out.
-// It would be much nicer to make clang-tidy not do this.
-auto CleanMessage = [&](std::string &Msg) {
-  StringRef Rest(Msg);
-  if (Rest.consume_back("]") && Rest.consume_back(Diag.Name) &&
-  Rest.consume_back(" ["))
-Msg.resize(Rest.size());
-};
-CleanMessage(Diag.Message);
-for (auto &Note : Diag.Notes)
-  CleanMessage(Note.Message);
-for (auto &Fix : Diag.Fixes)
-  CleanMessage(Fix.Message);
-continue;
   }
 }
   }
@@ -624,6 +608,7 @@
 LastDiagLoc.reset();
 LastDiagOriginallyError = OriginallyError;
 LastDiag->ID = Info.getID();
+LastDiag->Name = tidy::ClangTidyContext::getDiagnosticName(Info);
 fillNonLocationData(DiagLevel, Info, *LastDiag);
 LastDiag->InsideMainFile = true;
 // Put it at the start of the main file, for a lack of a better place.
@@ -734,6 +719,7 @@
 
 LastDiag = Diag();
 FillDiagBase(*LastDiag);
+LastDiag->Name = tidy::ClangTidyContext::getDiagnosticName(Info);
 LastDiagLoc.emplace(Info.getLocation(), Info.getSourceManager());
 LastDiagOriginallyError = OriginallyError;
 
Index: clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h
===
--- clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h
+++ clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h
@@ -123,7 +123,10 @@
 
   /// Returns the name of the clang-tidy check which produced this
   /// diagnostic ID.
-  std::string getCheckName(unsigned DiagnosticID) const;
+  static StringRef getDiagnosticName(const Diagnostic &Info,
+ SmallVectorImpl &Buffer);
+
+  static std::string getDiagnosticName(const Diagnostic &Info);
 
   /// Returns \c true if the check is enabled for the \c CurrentFile.
   ///
@@ -204,8 +207,6 @@
 
   std::string CurrentBuildDirectory;
 
-  llvm::DenseMap CheckNamesByDiagnosticID;
-
   bool Profile;
   std::string ProfilePrefix;
 
Index: clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
===
--- clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
+++ clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
@@ -30,6 +30,7 @@
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/StringMap.h"
+#include "llvm/ADT/StringRef.h"
 #include "llvm/Support/FormatVariadic.h"
 #include "llvm/Support/Regex.h"
 #include 
@@ -50,14 +51,6 @@
  DiagnosticsEngine::Level Level, StringRef Message,
  ArrayRef Ranges,
  DiagOrStoredDiag Info) override {
-// Remove check name from the message.
-// FIXME: Remove this once there's a better way to pass check names than
-// appending the check name to the message in ClangTidyContext::diag and
-// using getCustomDiagID.
-std::string CheckNameInMessage = " [" + Error.DiagnosticName + "]";
-if 

  1   2   3   >