[PATCH] D95346: [clang][cli] Port LangOpts to marshalling system, pt.1

2021-01-26 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 rGb6d87e6a92a9: [clang][cli] Port LangOpts to marshalling 
system, pt.1 (authored by jansvoboda11).

Changed prior to commit:
  https://reviews.llvm.org/D95346?vs=318959=319480#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95346

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
@@ -2017,6 +2017,8 @@
   Opts.HexFloats = Std.hasHexFloats();
   Opts.ImplicitInt = Std.hasImplicitInt();
 
+  Opts.CPlusPlusModules = Opts.CPlusPlus20;
+
   // Set OpenCL Version.
   Opts.OpenCL = Std.isOpenCL();
   if (LangStd == LangStandard::lang_opencl10)
@@ -2078,14 +2080,7 @@
   // C++ has wchar_t keyword.
   Opts.WChar = Opts.CPlusPlus;
 
-  Opts.CXXOperatorNames = Opts.CPlusPlus;
-
   Opts.AlignedAllocation = Opts.CPlusPlus17;
-
-  Opts.DollarIdents = !Opts.AsmPreprocessor;
-
-  // Enable [[]] attributes in C++11 and C2x by default.
-  Opts.DoubleSquareBracketAttributes = Opts.CPlusPlus11 || Opts.C2x;
 }
 
 /// Check if input file kind and language standard are compatible.
@@ -2263,9 +2258,6 @@
 }
   }
 
-  if (Args.hasArg(OPT_fno_operator_names))
-Opts.CXXOperatorNames = 0;
-
   if (Opts.ObjC) {
 if (Arg *arg = Args.getLastArg(OPT_fobjc_runtime_EQ)) {
   StringRef value = arg->getValue();
@@ -2337,8 +2329,6 @@
   else if (Args.hasArg(OPT_fwrapv))
 Opts.setSignedOverflowBehavior(LangOptions::SOB_Defined);
 
-  Opts.MicrosoftExt = Opts.MSVCCompat || Args.hasArg(OPT_fms_extensions);
-  Opts.AsmBlocks = Args.hasArg(OPT_fasm_blocks) || Opts.MicrosoftExt;
   Opts.MSCompatibilityVersion = 0;
   if (const Arg *A = Args.getLastArg(OPT_fms_compatibility_version)) {
 VersionTuple VT;
@@ -2359,48 +2349,13 @@
   Opts.Trigraphs =
   Args.hasFlag(OPT_ftrigraphs, OPT_fno_trigraphs, Opts.Trigraphs);
 
-  Opts.DollarIdents = Args.hasFlag(OPT_fdollars_in_identifiers,
-   OPT_fno_dollars_in_identifiers,
-   Opts.DollarIdents);
-
-  // -ffixed-point
-  Opts.FixedPoint =
-  Args.hasFlag(OPT_ffixed_point, OPT_fno_fixed_point, /*Default=*/false) &&
-  !Opts.CPlusPlus;
-  Opts.PaddingOnUnsignedFixedPoint =
-  Args.hasFlag(OPT_fpadding_on_unsigned_fixed_point,
-   OPT_fno_padding_on_unsigned_fixed_point,
-   /*Default=*/false) &&
-  Opts.FixedPoint;
-
-  Opts.RTTI = Opts.CPlusPlus && !Args.hasArg(OPT_fno_rtti);
-  Opts.RTTIData = Opts.RTTI && !Args.hasArg(OPT_fno_rtti_data);
   Opts.Blocks = Args.hasArg(OPT_fblocks) || (Opts.OpenCL
 && Opts.OpenCLVersion == 200);
-  Opts.Coroutines = Opts.CPlusPlus20 || Args.hasArg(OPT_fcoroutines_ts);
 
   Opts.ConvergentFunctions = Opts.OpenCL || (Opts.CUDA && Opts.CUDAIsDevice) ||
  Opts.SYCLIsDevice ||
  Args.hasArg(OPT_fconvergent_functions);
 
-  Opts.DoubleSquareBracketAttributes =
-  Args.hasFlag(OPT_fdouble_square_bracket_attributes,
-   OPT_fno_double_square_bracket_attributes,
-   Opts.DoubleSquareBracketAttributes);
-
-  Opts.CPlusPlusModules = Opts.CPlusPlus20;
-  Opts.Modules =
-  Args.hasArg(OPT_fmodules) || Opts.ModulesTS || Opts.CPlusPlusModules;
-  Opts.ModulesDeclUse =
-  Args.hasArg(OPT_fmodules_decluse) || Opts.ModulesStrictDeclUse;
-  // FIXME: We only need this in C++ modules / Modules TS if we might textually
-  // enter a different module (eg, when building a header unit).
-  Opts.ModulesLocalVisibility =
-  Args.hasArg(OPT_fmodules_local_submodule_visibility) || Opts.ModulesTS ||
-  Opts.CPlusPlusModules;
-  Opts.ModulesSearchAll = Opts.Modules &&
-!Args.hasArg(OPT_fno_modules_search_all) &&
-Args.hasArg(OPT_fmodules_search_all);
   Opts.CharIsSigned = Opts.OpenCL || !Args.hasArg(OPT_fno_signed_char);
   Opts.WChar = Opts.CPlusPlus && !Args.hasArg(OPT_fno_wchar);
   Opts.Char8 = Args.hasFlag(OPT_fchar8__t, OPT_fno_char8__t, Opts.CPlusPlus20);
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -435,12 +435,17 @@
 
 // Key paths that are constant during parsing of options with the same key path prefix.
 defvar cplusplus = LangOpts<"CPlusPlus">;
+defvar cpp11 = LangOpts<"CPlusPlus11">;
+defvar cpp20 = LangOpts<"CPlusPlus20">;
 defvar c99 = LangOpts<"C99">;
+defvar c2x = LangOpts<"C2x">;
 defvar lang_std = LangOpts<"LangStd">;
 defvar open_cl = LangOpts<"OpenCL">;
 defvar render_script = 

[PATCH] D95502: WIP: Frontend: Adopt llvm::vfs::OutputManager in CompilerInstance

2021-01-26 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith added a comment.

RFC is up at https://lists.llvm.org/pipermail/cfe-dev/2021-January/067576.html


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95502

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


[PATCH] D78058: option to write files to memory instead of disk

2021-01-26 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith added a comment.

In D78058#2481050 , @dexonsmith wrote:

> In D78058#2480411 , @dexonsmith 
> wrote:
>
>> In D78058#2471735 , @sammccall 
>> wrote:
>>
>>> @dexonsmith thanks for sharing!
>>> Some initial thoughts since abstracting outputs is something we're starting 
>>> to care about too...
>>
>> Thanks for looking.
>
> I think I've found a fairly clean way to get the write-through memory buffer 
> optimization with pluggable backends; still working through the other 
> feedback, but hoping to have the patch / RFC out soonish.

FYI, I posted an RFC here: 
https://lists.llvm.org/pipermail/cfe-dev/2021-January/067576.html


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78058

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


[PATCH] D94973: [clang][OpenMP] Use OpenMPIRBuilder for workshare loops.

2021-01-26 Thread Michael Kruse via Phabricator via cfe-commits
Meinersbur added a comment.

ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94973

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


[PATCH] D95502: WIP: Frontend: Adopt llvm::vfs::OutputManager in CompilerInstance

2021-01-26 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith created this revision.
dexonsmith added reviewers: sammccall, erik.pilkington, marcrasi.
Herald added a subscriber: ributzka.
dexonsmith requested review of this revision.
Herald added a project: clang.

[This is supporting an RFC I'll post in a bit; marked WIP for now]

Adopt the new llvm::vfs::OutputManager in CompilerInstance.

Depends on https://reviews.llvm.org/D95501.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D95502

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

Index: clang/lib/Frontend/CompilerInstance.cpp
===
--- clang/lib/Frontend/CompilerInstance.cpp
+++ clang/lib/Frontend/CompilerInstance.cpp
@@ -459,6 +459,10 @@
 collectVFSEntries(*this, ModuleDepCollector);
   }
 
+  // Modules need an output manager.
+  if (!hasOutputManager())
+createOutputManager();
+
   for (auto  : DependencyCollectors)
 Listener->attachToPreprocessor(*PP);
 
@@ -647,27 +651,19 @@
 // Output Files
 
 void CompilerInstance::clearOutputFiles(bool EraseFiles) {
-  for (OutputFile  : OutputFiles) {
-if (EraseFiles) {
-  if (!OF.TempFilename.empty()) {
-llvm::sys::fs::remove(OF.TempFilename);
-continue;
-  }
-  if (!OF.Filename.empty())
-llvm::sys::fs::remove(OF.Filename);
-  continue;
-}
-
-if (OF.TempFilename.empty())
-  continue;
-
-std::error_code EC = llvm::sys::fs::rename(OF.TempFilename, OF.Filename);
-if (!EC)
-  continue;
-getDiagnostics().Report(diag::err_unable_to_rename_temp)
-<< OF.TempFilename << OF.Filename << EC.message();
-
-llvm::sys::fs::remove(OF.TempFilename);
+  if (!EraseFiles) {
+for (auto  : OutputFiles)
+  llvm::handleAllErrors(
+  O->close(),
+  [&](const llvm::vfs::OnDiskOutputRenameTempError ) {
+getDiagnostics().Report(diag::err_unable_to_rename_temp)
+<< E.getTempPath() << E.getOutputPath()
+<< E.getErrorCode().message();
+  },
+  [&](const llvm::vfs::OutputError ) {
+getDiagnostics().Report(diag::err_fe_unable_to_open_output)
+<< E.getOutputPath() << E.getErrorCode().message();
+  });
   }
   OutputFiles.clear();
   if (DeleteBuiltModules) {
@@ -704,6 +700,28 @@
   return std::make_unique();
 }
 
+void CompilerInstance::setOutputManager(
+std::shared_ptr NewOutputs) {
+  assert(!TheOutputManager && "Already has an output manager");
+  TheOutputManager = std::move(NewOutputs);
+}
+
+void CompilerInstance::createOutputManager() {
+  assert(!TheOutputManager && "Already has an output manager");
+  TheOutputManager = std::make_unique();
+}
+
+llvm::vfs::OutputManager ::getOutputManager() {
+  assert(TheOutputManager);
+  return *TheOutputManager;
+}
+
+llvm::vfs::OutputManager ::getOrCreateOutputManager() {
+  if (!hasOutputManager())
+createOutputManager();
+  return getOutputManager();
+}
+
 std::unique_ptr
 CompilerInstance::createOutputFile(StringRef OutputPath, bool Binary,
bool RemoveFileOnSignal, bool UseTemporary,
@@ -735,86 +753,21 @@
 OutputPath = *AbsPath;
   }
 
-  std::unique_ptr OS;
-  Optional OSFile;
+  using namespace llvm::vfs;
+  Expected> O = getOrCreateOutputManager().createOutput(
+  OutputPath,
+  PartialOutputConfig()
+  .set(ClientIntentOutputConfig::NeedsSeeking, Binary)
+  .set(OnDiskOutputConfig::OpenFlagText, !Binary)
+  .set(OnDiskOutputConfig::RemoveFileOnSignal, RemoveFileOnSignal)
+  .set(OnDiskOutputConfig::UseTemporary, UseTemporary)
+  .set(OnDiskOutputConfig::UseTemporaryCreateMissingDirectories,
+   CreateMissingDirectories));
+  if (!O)
+return O.takeError();
 
-  if (UseTemporary) {
-if (OutputPath == "-")
-  UseTemporary = false;
-else {
-  llvm::sys::fs::file_status Status;
-  llvm::sys::fs::status(OutputPath, Status);
-  if (llvm::sys::fs::exists(Status)) {
-// Fail early if we can't write to the final destination.
-if (!llvm::sys::fs::can_write(OutputPath))
-  return llvm::errorCodeToError(
-  make_error_code(llvm::errc::operation_not_permitted));
-
-// Don't use a temporary if the output is a special file. This handles
-// things like '-o /dev/null'
-if (!llvm::sys::fs::is_regular_file(Status))
-  UseTemporary = false;
-  }
-}
-  }
-
-  std::string TempFile;
-  if (UseTemporary) {
-// Create a temporary file.
-// Insert - before the extension (if any), and because some tools
-// (noticeable, clang's own GlobalModuleIndex.cpp) glob for build
-// artifacts, also append .tmp.
-StringRef OutputExtension = llvm::sys::path::extension(OutputPath);
-SmallString<128> TempPath =
-StringRef(OutputPath).drop_back(OutputExtension.size());
-TempPath += 

[PATCH] D95499: [NFC] Disallow unused prefixes under clang/test/CodeGenCXX

2021-01-26 Thread Mircea Trofin via Phabricator via cfe-commits
mtrofin created this revision.
mtrofin added a reviewer: rnk.
mtrofin requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

The only test that needed change had 'QUAL' as an unused prefix. The
rest of the changes are to simplify the prefix lists.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D95499

Files:
  clang/test/CodeGenCXX/debug-info-codeview-display-name.cpp
  clang/test/CodeGenCXX/lit.local.cfg


Index: clang/test/CodeGenCXX/lit.local.cfg
===
--- /dev/null
+++ clang/test/CodeGenCXX/lit.local.cfg
@@ -0,0 +1,9 @@
+# -*- Python -*- vim: set ft=python ts=4 sw=4 expandtab tw=79:
+from lit.llvm.subst import ToolSubst
+
+fc = ToolSubst('FileCheck', unresolved='fatal')
+# Insert this first. Then, we'll first update the blank FileCheck command; 
then,
+# the default substitution of FileCheck will replace it to its full path.
+config.substitutions.insert(0, (fc.regex,
+'FileCheck --allow-unused-prefixes=false'))
+
Index: clang/test/CodeGenCXX/debug-info-codeview-display-name.cpp
===
--- clang/test/CodeGenCXX/debug-info-codeview-display-name.cpp
+++ clang/test/CodeGenCXX/debug-info-codeview-display-name.cpp
@@ -1,19 +1,19 @@
 // RUN: %clang_cc1 -fblocks -debug-info-kind=limited -gcodeview -emit-llvm %s \
 // RUN:   -o - -triple=x86_64-pc-win32 -Wno-new-returns-null -std=c++98 | \
 // RUN:grep -E 'DISubprogram|DICompositeType' | sed -e 's/.*name: 
"\([^"]*\)".*/"\1"/' | \
-// RUN:FileCheck %s --check-prefix=CHECK --check-prefix=UNQUAL
+// RUN:FileCheck %s --check-prefixes=CHECK,UNQUAL
 // RUN: %clang_cc1 -fblocks -debug-info-kind=line-tables-only -gcodeview 
-emit-llvm %s \
 // RUN:   -o - -triple=x86_64-pc-win32 -Wno-new-returns-null -std=c++98 | \
 // RUN:grep 'DISubprogram' | sed -e 's/.*name: "\([^"]*\)".*/"\1"/' | \
-// RUN:FileCheck %s --check-prefix=CHECK --check-prefix=QUAL
+// RUN:FileCheck %s
 // RUN: %clang_cc1 -fblocks -debug-info-kind=limited -gcodeview -emit-llvm %s \
 // RUN:   -o - -triple=x86_64-pc-win32 -Wno-new-returns-null -std=c++11 | \
 // RUN:grep -E 'DISubprogram|DICompositeType' | sed -e 's/.*name: 
"\([^"]*\)".*/"\1"/' | \
-// RUN:FileCheck %s --check-prefix=CHECK --check-prefix=UNQUAL
+// RUN:FileCheck %s --check-prefixes=CHECK,UNQUAL
 // RUN: %clang_cc1 -fblocks -debug-info-kind=limited -gcodeview -emit-llvm %s \
 // RUN:   -o - -triple=x86_64-pc-win32 -Wno-new-returns-null | \
 // RUN:grep -E 'DISubprogram|DICompositeType' | sed -e 's/.*name: 
"\([^"]*\)".*/"\1"/' | \
-// RUN:FileCheck %s --check-prefix=CHECK --check-prefix=UNQUAL
+// RUN:FileCheck %s --check-prefixes=CHECK,UNQUAL
 
 void freefunc() { }
 // CHECK-DAG: "freefunc"


Index: clang/test/CodeGenCXX/lit.local.cfg
===
--- /dev/null
+++ clang/test/CodeGenCXX/lit.local.cfg
@@ -0,0 +1,9 @@
+# -*- Python -*- vim: set ft=python ts=4 sw=4 expandtab tw=79:
+from lit.llvm.subst import ToolSubst
+
+fc = ToolSubst('FileCheck', unresolved='fatal')
+# Insert this first. Then, we'll first update the blank FileCheck command; then,
+# the default substitution of FileCheck will replace it to its full path.
+config.substitutions.insert(0, (fc.regex,
+'FileCheck --allow-unused-prefixes=false'))
+
Index: clang/test/CodeGenCXX/debug-info-codeview-display-name.cpp
===
--- clang/test/CodeGenCXX/debug-info-codeview-display-name.cpp
+++ clang/test/CodeGenCXX/debug-info-codeview-display-name.cpp
@@ -1,19 +1,19 @@
 // RUN: %clang_cc1 -fblocks -debug-info-kind=limited -gcodeview -emit-llvm %s \
 // RUN:   -o - -triple=x86_64-pc-win32 -Wno-new-returns-null -std=c++98 | \
 // RUN:grep -E 'DISubprogram|DICompositeType' | sed -e 's/.*name: "\([^"]*\)".*/"\1"/' | \
-// RUN:FileCheck %s --check-prefix=CHECK --check-prefix=UNQUAL
+// RUN:FileCheck %s --check-prefixes=CHECK,UNQUAL
 // RUN: %clang_cc1 -fblocks -debug-info-kind=line-tables-only -gcodeview -emit-llvm %s \
 // RUN:   -o - -triple=x86_64-pc-win32 -Wno-new-returns-null -std=c++98 | \
 // RUN:grep 'DISubprogram' | sed -e 's/.*name: "\([^"]*\)".*/"\1"/' | \
-// RUN:FileCheck %s --check-prefix=CHECK --check-prefix=QUAL
+// RUN:FileCheck %s
 // RUN: %clang_cc1 -fblocks -debug-info-kind=limited -gcodeview -emit-llvm %s \
 // RUN:   -o - -triple=x86_64-pc-win32 -Wno-new-returns-null -std=c++11 | \
 // RUN:grep -E 'DISubprogram|DICompositeType' | sed -e 's/.*name: "\([^"]*\)".*/"\1"/' | \
-// RUN:FileCheck %s --check-prefix=CHECK --check-prefix=UNQUAL
+// RUN:FileCheck %s --check-prefixes=CHECK,UNQUAL
 // RUN: %clang_cc1 -fblocks -debug-info-kind=limited -gcodeview -emit-llvm %s \
 // RUN:   -o - -triple=x86_64-pc-win32 -Wno-new-returns-null | \
 // RUN:

[PATCH] D95497: Frontend: Respect -working-directory when checking if output files can be written

2021-01-26 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith created this revision.
dexonsmith added a reviewer: erik.pilkington.
Herald added a subscriber: ributzka.
dexonsmith requested review of this revision.
Herald added a project: clang.

Call `FixupRelativePath` when opening output files to ensure that
`-working-directory` is used when checking up front for write failures,
not just when finalizing the files at the end. This also moves the
temporary file into the same directory as the output file.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D95497

Files:
  clang/lib/Frontend/CompilerInstance.cpp
  clang/test/Frontend/output-paths.c


Index: clang/test/Frontend/output-paths.c
===
--- clang/test/Frontend/output-paths.c
+++ clang/test/Frontend/output-paths.c
@@ -2,3 +2,9 @@
 // RUN: FileCheck -check-prefix=OUTPUTFAIL -input-file=%t %s
 
 // OUTPUTFAIL: error: unable to open output file 
'{{.*}}doesnotexist{{.}}somename': '{{[nN]}}o such file or directory'
+
+// Check that -working-directory is respected when diagnosing output failures.
+//
+// RUN: rm -rf %t.d && mkdir -p %t.d/%basename_t-inner.d
+// RUN: %clang_cc1 -emit-llvm -working-directory %t.d -E -o 
%basename_t-inner.d/somename %s -verify
+// expected-no-diagnostics
Index: clang/lib/Frontend/CompilerInstance.cpp
===
--- clang/lib/Frontend/CompilerInstance.cpp
+++ clang/lib/Frontend/CompilerInstance.cpp
@@ -661,11 +661,7 @@
 if (OF.TempFilename.empty())
   continue;
 
-// If '-working-directory' was passed, the output filename should be
-// relative to that.
-SmallString<128> NewOutFile(OF.Filename);
-FileMgr->FixupRelativePath(NewOutFile);
-std::error_code EC = llvm::sys::fs::rename(OF.TempFilename, NewOutFile);
+std::error_code EC = llvm::sys::fs::rename(OF.TempFilename, OF.Filename);
 if (!EC)
   continue;
 getDiagnostics().Report(diag::err_unable_to_rename_temp)
@@ -730,6 +726,15 @@
   assert((!CreateMissingDirectories || UseTemporary) &&
  "CreateMissingDirectories is only allowed when using temporary 
files");
 
+  // If '-working-directory' was passed, the output filename should be
+  // relative to that.
+  Optional> AbsPath;
+  if (!llvm::sys::path::is_absolute(OutputPath)) {
+AbsPath.emplace(OutputPath);
+FileMgr->FixupRelativePath(*AbsPath);
+OutputPath = *AbsPath;
+  }
+
   std::unique_ptr OS;
   Optional OSFile;
 


Index: clang/test/Frontend/output-paths.c
===
--- clang/test/Frontend/output-paths.c
+++ clang/test/Frontend/output-paths.c
@@ -2,3 +2,9 @@
 // RUN: FileCheck -check-prefix=OUTPUTFAIL -input-file=%t %s
 
 // OUTPUTFAIL: error: unable to open output file '{{.*}}doesnotexist{{.}}somename': '{{[nN]}}o such file or directory'
+
+// Check that -working-directory is respected when diagnosing output failures.
+//
+// RUN: rm -rf %t.d && mkdir -p %t.d/%basename_t-inner.d
+// RUN: %clang_cc1 -emit-llvm -working-directory %t.d -E -o %basename_t-inner.d/somename %s -verify
+// expected-no-diagnostics
Index: clang/lib/Frontend/CompilerInstance.cpp
===
--- clang/lib/Frontend/CompilerInstance.cpp
+++ clang/lib/Frontend/CompilerInstance.cpp
@@ -661,11 +661,7 @@
 if (OF.TempFilename.empty())
   continue;
 
-// If '-working-directory' was passed, the output filename should be
-// relative to that.
-SmallString<128> NewOutFile(OF.Filename);
-FileMgr->FixupRelativePath(NewOutFile);
-std::error_code EC = llvm::sys::fs::rename(OF.TempFilename, NewOutFile);
+std::error_code EC = llvm::sys::fs::rename(OF.TempFilename, OF.Filename);
 if (!EC)
   continue;
 getDiagnostics().Report(diag::err_unable_to_rename_temp)
@@ -730,6 +726,15 @@
   assert((!CreateMissingDirectories || UseTemporary) &&
  "CreateMissingDirectories is only allowed when using temporary files");
 
+  // If '-working-directory' was passed, the output filename should be
+  // relative to that.
+  Optional> AbsPath;
+  if (!llvm::sys::path::is_absolute(OutputPath)) {
+AbsPath.emplace(OutputPath);
+FileMgr->FixupRelativePath(*AbsPath);
+OutputPath = *AbsPath;
+  }
+
   std::unique_ptr OS;
   Optional OSFile;
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D95496: [clang][OpenMP] Augment ForStmt/CXXForRangeStmt for OpenMP canonicial loop.

2021-01-26 Thread Michael Kruse via Phabricator via cfe-commits
Meinersbur created this revision.
Meinersbur added reviewers: jdoerfert, AMDChirag, anchu-rajendran, 
kiranchandramohan, SouraVX, ftynse, kiranktp, fghanim, ABataev, craig.topper, 
dblaikie, rsmith, aaron.ballman.
Herald added subscribers: dexonsmith, martong, guansong, hiraditya, yaxunl.
Herald added a reviewer: shafik.
Meinersbur requested review of this revision.
Herald added subscribers: llvm-commits, sstefan1.
Herald added projects: clang, LLVM.

Alternative version of D94973 . Instead of a 
new AST node of kind OMPCanonicalLoop that acts as parent of a ForStmt or 
CXXForRangeStmt, introduce a new superclass for both classes for storying the 
properties for an OpenMP canonical loop.

This was suggested by @ABataev following the same approach taken in D83261 
 for directives. In this patch, the equivalent 
of OMPChildren is LoopChildren and the class corresponding to 
OMPExecutableDirective is MaybeCanonicalLoopStmt.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D95496

Files:
  clang/include/clang/AST/Stmt.h
  clang/include/clang/AST/StmtCXX.h
  clang/include/clang/Basic/StmtNodes.td
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/Stmt.cpp
  clang/lib/AST/StmtCXX.cpp
  clang/lib/CodeGen/CGStmt.cpp
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/lib/Parse/ParseOpenMP.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaOpenMP.cpp
  clang/lib/Sema/SemaStmt.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTReaderStmt.cpp
  clang/lib/Serialization/ASTWriterStmt.cpp
  clang/test/OpenMP/irbuilder_for_iterator.cpp
  clang/test/OpenMP/irbuilder_for_rangefor.cpp
  clang/test/OpenMP/irbuilder_for_unsigned.c
  llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
  llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp

Index: llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
===
--- llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
+++ llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
@@ -971,7 +971,8 @@
 
   // Emit the body content. We do it after connecting the loop to the CFG to
   // avoid that the callback encounters degenerate BBs.
-  BodyGenCB(CL->getBodyIP(), CL->getIndVar());
+  if (BodyGenCB)
+BodyGenCB(CL->getBodyIP(), CL->getIndVar());
 
 #ifndef NDEBUG
   CL->assertOK();
@@ -1164,6 +1165,13 @@
   return CLI;
 }
 
+CanonicalLoopInfo *OpenMPIRBuilder::createWorkshareLoop(
+const LocationDescription , CanonicalLoopInfo *CLI,
+InsertPointTy AllocaIP, bool NeedsBarrier) {
+  // Currently only supports static schedules.
+  return createStaticWorkshareLoop(Loc, CLI, AllocaIP, NeedsBarrier);
+}
+
 /// Make \p Source branch to \p Target.
 ///
 /// Handles two situations:
Index: llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
===
--- llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
+++ llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
@@ -300,6 +300,12 @@
bool NeedsBarrier,
Value *Chunk = nullptr);
 
+  /// Modifies the canonical loop to be a workshare loop.
+  CanonicalLoopInfo *createWorkshareLoop(const LocationDescription ,
+ CanonicalLoopInfo *CLI,
+ InsertPointTy AllocaIP,
+ bool NeedsBarrier);
+
   /// Tile a loop nest.
   ///
   /// Tiles the loops of \p Loops by the tile sizes in \p TileSizes. Loops in
Index: clang/test/OpenMP/irbuilder_for_unsigned.c
===
--- /dev/null
+++ clang/test/OpenMP/irbuilder_for_unsigned.c
@@ -0,0 +1,147 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --function-signature --include-generated-funcs
+// RUN: %clang_cc1 -fopenmp-enable-irbuilder -verify -fopenmp -fopenmp-version=45 -x c++ -triple x86_64-unknown-unknown -emit-llvm %s -o - | FileCheck %s
+// expected-no-diagnostics
+
+#ifndef HEADER
+#define HEADER
+
+extern "C" void workshareloop_unsigned(float *a, float *b, float *c, float *d) {
+#pragma omp for
+  for (unsigned i = 33; i < 3200; i += 7) {
+a[i] = b[i] * c[i] * d[i];
+  }
+}
+
+#endif // HEADER
+// CHECK-LABEL: define {{[^@]+}}@workshareloop_unsigned
+// CHECK-SAME: (float* [[A:%.*]], float* [[B:%.*]], float* [[C:%.*]], float* [[D:%.*]]) [[ATTR0:#.*]] {
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[A_ADDR:%.*]] = alloca float*, align 8
+// CHECK-NEXT:[[B_ADDR:%.*]] = alloca float*, align 8
+// CHECK-NEXT:[[C_ADDR:%.*]] = alloca float*, align 8
+// CHECK-NEXT:[[D_ADDR:%.*]] = alloca float*, align 8
+// CHECK-NEXT:[[I:%.*]] = alloca i32, align 4
+// CHECK-NEXT:[[AGG_CAPTURED:%.*]] = alloca [[STRUCT_ANON:%.*]], align 8
+// CHECK-NEXT:

[PATCH] D91913: Suppress non-conforming GNU paste extension in all standard-conforming modes

2021-01-26 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

We need a solution to our problem in the short term, though: there must be a 
code pattern that can be used in -std=c++14 modes to accomplish what the `, ## 
__VA_ARGS__` code pattern accomplishes with GCC extensions.

As of right now, my understanding is that `__VA_OPT__` is unavailable in C++14 
mode, so I can't go fix Chrome code to use it. If there is some other 
straightforward way to achieve the outcome, I'm open to it. Until there is, 
please revert this change.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91913

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


[PATCH] D94466: [X86] merge "={eax}" and "~{eax}" into "=" for MSInlineASM

2021-01-26 Thread Pengfei Wang via Phabricator via cfe-commits
pengfei accepted this revision.
pengfei added a comment.
This revision is now accepted and ready to land.

LGTM.




Comment at: clang/lib/CodeGen/CGStmt.cpp:2491
+std::string::size_type position1 =
+Constraints.find("={" + Clobber.str() + "}");
+if (position1 != std::string::npos) {

I'm not sure if there's real case that there's `"={edx}"` for MS inline asm, 
but there's no problem we handle it here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94466

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


[PATCH] D94820: Support for instrumenting only selected files or functions

2021-01-26 Thread Petr Hosek via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGbb9eb1982980: Support for instrumenting only selected files 
or functions (authored by phosek).

Changed prior to commit:
  https://reviews.llvm.org/D94820?vs=319359=319444#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94820

Files:
  clang/docs/ClangCommandLineReference.rst
  clang/docs/UsersManual.rst
  clang/include/clang/AST/ASTContext.h
  clang/include/clang/Basic/LangOptions.h
  clang/include/clang/Basic/ProfileList.h
  clang/include/clang/Driver/Options.td
  clang/lib/AST/ASTContext.cpp
  clang/lib/Basic/CMakeLists.txt
  clang/lib/Basic/ProfileList.cpp
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/CodeGen/CodeGenModule.h
  clang/lib/CodeGen/CodeGenPGO.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGen/profile-filter.c
  llvm/include/llvm/Bitcode/LLVMBitCodes.h
  llvm/include/llvm/IR/Attributes.td
  llvm/lib/AsmParser/LLLexer.cpp
  llvm/lib/AsmParser/LLParser.cpp
  llvm/lib/AsmParser/LLToken.h
  llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
  llvm/lib/IR/Attributes.cpp
  llvm/lib/IR/Verifier.cpp
  llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp
  llvm/lib/Transforms/Utils/CodeExtractor.cpp
  llvm/test/Transforms/PGOProfile/noprofile.ll

Index: llvm/test/Transforms/PGOProfile/noprofile.ll
===
--- /dev/null
+++ llvm/test/Transforms/PGOProfile/noprofile.ll
@@ -0,0 +1,25 @@
+; RUN: opt < %s -pgo-instr-gen -S | FileCheck %s
+; RUN: opt < %s -passes=pgo-instr-gen -S | FileCheck %s
+
+target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+@i = dso_local global i32 0, align 4
+
+define i32 @test1() {
+entry:
+; CHECK: call void @llvm.instrprof.increment
+  %0 = load i32, i32* @i, align 4
+  %add = add i32 %0, 1
+  ret i32 %add
+}
+
+define i32 @test2() #0 {
+entry:
+; CHECK-NOT: call void @llvm.instrprof.increment
+  %0 = load i32, i32* @i, align 4
+  %sub = sub i32 %0, 1
+  ret i32 %sub
+}
+
+attributes #0 = { noprofile }
Index: llvm/lib/Transforms/Utils/CodeExtractor.cpp
===
--- llvm/lib/Transforms/Utils/CodeExtractor.cpp
+++ llvm/lib/Transforms/Utils/CodeExtractor.cpp
@@ -973,6 +973,7 @@
   case Attribute::UWTable:
   case Attribute::NoCfCheck:
   case Attribute::MustProgress:
+  case Attribute::NoProfile:
 break;
   }
 
Index: llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp
===
--- llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp
+++ llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp
@@ -1591,6 +1591,8 @@
   for (auto  : M) {
 if (F.isDeclaration())
   continue;
+if (F.hasFnAttribute(llvm::Attribute::NoProfile))
+  continue;
 auto  = LookupTLI(F);
 auto *BPI = LookupBPI(F);
 auto *BFI = LookupBFI(F);
Index: llvm/lib/IR/Verifier.cpp
===
--- llvm/lib/IR/Verifier.cpp
+++ llvm/lib/IR/Verifier.cpp
@@ -1655,6 +1655,7 @@
   case Attribute::StrictFP:
   case Attribute::NullPointerIsValid:
   case Attribute::MustProgress:
+  case Attribute::NoProfile:
 return true;
   default:
 break;
Index: llvm/lib/IR/Attributes.cpp
===
--- llvm/lib/IR/Attributes.cpp
+++ llvm/lib/IR/Attributes.cpp
@@ -403,6 +403,8 @@
 return "nocf_check";
   if (hasAttribute(Attribute::NoRecurse))
 return "norecurse";
+  if (hasAttribute(Attribute::NoProfile))
+return "noprofile";
   if (hasAttribute(Attribute::NoUnwind))
 return "nounwind";
   if (hasAttribute(Attribute::OptForFuzzing))
Index: llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
===
--- llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
+++ llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
@@ -680,6 +680,8 @@
 return bitc::ATTR_KIND_NOSYNC;
   case Attribute::NoCfCheck:
 return bitc::ATTR_KIND_NOCF_CHECK;
+  case Attribute::NoProfile:
+return bitc::ATTR_KIND_NO_PROFILE;
   case Attribute::NoUnwind:
 return bitc::ATTR_KIND_NO_UNWIND;
   case Attribute::NullPointerIsValid:
Index: llvm/lib/AsmParser/LLToken.h
===
--- llvm/lib/AsmParser/LLToken.h
+++ llvm/lib/AsmParser/LLToken.h
@@ -210,6 +210,7 @@
   kw_nonlazybind,
   kw_nomerge,
   kw_nonnull,
+  kw_noprofile,
   kw_noredzone,
   kw_noreturn,
   kw_nosync,
Index: llvm/lib/AsmParser/LLParser.cpp
===
--- 

[PATCH] D95313: [WIP] Move part of nvptx devicertl under clang

2021-01-26 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield abandoned this revision.
JonChesterfield added a comment.

Abandoned in favour of multiple instantiations of the devicertl, which works 
across all languages and doesn't require hacks to clang


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95313

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


[PATCH] D95492: Pack relocations for Android when possible.

2021-01-26 Thread Dan Albert via Phabricator via cfe-commits
danalbert created this revision.
danalbert added reviewers: rprichard, srhines, rahulchaudhry.
danalbert added a project: clang.
danalbert requested review of this revision.

First supported by API 28.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D95492

Files:
  clang/lib/Driver/ToolChains/Linux.cpp
  clang/test/Driver/linux-ld.c


Index: clang/test/Driver/linux-ld.c
===
--- clang/test/Driver/linux-ld.c
+++ clang/test/Driver/linux-ld.c
@@ -1103,6 +1103,22 @@
 // CHECK-ANDROID-ROSEGMENT-29: "{{.*}}ld{{(.exe)?}}"
 // CHECK-ANDROID-ROSEGMENT-29-NOT: "--no-rosegment"
 
+// Check that we pass --pack-dyn-relocs=relr for API 28+ and not before.
+// RUN: %clang %s -### -o %t.o 2>&1 \
+// RUN: --target=armv7-linux-android27 \
+// RUN:   | FileCheck --check-prefix=CHECK-ANDROID-RELR-27 %s
+// CHECK-ANDROID-RELR-27: "{{.*}}ld{{(.exe)?}}"
+// CHECK-ANDROID-RELR-27-NOT: "--pack-dyn-relocs=relr"
+// CHECK-ANDROID-RELR-27-NOT: "--pack-dyn-relocs=android+relr"
+//
+// RUN: %clang %s -### -o %t.o 2>&1 \
+// RUN: --target=armv7-linux-android28 \
+// RUN:   | FileCheck --check-prefix=CHECK-ANDROID-RELR-28 %s
+// CHECK-ANDROID-RELR-28: "{{.*}}ld{{(.exe)?}}"
+// CHECK-ANDROID-RELR-28: "--use-android-relr-tags"
+// CHECK-ANDROID-RELR-28: "--pack-dyn-relocs=relr"
+// CHECK-ANDROID-RELR-28-NOT: "--pack-dyn-relocs=android+relr"
+
 // RUN: %clang %s -### -o %t.o 2>&1 \
 // RUN: --target=armv7-linux-android21 \
 // RUN:   | FileCheck --check-prefix=CHECK-ANDROID-NOEXECSTACK %s
Index: clang/lib/Driver/ToolChains/Linux.cpp
===
--- clang/lib/Driver/ToolChains/Linux.cpp
+++ clang/lib/Driver/ToolChains/Linux.cpp
@@ -245,6 +245,17 @@
 ExtraOpts.push_back("--no-rosegment");
   }
 
+  if (Triple.isAndroid() && !Triple.isAndroidVersionLT(28)) {
+// Android supports relr packing starting with API 28 and had its own 
flavor
+// (--pack-dyn-relocs=android) starting in API 23. It's possible to use 
both
+// with --pack-dyn-relocs=android+relr, but we need to gather some data on
+// the impact of that form before we can know if it's a good default.
+//
+// On the other hand, relr should always be an improvement.
+ExtraOpts.push_back("--use-android-relr-tags");
+ExtraOpts.push_back("--pack-dyn-relocs=relr");
+  }
+
   // Android ARM/AArch64 use max-page-size=4096 to reduce VMA usage. Note, lld
   // from 11 onwards default max-page-size to 65536 for both ARM and AArch64.
   if ((Triple.isARM() || Triple.isAArch64()) && Triple.isAndroid()) {


Index: clang/test/Driver/linux-ld.c
===
--- clang/test/Driver/linux-ld.c
+++ clang/test/Driver/linux-ld.c
@@ -1103,6 +1103,22 @@
 // CHECK-ANDROID-ROSEGMENT-29: "{{.*}}ld{{(.exe)?}}"
 // CHECK-ANDROID-ROSEGMENT-29-NOT: "--no-rosegment"
 
+// Check that we pass --pack-dyn-relocs=relr for API 28+ and not before.
+// RUN: %clang %s -### -o %t.o 2>&1 \
+// RUN: --target=armv7-linux-android27 \
+// RUN:   | FileCheck --check-prefix=CHECK-ANDROID-RELR-27 %s
+// CHECK-ANDROID-RELR-27: "{{.*}}ld{{(.exe)?}}"
+// CHECK-ANDROID-RELR-27-NOT: "--pack-dyn-relocs=relr"
+// CHECK-ANDROID-RELR-27-NOT: "--pack-dyn-relocs=android+relr"
+//
+// RUN: %clang %s -### -o %t.o 2>&1 \
+// RUN: --target=armv7-linux-android28 \
+// RUN:   | FileCheck --check-prefix=CHECK-ANDROID-RELR-28 %s
+// CHECK-ANDROID-RELR-28: "{{.*}}ld{{(.exe)?}}"
+// CHECK-ANDROID-RELR-28: "--use-android-relr-tags"
+// CHECK-ANDROID-RELR-28: "--pack-dyn-relocs=relr"
+// CHECK-ANDROID-RELR-28-NOT: "--pack-dyn-relocs=android+relr"
+
 // RUN: %clang %s -### -o %t.o 2>&1 \
 // RUN: --target=armv7-linux-android21 \
 // RUN:   | FileCheck --check-prefix=CHECK-ANDROID-NOEXECSTACK %s
Index: clang/lib/Driver/ToolChains/Linux.cpp
===
--- clang/lib/Driver/ToolChains/Linux.cpp
+++ clang/lib/Driver/ToolChains/Linux.cpp
@@ -245,6 +245,17 @@
 ExtraOpts.push_back("--no-rosegment");
   }
 
+  if (Triple.isAndroid() && !Triple.isAndroidVersionLT(28)) {
+// Android supports relr packing starting with API 28 and had its own flavor
+// (--pack-dyn-relocs=android) starting in API 23. It's possible to use both
+// with --pack-dyn-relocs=android+relr, but we need to gather some data on
+// the impact of that form before we can know if it's a good default.
+//
+// On the other hand, relr should always be an improvement.
+ExtraOpts.push_back("--use-android-relr-tags");
+ExtraOpts.push_back("--pack-dyn-relocs=relr");
+  }
+
   // Android ARM/AArch64 use max-page-size=4096 to reduce VMA usage. Note, lld
   // from 11 onwards default max-page-size to 65536 for both ARM and AArch64.
   if ((Triple.isARM() || Triple.isAArch64()) && Triple.isAndroid()) {
___
cfe-commits mailing list

[PATCH] D94881: WIP: Add a way to define matcher builders in the dynamic registry

2021-01-26 Thread Stephen Kelly via Phabricator via cfe-commits
steveire abandoned this revision.
steveire added a comment.

The split here is artificial. This can't be tested without the changes adding 
mapAnyOf support.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94881

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


[PATCH] D94880: Add clang-query support for mapAnyOf

2021-01-26 Thread Stephen Kelly via Phabricator via cfe-commits
steveire updated this revision to Diff 319431.
steveire added a comment.

Update


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94880

Files:
  clang/include/clang/ASTMatchers/Dynamic/Diagnostics.h
  clang/include/clang/ASTMatchers/Dynamic/Parser.h
  clang/include/clang/ASTMatchers/Dynamic/Registry.h
  clang/include/clang/ASTMatchers/Dynamic/VariantValue.h
  clang/lib/ASTMatchers/Dynamic/Diagnostics.cpp
  clang/lib/ASTMatchers/Dynamic/Marshallers.h
  clang/lib/ASTMatchers/Dynamic/Parser.cpp
  clang/lib/ASTMatchers/Dynamic/Registry.cpp
  clang/lib/ASTMatchers/Dynamic/VariantValue.cpp
  clang/unittests/ASTMatchers/Dynamic/ParserTest.cpp

Index: clang/unittests/ASTMatchers/Dynamic/ParserTest.cpp
===
--- clang/unittests/ASTMatchers/Dynamic/ParserTest.cpp
+++ clang/unittests/ASTMatchers/Dynamic/ParserTest.cpp
@@ -32,6 +32,17 @@
 return M.getID().second;
   }
 
+  bool isBuilderMatcher(MatcherCtor) const override { return false; }
+
+  ASTNodeKind nodeMatcherType(MatcherCtor) const override { return {}; }
+
+  internal::MatcherDescriptorPtr
+  buildMatcherCtor(MatcherCtor, SourceRange NameRange,
+   ArrayRef Args,
+   Diagnostics *Error) const override {
+return {};
+  }
+
   void parse(StringRef Code) {
 Diagnostics Error;
 VariantValue Value;
@@ -329,7 +340,7 @@
 "1:5: Invalid token <(> found when looking for a value.",
 ParseWithError("Foo(("));
   EXPECT_EQ("1:7: Expected end of code.", ParseWithError("expr()a"));
-  EXPECT_EQ("1:11: Malformed bind() expression.",
+  EXPECT_EQ("1:11: Period not followed by valid chained call.",
 ParseWithError("isArrow().biind"));
   EXPECT_EQ("1:15: Malformed bind() expression.",
 ParseWithError("isArrow().bind"));
@@ -340,6 +351,20 @@
   EXPECT_EQ("1:1: Error building matcher isArrow.\n"
 "1:1: Matcher does not support binding.",
 ParseWithError("isArrow().bind(\"foo\")"));
+  EXPECT_EQ("1:1: Error building matcher isArrow.\n"
+"1:11: Matcher does not support with call.",
+ParseWithError("isArrow().with"));
+  EXPECT_EQ(
+  "1:22: Error parsing matcher. Found token  while looking for '('.",
+  ParseWithError("mapAnyOf(ifStmt).with"));
+  EXPECT_EQ(
+  "1:22: Error parsing matcher. Found end-of-code while looking for ')'.",
+  ParseWithError("mapAnyOf(ifStmt).with("));
+  EXPECT_EQ("1:1: Failed to build matcher: mapAnyOf.",
+ParseWithError("mapAnyOf()"));
+  EXPECT_EQ("1:1: Error parsing argument 1 for matcher mapAnyOf.\n1:1: Failed "
+"to build matcher: mapAnyOf.",
+ParseWithError("mapAnyOf(\"foo\")"));
   EXPECT_EQ("Input value has unresolved overloaded type: "
 "Matcher",
 ParseMatcherWithError("hasBody(stmt())"));
@@ -470,7 +495,8 @@
 )matcher";
 M = Parser::parseMatcherExpression(Code, nullptr, , );
 EXPECT_FALSE(M.hasValue());
-EXPECT_EQ("1:11: Malformed bind() expression.", Error.toStringFull());
+EXPECT_EQ("1:11: Period not followed by valid chained call.",
+  Error.toStringFull());
   }
 
   {
@@ -515,6 +541,29 @@
   ASSERT_EQ(1u, Comps.size());
   EXPECT_EQ("bind(\"", Comps[0].TypedText);
   EXPECT_EQ("bind", Comps[0].MatcherDecl);
+
+  Code = "mapAny";
+  Comps = Parser::completeExpression(Code, 6);
+  ASSERT_EQ(1u, Comps.size());
+  EXPECT_EQ("Of(", Comps[0].TypedText);
+  EXPECT_EQ("Matcher "
+"mapAnyOf(NestedNameSpecifierLoc|QualType|TypeLoc|"
+"NestedNameSpecifier|Decl|Stmt|Type...)",
+Comps[0].MatcherDecl);
+
+  Code = "mapAnyOf(ifStmt).";
+  Comps = Parser::completeExpression(Code, 17);
+  ASSERT_EQ(2u, Comps.size());
+  EXPECT_EQ("bind(\"", Comps[0].TypedText);
+  EXPECT_EQ("bind", Comps[0].MatcherDecl);
+  EXPECT_EQ("with(\"", Comps[1].TypedText);
+  EXPECT_EQ("with", Comps[1].MatcherDecl);
+
+  Code = "mapAnyOf(ifS";
+  Comps = Parser::completeExpression(Code, 12);
+  ASSERT_EQ(1u, Comps.size());
+  EXPECT_EQ("tmt", Comps[0].TypedText);
+  EXPECT_EQ("ifStmt", Comps[0].MatcherDecl);
 }
 
 TEST(ParserTest, CompletionNamedValues) {
Index: clang/lib/ASTMatchers/Dynamic/VariantValue.cpp
===
--- clang/lib/ASTMatchers/Dynamic/VariantValue.cpp
+++ clang/lib/ASTMatchers/Dynamic/VariantValue.cpp
@@ -22,9 +22,11 @@
 std::string ArgKind::asString() const {
   switch (getArgKind()) {
   case AK_Matcher:
-return (Twine("Matcher<") + MatcherKind.asStringRef() + ">").str();
+return (Twine("Matcher<") + NodeKind.asStringRef() + ">").str();
   case AK_Boolean:
 return "boolean";
+  case AK_Node:
+return NodeKind.asStringRef().str();
   case AK_Double:
 return "double";
   case AK_Unsigned:
@@ -38,13 +40,13 @@
 bool ArgKind::isConvertibleTo(ArgKind To, unsigned 

[PATCH] D95166: Disable rosegment for old Android versions.

2021-01-26 Thread Dan Albert via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGfae16fc0eed7: Disable rosegment for old Android versions. 
(authored by danalbert).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95166

Files:
  clang/lib/Driver/ToolChains/Linux.cpp
  clang/test/Driver/linux-ld.c


Index: clang/test/Driver/linux-ld.c
===
--- clang/test/Driver/linux-ld.c
+++ clang/test/Driver/linux-ld.c
@@ -1089,6 +1089,20 @@
 // CHECK-ANDROID-HASH-STYLE-M: "{{.*}}ld{{(.exe)?}}"
 // CHECK-ANDROID-HASH-STYLE-M: "--hash-style=gnu"
 
+// Check that we pass --no-rosegment for pre-29 Android versions and do not for
+// 29+.
+// RUN: %clang %s -### -o %t.o 2>&1 \
+// RUN: --target=armv7-linux-android28 \
+// RUN:   | FileCheck --check-prefix=CHECK-ANDROID-ROSEGMENT-28 %s
+// CHECK-ANDROID-ROSEGMENT-28: "{{.*}}ld{{(.exe)?}}"
+// CHECK-ANDROID-ROSEGMENT-28: "--no-rosegment"
+//
+// RUN: %clang %s -### -o %t.o 2>&1 \
+// RUN: --target=armv7-linux-android29 \
+// RUN:   | FileCheck --check-prefix=CHECK-ANDROID-ROSEGMENT-29 %s
+// CHECK-ANDROID-ROSEGMENT-29: "{{.*}}ld{{(.exe)?}}"
+// CHECK-ANDROID-ROSEGMENT-29-NOT: "--no-rosegment"
+
 // RUN: %clang %s -### -o %t.o 2>&1 \
 // RUN: --target=armv7-linux-android21 \
 // RUN:   | FileCheck --check-prefix=CHECK-ANDROID-NOEXECSTACK %s
Index: clang/lib/Driver/ToolChains/Linux.cpp
===
--- clang/lib/Driver/ToolChains/Linux.cpp
+++ clang/lib/Driver/ToolChains/Linux.cpp
@@ -236,6 +236,15 @@
 ExtraOpts.push_back("relro");
   }
 
+  if (Triple.isAndroid() && Triple.isAndroidVersionLT(29)) {
+// https://github.com/android/ndk/issues/1196
+// The unwinder used by the crash handler on versions of Android prior to
+// API 29 did not correctly handle binaries built with rosegment, which is
+// enabled by default for LLD. Android only supports LLD, so it's not an
+// issue that this flag is not accepted by other linkers.
+ExtraOpts.push_back("--no-rosegment");
+  }
+
   // Android ARM/AArch64 use max-page-size=4096 to reduce VMA usage. Note, lld
   // from 11 onwards default max-page-size to 65536 for both ARM and AArch64.
   if ((Triple.isARM() || Triple.isAArch64()) && Triple.isAndroid()) {


Index: clang/test/Driver/linux-ld.c
===
--- clang/test/Driver/linux-ld.c
+++ clang/test/Driver/linux-ld.c
@@ -1089,6 +1089,20 @@
 // CHECK-ANDROID-HASH-STYLE-M: "{{.*}}ld{{(.exe)?}}"
 // CHECK-ANDROID-HASH-STYLE-M: "--hash-style=gnu"
 
+// Check that we pass --no-rosegment for pre-29 Android versions and do not for
+// 29+.
+// RUN: %clang %s -### -o %t.o 2>&1 \
+// RUN: --target=armv7-linux-android28 \
+// RUN:   | FileCheck --check-prefix=CHECK-ANDROID-ROSEGMENT-28 %s
+// CHECK-ANDROID-ROSEGMENT-28: "{{.*}}ld{{(.exe)?}}"
+// CHECK-ANDROID-ROSEGMENT-28: "--no-rosegment"
+//
+// RUN: %clang %s -### -o %t.o 2>&1 \
+// RUN: --target=armv7-linux-android29 \
+// RUN:   | FileCheck --check-prefix=CHECK-ANDROID-ROSEGMENT-29 %s
+// CHECK-ANDROID-ROSEGMENT-29: "{{.*}}ld{{(.exe)?}}"
+// CHECK-ANDROID-ROSEGMENT-29-NOT: "--no-rosegment"
+
 // RUN: %clang %s -### -o %t.o 2>&1 \
 // RUN: --target=armv7-linux-android21 \
 // RUN:   | FileCheck --check-prefix=CHECK-ANDROID-NOEXECSTACK %s
Index: clang/lib/Driver/ToolChains/Linux.cpp
===
--- clang/lib/Driver/ToolChains/Linux.cpp
+++ clang/lib/Driver/ToolChains/Linux.cpp
@@ -236,6 +236,15 @@
 ExtraOpts.push_back("relro");
   }
 
+  if (Triple.isAndroid() && Triple.isAndroidVersionLT(29)) {
+// https://github.com/android/ndk/issues/1196
+// The unwinder used by the crash handler on versions of Android prior to
+// API 29 did not correctly handle binaries built with rosegment, which is
+// enabled by default for LLD. Android only supports LLD, so it's not an
+// issue that this flag is not accepted by other linkers.
+ExtraOpts.push_back("--no-rosegment");
+  }
+
   // Android ARM/AArch64 use max-page-size=4096 to reduce VMA usage. Note, lld
   // from 11 onwards default max-page-size to 65536 for both ARM and AArch64.
   if ((Triple.isARM() || Triple.isAArch64()) && Triple.isAndroid()) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D93248: Frontend: Fix layering between create{,Default}OutputFile, NFC

2021-01-26 Thread Duncan P. N. Exon Smith 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 rGad7aaa475e5e: Frontend: Fix layering between 
create{,Default}OutputFile, NFC (authored by dexonsmith).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93248

Files:
  clang/include/clang/Frontend/CompilerInstance.h
  clang/lib/Frontend/CompilerInstance.cpp
  clang/lib/Frontend/FrontendActions.cpp
  clang/tools/driver/cc1_main.cpp

Index: clang/tools/driver/cc1_main.cpp
===
--- clang/tools/driver/cc1_main.cpp
+++ clang/tools/driver/cc1_main.cpp
@@ -248,13 +248,9 @@
   if (llvm::timeTraceProfilerEnabled()) {
 SmallString<128> Path(Clang->getFrontendOpts().OutputFile);
 llvm::sys::path::replace_extension(Path, "json");
-if (auto profilerOutput =
-Clang->createOutputFile(Path.str(),
-/*Binary=*/false,
-/*RemoveFileOnSignal=*/false, "",
-/*Extension=*/"json",
-/*useTemporary=*/false)) {
-
+if (auto profilerOutput = Clang->createOutputFile(
+Path.str(), /*Binary=*/false, /*RemoveFileOnSignal=*/false,
+/*useTemporary=*/false)) {
   llvm::timeTraceProfilerWrite(*profilerOutput);
   // FIXME(ibiryukov): make profilerOutput flush in destructor instead.
   profilerOutput->flush();
Index: clang/lib/Frontend/FrontendActions.cpp
===
--- clang/lib/Frontend/FrontendActions.cpp
+++ clang/lib/Frontend/FrontendActions.cpp
@@ -136,13 +136,9 @@
 std::unique_ptr
 GeneratePCHAction::CreateOutputFile(CompilerInstance , StringRef InFile,
 std::string ) {
-  // We use createOutputFile here because this is exposed via libclang, and we
-  // must disable the RemoveFileOnSignal behavior.
-  // We use a temporary to avoid race conditions.
-  std::unique_ptr OS =
-  CI.createOutputFile(CI.getFrontendOpts().OutputFile, /*Binary=*/true,
-  /*RemoveFileOnSignal=*/false, InFile,
-  /*Extension=*/"", CI.getFrontendOpts().UseTemporary);
+  // Because this is exposed via libclang we must disable RemoveFileOnSignal.
+  std::unique_ptr OS = CI.createDefaultOutputFile(
+  /*Binary=*/true, InFile, /*Extension=*/"", /*RemoveFileOnSignal=*/false);
   if (!OS)
 return nullptr;
 
@@ -219,13 +215,10 @@
ModuleMapFile);
   }
 
-  // We use createOutputFile here because this is exposed via libclang, and we
-  // must disable the RemoveFileOnSignal behavior.
-  // We use a temporary to avoid race conditions.
-  return CI.createOutputFile(CI.getFrontendOpts().OutputFile, /*Binary=*/true,
- /*RemoveFileOnSignal=*/false, InFile,
- /*Extension=*/"", /*UseTemporary=*/true,
- /*CreateMissingDirectories=*/true);
+  // Because this is exposed via libclang we must disable RemoveFileOnSignal.
+  return CI.createDefaultOutputFile(/*Binary=*/true, InFile, /*Extension=*/"",
+/*RemoveFileOnSignal=*/false,
+/*CreateMissingDirectories=*/true);
 }
 
 bool GenerateModuleInterfaceAction::BeginSourceFileAction(
Index: clang/lib/Frontend/CompilerInstance.cpp
===
--- clang/lib/Frontend/CompilerInstance.cpp
+++ clang/lib/Frontend/CompilerInstance.cpp
@@ -646,10 +646,6 @@
 
 // Output Files
 
-void CompilerInstance::addOutputFile(OutputFile &) {
-  OutputFiles.push_back(std::move(OutFile));
-}
-
 void CompilerInstance::clearOutputFiles(bool EraseFiles) {
   for (OutputFile  : OutputFiles) {
 if (!OF.TempFilename.empty()) {
@@ -682,10 +678,25 @@
 
 std::unique_ptr
 CompilerInstance::createDefaultOutputFile(bool Binary, StringRef InFile,
-  StringRef Extension) {
-  return createOutputFile(getFrontendOpts().OutputFile, Binary,
-  /*RemoveFileOnSignal=*/true, InFile, Extension,
-  getFrontendOpts().UseTemporary);
+  StringRef Extension,
+  bool RemoveFileOnSignal,
+  bool CreateMissingDirectories) {
+  StringRef OutputPath = getFrontendOpts().OutputFile;
+  Optional> PathStorage;
+  if (OutputPath.empty()) {
+if (InFile == "-" || Extension.empty()) {
+  OutputPath = "-";
+} else {
+  PathStorage.emplace(InFile);
+  llvm::sys::path::replace_extension(*PathStorage, Extension);
+  OutputPath = *PathStorage;
+}
+  }
+
+  // Force a temporary file 

[PATCH] D93922: Itanium Mangling: Mangle `__alignof__` differently than `alignof`.

2021-01-26 Thread James Y Knight via Phabricator via cfe-commits
jyknight added a comment.

OK, I've posted two follow-up changes now.

https://reviews.llvm.org/D95487 fixes the issue with mangleTemplateArg given 
expressions -- this turned out to be a larged-scoped problem than I had 
thought, affecting manglings other than just that used the matrix extension.
https://reviews.llvm.org/D95488 fixes the mangling for enable_if, which had the 
same problem of hardcoding X/E.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93922

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


[PATCH] D95488: Itanium Mangling: In 'enable_if', omit X/E around .

2021-01-26 Thread James Y Knight via Phabricator via cfe-commits
jyknight created this revision.
jyknight added reviewers: rsmith, rjmccall.
jyknight requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

The Clang enable_if extension is mangled as an ,
which is supposed to contain . However, we were
unconditionally emitting X/E around its arguments, neglecting the fact
that  should be emitted directly without the surrounding
X/E.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D95488

Files:
  clang/lib/AST/ItaniumMangle.cpp
  clang/test/CodeGen/enable_if.c
  clang/test/CodeGenCXX/enable_if.cpp

Index: clang/test/CodeGenCXX/enable_if.cpp
===
--- clang/test/CodeGenCXX/enable_if.cpp
+++ clang/test/CodeGenCXX/enable_if.cpp
@@ -5,7 +5,7 @@
 template 
 T test5(T) __attribute__((enable_if(1, "better than non-template")));
 
-// CHECK: @_Z5test5IiEUa9enable_ifIXLi1EEET_S0_
+// CHECK: @_Z5test5IiEUa9enable_ifILi1EET_S0_
 int (*Ptr)(int) = 
 
 // Test itanium mangling for attribute enable_if
Index: clang/test/CodeGen/enable_if.c
===
--- clang/test/CodeGen/enable_if.c
+++ clang/test/CodeGen/enable_if.c
@@ -31,22 +31,22 @@
 void bar(int m) __attribute__((overloadable, enable_if(1, "")));
 // CHECK-LABEL: define{{.*}} void @test2
 void test2() {
-  // CHECK: store void (i32)* @_Z3barUa9enable_ifIXLi1EEEi
+  // CHECK: store void (i32)* @_Z3barUa9enable_ifILi1EEi
   void (*p)(int) = bar;
-  // CHECK: store void (i32)* @_Z3barUa9enable_ifIXLi1EEEi
+  // CHECK: store void (i32)* @_Z3barUa9enable_ifILi1EEi
   void (*p2)(int) = 
-  // CHECK: store void (i32)* @_Z3barUa9enable_ifIXLi1EEEi
+  // CHECK: store void (i32)* @_Z3barUa9enable_ifILi1EEi
   p = bar;
-  // CHECK: store void (i32)* @_Z3barUa9enable_ifIXLi1EEEi
+  // CHECK: store void (i32)* @_Z3barUa9enable_ifILi1EEi
   p = 
 
-  // CHECK: store i8* bitcast (void (i32)* @_Z3barUa9enable_ifIXLi1EEEi to i8*)
+  // CHECK: store i8* bitcast (void (i32)* @_Z3barUa9enable_ifILi1EEi to i8*)
   void *vp1 = (void*)
-  // CHECK: store i8* bitcast (void (i32)* @_Z3barUa9enable_ifIXLi1EEEi to i8*)
+  // CHECK: store i8* bitcast (void (i32)* @_Z3barUa9enable_ifILi1EEi to i8*)
   void *vp2 = (void*)bar;
-  // CHECK: store i8* bitcast (void (i32)* @_Z3barUa9enable_ifIXLi1EEEi to i8*)
+  // CHECK: store i8* bitcast (void (i32)* @_Z3barUa9enable_ifILi1EEi to i8*)
   vp1 = (void*)
-  // CHECK: store i8* bitcast (void (i32)* @_Z3barUa9enable_ifIXLi1EEEi to i8*)
+  // CHECK: store i8* bitcast (void (i32)* @_Z3barUa9enable_ifILi1EEi to i8*)
   vp1 = (void*)bar;
 }
 
@@ -54,13 +54,13 @@
 void baz(int m) __attribute__((overloadable));
 // CHECK-LABEL: define{{.*}} void @test3
 void test3() {
-  // CHECK: store void (i32)* @_Z3bazUa9enable_ifIXLi1EEEi
+  // CHECK: store void (i32)* @_Z3bazUa9enable_ifILi1EEi
   void (*p)(int) = baz;
-  // CHECK: store void (i32)* @_Z3bazUa9enable_ifIXLi1EEEi
+  // CHECK: store void (i32)* @_Z3bazUa9enable_ifILi1EEi
   void (*p2)(int) = 
-  // CHECK: store void (i32)* @_Z3bazUa9enable_ifIXLi1EEEi
+  // CHECK: store void (i32)* @_Z3bazUa9enable_ifILi1EEi
   p = baz;
-  // CHECK: store void (i32)* @_Z3bazUa9enable_ifIXLi1EEEi
+  // CHECK: store void (i32)* @_Z3bazUa9enable_ifILi1EEi
   p = 
 }
 
@@ -71,13 +71,13 @@
 void qux(int m) __attribute__((overloadable, enable_if(1, "")));
 // CHECK-LABEL: define{{.*}} void @test4
 void test4() {
-  // CHECK: store void (i32)* @_Z3quxUa9enable_ifIXLi1EEXLi1EEEi
+  // CHECK: store void (i32)* @_Z3quxUa9enable_ifILi1ELi1EEi
   void (*p)(int) = qux;
-  // CHECK: store void (i32)* @_Z3quxUa9enable_ifIXLi1EEXLi1EEEi
+  // CHECK: store void (i32)* @_Z3quxUa9enable_ifILi1ELi1EEi
   void (*p2)(int) = 
-  // CHECK: store void (i32)* @_Z3quxUa9enable_ifIXLi1EEXLi1EEEi
+  // CHECK: store void (i32)* @_Z3quxUa9enable_ifILi1ELi1EEi
   p = qux;
-  // CHECK: store void (i32)* @_Z3quxUa9enable_ifIXLi1EEXLi1EEEi
+  // CHECK: store void (i32)* @_Z3quxUa9enable_ifILi1ELi1EEi
   p = 
 }
 
@@ -90,6 +90,6 @@
   int foo(char *i __attribute__((pass_object_size(0
   __attribute__((enable_if(1, ""), overloadable));
 
-  // CHECK: call i32 @_Z3fooUa9enable_ifIXLi1EEEPcU17pass_object_size0
+  // CHECK: call i32 @_Z3fooUa9enable_ifILi1EEPcU17pass_object_size0
   foo((void*)0);
 }
Index: clang/lib/AST/ItaniumMangle.cpp
===
--- clang/lib/AST/ItaniumMangle.cpp
+++ clang/lib/AST/ItaniumMangle.cpp
@@ -726,9 +726,17 @@
   EnableIfAttr *EIA = dyn_cast(*I);
   if (!EIA)
 continue;
-  Out << 'X';
-  mangleExpression(EIA->getCond());
-  Out << 'E';
+  if (Context.getASTContext().getLangOpts().getClangABICompat() >
+  LangOptions::ClangABI::Ver11) {
+mangleTemplateArgExpr(EIA->getCond());
+  } else {
+// Prior to Clang 12, we hardcoded the X/E around enable-if's argument,
+// even though  

[PATCH] D95487: Itanium Mangling: Fix handling of in .

2021-01-26 Thread James Y Knight via Phabricator via cfe-commits
jyknight created this revision.
Herald added a subscriber: kristof.beyls.
jyknight requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Previously, we were emitting an extraneous X .. E in 
around an  if the template argument was constructed from
an expression (rather than an already-evaluated literal value).  In
such a case, we would then e.g. emit 'XLi0EE' instead of 'Li0E'.

We had one special-case for DeclRefExpr expressions, in particular, to
omit them the mangled-name without the surrounding X/E. However,
unfortunately, that special case also triggered for ParmVarDecl (a
subtype of VarDecl), and _incorrectly_ emitted 'L_Z .. E' instead of
the proper 'Xfp_E'.

This change causes mangleExpression itself to be responsible for
emitting X/E around non-primary expressions, which removes the
special-case, and corrects both these problems.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D95487

Files:
  clang/lib/AST/ItaniumMangle.cpp
  clang/test/CodeGenCXX/clang-abi-compat.cpp
  clang/test/CodeGenCXX/mangle-abi-tag.cpp
  clang/test/CodeGenCXX/mangle-concept.cpp
  clang/test/CodeGenCXX/mangle-template.cpp
  clang/test/CodeGenCXX/mangle.cpp
  clang/test/CodeGenCXX/matrix-type.cpp
  clang/test/CodeGenCXX/microsoft-uuidof-mangling.cpp

Index: clang/test/CodeGenCXX/microsoft-uuidof-mangling.cpp
===
--- clang/test/CodeGenCXX/microsoft-uuidof-mangling.cpp
+++ clang/test/CodeGenCXX/microsoft-uuidof-mangling.cpp
@@ -60,14 +60,12 @@
 // CHECK-V11: call void @_Z15test_uuidofExprI9HasMemberEvDTu8__uuidofzsrT_6memberE(
 // CHECK-V12: call void @_Z15test_uuidofExprI9HasMemberEvDTu8__uuidofXsrT_6memberEEE(
 // CHECK-V11: call void @_Z16test_uuidofExpr2I10TestStructEvDTcmtlT_Eu8__uuidofzL_ZN9HasMember6memberEEE(
-// CHECK-V12: call void @_Z16test_uuidofExpr2I10TestStructEvDTcmtlT_Eu8__uuidofXL_ZN9HasMember6memberE(
-//TODO: the above mangling is wrong -- the X/E shouldn't be emitted:   ^ ^
+// CHECK-V12: call void @_Z16test_uuidofExpr2I10TestStructEvDTcmtlT_Eu8__uuidofL_ZN9HasMember6member(
 // CHECK: define linkonce_odr void @_ZN8UUIDTestI10TestStructL_Z42_GUID_eafa1952_66f8_438b_8fba_af1bbae42191EEC1Ev
 // CHECK-V11: define linkonce_odr void @_Z15test_uuidofTypeI10TestStructEvDTu8__uuidoftT_E(
 // CHECK-V12: define linkonce_odr void @_Z15test_uuidofTypeI10TestStructEvDTu8__uuidofT_EE(
 // CHECK-V11: define linkonce_odr void @_Z15test_uuidofExprI9HasMemberEvDTu8__uuidofzsrT_6memberE(
 // CHECK-V12: define linkonce_odr void @_Z15test_uuidofExprI9HasMemberEvDTu8__uuidofXsrT_6memberEEE(
 // CHECK-V11: define linkonce_odr void @_Z16test_uuidofExpr2I10TestStructEvDTcmtlT_Eu8__uuidofzL_ZN9HasMember6memberEEE(
-// CHECK-V12: define linkonce_odr void @_Z16test_uuidofExpr2I10TestStructEvDTcmtlT_Eu8__uuidofXL_ZN9HasMember6memberE(
-//TODO: the above mangling is wrong -- the X/E shouldn't be emitted:  ^ ^
+// CHECK-V12: define linkonce_odr void @_Z16test_uuidofExpr2I10TestStructEvDTcmtlT_Eu8__uuidofL_ZN9HasMember6member(
 // CHECK: define linkonce_odr void @_ZN8UUIDTestI10TestStructL_Z42_GUID_eafa1952_66f8_438b_8fba_af1bbae42191EEC2Ev
Index: clang/test/CodeGenCXX/matrix-type.cpp
===
--- clang/test/CodeGenCXX/matrix-type.cpp
+++ clang/test/CodeGenCXX/matrix-type.cpp
@@ -215,14 +215,14 @@
   // CHECK-NEXT:%m4 = alloca [144 x float], align 4
   // CHECK-NEXT:%v = alloca %struct.selector.3, align 1
   // CHECK-NEXT:%undef.agg.tmp4 = alloca %struct.selector.3, align 1
-  // CHECK-NEXT:call void @_Z10use_matrixIiLm12EE8selectorILi3EERu11matrix_typeIXLm10EEXT0_ET_E([120 x i32]* nonnull align 4 dereferenceable(480) %m0)
+  // CHECK-NEXT:call void @_Z10use_matrixIiLm12EE8selectorILi3EERu11matrix_typeILm10EXT0_ET_E([120 x i32]* nonnull align 4 dereferenceable(480) %m0)
   // CHECK-NEXT:call void @_Z10use_matrixIiE8selectorILi2EERu11matrix_typeILm10ELm10ET_E([100 x i32]* nonnull align 4 dereferenceable(400) %m1)
-  // CHECK-NEXT:call void @_Z10use_matrixIiLm12EE8selectorILi1EERu11matrix_typeIXT0_EXLm10EET_E([120 x i32]* nonnull align 4 dereferenceable(480) %m2)
+  // CHECK-NEXT:call void @_Z10use_matrixIiLm12EE8selectorILi1EERu11matrix_typeIXT0_ELm10ET_E([120 x i32]* nonnull align 4 dereferenceable(480) %m2)
   // CHECK-NEXT:call void @_Z10use_matrixIiLm12ELm12EE8selectorILi0EERu11matrix_typeIXT0_EXT1_ET_E([144 x i32]* nonnull align 4 dereferenceable(576) %m3)
   // CHECK-NEXT:call void @_Z10use_matrixILm12ELm12EE8selectorILi4EERu11matrix_typeIXT_EXT0_EfE([144 x float]* nonnull align 4 dereferenceable(576) %m4)
   // CHECK-NEXT:ret void
 
-  // CHECK-LABEL: define linkonce_odr void @_Z10use_matrixIiLm12EE8selectorILi3EERu11matrix_typeIXLm10EEXT0_ET_E([120 x i32]* nonnull align 4 dereferenceable(480) %m)
+  // 

[PATCH] D93922: Itanium Mangling: Mangle `__alignof__` differently than `alignof`.

2021-01-26 Thread James Y Knight via Phabricator via cfe-commits
jyknight updated this revision to Diff 319422.
jyknight retitled this revision from "Mangle `__alignof__` differently than 
`alignof`." to "Itanium Mangling: Mangle `__alignof__` differently than 
`alignof`.".
jyknight added a comment.

Minor updates.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93922

Files:
  clang/lib/AST/ItaniumMangle.cpp
  clang/test/CodeGenCXX/mangle-alignof.cpp
  clang/test/CodeGenCXX/microsoft-uuidof-mangling.cpp
  libcxxabi/src/demangle/ItaniumDemangle.h
  libcxxabi/test/test_demangle.pass.cpp
  llvm/include/llvm/Demangle/ItaniumDemangle.h

Index: llvm/include/llvm/Demangle/ItaniumDemangle.h
===
--- llvm/include/llvm/Demangle/ItaniumDemangle.h
+++ llvm/include/llvm/Demangle/ItaniumDemangle.h
@@ -96,7 +96,6 @@
 X(InitListExpr) \
 X(FoldExpr) \
 X(ThrowExpr) \
-X(UUIDOfExpr) \
 X(BoolExpr) \
 X(StringLiteral) \
 X(LambdaExpr) \
@@ -2035,21 +2034,6 @@
   }
 };
 
-// MSVC __uuidof extension, generated by clang in -fms-extensions mode.
-class UUIDOfExpr : public Node {
-  Node *Operand;
-public:
-  UUIDOfExpr(Node *Operand_) : Node(KUUIDOfExpr), Operand(Operand_) {}
-
-  template void match(Fn F) const { F(Operand); }
-
-  void printLeft(OutputStream ) const override {
-S << "__uuidof(";
-Operand->print(S);
-S << ")";
-  }
-};
-
 class BoolExpr : public Node {
   bool Value;
 
@@ -5013,6 +4997,43 @@
 }
 }
 return nullptr;
+  case 'u': {
+++First;
+Node *Name = getDerived().parseSourceName(/*NameState=*/nullptr);
+if (!Name)
+  return nullptr;
+// Special case legacy __uuidof mangling. The 't' and 'z' appear where the
+// standard encoding expects a , and would be otherwise be
+// interpreted as  node 'short' or 'ellipsis'. However, neither
+// __uuidof(short) nor __uuidof(...) can actually appear, so there is no
+// actual conflict here.
+if (Name->getBaseName() == "__uuidof") {
+  if (numLeft() < 2)
+return nullptr;
+  if (*First == 't') {
+++First;
+Node *Ty = getDerived().parseType();
+if (!Ty)
+  return nullptr;
+return make(Name, makeNodeArray(,  + 1));
+  }
+  if (*First == 'z') {
+++First;
+Node *Ex = getDerived().parseExpr();
+if (!Ex)
+  return nullptr;
+return make(Name, makeNodeArray(,  + 1));
+  }
+}
+size_t ExprsBegin = Names.size();
+while (!consumeIf('E')) {
+  Node *E = getDerived().parseTemplateArg();
+  if (E == nullptr)
+return E;
+  Names.push_back(E);
+}
+return make(Name, popTrailingNodeArray(ExprsBegin));
+  }
   case '1':
   case '2':
   case '3':
@@ -5024,21 +5045,6 @@
   case '9':
 return getDerived().parseUnresolvedName();
   }
-
-  if (consumeIf("u8__uuidoft")) {
-Node *Ty = getDerived().parseType();
-if (!Ty)
-  return nullptr;
-return make(Ty);
-  }
-
-  if (consumeIf("u8__uuidofz")) {
-Node *Ex = getDerived().parseExpr();
-if (!Ex)
-  return nullptr;
-return make(Ex);
-  }
-
   return nullptr;
 }
 
Index: libcxxabi/src/demangle/ItaniumDemangle.h
===
--- libcxxabi/src/demangle/ItaniumDemangle.h
+++ libcxxabi/src/demangle/ItaniumDemangle.h
@@ -96,7 +96,6 @@
 X(InitListExpr) \
 X(FoldExpr) \
 X(ThrowExpr) \
-X(UUIDOfExpr) \
 X(BoolExpr) \
 X(StringLiteral) \
 X(LambdaExpr) \
@@ -2035,21 +2034,6 @@
   }
 };
 
-// MSVC __uuidof extension, generated by clang in -fms-extensions mode.
-class UUIDOfExpr : public Node {
-  Node *Operand;
-public:
-  UUIDOfExpr(Node *Operand_) : Node(KUUIDOfExpr), Operand(Operand_) {}
-
-  template void match(Fn F) const { F(Operand); }
-
-  void printLeft(OutputStream ) const override {
-S << "__uuidof(";
-Operand->print(S);
-S << ")";
-  }
-};
-
 class BoolExpr : public Node {
   bool Value;
 
@@ -5013,6 +4997,43 @@
 }
 }
 return nullptr;
+  case 'u': {
+++First;
+Node *Name = getDerived().parseSourceName(/*NameState=*/nullptr);
+if (!Name)
+  return nullptr;
+// Special case legacy __uuidof mangling. The 't' and 'z' appear where the
+// standard encoding expects a , and would be otherwise be
+// interpreted as  node 'short' or 'ellipsis'. However, neither
+// __uuidof(short) nor __uuidof(...) can actually appear, so there is no
+// actual conflict here.
+if (Name->getBaseName() == "__uuidof") {
+  if (numLeft() < 2)
+return nullptr;
+  if (*First == 't') {
+++First;
+Node *Ty = getDerived().parseType();
+if (!Ty)
+  return nullptr;
+return make(Name, makeNodeArray(,  + 1));
+  }
+  if (*First == 'z') {
+++First;
+Node *Ex = getDerived().parseExpr();
+if (!Ex)
+  

[PATCH] D93260: Frontend: Simplify handling of non-seeking streams in CompilerInstance, NFC

2021-01-26 Thread Duncan P. N. Exon Smith 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 rG2f721476d10c: Frontend: Simplify handling of non-seeking 
streams in CompilerInstance, NFC (authored by dexonsmith).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93260

Files:
  clang/include/clang/Frontend/CompilerInstance.h
  clang/lib/Frontend/CompilerInstance.cpp
  llvm/include/llvm/Support/raw_ostream.h
  llvm/lib/Support/raw_ostream.cpp


Index: llvm/lib/Support/raw_ostream.cpp
===
--- llvm/lib/Support/raw_ostream.cpp
+++ llvm/lib/Support/raw_ostream.cpp
@@ -987,3 +987,5 @@
 void raw_pwrite_stream::anchor() {}
 
 void buffer_ostream::anchor() {}
+
+void buffer_unique_ostream::anchor() {}
Index: llvm/include/llvm/Support/raw_ostream.h
===
--- llvm/include/llvm/Support/raw_ostream.h
+++ llvm/include/llvm/Support/raw_ostream.h
@@ -687,6 +687,18 @@
   ~buffer_ostream() override { OS << str(); }
 };
 
+class buffer_unique_ostream : public raw_svector_ostream {
+  std::unique_ptr OS;
+  SmallVector Buffer;
+
+  virtual void anchor() override;
+
+public:
+  buffer_unique_ostream(std::unique_ptr OS)
+  : raw_svector_ostream(Buffer), OS(std::move(OS)) {}
+  ~buffer_unique_ostream() override { *OS << str(); }
+};
+
 } // end namespace llvm
 
 #endif // LLVM_SUPPORT_RAW_OSTREAM_H
Index: clang/lib/Frontend/CompilerInstance.cpp
===
--- clang/lib/Frontend/CompilerInstance.cpp
+++ clang/lib/Frontend/CompilerInstance.cpp
@@ -678,7 +678,6 @@
   llvm::sys::fs::remove(Module.second);
 BuiltModules.clear();
   }
-  NonSeekStream.reset();
 }
 
 std::unique_ptr
@@ -816,10 +815,7 @@
   if (!Binary || OS->supportsSeeking())
 return std::move(OS);
 
-  auto B = std::make_unique(*OS);
-  assert(!NonSeekStream);
-  NonSeekStream = std::move(OS);
-  return std::move(B);
+  return std::make_unique(std::move(OS));
 }
 
 // Initialization Utilities
Index: clang/include/clang/Frontend/CompilerInstance.h
===
--- clang/include/clang/Frontend/CompilerInstance.h
+++ clang/include/clang/Frontend/CompilerInstance.h
@@ -172,11 +172,6 @@
 }
   };
 
-  /// If the output doesn't support seeking (terminal, pipe). we switch
-  /// the stream to a buffer_ostream. These are the buffer and the original
-  /// stream.
-  std::unique_ptr NonSeekStream;
-
   /// The list of active output files.
   std::list OutputFiles;
 


Index: llvm/lib/Support/raw_ostream.cpp
===
--- llvm/lib/Support/raw_ostream.cpp
+++ llvm/lib/Support/raw_ostream.cpp
@@ -987,3 +987,5 @@
 void raw_pwrite_stream::anchor() {}
 
 void buffer_ostream::anchor() {}
+
+void buffer_unique_ostream::anchor() {}
Index: llvm/include/llvm/Support/raw_ostream.h
===
--- llvm/include/llvm/Support/raw_ostream.h
+++ llvm/include/llvm/Support/raw_ostream.h
@@ -687,6 +687,18 @@
   ~buffer_ostream() override { OS << str(); }
 };
 
+class buffer_unique_ostream : public raw_svector_ostream {
+  std::unique_ptr OS;
+  SmallVector Buffer;
+
+  virtual void anchor() override;
+
+public:
+  buffer_unique_ostream(std::unique_ptr OS)
+  : raw_svector_ostream(Buffer), OS(std::move(OS)) {}
+  ~buffer_unique_ostream() override { *OS << str(); }
+};
+
 } // end namespace llvm
 
 #endif // LLVM_SUPPORT_RAW_OSTREAM_H
Index: clang/lib/Frontend/CompilerInstance.cpp
===
--- clang/lib/Frontend/CompilerInstance.cpp
+++ clang/lib/Frontend/CompilerInstance.cpp
@@ -678,7 +678,6 @@
   llvm::sys::fs::remove(Module.second);
 BuiltModules.clear();
   }
-  NonSeekStream.reset();
 }
 
 std::unique_ptr
@@ -816,10 +815,7 @@
   if (!Binary || OS->supportsSeeking())
 return std::move(OS);
 
-  auto B = std::make_unique(*OS);
-  assert(!NonSeekStream);
-  NonSeekStream = std::move(OS);
-  return std::move(B);
+  return std::make_unique(std::move(OS));
 }
 
 // Initialization Utilities
Index: clang/include/clang/Frontend/CompilerInstance.h
===
--- clang/include/clang/Frontend/CompilerInstance.h
+++ clang/include/clang/Frontend/CompilerInstance.h
@@ -172,11 +172,6 @@
 }
   };
 
-  /// If the output doesn't support seeking (terminal, pipe). we switch
-  /// the stream to a buffer_ostream. These are the buffer and the original
-  /// stream.
-  std::unique_ptr NonSeekStream;
-
   /// The list of active output files.
   std::list OutputFiles;
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org

[PATCH] D93249: Frontend: Fix memory leak in CompilerInstance::setVerboseOutputStream

2021-01-26 Thread Duncan P. N. Exon Smith 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 rG8afabff6b11c: Frontend: Fix memory leak in 
CompilerInstance::setVerboseOutputStream (authored by dexonsmith).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93249

Files:
  clang/lib/Frontend/CompilerInstance.cpp
  clang/unittests/Frontend/OutputStreamTest.cpp


Index: clang/unittests/Frontend/OutputStreamTest.cpp
===
--- clang/unittests/Frontend/OutputStreamTest.cpp
+++ clang/unittests/Frontend/OutputStreamTest.cpp
@@ -101,4 +101,12 @@
   EXPECT_TRUE(StringRef(VerboseBuffer.data()).contains("errors generated"));
 }
 
+TEST(FrontendOutputTests, TestVerboseOutputStreamOwnedNotLeaked) {
+  CompilerInstance Compiler;
+  Compiler.setVerboseOutputStream(std::make_unique());
+
+  // Trust leak sanitizer bots to catch a leak here.
+  Compiler.setVerboseOutputStream(llvm::nulls());
+}
+
 } // anonymous namespace
Index: clang/lib/Frontend/CompilerInstance.cpp
===
--- clang/lib/Frontend/CompilerInstance.cpp
+++ clang/lib/Frontend/CompilerInstance.cpp
@@ -85,7 +85,7 @@
 }
 
 void CompilerInstance::setVerboseOutputStream(raw_ostream ) {
-  OwnedVerboseOutputStream.release();
+  OwnedVerboseOutputStream.reset();
   VerboseOutputStream = 
 }
 


Index: clang/unittests/Frontend/OutputStreamTest.cpp
===
--- clang/unittests/Frontend/OutputStreamTest.cpp
+++ clang/unittests/Frontend/OutputStreamTest.cpp
@@ -101,4 +101,12 @@
   EXPECT_TRUE(StringRef(VerboseBuffer.data()).contains("errors generated"));
 }
 
+TEST(FrontendOutputTests, TestVerboseOutputStreamOwnedNotLeaked) {
+  CompilerInstance Compiler;
+  Compiler.setVerboseOutputStream(std::make_unique());
+
+  // Trust leak sanitizer bots to catch a leak here.
+  Compiler.setVerboseOutputStream(llvm::nulls());
+}
+
 } // anonymous namespace
Index: clang/lib/Frontend/CompilerInstance.cpp
===
--- clang/lib/Frontend/CompilerInstance.cpp
+++ clang/lib/Frontend/CompilerInstance.cpp
@@ -85,7 +85,7 @@
 }
 
 void CompilerInstance::setVerboseOutputStream(raw_ostream ) {
-  OwnedVerboseOutputStream.release();
+  OwnedVerboseOutputStream.reset();
   VerboseOutputStream = 
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D94596: [clang][AST] Encapsulate DeclarationNameLoc, NFCI

2021-01-26 Thread Adrian Prantl via Phabricator via cfe-commits
aprantl accepted this revision.
aprantl added a comment.
This revision is now accepted and ready to land.

Seem reasonable.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94596

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


[PATCH] D94865: [ASTMatchers] Add callOrConstruct matcher

2021-01-26 Thread Stephen Kelly via Phabricator via cfe-commits
steveire added inline comments.



Comment at: clang/include/clang/ASTMatchers/ASTMatchers.h:2867
+extern const internal::MapAnyOfMatcher
+callOrConstruct;
+

aaron.ballman wrote:
> steveire wrote:
> > aaron.ballman wrote:
> > > steveire wrote:
> > > > aaron.ballman wrote:
> > > > > I'm not super keen on this name. It's certainly descriptive, but I do 
> > > > > wonder if it's a bit too specific and should perhaps be something 
> > > > > more like `callableExpr()`, `callLikeExpr()`, or something more 
> > > > > generic. For instance, I could imagine wanting this to match on 
> > > > > something like:
> > > > > ```
> > > > > struct S {
> > > > >   void setter(int val) {}
> > > > >   __declspec(property(put = setter)) int x;
> > > > > };
> > > > > 
> > > > > int main() {
> > > > >   S s;
> > > > >   s.x = 12; // Match here
> > > > >   // Because the above code actually does this:
> > > > >   // s.setter(12);
> > > > > }
> > > > > ```
> > > > > because this also has an expression that isn't really a call (as far 
> > > > > as our AST is concerned) but is a call as far as program semantics 
> > > > > are concerned. I'm not suggesting to make the matcher support that 
> > > > > right now (unless you felt like doing it), but thinking about the 
> > > > > future and avoiding a name that may paint us into a corner.
> > > > > 
> > > > > WDYT about using a more generic name?
> > > > I haven't seen code like that before (ms extension?) 
> > > > https://godbolt.org/z/anvd43 but I think that should be matched by 
> > > > `binaryOperator` instead. That already matches based on what the code 
> > > > looks like, rather than what it is in the AST.
> > > > 
> > > > This `callOrConstruct` is really for using `hasArgument` and related 
> > > > submatchers with nodes which support it. As such I think the name is 
> > > > fine. I don't like `callableExpr` or `callLikeExpr` because they don't 
> > > > bring to mind the possibility that construction is also supported.
> > > > I haven't seen code like that before (ms extension?)
> > > 
> > > Yes, it's an MS extension.
> > > 
> > > > That already matches based on what the code looks like, rather than 
> > > > what it is in the AST.
> > > 
> > > Yes, but these are AST matchers, so it's reasonable to match on what's in 
> > > the AST (as well as what the code looks like, of course). I'm not arguing 
> > > it needs to be supported so much as pointing out that there are other AST 
> > > nodes this notionally applies to where the name is a bit too specific.
> > > 
> > > > This callOrConstruct is really for using hasArgument and related 
> > > > submatchers with nodes which support it. As such I think the name is 
> > > > fine. I don't like callableExpr or callLikeExpr because they don't 
> > > > bring to mind the possibility that construction is also supported.
> > > 
> > > I'm pretty sure we've extended what `hasArgument` can be applied to in 
> > > the past (but I've not verified), so the part that worries me is 
> > > specifically naming the nodes as part of the identifier. This effectively 
> > > means that if we ever find another AST node for `hasArgument`, we either 
> > > need a different API like `callConstructOrWhatever` or we're stuck with a 
> > > poor name.
> > > 
> > > Another (smaller) concern with the name is that `callOrConstruct` can 
> > > describe declarations as well as expressions, to some degree as you can 
> > > declare calls and constructors. It's a smaller concern because those at 
> > > least share a common base class. `callOrConstructExpr` would clarify this 
> > > easily enough.
> > > 
> > > I see you added `ObjCMessageExpr` as well, thank you for that! It's a 
> > > perhaps better example of why this name feels awkward to me. In ObjC, you 
> > > don't call an `ObjCMessageExpr`, you "send" it to the given object or 
> > > class. That suggests to me that `callableExpr` or `callLikeExpr` is also 
> > > not a great name either.
> > > 
> > > Perhaps `executableExpr` because you're executing some code?
> > > Perhaps `executableExpr` because you're executing some code?
> > 
> > The thing that this really does is make it possible to use `hasArgument` 
> > and related matchers with the nodes that that matcher supports. So, 
> > something with `argument` in the name probably makes sense. Like 
> > `argumentExpr`. 
> > 
> > The thing that this really does is make it possible to use hasArgument and 
> > related matchers with the nodes that that matcher supports. So, something 
> > with argument in the name probably makes sense. Like argumentExpr.
> 
> A name like `argumentExpr()` would make me think we're trying to match the 
> `42` in an expression like `foo(42)` (e.g., it makes me think we're going to 
> match on expressions that are arguments to a call).
Actually I think that's confusing. Other matchers with `Expr` suffix are for 
matching subclasses of `clang::Expr`. This name would break that mould.

So, I think it should be 

[PATCH] D95187: [DebugInfo][CodeView] Use as the display name for lambdas.

2021-01-26 Thread Amy Huang via Phabricator via cfe-commits
akhuang added inline comments.



Comment at: clang/include/clang/AST/Mangle.h:92
 
+  virtual StringRef getLambdaString(const CXXRecordDecl *Lambda) = 0;
+

rnk wrote:
> akhuang wrote:
> > rnk wrote:
> > > I think I would prefer to have this return a number. I think CGDebugInfo 
> > > should be responsible for the formatting of the display names, not the 
> > > mangler. Both the MS and Itanium manglers have private methods for 
> > > numbering internal linkage lambdas, and I think it would be reasonable to 
> > > hook those up to a public virtual method.
> > I used a string because we mangle some lambdas like  (when 
> > they're used as function parameters). 
> > Maybe we don't need to differentiate between these lambdas though? 
> I see. So, the situation we are worried about would look like:
> 
> ```
> struct Foo {
>   static volatile int arg1_defaults, arg2_defaults;
>   static void foo(
>   int arg1 = []() { return ++arg1_defaults; }(),
>   int arg2 = []() { return ++arg2_defaults; }());
> };
> void bar() { Foo::foo(); }
> ```
> 
> In this case, if we use numbers here, we'd end up using the names 
> `Foo::` `Foo::`, and those would end up being duplicate 
> LF_FUNC_IDs. Darn.
> 
> You were right, we better go back to using strings. Sorry about that. That 
> makes a good test, though. :)
Yep. I don't know what it should output for the Itanium version though. I guess 
it could just do the same thing, even though we don't use that string anywhere 
there.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95187

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


[PATCH] D95187: [DebugInfo][CodeView] Use as the display name for lambdas.

2021-01-26 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added inline comments.



Comment at: clang/include/clang/AST/Mangle.h:92
 
+  virtual StringRef getLambdaString(const CXXRecordDecl *Lambda) = 0;
+

akhuang wrote:
> rnk wrote:
> > I think I would prefer to have this return a number. I think CGDebugInfo 
> > should be responsible for the formatting of the display names, not the 
> > mangler. Both the MS and Itanium manglers have private methods for 
> > numbering internal linkage lambdas, and I think it would be reasonable to 
> > hook those up to a public virtual method.
> I used a string because we mangle some lambdas like  (when 
> they're used as function parameters). 
> Maybe we don't need to differentiate between these lambdas though? 
I see. So, the situation we are worried about would look like:

```
struct Foo {
  static volatile int arg1_defaults, arg2_defaults;
  static void foo(
  int arg1 = []() { return ++arg1_defaults; }(),
  int arg2 = []() { return ++arg2_defaults; }());
};
void bar() { Foo::foo(); }
```

In this case, if we use numbers here, we'd end up using the names 
`Foo::` `Foo::`, and those would end up being duplicate 
LF_FUNC_IDs. Darn.

You were right, we better go back to using strings. Sorry about that. That 
makes a good test, though. :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95187

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


[PATCH] D93260: Frontend: Simplify handling of non-seeking streams in CompilerInstance, NFC

2021-01-26 Thread Erik Pilkington via Phabricator via cfe-commits
erik.pilkington accepted this revision.
erik.pilkington 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/D93260/new/

https://reviews.llvm.org/D93260

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


[PATCH] D95459: Add helper functionality for parsing different attribute syntaxes in arbitrary order

2021-01-26 Thread David Blaikie via Phabricator via cfe-commits
dblaikie accepted this revision.
dblaikie added a comment.
This revision is now accepted and ready to land.

Looks good to me! (welcome to wait for more eyes, if you like)


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

https://reviews.llvm.org/D95459

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


[PATCH] D93249: Frontend: Fix memory leak in CompilerInstance::setVerboseOutputStream

2021-01-26 Thread Erik Pilkington via Phabricator via cfe-commits
erik.pilkington accepted this revision.
erik.pilkington 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/D93249/new/

https://reviews.llvm.org/D93249

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


[PATCH] D94820: Support for instrumenting only selected files or functions

2021-01-26 Thread Petr Hosek via Phabricator via cfe-commits
phosek added inline comments.



Comment at: clang/docs/UsersManual.rst:2271
 
+.. option:: -fprofile-list=
+

MaskRay wrote:
> This can be added below `-fprofile-exclude-files=`
I considered it but that's in the GCOV section and this flag only applies to 
the LLVM instrumentation.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94820

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


[PATCH] D93248: Frontend: Fix layering between create{,Default}OutputFile, NFC

2021-01-26 Thread Erik Pilkington via Phabricator via cfe-commits
erik.pilkington accepted this revision.
erik.pilkington 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/D93248/new/

https://reviews.llvm.org/D93248

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


[PATCH] D95479: [clang-format] Avoid considering include directive as a template closer.

2021-01-26 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay accepted this revision.
MyDeveloperDay added a comment.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95479

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


[PATCH] D95482: [PATCH] [clang] Fix bug 48848 by removing assertion related to recoverFromMSUnqualifiedLookup

2021-01-26 Thread Melanie Blower via Phabricator via cfe-commits
mibintc created this revision.
mibintc added reviewers: erichkeane, rnk.
mibintc requested review of this revision.
Herald added a project: clang.

Fix https://bugs.llvm.org/show_bug.cgi?id=48848 by removing assertion


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D95482

Files:
  clang/lib/Sema/SemaExprCXX.cpp
  clang/test/SemaCXX/lambda-expressions.cpp


Index: clang/test/SemaCXX/lambda-expressions.cpp
===
--- clang/test/SemaCXX/lambda-expressions.cpp
+++ clang/test/SemaCXX/lambda-expressions.cpp
@@ -1,6 +1,8 @@
 // RUN: %clang_cc1 -std=c++14 -Wno-unused-value -fsyntax-only -verify 
-verify=expected-cxx14 -fblocks %s
 // RUN: %clang_cc1 -std=c++17 -Wno-unused-value -fsyntax-only -verify -fblocks 
%s
+// RUN: %clang_cc1 -std=c++17 -fblocks -DSHOW_MS -Wno-unused-value 
-fms-compatibility -fdelayed-template-parsing -fsyntax-only -verify %s
 
+#ifndef SHOW_MS
 namespace std { class type_info; };
 
 namespace ExplicitCapture {
@@ -664,3 +666,22 @@
 
 }
 };
+
+#else
+template 
+void Decider(const RT , ET ) {
+  [=](auto i) { ep[i] = sp[i + j]; };
+// expected-error@-1 {{use of undeclared identifier 'j'}}
+}
+
+template  void LS() {
+  int *ep;
+  Decider(5, ep);
+}
+
+void runChapter4()
+{
+  LS(); // expected-note {{in instantiation of}}
+}
+
+#endif
Index: clang/lib/Sema/SemaExprCXX.cpp
===
--- clang/lib/Sema/SemaExprCXX.cpp
+++ clang/lib/Sema/SemaExprCXX.cpp
@@ -1176,15 +1176,11 @@
   }
 
   if (ThisTy.isNull() && isLambdaCallOperator(CurContext) &&
-  inTemplateInstantiation()) {
-
-assert(isa(DC) &&
-   "Trying to get 'this' type from static method?");
+  inTemplateInstantiation() && isa(DC)) {
 
 // This is a lambda call operator that is being instantiated as a default
 // initializer. DC must point to the enclosing class type, so we can 
recover
 // the 'this' type from it.
-
 QualType ClassTy = Context.getTypeDeclType(cast(DC));
 // There are no cv-qualifiers for 'this' within default initializers,
 // per [expr.prim.general]p4.


Index: clang/test/SemaCXX/lambda-expressions.cpp
===
--- clang/test/SemaCXX/lambda-expressions.cpp
+++ clang/test/SemaCXX/lambda-expressions.cpp
@@ -1,6 +1,8 @@
 // RUN: %clang_cc1 -std=c++14 -Wno-unused-value -fsyntax-only -verify -verify=expected-cxx14 -fblocks %s
 // RUN: %clang_cc1 -std=c++17 -Wno-unused-value -fsyntax-only -verify -fblocks %s
+// RUN: %clang_cc1 -std=c++17 -fblocks -DSHOW_MS -Wno-unused-value -fms-compatibility -fdelayed-template-parsing -fsyntax-only -verify %s
 
+#ifndef SHOW_MS
 namespace std { class type_info; };
 
 namespace ExplicitCapture {
@@ -664,3 +666,22 @@
 
 }
 };
+
+#else
+template 
+void Decider(const RT , ET ) {
+  [=](auto i) { ep[i] = sp[i + j]; };
+// expected-error@-1 {{use of undeclared identifier 'j'}}
+}
+
+template  void LS() {
+  int *ep;
+  Decider(5, ep);
+}
+
+void runChapter4()
+{
+  LS(); // expected-note {{in instantiation of}}
+}
+
+#endif
Index: clang/lib/Sema/SemaExprCXX.cpp
===
--- clang/lib/Sema/SemaExprCXX.cpp
+++ clang/lib/Sema/SemaExprCXX.cpp
@@ -1176,15 +1176,11 @@
   }
 
   if (ThisTy.isNull() && isLambdaCallOperator(CurContext) &&
-  inTemplateInstantiation()) {
-
-assert(isa(DC) &&
-   "Trying to get 'this' type from static method?");
+  inTemplateInstantiation() && isa(DC)) {
 
 // This is a lambda call operator that is being instantiated as a default
 // initializer. DC must point to the enclosing class type, so we can recover
 // the 'this' type from it.
-
 QualType ClassTy = Context.getTypeDeclType(cast(DC));
 // There are no cv-qualifiers for 'this' within default initializers,
 // per [expr.prim.general]p4.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D92808: [ObjC][ARC] Annotate calls with attributes instead of emitting retainRV or claimRV calls in the IR

2021-01-26 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak added inline comments.



Comment at: llvm/lib/IR/Instruction.cpp:580
+if (auto *CB = dyn_cast(this))
+  return objcarc::hasRetainRVOrClaimRVAttr(CB);
+return false;

fhahn wrote:
> ahatanak wrote:
> > fhahn wrote:
> > > rjmccall wrote:
> > > > nikic wrote:
> > > > > This change looks pretty fishy. Objective C shouldn't be hijacking 
> > > > > LLVMs core instruction model in this way. If it writes to memory, 
> > > > > this should either be reflected in the attributes, or modeled using 
> > > > > operand bundles.
> > > > > 
> > > > > @fhahn Did you review these changes? If not, I'd suggest to revert 
> > > > > this patch and get a review on the LLVM changes.
> > > > This could definitely be an operand bundle, and I suppose the presence 
> > > > of a bundle does force a conservative assumption on passes.
> > > > @fhahn Did you review these changes? 
> > > 
> > > Nope I didn't have time to look at this so far.
> > > 
> > > 
> > > 
> > > Can functions marked as `readonly`/`readnone` be called with the objc 
> > > attributes? 
> > > 
> > > I'm not very familiar with ObjC, but even for a function that just 
> > > returns a passed in object id, don't we need to retain & release the 
> > > object in the function? Which means the function cannot be `readonly` 
> > > because we need to call `@llvm.objc*` functions? If that's the case, 
> > > could we just check in the verifier that the attributes are never used 
> > > with `readonly` functions?
> > > 
> > > If there are indeed cases where we can call `readonly` functions, operand 
> > > bundles would probably be safest. It would probably also good to have at 
> > > least a few alias-analysis tests, to make sure things work as expected.
> > A function compiled using ARC can call a function compiled using MRR, which 
> > can be readonly/readnone. Also, a function compiled using ARC can be marked 
> > as readonly/readnone (if an optimization pass wants to do so) after ARC 
> > optimizer removes the retainRV/autoreleaseRV pair.
> > 
> > ```
> > define i8* @foo() {
> >   %1 = tail call i8* @readonlyMRRFunc()
> >   ; This function can be readonly if ARC optimizer removes the following 
> > two instructions.
> >   %2 = call i8* @llvm.objc.retainAutoreleasedReturnValue(i8* %1)
> >   %3 = tail call i8* @llvm.objc.autoreleaseReturnValue(i8* %2)
> >   ret i8* 
> > }
> > ```
> > A function compiled using ARC can call a function compiled using MRR, which 
> > can be readonly/readnone
> 
> Ok, sounds like a bundle would be a good option then?
Yes. I think bundle should be used here.

I'm considering passing an integer flag, which distinguishes between retain and 
claim (e.g., 0 for retain and 1 for claim), to the bundles:

```
call i8* @foo() [ "clang.arc.rv"(i64 0) ]
```

Do you see any problems with this approach? Alternatively, we could pass the 
pointer to the runtime function (e.g., pointer to 
`@llvm.objc.retainAutoreleasedReturnValue`).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92808

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


[PATCH] D95479: [clang-format] Avoid considering include directive as a template closer.

2021-01-26 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan accepted this revision.
leonardchan added a comment.
This revision is now accepted and ready to land.

LGTM. Confirmed on our end this fixes our issue. Thanks for addressing this!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95479

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


[PATCH] D95409: [clang] implicitly delete space ship operator with function pointers

2021-01-26 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov updated this revision to Diff 319400.
mizvekov added a comment.

added tests

adds test that will catch original bug
also adds some tests on default equality/relational operators

this last one would have caught the issue of not accepting equality
operator for function pointers, had I not remembered about it :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95409

Files:
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/test/CXX/class/class.compare/class.compare.default/p6.cpp
  clang/test/CXX/class/class.compare/class.spaceship/p4.cpp


Index: clang/test/CXX/class/class.compare/class.spaceship/p4.cpp
===
--- /dev/null
+++ clang/test/CXX/class/class.compare/class.spaceship/p4.cpp
@@ -0,0 +1,35 @@
+// RUN: %clang_cc1 -std=c++2a -verify %s
+
+namespace std {
+class partial_ordering {
+  int n;
+  constexpr partial_ordering(int n) : n(n) {}
+
+public:
+  static const partial_ordering less, equivalent, greater, unordered;
+  bool operator!=(int) { return n != 0; }
+};
+constexpr partial_ordering partial_ordering::less{-1},
+partial_ordering::equivalent{0}, partial_ordering::greater{1},
+partial_ordering::unordered{2};
+} // namespace std
+
+struct A {
+  auto operator<=>(A const &) const = default; // expected-warning 
{{explicitly defaulted three-way comparison operator is implicitly deleted}}
+  const int  = 0;// expected-note {{defaulted 
'operator<=>' is implicitly deleted because class 'A' has a reference member}}
+};
+
+struct B {
+  auto operator<=>(B const &) const = default; // expected-warning 
{{explicitly defaulted three-way comparison operator is implicitly deleted}}
+  void (*a)(); // expected-note {{defaulted 
'operator<=>' is implicitly deleted because there is no viable comparison 
function for member 'a'}}
+};
+
+struct C {
+  auto operator<=>(C const &) const = default; // expected-warning 
{{explicitly defaulted three-way comparison operator is implicitly deleted}}
+  void (C::*a)();  // expected-note {{defaulted 
'operator<=>' is implicitly deleted because there is no viable comparison 
function for member 'a'}}
+};
+
+struct D {
+  auto operator<=>(D const &) const = default; // expected-warning 
{{explicitly defaulted three-way comparison operator is implicitly deleted}}
+  int D::*a;   // expected-note {{defaulted 
'operator<=>' is implicitly deleted because there is no viable comparison 
function for member 'a'}}
+};
Index: clang/test/CXX/class/class.compare/class.compare.default/p6.cpp
===
--- /dev/null
+++ clang/test/CXX/class/class.compare/class.compare.default/p6.cpp
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -std=c++2a -verify %s
+
+struct A {
+  bool operator==(A const &) const = default; // expected-warning {{explicitly 
defaulted equality comparison operator is implicitly deleted}}
+  bool operator<(A const &) const = default;  // expected-warning {{explicitly 
defaulted relational comparison operator is implicitly deleted}}
+  // expected-note@-1 {{defaulted 'operator<' is implicitly deleted because 
there is no viable comparison function}}
+  const int  = 0; // expected-note {{defaulted 'operator==' is implicitly 
deleted because class 'A' has a reference member}}
+};
+
+struct B {
+  bool operator==(B const &) const = default;
+  bool operator<(B const &) const = default; // expected-warning {{explicitly 
defaulted relational comparison operator is implicitly deleted}}
+  // expected-note@-1 {{defaulted 'operator<' is implicitly deleted because 
there is no viable comparison function}}
+  void (*a)();
+};
+
+struct C {
+  bool operator==(C const &) const = default;
+  bool operator<(C const &) const = default; // expected-warning {{explicitly 
defaulted relational comparison operator is implicitly deleted}}
+  // expected-note@-1 {{defaulted 'operator<' is implicitly deleted because 
there is no viable comparison function}}
+  void (C::*a)();
+};
+
+struct D {
+  bool operator==(D const &) const = default;
+  bool operator<(D const &) const = default; // expected-warning {{explicitly 
defaulted relational comparison operator is implicitly deleted}}
+  // expected-note@-1 {{defaulted 'operator<' is implicitly deleted because 
there is no viable comparison function}}
+  int D::*a;
+};
Index: clang/lib/Sema/SemaDeclCXX.cpp
===
--- clang/lib/Sema/SemaDeclCXX.cpp
+++ clang/lib/Sema/SemaDeclCXX.cpp
@@ -7677,7 +7677,8 @@
 
 if (Args[0]->getType()->isOverloadableType())
   S.LookupOverloadedBinOp(CandidateSet, OO, Fns, Args);
-else {
+else if (OO == OO_EqualEqual ||
+ !Args[0]->getType()->isFunctionPointerType()) {
   // FIXME: We determine whether this is a 

[PATCH] D95479: [clang-format] Avoid considering include directive as a template closer.

2021-01-26 Thread Marek Kurdej via Phabricator via cfe-commits
curdeius created this revision.
curdeius added reviewers: MyDeveloperDay, leonardchan.
curdeius requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This fixes a bug introduced in D93839  where:

  #include 
  namespace rep {}

got formatted as

  #include 
  namespace rep {
  }


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D95479

Files:
  clang/lib/Format/UnwrappedLineFormatter.cpp
  clang/unittests/Format/FormatTest.cpp


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -10248,6 +10248,21 @@
"{\n"
"};",
Style);
+
+  verifyFormat("#include \"stdint.h\"\n"
+   "namespace rep {}",
+   Style);
+  verifyFormat("#include \n"
+   "namespace rep {}",
+   Style);
+  verifyFormat("#include \n"
+   "namespace rep {}",
+   "#include \n"
+   "namespace rep {\n"
+   "\n"
+   "\n"
+   "}",
+   Style);
 }
 
 TEST_F(FormatTest, SplitEmptyStruct) {
Index: clang/lib/Format/UnwrappedLineFormatter.cpp
===
--- clang/lib/Format/UnwrappedLineFormatter.cpp
+++ clang/lib/Format/UnwrappedLineFormatter.cpp
@@ -371,7 +371,7 @@
 if (Previous->is(tok::comment))
   Previous = Previous->getPreviousNonComment();
 if (Previous) {
-  if (Previous->is(tok::greater))
+  if (Previous->is(tok::greater) && !I[-1]->InPPDirective)
 return 0;
   if (Previous->is(tok::identifier)) {
 const FormatToken *PreviousPrevious =


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -10248,6 +10248,21 @@
"{\n"
"};",
Style);
+
+  verifyFormat("#include \"stdint.h\"\n"
+   "namespace rep {}",
+   Style);
+  verifyFormat("#include \n"
+   "namespace rep {}",
+   Style);
+  verifyFormat("#include \n"
+   "namespace rep {}",
+   "#include \n"
+   "namespace rep {\n"
+   "\n"
+   "\n"
+   "}",
+   Style);
 }
 
 TEST_F(FormatTest, SplitEmptyStruct) {
Index: clang/lib/Format/UnwrappedLineFormatter.cpp
===
--- clang/lib/Format/UnwrappedLineFormatter.cpp
+++ clang/lib/Format/UnwrappedLineFormatter.cpp
@@ -371,7 +371,7 @@
 if (Previous->is(tok::comment))
   Previous = Previous->getPreviousNonComment();
 if (Previous) {
-  if (Previous->is(tok::greater))
+  if (Previous->is(tok::greater) && !I[-1]->InPPDirective)
 return 0;
   if (Previous->is(tok::identifier)) {
 const FormatToken *PreviousPrevious =
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D93839: [clang-format] PR48594 BraceWrapping: SplitEmptyRecord ignored for templates

2021-01-26 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan added a comment.

In D93839#2523703 , @curdeius wrote:

> That's definitely an unintended behaviour. Please file a bug and possibly 
> mark it as release blocker for LLVM 12. Either a fix will be there soon, or 
> we'll revert.
>
> FYI, simple reproduce:
>
>   verifyFormat("#include \n"
>"namespace rep {}",
>Style);
>
> The problem doesn't happen with `#include "stdint.h"`.

Thanks for looking into this. I filed 
https://bugs.llvm.org/show_bug.cgi?id=48891.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93839

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


[PATCH] D93839: [clang-format] PR48594 BraceWrapping: SplitEmptyRecord ignored for templates

2021-01-26 Thread Marek Kurdej via Phabricator via cfe-commits
curdeius added a comment.

That's definitely an unintended behaviour. Please file a bug and possibly mark 
it as release blocker for LLVM 12. Either a fix will be there soon, or we'll 
revert.

FYI, simple reproduce:

  verifyFormat("#include \n"
   "namespace rep {}",
   Style);

The problem doesn't happen with `#include "stdint.h"`.




Comment at: clang/lib/Format/UnwrappedLineFormatter.cpp:374-375
+if (Previous) {
+  if (Previous->is(tok::greater))
+return 0;
+  if (Previous->is(tok::identifier)) {

@leonardchan, it seems this is the culprit. the closing `>` in the `#include 
<...>` is treated as if it were a template closer and so it inhibits line 
merging.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93839

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


[PATCH] D94820: Support for instrumenting only selected files or functions

2021-01-26 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added inline comments.



Comment at: clang/docs/UsersManual.rst:2271
 
+.. option:: -fprofile-list=
+

This can be added below `-fprofile-exclude-files=`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94820

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


[PATCH] D85474: Add -fbinutils-version= to gate ELF features on the specified binutils version

2021-01-26 Thread Fangrui Song 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 rG34b60d8a5684: Add -fbinutils-version= to gate ELF features 
on the specified binutils version (authored by MaskRay).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85474

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/CodeGenOptions.h
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/Driver/fbinutils-version.c
  llvm/include/llvm/MC/MCAsmInfo.h
  llvm/include/llvm/Target/TargetMachine.h
  llvm/include/llvm/Target/TargetOptions.h
  llvm/lib/CodeGen/LLVMTargetMachine.cpp
  llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
  llvm/lib/Target/TargetMachine.cpp
  llvm/test/CodeGen/X86/explicit-section-mergeable.ll
  llvm/test/tools/llc/binutils-version.ll
  llvm/tools/llc/llc.cpp

Index: llvm/tools/llc/llc.cpp
===
--- llvm/tools/llc/llc.cpp
+++ llvm/tools/llc/llc.cpp
@@ -82,6 +82,15 @@
  cl::value_desc("N"),
  cl::desc("Repeat compilation N times for timing"));
 
+static cl::opt
+BinutilsVersion("binutils-version", cl::Hidden,
+cl::desc("Produced object files can use all ELF features "
+ "supported by this binutils version and newer."
+ "If -no-integrated-as is specified, the generated "
+ "assembly will consider GNU as support."
+ "'none' means that all ELF features can be used, "
+ "regardless of binutils support"));
+
 static cl::opt
 NoIntegratedAssembler("no-integrated-as", cl::Hidden,
   cl::desc("Disable integrated assembler"));
@@ -427,9 +436,24 @@
   case '3': OLvl = CodeGenOpt::Aggressive; break;
   }
 
+  // Parse 'none' or '$major.$minor'. Disallow -binutils-version=0 because we
+  // use that to indicate the MC default.
+  if (!BinutilsVersion.empty() && BinutilsVersion != "none") {
+StringRef V = BinutilsVersion.getValue();
+unsigned Num;
+if (V.consumeInteger(10, Num) || Num == 0 ||
+!(V.empty() ||
+  (V.consume_front(".") && !V.consumeInteger(10, Num) && V.empty( {
+  WithColor::error(errs(), argv[0])
+  << "invalid -binutils-version, accepting 'none' or major.minor\n";
+  return 1;
+}
+  }
   TargetOptions Options;
   auto InitializeOptions = [&](const Triple ) {
 Options = codegen::InitTargetOptionsFromCodeGenFlags(TheTriple);
+Options.BinutilsVersion =
+TargetMachine::parseBinutilsVersion(BinutilsVersion);
 Options.DisableIntegratedAS = NoIntegratedAssembler;
 Options.MCOptions.ShowMCEncoding = ShowMCEncoding;
 Options.MCOptions.MCUseDwarfDirectory = EnableDwarfDirectory;
Index: llvm/test/tools/llc/binutils-version.ll
===
--- /dev/null
+++ llvm/test/tools/llc/binutils-version.ll
@@ -0,0 +1,13 @@
+;; Test valid and invalid -binutils-version values.
+; RUN: llc %s -filetype=null -binutils-version=none
+; RUN: llc %s -filetype=null -binutils-version=2
+; RUN: llc %s -filetype=null -binutils-version=2.35
+
+;; Disallow -binutils-version=0 because we use $major==0 to indicate the MC
+;; default.
+; RUN: not llc %s -filetype=null -binutils-version=0 2>&1 | FileCheck %s --check-prefix=ERR
+; RUN: not llc %s -filetype=null -binutils-version=nan 2>&1 | FileCheck %s --check-prefix=ERR
+; RUN: not llc %s -filetype=null -binutils-version=2. 2>&1 | FileCheck %s --check-prefix=ERR
+; RUN: not llc %s -filetype=null -binutils-version=3.-14 2>&1 | FileCheck %s --check-prefix=ERR
+
+; ERR: error: invalid -binutils-version, accepting 'none' or major.minor
Index: llvm/test/CodeGen/X86/explicit-section-mergeable.ll
===
--- llvm/test/CodeGen/X86/explicit-section-mergeable.ll
+++ llvm/test/CodeGen/X86/explicit-section-mergeable.ll
@@ -282,15 +282,21 @@
 ;; --no-integrated-as avoids the use of ",unique," for compatibility with older binutils.
 
 ;; Error if an incompatible symbol is explicitly placed into a mergeable section.
-; RUN: not llc < %s -mtriple=x86_64 --no-integrated-as 2>&1 \
+; RUN: not llc < %s -mtriple=x86_64 --no-integrated-as -binutils-version=2.34 2>&1 \
 ; RUN: | FileCheck %s --check-prefix=NO-I-AS-ERR
 ; NO-I-AS-ERR: error: Symbol 'explicit_default_1' from module '' required a section with entry-size=0 but was placed in section '.rodata.cst16' with entry-size=16: Explicit assignment by pragma or attribute of an incompatible symbol to this section?
 ; NO-I-AS-ERR: error: Symbol 'explicit_default_4' from module '' required a section with 

[PATCH] D94820: Support for instrumenting only selected files or functions

2021-01-26 Thread Petr Hosek via Phabricator via cfe-commits
phosek added a comment.

In D94820#2523461 , @thakis wrote:

> Looks like this breaks tests on windows: 
> http://45.33.8.238/win/32075/step_7.txt
>
> Please take a look, and revert for now if it takes a while to fix.

Thanks for the heads up, I suspect it might be because of the Windows paths in 
the list file. I've reverted the change so I can test the fix on Windows before 
relanding.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94820

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


[PATCH] D95187: [DebugInfo][CodeView] Use as the display name for lambdas.

2021-01-26 Thread Amy Huang via Phabricator via cfe-commits
akhuang updated this revision to Diff 319379.
akhuang added a comment.

Avoid using getLambdaId function


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95187

Files:
  clang/include/clang/AST/Mangle.h
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/AST/MicrosoftMangle.cpp
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/test/CodeGenCXX/debug-info-codeview-unnamed.cpp
  clang/test/CodeGenCXX/debug-info-gline-tables-only-codeview.cpp

Index: clang/test/CodeGenCXX/debug-info-gline-tables-only-codeview.cpp
===
--- clang/test/CodeGenCXX/debug-info-gline-tables-only-codeview.cpp
+++ clang/test/CodeGenCXX/debug-info-gline-tables-only-codeview.cpp
@@ -6,10 +6,15 @@
 namespace NS {
 struct C {
   void m() {}
+  // Test externally visible lambda.
+  void lambda2() { []() {}(); }
 };
 void f() {}
 }
 
+// Test non- externally visible lambda.
+auto lambda1 = []() { return 1; };
+
 NS::C c;
 
 void test() {
@@ -27,4 +32,16 @@
   // CHECK-NOT: identifier
   // CHECK: ![[MTYPE]] = !DISubroutineType(types: !{{.*}})
   c.m();
+
+  // CHECK: !DISubprogram(name: "operator()", scope: ![[LAMBDA1:[0-9]+]]
+  // CHECK: ![[LAMBDA1]] = !DICompositeType(tag: DW_TAG_class_type,
+  // CHECK-SAME:name: ""
+  // CHECK-SAME:flags: DIFlagFwdDecl
+  lambda1();
+
+  // CHECK: !DISubprogram(name: "operator()", scope: ![[LAMBDA2:[0-9]+]]
+  // CHECK: ![[LAMBDA2]] = !DICompositeType(tag: DW_TAG_class_type,
+  // CHECK-SAME:name: ""
+  // CHECK-SAME:flags: DIFlagFwdDecl
+  c.lambda2();
 }
Index: clang/test/CodeGenCXX/debug-info-codeview-unnamed.cpp
===
--- clang/test/CodeGenCXX/debug-info-codeview-unnamed.cpp
+++ clang/test/CodeGenCXX/debug-info-codeview-unnamed.cpp
@@ -100,7 +100,7 @@
   // MSVC-SAME:  )
   // MSVC:   [[TYPE_OF_FOUR]] = distinct !DICompositeType
   // MSVC-SAME:  tag: DW_TAG_class_type
-  // MSVC-NOT:   name:
+  // MSVC-SAME:  name: ""
   // MSVC-SAME:  identifier: ".?AV@?0??main@@9@"
   // MSVC-SAME:  )
 
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -317,8 +317,9 @@
   if (const IdentifierInfo *II = RD->getIdentifier())
 return II->getName();
 
-  // The CodeView printer in LLVM wants to see the names of unnamed types: it is
-  // used to reconstruct the fully qualified type names.
+  // The CodeView printer in LLVM wants to see the names of unnamed types
+  // because they need to have a unique identifier.
+  // These names are used to reconstruct the fully qualified type names.
   if (CGM.getCodeGenOpts().EmitCodeView) {
 if (const TypedefNameDecl *D = RD->getTypedefNameForAnonDecl()) {
   assert(RD->getDeclContext() == D->getDeclContext() &&
@@ -342,6 +343,18 @@
 // associate typedef mangled in if they have one.
 Name = TND->getName();
 
+  // Give lambdas a display name based on their name mangling.
+  if (const CXXRecordDecl *CXXRD = dyn_cast(RD))
+if (CXXRD->isLambda()) {
+  unsigned LambdaNumber =
+  CGM.getCXXABI().getMangleContext().getLambdaNumber(CXXRD);
+
+  SmallString<256> LambdaName(" UnnamedType("getLambdaManglingNumber();
+if (LambdaManglingNumber)
+  return LambdaManglingNumber;
+return getLambdaIdForDebugInfo(Lambda);
+  }
+
   unsigned getLambdaId(const CXXRecordDecl *RD) {
 assert(RD->isLambda() && "RD must be a lambda!");
 assert(!RD->isExternallyVisible() && "RD must not be visible!");
@@ -238,6 +245,19 @@
 return Result.first->second;
   }
 
+  unsigned getLambdaIdForDebugInfo(const CXXRecordDecl *RD) {
+assert(RD->isLambda() && "RD must be a lambda!");
+assert(!RD->isExternallyVisible() && "RD must not be visible!");
+assert(RD->getLambdaManglingNumber() == 0 &&
+   "RD must not have a mangling number!");
+llvm::DenseMap::iterator Result =
+LambdaIds.find(RD);
+// The lambda should exist, but return 0 in case it doesn't.
+if (Result == LambdaIds.end())
+  return 0;
+return Result->second;
+  }
+
   /// Return a character sequence that is (somewhat) unique to the TU suitable
   /// for mangling anonymous namespaces.
   StringRef getAnonymousNamespaceHash() const {
Index: clang/lib/AST/ItaniumMangle.cpp
===
--- clang/lib/AST/ItaniumMangle.cpp
+++ clang/lib/AST/ItaniumMangle.cpp
@@ -203,6 +203,14 @@
 disc = discriminator-2;
 return true;
   }
+
+  unsigned getLambdaNumber(const CXXRecordDecl *Lambda) override {
+unsigned Number = Lambda->getLambdaManglingNumber();
+if (Number == 0)
+  return 

[PATCH] D95187: [DebugInfo][CodeView] Use as the display name for lambdas.

2021-01-26 Thread Amy Huang via Phabricator via cfe-commits
akhuang added inline comments.



Comment at: clang/include/clang/AST/Mangle.h:92
 
+  virtual StringRef getLambdaString(const CXXRecordDecl *Lambda) = 0;
+

rnk wrote:
> I think I would prefer to have this return a number. I think CGDebugInfo 
> should be responsible for the formatting of the display names, not the 
> mangler. Both the MS and Itanium manglers have private methods for numbering 
> internal linkage lambdas, and I think it would be reasonable to hook those up 
> to a public virtual method.
I used a string because we mangle some lambdas like  (when they're 
used as function parameters). 
Maybe we don't need to differentiate between these lambdas though? 



Comment at: clang/lib/AST/ItaniumMangle.cpp:210
+if (Number == 0)
+  return getAnonymousStructId(Lambda);
+return Number;

rnk wrote:
> This has the potential to create a situation where enabling debug info 
> changes the internal mangled names that clang uses. To be *extra* safe, you 
> could add a method like `getAnonymousStructIdForDebugInfo` that does .find 
> instead of .insert, and use it here.
Oh, right, yeah. I guess I'll just let it return 0 if it's not found.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95187

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


[PATCH] D85474: Add -fbinutils-version= to gate ELF features on the specified binutils version

2021-01-26 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay updated this revision to Diff 319378.
MaskRay added a comment.

Add llc validity check and tests


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85474

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/CodeGenOptions.h
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/Driver/fbinutils-version.c
  llvm/include/llvm/MC/MCAsmInfo.h
  llvm/include/llvm/Target/TargetMachine.h
  llvm/include/llvm/Target/TargetOptions.h
  llvm/lib/CodeGen/LLVMTargetMachine.cpp
  llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
  llvm/lib/Target/TargetMachine.cpp
  llvm/test/CodeGen/X86/explicit-section-mergeable.ll
  llvm/test/tools/llc/binutils-version.ll
  llvm/tools/llc/llc.cpp

Index: llvm/tools/llc/llc.cpp
===
--- llvm/tools/llc/llc.cpp
+++ llvm/tools/llc/llc.cpp
@@ -82,6 +82,15 @@
  cl::value_desc("N"),
  cl::desc("Repeat compilation N times for timing"));
 
+static cl::opt
+BinutilsVersion("binutils-version", cl::Hidden,
+cl::desc("Produced object files can use all ELF features "
+ "supported by this binutils version and newer."
+ "If -no-integrated-as is specified, the generated "
+ "assembly will consider GNU as support."
+ "'none' means that all ELF features can be used, "
+ "regardless of binutils support"));
+
 static cl::opt
 NoIntegratedAssembler("no-integrated-as", cl::Hidden,
   cl::desc("Disable integrated assembler"));
@@ -427,9 +436,24 @@
   case '3': OLvl = CodeGenOpt::Aggressive; break;
   }
 
+  // Parse 'none' or '$major.$minor'. Disallow -binutils-version=0 because we
+  // use that to indicate the MC default.
+  if (!BinutilsVersion.empty() && BinutilsVersion != "none") {
+StringRef V = BinutilsVersion.getValue();
+unsigned Num;
+if (V.consumeInteger(10, Num) || Num == 0 ||
+!(V.empty() ||
+  (V.consume_front(".") && !V.consumeInteger(10, Num) && V.empty( {
+  WithColor::error(errs(), argv[0])
+  << "invalid -binutils-version, accepting 'none' or major.minor\n";
+  return 1;
+}
+  }
   TargetOptions Options;
   auto InitializeOptions = [&](const Triple ) {
 Options = codegen::InitTargetOptionsFromCodeGenFlags(TheTriple);
+Options.BinutilsVersion =
+TargetMachine::parseBinutilsVersion(BinutilsVersion);
 Options.DisableIntegratedAS = NoIntegratedAssembler;
 Options.MCOptions.ShowMCEncoding = ShowMCEncoding;
 Options.MCOptions.MCUseDwarfDirectory = EnableDwarfDirectory;
Index: llvm/test/tools/llc/binutils-version.ll
===
--- /dev/null
+++ llvm/test/tools/llc/binutils-version.ll
@@ -0,0 +1,13 @@
+;; Test valid and invalid -binutils-version values.
+; RUN: llc %s -filetype=null -binutils-version=none
+; RUN: llc %s -filetype=null -binutils-version=2
+; RUN: llc %s -filetype=null -binutils-version=2.35
+
+;; Disallow -binutils-version=0 because we use $major==0 to indicate the MC
+;; default.
+; RUN: not llc %s -filetype=null -binutils-version=0 2>&1 | FileCheck %s --check-prefix=ERR
+; RUN: not llc %s -filetype=null -binutils-version=nan 2>&1 | FileCheck %s --check-prefix=ERR
+; RUN: not llc %s -filetype=null -binutils-version=2. 2>&1 | FileCheck %s --check-prefix=ERR
+; RUN: not llc %s -filetype=null -binutils-version=3.-14 2>&1 | FileCheck %s --check-prefix=ERR
+
+; ERR: error: invalid -binutils-version, accepting 'none' or major.minor
Index: llvm/test/CodeGen/X86/explicit-section-mergeable.ll
===
--- llvm/test/CodeGen/X86/explicit-section-mergeable.ll
+++ llvm/test/CodeGen/X86/explicit-section-mergeable.ll
@@ -282,15 +282,21 @@
 ;; --no-integrated-as avoids the use of ",unique," for compatibility with older binutils.
 
 ;; Error if an incompatible symbol is explicitly placed into a mergeable section.
-; RUN: not llc < %s -mtriple=x86_64 --no-integrated-as 2>&1 \
+; RUN: not llc < %s -mtriple=x86_64 --no-integrated-as -binutils-version=2.34 2>&1 \
 ; RUN: | FileCheck %s --check-prefix=NO-I-AS-ERR
 ; NO-I-AS-ERR: error: Symbol 'explicit_default_1' from module '' required a section with entry-size=0 but was placed in section '.rodata.cst16' with entry-size=16: Explicit assignment by pragma or attribute of an incompatible symbol to this section?
 ; NO-I-AS-ERR: error: Symbol 'explicit_default_4' from module '' required a section with entry-size=0 but was placed in section '.debug_str' with entry-size=1: Explicit assignment by pragma or attribute of an incompatible symbol to this section?
 ; 

[PATCH] D93031: Enable fexec-charset option

2021-01-26 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan added a comment.
Herald added a reviewer: jansvoboda11.

ping :)
Is there any more feedback on the implementation inside ProcessCharEscape()?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93031

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


[PATCH] D94472: [WIP][clang][cli] Command line round-trip for HeaderSearch options

2021-01-26 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith added a comment.

In D94472#2523053 , @Bigcheese wrote:

> In D94472#2519838 , @jansvoboda11 
> wrote:
>
>> In D94472#2508018 , @dexonsmith 
>> wrote:
>>
>>> `strict` mode additionally uses the `GeneratedArgs1` to fill 
>>> CompilerInvocation, indirectly checking both directions by requiring tests 
>>> to pass both with and without this round-trip. However, during development 
>>> people generally only run the tests one way and the failure mode won't be 
>>> ideal.
>>
>> So people build without assertions during development? In that case, I agree 
>> that erroring out on `GeneratedArgs1 != GeneratedArgs2` (in all kinds of 
>> builds) would improve the experience. I don't think there's anything 
>> preventing us to incorporate this into the current patch.
>
> The only issue I have with this if always parsing twice has a noticeable 
> performance impact for any users of Clang. Can we measure the impact? If it's 
> small (< 100ms ?) then that's fine. I'm also concerned about users like cling 
> and clangd.

I think the idea is only to parse twice when `-round-trip-args` is on, which 
the driver will only set by default in asserts mode. Good to measure the impact 
nevertheless.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94472

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


[PATCH] D85474: Add -fbinutils-version= to gate ELF features on the specified binutils version

2021-01-26 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

In D85474#2523439 , @rsmith wrote:

> Clang side looks good to me.
>
> On the LLVM side, is it intended that invalid `-binutils-version` values are 
> silently accepted?

Yes. In `llvm/tools/llc/llc.cpp`, there is no validity check. For these 
non-user-facing utilities (opt/llc/llvm-mc/...), validity check for options 
tends to be scarce.

I can add some tests to `llvm/test/tools/llc` (which hardly has any test 
currently).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85474

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


[PATCH] D94820: Support for instrumenting only selected files or functions

2021-01-26 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

Looks like this breaks tests on windows: http://45.33.8.238/win/32075/step_7.txt

Please take a look, and revert for now if it takes a while to fix.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94820

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


[PATCH] D94735: CGDebugInfo CreatedLimitedType: Drop file/line for RecordType with invalid location

2021-01-26 Thread Fangrui Song 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 rG189f311130da: CGDebugInfo CreatedLimitedType: Drop file/line 
for RecordType with invalid… (authored by MaskRay).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94735

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/test/CodeGen/X86/x86_64-arguments.c


Index: clang/test/CodeGen/X86/x86_64-arguments.c
===
--- clang/test/CodeGen/X86/x86_64-arguments.c
+++ clang/test/CodeGen/X86/x86_64-arguments.c
@@ -1,8 +1,8 @@
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm -o - %s | \
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm 
-debug-info-kind=limited -o - %s | \
 // RUN:   FileCheck %s -check-prefix=CHECK -check-prefix=SSE 
-check-prefix=NO-AVX512
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm -o - %s 
-target-feature +avx | \
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm 
-debug-info-kind=limited -o - %s -target-feature +avx | \
 // RUN:   FileCheck %s -check-prefix=CHECK -check-prefix=AVX 
-check-prefix=NO-AVX512
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm -o - %s 
-target-feature +avx512f | \
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm 
-debug-info-kind=limited -o - %s -target-feature +avx512f | \
 // RUN:   FileCheck %s -check-prefix=CHECK -check-prefix=AVX 
-check-prefix=AVX512
 #include 
 
@@ -545,3 +545,9 @@
 // AVX: @f65(<8 x float> %{{[^,)]+}})
 void f65(struct t65 a0) {
 }
+
+/// The synthesized __va_list_tag does not have file/line fields.
+// CHECK:  = distinct !DICompositeType(tag: DW_TAG_structure_type, name: 
"__va_list_tag",
+// CHECK-NOT:  file:
+// CHECK-NOT:  line:
+// CHECK-SAME: size:
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -3332,10 +3332,14 @@
   RecordDecl *RD = Ty->getDecl();
 
   // Get overall information about the record type for the debug info.
-  llvm::DIFile *DefUnit = getOrCreateFile(RD->getLocation());
-  const unsigned Line =
-  getLineNumber(RD->getLocation().isValid() ? RD->getLocation() : CurLoc);
   StringRef RDName = getClassName(RD);
+  const SourceLocation Loc = RD->getLocation();
+  llvm::DIFile *DefUnit = nullptr;
+  unsigned Line = 0;
+  if (Loc.isValid()) {
+DefUnit = getOrCreateFile(Loc);
+Line = getLineNumber(Loc);
+  }
 
   llvm::DIScope *RDContext = getDeclContextDescriptor(RD);
 


Index: clang/test/CodeGen/X86/x86_64-arguments.c
===
--- clang/test/CodeGen/X86/x86_64-arguments.c
+++ clang/test/CodeGen/X86/x86_64-arguments.c
@@ -1,8 +1,8 @@
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm -o - %s | \
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm -debug-info-kind=limited -o - %s | \
 // RUN:   FileCheck %s -check-prefix=CHECK -check-prefix=SSE -check-prefix=NO-AVX512
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm -o - %s -target-feature +avx | \
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm -debug-info-kind=limited -o - %s -target-feature +avx | \
 // RUN:   FileCheck %s -check-prefix=CHECK -check-prefix=AVX -check-prefix=NO-AVX512
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm -o - %s -target-feature +avx512f | \
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm -debug-info-kind=limited -o - %s -target-feature +avx512f | \
 // RUN:   FileCheck %s -check-prefix=CHECK -check-prefix=AVX -check-prefix=AVX512
 #include 
 
@@ -545,3 +545,9 @@
 // AVX: @f65(<8 x float> %{{[^,)]+}})
 void f65(struct t65 a0) {
 }
+
+/// The synthesized __va_list_tag does not have file/line fields.
+// CHECK:  = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "__va_list_tag",
+// CHECK-NOT:  file:
+// CHECK-NOT:  line:
+// CHECK-SAME: size:
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -3332,10 +3332,14 @@
   RecordDecl *RD = Ty->getDecl();
 
   // Get overall information about the record type for the debug info.
-  llvm::DIFile *DefUnit = getOrCreateFile(RD->getLocation());
-  const unsigned Line =
-  getLineNumber(RD->getLocation().isValid() ? RD->getLocation() : CurLoc);
   StringRef RDName = getClassName(RD);
+  const SourceLocation Loc = RD->getLocation();
+  llvm::DIFile *DefUnit = nullptr;
+  unsigned Line = 0;
+  if (Loc.isValid()) {
+DefUnit = getOrCreateFile(Loc);
+Line = getLineNumber(Loc);
+  }
 
   llvm::DIScope *RDContext = getDeclContextDescriptor(RD);
 
___
cfe-commits 

[PATCH] D85474: Add -fbinutils-version= to gate ELF features on the specified binutils version

2021-01-26 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith accepted this revision.
rsmith added a comment.

Clang side looks good to me.

On the LLVM side, is it intended that invalid `-binutils-version` values are 
silently accepted?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85474

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


[PATCH] D94391: CGDebugInfo: Drop Loc.isInvalid() special case from getLineNumber

2021-01-26 Thread Fangrui Song via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG31d375f178c2: CGDebugInfo: Drop Loc.isInvalid() special case 
from getLineNumber (authored by MaskRay).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94391

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp


Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -481,11 +481,10 @@
 }
 
 unsigned CGDebugInfo::getLineNumber(SourceLocation Loc) {
-  if (Loc.isInvalid() && CurLoc.isInvalid())
+  if (Loc.isInvalid())
 return 0;
   SourceManager  = CGM.getContext().getSourceManager();
-  PresumedLoc PLoc = SM.getPresumedLoc(Loc.isValid() ? Loc : CurLoc);
-  return PLoc.isValid() ? PLoc.getLine() : 0;
+  return SM.getPresumedLoc(Loc).getLine();
 }
 
 unsigned CGDebugInfo::getColumnNumber(SourceLocation Loc, bool Force) {
@@ -1025,7 +1024,8 @@
   if (llvm::DIType *T = getTypeOrNull(CGM.getContext().getRecordType(RD)))
 return cast(T);
   llvm::DIFile *DefUnit = getOrCreateFile(RD->getLocation());
-  unsigned Line = getLineNumber(RD->getLocation());
+  const unsigned Line =
+  getLineNumber(RD->getLocation().isValid() ? RD->getLocation() : CurLoc);
   StringRef RDName = getClassName(RD);
 
   uint64_t Size = 0;
@@ -1349,7 +1349,7 @@
 
   // Get the location for the field.
   llvm::DIFile *file = getOrCreateFile(loc);
-  unsigned line = getLineNumber(loc);
+  const unsigned line = getLineNumber(loc.isValid() ? loc : CurLoc);
 
   uint64_t SizeInBits = 0;
   auto Align = AlignInBits;
@@ -,7 +,8 @@
 
   // Get overall information about the record type for the debug info.
   llvm::DIFile *DefUnit = getOrCreateFile(RD->getLocation());
-  unsigned Line = getLineNumber(RD->getLocation());
+  const unsigned Line =
+  getLineNumber(RD->getLocation().isValid() ? RD->getLocation() : CurLoc);
   StringRef RDName = getClassName(RD);
 
   llvm::DIScope *RDContext = getDeclContextDescriptor(RD);
@@ -3869,7 +3870,7 @@
   llvm::DISubprogram::DISPFlags SPFlagsForDef =
   SPFlags | llvm::DISubprogram::SPFlagDefinition;
 
-  unsigned LineNo = getLineNumber(Loc);
+  const unsigned LineNo = getLineNumber(Loc.isValid() ? Loc : CurLoc);
   unsigned ScopeLine = getLineNumber(ScopeLoc);
   llvm::DISubroutineType *DIFnType = getOrCreateFunctionType(D, FnType, Unit);
   llvm::DISubprogram *Decl = nullptr;
@@ -4372,7 +4373,8 @@
   Ty = CreateSelfType(VD->getType(), Ty);
 
   // Get location information.
-  unsigned Line = getLineNumber(VD->getLocation());
+  const unsigned Line =
+  getLineNumber(VD->getLocation().isValid() ? VD->getLocation() : CurLoc);
   unsigned Column = getColumnNumber(VD->getLocation());
 
   const llvm::DataLayout  = CGM.getDataLayout();
@@ -4832,6 +4834,8 @@
   if (!NSDecl->isAnonymousNamespace() ||
   CGM.getCodeGenOpts().DebugExplicitImport) {
 auto Loc = UD.getLocation();
+if (!Loc.isValid())
+  Loc = CurLoc;
 DBuilder.createImportedModule(
 getCurrentContextDescriptor(cast(UD.getDeclContext())),
 getOrCreateNamespace(NSDecl), getOrCreateFile(Loc), 
getLineNumber(Loc));


Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -481,11 +481,10 @@
 }
 
 unsigned CGDebugInfo::getLineNumber(SourceLocation Loc) {
-  if (Loc.isInvalid() && CurLoc.isInvalid())
+  if (Loc.isInvalid())
 return 0;
   SourceManager  = CGM.getContext().getSourceManager();
-  PresumedLoc PLoc = SM.getPresumedLoc(Loc.isValid() ? Loc : CurLoc);
-  return PLoc.isValid() ? PLoc.getLine() : 0;
+  return SM.getPresumedLoc(Loc).getLine();
 }
 
 unsigned CGDebugInfo::getColumnNumber(SourceLocation Loc, bool Force) {
@@ -1025,7 +1024,8 @@
   if (llvm::DIType *T = getTypeOrNull(CGM.getContext().getRecordType(RD)))
 return cast(T);
   llvm::DIFile *DefUnit = getOrCreateFile(RD->getLocation());
-  unsigned Line = getLineNumber(RD->getLocation());
+  const unsigned Line =
+  getLineNumber(RD->getLocation().isValid() ? RD->getLocation() : CurLoc);
   StringRef RDName = getClassName(RD);
 
   uint64_t Size = 0;
@@ -1349,7 +1349,7 @@
 
   // Get the location for the field.
   llvm::DIFile *file = getOrCreateFile(loc);
-  unsigned line = getLineNumber(loc);
+  const unsigned line = getLineNumber(loc.isValid() ? loc : CurLoc);
 
   uint64_t SizeInBits = 0;
   auto Align = AlignInBits;
@@ -,7 +,8 @@
 
   // Get overall information about the record type for the debug info.
   llvm::DIFile *DefUnit = getOrCreateFile(RD->getLocation());
-  unsigned Line = getLineNumber(RD->getLocation());
+  const unsigned Line =
+  getLineNumber(RD->getLocation().isValid() ? RD->getLocation() : CurLoc);
   StringRef RDName = getClassName(RD);
 
   

[PATCH] D95442: [OpenCL] Add diagnostics for references to functions

2021-01-26 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added inline comments.



Comment at: clang/test/SemaOpenCLCXX/references.cl:29
+void foo();
+void test(void ()()) {
+  void ()();

Anastasia wrote:
> oops, I thought this was covered in my patch. I will see if there is a quick 
> fix and if not I will create another PR.
Ok, I have addressed that. I realized that my original patch was not doing what 
I said in the description as it was still allowing the references to functions 
in type aliases or template arguments. While I think such functionality might 
be useful we should first start from the language definition side of it. For 
now let's just go with the conservative approach and disallow this.


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

https://reviews.llvm.org/D95442

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


[PATCH] D95017: [clang-format] add case aware include sorting

2021-01-26 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks added inline comments.



Comment at: clang/docs/ClangFormatStyleOptions.rst:2286
+**IncludeSortAlphabetically** (``bool``)
+  Specify if sorting should be done in an alphabetical and
+  case sensitive fashion.

MyDeveloperDay wrote:
> curdeius wrote:
> > kentsommer wrote:
> > > MyDeveloperDay wrote:
> > > > Are you sure `IncludeSortAlphabetically` expresses what you mean? Once 
> > > > these things get released they cannot be changed easily.
> > > > 
> > > > If you were not sure of a new option, in my view we should slow down 
> > > > and make sure we have the correct design, for example you could have 
> > > > used a enum and it might have given you more possibility for greater 
> > > > flexibility
> > > > 
> > > > ```
> > > > enum IncludeSort
> > > > {
> > > >CaseInsensitive
> > > >CaseSensitive
> > > > }
> > > > ```
> > > > 
> > > > Please give people time to re-review your changes before we commit, 
> > > > especially if they've taken the time to look at your review in the 
> > > > first place. Just saying.
> > > > 
> > > Hi, @MyDeveloperDay I definitely agree. It was not my intention to rush 
> > > through the review. I was simply trying to follow the process outlined in 
> > > https://llvm.org/docs/Contributing.html#how-to-submit-a-patch which 
> > > mentions giving sufficient information to allow for a commit on your 
> > > behalf when you don't have access after an LGTM (which is all that I 
> > > did). As you can see from the lack of additional comments from my end, I 
> > > was happy to let this sit and be reviewed. 
> > > 
> > > Per the discussion about the option itself, I do believe 
> > > `IncludeSortAlphabetically` currently expresses what I mean as the 
> > > behavior with this off is indeed not an alphabetical sort as case takes 
> > > precedence over the alphabetical ordering. However, looking at the enum 
> > > and realizing that others probably will have additional styles they 
> > > prefer (maybe they want alphabetical but lower case first, etc.) I do 
> > > believe it might have been a better way to go as it leaves more 
> > > flexibility and room for additional ordering styles. Given that this just 
> > > landed, I would be happy to open a patch to turn this into an `enum` as I 
> > > do see benefits to doing so. What do you think?
> > Hmmm, and how about using the existing option `SortIncludes` and change its 
> > type from `bool` to some `enum`?
> > We could then, for backward-compatibility, map `false` to (tentative) 
> > `Never` and `true` to `ASCII`/`CaseInsensitive`, and add `CaseSensitive`.
> > 
> > This will have the advantage of not adding additional style options.
> > ... and it will prove once again that using `bool`s for style options is 
> > not a good idea.
> I think that is an excellent idea @curdeius 
I also fully support that! (Although I would not say a bool is per se bad.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95017

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


[PATCH] D95442: [OpenCL] Add diagnostics for references to functions

2021-01-26 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia updated this revision to Diff 319369.
Anastasia added a comment.

Improved diagnostics to cover more cases.

NOTE that this now also contains similar improvements for the pointers to 
member functions.


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

https://reviews.llvm.org/D95442

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaType.cpp
  clang/test/SemaOpenCLCXX/members.cl
  clang/test/SemaOpenCLCXX/references.cl

Index: clang/test/SemaOpenCLCXX/references.cl
===
--- /dev/null
+++ clang/test/SemaOpenCLCXX/references.cl
@@ -0,0 +1,46 @@
+//RUN: %clang_cc1 %s -cl-std=clc++ -verify -fsyntax-only
+//RUN: %clang_cc1 %s -cl-std=clc++ -verify -fsyntax-only -DFPTREXT
+
+#ifdef FPTREXT
+#pragma OPENCL EXTENSION __cl_clang_function_pointers : enable
+#endif // FPTREXT
+
+// References to functions are not allowed.
+struct myclass {
+//FIXME: Here we provide incorrect diagnostic.
+  void ()(); //expected-error{{reference to function type cannot have '__generic' qualifier}}
+};
+
+void ()();
+#ifndef FPTREXT
+//expected-error@-2{{references to functions are not allowed}}
+#else
+//expected-error@-4{{declaration of reference variable 'glob' requires an initializer}}
+#endif // FPTREXT
+
+using ref2fct_t = void (&)();
+#ifndef FPTREXT
+//expected-error@-2{{references to functions are not allowed}}
+#endif // FPTREXT
+typedef void (_t)();
+#ifndef FPTREXT
+//expected-error@-2{{references to functions are not allowed}}
+#endif // FPTREXT
+
+void test(void ()()) {
+#ifndef FPTREXT
+//expected-error@-2{{references to functions are not allowed}}
+#endif // FPTREXT
+  void ()();
+#ifndef FPTREXT
+//expected-error@-2{{references to functions are not allowed}}
+#else
+//expected-error@-4{{declaration of reference variable 'loc' requires an initializer}}
+#endif // FPTREXT
+
+  void (*)();
+#ifndef FPTREXT
+//expected-error@-2{{pointers to functions are not allowed}}
+#endif // FPTREXT
+//expected-error@-4{{declaration of reference variable 'ref2fptr' requires an initializer}}
+}
Index: clang/test/SemaOpenCLCXX/members.cl
===
--- clang/test/SemaOpenCLCXX/members.cl
+++ clang/test/SemaOpenCLCXX/members.cl
@@ -13,31 +13,13 @@
 };
 
 typedef void (C::*p_t)(int);
-
-template  struct remove_reference { typedef T type; };
-template  struct remove_reference { typedef T type; };
-
-template 
-void templ_test() {
-  typename remove_reference::type *ptr;
 #ifndef FUNCPTREXT
-  //expected-error@-2{{pointers to functions are not allowed}}
+//expected-error@-2{{pointers to functions are not allowed}}
 #endif
-}
 
 void test() {
   void (C::*p)(int);
 #ifndef FUNCPTREXT
 //expected-error@-2{{pointers to functions are not allowed}}
-#endif
-
-  p_t p1;
-#ifndef FUNCPTREXT
-//expected-error@-2{{pointers to functions are not allowed}}
-#endif
-
-  templ_test();
-#ifndef FUNCPTREXT
-//expected-note@-2{{in instantiation of function template specialization}}
 #endif
 }
Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -2091,7 +2091,7 @@
 
   if (T->isFunctionType() && getLangOpts().OpenCL &&
   !getOpenCLOptions().isEnabled("__cl_clang_function_pointers")) {
-Diag(Loc, diag::err_opencl_function_pointer);
+Diag(Loc, diag::err_opencl_function_pointer) << /*pointer*/ 0;
 return QualType();
   }
 
@@ -2163,6 +2163,12 @@
   if (checkQualifiedFunction(*this, T, Loc, QFK_Reference))
 return QualType();
 
+  if (T->isFunctionType() && getLangOpts().OpenCL &&
+  !getOpenCLOptions().isEnabled("__cl_clang_function_pointers")) {
+Diag(Loc, diag::err_opencl_function_pointer) << /*reference*/ 1;
+return QualType();
+  }
+
   // In ARC, it is forbidden to build references to unqualified pointers.
   if (getLangOpts().ObjCAutoRefCount)
 T = inferARCLifetimeForPointee(*this, T, Loc, /*reference*/ true);
@@ -2889,6 +2895,12 @@
 return QualType();
   }
 
+  if (T->isFunctionType() && getLangOpts().OpenCL &&
+  !getOpenCLOptions().isEnabled("__cl_clang_function_pointers")) {
+Diag(Loc, diag::err_opencl_function_pointer) << /*pointer*/ 0;
+return QualType();
+  }
+
   // Adjust the default free function calling convention to the default method
   // calling convention.
   bool IsCtorOrDtor =
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -6751,10 +6751,13 @@
 
   // OpenCL v1.0 s6.8.a.3: Pointers to functions are not allowed.
   if (!Se.getOpenCLOptions().isEnabled("__cl_clang_function_pointers")) {
-QualType NR = R;
-while (NR->isPointerType() || NR->isMemberFunctionPointerType()) {
-  if (NR->isFunctionPointerType() || 

[PATCH] D83250: [clang] Enable errors for undefined TARGET_OS_ macros in Darwin driver

2021-01-26 Thread Jeff Muizelaar via Phabricator via cfe-commits
jrmuizel added a comment.

Actually, this may just be a local configuration issue.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83250

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


[PATCH] D83250: [clang] Enable errors for undefined TARGET_OS_ macros in Darwin driver

2021-01-26 Thread Jeff Muizelaar via Phabricator via cfe-commits
jrmuizel added a comment.

This seems to have broken compilation for me on 10.15.

The stdio.h from the 10.15 SDK there's the following usage:

  #if TARGET_OS_EMBEDDED
  #define __swift_unavailable_on(osx_msg, ios_msg) __swift_unavailable(ios_msg)
  #else
  #define __swift_unavailable_on(osx_msg, ios_msg) __swift_unavailable(osx_msg)
  #endif


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83250

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


[PATCH] D95187: [DebugInfo][CodeView] Use as the display name for lambdas.

2021-01-26 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

I see a potential issue, but I think this looks good otherwise.




Comment at: clang/lib/AST/ItaniumMangle.cpp:210
+if (Number == 0)
+  return getAnonymousStructId(Lambda);
+return Number;

This has the potential to create a situation where enabling debug info changes 
the internal mangled names that clang uses. To be *extra* safe, you could add a 
method like `getAnonymousStructIdForDebugInfo` that does .find instead of 
.insert, and use it here.



Comment at: clang/lib/AST/MicrosoftMangle.cpp:236
+else
+  return getLambdaId(Lambda);
+  }

This has a similar concern, this isn't a readonly operation.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95187

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


[PATCH] D94820: Support for instrumenting only selected files or functions

2021-01-26 Thread Petr Hosek via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG4edf35f11a9e: Support for instrumenting only selected files 
or functions (authored by phosek).

Changed prior to commit:
  https://reviews.llvm.org/D94820?vs=318257=319359#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94820

Files:
  clang/docs/ClangCommandLineReference.rst
  clang/docs/SourceBasedCodeCoverage.rst
  clang/docs/UsersManual.rst
  clang/include/clang/AST/ASTContext.h
  clang/include/clang/Basic/LangOptions.h
  clang/include/clang/Basic/ProfileList.h
  clang/include/clang/Driver/Options.td
  clang/lib/AST/ASTContext.cpp
  clang/lib/Basic/CMakeLists.txt
  clang/lib/Basic/ProfileList.cpp
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/CodeGen/CodeGenModule.h
  clang/lib/CodeGen/CodeGenPGO.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGen/profile-filter.c
  llvm/include/llvm/Bitcode/LLVMBitCodes.h
  llvm/include/llvm/IR/Attributes.td
  llvm/lib/AsmParser/LLLexer.cpp
  llvm/lib/AsmParser/LLParser.cpp
  llvm/lib/AsmParser/LLToken.h
  llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
  llvm/lib/IR/Attributes.cpp
  llvm/lib/IR/Verifier.cpp
  llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp
  llvm/lib/Transforms/Utils/CodeExtractor.cpp
  llvm/test/Transforms/PGOProfile/noprofile.ll

Index: llvm/test/Transforms/PGOProfile/noprofile.ll
===
--- /dev/null
+++ llvm/test/Transforms/PGOProfile/noprofile.ll
@@ -0,0 +1,25 @@
+; RUN: opt < %s -pgo-instr-gen -S | FileCheck %s
+; RUN: opt < %s -passes=pgo-instr-gen -S | FileCheck %s
+
+target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+@i = dso_local global i32 0, align 4
+
+define i32 @test1() {
+entry:
+; CHECK: call void @llvm.instrprof.increment
+  %0 = load i32, i32* @i, align 4
+  %add = add i32 %0, 1
+  ret i32 %add
+}
+
+define i32 @test2() #0 {
+entry:
+; CHECK-NOT: call void @llvm.instrprof.increment
+  %0 = load i32, i32* @i, align 4
+  %sub = sub i32 %0, 1
+  ret i32 %sub
+}
+
+attributes #0 = { noprofile }
Index: llvm/lib/Transforms/Utils/CodeExtractor.cpp
===
--- llvm/lib/Transforms/Utils/CodeExtractor.cpp
+++ llvm/lib/Transforms/Utils/CodeExtractor.cpp
@@ -973,6 +973,7 @@
   case Attribute::UWTable:
   case Attribute::NoCfCheck:
   case Attribute::MustProgress:
+  case Attribute::NoProfile:
 break;
   }
 
Index: llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp
===
--- llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp
+++ llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp
@@ -1591,6 +1591,8 @@
   for (auto  : M) {
 if (F.isDeclaration())
   continue;
+if (F.hasFnAttribute(llvm::Attribute::NoProfile))
+  continue;
 auto  = LookupTLI(F);
 auto *BPI = LookupBPI(F);
 auto *BFI = LookupBFI(F);
Index: llvm/lib/IR/Verifier.cpp
===
--- llvm/lib/IR/Verifier.cpp
+++ llvm/lib/IR/Verifier.cpp
@@ -1655,6 +1655,7 @@
   case Attribute::StrictFP:
   case Attribute::NullPointerIsValid:
   case Attribute::MustProgress:
+  case Attribute::NoProfile:
 return true;
   default:
 break;
Index: llvm/lib/IR/Attributes.cpp
===
--- llvm/lib/IR/Attributes.cpp
+++ llvm/lib/IR/Attributes.cpp
@@ -403,6 +403,8 @@
 return "nocf_check";
   if (hasAttribute(Attribute::NoRecurse))
 return "norecurse";
+  if (hasAttribute(Attribute::NoProfile))
+return "noprofile";
   if (hasAttribute(Attribute::NoUnwind))
 return "nounwind";
   if (hasAttribute(Attribute::OptForFuzzing))
Index: llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
===
--- llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
+++ llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
@@ -680,6 +680,8 @@
 return bitc::ATTR_KIND_NOSYNC;
   case Attribute::NoCfCheck:
 return bitc::ATTR_KIND_NOCF_CHECK;
+  case Attribute::NoProfile:
+return bitc::ATTR_KIND_NO_PROFILE;
   case Attribute::NoUnwind:
 return bitc::ATTR_KIND_NO_UNWIND;
   case Attribute::NullPointerIsValid:
Index: llvm/lib/AsmParser/LLToken.h
===
--- llvm/lib/AsmParser/LLToken.h
+++ llvm/lib/AsmParser/LLToken.h
@@ -210,6 +210,7 @@
   kw_nonlazybind,
   kw_nomerge,
   kw_nonnull,
+  kw_noprofile,
   kw_noredzone,
   kw_noreturn,
   kw_nosync,
Index: llvm/lib/AsmParser/LLParser.cpp

[PATCH] D95338: [clangd] FindTarget resolves base specifier

2021-01-26 Thread Nathan James via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG7730599c4164: [clangd] FindTarget resolves base specifier 
(authored by njames93).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95338

Files:
  clang-tools-extra/clangd/FindTarget.cpp
  clang-tools-extra/clangd/unittests/FindTargetTests.cpp


Index: clang-tools-extra/clangd/unittests/FindTargetTests.cpp
===
--- clang-tools-extra/clangd/unittests/FindTargetTests.cpp
+++ clang-tools-extra/clangd/unittests/FindTargetTests.cpp
@@ -230,6 +230,24 @@
{"void waldo()"});
 }
 
+TEST_F(TargetDeclTest, BaseSpecifier) {
+  Code = R"cpp(
+struct X {};
+struct Y : [[private]] X {};
+  )cpp";
+  EXPECT_DECLS("CXXBaseSpecifier", "struct X");
+  Code = R"cpp(
+struct X {};
+struct Y : [[private X]] {};
+  )cpp";
+  EXPECT_DECLS("CXXBaseSpecifier", "struct X");
+  Code = R"cpp(
+struct X {};
+struct Y : private [[X]] {};
+  )cpp";
+  EXPECT_DECLS("RecordTypeLoc", "struct X");
+}
+
 TEST_F(TargetDeclTest, ConstructorInitList) {
   Code = R"cpp(
 struct X {
Index: clang-tools-extra/clangd/FindTarget.cpp
===
--- clang-tools-extra/clangd/FindTarget.cpp
+++ clang-tools-extra/clangd/FindTarget.cpp
@@ -710,7 +710,8 @@
 Finder.add(CCI, Flags);
   else if (const TemplateArgumentLoc *TAL = N.get())
 Finder.add(TAL->getArgument(), Flags);
-
+  else if (const CXXBaseSpecifier *CBS = N.get())
+Finder.add(CBS->getTypeSourceInfo()->getType(), Flags);
   return Finder.takeDecls();
 }
 


Index: clang-tools-extra/clangd/unittests/FindTargetTests.cpp
===
--- clang-tools-extra/clangd/unittests/FindTargetTests.cpp
+++ clang-tools-extra/clangd/unittests/FindTargetTests.cpp
@@ -230,6 +230,24 @@
{"void waldo()"});
 }
 
+TEST_F(TargetDeclTest, BaseSpecifier) {
+  Code = R"cpp(
+struct X {};
+struct Y : [[private]] X {};
+  )cpp";
+  EXPECT_DECLS("CXXBaseSpecifier", "struct X");
+  Code = R"cpp(
+struct X {};
+struct Y : [[private X]] {};
+  )cpp";
+  EXPECT_DECLS("CXXBaseSpecifier", "struct X");
+  Code = R"cpp(
+struct X {};
+struct Y : private [[X]] {};
+  )cpp";
+  EXPECT_DECLS("RecordTypeLoc", "struct X");
+}
+
 TEST_F(TargetDeclTest, ConstructorInitList) {
   Code = R"cpp(
 struct X {
Index: clang-tools-extra/clangd/FindTarget.cpp
===
--- clang-tools-extra/clangd/FindTarget.cpp
+++ clang-tools-extra/clangd/FindTarget.cpp
@@ -710,7 +710,8 @@
 Finder.add(CCI, Flags);
   else if (const TemplateArgumentLoc *TAL = N.get())
 Finder.add(TAL->getArgument(), Flags);
-
+  else if (const CXXBaseSpecifier *CBS = N.get())
+Finder.add(CBS->getTypeSourceInfo()->getType(), Flags);
   return Finder.takeDecls();
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D95231: [clangd] Selection handles CXXBaseSpecifier

2021-01-26 Thread Nathan James via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGd92413a45e20: [clangd] Selection handles CXXBaseSpecifier 
(authored by njames93).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95231

Files:
  clang-tools-extra/clangd/Selection.cpp
  clang-tools-extra/clangd/unittests/RenameTests.cpp
  clang-tools-extra/clangd/unittests/SelectionTests.cpp
  clang/lib/AST/ASTTypeTraits.cpp


Index: clang/lib/AST/ASTTypeTraits.cpp
===
--- clang/lib/AST/ASTTypeTraits.cpp
+++ clang/lib/AST/ASTTypeTraits.cpp
@@ -193,5 +193,7 @@
 return TAL->getSourceRange();
   if (const auto *C = get())
 return SourceRange(C->getBeginLoc(), C->getEndLoc());
+  if (const auto *CBS = get())
+return CBS->getSourceRange();
   return SourceRange();
 }
Index: clang-tools-extra/clangd/unittests/SelectionTests.cpp
===
--- clang-tools-extra/clangd/unittests/SelectionTests.cpp
+++ clang-tools-extra/clangd/unittests/SelectionTests.cpp
@@ -261,6 +261,27 @@
   )cpp",
   "StringLiteral", // Not DeclRefExpr to operator()!
   },
+  {
+  R"cpp(
+struct Foo {};
+struct Bar : [[v^ir^tual private Foo]] {};
+  )cpp",
+  "CXXBaseSpecifier",
+  },
+  {
+  R"cpp(
+struct Foo {};
+struct Bar : private [[Fo^o]] {};
+  )cpp",
+  "RecordTypeLoc",
+  },
+  {
+  R"cpp(
+struct Foo {};
+struct Bar : [[Fo^o]] {};
+  )cpp",
+  "RecordTypeLoc",
+  },
 
   // Point selections.
   {"void foo() { [[^foo]](); }", "DeclRefExpr"},
Index: clang-tools-extra/clangd/unittests/RenameTests.cpp
===
--- clang-tools-extra/clangd/unittests/RenameTests.cpp
+++ clang-tools-extra/clangd/unittests/RenameTests.cpp
@@ -1024,6 +1024,12 @@
 }
   )cpp",
"new name is the same", !HeaderFile, nullptr, "SameName"},
+  {R"cpp(// Ensure it doesn't associate base specifier with base name.
+struct A {};
+struct B : priv^ate A {};
+  )cpp",
+   "Cannot rename symbol: there is no symbol at the given location", false,
+   nullptr},
   };
 
   for (const auto& Case : Cases) {
Index: clang-tools-extra/clangd/Selection.cpp
===
--- clang-tools-extra/clangd/Selection.cpp
+++ clang-tools-extra/clangd/Selection.cpp
@@ -493,6 +493,9 @@
 return traverseNode(
 X, [&] { return Base::TraverseConstructorInitializer(X); });
   }
+  bool TraverseCXXBaseSpecifier(const CXXBaseSpecifier ) {
+return traverseNode(, [&] { return Base::TraverseCXXBaseSpecifier(X); });
+  }
   // Stmt is the same, but this form allows the data recursion optimization.
   bool dataTraverseStmtPre(Stmt *X) {
 if (!X || isImplicit(X))


Index: clang/lib/AST/ASTTypeTraits.cpp
===
--- clang/lib/AST/ASTTypeTraits.cpp
+++ clang/lib/AST/ASTTypeTraits.cpp
@@ -193,5 +193,7 @@
 return TAL->getSourceRange();
   if (const auto *C = get())
 return SourceRange(C->getBeginLoc(), C->getEndLoc());
+  if (const auto *CBS = get())
+return CBS->getSourceRange();
   return SourceRange();
 }
Index: clang-tools-extra/clangd/unittests/SelectionTests.cpp
===
--- clang-tools-extra/clangd/unittests/SelectionTests.cpp
+++ clang-tools-extra/clangd/unittests/SelectionTests.cpp
@@ -261,6 +261,27 @@
   )cpp",
   "StringLiteral", // Not DeclRefExpr to operator()!
   },
+  {
+  R"cpp(
+struct Foo {};
+struct Bar : [[v^ir^tual private Foo]] {};
+  )cpp",
+  "CXXBaseSpecifier",
+  },
+  {
+  R"cpp(
+struct Foo {};
+struct Bar : private [[Fo^o]] {};
+  )cpp",
+  "RecordTypeLoc",
+  },
+  {
+  R"cpp(
+struct Foo {};
+struct Bar : [[Fo^o]] {};
+  )cpp",
+  "RecordTypeLoc",
+  },
 
   // Point selections.
   {"void foo() { [[^foo]](); }", "DeclRefExpr"},
Index: clang-tools-extra/clangd/unittests/RenameTests.cpp
===
--- clang-tools-extra/clangd/unittests/RenameTests.cpp
+++ clang-tools-extra/clangd/unittests/RenameTests.cpp
@@ -1024,6 +1024,12 @@
 }
   )cpp",
"new name is the same", !HeaderFile, nullptr, "SameName"},
+  {R"cpp(// Ensure it doesn't associate base specifier with base name.
+struct A {};
+struct B : priv^ate A {};
+  )cpp",
+   "Cannot rename symbol: there is no symbol at the given 

[PATCH] D95460: [flang][driver] Add forced form flags and -ffixed-line-length

2021-01-26 Thread Faris via Phabricator via cfe-commits
FarisRehman created this revision.
Herald added a reviewer: sscalpone.
Herald added a subscriber: dang.
Herald added a reviewer: awarzynski.
Herald added a reviewer: jansvoboda11.
FarisRehman requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Add support for the following layout options:

- -ffree-form
- -ffixed-form
- -ffixed-line-length-n

The default fixed line length is 72, based off the current default.

This patch does not add `-ffree-line-length-n` as Fortran::parser::Options does 
not have a variable for free form columns.
Whilst `fixedFormColumns` variable is used in f18 for `-ffree-line-length-n`, 
f18 only allows `-ffree-line-length-none`/`-ffree-line-length-0` and not a 
user-specified value. `fixedFormcolumns` cannot be used in the new driver as it 
is ignored in the frontend when dealing with free form files.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D95460

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Flang.cpp
  flang/include/flang/Frontend/FrontendOptions.h
  flang/lib/Frontend/CompilerInstance.cpp
  flang/lib/Frontend/CompilerInvocation.cpp
  flang/test/Flang-Driver/Inputs/fixed-form-test.f
  flang/test/Flang-Driver/Inputs/fixed-line-length-test.f
  flang/test/Flang-Driver/driver-help-hidden.f90
  flang/test/Flang-Driver/driver-help.f90
  flang/test/Flang-Driver/fixed-free-flag.f90
  flang/test/Flang-Driver/fixed-line-length.f90

Index: flang/test/Flang-Driver/fixed-line-length.f90
===
--- /dev/null
+++ flang/test/Flang-Driver/fixed-line-length.f90
@@ -0,0 +1,43 @@
+! Ensure argument -ffixed-line-length-n works as expected.
+
+! REQUIRES: new-flang-driver
+
+!--
+! FLANG DRIVER (flang-new)
+!--
+! RUN: %flang-new -E %S/Inputs/fixed-line-length-test.f  2>&1 | FileCheck %s --check-prefix=DEFAULTLENGTH
+! RUN: not %flang-new -E -ffixed-line-length-3 %S/Inputs/fixed-line-length-test.f  2>&1 | FileCheck %s --check-prefix=INVALIDLENGTH
+! RUN: %flang-new -E -ffixed-line-length-none %S/Inputs/fixed-line-length-test.f  2>&1 | FileCheck %s --check-prefix=UNLIMITEDLENGTH
+! RUN: %flang-new -E -ffixed-line-length-0 %S/Inputs/fixed-line-length-test.f  2>&1 | FileCheck %s --check-prefix=UNLIMITEDLENGTH
+! RUN: %flang-new -E -ffixed-line-length-13 %S/Inputs/fixed-line-length-test.f  2>&1 | FileCheck %s --check-prefix=LENGTH13
+
+!
+! FRONTEND FLANG DRIVER (flang-new -fc1)
+!
+! RUN: %flang-new -fc1 -E %S/Inputs/fixed-line-length-test.f  2>&1 | FileCheck %s --check-prefix=DEFAULTLENGTH
+! RUN: not %flang-new -fc1 -E -ffixed-line-length-3 %S/Inputs/fixed-line-length-test.f  2>&1 | FileCheck %s --check-prefix=INVALIDLENGTH
+! RUN: %flang-new -fc1 -E -ffixed-line-length-none %S/Inputs/fixed-line-length-test.f  2>&1 | FileCheck %s --check-prefix=UNLIMITEDLENGTH
+! RUN: %flang-new -fc1 -E -ffixed-line-length-0 %S/Inputs/fixed-line-length-test.f  2>&1 | FileCheck %s --check-prefix=UNLIMITEDLENGTH
+! RUN: %flang-new -fc1 -E -ffixed-line-length-13 %S/Inputs/fixed-line-length-test.f  2>&1 | FileCheck %s --check-prefix=LENGTH13
+
+!-
+! EXPECTED OUTPUT WITH DEFAULT LENGTH
+!-
+! The line should be trimmed to 72 characters when reading based on the default value of fixed line length.
+! DEFAULTLENGTH: programaa
+
+!-
+! EXPECTED OUTPUT WITH LENGTH LESS THAN 7
+!-
+! INVALIDLENGTH: invalid value '{{(-)?[0-9]+}}'
+
+!---
+! EXPECTED OUTPUT WITH UNLIMITED LENGTH
+!---
+! The line should not be trimmed and so 73 characters (including spaces) should be read.
+! UNLIMITEDLENGTH: programaaa
+
+!
+! EXPECTED OUTPUT WITH LENGTH 13
+!
+! LENGTH13: program
Index: flang/test/Flang-Driver/fixed-free-flag.f90
===
--- /dev/null
+++ flang/test/Flang-Driver/fixed-free-flag.f90
@@ -0,0 +1,25 @@
+! Ensure arguments -ffree-form and -ffixed-form work as expected.
+
+! REQUIRES: new-flang-driver
+
+!--
+! FLANG DRIVER (flang-new)
+!--
+! RUN: not %flang-new -fsyntax-only -ffree-form %S/Inputs/fixed-form-test.f %S/Inputs/free-form-test.f90  2>&1 | FileCheck %s --check-prefix=FREEFORM
+! RUN: %flang-new -fsyntax-only -ffixed-form %S/Inputs/free-form-test.f90 %S/Inputs/fixed-form-test.f  2>&1 | FileCheck %s --check-prefix=FIXEDFORM
+
+!
+! FRONTEND FLANG DRIVER (flang-new -fc1)

[PATCH] D95187: [DebugInfo][CodeView] Use as the display name for lambdas.

2021-01-26 Thread Amy Huang via Phabricator via cfe-commits
akhuang updated this revision to Diff 319348.
akhuang marked an inline comment as done.
akhuang added a comment.

change to function returning a number, fill in ItaniumMangle function


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95187

Files:
  clang/include/clang/AST/Mangle.h
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/AST/MicrosoftMangle.cpp
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/test/CodeGenCXX/debug-info-codeview-unnamed.cpp
  clang/test/CodeGenCXX/debug-info-gline-tables-only-codeview.cpp

Index: clang/test/CodeGenCXX/debug-info-gline-tables-only-codeview.cpp
===
--- clang/test/CodeGenCXX/debug-info-gline-tables-only-codeview.cpp
+++ clang/test/CodeGenCXX/debug-info-gline-tables-only-codeview.cpp
@@ -6,10 +6,15 @@
 namespace NS {
 struct C {
   void m() {}
+  // Test externally visible lambda.
+  void lambda2() { []() {}(); }
 };
 void f() {}
 }
 
+// Test non- externally visible lambda.
+auto lambda1 = []() { return 1; };
+
 NS::C c;
 
 void test() {
@@ -27,4 +32,16 @@
   // CHECK-NOT: identifier
   // CHECK: ![[MTYPE]] = !DISubroutineType(types: !{{.*}})
   c.m();
+
+  // CHECK: !DISubprogram(name: "operator()", scope: ![[LAMBDA1:[0-9]+]]
+  // CHECK: ![[LAMBDA1]] = !DICompositeType(tag: DW_TAG_class_type,
+  // CHECK-SAME:name: ""
+  // CHECK-SAME:flags: DIFlagFwdDecl
+  lambda1();
+
+  // CHECK: !DISubprogram(name: "operator()", scope: ![[LAMBDA2:[0-9]+]]
+  // CHECK: ![[LAMBDA2]] = !DICompositeType(tag: DW_TAG_class_type,
+  // CHECK-SAME:name: ""
+  // CHECK-SAME:flags: DIFlagFwdDecl
+  c.lambda2();
 }
Index: clang/test/CodeGenCXX/debug-info-codeview-unnamed.cpp
===
--- clang/test/CodeGenCXX/debug-info-codeview-unnamed.cpp
+++ clang/test/CodeGenCXX/debug-info-codeview-unnamed.cpp
@@ -100,7 +100,7 @@
   // MSVC-SAME:  )
   // MSVC:   [[TYPE_OF_FOUR]] = distinct !DICompositeType
   // MSVC-SAME:  tag: DW_TAG_class_type
-  // MSVC-NOT:   name:
+  // MSVC-SAME:  name: ""
   // MSVC-SAME:  identifier: ".?AV@?0??main@@9@"
   // MSVC-SAME:  )
 
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -317,8 +317,9 @@
   if (const IdentifierInfo *II = RD->getIdentifier())
 return II->getName();
 
-  // The CodeView printer in LLVM wants to see the names of unnamed types: it is
-  // used to reconstruct the fully qualified type names.
+  // The CodeView printer in LLVM wants to see the names of unnamed types
+  // because they need to have a unique identifier.
+  // These names are used to reconstruct the fully qualified type names.
   if (CGM.getCodeGenOpts().EmitCodeView) {
 if (const TypedefNameDecl *D = RD->getTypedefNameForAnonDecl()) {
   assert(RD->getDeclContext() == D->getDeclContext() &&
@@ -342,6 +343,18 @@
 // associate typedef mangled in if they have one.
 Name = TND->getName();
 
+  // Give lambdas a display name based on their name mangling.
+  if (const CXXRecordDecl *CXXRD = dyn_cast(RD))
+if (CXXRD->isLambda()) {
+  unsigned LambdaNumber =
+  CGM.getCXXABI().getMangleContext().getLambdaNumber(CXXRD);
+
+  SmallString<256> LambdaName(" UnnamedType("getLambdaManglingNumber();
+if (LambdaManglingNumber)
+  return LambdaManglingNumber;
+else
+  return getLambdaId(Lambda);
+  }
+
   unsigned getLambdaId(const CXXRecordDecl *RD) {
 assert(RD->isLambda() && "RD must be a lambda!");
 assert(!RD->isExternallyVisible() && "RD must not be visible!");
Index: clang/lib/AST/ItaniumMangle.cpp
===
--- clang/lib/AST/ItaniumMangle.cpp
+++ clang/lib/AST/ItaniumMangle.cpp
@@ -203,6 +203,14 @@
 disc = discriminator-2;
 return true;
   }
+
+  unsigned getLambdaNumber(const CXXRecordDecl *Lambda) override {
+unsigned Number = Lambda->getLambdaManglingNumber();
+if (Number == 0)
+  return getAnonymousStructId(Lambda);
+return Number;
+  }
+
   /// @}
 };
 
Index: clang/include/clang/AST/Mangle.h
===
--- clang/include/clang/AST/Mangle.h
+++ clang/include/clang/AST/Mangle.h
@@ -89,6 +89,8 @@
 return Result.first->second;
   }
 
+  virtual unsigned getLambdaNumber(const CXXRecordDecl *Lambda) = 0;
+
   /// @name Mangler Entry Points
   /// @{
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D93839: [clang-format] PR48594 BraceWrapping: SplitEmptyRecord ignored for templates

2021-01-26 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan added a comment.

Hi. Up until this point, we've noticed that this patch can produce different 
formatted files depending on amount of whitespace. For example, given (A):

  #include 
  namespace fuzzing {}

`clang-format` with this patch would produced (B):

  #include 
  namespace fuzzing {
  }

but given (C):

  #include 
  namespace fuzzing {
  
  
  }

would be formatted to (D):

  #include 
  namespace fuzzing {
  
  }

The invocation specifically is `clang-format --style=google file`. Prior to 
this patch, both inputs (A/C) would give the same output:

  #include 
  namespace fuzzing {}

Is this unintended behavior and worth looking into? We have tests for generated 
code that use `clang-format` to attempt to "unify" expected and generated 
output for easy comparison. We would expect that extra whitespace not produce 
different formatted outputs. Thanks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93839

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


[PATCH] D94987: DR39: Perform ambiguous subobject checks for class member access as part of object argument conversion, not as part of name lookup.

2021-01-26 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: clang/include/clang/AST/CXXInheritance.h:77
 
-  CXXBasePath() = default;
+  /// Additional data stashed on the base path by its consumers.
+  union {

rsmith wrote:
> rjmccall wrote:
> > rsmith wrote:
> > > rjmccall wrote:
> > > > Is there a way to know which case we're in, or do different consumers 
> > > > do different things?
> > > We could use a discriminated union here. Ultimately, I think what we 
> > > really want is to provide some opaque storage for the consumer to use, 
> > > rather than to have some hard-coded list here. I haven't thought of a 
> > > good way to expose that; I don't think it's worth templating the entire 
> > > base path finding mechanism to add such storage, and a single pointer 
> > > isn't large enough for a `DeclContext::lookup_result`.
> > > 
> > > Vassil's https://reviews.llvm.org/D91524 will make the `lookup_result` 
> > > case fit into a single pointer; once we adopt that, perhaps we can switch 
> > > to holding an opaque `void*` here?
> > Yeah, that might be cleaner, assuming we really need this.  What are the 
> > clients that need to store something specifically in the `CXXBasePath` 
> > object and can't just keep it separate?
> The main users of this are in name lookup proper (where we store the lookup 
> results on the path to avoid redoing the class scope hash table lookup) and 
> now in access checking (where we store the most-accessible declaration). I 
> think there's a couple of other name-lookup-like clients that also store a 
> lookup result here.
> 
> In all cases the side storage is just a convenience. But it's probably an 
> important convenience; it's awkward for a client to maintain a mapping on the 
> side, because the key for that map would end up being the entire base path. 
> 
> We could just number the paths as we find them, and let the consumers build a 
> `SmallVector` on the side rather than storing data in the `CXXBasePath`s. 
> We'd need to be careful about the post-processing pass in `lookupInBases` 
> that removes virtual base paths that are shadowed by non-virtual inheritance 
> from the vbase, but that seems feasible. Worthwhile?
I see what you're saying.  We have places that compute all the base paths in an 
array, and it's convenient to be able to stash things into the elements of that 
array instead of having a second data structure that's parallel to it.  I guess 
there are three options:

- Tell clients to just make a parallel structure.

- Have this sort of intrusive storage and just accept that clients that want to 
use it will have some awkward casting to do.

- Get rid of the initial array dependence by making it a callback API instead 
of an array-building API, and then clients that want to build an array can 
build an array with the type they actually want.

I guess the third might be awkward?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94987

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


[PATCH] D95459: Add helper functionality for parsing different attribute syntaxes in arbitrary order

2021-01-26 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman created this revision.
aaron.ballman added reviewers: rsmith, dblaikie, jyknight, rjmccall.
aaron.ballman requested review of this revision.

In Clang today, we parse the different attribute syntaxes (`__attribute__`, 
`__declspec`, and `[[]]`) in a fairly rigid order. This leads to confusion for 
users when they guess the order incorrectly, and leads to bug reports like 
PR24559 or necessitates changes like D94788 .

This patch adds a helper function to allow us to more easily parse attributes 
in arbitrary order, and then updates all of the places where we would parse two 
or more different syntaxes in a rigid order to use the helper method. The patch 
does not attempt to handle Microsoft attributes (`[]`) because those are 
ambiguous with other code constructs and we don't have any attributes that use 
the syntax.

There may be other places that could be modified to start accepting attributes 
with more arbitrary orders (such as in lambda expressions), but I think that 
effort is best left to follow-up work as we notice a need.


https://reviews.llvm.org/D95459

Files:
  clang/include/clang/Parse/Parser.h
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Parse/ParseDeclCXX.cpp
  clang/lib/Parse/ParseExprCXX.cpp
  clang/lib/Parse/ParseObjc.cpp
  clang/test/Parser/attr-order.cpp
  clang/test/SemaOpenCL/address-spaces.cl

Index: clang/test/SemaOpenCL/address-spaces.cl
===
--- clang/test/SemaOpenCL/address-spaces.cl
+++ clang/test/SemaOpenCL/address-spaces.cl
@@ -256,7 +256,8 @@
 
 void func_multiple_addr2(void) {
   typedef __private int private_int_t;
-  __private __attribute__((opencl_global)) int var1;   // expected-error {{multiple address spaces specified for type}}
+  __private __attribute__((opencl_global)) int var1;   // expected-error {{multiple address spaces specified for type}} \
+   // expected-error {{function scope variable cannot be declared in global address space}}
   __private __attribute__((opencl_global)) int *var2;  // expected-error {{multiple address spaces specified for type}}
   __attribute__((opencl_global)) private_int_t var3;   // expected-error {{multiple address spaces specified for type}}
   __attribute__((opencl_global)) private_int_t *var4;  // expected-error {{multiple address spaces specified for type}}
Index: clang/test/Parser/attr-order.cpp
===
--- /dev/null
+++ clang/test/Parser/attr-order.cpp
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 -fsyntax-only -fms-extensions -verify %s
+
+struct [[]] __attribute__((lockable)) __declspec(dllexport) A {}; // ok
+struct [[]] __declspec(dllexport) __attribute__((lockable)) B {}; // ok
+struct [[]] [[]] __declspec(dllexport) __attribute__((lockable)) C {}; // ok
+struct __declspec(dllexport) [[]] __attribute__((lockable)) D {}; // ok
+struct __declspec(dllexport) __attribute__((lockable)) [[]] E {}; // ok
+struct __attribute__((lockable)) __declspec(dllexport) [[]] F {}; // ok
+struct __attribute__((lockable)) [[]] __declspec(dllexport) G {}; // ok
+struct [[]] __attribute__((lockable)) [[]] __declspec(dllexport) H {}; // ok
+
+[[noreturn]] __attribute__((cdecl)) __declspec(dllexport) void a(); // ok
+[[noreturn]] __declspec(dllexport) __attribute__((cdecl)) void b(); // ok
+[[]] [[noreturn]] __attribute__((cdecl)) __declspec(dllexport) void c(); // ok
+
+// [[]] attributes before a declaration must be at the start of the line.
+__declspec(dllexport) [[noreturn]] __attribute__((cdecl)) void d(); // expected-error {{an attribute list cannot appear here}}
+__declspec(dllexport) __attribute__((cdecl)) [[noreturn]] void e(); // expected-error {{an attribute list cannot appear here}}
+__attribute__((cdecl)) __declspec(dllexport) [[noreturn]] void f(); // expected-error {{an attribute list cannot appear here}}
+__attribute__((cdecl)) [[noreturn]] __declspec(dllexport) void g(); // expected-error {{an attribute list cannot appear here}}
+
+[[noreturn]] __attribute__((cdecl))
+[[]] // expected-error {{an attribute list cannot appear here}}
+__declspec(dllexport) void h();
Index: clang/lib/Parse/ParseObjc.cpp
===
--- clang/lib/Parse/ParseObjc.cpp
+++ clang/lib/Parse/ParseObjc.cpp
@@ -1350,9 +1350,8 @@
 
   // If attributes exist before the method, parse them.
   ParsedAttributes methodAttrs(AttrFactory);
-  if (getLangOpts().ObjC)
-MaybeParseGNUAttributes(methodAttrs);
-  MaybeParseCXX11Attributes(methodAttrs);
+  MaybeParseAttributes(PAKM_CXX11 | (getLangOpts().ObjC ? PAKM_GNU : 0),
+   methodAttrs);
 
   if (Tok.is(tok::code_completion)) {
 Actions.CodeCompleteObjCMethodDecl(getCurScope(), mType == tok::minus,
@@ -1377,9 +1376,8 @@
   SmallVector CParamInfo;
   if (Tok.isNot(tok::colon)) {
 // If attributes exist after the method, 

[PATCH] D95458: [PowerPC] Exploit xxsplti32dx (constant materialization) for scalars

2021-01-26 Thread Albion Fung via Phabricator via cfe-commits
Conanap created this revision.
Conanap added reviewers: nemanjai, saghir, PowerPC.
Conanap added projects: LLVM, clang, PowerPC.
Herald added a subscriber: kbarton.
Conanap requested review of this revision.

Previously related differential (exploit xxsplti32dx for vectors) here: 
https://reviews.llvm.org/D90173

This patch exploits the xxsplti32dx instruction available on Power10 in place 
of constant pool loads where xxspltidp would not be able to, usually because 
the immediate cannot fit into 32 bits.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D95458

Files:
  llvm/lib/Target/PowerPC/PPCISelLowering.cpp
  llvm/lib/Target/PowerPC/PPCISelLowering.h
  llvm/lib/Target/PowerPC/PPCInstrInfo.td
  llvm/lib/Target/PowerPC/PPCInstrPrefix.td
  llvm/test/CodeGen/PowerPC/constant-pool.ll
  llvm/test/CodeGen/PowerPC/p10-splatImm-CPload-pcrel.ll
  llvm/test/CodeGen/PowerPC/pcrel-call-linkage-leaf.ll
  llvm/test/CodeGen/PowerPC/pcrel-linkeropt.ll
  llvm/test/CodeGen/PowerPC/pcrel.ll

Index: llvm/test/CodeGen/PowerPC/pcrel.ll
===
--- llvm/test/CodeGen/PowerPC/pcrel.ll
+++ llvm/test/CodeGen/PowerPC/pcrel.ll
@@ -8,13 +8,14 @@
 
 ; Constant Pool Index.
 ; CHECK-S-LABEL: ConstPool
-; CHECK-S:   plfd f1, .LCPI0_0@PCREL(0), 1
+; CHECK-S:   xxsplti32dx vs1, 0, 1081002676
+; CHECK-S-NEXT:   xxsplti32dx vs1, 1, 962072674
 ; CHECK-S:   blr
 
 ; CHECK-O-LABEL: ConstPool
-; CHECK-O:   plfd 1, 0(0), 1
-; CHECK-O-NEXT:  R_PPC64_PCREL34  .rodata.cst8
-; CHECK-O:   blr
+; CHECK-O:   xxsplti32dx 1, 0, 1081002676
+; CHECK-O-NEXT:  xxsplti32dx 1, 1, 962072674
+; CHECK-O-NEXT:  blr
 define dso_local double @ConstPool() local_unnamed_addr {
   entry:
 ret double 0x406ECAB439581062
Index: llvm/test/CodeGen/PowerPC/pcrel-linkeropt.ll
===
--- llvm/test/CodeGen/PowerPC/pcrel-linkeropt.ll
+++ llvm/test/CodeGen/PowerPC/pcrel-linkeropt.ll
@@ -35,6 +35,9 @@
 @FuncPtrOut = external local_unnamed_addr global void (...)*, align 8
 
 define dso_local void @ReadWrite8() local_unnamed_addr #0 {
+; In this test the stb r3, 0(r4) cannot be optimized because it
+; uses the register r3 and that register is defined by lbz r3, 0(r3)
+; which is defined between the pld and the stb.
 ; CHECK-LABEL: ReadWrite8:
 ; CHECK:   # %bb.0: # %entry
 ; CHECK-NEXT:pld r3, input8@got@pcrel(0), 1
@@ -42,9 +45,6 @@
 ; CHECK-NEXT:pld r4, output8@got@pcrel(0), 1
 ; CHECK-NEXT:.reloc .Lpcrel0-8,R_PPC64_PCREL_OPT,.-(.Lpcrel0-8)
 ; CHECK-NEXT:lbz r3, 0(r3)
-; In this test the stb r3, 0(r4) cannot be optimized because it
-; uses the register r3 and that register is defined by lbz r3, 0(r3)
-; which is defined between the pld and the stb.
 ; CHECK-NEXT:stb r3, 0(r4)
 ; CHECK-NEXT:blr
 entry:
@@ -54,6 +54,9 @@
 }
 
 define dso_local void @ReadWrite16() local_unnamed_addr #0 {
+; In this test the sth r3, 0(r4) cannot be optimized because it
+; uses the register r3 and that register is defined by lhz r3, 0(r3)
+; which is defined between the pld and the sth.
 ; CHECK-LABEL: ReadWrite16:
 ; CHECK:   # %bb.0: # %entry
 ; CHECK-NEXT:pld r3, input16@got@pcrel(0), 1
@@ -61,9 +64,6 @@
 ; CHECK-NEXT:pld r4, output16@got@pcrel(0), 1
 ; CHECK-NEXT:.reloc .Lpcrel1-8,R_PPC64_PCREL_OPT,.-(.Lpcrel1-8)
 ; CHECK-NEXT:lhz r3, 0(r3)
-; In this test the sth r3, 0(r4) cannot be optimized because it
-; uses the register r3 and that register is defined by lhz r3, 0(r3)
-; which is defined between the pld and the sth.
 ; CHECK-NEXT:sth r3, 0(r4)
 ; CHECK-NEXT:blr
 entry:
@@ -144,7 +144,8 @@
 ; CHECK:   # %bb.0: # %entry
 ; CHECK-NEXT:pld r3, inputf64@got@pcrel(0), 1
 ; CHECK-NEXT:  .Lpcrel5:
-; CHECK-NEXT:plfd f1, .LCPI6_0@PCREL(0), 1
+; CHECK-NEXT:xxsplti32dx vs1, 0, 1075524403
+; CHECK-NEXT:xxsplti32dx vs1, 1, 858993459
 ; CHECK-NEXT:.reloc .Lpcrel5-8,R_PPC64_PCREL_OPT,.-(.Lpcrel5-8)
 ; CHECK-NEXT:lfd f0, 0(r3)
 ; CHECK-NEXT:pld r3, outputf64@got@pcrel(0), 1
@@ -286,8 +287,7 @@
 
 define dso_local void @FuncPtrCall() local_unnamed_addr #0 {
 ; CHECK-LABEL: FuncPtrCall:
-; CHECK: .localentry FuncPtrCall, 1
-; CHECK-NEXT:  # %bb.0: # %entry
+; CHECK:   # %bb.0: # %entry
 ; CHECK-NEXT:pld r3, FuncPtrIn@got@pcrel(0), 1
 ; CHECK-NEXT:  .Lpcrel10:
 ; CHECK-NEXT:.reloc .Lpcrel10-8,R_PPC64_PCREL_OPT,.-(.Lpcrel10-8)
@@ -317,8 +317,7 @@
 
 define dso_local signext i32 @VecMultiUse() local_unnamed_addr #0 {
 ; CHECK-LABEL: VecMultiUse:
-; CHECK: .localentry VecMultiUse, 1
-; CHECK-NEXT:  # %bb.0: # %entry
+; CHECK:   # %bb.0: # %entry
 ; CHECK-NEXT:mflr r0
 ; CHECK-NEXT:std r29, -24(r1) # 8-byte Folded Spill
 ; CHECK-NEXT:std r30, -16(r1) # 8-byte Folded Spill
@@ -355,8 +354,7 @@
 
 define dso_local signext i32 @UseAddr(i32 signext %a) local_unnamed_addr #0 {
 ; CHECK-LABEL: UseAddr:
-; CHECK: 

[PATCH] D94500: Rework Whitesmiths mode to use line-level values in UnwrappedLineParser

2021-01-26 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay accepted this revision.
MyDeveloperDay added a comment.
This revision is now accepted and ready to land.

LGTM I think, it would be good to get input from other reviewers




Comment at: clang/unittests/Format/FormatTest.cpp:13696
"  }\n"
-   "break;\n"
+   "  break;\n"
"}\n"

whilst I don't really like changing the indentation I don't think there was 
anything that says it was correct before.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94500

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


[PATCH] D85474: Add -fbinutils-version= to gate ELF features on the specified binutils version

2021-01-26 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay updated this revision to Diff 319337.
MaskRay marked 6 inline comments as done.
MaskRay added a comment.

Address comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85474

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/CodeGenOptions.h
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/Driver/fbinutils-version.c
  llvm/include/llvm/MC/MCAsmInfo.h
  llvm/include/llvm/Target/TargetMachine.h
  llvm/include/llvm/Target/TargetOptions.h
  llvm/lib/CodeGen/LLVMTargetMachine.cpp
  llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
  llvm/lib/Target/TargetMachine.cpp
  llvm/test/CodeGen/X86/explicit-section-mergeable.ll
  llvm/tools/llc/llc.cpp

Index: llvm/tools/llc/llc.cpp
===
--- llvm/tools/llc/llc.cpp
+++ llvm/tools/llc/llc.cpp
@@ -82,6 +82,15 @@
  cl::value_desc("N"),
  cl::desc("Repeat compilation N times for timing"));
 
+static cl::opt
+BinutilsVersion("binutils-version", cl::Hidden,
+cl::desc("Produced object files can use all ELF features "
+ "supported by this binutils version and newer."
+ "If -no-integrated-as is specified, the generated "
+ "assembly will consider GNU as support."
+ "'none' means that all ELF features can be used, "
+ "regardless of binutils support"));
+
 static cl::opt
 NoIntegratedAssembler("no-integrated-as", cl::Hidden,
   cl::desc("Disable integrated assembler"));
@@ -430,6 +439,8 @@
   TargetOptions Options;
   auto InitializeOptions = [&](const Triple ) {
 Options = codegen::InitTargetOptionsFromCodeGenFlags(TheTriple);
+Options.BinutilsVersion =
+TargetMachine::parseBinutilsVersion(BinutilsVersion);
 Options.DisableIntegratedAS = NoIntegratedAssembler;
 Options.MCOptions.ShowMCEncoding = ShowMCEncoding;
 Options.MCOptions.MCUseDwarfDirectory = EnableDwarfDirectory;
Index: llvm/test/CodeGen/X86/explicit-section-mergeable.ll
===
--- llvm/test/CodeGen/X86/explicit-section-mergeable.ll
+++ llvm/test/CodeGen/X86/explicit-section-mergeable.ll
@@ -282,15 +282,21 @@
 ;; --no-integrated-as avoids the use of ",unique," for compatibility with older binutils.
 
 ;; Error if an incompatible symbol is explicitly placed into a mergeable section.
-; RUN: not llc < %s -mtriple=x86_64 --no-integrated-as 2>&1 \
+; RUN: not llc < %s -mtriple=x86_64 --no-integrated-as -binutils-version=2.34 2>&1 \
 ; RUN: | FileCheck %s --check-prefix=NO-I-AS-ERR
 ; NO-I-AS-ERR: error: Symbol 'explicit_default_1' from module '' required a section with entry-size=0 but was placed in section '.rodata.cst16' with entry-size=16: Explicit assignment by pragma or attribute of an incompatible symbol to this section?
 ; NO-I-AS-ERR: error: Symbol 'explicit_default_4' from module '' required a section with entry-size=0 but was placed in section '.debug_str' with entry-size=1: Explicit assignment by pragma or attribute of an incompatible symbol to this section?
 ; NO-I-AS-ERR: error: Symbol 'explicit_implicit_2' from module '' required a section with entry-size=0 but was placed in section '.rodata.str1.1' with entry-size=1: Explicit assignment by pragma or attribute of an incompatible symbol to this section?
 ; NO-I-AS-ERR: error: Symbol 'explicit_implicit_4' from module '' required a section with entry-size=0 but was placed in section '.rodata.str1.1' with entry-size=1: Explicit assignment by pragma or attribute of an incompatible symbol to this section?
 
+;; For GNU as before 2.35,
 ;; Don't create mergeable sections for globals with an explicit section name.
 ; RUN: echo '@explicit = unnamed_addr constant [2 x i16] [i16 1, i16 1], section ".explicit"' > %t.no_i_as.ll
-; RUN: llc < %t.no_i_as.ll -mtriple=x86_64 --no-integrated-as 2>&1 \
-; RUN: | FileCheck %s --check-prefix=NO-I-AS
-; NO-I-AS: .section .explicit,"a",@progbits
+; RUN: llc < %t.no_i_as.ll -mtriple=x86_64 --no-integrated-as -binutils-version=2.34 2>&1 \
+; RUN: | FileCheck %s --check-prefix=NO-I-AS-OLD
+; NO-I-AS-OLD: .section .explicit,"a",@progbits
+; RUN: llc < %t.no_i_as.ll -mtriple=x86_64 --no-integrated-as -binutils-version=2.35 2>&1 \
+; RUN: | FileCheck %s --check-prefix=NO-I-AS-NEW
+; RUN: llc < %t.no_i_as.ll -mtriple=x86_64 --no-integrated-as -binutils-version=none 2>&1 \
+; RUN: | FileCheck %s --check-prefix=NO-I-AS-NEW
+; NO-I-AS-NEW: .section .explicit,"aM",@progbits,4,unique,1
Index: llvm/lib/Target/TargetMachine.cpp
===
--- llvm/lib/Target/TargetMachine.cpp

[PATCH] D95451: [clangd] references: decls of overrides of x are refs to x, not decls

2021-01-26 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet accepted this revision.
kadircet added a comment.
This revision is now accepted and ready to land.

thanks, lgtm!




Comment at: clang-tools-extra/clangd/XRefs.cpp:1406
+  Req.Limit = Limit;
+  auto QueryIndex = [&](bool AllowAttributes) {
+if (Req.IDs.empty() || !Index || Results.References.size() > Limit)

it might be nicer to make `IDs` a parameter too.



Comment at: clang-tools-extra/clangd/XRefs.cpp:1409
+  return;
 Results.HasMore |= Index->refs(Req, [&](const Ref ) {
   // No need to continue process if we reach the limit.

just thinking out loud, i wonder why we don't just provide a symbolid in this 
callback too. the interface currently says refs will be returned in any order, 
and i am not sure about all the index implementations we have, but i think they 
should be able to provide that for each reference. that way we could get rid of 
multiple index queries (not that it matters too much currently, but it might 
one day..)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95451

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


[PATCH] D69322: [hip][cuda] Enable extended lambda support on Windows.

2021-01-26 Thread Artem Belevich via Phabricator via cfe-commits
tra added a comment.

@hliao -- Can you take a look at  https://bugs.llvm.org/show_bug.cgi?id=48866. 
This patch may be relevant there.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69322

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


[PATCH] D94472: [WIP][clang][cli] Command line round-trip for HeaderSearch options

2021-01-26 Thread Michael Spencer via Phabricator via cfe-commits
Bigcheese added a comment.

In D94472#2519838 , @jansvoboda11 
wrote:

> In D94472#2508018 , @dexonsmith 
> wrote:
>
>> `strict` mode additionally uses the `GeneratedArgs1` to fill 
>> CompilerInvocation, indirectly checking both directions by requiring tests 
>> to pass both with and without this round-trip. However, during development 
>> people generally only run the tests one way and the failure mode won't be 
>> ideal.
>
> So people build without assertions during development? In that case, I agree 
> that erroring out on `GeneratedArgs1 != GeneratedArgs2` (in all kinds of 
> builds) would improve the experience. I don't think there's anything 
> preventing us to incorporate this into the current patch.

The only issue I have with this if always parsing twice has a noticeable 
performance impact for any users of Clang. Can we measure the impact? If it's 
small (< 100ms ?) then that's fine. I'm also concerned about users like cling 
and clangd.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94472

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


[PATCH] D94745: [OpenMP][deviceRTLs] Build the deviceRTLs with OpenMP instead of target dependent language

2021-01-26 Thread Shilei Tian 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 rG7c03f7d7d04c: [OpenMP][deviceRTLs] Build the deviceRTLs with 
OpenMP instead of target… (authored by tianshilei1992).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94745

Files:
  clang/lib/Driver/ToolChains/Cuda.cpp
  clang/test/Driver/Inputs/libomptarget/libomptarget-nvptx-cuda_80-sm_20.bc
  clang/test/Driver/Inputs/libomptarget/libomptarget-nvptx-sm_20.bc
  clang/test/Driver/openmp-offload-gpu.c
  openmp/libomptarget/deviceRTLs/amdgcn/src/target_impl.h
  openmp/libomptarget/deviceRTLs/common/allocator.h
  openmp/libomptarget/deviceRTLs/common/omptarget.h
  openmp/libomptarget/deviceRTLs/common/src/omp_data.cu
  openmp/libomptarget/deviceRTLs/common/src/reduction.cu
  openmp/libomptarget/deviceRTLs/nvptx/CMakeLists.txt
  openmp/libomptarget/deviceRTLs/nvptx/src/nvptx_interface.h
  openmp/libomptarget/deviceRTLs/nvptx/src/target_impl.cu
  openmp/libomptarget/deviceRTLs/nvptx/src/target_impl.h

Index: openmp/libomptarget/deviceRTLs/nvptx/src/target_impl.h
===
--- openmp/libomptarget/deviceRTLs/nvptx/src/target_impl.h
+++ openmp/libomptarget/deviceRTLs/nvptx/src/target_impl.h
@@ -13,18 +13,16 @@
 #define _TARGET_IMPL_H_
 
 #include 
-#include 
 #include 
 #include 
 #include 
 
 #include "nvptx_interface.h"
 
-#define DEVICE __device__
-#define INLINE __forceinline__ DEVICE
-#define NOINLINE __noinline__ DEVICE
-#define SHARED __shared__
-#define ALIGN(N) __align__(N)
+#define DEVICE
+#define INLINE inline __attribute__((always_inline))
+#define NOINLINE __attribute__((noinline))
+#define ALIGN(N) __attribute__((aligned(N)))
 
 
 // Kernel options
@@ -96,10 +94,6 @@
 INLINE uint32_t __kmpc_impl_ffs(uint32_t x) { return __builtin_ffs(x); }
 INLINE uint32_t __kmpc_impl_popc(uint32_t x) { return __builtin_popcount(x); }
 
-#ifndef CUDA_VERSION
-#error CUDA_VERSION macro is undefined, something wrong with cuda.
-#endif
-
 DEVICE __kmpc_impl_lanemask_t __kmpc_impl_activemask();
 
 DEVICE int32_t __kmpc_impl_shfl_sync(__kmpc_impl_lanemask_t Mask, int32_t Var,
Index: openmp/libomptarget/deviceRTLs/nvptx/src/target_impl.cu
===
--- openmp/libomptarget/deviceRTLs/nvptx/src/target_impl.cu
+++ openmp/libomptarget/deviceRTLs/nvptx/src/target_impl.cu
@@ -14,8 +14,6 @@
 #include "target_impl.h"
 #include "common/debug.h"
 
-#include 
-
 DEVICE void __kmpc_impl_unpack(uint64_t val, uint32_t , uint32_t ) {
   asm volatile("mov.b64 {%0,%1}, %2;" : "=r"(lo), "=r"(hi) : "l"(val));
 }
Index: openmp/libomptarget/deviceRTLs/nvptx/src/nvptx_interface.h
===
--- openmp/libomptarget/deviceRTLs/nvptx/src/nvptx_interface.h
+++ openmp/libomptarget/deviceRTLs/nvptx/src/nvptx_interface.h
@@ -11,7 +11,8 @@
 
 #include 
 
-#define EXTERN extern "C" __device__
+#define EXTERN extern "C"
+
 typedef uint32_t __kmpc_impl_lanemask_t;
 typedef uint32_t omp_lock_t; /* arbitrary type of the right length */
 
Index: openmp/libomptarget/deviceRTLs/nvptx/CMakeLists.txt
===
--- openmp/libomptarget/deviceRTLs/nvptx/CMakeLists.txt
+++ openmp/libomptarget/deviceRTLs/nvptx/CMakeLists.txt
@@ -10,6 +10,21 @@
 #
 ##===--===##
 
+# TODO: This part needs to be refined when libomptarget is going to support
+# Windows!
+# TODO: This part can also be removed if we can change the clang driver to make
+# it support device only compilation.
+if(CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "x86_64")
+  set(aux_triple x86_64-unknown-linux-gnu)
+elseif(CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "ppc64le")
+  set(aux_triple powerpc64le-unknown-linux-gnu)
+elseif(CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "aarch64")
+  set(aux_triple aarch64-unknown-linux-gnu)
+else()
+  libomptarget_say("Not building CUDA offloading device RTL: unknown host arch: ${CMAKE_HOST_SYSTEM_PROCESSOR}")
+  return()
+endif()
+
 get_filename_component(devicertl_base_directory
   ${CMAKE_CURRENT_SOURCE_DIR}
   DIRECTORY)
@@ -79,61 +94,91 @@
 )
 
 # Set flags for LLVM Bitcode compilation.
-set(bc_flags ${LIBOMPTARGET_NVPTX_SELECTED_CUDA_COMPILER_FLAGS}
+set(bc_flags -S -x c++
+ -target nvptx64
+ -Xclang -emit-llvm-bc
+ -Xclang -aux-triple -Xclang ${aux_triple}
+ -fopenmp -fopenmp-cuda-mode -Xclang -fopenmp-is-device
+ -D__CUDACC__
  -I${devicertl_base_directory}
  -I${devicertl_nvptx_directory}/src)
 
 if(${LIBOMPTARGET_NVPTX_DEBUG})
-  set(bc_flags ${bc_flags} 

[PATCH] D95017: [clang-format] add case aware include sorting

2021-01-26 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added inline comments.



Comment at: clang/docs/ClangFormatStyleOptions.rst:2286
+**IncludeSortAlphabetically** (``bool``)
+  Specify if sorting should be done in an alphabetical and
+  case sensitive fashion.

curdeius wrote:
> kentsommer wrote:
> > MyDeveloperDay wrote:
> > > Are you sure `IncludeSortAlphabetically` expresses what you mean? Once 
> > > these things get released they cannot be changed easily.
> > > 
> > > If you were not sure of a new option, in my view we should slow down and 
> > > make sure we have the correct design, for example you could have used a 
> > > enum and it might have given you more possibility for greater flexibility
> > > 
> > > ```
> > > enum IncludeSort
> > > {
> > >CaseInsensitive
> > >CaseSensitive
> > > }
> > > ```
> > > 
> > > Please give people time to re-review your changes before we commit, 
> > > especially if they've taken the time to look at your review in the first 
> > > place. Just saying.
> > > 
> > Hi, @MyDeveloperDay I definitely agree. It was not my intention to rush 
> > through the review. I was simply trying to follow the process outlined in 
> > https://llvm.org/docs/Contributing.html#how-to-submit-a-patch which 
> > mentions giving sufficient information to allow for a commit on your behalf 
> > when you don't have access after an LGTM (which is all that I did). As you 
> > can see from the lack of additional comments from my end, I was happy to 
> > let this sit and be reviewed. 
> > 
> > Per the discussion about the option itself, I do believe 
> > `IncludeSortAlphabetically` currently expresses what I mean as the behavior 
> > with this off is indeed not an alphabetical sort as case takes precedence 
> > over the alphabetical ordering. However, looking at the enum and realizing 
> > that others probably will have additional styles they prefer (maybe they 
> > want alphabetical but lower case first, etc.) I do believe it might have 
> > been a better way to go as it leaves more flexibility and room for 
> > additional ordering styles. Given that this just landed, I would be happy 
> > to open a patch to turn this into an `enum` as I do see benefits to doing 
> > so. What do you think?
> Hmmm, and how about using the existing option `SortIncludes` and change its 
> type from `bool` to some `enum`?
> We could then, for backward-compatibility, map `false` to (tentative) `Never` 
> and `true` to `ASCII`/`CaseInsensitive`, and add `CaseSensitive`.
> 
> This will have the advantage of not adding additional style options.
> ... and it will prove once again that using `bool`s for style options is not 
> a good idea.
I think that is an excellent idea @curdeius 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95017

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


[PATCH] D95001: [CodeView] Emit function types in -gline-tables-only.

2021-01-26 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

In your commit the message does not include `Reviewed by:`. Many people agree 
that both `Reviewed by:` & `Differential Revision:` should be present. The 
`Reviewed by:` list indicates people who acknowledged the patch. (The 
`Reviewers:` list does not necessarily mean all the people on the list have 
acknowledged the patch so `Reviewers:` is mostly useless.)

`arc amend` can fetch the Phabricator summary and amend the local description.

You can install `llvm/.git/hooks/pre-push` to prevent accidental `Summary:`, 
`Reviewers:`, `Subscribers:` and `Tags:`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95001

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


[PATCH] D95075: [hip] Fix `` compilation on Windows with VS2019.

2021-01-26 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

In your commit the message does not include `Reviewed by:`. Many people agree 
that both `Reviewed by:` & `Differential Revision:` should be present. The 
`Reviewed by:` list indicates people who acknowledged the patch. (The 
`Reviewers:` list does not necessarily mean all the people on the list have 
acknowledged the patch so `Reviewers:` is mostly useless.)

`arc amend` can fetch the Phabricator summary and amend the local description.

You can install `llvm/.git/hooks/pre-push` to prevent accidental `Summary:`, 
`Reviewers:`, `Subscribers:` and `Tags:`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95075

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


[PATCH] D94806: [OpenMP] Add support for mapping names in mapper API

2021-01-26 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

In your commit the message has just `Reviewers:`. The `Reviewers:` list does 
not necessarily mean all the people on the list have acknowledged the patch so 
`Reviewers:` is mostly useless. Many people agree that both `Reviewed:` & 
`Differential Revision:` should be present.

`arc amend` can fetch the Phabricator summary and amend the local description.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94806

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


[PATCH] D95229: [clangd] Treat optional field type mismatches as soft failures

2021-01-26 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 319321.
kadircet marked 4 inline comments as done.
kadircet added a comment.

As discussed offline, only treat "null" fields as missing, rather than allowing
type mismatches.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95229

Files:
  clang-tools-extra/clangd/Protocol.cpp

Index: clang-tools-extra/clangd/Protocol.cpp
===
--- clang-tools-extra/clangd/Protocol.cpp
+++ clang-tools-extra/clangd/Protocol.cpp
@@ -27,6 +27,21 @@
 
 namespace clang {
 namespace clangd {
+namespace {
+
+// Helper that doesn't treat `null` and absent fields as failures.
+template 
+bool tryMap(const llvm::json::Value , llvm::StringLiteral Prop, T ,
+llvm::json::Path P) {
+  auto *O = Params.getAsObject();
+  assert(O);
+  auto *V = O->get(Prop);
+  // Field is missing or null.
+  if (!V || V->getAsNull().hasValue())
+return true;
+  return fromJSON(*V, Out, P.field(Prop));
+}
+} // namespace
 
 char LSPError::ID;
 
@@ -490,7 +505,7 @@
   return O && O.map("textDocument", R.textDocument) &&
  O.map("contentChanges", R.contentChanges) &&
  O.map("wantDiagnostics", R.wantDiagnostics) &&
- O.mapOptional("forceRebuild", R.forceRebuild);
+ tryMap(Params, "forceRebuild", R.forceRebuild, P);
 }
 
 bool fromJSON(const llvm::json::Value , FileChangeType ,
@@ -580,10 +595,10 @@
   llvm::json::Path P) {
   llvm::json::ObjectMapper O(Params, P);
   return O && O.map("range", R.range) && O.map("message", R.message) &&
- O.mapOptional("severity", R.severity) &&
- O.mapOptional("category", R.category) &&
- O.mapOptional("code", R.code) && O.mapOptional("source", R.source);
-  return true;
+ tryMap(Params, "severity", R.severity, P) &&
+ tryMap(Params, "category", R.category, P) &&
+ tryMap(Params, "code", R.code, P) &&
+ tryMap(Params, "source", R.source, P);
 }
 
 llvm::json::Value toJSON(const PublishDiagnosticsParams ) {
@@ -817,9 +832,9 @@
   llvm::json::Path P) {
   llvm::json::ObjectMapper O(Params, P);
   int TriggerKind;
-  if (!O || !O.map("triggerKind", TriggerKind) ||
-  !O.mapOptional("triggerCharacter", R.triggerCharacter))
+  if (!O || !O.map("triggerKind", TriggerKind))
 return false;
+  tryMap(Params, "triggerCharacter", R.triggerCharacter, P);
   R.triggerKind = static_cast(TriggerKind);
   return true;
 }
@@ -1121,8 +1136,8 @@
   llvm::json::ObjectMapper O(Params, P);
   if (!O)
 return true; // 'any' type in LSP.
-  return O.mapOptional("compilationDatabaseChanges",
-   S.compilationDatabaseChanges);
+  tryMap(Params, "compilationDatabaseChanges", S.compilationDatabaseChanges, P);
+  return true;
 }
 
 bool fromJSON(const llvm::json::Value , InitializationOptions ,
@@ -1133,8 +1148,8 @@
 
   return fromJSON(Params, Opts.ConfigSettings, P) &&
  O.map("compilationDatabasePath", Opts.compilationDatabasePath) &&
- O.mapOptional("fallbackFlags", Opts.fallbackFlags) &&
- O.mapOptional("clangdFileStatus", Opts.FileStatus);
+ tryMap(Params, "fallbackFlags", Opts.fallbackFlags, P) &&
+ tryMap(Params, "clangdFileStatus", Opts.FileStatus, P);
 }
 
 bool fromJSON(const llvm::json::Value , TypeHierarchyDirection ,
@@ -1190,10 +1205,11 @@
   return O && O.map("name", I.name) && O.map("kind", I.kind) &&
  O.map("uri", I.uri) && O.map("range", I.range) &&
  O.map("selectionRange", I.selectionRange) &&
- O.mapOptional("detail", I.detail) &&
- O.mapOptional("deprecated", I.deprecated) &&
- O.mapOptional("parents", I.parents) &&
- O.mapOptional("children", I.children) && O.mapOptional("data", I.data);
+ tryMap(Params, "detail", I.detail, P) &&
+ tryMap(Params, "deprecated", I.deprecated, P) &&
+ tryMap(Params, "parents", I.parents, P) &&
+ tryMap(Params, "children", I.children, P) &&
+ tryMap(Params, "data", I.data, P);
 }
 
 bool fromJSON(const llvm::json::Value ,
@@ -1238,7 +1254,7 @@
   return O && O.map("name", I.name) && O.map("kind", I.kind) &&
  O.map("uri", I.uri) && O.map("range", I.range) &&
  O.map("selectionRange", I.selectionRange) &&
- O.mapOptional("data", I.data);
+ tryMap(Params, "data", I.data, P);
 }
 
 bool fromJSON(const llvm::json::Value ,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D95451: [clangd] references: decls of overrides of x are refs to x, not decls

2021-01-26 Thread Sam McCall via Phabricator via cfe-commits
sammccall created this revision.
sammccall added a reviewer: kadircet.
Herald added subscribers: usaxena95, arphaman.
sammccall requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay, ilya-biryukov.
Herald added a project: clang.

This requires a second index query for refs to overrides, as the refs
call doesn't tell you which ref points at which symbol.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D95451

Files:
  clang-tools-extra/clangd/XRefs.cpp
  clang-tools-extra/clangd/unittests/XRefsTests.cpp

Index: clang-tools-extra/clangd/unittests/XRefsTests.cpp
===
--- clang-tools-extra/clangd/unittests/XRefsTests.cpp
+++ clang-tools-extra/clangd/unittests/XRefsTests.cpp
@@ -1872,7 +1872,7 @@
 };
 class Derived : public Base {
 public:
-  void $decl[[func]]() override; // FIXME: ref, not decl
+  void [[func]]() override;
 };
 void test(Derived* D) {
   D->[[func]]();
Index: clang-tools-extra/clangd/XRefs.cpp
===
--- clang-tools-extra/clangd/XRefs.cpp
+++ clang-tools-extra/clangd/XRefs.cpp
@@ -872,6 +872,7 @@
   struct Reference {
 syntax::Token SpelledTok;
 index::SymbolRoleSet Role;
+SymbolID Target;
 
 Range range(const SourceManager ) const {
   return halfOpenToRange(SM, SpelledTok.range(SM).toCharRange(SM));
@@ -906,13 +907,15 @@
SourceLocation Loc,
index::IndexDataConsumer::ASTNodeInfo ASTNode) override {
 const SourceManager  = AST.getSourceManager();
-if (!isInsideMainFile(Loc, SM) ||
-TargetIDs.find(getSymbolID(D)) == TargetIDs.end())
+if (!isInsideMainFile(Loc, SM))
+  return true;
+SymbolID ID = getSymbolID(D);
+if (!TargetIDs.contains(ID))
   return true;
 const auto  = AST.getTokens();
 Loc = SM.getFileLoc(Loc);
 if (const auto *Tok = TB.spelledTokenAt(Loc))
-  References.push_back({*Tok, Roles});
+  References.push_back({*Tok, Roles, ID});
 return true;
   }
 
@@ -1298,6 +1301,7 @@
   }
 
   RefsRequest Req;
+  llvm::DenseSet Overrides;
 
   const auto *IdentifierAtCursor =
   syntax::spelledIdentifierTouching(*CurLoc, AST.getTokens());
@@ -1336,7 +1340,6 @@
   if (auto ID = getSymbolID(D))
 Targets.insert(ID);
 
-llvm::DenseSet Overrides;
 if (Index) {
   RelationsRequest FindOverrides;
   FindOverrides.Predicate = RelationKind::OverriddenBy;
@@ -1374,16 +1377,18 @@
   ReferencesResult::Reference Result;
   Result.Loc.range = Ref.range(SM);
   Result.Loc.uri = URIMainFile;
-  if (Ref.Role & static_cast(index::SymbolRole::Declaration))
-Result.Attributes |= ReferencesResult::Declaration;
-  // clang-index doesn't report definitions as declarations, but they are.
-  if (Ref.Role & static_cast(index::SymbolRole::Definition))
-Result.Attributes |=
-ReferencesResult::Definition | ReferencesResult::Declaration;
+  // Overrides are always considered references, not defs/decls.
+  if (!Overrides.contains(Ref.Target)) {
+if (Ref.Role & static_cast(index::SymbolRole::Declaration))
+  Result.Attributes |= ReferencesResult::Declaration;
+// clang-index doesn't report definitions as declarations, but they are.
+if (Ref.Role & static_cast(index::SymbolRole::Definition))
+  Result.Attributes |=
+  ReferencesResult::Definition | ReferencesResult::Declaration;
+  }
   Results.References.push_back(std::move(Result));
 }
 if (Index && Results.References.size() <= Limit) {
-  Req.IDs = std::move(Overrides);
   for (const Decl *D : Decls) {
 // Not all symbols can be referenced from outside (e.g.
 // function-locals).
@@ -1397,8 +1402,10 @@
 }
   }
   // Now query the index for references from other files.
-  if (!Req.IDs.empty() && Index && Results.References.size() <= Limit) {
-Req.Limit = Limit;
+  Req.Limit = Limit;
+  auto QueryIndex = [&](bool AllowAttributes) {
+if (Req.IDs.empty() || !Index || Results.References.size() > Limit)
+  return;
 Results.HasMore |= Index->refs(Req, [&](const Ref ) {
   // No need to continue process if we reach the limit.
   if (Results.References.size() > Limit)
@@ -1409,15 +1416,22 @@
 return;
   ReferencesResult::Reference Result;
   Result.Loc = std::move(*LSPLoc);
-  if ((R.Kind & RefKind::Declaration) == RefKind::Declaration)
-Result.Attributes |= ReferencesResult::Declaration;
-  // FIXME: our index should definitely store def | decl separately!
-  if ((R.Kind & RefKind::Definition) == RefKind::Definition)
-Result.Attributes |=
-ReferencesResult::Declaration | ReferencesResult::Definition;
+  if (AllowAttributes) {
+if ((R.Kind & 

[PATCH] D69560: [clang-tidy] Add 'bugprone-easily-swappable-parameters' check

2021-01-26 Thread Whisperity via Phabricator via cfe-commits
whisperity updated this revision to Diff 319315.
whisperity added a comment.

  - Added a fallback case to also diagnose when Clang parsed the two types to 
be canonically the same (we will elaborate a few cases of such equivalences 
later, such as `typedef`s)
- Fixed Clang-Format and Clang-Tidy warnings in the patch


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69560

Files:
  clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
  clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
  clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  
clang-tools-extra/docs/clang-tidy/checks/bugprone-easily-swappable-parameters.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-ignore.cpp
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-len2.cpp
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-len3.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-len3.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-len3.cpp
@@ -0,0 +1,24 @@
+// RUN: %check_clang_tidy %s bugprone-easily-swappable-parameters %t \
+// RUN:   -config='{CheckOptions: [ \
+// RUN: {key: bugprone-easily-swappable-parameters.MinimumLength, value: 3}, \
+// RUN: {key: bugprone-easily-swappable-parameters.IgnoredParameterNames, value: ""}, \
+// RUN: {key: bugprone-easily-swappable-parameters.IgnoredParameterTypeSuffixes, value: ""} \
+// RUN:  ]}' --
+
+int add(int Left, int Right) { return Left + Right; } // NO-WARN: Only 2 parameters.
+
+int magic(int Left, int Right, int X, int Y) { return 0; }
+// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: 4 adjacent parameters of 'magic' of similar type ('int') are easily swapped by mistake [bugprone-easily-swappable-parameters]
+// CHECK-MESSAGES: :[[@LINE-2]]:15: note: the first parameter in the range is 'Left'
+// CHECK-MESSAGES: :[[@LINE-3]]:43: note: the last parameter in the range is 'Y'
+
+void multipleDistinctTypes(int I, int J, int K,
+   long L, long M,
+   double D, double E, double F) {}
+// CHECK-MESSAGES: :[[@LINE-3]]:28: warning: 3 adjacent parameters of 'multipleDistinctTypes' of similar type ('int')
+// CHECK-MESSAGES: :[[@LINE-4]]:32: note: the first parameter in the range is 'I'
+// CHECK-MESSAGES: :[[@LINE-5]]:46: note: the last parameter in the range is 'K'
+// NO-WARN: The [long, long] range is length of 2.
+// CHECK-MESSAGES: :[[@LINE-5]]:28: warning: 3 adjacent parameters of 'multipleDistinctTypes' of similar type ('double')
+// CHECK-MESSAGES: :[[@LINE-6]]:35: note: the first parameter in the range is 'D'
+// CHECK-MESSAGES: :[[@LINE-7]]:55: note: the last parameter in the range is 'F'
Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-len2.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-len2.cpp
@@ -0,0 +1,141 @@
+// RUN: %check_clang_tidy %s bugprone-easily-swappable-parameters %t \
+// RUN:   -config='{CheckOptions: [ \
+// RUN: {key: bugprone-easily-swappable-parameters.MinimumLength, value: 2}, \
+// RUN: {key: bugprone-easily-swappable-parameters.IgnoredParameterNames, value: ""}, \
+// RUN: {key: bugprone-easily-swappable-parameters.IgnoredParameterTypeSuffixes, value: ""} \
+// RUN:  ]}' --
+
+#define assert(X)
+
+void declaration(int Param, int Other); // NO-WARN: No chance to change this function.
+
+struct S {};
+
+S *allocate() { return nullptr; }   // NO-WARN: 1 parameter.
+void allocate(S **Out) {}   // NO-WARN: 1 parameter.
+bool operator<(const S , const S ) { return true; } // NO-WARN: Operator.
+
+void redeclChain(int, int, int);
+void redeclChain(int I, int, int);
+void redeclChain(int, int J, int);
+void redeclChain(int I, int J, int K) {}
+// CHECK-MESSAGES: :[[@LINE-1]]:18: warning: 3 adjacent parameters of 'redeclChain' of similar type ('int') are easily swapped by mistake [bugprone-easily-swappable-parameters]
+// CHECK-MESSAGES: :[[@LINE-2]]:22: note: the first parameter in the range is 'I'
+// CHECK-MESSAGES: :[[@LINE-3]]:36: note: the last parameter in the range is 'K'
+
+void copyMany(S *Src, S *Dst, unsigned Num) {}
+// CHECK-MESSAGES: :[[@LINE-1]]:15: warning: 2 adjacent parameters of 'copyMany' of similar type ('S *')
+// CHECK-MESSAGES: :[[@LINE-2]]:18: note: the first parameter in the range is 'Src'
+// CHECK-MESSAGES: :[[@LINE-3]]:26: note: 

[PATCH] D95423: [clangd] Add std::size_t to StdSymbol mapping

2021-01-26 Thread Kadir Cetinkaya via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG9190f17a7cc5: [clangd] Add std::size_t to StdSymbol mapping 
(authored by kadircet).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95423

Files:
  clang-tools-extra/clangd/index/CanonicalIncludes.cpp


Index: clang-tools-extra/clangd/index/CanonicalIncludes.cpp
===
--- clang-tools-extra/clangd/index/CanonicalIncludes.cpp
+++ clang-tools-extra/clangd/index/CanonicalIncludes.cpp
@@ -92,6 +92,8 @@
 #include "StdSymbolMap.inc"
 // There are two std::move()s, this is by far the most common.
 SYMBOL(move, std::, )
+// There are multiple headers for size_t, pick one.
+SYMBOL(size_t, std::, )
 #undef SYMBOL
 });
 StdSymbolMapping = Symbols;
@@ -99,6 +101,8 @@
 static const auto *CSymbols = new llvm::StringMap({
 #define SYMBOL(Name, NameSpace, Header) {#Name, #Header},
 #include "CSymbolMap.inc"
+// There are multiple headers for size_t, pick one.
+SYMBOL(size_t, None, )
 #undef SYMBOL
 });
 StdSymbolMapping = CSymbols;


Index: clang-tools-extra/clangd/index/CanonicalIncludes.cpp
===
--- clang-tools-extra/clangd/index/CanonicalIncludes.cpp
+++ clang-tools-extra/clangd/index/CanonicalIncludes.cpp
@@ -92,6 +92,8 @@
 #include "StdSymbolMap.inc"
 // There are two std::move()s, this is by far the most common.
 SYMBOL(move, std::, )
+// There are multiple headers for size_t, pick one.
+SYMBOL(size_t, std::, )
 #undef SYMBOL
 });
 StdSymbolMapping = Symbols;
@@ -99,6 +101,8 @@
 static const auto *CSymbols = new llvm::StringMap({
 #define SYMBOL(Name, NameSpace, Header) {#Name, #Header},
 #include "CSymbolMap.inc"
+// There are multiple headers for size_t, pick one.
+SYMBOL(size_t, None, )
 #undef SYMBOL
 });
 StdSymbolMapping = CSymbols;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D95439: [clangd] Add include-fixer fixit for field_incomplete_or_sizeless diagnostic.

2021-01-26 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added inline comments.



Comment at: clang-tools-extra/clangd/IncludeFixer.cpp:81
   case diag::err_func_def_incomplete_result:
+  case diag::err_field_incomplete_or_sizeless:
 // Incomplete type diagnostics should have a QualType argument for the

what about the `sizless` case ? we'll attach a fixit, but it is not going to 
fix the issue :(



Comment at: clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp:786
   TU.build().getDiagnostics(),
-  UnorderedElementsAre(
-  AllOf(Diag(Test.range("nested"),
- "incomplete type 'ns::X' named in nested name specifier"),
-DiagName("incomplete_nested_name_spec"),
-WithFix(Fix(Test.range("insert"), "#include \"x.h\"\n",
-"Add include \"x.h\" for symbol ns::X"))),
-  AllOf(Diag(Test.range("base"), "base class has incomplete type"),
-DiagName("incomplete_base_class"),
-WithFix(Fix(Test.range("insert"), "#include \"x.h\"\n",
-"Add include \"x.h\" for symbol ns::X"))),
-  AllOf(Diag(Test.range("access"),
- "member access into incomplete type 'ns::X'"),
-DiagName("incomplete_member_access"),
-WithFix(Fix(Test.range("insert"), "#include \"x.h\"\n",
-"Add include \"x.h\" for symbol ns::X"))),
-  AllOf(
-  Diag(Test.range("type"),
+  testing::UnorderedElementsAreArray(
+  {AllOf(Diag(Test.range("nested"),

nit: add a `using` decl instead


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95439

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


[PATCH] D95246: [SystemZ][z/OS] Fix No such file or directory expression error matching in lit tests - continued

2021-01-26 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan updated this revision to Diff 319309.
abhina.sreeskantharajan added a comment.

Fix CI: Other projects like flang also do not specify LLVM_HOST_TRIPLE. If this 
is not specified, set the triple to an empty string.

I also added one more error code %errc_EISDIR and updated the TestingGuide. 
Please let me know if there are other guides I will need to update that I'm not 
aware of.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95246

Files:
  clang/test/Driver/clang-offload-bundler.c
  clang/test/Frontend/output-failures.c
  clang/test/Frontend/stats-file.c
  lld/CMakeLists.txt
  lld/test/ELF/basic.s
  lld/test/lit.site.cfg.py.in
  llvm/docs/TestingGuide.rst
  llvm/test/Object/archive-extract.test
  llvm/test/Object/directory.ll
  llvm/test/tools/llvm-ar/move.test
  llvm/utils/lit/lit/llvm/config.py

Index: llvm/utils/lit/lit/llvm/config.py
===
--- llvm/utils/lit/lit/llvm/config.py
+++ llvm/utils/lit/lit/llvm/config.py
@@ -345,6 +345,21 @@
 self.config.substitutions.extend(substitutions)
 return True
 
+def add_err_msg_substitutions(self):
+triple = ""
+if hasattr(self.config, 'host_triple'):
+triple = self.config.host_triple
+
+if (re.match(r's390x-.*-zos', triple)):
+self.config.substitutions.append(('%errc_ENOENT', '\'EDC5129I No such file or directory.\''))
+self.config.substitutions.append(('%errc_EISDIR', '\'EDC5123I Is a directory.\''))
+elif (re.match(r'.*windows.*', triple)):
+self.config.substitutions.append(('%errc_ENOENT', '\'no such file or directory\''))
+self.config.substitutions.append(('%errc_EISDIR', '\'is a directory\''))
+else:
+self.config.substitutions.append(('%errc_ENOENT', '\'No such file or directory\''))
+self.config.substitutions.append(('%errc_EISDIR', '\'Is a directory\''))
+
 def use_default_substitutions(self):
 tool_patterns = [
 ToolSubst('FileCheck', unresolved='fatal'),
@@ -358,6 +373,8 @@
 self.add_tool_substitutions(
 tool_patterns, [self.config.llvm_tools_dir])
 
+self.add_err_msg_substitutions()
+
 def use_llvm_tool(self, name, search_env=None, required=False, quiet=False):
 """Find the executable program 'name', optionally using the specified
 environment variable as an override before searching the
Index: llvm/test/tools/llvm-ar/move.test
===
--- llvm/test/tools/llvm-ar/move.test
+++ llvm/test/tools/llvm-ar/move.test
@@ -82,9 +82,9 @@
 ## Member does not exist:
 # RUN: llvm-ar rc %t/missing.a %t/1.o %t/2.o %t/3.o
 # RUN: not llvm-ar m %t/missing.a %t/missing.txt 2>&1 \
-# RUN:   | FileCheck %s --check-prefix=MISSING-FILE -DFILE=%t/missing.txt
+# RUN:   | FileCheck %s --check-prefix=MISSING-FILE -DFILE=%t/missing.txt -DMSG=%errc_ENOENT
 
-# MISSING-FILE: error: [[FILE]]: {{[nN]}}o such file or directory
+# MISSING-FILE: error: [[FILE]]: [[MSG]]
 
 --- !ELF
 FileHeader:
Index: llvm/test/Object/directory.ll
===
--- llvm/test/Object/directory.ll
+++ llvm/test/Object/directory.ll
@@ -1,6 +1,6 @@
 ;RUN: rm -rf %t && mkdir -p %t
-;RUN: not llvm-ar r %t/test.a . 2>&1 | FileCheck %s
-;CHECK: .: {{I|i}}s a directory
+;RUN: not llvm-ar r %t/test.a . 2>&1 | FileCheck -DMSG=%errc_EISDIR %s
+;CHECK: .: [[MSG]]
 
 ;RUN: rm -f %t/test.a
 ;RUN: touch %t/a-very-long-file-name
Index: llvm/test/Object/archive-extract.test
===
--- llvm/test/Object/archive-extract.test
+++ llvm/test/Object/archive-extract.test
@@ -57,5 +57,5 @@
 RUN: llvm-ar p %p/Inputs/thin.a evenlen | FileCheck %s --check-prefix=EVENLEN
 EVENLEN: evenlen
 
-RUN: not llvm-ar p %p/Inputs/thin-path.a t/test2.o 2>&1 | FileCheck %s --check-prefix=MISSING
-MISSING: error: {{N|n}}o such file or directory
+RUN: not llvm-ar p %p/Inputs/thin-path.a t/test2.o 2>&1 | FileCheck %s --DMSG=%errc_ENOENT --check-prefix=MISSING
+MISSING: error: [[MSG]]
Index: llvm/docs/TestingGuide.rst
===
--- llvm/docs/TestingGuide.rst
+++ llvm/docs/TestingGuide.rst
@@ -537,6 +537,14 @@
 
Example: ``%:s: C\Desktop Files\foo_test.s.tmp``
 
+``%errc_``
+
+ Some error messages may be substituted to allow different spellings
+ based on the host platform.
+
+   Example (%errc_ENOENT): ``No such file or directory``
+
+   Example (%errc_ENOENT): ``no such file or directory``
 
 **LLVM-specific substitutions:**
 
Index: lld/test/lit.site.cfg.py.in
===
--- lld/test/lit.site.cfg.py.in
+++ lld/test/lit.site.cfg.py.in
@@ -11,6 +11,7 @@
 config.lld_obj_root = 

[PATCH] D95450: [clangd] Respect ReferencesParams.context.includeDeclarations

2021-01-26 Thread Sam McCall via Phabricator via cfe-commits
sammccall created this revision.
sammccall added a reviewer: kbobyrev.
Herald added subscribers: usaxena95, kadircet, arphaman.
sammccall requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay, ilya-biryukov.
Herald added a project: clang.

Unfortunately this treats overrides declarations as declarations, not as
references. I don't plan to land this until I have a fix for that issue.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D95450

Files:
  clang-tools-extra/clangd/ClangdLSPServer.cpp
  clang-tools-extra/clangd/Protocol.cpp
  clang-tools-extra/clangd/Protocol.h
  clang-tools-extra/clangd/XRefs.cpp
  clang-tools-extra/clangd/XRefs.h
  clang-tools-extra/clangd/test/references.test
  clang-tools-extra/clangd/unittests/PreambleTests.cpp
  clang-tools-extra/clangd/unittests/XRefsTests.cpp

Index: clang-tools-extra/clangd/unittests/XRefsTests.cpp
===
--- clang-tools-extra/clangd/unittests/XRefsTests.cpp
+++ clang-tools-extra/clangd/unittests/XRefsTests.cpp
@@ -37,6 +37,7 @@
 namespace clangd {
 namespace {
 
+using ::testing::AllOf;
 using ::testing::ElementsAre;
 using ::testing::Eq;
 using ::testing::IsEmpty;
@@ -290,7 +291,8 @@
 
 MATCHER_P(Sym, Name, "") { return arg.Name == Name; }
 
-MATCHER_P(RangeIs, R, "") { return arg.range == R; }
+MATCHER_P(RangeIs, R, "") { return arg.Loc.range == R; }
+MATCHER_P(AttrsAre, A, "") { return arg.Attributes == A; }
 
 TEST(LocateSymbol, WithIndex) {
   Annotations SymbolHeader(R"cpp(
@@ -1688,11 +1690,35 @@
   << Test;
 }
 
+void checkFindRefs(llvm::StringRef Test, bool UseIndex = false) {
+  Annotations T(Test);
+  auto TU = TestTU::withCode(T.code());
+  auto AST = TU.build();
+  std::vector> ExpectedLocations;
+  for (const auto  : T.ranges())
+ExpectedLocations.push_back(
+AllOf(RangeIs(R), AttrsAre(ReferencesResult::Plain)));
+  // $def is actually shorthand for both definition and declaration.
+  // If we have cases that are definition-only, we should change this.
+  for (const auto  : T.ranges("def"))
+ExpectedLocations.push_back(
+AllOf(RangeIs(R), AttrsAre(ReferencesResult::Definition |
+   ReferencesResult::Declaration)));
+  for (const auto  : T.ranges("decl"))
+ExpectedLocations.push_back(
+AllOf(RangeIs(R), AttrsAre(ReferencesResult::Declaration)));
+  EXPECT_THAT(
+  findReferences(AST, T.point(), 0, UseIndex ? TU.index().get() : nullptr)
+  .References,
+  UnorderedElementsAreArray(ExpectedLocations))
+  << Test;
+}
+
 TEST(FindReferences, WithinAST) {
   const char *Tests[] = {
   R"cpp(// Local variable
 int main() {
-  int [[foo]];
+  int $def[[foo]];
   [[^foo]] = 2;
   int test1 = [[foo]];
 }
@@ -1700,7 +1726,7 @@
 
   R"cpp(// Struct
 namespace ns1 {
-struct [[Foo]] {};
+struct $def[[Foo]] {};
 } // namespace ns1
 int main() {
   ns1::[[Fo^o]]* Params;
@@ -1708,15 +1734,15 @@
   )cpp",
 
   R"cpp(// Forward declaration
-class [[Foo]];
-class [[Foo]] {};
+class $decl[[Foo]];
+class $def[[Foo]] {};
 int main() {
   [[Fo^o]] foo;
 }
   )cpp",
 
   R"cpp(// Function
-int [[foo]](int) {}
+int $def[[foo]](int) {}
 int main() {
   auto *X = &[[^foo]];
   [[foo]](42);
@@ -1725,7 +1751,7 @@
 
   R"cpp(// Field
 struct Foo {
-  int [[foo]];
+  int $def[[foo]];
   Foo() : [[foo]](0) {}
 };
 int main() {
@@ -1735,8 +1761,8 @@
   )cpp",
 
   R"cpp(// Method call
-struct Foo { int [[foo]](); };
-int Foo::[[foo]]() {}
+struct Foo { int $decl[[foo]](); };
+int Foo::$def[[foo]]() {}
 int main() {
   Foo f;
   f.[[^foo]]();
@@ -1745,7 +1771,7 @@
 
   R"cpp(// Constructor
 struct Foo {
-  [[F^oo]](int);
+  $decl[[F^oo]](int);
 };
 void foo() {
   Foo f = [[Foo]](42);
@@ -1753,14 +1779,14 @@
   )cpp",
 
   R"cpp(// Typedef
-typedef int [[Foo]];
+typedef int $def[[Foo]];
 int main() {
   [[^Foo]] bar;
 }
   )cpp",
 
   R"cpp(// Namespace
-namespace [[ns]] {
+namespace $decl[[ns]] { // FIXME: def?
 struct Foo {};
 } // namespace ns
 int main() { [[^ns]]::Foo foo; }
@@ -1770,7 +1796,7 @@
 #define TYPE(X) X
 #define FOO Foo
 #define CAT(X, Y) X##Y
-class [[Fo^o]] {};
+class $def[[Fo^o]] {};
 void test() {
   TYPE([[Foo]]) foo;
   [[FOO]] foo2;
@@ -1780,7 +1806,7 @@
   )cpp",
 
   R"cpp(// Macros
-#define [[MA^CRO]](X) (X+1)
+#define $def[[MA^CRO]](X) (X+1)
 void test() {
   int x = 

[PATCH] D95442: [OpenCL] Add diagnostics for references to functions

2021-01-26 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added inline comments.



Comment at: clang/test/SemaOpenCLCXX/references.cl:24
+void templ() {
+  // FIXME: We miss to diagnose the reference to function.
+  T loc; //expected-error{{declaration of reference variable 'loc' requires an 
initializer}}

I have created PR48887 for this because we also miss other diagnotics.



Comment at: clang/test/SemaOpenCLCXX/references.cl:29
+void foo();
+void test(void ()()) {
+  void ()();

oops, I thought this was covered in my patch. I will see if there is a quick 
fix and if not I will create another PR.


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

https://reviews.llvm.org/D95442

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


[PATCH] D95417: [NFC] Disallow unused prefixes under clang/test/CodeGen

2021-01-26 Thread Mircea Trofin via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG0c0d009a88f2: [NFC] Disallow unused prefixes under 
clang/test/CodeGen (authored by mtrofin).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95417

Files:
  
clang/test/CodeGen/catch-alignment-assumption-attribute-align_value-on-lvalue.cpp
  
clang/test/CodeGen/catch-alignment-assumption-attribute-alloc_align-on-function-variable.cpp
  
clang/test/CodeGen/catch-alignment-assumption-attribute-assume_aligned-on-function-two-params.cpp
  
clang/test/CodeGen/catch-alignment-assumption-builtin_assume_aligned-three-params-variable.cpp
  
clang/test/CodeGen/catch-alignment-assumption-builtin_assume_aligned-three-params.cpp
  
clang/test/CodeGen/catch-alignment-assumption-builtin_assume_aligned-two-params.cpp
  clang/test/CodeGen/catch-alignment-assumption-openmp.cpp
  clang/test/CodeGen/catch-implicit-integer-sign-changes-incdec.c
  clang/test/CodeGen/catch-implicit-integer-sign-changes-true-negatives.c
  clang/test/CodeGen/catch-implicit-signed-integer-truncations-incdec.c
  clang/test/CodeGen/catch-nullptr-and-nonzero-offset-blacklist.c
  clang/test/CodeGen/catch-nullptr-and-nonzero-offset-when-nullptr-is-defined.c
  clang/test/CodeGen/catch-nullptr-and-nonzero-offset.c
  clang/test/CodeGen/catch-pointer-overflow-volatile.c
  clang/test/CodeGen/catch-pointer-overflow.c
  clang/test/CodeGen/cmse-clear-return.c
  clang/test/CodeGen/lit.local.cfg

Index: clang/test/CodeGen/lit.local.cfg
===
--- /dev/null
+++ clang/test/CodeGen/lit.local.cfg
@@ -0,0 +1,9 @@
+# -*- Python -*- vim: set ft=python ts=4 sw=4 expandtab tw=79:
+from lit.llvm.subst import ToolSubst
+
+fc = ToolSubst('FileCheck', unresolved='fatal')
+# Insert this first. Then, we'll first update the blank FileCheck command; then,
+# the default substitution of FileCheck will replace it to its full path.
+config.substitutions.insert(0, (fc.regex,
+'FileCheck --allow-unused-prefixes=false'))
+
Index: clang/test/CodeGen/cmse-clear-return.c
===
--- clang/test/CodeGen/cmse-clear-return.c
+++ clang/test/CodeGen/cmse-clear-return.c
@@ -1,7 +1,7 @@
 // RUN: %clang_cc1 -triple thumbv8m.main   -O0 -mcmse -S -emit-llvm %s -o - | \
 // RUN:FileCheck %s --check-prefixes=CHECK,CHECK-LE,CHECK-LE-NOPT,CHECK-SOFT
 // RUN: %clang_cc1 -triple thumbebv8m.main -O0 -mcmse -S -emit-llvm %s -o - | \
-// RUN:FileCheck %s --check-prefixes=CHECK,CHECK-BE,CHECK-BE-NOPT,CHECK-SOFT
+// RUN:FileCheck %s --check-prefixes=CHECK,CHECK-BE,CHECK-SOFT
 // RUN: %clang_cc1 -triple thumbv8m.main   -O2 -mcmse -S -emit-llvm %s -o - | \
 // RUN:FileCheck %s --check-prefixes=CHECK,CHECK-LE,CHECK-LE-OPT,CHECK-SOFT
 // RUN: %clang_cc1 -triple thumbebv8m.main -O2 -mcmse -S -emit-llvm %s -o - | \
Index: clang/test/CodeGen/catch-pointer-overflow.c
===
--- clang/test/CodeGen/catch-pointer-overflow.c
+++ clang/test/CodeGen/catch-pointer-overflow.c
@@ -1,9 +1,9 @@
-// RUN: %clang_cc1 -x c -emit-llvm %s -o - -triple x86_64-linux-gnu | FileCheck %s --check-prefixes=CHECK,CHECK-NOSANITIZE
+// RUN: %clang_cc1 -x c -emit-llvm %s -o - -triple x86_64-linux-gnu | FileCheck %s
 // RUN: %clang_cc1 -x c -fsanitize=pointer-overflow -fno-sanitize-recover=pointer-overflow -emit-llvm %s -o - -triple x86_64-linux-gnu | FileCheck %s -implicit-check-not="call void @__ubsan_handle_pointer_overflow" --check-prefixes=CHECK,CHECK-SANITIZE,CHECK-SANITIZE-C,CHECK-SANITIZE-ANYRECOVER,CHECK-SANITIZE-NORECOVER,CHECK-SANITIZE-UNREACHABLE
 // RUN: %clang_cc1 -x c -fsanitize=pointer-overflow -fsanitize-recover=pointer-overflow -emit-llvm %s -o - -triple x86_64-linux-gnu | FileCheck %s -implicit-check-not="call void @__ubsan_handle_pointer_overflow" --check-prefixes=CHECK,CHECK-SANITIZE,CHECK-SANITIZE-C,CHECK-SANITIZE-ANYRECOVER,CHECK-SANITIZE-RECOVER
 // RUN: %clang_cc1 -x c -fsanitize=pointer-overflow -fsanitize-trap=pointer-overflow -emit-llvm %s -o - -triple x86_64-linux-gnu | FileCheck %s -implicit-check-not="call void @__ubsan_handle_pointer_overflow" --check-prefixes=CHECK,CHECK-SANITIZE,CHECK-SANITIZE-C,CHECK-SANITIZE-TRAP,CHECK-SANITIZE-UNREACHABLE
 
-// RUN: %clang_cc1 -x c++ -emit-llvm %s -o - -triple x86_64-linux-gnu | FileCheck %s --check-prefixes=CHECK,CHECK-NOSANITIZE
+// RUN: %clang_cc1 -x c++ -emit-llvm %s -o - -triple x86_64-linux-gnu | FileCheck %s
 // RUN: %clang_cc1 -x c++ -fsanitize=pointer-overflow -fno-sanitize-recover=pointer-overflow -emit-llvm %s -o - -triple x86_64-linux-gnu | FileCheck %s -implicit-check-not="call void @__ubsan_handle_pointer_overflow" --check-prefixes=CHECK,CHECK-SANITIZE,CHECK-SANITIZE-CPP,CHECK-SANITIZE-ANYRECOVER,CHECK-SANITIZE-NORECOVER,CHECK-SANITIZE-UNREACHABLE
 // RUN: %clang_cc1 -x c++ 

[PATCH] D95448: [flang][driver] Add support for `-J/-module-dir`

2021-01-26 Thread Arnamoy B via Phabricator via cfe-commits
arnamoy10 created this revision.
arnamoy10 added reviewers: awarzynski, sscalpone, sameeranjoshi, SouraVX, 
tskeith, kiranktp, AMDChirag.
Herald added a subscriber: dang.
Herald added a reviewer: jansvoboda11.
arnamoy10 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Add support for option -J/-module-dir in the new Flang driver.
This will allow for including module files in other directories, as the default 
search path is currently the working folder.  This also provides an option of 
storing the output module in the specified folder.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D95448

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Flang.cpp
  flang/include/flang/Frontend/CompilerInstance.h
  flang/include/flang/Frontend/PreprocessorOptions.h
  flang/include/flang/Parser/parsing.h
  flang/lib/Frontend/CompilerInvocation.cpp
  flang/lib/Frontend/FrontendActions.cpp
  flang/test/Flang-Driver/driver-help-hidden.f90
  flang/test/Flang-Driver/driver-help.f90
  flang/test/Flang-Driver/include-module.f90

Index: flang/test/Flang-Driver/include-module.f90
===
--- flang/test/Flang-Driver/include-module.f90
+++ flang/test/Flang-Driver/include-module.f90
@@ -1,4 +1,4 @@
-! Ensure argument -I works as expected with module files.
+! Ensure argument -I, -J and -module-dir works as expected with module files.
 ! The module files for this test are not real module files.
 
 ! REQUIRES: new-flang-driver
@@ -8,12 +8,20 @@
 !--
 ! RUN: not %flang-new -fsyntax-only -I %S/Inputs -I %S/Inputs/module-dir %s  2>&1 | FileCheck %s --check-prefix=INCLUDED
 ! RUN: not %flang-new -fsyntax-only -I %S/Inputs %s  2>&1 | FileCheck %s --check-prefix=SINGLEINCLUDE
+! RUN: not %flang-new -fsyntax-only -J %S/Inputs -I %S/Inputs/module-dir %s  2>&1 | FileCheck %s --check-prefix=INCLUDED
+! RUN: not %flang-new -fsyntax-only -J %S/Inputs %s  2>&1 | FileCheck %s --check-prefix=SINGLEINCLUDE
+! RUN: not %flang-new -fsyntax-only -module-dir %S/Inputs -I %S/Inputs/module-dir %s  2>&1 | FileCheck %s --check-prefix=INCLUDED
+! RUN: not %flang-new -fsyntax-only -module-dir %S/Inputs %s  2>&1 | FileCheck %s --check-prefix=SINGLEINCLUDE
 
 !-
 ! FRONTEND FLANG DRIVER (flang-new -fc1)
 !-
 ! RUN: not %flang-new -fc1 -fsyntax-only -I %S/Inputs -I %S/Inputs/module-dir %s  2>&1 | FileCheck %s --check-prefix=INCLUDED
 ! RUN: not %flang-new -fc1 -fsyntax-only -I %S/Inputs %s  2>&1 | FileCheck %s --check-prefix=SINGLEINCLUDE
+! RUN: not %flang-new -fc1 -fsyntax-only -J %S/Inputs -I %S/Inputs/module-dir %s  2>&1 | FileCheck %s --check-prefix=INCLUDED
+! RUN: not %flang-new -fc1 -fsyntax-only -J %S/Inputs %s  2>&1 | FileCheck %s --check-prefix=SINGLEINCLUDE
+! RUN: not %flang-new -fc1 -fsyntax-only -module-dir %S/Inputs -I %S/Inputs/module-dir %s  2>&1 | FileCheck %s --check-prefix=INCLUDED
+! RUN: not %flang-new -fc1 -fsyntax-only -module-dir %S/Inputs %s  2>&1 | FileCheck %s --check-prefix=SINGLEINCLUDE
 
 !-
 ! EXPECTED OUTPUT FOR MISSING MODULE FILE
Index: flang/test/Flang-Driver/driver-help.f90
===
--- flang/test/Flang-Driver/driver-help.f90
+++ flang/test/Flang-Driver/driver-help.f90
@@ -26,6 +26,7 @@
 ! HELP-NEXT: -fno-color-diagnostics Disable colors in diagnostics
 ! HELP-NEXT: -help  Display available options
 ! HELP-NEXT: -IAdd directory to the end of the list of include search paths
+! HELP-NEXT: -module-dir  Add to the list of directories to be searched by an USE statement
 ! HELP-NEXT: -o   Write output to 
 ! HELP-NEXT: -U  Undefine macro 
 ! HELP-NEXT: --version  Print version information
@@ -41,6 +42,7 @@
 ! HELP-FC1-NEXT: -E Only run the preprocessor
 ! HELP-FC1-NEXT: -help  Display available options
 ! HELP-FC1-NEXT: -IAdd directory to the end of the list of include search paths
+! HELP-FC1-NEXT: -module-dir  Add to the list of directories to be searched by an USE statement
 ! HELP-FC1-NEXT: -o   Write output to 
 ! HELP-FC1-NEXT: -U  Undefine macro 
 ! HELP-FC1-NEXT: --version  Print version information
Index: flang/test/Flang-Driver/driver-help-hidden.f90
===
--- flang/test/Flang-Driver/driver-help-hidden.f90
+++ flang/test/Flang-Driver/driver-help-hidden.f90
@@ -26,6 +26,7 @@
 ! CHECK-NEXT: -fno-color-diagnostics Disable colors in diagnostics
 ! CHECK-NEXT: -help Display available options
 ! CHECK-NEXT: -IAdd directory to the end of the list of include search paths
+! CHECK-NEXT: -module-dir  Add to the list of directories to be 

[PATCH] D92808: [ObjC][ARC] Annotate calls with attributes instead of emitting retainRV or claimRV calls in the IR

2021-01-26 Thread Florian Hahn via Phabricator via cfe-commits
fhahn added inline comments.



Comment at: llvm/lib/IR/Instruction.cpp:580
+if (auto *CB = dyn_cast(this))
+  return objcarc::hasRetainRVOrClaimRVAttr(CB);
+return false;

ahatanak wrote:
> fhahn wrote:
> > rjmccall wrote:
> > > nikic wrote:
> > > > This change looks pretty fishy. Objective C shouldn't be hijacking 
> > > > LLVMs core instruction model in this way. If it writes to memory, this 
> > > > should either be reflected in the attributes, or modeled using operand 
> > > > bundles.
> > > > 
> > > > @fhahn Did you review these changes? If not, I'd suggest to revert this 
> > > > patch and get a review on the LLVM changes.
> > > This could definitely be an operand bundle, and I suppose the presence of 
> > > a bundle does force a conservative assumption on passes.
> > > @fhahn Did you review these changes? 
> > 
> > Nope I didn't have time to look at this so far.
> > 
> > 
> > 
> > Can functions marked as `readonly`/`readnone` be called with the objc 
> > attributes? 
> > 
> > I'm not very familiar with ObjC, but even for a function that just returns 
> > a passed in object id, don't we need to retain & release the object in the 
> > function? Which means the function cannot be `readonly` because we need to 
> > call `@llvm.objc*` functions? If that's the case, could we just check in 
> > the verifier that the attributes are never used with `readonly` functions?
> > 
> > If there are indeed cases where we can call `readonly` functions, operand 
> > bundles would probably be safest. It would probably also good to have at 
> > least a few alias-analysis tests, to make sure things work as expected.
> A function compiled using ARC can call a function compiled using MRR, which 
> can be readonly/readnone. Also, a function compiled using ARC can be marked 
> as readonly/readnone (if an optimization pass wants to do so) after ARC 
> optimizer removes the retainRV/autoreleaseRV pair.
> 
> ```
> define i8* @foo() {
>   %1 = tail call i8* @readonlyMRRFunc()
>   ; This function can be readonly if ARC optimizer removes the following two 
> instructions.
>   %2 = call i8* @llvm.objc.retainAutoreleasedReturnValue(i8* %1)
>   %3 = tail call i8* @llvm.objc.autoreleaseReturnValue(i8* %2)
>   ret i8* 
> }
> ```
> A function compiled using ARC can call a function compiled using MRR, which 
> can be readonly/readnone

Ok, sounds like a bundle would be a good option then?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92808

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


[PATCH] D92808: [ObjC][ARC] Annotate calls with attributes instead of emitting retainRV or claimRV calls in the IR

2021-01-26 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak added inline comments.



Comment at: llvm/lib/IR/Instruction.cpp:580
+if (auto *CB = dyn_cast(this))
+  return objcarc::hasRetainRVOrClaimRVAttr(CB);
+return false;

fhahn wrote:
> rjmccall wrote:
> > nikic wrote:
> > > This change looks pretty fishy. Objective C shouldn't be hijacking LLVMs 
> > > core instruction model in this way. If it writes to memory, this should 
> > > either be reflected in the attributes, or modeled using operand bundles.
> > > 
> > > @fhahn Did you review these changes? If not, I'd suggest to revert this 
> > > patch and get a review on the LLVM changes.
> > This could definitely be an operand bundle, and I suppose the presence of a 
> > bundle does force a conservative assumption on passes.
> > @fhahn Did you review these changes? 
> 
> Nope I didn't have time to look at this so far.
> 
> 
> 
> Can functions marked as `readonly`/`readnone` be called with the objc 
> attributes? 
> 
> I'm not very familiar with ObjC, but even for a function that just returns a 
> passed in object id, don't we need to retain & release the object in the 
> function? Which means the function cannot be `readonly` because we need to 
> call `@llvm.objc*` functions? If that's the case, could we just check in the 
> verifier that the attributes are never used with `readonly` functions?
> 
> If there are indeed cases where we can call `readonly` functions, operand 
> bundles would probably be safest. It would probably also good to have at 
> least a few alias-analysis tests, to make sure things work as expected.
A function compiled using ARC can call a function compiled using MRR, which can 
be readonly/readnone. Also, a function compiled using ARC can be marked as 
readonly/readnone (if an optimization pass wants to do so) after ARC optimizer 
removes the retainRV/autoreleaseRV pair.

```
define i8* @foo() {
  %1 = tail call i8* @readonlyMRRFunc()
  ; This function can be readonly if ARC optimizer removes the following two 
instructions.
  %2 = call i8* @llvm.objc.retainAutoreleasedReturnValue(i8* %1)
  %3 = tail call i8* @llvm.objc.autoreleaseReturnValue(i8* %2)
  ret i8* 
}
```



Comment at: llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp:576
+// Don't change the return type of the function if it has retainRV/claimRV.
+if (objcarc::hasRetainRVOrClaimRVAttr(CB)) {
+  NumLiveRetVals = RetCount;

fhahn wrote:
> This seems fragile. IIUC this workaround is needed because the return value 
> of a `retainRV/claimRV` function always has one implicit use. This aspect 
> could get missed in other places as well.
> 
> As an alternative, could the frontend insert 'dummy' uses (e.g. 
> `llvm.objc.arc.use`) to make this assumption transparent? Those could be 
> removed sufficiently late. Their placement doesn't really matter and neither 
> does if any instructions are moved between the original call and the dummy 
> use, but the fact that the returned value is used is now explicit. IICU they 
> could be marked as accessing inaccessible memory only, so they should be too 
> much trouble for other optimizations (at least not more than the previous 
> explicit release calls). Or perhaps there's a different way to mark the 
> return value as used explicitly.
> 
I think we can make the front-end insert a dummy use instruction. The front-end 
currently emits `@llvm.objc.clang.arc.use` in some cases to make sure the 
object doesn't get released too early, but we can't use that in this case since 
ARC optimizer treats a call to `@llvm.objc.clang.arc.use` as a real use, so we 
probably need a new intrinsic.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92808

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


[PATCH] D82862: [ThinLTO] Always parse module level inline asm with At dialect

2021-01-26 Thread Ulrich Weigand via Phabricator via cfe-commits
uweigand added a comment.

In D82862#2513044 , @rnk wrote:

> In D82862#2512908 , @uweigand wrote:
>
>> So why do you want GNU inline asm for clang-cl anyway?   I thought the whole 
>> point of clang-cl was to be compatible with the Microsoft Visual Studio 
>> compiler, which I understand only supports the MS asm syntax?
>
> We have users, in this case, I think it's V8, who would prefer to use 
> gcc-style module level assembly if it is available. Their motivation is 
> somewhat arbitrary, but generally, clang-cl supports a variety of extensions, 
> some inherited from GCC, in all modes. Part of the point of switching 
> compilers from MSVC to clang is to get access to those extensions.

I see, thanks.   I think what would make sense to preserve existing behavior 
while still allowing other platforms to use different dialects for GNU inline 
asm would be to move the decision which dialect to use for inline asm to the 
back-end.  I've posted a patch along those lines as 
https://reviews.llvm.org/D95444 - I hope we can continue the discussion there.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82862

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


[PATCH] D95442: [OpenCL] Add diagnostics for references to functions

2021-01-26 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia created this revision.
Anastasia added a reviewer: mantognini.
Herald added subscribers: ebevhan, yaxunl.
Anastasia requested review of this revision.

References to functions are less permissive than pointers to functions and 
therefore some use cases could be allowed for example:

- For local variables
- For non-extern static and global variables
- For template parameters that are not used as function parameters or class 
members
- In constexpr

However, more language work is needed to analyze the invalid/valid cases. This 
can be done in the future language versions if there is enough interest in the 
feature from the application developers. Even if we had  a request for allowing 
some function pointer functionality (PR44788), OpenCL has never adopted the 
feature as a part of the standard and therefore many applications have been 
written successfully without it. On the other hand C++ provides other related 
features - lambdas and function objects that are allowed in OpenCL and can be 
used to express some sort of the indirect function call logic. For now it seems 
reasonable to just disallow the references to functions just like we disallow 
function pointers. This prevents erroneous programs from being compiled 
silently.

Note that for the advanced users there is the following extension available 
`__cl_clang_function_pointers` that can be used if there is knowledge about the 
application sources or compilation options to make sure the non-conformant 
functionality is safe (more details are in 
https://clang.llvm.org/docs/LanguageExtensions.html#opencl-features).


https://reviews.llvm.org/D95442

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaType.cpp
  clang/test/SemaOpenCLCXX/references.cl


Index: clang/test/SemaOpenCLCXX/references.cl
===
--- /dev/null
+++ clang/test/SemaOpenCLCXX/references.cl
@@ -0,0 +1,43 @@
+//RUN: %clang_cc1 %s -cl-std=clc++ -verify -fsyntax-only
+//RUN: %clang_cc1 %s -cl-std=clc++ -verify -fsyntax-only -DFPTREXT
+
+#ifdef FPTREXT
+#pragma OPENCL EXTENSION __cl_clang_function_pointers : enable
+#endif // FPTREXT
+
+// References to functions are not allowed.
+struct myclass {
+  void ()();
+//FIXME: Here we provide incorrect diagnostic.
+#ifndef FPTREXT
+//expected-error@-3{{reference to function type cannot have '__generic' 
qualifier}}
+#endif // FPTREXT
+};
+
+void ()();
+#ifndef FPTREXT
+//expected-error@-2{{references to functions are not allowed}}
+//expected-error@-3{{declaration of reference variable 'glob' requires an 
initializer}}
+#endif // FPTREXT
+template 
+void templ() {
+  // FIXME: We miss to diagnose the reference to function.
+  T loc; //expected-error{{declaration of reference variable 'loc' requires an 
initializer}}
+}
+
+void foo();
+void test(void ()()) {
+  void ()();
+#ifndef FPTREXT
+//expected-error@-2{{references to functions are not allowed}}
+//expected-error@-3{{declaration of reference variable 'loc' requires an 
initializer}}
+#endif // FPTREXT
+
+  void (*)();
+#ifndef FPTREXT
+//expected-error@-2{{pointers to functions are not allowed}}
+//expected-error@-3{{declaration of reference variable 'ref2fptr' requires an 
initializer}}
+#endif // FPTREXT
+
+  templ(); //expected-note{{in instantiation of function template 
specialization}}
+}
Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -2091,7 +2091,7 @@
 
   if (T->isFunctionType() && getLangOpts().OpenCL &&
   !getOpenCLOptions().isEnabled("__cl_clang_function_pointers")) {
-Diag(Loc, diag::err_opencl_function_pointer);
+Diag(Loc, diag::err_opencl_function_pointer) << /*pointer*/ 0;
 return QualType();
   }
 
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -6752,9 +6752,12 @@
   // OpenCL v1.0 s6.8.a.3: Pointers to functions are not allowed.
   if (!Se.getOpenCLOptions().isEnabled("__cl_clang_function_pointers")) {
 QualType NR = R;
-while (NR->isPointerType() || NR->isMemberFunctionPointerType()) {
-  if (NR->isFunctionPointerType() || NR->isMemberFunctionPointerType()) {
-Se.Diag(D.getIdentifierLoc(), diag::err_opencl_function_pointer);
+while (NR->isPointerType() || NR->isMemberFunctionPointerType() ||
+   NR->isReferenceType()) {
+  if (NR->isFunctionPointerType() || NR->isMemberFunctionPointerType() ||
+  NR->isFunctionReferenceType()) {
+Se.Diag(D.getIdentifierLoc(), diag::err_opencl_function_pointer)
+<< NR->isReferenceType();
 D.setInvalidType();
 return false;
   }
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- 

[PATCH] D95307: [StaticAnalyzer] Add checking for degenerate base class in MemRegion

2021-01-26 Thread Deep Majumder via Phabricator via cfe-commits
RedDocMD added a comment.

On further digging as to how pointer-to-members are handled in StaticAnalyzer, 
I discovered that in `BasicValueFactory::accumCXXBase() for the example given 
in my test produces the two `CXXBaseSpecifier` for the pointer-to-member. At 
line 195, one base specifier is added while the other is added in the loop in 
201. The loop accounts for the static_cast while line 195 adds a base specifier 
from the expression being cast. 
This causes the duplication. I will try to update this patch to handle the 
duplication.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95307

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


[PATCH] D94466: [X86] merge "={eax}" and "~{eax}" into "=" for MSInlineASM

2021-01-26 Thread Freddy, Ye via Phabricator via cfe-commits
FreddyYe updated this revision to Diff 319284.
FreddyYe added a comment.

refine clang-format


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94466

Files:
  clang/lib/CodeGen/CGStmt.cpp
  clang/test/CodeGen/ms-inline-asm.c
  clang/test/CodeGenCXX/ms-inline-asm-return.cpp

Index: clang/test/CodeGenCXX/ms-inline-asm-return.cpp
===
--- clang/test/CodeGenCXX/ms-inline-asm-return.cpp
+++ clang/test/CodeGenCXX/ms-inline-asm-return.cpp
@@ -13,7 +13,17 @@
   }
 }
 // CHECK-LABEL: define dso_local i64 @f_i64()
-// CHECK: %[[r:[^ ]*]] = call i64 asm sideeffect inteldialect "mov eax, $$1\0A\09mov edx, $$1", "=A,~{eax},{{.*}}"
+// CHECK: %[[r:[^ ]*]] = call i64 asm sideeffect inteldialect "mov eax, $$1\0A\09mov edx, $$1", "=,{{.*}}"
+// CHECK: ret i64 %[[r]]
+
+long long f_i64_reverse() {
+  __asm {
+mov edx, 1
+mov eax, 1
+  }
+}
+// CHECK-LABEL: define dso_local i64 @f_i64_reverse()
+// CHECK: %[[r:[^ ]*]] = call i64 asm sideeffect inteldialect "mov edx, $$1\0A\09mov eax, $$1", "=,{{.*}}"
 // CHECK: ret i64 %[[r]]
 
 int f_i32() {
@@ -23,7 +33,26 @@
   }
 }
 // CHECK-LABEL: define dso_local i32 @f_i32()
-// CHECK: %[[r:[^ ]*]] = call i32 asm sideeffect inteldialect "mov eax, $$1\0A\09mov edx, $$1", "={eax},~{eax},{{.*}}"
+// CHECK: %[[r:[^ ]*]] = call i32 asm sideeffect inteldialect "mov eax, $$1\0A\09mov edx, $$1", "=&{eax},~{edx},{{.*}}"
+// CHECK: ret i32 %[[r]]
+
+int f_i32_reverse() {
+  __asm {
+mov edx, 1
+mov eax, 1
+  }
+}
+// CHECK-LABEL: define dso_local i32 @f_i32_reverse()
+// CHECK: %[[r:[^ ]*]] = call i32 asm sideeffect inteldialect "mov edx, $$1\0A\09mov eax, $$1", "=&{eax},~{edx},{{.*}}"
+// CHECK: ret i32 %[[r]]
+
+int f_i32_edx() {
+  __asm {
+mov edx, 1
+  }
+}
+// CHECK-LABEL: define dso_local i32 @f_i32_edx()
+// CHECK: %[[r:[^ ]*]] = call i32 asm sideeffect inteldialect "mov edx, $$1", "={eax},~{edx},{{.*}}"
 // CHECK: ret i32 %[[r]]
 
 short f_i16() {
@@ -33,7 +62,7 @@
   }
 }
 // CHECK-LABEL: define dso_local signext i16 @f_i16()
-// CHECK: %[[r:[^ ]*]] = call i32 asm sideeffect inteldialect "mov eax, $$1\0A\09mov edx, $$1", "={eax},~{eax},{{.*}}"
+// CHECK: %[[r:[^ ]*]] = call i32 asm sideeffect inteldialect "mov eax, $$1\0A\09mov edx, $$1", "=&{eax},~{edx},{{.*}}"
 // CHECK: %[[r_i16:[^ ]*]] = trunc i32 %[[r]] to i16
 // CHECK: ret i16 %[[r_i16]]
 
@@ -44,7 +73,7 @@
   }
 }
 // CHECK-LABEL: define dso_local signext i8 @f_i8()
-// CHECK: %[[r:[^ ]*]] = call i32 asm sideeffect inteldialect "mov eax, $$1\0A\09mov edx, $$1", "={eax},~{eax},{{.*}}"
+// CHECK: %[[r:[^ ]*]] = call i32 asm sideeffect inteldialect "mov eax, $$1\0A\09mov edx, $$1", "=&{eax},~{edx},{{.*}}"
 // CHECK: %[[r_i8:[^ ]*]] = trunc i32 %[[r]] to i8
 // CHECK: ret i8 %[[r_i8]]
 
@@ -55,7 +84,7 @@
   }
 }
 // CHECK-LABEL: define dso_local zeroext i1 @f_i1()
-// CHECK: %[[r:[^ ]*]] = call i32 asm sideeffect inteldialect "mov eax, $$1\0A\09mov edx, $$1", "={eax},~{eax},{{.*}}"
+// CHECK: %[[r:[^ ]*]] = call i32 asm sideeffect inteldialect "mov eax, $$1\0A\09mov edx, $$1", "=&{eax},~{edx},{{.*}}"
 // CHECK: %[[r_i8:[^ ]*]] = trunc i32 %[[r]] to i8
 // CHECK: store i8 %[[r_i8]], i8* %{{.*}}
 // CHECK: %[[r_i1:[^ ]*]] = load i1, i1* %{{.*}}
@@ -70,7 +99,7 @@
   }
 }
 // CHECK-LABEL: define dso_local i32 @f_s4()
-// CHECK: %[[r:[^ ]*]] = call i32 asm sideeffect inteldialect "mov eax, $$16843009", "={eax},~{eax},{{.*}}"
+// CHECK: %[[r:[^ ]*]] = call i32 asm sideeffect inteldialect "mov eax, $$16843009", "=&{eax},{{.*}}"
 // CHECK: store i32 %[[r]], i32* %{{.*}}
 // CHECK: %[[r_i32:[^ ]*]] = load i32, i32* %{{.*}}
 // CHECK: ret i32 %[[r_i32]]
@@ -85,7 +114,7 @@
   }
 }
 // CHECK-LABEL: define dso_local i64 @f_s8()
-// CHECK: %[[r:[^ ]*]] = call i64 asm sideeffect inteldialect "mov eax, $$16843009\0A\09mov edx, $$85", "=A,~{eax},{{.*}}"
+// CHECK: %[[r:[^ ]*]] = call i64 asm sideeffect inteldialect "mov eax, $$16843009\0A\09mov edx, $$85", "=,{{.*}}"
 // CHECK: store i64 %[[r]], i64* %{{.*}}
 // CHECK: %[[r_i64:[^ ]*]] = load i64, i64* %{{.*}}
 // CHECK: ret i64 %[[r_i64]]
@@ -96,5 +125,5 @@
   __asm xor eax, eax
 }
 // CHECK-LABEL: define dso_local i32 @main()
-// CHECK: %[[r:[^ ]*]] = call i32 asm sideeffect inteldialect "xor eax, eax", "={eax},{{.*}}"
+// CHECK: %[[r:[^ ]*]] = call i32 asm sideeffect inteldialect "xor eax, eax", "=&{eax},{{.*}}"
 // CHECK: ret i32 %[[r]]
Index: clang/test/CodeGen/ms-inline-asm.c
===
--- clang/test/CodeGen/ms-inline-asm.c
+++ clang/test/CodeGen/ms-inline-asm.c
@@ -114,7 +114,7 @@
 // CHECK: call i32 asm sideeffect inteldialect
 // CHECK-SAME: mov eax, $2
 // CHECK-SAME: mov $0, eax
-// CHECK-SAME: "=*m,={eax},*m,~{eax},~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}}, i32* %{{.*}})
+// CHECK-SAME: "=*m,=&{eax},*m,~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}}, i32* %{{.*}})
 // 

[PATCH] D94466: [X86] merge "={eax}" and "~{eax}" into "=" for MSInlineASM

2021-01-26 Thread Freddy, Ye via Phabricator via cfe-commits
FreddyYe updated this revision to Diff 319282.
FreddyYe added a comment.

If Clobber is edx only, don't change "={eax}" to "=&{eax}".


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94466

Files:
  clang/lib/CodeGen/CGStmt.cpp
  clang/test/CodeGen/ms-inline-asm.c
  clang/test/CodeGenCXX/ms-inline-asm-return.cpp

Index: clang/test/CodeGenCXX/ms-inline-asm-return.cpp
===
--- clang/test/CodeGenCXX/ms-inline-asm-return.cpp
+++ clang/test/CodeGenCXX/ms-inline-asm-return.cpp
@@ -13,7 +13,17 @@
   }
 }
 // CHECK-LABEL: define dso_local i64 @f_i64()
-// CHECK: %[[r:[^ ]*]] = call i64 asm sideeffect inteldialect "mov eax, $$1\0A\09mov edx, $$1", "=A,~{eax},{{.*}}"
+// CHECK: %[[r:[^ ]*]] = call i64 asm sideeffect inteldialect "mov eax, $$1\0A\09mov edx, $$1", "=,{{.*}}"
+// CHECK: ret i64 %[[r]]
+
+long long f_i64_reverse() {
+  __asm {
+mov edx, 1
+mov eax, 1
+  }
+}
+// CHECK-LABEL: define dso_local i64 @f_i64_reverse()
+// CHECK: %[[r:[^ ]*]] = call i64 asm sideeffect inteldialect "mov edx, $$1\0A\09mov eax, $$1", "=,{{.*}}"
 // CHECK: ret i64 %[[r]]
 
 int f_i32() {
@@ -23,7 +33,26 @@
   }
 }
 // CHECK-LABEL: define dso_local i32 @f_i32()
-// CHECK: %[[r:[^ ]*]] = call i32 asm sideeffect inteldialect "mov eax, $$1\0A\09mov edx, $$1", "={eax},~{eax},{{.*}}"
+// CHECK: %[[r:[^ ]*]] = call i32 asm sideeffect inteldialect "mov eax, $$1\0A\09mov edx, $$1", "=&{eax},~{edx},{{.*}}"
+// CHECK: ret i32 %[[r]]
+
+int f_i32_reverse() {
+  __asm {
+mov edx, 1
+mov eax, 1
+  }
+}
+// CHECK-LABEL: define dso_local i32 @f_i32_reverse()
+// CHECK: %[[r:[^ ]*]] = call i32 asm sideeffect inteldialect "mov edx, $$1\0A\09mov eax, $$1", "=&{eax},~{edx},{{.*}}"
+// CHECK: ret i32 %[[r]]
+
+int f_i32_edx() {
+  __asm {
+mov edx, 1
+  }
+}
+// CHECK-LABEL: define dso_local i32 @f_i32_edx()
+// CHECK: %[[r:[^ ]*]] = call i32 asm sideeffect inteldialect "mov edx, $$1", "={eax},~{edx},{{.*}}"
 // CHECK: ret i32 %[[r]]
 
 short f_i16() {
@@ -33,7 +62,7 @@
   }
 }
 // CHECK-LABEL: define dso_local signext i16 @f_i16()
-// CHECK: %[[r:[^ ]*]] = call i32 asm sideeffect inteldialect "mov eax, $$1\0A\09mov edx, $$1", "={eax},~{eax},{{.*}}"
+// CHECK: %[[r:[^ ]*]] = call i32 asm sideeffect inteldialect "mov eax, $$1\0A\09mov edx, $$1", "=&{eax},~{edx},{{.*}}"
 // CHECK: %[[r_i16:[^ ]*]] = trunc i32 %[[r]] to i16
 // CHECK: ret i16 %[[r_i16]]
 
@@ -44,7 +73,7 @@
   }
 }
 // CHECK-LABEL: define dso_local signext i8 @f_i8()
-// CHECK: %[[r:[^ ]*]] = call i32 asm sideeffect inteldialect "mov eax, $$1\0A\09mov edx, $$1", "={eax},~{eax},{{.*}}"
+// CHECK: %[[r:[^ ]*]] = call i32 asm sideeffect inteldialect "mov eax, $$1\0A\09mov edx, $$1", "=&{eax},~{edx},{{.*}}"
 // CHECK: %[[r_i8:[^ ]*]] = trunc i32 %[[r]] to i8
 // CHECK: ret i8 %[[r_i8]]
 
@@ -55,7 +84,7 @@
   }
 }
 // CHECK-LABEL: define dso_local zeroext i1 @f_i1()
-// CHECK: %[[r:[^ ]*]] = call i32 asm sideeffect inteldialect "mov eax, $$1\0A\09mov edx, $$1", "={eax},~{eax},{{.*}}"
+// CHECK: %[[r:[^ ]*]] = call i32 asm sideeffect inteldialect "mov eax, $$1\0A\09mov edx, $$1", "=&{eax},~{edx},{{.*}}"
 // CHECK: %[[r_i8:[^ ]*]] = trunc i32 %[[r]] to i8
 // CHECK: store i8 %[[r_i8]], i8* %{{.*}}
 // CHECK: %[[r_i1:[^ ]*]] = load i1, i1* %{{.*}}
@@ -70,7 +99,7 @@
   }
 }
 // CHECK-LABEL: define dso_local i32 @f_s4()
-// CHECK: %[[r:[^ ]*]] = call i32 asm sideeffect inteldialect "mov eax, $$16843009", "={eax},~{eax},{{.*}}"
+// CHECK: %[[r:[^ ]*]] = call i32 asm sideeffect inteldialect "mov eax, $$16843009", "=&{eax},{{.*}}"
 // CHECK: store i32 %[[r]], i32* %{{.*}}
 // CHECK: %[[r_i32:[^ ]*]] = load i32, i32* %{{.*}}
 // CHECK: ret i32 %[[r_i32]]
@@ -85,7 +114,7 @@
   }
 }
 // CHECK-LABEL: define dso_local i64 @f_s8()
-// CHECK: %[[r:[^ ]*]] = call i64 asm sideeffect inteldialect "mov eax, $$16843009\0A\09mov edx, $$85", "=A,~{eax},{{.*}}"
+// CHECK: %[[r:[^ ]*]] = call i64 asm sideeffect inteldialect "mov eax, $$16843009\0A\09mov edx, $$85", "=,{{.*}}"
 // CHECK: store i64 %[[r]], i64* %{{.*}}
 // CHECK: %[[r_i64:[^ ]*]] = load i64, i64* %{{.*}}
 // CHECK: ret i64 %[[r_i64]]
@@ -96,5 +125,5 @@
   __asm xor eax, eax
 }
 // CHECK-LABEL: define dso_local i32 @main()
-// CHECK: %[[r:[^ ]*]] = call i32 asm sideeffect inteldialect "xor eax, eax", "={eax},{{.*}}"
+// CHECK: %[[r:[^ ]*]] = call i32 asm sideeffect inteldialect "xor eax, eax", "=&{eax},{{.*}}"
 // CHECK: ret i32 %[[r]]
Index: clang/test/CodeGen/ms-inline-asm.c
===
--- clang/test/CodeGen/ms-inline-asm.c
+++ clang/test/CodeGen/ms-inline-asm.c
@@ -114,7 +114,7 @@
 // CHECK: call i32 asm sideeffect inteldialect
 // CHECK-SAME: mov eax, $2
 // CHECK-SAME: mov $0, eax
-// CHECK-SAME: "=*m,={eax},*m,~{eax},~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}}, i32* %{{.*}})
+// CHECK-SAME: 

[PATCH] D94865: [ASTMatchers] Add callOrConstruct matcher

2021-01-26 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

Pinging the reviewers to help with the naming questions.




Comment at: clang/include/clang/ASTMatchers/ASTMatchers.h:2867
+extern const internal::MapAnyOfMatcher
+callOrConstruct;
+

steveire wrote:
> aaron.ballman wrote:
> > steveire wrote:
> > > aaron.ballman wrote:
> > > > I'm not super keen on this name. It's certainly descriptive, but I do 
> > > > wonder if it's a bit too specific and should perhaps be something more 
> > > > like `callableExpr()`, `callLikeExpr()`, or something more generic. For 
> > > > instance, I could imagine wanting this to match on something like:
> > > > ```
> > > > struct S {
> > > >   void setter(int val) {}
> > > >   __declspec(property(put = setter)) int x;
> > > > };
> > > > 
> > > > int main() {
> > > >   S s;
> > > >   s.x = 12; // Match here
> > > >   // Because the above code actually does this:
> > > >   // s.setter(12);
> > > > }
> > > > ```
> > > > because this also has an expression that isn't really a call (as far as 
> > > > our AST is concerned) but is a call as far as program semantics are 
> > > > concerned. I'm not suggesting to make the matcher support that right 
> > > > now (unless you felt like doing it), but thinking about the future and 
> > > > avoiding a name that may paint us into a corner.
> > > > 
> > > > WDYT about using a more generic name?
> > > I haven't seen code like that before (ms extension?) 
> > > https://godbolt.org/z/anvd43 but I think that should be matched by 
> > > `binaryOperator` instead. That already matches based on what the code 
> > > looks like, rather than what it is in the AST.
> > > 
> > > This `callOrConstruct` is really for using `hasArgument` and related 
> > > submatchers with nodes which support it. As such I think the name is 
> > > fine. I don't like `callableExpr` or `callLikeExpr` because they don't 
> > > bring to mind the possibility that construction is also supported.
> > > I haven't seen code like that before (ms extension?)
> > 
> > Yes, it's an MS extension.
> > 
> > > That already matches based on what the code looks like, rather than what 
> > > it is in the AST.
> > 
> > Yes, but these are AST matchers, so it's reasonable to match on what's in 
> > the AST (as well as what the code looks like, of course). I'm not arguing 
> > it needs to be supported so much as pointing out that there are other AST 
> > nodes this notionally applies to where the name is a bit too specific.
> > 
> > > This callOrConstruct is really for using hasArgument and related 
> > > submatchers with nodes which support it. As such I think the name is 
> > > fine. I don't like callableExpr or callLikeExpr because they don't bring 
> > > to mind the possibility that construction is also supported.
> > 
> > I'm pretty sure we've extended what `hasArgument` can be applied to in the 
> > past (but I've not verified), so the part that worries me is specifically 
> > naming the nodes as part of the identifier. This effectively means that if 
> > we ever find another AST node for `hasArgument`, we either need a different 
> > API like `callConstructOrWhatever` or we're stuck with a poor name.
> > 
> > Another (smaller) concern with the name is that `callOrConstruct` can 
> > describe declarations as well as expressions, to some degree as you can 
> > declare calls and constructors. It's a smaller concern because those at 
> > least share a common base class. `callOrConstructExpr` would clarify this 
> > easily enough.
> > 
> > I see you added `ObjCMessageExpr` as well, thank you for that! It's a 
> > perhaps better example of why this name feels awkward to me. In ObjC, you 
> > don't call an `ObjCMessageExpr`, you "send" it to the given object or 
> > class. That suggests to me that `callableExpr` or `callLikeExpr` is also 
> > not a great name either.
> > 
> > Perhaps `executableExpr` because you're executing some code?
> > Perhaps `executableExpr` because you're executing some code?
> 
> The thing that this really does is make it possible to use `hasArgument` and 
> related matchers with the nodes that that matcher supports. So, something 
> with `argument` in the name probably makes sense. Like `argumentExpr`. 
> 
> The thing that this really does is make it possible to use hasArgument and 
> related matchers with the nodes that that matcher supports. So, something 
> with argument in the name probably makes sense. Like argumentExpr.

A name like `argumentExpr()` would make me think we're trying to match the `42` 
in an expression like `foo(42)` (e.g., it makes me think we're going to match 
on expressions that are arguments to a call).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94865

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


[PATCH] D95246: [SystemZ][z/OS] Fix No such file or directory expression error matching in lit tests - continued

2021-01-26 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan requested review of this revision.
abhina.sreeskantharajan marked 4 inline comments as done.
abhina.sreeskantharajan added inline comments.



Comment at: llvm/utils/lit/lit/llvm/config.py:349-354
+if (re.match(r's390x-.*-zos', triple)):
+
self.config.substitutions.append(('%err_no_such_file_or_directory', '\'EDC5129I 
No such file or directory.\''))
+elif (re.match(r'.*windows.*', triple)):
+
self.config.substitutions.append(('%err_no_such_file_or_directory', '\'no such 
file or directory\''))
+else:
+
self.config.substitutions.append(('%err_no_such_file_or_directory', '\'No such 
file or directory\''))

jhenderson wrote:
> These lines are quite long, so probably want reflowing.
> 
> I wonder if `%errc_...` might be a better name? That way, it ties to the 
> `std::errc` values these match up with.
Thanks, I've changed the error messages to your suggestion.



Comment at: llvm/utils/lit/lit/llvm/config.py:369-370
 
+if hasattr(self.config, 'host_triple'):
+   self.add_err_msg_substitutions(self.config.host_triple) 
+

jhenderson wrote:
> Under what conditions can there not be a `host_triple`? In those cases, what 
> happens to the tests that use the new substitution?
This was not defined for lld. I added changes to define this for lld and 
removed the check. I think this is defined in all the other projects.


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: [SystemZ][z/OS] Fix No such file or directory expression error matching in lit tests - continued

2021-01-26 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan updated this revision to Diff 319276.
abhina.sreeskantharajan added a comment.
Herald added subscribers: mgorny, emaste.

This patch makes the following changes:

- Define LLVM_HOST_TRIPLE for lld tests. (This was the project that didn't have 
host defined.)
- Change %err_no_such_file_or_directory to %errc_ENOENT as suggested by 
jhenderson

I've also created a post on llvm-dev about this patch: 
https://lists.llvm.org/pipermail/llvm-dev/2021-January/148089.html


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95246

Files:
  clang/test/Driver/clang-offload-bundler.c
  clang/test/Frontend/output-failures.c
  clang/test/Frontend/stats-file.c
  lld/CMakeLists.txt
  lld/test/ELF/basic.s
  lld/test/lit.site.cfg.py.in
  llvm/test/Object/archive-extract.test
  llvm/test/tools/llvm-ar/move.test
  llvm/utils/lit/lit/llvm/config.py

Index: llvm/utils/lit/lit/llvm/config.py
===
--- llvm/utils/lit/lit/llvm/config.py
+++ llvm/utils/lit/lit/llvm/config.py
@@ -345,6 +345,14 @@
 self.config.substitutions.extend(substitutions)
 return True
 
+def add_err_msg_substitutions(self, triple):
+if (re.match(r's390x-.*-zos', triple)):
+self.config.substitutions.append(('%errc_ENOENT', '\'EDC5129I No such file or directory.\''))
+elif (re.match(r'.*windows.*', triple)):
+self.config.substitutions.append(('%errc_ENOENT', '\'no such file or directory\''))
+else:
+self.config.substitutions.append(('%errc_ENOENT', '\'No such file or directory\''))
+
 def use_default_substitutions(self):
 tool_patterns = [
 ToolSubst('FileCheck', unresolved='fatal'),
@@ -358,6 +366,8 @@
 self.add_tool_substitutions(
 tool_patterns, [self.config.llvm_tools_dir])
 
+self.add_err_msg_substitutions(self.config.host_triple)
+
 def use_llvm_tool(self, name, search_env=None, required=False, quiet=False):
 """Find the executable program 'name', optionally using the specified
 environment variable as an override before searching the
Index: llvm/test/tools/llvm-ar/move.test
===
--- llvm/test/tools/llvm-ar/move.test
+++ llvm/test/tools/llvm-ar/move.test
@@ -82,9 +82,9 @@
 ## Member does not exist:
 # RUN: llvm-ar rc %t/missing.a %t/1.o %t/2.o %t/3.o
 # RUN: not llvm-ar m %t/missing.a %t/missing.txt 2>&1 \
-# RUN:   | FileCheck %s --check-prefix=MISSING-FILE -DFILE=%t/missing.txt
+# RUN:   | FileCheck %s --check-prefix=MISSING-FILE -DFILE=%t/missing.txt -DMSG=%errc_ENOENT
 
-# MISSING-FILE: error: [[FILE]]: {{[nN]}}o such file or directory
+# MISSING-FILE: error: [[FILE]]: [[MSG]]
 
 --- !ELF
 FileHeader:
Index: llvm/test/Object/archive-extract.test
===
--- llvm/test/Object/archive-extract.test
+++ llvm/test/Object/archive-extract.test
@@ -57,5 +57,5 @@
 RUN: llvm-ar p %p/Inputs/thin.a evenlen | FileCheck %s --check-prefix=EVENLEN
 EVENLEN: evenlen
 
-RUN: not llvm-ar p %p/Inputs/thin-path.a t/test2.o 2>&1 | FileCheck %s --check-prefix=MISSING
-MISSING: error: {{N|n}}o such file or directory
+RUN: not llvm-ar p %p/Inputs/thin-path.a t/test2.o 2>&1 | FileCheck %s --DMSG=%errc_ENOENT --check-prefix=MISSING
+MISSING: error: [[MSG]]
Index: lld/test/lit.site.cfg.py.in
===
--- lld/test/lit.site.cfg.py.in
+++ lld/test/lit.site.cfg.py.in
@@ -11,6 +11,7 @@
 config.lld_obj_root = "@LLD_BINARY_DIR@"
 config.lld_libs_dir = "@LLVM_LIBRARY_OUTPUT_INTDIR@"
 config.lld_tools_dir = "@LLVM_RUNTIME_OUTPUT_INTDIR@"
+config.host_triple = "@LLVM_HOST_TRIPLE@"
 config.target_triple = "@TARGET_TRIPLE@"
 config.python_executable = "@Python3_EXECUTABLE@"
 config.have_zlib = @LLVM_ENABLE_ZLIB@
Index: lld/test/ELF/basic.s
===
--- lld/test/ELF/basic.s
+++ lld/test/ELF/basic.s
@@ -219,8 +219,8 @@
 # INVRSP: invalid response file quoting: patatino
 
 # RUN: not ld.lld %t.foo -o /dev/null 2>&1 | \
-# RUN:  FileCheck --check-prefix=MISSING %s
-# MISSING: cannot open {{.*}}.foo: {{[Nn]}}o such file or directory
+# RUN:  FileCheck -DMSG=%errc_ENOENT --check-prefix=MISSING %s
+# MISSING: cannot open {{.*}}.foo: [[MSG]]
 
 # RUN: not ld.lld -o /dev/null 2>&1 | \
 # RUN:  FileCheck --check-prefix=NO_INPUT %s
Index: lld/CMakeLists.txt
===
--- lld/CMakeLists.txt
+++ lld/CMakeLists.txt
@@ -111,6 +111,10 @@
 set(LLD_INCLUDE_DIR ${LLD_SOURCE_DIR}/include )
 set(LLD_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
 
+if (LLD_BUILT_STANDALONE)
+  set(LLVM_HOST_TRIPLE ${TARGET_TRIPLE})
+endif()
+
 set(LLD_VENDOR ${PACKAGE_VENDOR} CACHE STRING
   "Vendor-specific text for showing with 

[PATCH] D95408: [Sema][C] members of anonymous struct inherit QualType

2021-01-26 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

I know we don't have to deal with `restrict` because that qualifies a pointer 
(so there's no way to use it with an anonymous struct), but are there others? 
There's `DeclSpec::TQ_unaligned` (which has no corresponding qualifier in 
`Qualifiers::TQ` despite the comment about keeping them in sync). Similarly, 
what about:

  struct S {
_Atomic struct {
  int i;
};
  }
  
  void foo(void) {
struct S s;
s.i = 12; // Is this an atomic assignment?
  }

Further, do we have to worry about things which are not type specifiers but 
still impact the declaration, like various type attributes?




Comment at: clang/test/AST/ast-dump-decl.c:132
 
+// CHECK: IndirectFieldDecl{{.*}} Test48755Const 'int'
+// CHECK-NEXT: Field{{.*}} 'const struct testIndirectFieldDecl::{{.*}}'

This looks wrong to me -- I would have assumed the type would be `const int` 
and not `int`, which would match the behavior if the type was directly 
qualified: https://godbolt.org/


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95408

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


[PATCH] D94986: Remove requirement for -maltivec to be used when using -mabi=vec-extabi or -mabi=vec-default when not using vector code

2021-01-26 Thread Zarko Todorovski via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
ZarkoCA marked an inline comment as done.
Closed by commit rG028d7a36681f: Remove requirement for -maltivec to be used 
when using -mabi=vec-extabi or… (authored by ZarkoCA).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94986

Files:
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/CodeGen/altivec.c


Index: clang/test/CodeGen/altivec.c
===
--- clang/test/CodeGen/altivec.c
+++ clang/test/CodeGen/altivec.c
@@ -2,23 +2,17 @@
 // RUN: %clang_cc1 -target-feature +altivec -triple powerpcle-unknown-unknown 
-emit-llvm %s -o - | FileCheck %s --check-prefixes=CHECK,CHECK-LE
 // RUN: %clang_cc1 -target-feature +altivec -triple powerpc64-unknown-unknown 
-emit-llvm %s -o - | FileCheck %s --check-prefixes=CHECK,CHECK-BE
 // RUN: %clang_cc1 -target-feature +altivec -triple 
powerpc64le-unknown-unknown -emit-llvm %s -o - | FileCheck %s 
--check-prefixes=CHECK,CHECK-LE
-// RUN: %clang_cc1 -target-feature +altivec -mabi=vec-extabi -triple 
powerpc-unknown-aix -emit-llvm %s -o - | FileCheck %s 
--check-prefixes=CHECK,CHECK-BE
-// RUN: %clang_cc1 -target-feature +altivec -mabi=vec-extabi -triple 
powerpc64-unknown-aix -emit-llvm %s -o - | FileCheck %s 
--check-prefixes=CHECK,CHECK-BE
-// RUN: not %clang_cc1 -target-feature +altivec -mabi=vec-default -triple 
powerpc-unknown-aix -emit-llvm %s 2>&1 | FileCheck %s --check-prefix=AIX-ERROR
-// RUN: not %clang_cc1 -target-feature +altivec -mabi=vec-default -triple 
powerpc64-unknown-aix -emit-llvm %s 2>&1 | FileCheck %s --check-prefix=AIX-ERROR
- 
-// RUN: %clang -S -emit-llvm -maltivec -mabi=vec-extabi -target 
powerpc-unknown-aix %s -o - | FileCheck %s --check-prefixes=CHECK,CHECK-BE
-// RUN: not %clang -S -emit-llvm -maltivec -target powerpc-unknown-aix %s 2>&1 
| FileCheck %s --check-prefix=AIX-ERROR
-// RUN: not %clang -S -emit-llvm -maltivec -target powerpc64-unknown-aix %s 
2>&1 | FileCheck %s --check-prefix=AIX-ERROR 
-// RUN: not %clang -S -emit-llvm -mabi=vec-default -target powerpc-unknown-aix 
%s 2>&1  | FileCheck  %s --check-prefix=AIX-ATVER
-// RUN: not %clang -S -emit-llvm -mabi=vec-extabi -target powerpc-unknown-aix 
%s 2>&1  | FileCheck  %s --check-prefix=AIX-ATVER
-// RUN: %clang -S -emit-llvm -maltivec -mabi=vec-extabi -target 
powerpc64-unknown-aix %s -o - | FileCheck %s --check-prefixes=CHECK,CHECK-BE
-// RUN: not %clang -S -emit-llvm -mabi=vec-default -target 
powerpc64-unknown-aix %s 2>&1  | FileCheck  %s --check-prefix=AIX-ATVER
-// RUN: not %clang -S -emit-llvm -mabi=vec-extabi -target 
powerpc64-unknown-aix %s 2>&1  | FileCheck  %s --check-prefix=AIX-ATVER
-// RUN: not %clang -S -mabi=vec-default -target powerpc-unknown-aix %s 2>&1  | 
FileCheck  %s --check-prefix=AIX-ATVER
-// RUN: not %clang -S -mabi=vec-extabi -target powerpc-unknown-aix %s 2>&1  | 
FileCheck  %s --check-prefix=AIX-ATVER
-// RUN: not %clang -S -mabi=vec-default -target powerpc64-unknown-aix %s 2>&1  
| FileCheck  %s --check-prefix=AIX-ATVER
-// RUN: not %clang -S -mabi=vec-extabi -target powerpc64-unknown-aix %s 2>&1  
| FileCheck  %s --check-prefix=AIX-ATVER
+// RUN: %clang_cc1 -target-feature +altivec -mabi=vec-extabi -target-cpu pwr8 
-triple powerpc-unknown-aix -emit-llvm %s -o - | FileCheck %s 
--check-prefixes=CHECK,CHECK-BE
+// RUN: %clang_cc1 -target-feature +altivec -mabi=vec-extabi -target-cpu pwr8 
-triple powerpc64-unknown-aix -emit-llvm %s -o - | FileCheck %s 
--check-prefixes=CHECK,CHECK-BE
+// RUN: not %clang_cc1 -target-feature +altivec -mabi=vec-default -target-cpu 
pwr8 -triple powerpc-unknown-aix -emit-llvm %s 2>&1 | FileCheck %s 
--check-prefix=AIX-ERROR
+// RUN: not %clang_cc1 -target-feature +altivec -mabi=vec-default -target-cpu 
pwr8 -triple powerpc64-unknown-aix -emit-llvm %s 2>&1 | FileCheck %s 
--check-prefix=AIX-ERROR
+
+// RUN: not %clang -S -emit-llvm -maltivec -mcpu=pwr8 -target 
powerpc-unknown-aix %s 2>&1 | FileCheck %s --check-prefix=AIX-ERROR
+// RUN: not %clang -S -emit-llvm -maltivec -mcpu=pwr8 -target 
powerpc64-unknown-aix %s 2>&1 | FileCheck %s --check-prefix=AIX-ERROR 
+// RUN: %clang -S -emit-llvm -maltivec -mabi=vec-extabi -mcpu=pwr8 -target 
powerpc-unknown-aix %s -o - | FileCheck %s --check-prefixes=CHECK,CHECK-BE
+// RUN: %clang -S -emit-llvm -maltivec -mabi=vec-extabi -mcpu=pwr8 -target 
powerpc64-unknown-aix %s -o - | FileCheck %s --check-prefixes=CHECK,CHECK-BE
+// RUN: not %clang -S -emit-llvm -maltivec -mabi=vec-default -mcpu=pwr8 
-triple powerpc-unknown-aix -emit-llvm %s 2>&1 | FileCheck %s 
--check-prefix=AIX-ERROR
+// RUN: not %clang -S -emit-llvm -maltivec -mabi=vec-default -mcpu=pwr8 
-triple powerpc64-unknown-aix -emit-llvm %s 2>&1 | FileCheck %s 
--check-prefix=AIX-ERROR
 // Check initialization
 
 vector int test0 = (vector int)(1);   // 

  1   2   >