r340929 - [Preamble] Fix incorrect usage of std::error_category

2018-08-29 Thread Alexandre Ganea via cfe-commits
Author: aganea
Date: Wed Aug 29 07:28:04 2018
New Revision: 340929

URL: http://llvm.org/viewvc/llvm-project?rev=340929&view=rev
Log:
[Preamble] Fix incorrect usage of std::error_category

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

Modified:
cfe/trunk/lib/Frontend/PrecompiledPreamble.cpp

Modified: cfe/trunk/lib/Frontend/PrecompiledPreamble.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/PrecompiledPreamble.cpp?rev=340929&r1=340928&r2=340929&view=diff
==
--- cfe/trunk/lib/Frontend/PrecompiledPreamble.cpp (original)
+++ cfe/trunk/lib/Frontend/PrecompiledPreamble.cpp Wed Aug 29 07:28:04 2018
@@ -742,8 +742,10 @@ std::unique_ptr PreambleCal
   return nullptr;
 }
 
+static llvm::ManagedStatic 
BuildPreambleErrCategory;
+
 std::error_code clang::make_error_code(BuildPreambleError Error) {
-  return std::error_code(static_cast(Error), 
BuildPreambleErrorCategory());
+  return std::error_code(static_cast(Error), *BuildPreambleErrCategory);
 }
 
 const char *BuildPreambleErrorCategory::name() const noexcept {


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


RE: [PATCH] D51806: [clang-cl] Enable -march

2018-09-10 Thread Alexandre Ganea via cfe-commits
Yes, indeed. The code in clang/lib/Driver/ToolChains/Arch/X86.cpp makes that 
–march is always parsed, leaving out /arch unused, no matter in which order 
they appear.

De : Nico Weber 
Envoyé : 10 septembre 2018 12:14
À : reviews+d51806+public+c25b17a1aa94d...@reviews.llvm.org; Senthil Kumar 
Selvaraj via Phabricator 
Cc : Alexandre Ganea ; cfe-commits 

Objet : Re: [PATCH] D51806: [clang-cl] Enable -march

On Mon, Sep 10, 2018 at 10:33 AM Hans Wennborg via Phabricator via cfe-commits 
mailto:cfe-commits@lists.llvm.org>> wrote:
hans added a comment.

In https://reviews.llvm.org/D51806#1228893, @aganea wrote:

> @hans Just an after thought: maybe we should prevent usage of `-march=` and 
> `/arch:` at the same time. What do you think? I can add another patch for 
> that purpose.


Hmm, yes, at least we should warn or do something smart. Currently it doesn't 
look like they'd interact well together in x86::getX86TargetCPU

Wouldn't you get an "unused arg" for /arch if you use -march and /arch at the 
same time?



Repository:
  rC Clang

https://reviews.llvm.org/D51806



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


r341847 - [clang-cl] Enable -march option

2018-09-10 Thread Alexandre Ganea via cfe-commits
Author: aganea
Date: Mon Sep 10 10:54:32 2018
New Revision: 341847

URL: http://llvm.org/viewvc/llvm-project?rev=341847&view=rev
Log:
[clang-cl] Enable -march option

This change allows usage of -march when using the clang-cl driver. This is 
similar to MSVC's /arch; however -march can target precisely all supported 
CPUs, while /arch has a more restricted set.

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

Modified:
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/test/Driver/cl-options.c

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=341847&r1=341846&r2=341847&view=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Mon Sep 10 10:54:32 2018
@@ -1931,7 +1931,7 @@ def mappletvsimulator_version_min_EQ : J
 def mwatchos_version_min_EQ : Joined<["-"], "mwatchos-version-min=">, 
Group;
 def mwatchos_simulator_version_min_EQ : Joined<["-"], 
"mwatchos-simulator-version-min=">;
 def mwatchsimulator_version_min_EQ : Joined<["-"], 
"mwatchsimulator-version-min=">, Alias;
-def march_EQ : Joined<["-"], "march=">, Group;
+def march_EQ : Joined<["-"], "march=">, Group, Flags<[CoreOption]>;
 def masm_EQ : Joined<["-"], "masm=">, Group, Flags<[DriverOption]>;
 def mcmodel_EQ : Joined<["-"], "mcmodel=">, Group;
 def mimplicit_it_EQ : Joined<["-"], "mimplicit-it=">, Group;

Modified: cfe/trunk/test/Driver/cl-options.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/cl-options.c?rev=341847&r1=341846&r2=341847&view=diff
==
--- cfe/trunk/test/Driver/cl-options.c (original)
+++ cfe/trunk/test/Driver/cl-options.c Mon Sep 10 10:54:32 2018
@@ -610,6 +610,7 @@
 // RUN: -flto \
 // RUN: -fmerge-all-constants \
 // RUN: -no-canonical-prefixes \
+// RUN: -march=skylake \
 // RUN: --version \
 // RUN: -Werror /Zs -- %s 2>&1
 


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


RE: [PATCH] D42642: [CUDA] Detect installation in PATH

2019-05-02 Thread Alexandre Ganea via cfe-commits
Thanks Michael, it makes sense. I'm still with the old SVN setup on Windows. 
WSL uses the NTFS partition through drvfs (your case 2.)
I'll switch to the git monorepo, it looks like the latest git supports [1] 
symlinks on Windows (with the restrictions you've mentioned) and they should be 
mapped properly inside WSL in that case.

Should we then assume symlinks will always work for end-users? Should we 
validate that somehow, during cmake setup?

Alex.

[1] https://github.com/libgit2/libgit2/pull/4713

-Message d'origine-
De : Michael Kruse  
Envoyé : 1 mai 2019 17:23
À : reviews+d42642+public+5dc9c99d2f2d3...@reviews.llvm.org; Alexandre Ganea 
via Phabricator 
Cc : hah...@hahnjo.de; jle...@google.com; t...@google.com; Alexandre Ganea 
; cfe-commits ; 
llvm-commits ; sylvestre.le...@gmail.com
Objet : Re: [PATCH] D42642: [CUDA] Detect installation in PATH

Hi,

I had my own difficulties with this. It depends on how the repository
containing the symlink has been checked-out. For instance:

1. Using a windows git (such as git extensions, mingw-git, git for windows)
2. Using git inside wsl on a drvfs mount (i.e. a windows folder
mounted into the Unix filesystem)
3. Using git inside wsl on a lxfs mount (I.e. native mount such as '/')

In case 1. git does not create a Ubuntu symlink. Also, there are no
Unix symlinks in Windows filesystems, so when Unix tools (such as git)
request to create a symlink, it creates something else (AFAIR it's a
text file containing the symlink path, but having lost its symlink
properties). Case 3 should work.

I still managed to make cases 1 and 2 work by deleting the text file
and re-creating it with windows's "mklink" tool (which requires either
admin rights or developer mode turned on). It seems the WSL layer
translates this as a symlink to the Linux environment.

Michael





Am Mi., 1. Mai 2019 um 16:59 Uhr schrieb Alexandre Ganea via
Phabricator via llvm-commits :
>
> aganea added a subscriber: rnk.
> aganea added a comment.
>
> So it turns out this is a symlink issue. The file 
> `clang/trunk/test/Driver/Inputs/CUDA-symlinks/usr/bin/ptxas` has been 
> synchronized on my Windows 10 PC as a regular text file, not a symlink. It 
> looks like TortoiseSVN doesn't implement symlinks. As WSL inherits of my file 
> system, it will not find the symbolic link. I suppose `REQUIRES: 
> !system-windows` isn't enough for `cuda-detect-path.cu`, and it would need 
> something like `REQUIRES: symlinks` along with support in lit. @rnk
>
>
> Repository:
>   rL LLVM
>
> CHANGES SINCE LAST ACTION
>   https://reviews.llvm.org/D42642/new/
>
> https://reviews.llvm.org/D42642
>
>
>
> ___
> llvm-commits mailing list
> llvm-comm...@lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r360467 - Fixed tests where grep was not matching the linefeed

2019-05-10 Thread Alexandre Ganea via cfe-commits
Author: aganea
Date: Fri May 10 13:11:36 2019
New Revision: 360467

URL: http://llvm.org/viewvc/llvm-project?rev=360467&view=rev
Log:
Fixed tests where grep was not matching the linefeed

When files are synchronized locally as CRLF on Windows, grep didn't match the 
newline. Switched to FileCheck instead.

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

Modified:
cfe/trunk/test/Preprocessor/indent_macro.c
cfe/trunk/test/Preprocessor/macro_fn_varargs_named.c
cfe/trunk/test/Preprocessor/macro_not_define.c
cfe/trunk/test/Preprocessor/macro_rparen_scan.c

Modified: cfe/trunk/test/Preprocessor/indent_macro.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/indent_macro.c?rev=360467&r1=360466&r2=360467&view=diff
==
--- cfe/trunk/test/Preprocessor/indent_macro.c (original)
+++ cfe/trunk/test/Preprocessor/indent_macro.c Fri May 10 13:11:36 2019
@@ -1,4 +1,5 @@
-// RUN: %clang_cc1 -E %s | grep '^   zzap$'
+// RUN: %clang_cc1 -E %s | FileCheck %s --match-full-lines --strict-whitespace
+// CHECK:   zzap
 
 // zzap is on a new line, should be indented.
 #define BLAH  zzap

Modified: cfe/trunk/test/Preprocessor/macro_fn_varargs_named.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/macro_fn_varargs_named.c?rev=360467&r1=360466&r2=360467&view=diff
==
--- cfe/trunk/test/Preprocessor/macro_fn_varargs_named.c (original)
+++ cfe/trunk/test/Preprocessor/macro_fn_varargs_named.c Fri May 10 13:11:36 
2019
@@ -1,6 +1,9 @@
-// RUN: %clang_cc1 -E %s | grep '^a: x$'
-// RUN: %clang_cc1 -E %s | grep '^b: x y, z,h$'
-// RUN: %clang_cc1 -E %s | grep '^c: foo(x)$'
+// RUN: %clang_cc1 -E %s | FileCheck %s --match-full-lines --strict-whitespace 
--check-prefix CHECK-1
+// CHECK-1:a: x
+// RUN: %clang_cc1 -E %s | FileCheck %s --match-full-lines --strict-whitespace 
--check-prefix CHECK-2
+// CHECK-2:b: x y, z,h
+// RUN: %clang_cc1 -E %s | FileCheck %s --match-full-lines --strict-whitespace 
--check-prefix CHECK-3
+// CHECK-3:c: foo(x)
 
 #define A(b, c...) b c
 a: A(x)

Modified: cfe/trunk/test/Preprocessor/macro_not_define.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/macro_not_define.c?rev=360467&r1=360466&r2=360467&view=diff
==
--- cfe/trunk/test/Preprocessor/macro_not_define.c (original)
+++ cfe/trunk/test/Preprocessor/macro_not_define.c Fri May 10 13:11:36 2019
@@ -1,4 +1,5 @@
-// RUN: %clang_cc1 -E %s | grep '^ # define X 3$'
+// RUN: %clang_cc1 -E %s | FileCheck %s --match-full-lines --strict-whitespace
+// CHECK: # define X 3
 
 #define H # 
  #define D define 

Modified: cfe/trunk/test/Preprocessor/macro_rparen_scan.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/macro_rparen_scan.c?rev=360467&r1=360466&r2=360467&view=diff
==
--- cfe/trunk/test/Preprocessor/macro_rparen_scan.c (original)
+++ cfe/trunk/test/Preprocessor/macro_rparen_scan.c Fri May 10 13:11:36 2019
@@ -1,4 +1,5 @@
-// RUN: %clang_cc1 -E %s | grep '^3 ;$'
+// RUN: %clang_cc1 -E %s | FileCheck %s --match-full-lines --strict-whitespace
+// CHECK:3 ;
 
 /* Right paren scanning, hard case.  Should expand to 3. */
 #define i(x) 3 


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


r360907 - ftime-trace as a CoreOption

2019-05-16 Thread Alexandre Ganea via cfe-commits
Author: aganea
Date: Thu May 16 08:14:01 2019
New Revision: 360907

URL: http://llvm.org/viewvc/llvm-project?rev=360907&view=rev
Log:
ftime-trace as a CoreOption

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

Modified:
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/test/Driver/cl-options.c

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=360907&r1=360906&r2=360907&view=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Thu May 16 08:14:01 2019
@@ -1747,7 +1747,7 @@ def Wframe_larger_than_EQ : Joined<["-"]
 def : Flag<["-"], "fterminated-vtables">, Alias;
 def fthreadsafe_statics : Flag<["-"], "fthreadsafe-statics">, Group;
 def ftime_report : Flag<["-"], "ftime-report">, Group, 
Flags<[CC1Option]>;
-def ftime_trace : Flag<["-"], "ftime-trace">, Group, 
Flags<[CC1Option]>;
+def ftime_trace : Flag<["-"], "ftime-trace">, Group, 
Flags<[CC1Option, CoreOption]>;
 def ftlsmodel_EQ : Joined<["-"], "ftls-model=">, Group, 
Flags<[CC1Option]>;
 def ftrapv : Flag<["-"], "ftrapv">, Group, Flags<[CC1Option]>,
   HelpText<"Trap on integer overflow">;

Modified: cfe/trunk/test/Driver/cl-options.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/cl-options.c?rev=360907&r1=360906&r2=360907&view=diff
==
--- cfe/trunk/test/Driver/cl-options.c (original)
+++ cfe/trunk/test/Driver/cl-options.c Thu May 16 08:14:01 2019
@@ -638,6 +638,7 @@
 // RUN: -fno-profile-instr-use \
 // RUN: -fcs-profile-generate \
 // RUN: -fcs-profile-generate=dir \
+// RUN: -ftime-trace \
 // RUN: --version \
 // RUN: -Werror /Zs -- %s 2>&1
 


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


r361296 - [DebugInfo] Don't emit checksums when compiling a preprocessed CPP

2019-05-21 Thread Alexandre Ganea via cfe-commits
Author: aganea
Date: Tue May 21 12:40:28 2019
New Revision: 361296

URL: http://llvm.org/viewvc/llvm-project?rev=361296&view=rev
Log:
[DebugInfo] Don't emit checksums when compiling a preprocessed CPP

Fixes PR41215

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

Added:
cfe/trunk/test/CodeGen/Inputs/debug-info-file-checksum-line.cpp
cfe/trunk/test/CodeGen/Inputs/debug-info-file-checksum-pre.cpp
Modified:
cfe/trunk/include/clang/Basic/SourceLocation.h
cfe/trunk/lib/Basic/SourceManager.cpp
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
cfe/trunk/test/CodeGen/debug-info-file-checksum.c

Modified: cfe/trunk/include/clang/Basic/SourceLocation.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/SourceLocation.h?rev=361296&r1=361295&r2=361296&view=diff
==
--- cfe/trunk/include/clang/Basic/SourceLocation.h (original)
+++ cfe/trunk/include/clang/Basic/SourceLocation.h Tue May 21 12:40:28 2019
@@ -282,13 +282,15 @@ public:
 /// You can get a PresumedLoc from a SourceLocation with SourceManager.
 class PresumedLoc {
   const char *Filename = nullptr;
+  FileID ID;
   unsigned Line, Col;
   SourceLocation IncludeLoc;
 
 public:
   PresumedLoc() = default;
-  PresumedLoc(const char *FN, unsigned Ln, unsigned Co, SourceLocation IL)
-  : Filename(FN), Line(Ln), Col(Co), IncludeLoc(IL) {}
+  PresumedLoc(const char *FN, FileID FID, unsigned Ln, unsigned Co,
+  SourceLocation IL)
+  : Filename(FN), ID(FID), Line(Ln), Col(Co), IncludeLoc(IL) {}
 
   /// Return true if this object is invalid or uninitialized.
   ///
@@ -305,6 +307,11 @@ public:
 return Filename;
   }
 
+  FileID getFileID() const {
+assert(isValid());
+return ID;
+  }
+
   /// Return the presumed line number of this location.
   ///
   /// This can be affected by \#line etc.

Modified: cfe/trunk/lib/Basic/SourceManager.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/SourceManager.cpp?rev=361296&r1=361295&r2=361296&view=diff
==
--- cfe/trunk/lib/Basic/SourceManager.cpp (original)
+++ cfe/trunk/lib/Basic/SourceManager.cpp Tue May 21 12:40:28 2019
@@ -1430,6 +1430,7 @@ PresumedLoc SourceManager::getPresumedLo
   // To get the source name, first consult the FileEntry (if one exists)
   // before the MemBuffer as this will avoid unnecessarily paging in the
   // MemBuffer.
+  FileID FID = LocInfo.first;
   StringRef Filename;
   if (C->OrigEntry)
 Filename = C->OrigEntry->getName();
@@ -1453,8 +1454,12 @@ PresumedLoc SourceManager::getPresumedLo
 if (const LineEntry *Entry =
   LineTable->FindNearestLineEntry(LocInfo.first, LocInfo.second)) {
   // If the LineEntry indicates a filename, use it.
-  if (Entry->FilenameID != -1)
+  if (Entry->FilenameID != -1) {
 Filename = LineTable->getFilename(Entry->FilenameID);
+// The contents of files referenced by #line are not in the
+// SourceManager
+FID = FileID::get(0);
+  }
 
   // Use the line number specified by the LineEntry.  This line number may
   // be multiple lines down from the line entry.  Add the difference in
@@ -1473,7 +1478,7 @@ PresumedLoc SourceManager::getPresumedLo
 }
   }
 
-  return PresumedLoc(Filename.data(), LineNo, ColNo, IncludeLoc);
+  return PresumedLoc(Filename.data(), FID, LineNo, ColNo, IncludeLoc);
 }
 
 /// Returns whether the PresumedLoc for a given SourceLocation is

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=361296&r1=361295&r2=361296&view=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Tue May 21 12:40:28 2019
@@ -422,8 +422,12 @@ llvm::DIFile *CGDebugInfo::getOrCreateFi
   }
 
   SmallString<32> Checksum;
+
+  // Compute the checksum if possible. If the location is affected by a #line
+  // directive that refers to a file, PLoc will have an invalid FileID, and we
+  // will correctly get no checksum.
   Optional CSKind =
-  computeChecksum(SM.getFileID(Loc), Checksum);
+  computeChecksum(PLoc.getFileID(), Checksum);
   Optional> CSInfo;
   if (CSKind)
 CSInfo.emplace(*CSKind, Checksum);

Added: cfe/trunk/test/CodeGen/Inputs/debug-info-file-checksum-line.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/Inputs/debug-info-file-checksum-line.cpp?rev=361296&view=auto
==
--- cfe/trunk/test/CodeGen/Inputs/debug-info-file-checksum-line.cpp (added)
+++ cfe/trunk/test/CodeGen/Inputs/debug-info-file-checksum-line.cpp Tue May 21 
12:40:28 2019
@@ -0,0 +1,9 @@
+int foo(int x) {
+  return x+1;
+}
+
+#line 100
+void test1() {}
+
+#line 200
+void test2() {}


[clang] 41d2813 - [PDB] Attempt fix for debug-info-codeview-buildinfo.c test

2020-07-10 Thread Alexandre Ganea via cfe-commits

Author: Alexandre Ganea
Date: 2020-07-10T18:52:52-04:00
New Revision: 41d2813a5faea1c18b7d329109e0287c5cd9ffea

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

LOG: [PDB] Attempt fix for debug-info-codeview-buildinfo.c test

This is a bit a shot in the dark, as it doesn't occur on my Windows 10 
machines, nor on x64 Linux Ubuntu 18.04.
This patch tries to fix the following kind of error:
- 
http://lab.llvm.org:8011/builders/clang-ppc64le-linux/builds/31511/steps/cmake%20stage%201/logs/stdio
- 
http://lab.llvm.org:8011/builders/clang-ppc64le-linux-lnt/builds/25150/steps/ninja%20check%201/logs/FAIL%3A%20Clang%3A%3Adebug-info-codeview-buildinfo.c
- 
http://lab.llvm.org:8011/builders/fuchsia-x86_64-linux/builds/7947/steps/check/logs/stdio

Added: 


Modified: 
clang/cmake/caches/BaremetalARM.cmake
clang/cmake/caches/CrossWinToARMLinux.cmake
clang/cmake/caches/Fuchsia-stage2.cmake
clang/test/CMakeLists.txt
clang/test/CodeGen/debug-info-codeview-buildinfo.c

Removed: 




diff  --git a/clang/cmake/caches/BaremetalARM.cmake 
b/clang/cmake/caches/BaremetalARM.cmake
index 85295d9db392..e44355cfcbd7 100644
--- a/clang/cmake/caches/BaremetalARM.cmake
+++ b/clang/cmake/caches/BaremetalARM.cmake
@@ -31,6 +31,7 @@ set(LLVM_TOOLCHAIN_TOOLS
   llvm-dwarfdump
   llvm-nm
   llvm-objdump
+  llvm-pdbutil
   llvm-ranlib
   llvm-readobj
   llvm-size

diff  --git a/clang/cmake/caches/CrossWinToARMLinux.cmake 
b/clang/cmake/caches/CrossWinToARMLinux.cmake
index 9aa0efa8049f..ccfccce3cb89 100644
--- a/clang/cmake/caches/CrossWinToARMLinux.cmake
+++ b/clang/cmake/caches/CrossWinToARMLinux.cmake
@@ -137,6 +137,7 @@ set(LLVM_TOOLCHAIN_TOOLS
   llvm-lib
   llvm-nm
   llvm-objdump
+  llvm-pdbutil
   llvm-profdata
   llvm-ranlib
   llvm-readobj

diff  --git a/clang/cmake/caches/Fuchsia-stage2.cmake 
b/clang/cmake/caches/Fuchsia-stage2.cmake
index 259684ff2b0d..8b5e9d0c4181 100644
--- a/clang/cmake/caches/Fuchsia-stage2.cmake
+++ b/clang/cmake/caches/Fuchsia-stage2.cmake
@@ -240,6 +240,7 @@ set(LLVM_TOOLCHAIN_TOOLS
   llvm-nm
   llvm-objcopy
   llvm-objdump
+  llvm-pdbutil
   llvm-profdata
   llvm-ranlib
   llvm-readelf

diff  --git a/clang/test/CMakeLists.txt b/clang/test/CMakeLists.txt
index 38bbc5be90d5..b2777fded0ae 100644
--- a/clang/test/CMakeLists.txt
+++ b/clang/test/CMakeLists.txt
@@ -126,6 +126,7 @@ if( NOT CLANG_BUILT_STANDALONE )
 llvm-nm
 llvm-objcopy
 llvm-objdump
+llvm-pdbutil
 llvm-profdata
 llvm-readelf
 llvm-readobj

diff  --git a/clang/test/CodeGen/debug-info-codeview-buildinfo.c 
b/clang/test/CodeGen/debug-info-codeview-buildinfo.c
index 3434f5f86579..e1082d2532b2 100644
--- a/clang/test/CodeGen/debug-info-codeview-buildinfo.c
+++ b/clang/test/CodeGen/debug-info-codeview-buildinfo.c
@@ -1,7 +1,6 @@
-// UNSUPPORTED: s390x
-// RUN: %clang_cl /c /Z7 /Fo%t.obj -- %s
+// RUN: %clang_cl --target=i686-windows-msvc /c /Z7 /Fo%t.obj -- %s
 // RUN: llvm-pdbutil dump --types %t.obj | FileCheck %s
-// RUN: %clang_cl /c /Z7 /Fo%t.obj -fdebug-compilation-dir . -- %s
+// RUN: %clang_cl --target=i686-windows-msvc /c /Z7 /Fo%t.obj 
-fdebug-compilation-dir=. -- %s
 // RUN: llvm-pdbutil dump --types %t.obj | FileCheck %s --check-prefix RELATIVE
 
 int main() { return 42; }



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


RE: [PATCH] D80833: [CodeView] Add full repro to LF_BUILDINFO record

2020-07-10 Thread Alexandre Ganea via cfe-commits
Thanks for letting me know Eric. What test fails exactly? What config?

De : Eric Christopher 
Envoyé : July 10, 2020 7:04 PM
À : reviews+d80833+public+da87cf0eabdca...@reviews.llvm.org; Alexandre Ganea 
via Phabricator 
Cc : Alexandre Ganea ; Hans Wennborg 
; Adrian McCarthy ; Martin Storsjo 
; Amy Huang ; dma...@mozilla.com; 
john.rea...@vmssoftware.com; ztur...@roblox.com; ...@gmail.com; 
llvm-commits ; 
stefan.reinal...@molecular-matters.com; Ulrich Weigand 
; mlek...@skidmore.edu; Clang Commits 
; Han Shen 
Objet : Re: [PATCH] D80833: [CodeView] Add full repro to LF_BUILDINFO record

I'm seeing tests fail with a crash. Can we revert the patch and attempted fixes 
and start working from there?

Stacktrace for the curious :)

@ 0x56420187cbbe  llvm::MCStreamer::emitIntValue()
@ 0x5641fec38899  llvm::MCStreamer::emitInt16()
@ 0x5641ff73b337  llvm::CodeViewDebug::emitCompilerInformation()
@ 0x5641ff73ac73  llvm::CodeViewDebug::endModule()
@ 0x5641ff718e83  llvm::AsmPrinter::doFinalization()
@ 0x5642016fd9ca  llvm::FPPassManager::doFinalization()
@ 0x5642016f954e  (anonymous namespace)::MPPassManager::runOnModule()

-eric

On Tue, Jun 30, 2020 at 11:56 AM Alexandre Ganea via Phabricator via 
cfe-commits mailto:cfe-commits@lists.llvm.org>> 
wrote:
aganea added a comment.

In D80833#2109172 , @uweigand wrote:

> Hmm, with clang-cl it seems the driver is trying to use this:
>  Target: s390x-pc-windows-msvc
>  which of course doesn't exist.  Not sure what is supposed to be happening 
> here, but it seems that it's falling back on s390x-linux since on s390x, 
> Linux is currently the only supported OS.


I'm seeing some of the tests are setting the target explicitly `%clang_cl 
--target=x86_64-windows-msvc`. Would that work on your machine? Or should I do 
`UNSUPPORTED: s390x` ?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80833



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


[clang] 89ea0b0 - [MC] Pass down argv0 & cc1 cmd-line to the back-end and store in MCTargetOptions

2020-06-18 Thread Alexandre Ganea via cfe-commits

Author: Alexandre Ganea
Date: 2020-06-18T09:17:14-04:00
New Revision: 89ea0b05207d45c145fb525df554b3b986ae379b

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

LOG: [MC] Pass down argv0 & cc1 cmd-line to the back-end and store in 
MCTargetOptions

When targetting CodeView, the goal is to store argv0 & cc1 cmd-line in the 
emitted .OBJ, in order to allow a reproducer from the .OBJ alone.

This patch is to simplify https://reviews.llvm.org/D80833

Added: 


Modified: 
clang/include/clang/Basic/CodeGenOptions.h
clang/include/clang/Frontend/CompilerInvocation.h
clang/lib/CodeGen/BackendUtil.cpp
clang/lib/Frontend/CompilerInvocation.cpp
clang/lib/Frontend/CreateInvocationFromCommandLine.cpp
clang/lib/Tooling/Tooling.cpp
clang/tools/driver/cc1_main.cpp
clang/tools/driver/driver.cpp
llvm/include/llvm/MC/MCTargetOptions.h

Removed: 




diff  --git a/clang/include/clang/Basic/CodeGenOptions.h 
b/clang/include/clang/Basic/CodeGenOptions.h
index 864ccd5e276d..b14a088d77b2 100644
--- a/clang/include/clang/Basic/CodeGenOptions.h
+++ b/clang/include/clang/Basic/CodeGenOptions.h
@@ -332,6 +332,11 @@ class CodeGenOptions : public CodeGenOptionsBase {
   /// coverage pass should actually not be instrumented.
   std::vector SanitizeCoverageBlacklistFiles;
 
+  /// Executable and command-line used to create a given CompilerInvocation.
+  /// Most of the time this will be the full -cc1 command.
+  const char *Argv0 = nullptr;
+  ArrayRef CommandLineArgs;
+
 public:
   // Define accessors/mutators for code generation options of enumeration type.
 #define CODEGENOPT(Name, Bits, Default)

diff  --git a/clang/include/clang/Frontend/CompilerInvocation.h 
b/clang/include/clang/Frontend/CompilerInvocation.h
index 25476f78a6a0..e63408da8f5e 100644
--- a/clang/include/clang/Frontend/CompilerInvocation.h
+++ b/clang/include/clang/Frontend/CompilerInvocation.h
@@ -155,7 +155,8 @@ class CompilerInvocation : public CompilerInvocationBase {
   /// \param [out] Res - The resulting invocation.
   static bool CreateFromArgs(CompilerInvocation &Res,
  ArrayRef CommandLineArgs,
- DiagnosticsEngine &Diags);
+ DiagnosticsEngine &Diags,
+ const char *Argv0 = nullptr);
 
   /// Get the directory where the compiler headers
   /// reside, relative to the compiler binary (found by the passed in

diff  --git a/clang/lib/CodeGen/BackendUtil.cpp 
b/clang/lib/CodeGen/BackendUtil.cpp
index 603f1c9adf54..e810bb23f347 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -537,6 +537,8 @@ static void initTargetOptions(DiagnosticsEngine &Diags,
  Entry.Group == frontend::IncludeDirGroup::System))
   Options.MCOptions.IASSearchPaths.push_back(
   Entry.IgnoreSysRoot ? Entry.Path : HSOpts.Sysroot + Entry.Path);
+  Options.MCOptions.Argv0 = CodeGenOpts.Argv0;
+  Options.MCOptions.CommandLineArgs = CodeGenOpts.CommandLineArgs;
 }
 static Optional getGCOVOptions(const CodeGenOptions &CodeGenOpts) 
{
   if (CodeGenOpts.DisableGCov)

diff  --git a/clang/lib/Frontend/CompilerInvocation.cpp 
b/clang/lib/Frontend/CompilerInvocation.cpp
index 4c05717a24f2..1af4153c4423 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -3627,7 +3627,8 @@ static void ParseTargetArgs(TargetOptions &Opts, ArgList 
&Args,
 
 bool CompilerInvocation::CreateFromArgs(CompilerInvocation &Res,
 ArrayRef CommandLineArgs,
-DiagnosticsEngine &Diags) {
+DiagnosticsEngine &Diags,
+const char *Argv0) {
   bool Success = true;
 
   // Parse the arguments.
@@ -3747,6 +3748,11 @@ bool 
CompilerInvocation::CreateFromArgs(CompilerInvocation &Res,
 Res.getCodeGenOpts().FineGrainedBitfieldAccesses = false;
 Diags.Report(diag::warn_drv_fine_grained_bitfield_accesses_ignored);
   }
+
+  // Store the command-line for using in the CodeView backend.
+  Res.getCodeGenOpts().Argv0 = Argv0;
+  Res.getCodeGenOpts().CommandLineArgs = CommandLineArgs;
+
   return Success;
 }
 

diff  --git a/clang/lib/Frontend/CreateInvocationFromCommandLine.cpp 
b/clang/lib/Frontend/CreateInvocationFromCommandLine.cpp
index 18c4814bbd5c..1d5a6c06b34f 100644
--- a/clang/lib/Frontend/CreateInvocationFromCommandLine.cpp
+++ b/clang/lib/Frontend/CreateInvocationFromCommandLine.cpp
@@ -93,7 +93,7 @@ std::unique_ptr 
clang::createInvocationFromCommandLine(
   if (CC1Args)
 *CC1Args = {CCArgs.begin(), CCArgs.end()};
   auto CI = std::make_unique();
-  if (!CompilerInvocation::CreateFromArgs(*C

[clang] a45409d - [Clang] Move clang::Job::printArg to llvm::sys::printArg. NFCI.

2020-06-18 Thread Alexandre Ganea via cfe-commits

Author: Alexandre Ganea
Date: 2020-06-18T09:17:13-04:00
New Revision: a45409d8855a1e4538990507ef25e9b51c090193

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

LOG: [Clang] Move clang::Job::printArg to llvm::sys::printArg. NFCI.

This patch is to support/simplify https://reviews.llvm.org/D80833

Added: 


Modified: 
clang/include/clang/Driver/Job.h
clang/lib/Driver/Driver.cpp
clang/lib/Driver/Job.cpp
llvm/include/llvm/Support/Program.h
llvm/lib/Support/Program.cpp

Removed: 




diff  --git a/clang/include/clang/Driver/Job.h 
b/clang/include/clang/Driver/Job.h
index 9a3cad23363b..1c6ea6971919 100644
--- a/clang/include/clang/Driver/Job.h
+++ b/clang/include/clang/Driver/Job.h
@@ -128,9 +128,6 @@ class Command {
 
   const llvm::opt::ArgStringList &getArguments() const { return Arguments; }
 
-  /// Print a command argument, and optionally quote it.
-  static void printArg(llvm::raw_ostream &OS, StringRef Arg, bool Quote);
-
 protected:
   /// Optionally print the filenames to be compiled
   void PrintFileNames() const;

diff  --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index a8442d2cd0af..a48761af400f 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -1167,7 +1167,7 @@ static void printArgList(raw_ostream &OS, const 
llvm::opt::ArgList &Args) {
   for (auto I = ASL.begin(), E = ASL.end(); I != E; ++I) {
 if (I != ASL.begin())
   OS << ' ';
-Command::printArg(OS, *I, true);
+llvm::sys::printArg(OS, *I, true);
   }
   OS << '\n';
 }

diff  --git a/clang/lib/Driver/Job.cpp b/clang/lib/Driver/Job.cpp
index 6d1e7e61ba1d..274bda9dc9f1 100644
--- a/clang/lib/Driver/Job.cpp
+++ b/clang/lib/Driver/Job.cpp
@@ -100,24 +100,6 @@ static bool skipArgs(const char *Flag, bool HaveCrashVFS, 
int &SkipNum,
   return false;
 }
 
-void Command::printArg(raw_ostream &OS, StringRef Arg, bool Quote) {
-  const bool Escape = Arg.find_first_of(" \"\\$") != StringRef::npos;
-
-  if (!Quote && !Escape) {
-OS << Arg;
-return;
-  }
-
-  // Quote and escape. This isn't really complete, but good enough.
-  OS << '"';
-  for (const auto c : Arg) {
-if (c == '"' || c == '\\' || c == '$')
-  OS << '\\';
-OS << c;
-  }
-  OS << '"';
-}
-
 void Command::writeResponseFile(raw_ostream &OS) const {
   // In a file list, we only write the set of inputs to the response file
   if (Creator.getResponseFilesSupport() == Tool::RF_FileList) {
@@ -217,7 +199,7 @@ void Command::Print(raw_ostream &OS, const char 
*Terminator, bool Quote,
 CrashReportInfo *CrashInfo) const {
   // Always quote the exe.
   OS << ' ';
-  printArg(OS, Executable, /*Quote=*/true);
+  llvm::sys::printArg(OS, Executable, /*Quote=*/true);
 
   ArrayRef Args = Arguments;
   SmallVector ArgsRespFile;
@@ -245,7 +227,7 @@ void Command::Print(raw_ostream &OS, const char 
*Terminator, bool Quote,
 if (!NewIncFlags.empty()) {
   for (auto &F : NewIncFlags) {
 OS << ' ';
-printArg(OS, F.c_str(), Quote);
+llvm::sys::printArg(OS, F.c_str(), Quote);
   }
   i += NumArgs - 1;
   continue;
@@ -259,20 +241,20 @@ void Command::Print(raw_ostream &OS, const char 
*Terminator, bool Quote,
 // Replace the input file name with the crashinfo's file name.
 OS << ' ';
 StringRef ShortName = llvm::sys::path::filename(CrashInfo->Filename);
-printArg(OS, ShortName.str(), Quote);
+llvm::sys::printArg(OS, ShortName.str(), Quote);
 continue;
   }
 }
 
 OS << ' ';
-printArg(OS, Arg, Quote);
+llvm::sys::printArg(OS, Arg, Quote);
   }
 
   if (CrashInfo && HaveCrashVFS) {
 OS << ' ';
-printArg(OS, "-ivfsoverlay", Quote);
+llvm::sys::printArg(OS, "-ivfsoverlay", Quote);
 OS << ' ';
-printArg(OS, CrashInfo->VFSPath.str(), Quote);
+llvm::sys::printArg(OS, CrashInfo->VFSPath.str(), Quote);
 
 // The leftover modules from the crash are stored in
 //  .cache/vfs/modules
@@ -287,7 +269,7 @@ void Command::Print(raw_ostream &OS, const char 
*Terminator, bool Quote,
 ModCachePath.append(RelModCacheDir.c_str());
 
 OS << ' ';
-printArg(OS, ModCachePath, Quote);
+llvm::sys::printArg(OS, ModCachePath, Quote);
   }
 
   if (ResponseFile != nullptr) {

diff  --git a/llvm/include/llvm/Support/Program.h 
b/llvm/include/llvm/Support/Program.h
index ff4777ebecee..ce0b6db5705f 100644
--- a/llvm/include/llvm/Support/Program.h
+++ b/llvm/include/llvm/Support/Program.h
@@ -210,6 +210,9 @@ namespace sys {
   /// stored.
   );
 
+  /// Print a command argument, and optionally quote it.
+  void printArg(llvm::raw_ostream &OS, StringRef Arg, bool Quote);
+
 #if defined(_WIN32)
   /// Given a lis

[clang] 403f953 - [CodeView] Add full repro to LF_BUILDINFO record

2020-06-18 Thread Alexandre Ganea via cfe-commits

Author: Alexandre Ganea
Date: 2020-06-18T09:17:15-04:00
New Revision: 403f9537924b8910ed4f741ed96c61f5e657915b

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

LOG: [CodeView] Add full repro to LF_BUILDINFO record

This patch adds some missing information to the LF_BUILDINFO which allows for 
rebuilding an .OBJ without any external dependency but the .OBJ itself (other 
than the compiler executable).

Some tools need this information to reproduce a build without any knowledge of 
the build system. The LF_BUILDINFO therefore stores a full path to the 
compiler, the PWD (which is the CWD at program startup), a relative or absolute 
path to the TU, and the full CC1 command line. The command line needs to be 
freestanding (not depend on any environment variable). In the same way, MSVC 
doesn't store the provided command-line, but an expanded version (somehow their 
equivalent of CC1) which is also freestanding.

For more information see PR36198 and D43002.

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

Added: 
clang/test/CodeGen/debug-info-codeview-buildinfo.c

Modified: 
lld/COFF/PDB.cpp
lld/test/COFF/Inputs/pdb_lines_1_relative.yaml
lld/test/COFF/Inputs/pdb_lines_2_relative.yaml
lld/test/COFF/pdb-relative-source-lines.test
llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp

Removed: 




diff  --git a/clang/test/CodeGen/debug-info-codeview-buildinfo.c 
b/clang/test/CodeGen/debug-info-codeview-buildinfo.c
new file mode 100644
index ..d08fadbbf1a9
--- /dev/null
+++ b/clang/test/CodeGen/debug-info-codeview-buildinfo.c
@@ -0,0 +1,24 @@
+// RUN: %clang_cl /c /Z7 /Fo%t.obj -- %s
+// RUN: llvm-pdbutil dump --types %t.obj | FileCheck %s
+// RUN: %clang_cl /c /Z7 %s /Fo%t.obj -fdebug-compilation-dir .
+// RUN: llvm-pdbutil dump --types %t.obj | FileCheck %s --check-prefix RELATIVE
+
+int main() { return 42; }
+
+// CHECK:   Types (.debug$T)
+// CHECK: 
+// CHECK: 0x[[PWD:.+]] | LF_STRING_ID [size = {{.+}}] ID: , String: 
[[PWDVAL:.+]]
+// CHECK: 0x[[FILEPATH:.+]] | LF_STRING_ID [size = {{.+}}] ID: , 
String: [[FILEPATHVAL:.+[\\/]debug-info-codeview-buildinfo.c]]
+// CHECK: 0x[[TOOL:.+]] | LF_STRING_ID [size = {{.+}}] ID: , String: 
[[TOOLVAL:.+[\\/]clang.*]]
+// CHECK: 0x[[CMDLINE:.+]] | LF_STRING_ID [size = {{.+}}] ID: , 
String: "-cc1
+// CHECK: 0x{{.+}} | LF_BUILDINFO [size = {{.+}}]
+// CHECK:  0x[[PWD]]: `[[PWDVAL]]`
+// CHECK:  0x[[TOOL]]: `[[TOOLVAL]]`
+// CHECK:  0x[[FILEPATH]]: `[[FILEPATHVAL]]`
+// CHECK:  : ``
+// CHECK:  0x[[CMDLINE]]: `"-cc1
+
+// RELATIVE:   Types (.debug$T)
+// RELATIVE: 
+// RELATIVE: 0x{{.+}} | LF_BUILDINFO [size = {{.+}}]
+// RELATIVE:  0x{{.+}}: `.`

diff  --git a/lld/COFF/PDB.cpp b/lld/COFF/PDB.cpp
index be6af13f3647..75884ed11308 100644
--- a/lld/COFF/PDB.cpp
+++ b/lld/COFF/PDB.cpp
@@ -250,6 +250,72 @@ static void addTypeInfo(pdb::TpiStreamBuilder &tpiBuilder,
   });
 }
 
+// LF_BUILDINFO records might contain relative paths, and we want to make them
+// absolute. We do this remapping only after the type records were merged,
+// because the full types graph isn't known during merging. In addition, we 
plan
+// to multi-thread the type merging, and the change below needs to be done
+// atomically, single-threaded.
+
+// A complication could arise when a LF_STRING_ID record already exists with 
the
+// same content as the new absolutized path. In that case, we simply redirect
+// LF_BUILDINFO's CurrentDirectory index to reference the existing LF_STRING_ID
+// record.
+
+static void remapBuildInfo(TypeCollection &idTable) {
+  SimpleTypeSerializer s;
+  idTable.ForEachRecord([&](TypeIndex ti, const CVType &type) {
+if (type.kind() != LF_BUILDINFO)
+  return;
+BuildInfoRecord bi;
+cantFail(TypeDeserializer::deserializeAs(const_cast(type), bi));
+
+auto makeAbsoluteRecord =
+[&](BuildInfoRecord::BuildInfoArg recordType) -> Optional {
+  TypeIndex recordTi = bi.getArgs()[recordType];
+  if (recordTi.isNoneType())
+return None;
+  CVType recordRef = idTable.getType(recordTi);
+
+  StringIdRecord record;
+  cantFail(TypeDeserializer::deserializeAs(recordRef, record));
+
+  SmallString<128> abolutizedPath(record.getString());
+  pdbMakeAbsolute(abolutizedPath);
+
+  if (abolutizedPath == record.getString())
+return None; // The path is already absolute.
+
+  record.String = abolutizedPath;
+  ArrayRef recordData = s.serialize(record);
+
+  // Replace the previous LF_STRING_ID record
+  if (!idTable.replaceType(recordTi, CVType(recor

[clang] cab3fc5 - Fix linker error in clang-fuzzer following 89ea0b05207d45c145fb525df554b3b986ae379b.

2020-06-18 Thread Alexandre Ganea via cfe-commits

Author: Alexandre Ganea
Date: 2020-06-18T10:07:31-04:00
New Revision: cab3fc53d2e173243a462e9c8e914af58ddbeaba

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

LOG: Fix linker error in clang-fuzzer following 
89ea0b05207d45c145fb525df554b3b986ae379b.

This fixes:
tools/clang/tools/clang-fuzzer/handle-cxx/CMakeFiles/obj.clangHandleCXX.dir/handle_cxx.cpp.o:handle_cxx.cpp:function
 clang_fuzzer::HandleCXX(std::__cxx11::basic_string, std::allocator > const&, char const*, 
std::vector > const&): error: 
undefined reference to 
'clang::tooling::newInvocation(clang::DiagnosticsEngine*, 
llvm::SmallVector const&)'

Added: 


Modified: 
clang/include/clang/Tooling/Tooling.h
clang/tools/clang-fuzzer/handle-cxx/handle_cxx.cpp

Removed: 




diff  --git a/clang/include/clang/Tooling/Tooling.h 
b/clang/include/clang/Tooling/Tooling.h
index ced2405f6e83..4fb0c18be95e 100644
--- a/clang/include/clang/Tooling/Tooling.h
+++ b/clang/include/clang/Tooling/Tooling.h
@@ -505,7 +505,8 @@ void 
addTargetAndModeForProgramName(std::vector &CommandLine,
 
 /// Creates a \c CompilerInvocation.
 CompilerInvocation *newInvocation(DiagnosticsEngine *Diagnostics,
-  const llvm::opt::ArgStringList &CC1Args);
+  const llvm::opt::ArgStringList &CC1Args,
+  const char *const BinaryName);
 
 } // namespace tooling
 

diff  --git a/clang/tools/clang-fuzzer/handle-cxx/handle_cxx.cpp 
b/clang/tools/clang-fuzzer/handle-cxx/handle_cxx.cpp
index 32d351f4c3e9..14204021d262 100644
--- a/clang/tools/clang-fuzzer/handle-cxx/handle_cxx.cpp
+++ b/clang/tools/clang-fuzzer/handle-cxx/handle_cxx.cpp
@@ -37,7 +37,7 @@ void clang_fuzzer::HandleCXX(const std::string &S,
   IntrusiveRefCntPtr(new DiagnosticIDs()), 
&*DiagOpts,
   &Diags, false);
   std::unique_ptr Invocation(
-  tooling::newInvocation(&Diagnostics, CC1Args));
+  tooling::newInvocation(&Diagnostics, CC1Args, /*BinaryName=*/nullptr));
   std::unique_ptr Input =
   llvm::MemoryBuffer::getMemBuffer(S);
   Invocation->getPreprocessorOpts().addRemappedFile(FileName,



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


[clang] 8374bf4 - [CodeView] Fix generated command-line expansion in LF_BUILDINFO. Fix the 'pdb' entry which was previously a null reference, now an empty string.

2020-06-18 Thread Alexandre Ganea via cfe-commits

Author: Alexandre Ganea
Date: 2020-06-18T10:07:30-04:00
New Revision: 8374bf43634725dc02a262a77b5f940fca25938c

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

LOG: [CodeView] Fix generated command-line expansion in LF_BUILDINFO. Fix the 
'pdb' entry which was previously a null reference, now an empty string.

Previously, the DIA SDK didn't like the empty reference in the 'pdb' entry.

Added: 


Modified: 
clang/test/CodeGen/debug-info-codeview-buildinfo.c
llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
llvm/test/DebugInfo/COFF/build-info.ll
llvm/test/DebugInfo/COFF/global-type-hashes.ll
llvm/test/DebugInfo/COFF/types-basic.ll
llvm/test/DebugInfo/COFF/types-data-members.ll

Removed: 




diff  --git a/clang/test/CodeGen/debug-info-codeview-buildinfo.c 
b/clang/test/CodeGen/debug-info-codeview-buildinfo.c
index d08fadbbf1a9..5d37162b7325 100644
--- a/clang/test/CodeGen/debug-info-codeview-buildinfo.c
+++ b/clang/test/CodeGen/debug-info-codeview-buildinfo.c
@@ -1,6 +1,6 @@
 // RUN: %clang_cl /c /Z7 /Fo%t.obj -- %s
 // RUN: llvm-pdbutil dump --types %t.obj | FileCheck %s
-// RUN: %clang_cl /c /Z7 %s /Fo%t.obj -fdebug-compilation-dir .
+// RUN: %clang_cl /c /Z7 /Fo%t.obj -fdebug-compilation-dir . -- %s
 // RUN: llvm-pdbutil dump --types %t.obj | FileCheck %s --check-prefix RELATIVE
 
 int main() { return 42; }
@@ -9,13 +9,14 @@ int main() { return 42; }
 // CHECK: 
 // CHECK: 0x[[PWD:.+]] | LF_STRING_ID [size = {{.+}}] ID: , String: 
[[PWDVAL:.+]]
 // CHECK: 0x[[FILEPATH:.+]] | LF_STRING_ID [size = {{.+}}] ID: , 
String: [[FILEPATHVAL:.+[\\/]debug-info-codeview-buildinfo.c]]
+// CHECK: 0x[[ZIPDB:.+]] | LF_STRING_ID [size = {{.+}}] ID: , String:
 // CHECK: 0x[[TOOL:.+]] | LF_STRING_ID [size = {{.+}}] ID: , String: 
[[TOOLVAL:.+[\\/]clang.*]]
 // CHECK: 0x[[CMDLINE:.+]] | LF_STRING_ID [size = {{.+}}] ID: , 
String: "-cc1
 // CHECK: 0x{{.+}} | LF_BUILDINFO [size = {{.+}}]
 // CHECK:  0x[[PWD]]: `[[PWDVAL]]`
 // CHECK:  0x[[TOOL]]: `[[TOOLVAL]]`
 // CHECK:  0x[[FILEPATH]]: `[[FILEPATHVAL]]`
-// CHECK:  : ``
+// CHECK:  0x[[ZIPDB]]: ``
 // CHECK:  0x[[CMDLINE]]: `"-cc1
 
 // RELATIVE:   Types (.debug$T)

diff  --git a/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp 
b/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
index 7f47849e3aa8..cf3c38c57f6d 100644
--- a/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
@@ -849,10 +849,11 @@ static std::string flattenCommandLine(ArrayRef Args,
   continue;
 }
 if (!LastArg.empty())
-  FlatCmdLine += " ";
+  OS << " ";
 llvm::sys::printArg(OS, Arg, /*Quote=*/true);
 LastArg = Arg;
   }
+  OS.flush();
   return FlatCmdLine;
 }
 
@@ -876,6 +877,9 @@ void CodeViewDebug::emitBuildInfo() {
   getStringIdTypeIdx(TypeTable, MainSourceFile->getDirectory());
   BuildInfoArgs[BuildInfoRecord::SourceFile] =
   getStringIdTypeIdx(TypeTable, MainSourceFile->getFilename());
+  // FIXME: PDB is intentionally blank unless we implement /Zi type servers.
+  BuildInfoArgs[BuildInfoRecord::TypeServerPDB] =
+  getStringIdTypeIdx(TypeTable, "");
   if (Asm->TM.Options.MCOptions.Argv0 != nullptr) {
 BuildInfoArgs[BuildInfoRecord::BuildTool] =
 getStringIdTypeIdx(TypeTable, Asm->TM.Options.MCOptions.Argv0);
@@ -883,7 +887,6 @@ void CodeViewDebug::emitBuildInfo() {
 TypeTable, 
flattenCommandLine(Asm->TM.Options.MCOptions.CommandLineArgs,
   MainSourceFile->getFilename()));
   }
-  // FIXME: PDB is intentionally blank unless we implement /Zi type servers.
   BuildInfoRecord BIR(BuildInfoArgs);
   TypeIndex BuildInfoIndex = TypeTable.writeLeafType(BIR);
 

diff  --git a/llvm/test/DebugInfo/COFF/build-info.ll 
b/llvm/test/DebugInfo/COFF/build-info.ll
index 94f006c3b093..983aa22214bc 100644
--- a/llvm/test/DebugInfo/COFF/build-info.ll
+++ b/llvm/test/DebugInfo/COFF/build-info.ll
@@ -5,7 +5,7 @@
 ; CHECK-NEXT:  0x{{.*}}: `D:\src\scopes\clang`
 ; CHECK-NEXT:  : ``
 ; CHECK-NEXT:  0x{{.*}}: `D:\src\scopes\foo.cpp`
-; CHECK-NEXT:  : ``
+; CHECK-NEXT:  0x{{.*}}: ``
 ; CHECK-NEXT:  : ``
 
 ; CHECK: {{.*}} | S_BUILDINFO [size = 8] BuildId = `[[INFO_IDX]]`

diff  --git a/llvm/test/DebugInfo/COFF/global-type-hashes.ll 
b/llvm/test/DebugInfo/COFF/global-type-hashes.ll
index 70f9df156a5b..3c6c27301b20 100644
--- a/llvm/test/DebugInfo/COFF/global-type-hashes.ll
+++ b/llvm/test/DebugInfo/COFF/global-type-hashes.ll
@@ -295,7 +295,8 @@ attributes #2 = { noinline nounwind optnone 
"correctly-rounded-divide-sqrt-fp-ma
 ; YAML: - 4470750F2E319329
 ; YAML:  

[clang] 2ae0df5 - [CodeView] Revert 8374bf43634725dc02a262a77b5f940fca25938c and 403f9537924b8910ed4f741ed96c61f5e657915b

2020-06-18 Thread Alexandre Ganea via cfe-commits

Author: Alexandre Ganea
Date: 2020-06-18T16:18:46-04:00
New Revision: 2ae0df5be7408a79524743762b6c74953f31b805

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

LOG: [CodeView] Revert 8374bf43634725dc02a262a77b5f940fca25938c and 
403f9537924b8910ed4f741ed96c61f5e657915b

This reverts:
8374bf43634725dc02a262a77b5f940fca25938c [CodeView] Fix generated command-line 
expansion in LF_BUILDINFO. Fix the 'pdb' entry which was previously a null 
reference, now an empty string.
403f9537924b8910ed4f741ed96c61f5e657915b [CodeView] Add full repro to 
LF_BUILDINFO record

This is causing the lld/test/COFF/pdb-relative-source-lines.test to fail: 
http://lab.llvm.org:8011/builders/lld-x86_64-win/builds/1096/steps/test-check-all/logs/FAIL%3A%20lld%3A%3Apdb-relative-source-lines.test
And clang/test/CodeGen/debug-info-codeview-buildinfo.c fails as well: 
http://lab.llvm.org:8011/builders/clang-s390x-linux/builds/33346/steps/ninja%20check%201/logs/FAIL%3A%20Clang%3A%3Adebug-info-codeview-buildinfo.c

Added: 


Modified: 
lld/COFF/PDB.cpp
lld/test/COFF/Inputs/pdb_lines_1_relative.yaml
lld/test/COFF/Inputs/pdb_lines_2_relative.yaml
lld/test/COFF/pdb-relative-source-lines.test
llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
llvm/test/DebugInfo/COFF/build-info.ll
llvm/test/DebugInfo/COFF/global-type-hashes.ll
llvm/test/DebugInfo/COFF/types-basic.ll
llvm/test/DebugInfo/COFF/types-data-members.ll

Removed: 
clang/test/CodeGen/debug-info-codeview-buildinfo.c



diff  --git a/clang/test/CodeGen/debug-info-codeview-buildinfo.c 
b/clang/test/CodeGen/debug-info-codeview-buildinfo.c
deleted file mode 100644
index 5d37162b7325..
--- a/clang/test/CodeGen/debug-info-codeview-buildinfo.c
+++ /dev/null
@@ -1,25 +0,0 @@
-// RUN: %clang_cl /c /Z7 /Fo%t.obj -- %s
-// RUN: llvm-pdbutil dump --types %t.obj | FileCheck %s
-// RUN: %clang_cl /c /Z7 /Fo%t.obj -fdebug-compilation-dir . -- %s
-// RUN: llvm-pdbutil dump --types %t.obj | FileCheck %s --check-prefix RELATIVE
-
-int main() { return 42; }
-
-// CHECK:   Types (.debug$T)
-// CHECK: 
-// CHECK: 0x[[PWD:.+]] | LF_STRING_ID [size = {{.+}}] ID: , String: 
[[PWDVAL:.+]]
-// CHECK: 0x[[FILEPATH:.+]] | LF_STRING_ID [size = {{.+}}] ID: , 
String: [[FILEPATHVAL:.+[\\/]debug-info-codeview-buildinfo.c]]
-// CHECK: 0x[[ZIPDB:.+]] | LF_STRING_ID [size = {{.+}}] ID: , String:
-// CHECK: 0x[[TOOL:.+]] | LF_STRING_ID [size = {{.+}}] ID: , String: 
[[TOOLVAL:.+[\\/]clang.*]]
-// CHECK: 0x[[CMDLINE:.+]] | LF_STRING_ID [size = {{.+}}] ID: , 
String: "-cc1
-// CHECK: 0x{{.+}} | LF_BUILDINFO [size = {{.+}}]
-// CHECK:  0x[[PWD]]: `[[PWDVAL]]`
-// CHECK:  0x[[TOOL]]: `[[TOOLVAL]]`
-// CHECK:  0x[[FILEPATH]]: `[[FILEPATHVAL]]`
-// CHECK:  0x[[ZIPDB]]: ``
-// CHECK:  0x[[CMDLINE]]: `"-cc1
-
-// RELATIVE:   Types (.debug$T)
-// RELATIVE: 
-// RELATIVE: 0x{{.+}} | LF_BUILDINFO [size = {{.+}}]
-// RELATIVE:  0x{{.+}}: `.`

diff  --git a/lld/COFF/PDB.cpp b/lld/COFF/PDB.cpp
index 75884ed11308..be6af13f3647 100644
--- a/lld/COFF/PDB.cpp
+++ b/lld/COFF/PDB.cpp
@@ -250,72 +250,6 @@ static void addTypeInfo(pdb::TpiStreamBuilder &tpiBuilder,
   });
 }
 
-// LF_BUILDINFO records might contain relative paths, and we want to make them
-// absolute. We do this remapping only after the type records were merged,
-// because the full types graph isn't known during merging. In addition, we 
plan
-// to multi-thread the type merging, and the change below needs to be done
-// atomically, single-threaded.
-
-// A complication could arise when a LF_STRING_ID record already exists with 
the
-// same content as the new absolutized path. In that case, we simply redirect
-// LF_BUILDINFO's CurrentDirectory index to reference the existing LF_STRING_ID
-// record.
-
-static void remapBuildInfo(TypeCollection &idTable) {
-  SimpleTypeSerializer s;
-  idTable.ForEachRecord([&](TypeIndex ti, const CVType &type) {
-if (type.kind() != LF_BUILDINFO)
-  return;
-BuildInfoRecord bi;
-cantFail(TypeDeserializer::deserializeAs(const_cast(type), bi));
-
-auto makeAbsoluteRecord =
-[&](BuildInfoRecord::BuildInfoArg recordType) -> Optional {
-  TypeIndex recordTi = bi.getArgs()[recordType];
-  if (recordTi.isNoneType())
-return None;
-  CVType recordRef = idTable.getType(recordTi);
-
-  StringIdRecord record;
-  cantFail(TypeDeserializer::deserializeAs(recordRef, record));
-
-  SmallString<128> abolutizedPath(record.getString());
-  pdbMakeAbsolute(abolutizedPath);
-
-  if (abolutizedPath == record.getString())
-  

[clang] a3036b3 - Re-Re-land: [CodeView] Add full repro to LF_BUILDINFO record

2020-08-10 Thread Alexandre Ganea via cfe-commits

Author: Alexandre Ganea
Date: 2020-08-10T13:36:30-04:00
New Revision: a3036b386383f1c1e9d32c2c8dba995087959da3

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

LOG: Re-Re-land: [CodeView] Add full repro to LF_BUILDINFO record

This patch adds the missing information to the LF_BUILDINFO record, which 
allows for rebuilding a .CPP without any external dependency but the .OBJ 
itself (other than the compiler).

Some external tools that we are using (Recode, Live++) are extracting the 
information to reproduce a build without any knowledge of the build system. The 
LF_BUILDINFO stores a full path to the compiler, the PWD (CWD at program 
startup), a relative or absolute path to the TU, and the full CC1 command line. 
The command line needs to be freestanding (not depend on any environment 
variables). In the same way, MSVC doesn't store the provided command-line, but 
an expanded version (somehow their equivalent of CC1) which is also 
freestanding.

For more information see PR36198 and D43002.

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

Added: 
clang/test/CodeGen/debug-info-codeview-buildinfo.c
lld/test/COFF/pdb-relative-source-lines2.test

Modified: 
clang/cmake/caches/BaremetalARM.cmake
clang/cmake/caches/CrossWinToARMLinux.cmake
clang/cmake/caches/Fuchsia-stage2.cmake
clang/test/CMakeLists.txt
lld/COFF/PDB.cpp
lld/test/COFF/Inputs/pdb_lines_1_relative.yaml
lld/test/COFF/Inputs/pdb_lines_2_relative.yaml
lld/test/COFF/pdb-relative-source-lines.test
llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
llvm/test/DebugInfo/COFF/build-info.ll
llvm/test/DebugInfo/COFF/global-type-hashes.ll
llvm/test/DebugInfo/COFF/types-basic.ll
llvm/test/DebugInfo/COFF/types-data-members.ll

Removed: 




diff  --git a/clang/cmake/caches/BaremetalARM.cmake 
b/clang/cmake/caches/BaremetalARM.cmake
index 85295d9db392a..e44355cfcbd74 100644
--- a/clang/cmake/caches/BaremetalARM.cmake
+++ b/clang/cmake/caches/BaremetalARM.cmake
@@ -31,6 +31,7 @@ set(LLVM_TOOLCHAIN_TOOLS
   llvm-dwarfdump
   llvm-nm
   llvm-objdump
+  llvm-pdbutil
   llvm-ranlib
   llvm-readobj
   llvm-size

diff  --git a/clang/cmake/caches/CrossWinToARMLinux.cmake 
b/clang/cmake/caches/CrossWinToARMLinux.cmake
index 9aa0efa8049fb..ccfccce3cb890 100644
--- a/clang/cmake/caches/CrossWinToARMLinux.cmake
+++ b/clang/cmake/caches/CrossWinToARMLinux.cmake
@@ -137,6 +137,7 @@ set(LLVM_TOOLCHAIN_TOOLS
   llvm-lib
   llvm-nm
   llvm-objdump
+  llvm-pdbutil
   llvm-profdata
   llvm-ranlib
   llvm-readobj

diff  --git a/clang/cmake/caches/Fuchsia-stage2.cmake 
b/clang/cmake/caches/Fuchsia-stage2.cmake
index e00b64073ca52..7cefeedf1bada 100644
--- a/clang/cmake/caches/Fuchsia-stage2.cmake
+++ b/clang/cmake/caches/Fuchsia-stage2.cmake
@@ -242,6 +242,7 @@ set(LLVM_TOOLCHAIN_TOOLS
   llvm-nm
   llvm-objcopy
   llvm-objdump
+  llvm-pdbutil
   llvm-profdata
   llvm-rc
   llvm-ranlib

diff  --git a/clang/test/CMakeLists.txt b/clang/test/CMakeLists.txt
index 38bbc5be90d52..b2777fded0ae5 100644
--- a/clang/test/CMakeLists.txt
+++ b/clang/test/CMakeLists.txt
@@ -126,6 +126,7 @@ if( NOT CLANG_BUILT_STANDALONE )
 llvm-nm
 llvm-objcopy
 llvm-objdump
+llvm-pdbutil
 llvm-profdata
 llvm-readelf
 llvm-readobj

diff  --git a/clang/test/CodeGen/debug-info-codeview-buildinfo.c 
b/clang/test/CodeGen/debug-info-codeview-buildinfo.c
new file mode 100644
index 0..93810e829c6d9
--- /dev/null
+++ b/clang/test/CodeGen/debug-info-codeview-buildinfo.c
@@ -0,0 +1,26 @@
+// REQUIRES: x86-registered-target
+// RUN: %clang_cl --target=i686-windows-msvc /c /Z7 /Fo%t.obj -- %s
+// RUN: llvm-pdbutil dump --types %t.obj | FileCheck %s
+// RUN: %clang_cl --target=i686-windows-msvc /c /Z7 /Fo%t.obj 
-fdebug-compilation-dir=. -- %s
+// RUN: llvm-pdbutil dump --types %t.obj | FileCheck %s --check-prefix RELATIVE
+
+int main() { return 42; }
+
+// CHECK:   Types (.debug$T)
+// CHECK: 
+// CHECK: 0x[[PWD:.+]] | LF_STRING_ID [size = {{.+}}] ID: , String: 
[[PWDVAL:.+]]
+// CHECK: 0x[[FILEPATH:.+]] | LF_STRING_ID [size = {{.+}}] ID: , 
String: [[FILEPATHVAL:.+[\\/]debug-info-codeview-buildinfo.c]]
+// CHECK: 0x[[ZIPDB:.+]] | LF_STRING_ID [size = {{.+}}] ID: , String:
+// CHECK: 0x[[TOOL:.+]] | LF_STRING_ID [size = {{.+}}] ID: , String: 
[[TOOLVAL:.+[\\/]clang.*]]
+// CHECK: 0x[[CMDLINE:.+]] | LF_STRING_ID [size = {{.+}}] ID: , 
String: "-cc1
+// CHECK: 0x{{.+}} | LF_BUILDINFO [size = {{.+}}]
+// CHECK:  0x[[PWD]]: `[[PWDVAL]]`
+// CHECK:  0x[[TOOL]]: `[[TOOLVAL]]`
+// CHECK:  0x[[FILEPATH]]: `[[FILEPATHVAL]]`
+// CHECK:  0x[[ZIPDB]]: ``
+// CHECK:  0x[[CMDLINE]]: `"-cc1
+
+// R

[clang] 98e01f5 - Revert "Re-Re-land: [CodeView] Add full repro to LF_BUILDINFO record"

2020-08-17 Thread Alexandre Ganea via cfe-commits

Author: Alexandre Ganea
Date: 2020-08-17T15:49:18-04:00
New Revision: 98e01f56b0a117f0f32ed2f9b7d61e85830c

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

LOG: Revert "Re-Re-land: [CodeView] Add full repro to LF_BUILDINFO record"

This reverts commit a3036b386383f1c1e9d32c2c8dba995087959da3.

As requested in: https://reviews.llvm.org/D80833#2221866
Bug report: https://crbug.com/1117026

Added: 


Modified: 
clang/cmake/caches/BaremetalARM.cmake
clang/cmake/caches/CrossWinToARMLinux.cmake
clang/cmake/caches/Fuchsia-stage2.cmake
clang/test/CMakeLists.txt
lld/COFF/PDB.cpp
lld/test/COFF/Inputs/pdb_lines_1_relative.yaml
lld/test/COFF/Inputs/pdb_lines_2_relative.yaml
lld/test/COFF/pdb-relative-source-lines.test
llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
llvm/test/DebugInfo/COFF/build-info.ll
llvm/test/DebugInfo/COFF/global-type-hashes.ll
llvm/test/DebugInfo/COFF/types-basic.ll
llvm/test/DebugInfo/COFF/types-data-members.ll

Removed: 
clang/test/CodeGen/debug-info-codeview-buildinfo.c
lld/test/COFF/pdb-relative-source-lines2.test



diff  --git a/clang/cmake/caches/BaremetalARM.cmake 
b/clang/cmake/caches/BaremetalARM.cmake
index e44355cfcbd7..85295d9db392 100644
--- a/clang/cmake/caches/BaremetalARM.cmake
+++ b/clang/cmake/caches/BaremetalARM.cmake
@@ -31,7 +31,6 @@ set(LLVM_TOOLCHAIN_TOOLS
   llvm-dwarfdump
   llvm-nm
   llvm-objdump
-  llvm-pdbutil
   llvm-ranlib
   llvm-readobj
   llvm-size

diff  --git a/clang/cmake/caches/CrossWinToARMLinux.cmake 
b/clang/cmake/caches/CrossWinToARMLinux.cmake
index ccfccce3cb89..9aa0efa8049f 100644
--- a/clang/cmake/caches/CrossWinToARMLinux.cmake
+++ b/clang/cmake/caches/CrossWinToARMLinux.cmake
@@ -137,7 +137,6 @@ set(LLVM_TOOLCHAIN_TOOLS
   llvm-lib
   llvm-nm
   llvm-objdump
-  llvm-pdbutil
   llvm-profdata
   llvm-ranlib
   llvm-readobj

diff  --git a/clang/cmake/caches/Fuchsia-stage2.cmake 
b/clang/cmake/caches/Fuchsia-stage2.cmake
index 7cefeedf1bad..e00b64073ca5 100644
--- a/clang/cmake/caches/Fuchsia-stage2.cmake
+++ b/clang/cmake/caches/Fuchsia-stage2.cmake
@@ -242,7 +242,6 @@ set(LLVM_TOOLCHAIN_TOOLS
   llvm-nm
   llvm-objcopy
   llvm-objdump
-  llvm-pdbutil
   llvm-profdata
   llvm-rc
   llvm-ranlib

diff  --git a/clang/test/CMakeLists.txt b/clang/test/CMakeLists.txt
index 3ace9f2521b0..334a90498d0d 100644
--- a/clang/test/CMakeLists.txt
+++ b/clang/test/CMakeLists.txt
@@ -117,7 +117,6 @@ if( NOT CLANG_BUILT_STANDALONE )
 llvm-nm
 llvm-objcopy
 llvm-objdump
-llvm-pdbutil
 llvm-profdata
 llvm-readelf
 llvm-readobj

diff  --git a/clang/test/CodeGen/debug-info-codeview-buildinfo.c 
b/clang/test/CodeGen/debug-info-codeview-buildinfo.c
deleted file mode 100644
index 93810e829c6d..
--- a/clang/test/CodeGen/debug-info-codeview-buildinfo.c
+++ /dev/null
@@ -1,26 +0,0 @@
-// REQUIRES: x86-registered-target
-// RUN: %clang_cl --target=i686-windows-msvc /c /Z7 /Fo%t.obj -- %s
-// RUN: llvm-pdbutil dump --types %t.obj | FileCheck %s
-// RUN: %clang_cl --target=i686-windows-msvc /c /Z7 /Fo%t.obj 
-fdebug-compilation-dir=. -- %s
-// RUN: llvm-pdbutil dump --types %t.obj | FileCheck %s --check-prefix RELATIVE
-
-int main() { return 42; }
-
-// CHECK:   Types (.debug$T)
-// CHECK: 
-// CHECK: 0x[[PWD:.+]] | LF_STRING_ID [size = {{.+}}] ID: , String: 
[[PWDVAL:.+]]
-// CHECK: 0x[[FILEPATH:.+]] | LF_STRING_ID [size = {{.+}}] ID: , 
String: [[FILEPATHVAL:.+[\\/]debug-info-codeview-buildinfo.c]]
-// CHECK: 0x[[ZIPDB:.+]] | LF_STRING_ID [size = {{.+}}] ID: , String:
-// CHECK: 0x[[TOOL:.+]] | LF_STRING_ID [size = {{.+}}] ID: , String: 
[[TOOLVAL:.+[\\/]clang.*]]
-// CHECK: 0x[[CMDLINE:.+]] | LF_STRING_ID [size = {{.+}}] ID: , 
String: "-cc1
-// CHECK: 0x{{.+}} | LF_BUILDINFO [size = {{.+}}]
-// CHECK:  0x[[PWD]]: `[[PWDVAL]]`
-// CHECK:  0x[[TOOL]]: `[[TOOLVAL]]`
-// CHECK:  0x[[FILEPATH]]: `[[FILEPATHVAL]]`
-// CHECK:  0x[[ZIPDB]]: ``
-// CHECK:  0x[[CMDLINE]]: `"-cc1
-
-// RELATIVE:   Types (.debug$T)
-// RELATIVE: 
-// RELATIVE: 0x{{.+}} | LF_BUILDINFO [size = {{.+}}]
-// RELATIVE:  0x{{.+}}: `.`

diff  --git a/lld/COFF/PDB.cpp b/lld/COFF/PDB.cpp
index 5738eae7d6c4..49d04add5be0 100644
--- a/lld/COFF/PDB.cpp
+++ b/lld/COFF/PDB.cpp
@@ -250,72 +250,6 @@ static void addTypeInfo(pdb::TpiStreamBuilder &tpiBuilder,
   });
 }
 
-// LF_BUILDINFO records might contain relative paths, and we want to make them
-// absolute. We do this remapping only after the type records were merged,
-// because the full types graph isn't known during merging. In addition, w

[clang] 3483cdc - [Sema] Silence warnings when targeting x86 with VS2019 16.5.4

2020-05-06 Thread Alexandre Ganea via cfe-commits

Author: Alexandre Ganea
Date: 2020-05-06T09:11:59-04:00
New Revision: 3483cdc8344d9c2c08c3f12490df54cfa63b6838

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

LOG: [Sema] Silence warnings when targeting x86 with VS2019 16.5.4

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

Added: 


Modified: 
clang/lib/Sema/ParsedAttr.cpp

Removed: 




diff  --git a/clang/lib/Sema/ParsedAttr.cpp b/clang/lib/Sema/ParsedAttr.cpp
index d45777ca127d..3ef8498baffd 100644
--- a/clang/lib/Sema/ParsedAttr.cpp
+++ b/clang/lib/Sema/ParsedAttr.cpp
@@ -111,7 +111,7 @@ namespace {
 
 const ParsedAttrInfo &ParsedAttrInfo::get(const AttributeCommonInfo &A) {
   // If we have a ParsedAttrInfo for this ParsedAttr then return that.
-  if (A.getParsedKind() < llvm::array_lengthof(AttrInfoMap))
+  if ((size_t)A.getParsedKind() < llvm::array_lengthof(AttrInfoMap))
 return *AttrInfoMap[A.getParsedKind()];
 
   // If this is an ignored attribute then return an appropriate ParsedAttrInfo.



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


[lld] [clang] [llvm] [llvm-driver] Fix usage of `InitLLVM` on Windows (PR #76306)

2023-12-30 Thread Alexandre Ganea via cfe-commits

https://github.com/aganea updated 
https://github.com/llvm/llvm-project/pull/76306

>From 8187e95ea4e04793fbfc85045aa21f9633bbc03d Mon Sep 17 00:00:00 2001
From: Alexandre Ganea 
Date: Sat, 23 Dec 2023 19:17:06 -0500
Subject: [PATCH 1/2] [llvm-driver] Fix tool re-entrance on Windows.

Previously, some tools such as `clang` or `lld` which require strict order for 
certain command-line options, such as `clang -cc1` or `lld -flavor` would not 
long work on Windows, when these tools were linked as part of `llvm-driver`. 
This was caused by `InitLLVM` which was part of the `main()` function of these 
tools, which in turn calls `windows::GetCommandLineArguments`. This function 
completly replaces argc/argv by new UTF-8 contents, so any ajustements to 
argc/argv made by `llvm-driver` prior to calling these tools would be reset.

We now call `InitLLVM` as part of the `llvm-driver`. Any further usages to 
`InitLLVM` on the stack, after the first call in the process would have no 
effect. In the same way, the last `InitLLVM` on the stack will clear the 
`ManagedStatics` as usual.
---
 llvm/cmake/modules/llvm-driver-template.cpp.in | 2 ++
 llvm/lib/Support/InitLLVM.cpp  | 6 ++
 llvm/tools/llvm-driver/llvm-driver.cpp | 6 +-
 3 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/llvm/cmake/modules/llvm-driver-template.cpp.in 
b/llvm/cmake/modules/llvm-driver-template.cpp.in
index 16c4fb34714638..71aca6cd140cb5 100644
--- a/llvm/cmake/modules/llvm-driver-template.cpp.in
+++ b/llvm/cmake/modules/llvm-driver-template.cpp.in
@@ -8,9 +8,11 @@
 
 #include "llvm/Support/LLVMDriver.h"
 #include "llvm/ADT/ArrayRef.h"
+#include "llvm/Support/InitLLVM.h"
 
 int @TOOL_NAME@_main(int argc, char **, const llvm::ToolContext &);
 
 int main(int argc, char **argv) {
+  llvm::InitLLVM X(argc, argv);
   return @TOOL_NAME@_main(argc, argv, {argv[0], nullptr, false});
 }
diff --git a/llvm/lib/Support/InitLLVM.cpp b/llvm/lib/Support/InitLLVM.cpp
index 7f475f42f3cb81..2a2e6c254c795a 100644
--- a/llvm/lib/Support/InitLLVM.cpp
+++ b/llvm/lib/Support/InitLLVM.cpp
@@ -36,8 +36,12 @@ void CleanupStdHandles(void *Cookie) {
 using namespace llvm;
 using namespace llvm::sys;
 
+static std::atomic UsageCount{0};
+
 InitLLVM::InitLLVM(int &Argc, const char **&Argv,
bool InstallPipeSignalExitHandler) {
+  if (UsageCount++)
+return;
 #ifdef __MVS__
   // Bring stdin/stdout/stderr into a known state.
   sys::AddSignalHandler(CleanupStdHandles, nullptr);
@@ -94,6 +98,8 @@ InitLLVM::InitLLVM(int &Argc, const char **&Argv,
 }
 
 InitLLVM::~InitLLVM() {
+  if (--UsageCount)
+return;
 #ifdef __MVS__
   CleanupStdHandles(nullptr);
 #endif
diff --git a/llvm/tools/llvm-driver/llvm-driver.cpp 
b/llvm/tools/llvm-driver/llvm-driver.cpp
index a0f1ca831d93b6..53a8b9357e3780 100644
--- a/llvm/tools/llvm-driver/llvm-driver.cpp
+++ b/llvm/tools/llvm-driver/llvm-driver.cpp
@@ -10,6 +10,7 @@
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/ErrorHandling.h"
+#include "llvm/Support/InitLLVM.h"
 #include "llvm/Support/LLVMDriver.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/WithColor.h"
@@ -79,4 +80,7 @@ static int findTool(int Argc, char **Argv, const char *Argv0) 
{
   return 1;
 }
 
-int main(int Argc, char **Argv) { return findTool(Argc, Argv, Argv[0]); }
+int main(int Argc, char **Argv) {
+  llvm::InitLLVM X(Argc, Argv);
+  return findTool(Argc, Argv, Argv[0]);
+}

>From 03d24462dbc2e113bf0f740f3d95f519367c1abd Mon Sep 17 00:00:00 2001
From: Alexandre Ganea 
Date: Sat, 30 Dec 2023 22:45:58 -0500
Subject: [PATCH 2/2] Remove `InitLLVM` from all the tools participating in the
 `llvm-driver`.

---
 clang/tools/clang-scan-deps/ClangScanDeps.cpp |  2 --
 clang/tools/driver/driver.cpp |  2 --
 lld/Common/DriverDispatcher.cpp   |  1 -
 lld/tools/lld/lld.cpp |  2 --
 llvm/lib/Support/InitLLVM.cpp | 11 +--
 llvm/tools/dsymutil/dsymutil.cpp  |  3 ---
 llvm/tools/llvm-ar/llvm-ar.cpp|  2 --
 llvm/tools/llvm-cxxfilt/llvm-cxxfilt.cpp  |  2 --
 llvm/tools/llvm-debuginfod/llvm-debuginfod.cpp|  2 --
 llvm/tools/llvm-dwp/llvm-dwp.cpp  |  3 ---
 .../tools/llvm-libtool-darwin/llvm-libtool-darwin.cpp |  2 --
 llvm/tools/llvm-lipo/llvm-lipo.cpp|  2 --
 llvm/tools/llvm-ml/llvm-ml.cpp|  2 --
 llvm/tools/llvm-mt/llvm-mt.cpp|  3 ---
 llvm/tools/llvm-nm/llvm-nm.cpp|  2 --
 llvm/tools/llvm-objcopy/llvm-objcopy.cpp  |  2 --
 llvm/tools/llvm-objdump/llvm-objdump.cpp  |  2 --
 llvm/tools/llvm-profdata/llvm-profdata.cpp|  2 --
 llvm/tools/llvm-rc/llvm-rc.cpp|  2 --
 llvm/tools/llvm-readobj/llvm-readobj.cpp  |  2 --
 l

[lld] [clang] [llvm] [llvm-driver] Fix usage of `InitLLVM` on Windows (PR #76306)

2023-12-30 Thread Alexandre Ganea via cfe-commits

https://github.com/aganea edited https://github.com/llvm/llvm-project/pull/76306
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[lld] [clang] [llvm] [llvm-driver] Fix usage of `InitLLVM` on Windows (PR #76306)

2023-12-30 Thread Alexandre Ganea via cfe-commits

aganea wrote:

@MaskRay Can you please take another look?

https://github.com/llvm/llvm-project/pull/76306
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 18f230a - [Clang] Silence warning when building with MSVC 2022

2022-07-05 Thread Alexandre Ganea via cfe-commits

Author: Alexandre Ganea
Date: 2022-07-05T20:31:54-04:00
New Revision: 18f230a89aa234ac58be4fb8cee2bfa95ea67be4

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

LOG: [Clang] Silence warning when building with MSVC 2022

Previously, the warning seen:

[22/95] Building CXX object 
tools\clang\lib\StaticAnalyzer\Checker...bj.clangStaticAnalyzerCheckers.dir\NoReturnFunctionChecker.cpp.objC:\git\llvm-project\clang\lib\StaticAnalyzer\Checkers\NoReturnFunctionChecker.cpp(149):
 warning C4305: 'if': truncation from 'size_t' to 'bool'
C:\git\llvm-project\clang\include\clang/Analysis/SelectorExtras.h(28): note: 
see reference to function template instantiation 'clang::Selector 
clang::getKeywordSelector(clang::ASTContext &,const char *,const char *,const char *,const char *)' 
being compiled
C:\git\llvm-project\clang\lib\StaticAnalyzer\Checkers\NoReturnFunctionChecker.cpp(125):
 note: see reference to function template instantiation 'void 
clang::lazyInitKeywordSelector(clang::Selector &,clang::ASTContext &,const char *,const char *,const 
char *,const char *)' being compiled

Added: 


Modified: 
clang/include/clang/Analysis/SelectorExtras.h

Removed: 




diff  --git a/clang/include/clang/Analysis/SelectorExtras.h 
b/clang/include/clang/Analysis/SelectorExtras.h
index 278f20e87cc69..1e1daf5706bbf 100644
--- a/clang/include/clang/Analysis/SelectorExtras.h
+++ b/clang/include/clang/Analysis/SelectorExtras.h
@@ -16,7 +16,7 @@ namespace clang {
 template 
 static inline Selector getKeywordSelector(ASTContext &Ctx,
   IdentifierInfos *... IIs) {
-  static_assert(sizeof...(IdentifierInfos),
+  static_assert(sizeof...(IdentifierInfos) > 0,
 "keyword selectors must have at least one argument");
   SmallVector II({&Ctx.Idents.get(IIs)...});
 



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


[clang] 0880b9d - [Clang][unittests] Silence trucation warning with MSVC 2022

2022-07-05 Thread Alexandre Ganea via cfe-commits

Author: Alexandre Ganea
Date: 2022-07-05T20:31:54-04:00
New Revision: 0880b9d52620ca3c46456095f6040a2e4de6c871

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

LOG: [Clang][unittests] Silence trucation warning with MSVC 2022

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

Added: 


Modified: 
clang/unittests/StaticAnalyzer/RangeSetTest.cpp

Removed: 




diff  --git a/clang/unittests/StaticAnalyzer/RangeSetTest.cpp 
b/clang/unittests/StaticAnalyzer/RangeSetTest.cpp
index 91a6351c8e3b3..892c1ac23f92f 100644
--- a/clang/unittests/StaticAnalyzer/RangeSetTest.cpp
+++ b/clang/unittests/StaticAnalyzer/RangeSetTest.cpp
@@ -88,6 +88,12 @@ template  struct TestValues {
   template 
   static constexpr T X555TruncZeroOf = TruncZeroOf; // 0x'5600
 
+// Silence 'warning C4309: 'initializing': truncation of constant value'
+//   in RangeSetCastToPromotionConversionTest.
+#if defined(_MSC_VER) && !defined(__clang__)
+#pragma warning(push)
+#pragma warning(disable : 4309)
+#endif
   // Numbers for ranges with the same bits in the lowest byte.
   // 0x'AA2A
   static constexpr T FromA = ClearLowBytes + 42;
@@ -95,6 +101,10 @@ template  struct TestValues {
   // 0x'552A
   static constexpr T FromB = ClearLowBytes + 42;
   static constexpr T ToB = FromB + 2; // 0x'552C
+
+#if defined(_MSC_VER) && !defined(__clang__)
+#pragma warning(pop)
+#endif
 };
 
 template 



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


[clang] [llvm] [clang][MBD] set up module build daemon infrastructure (PR #67562)

2024-01-24 Thread Alexandre Ganea via cfe-commits

aganea wrote:

Can you please send separate PRs for the Support changes?

https://github.com/llvm/llvm-project/pull/67562
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 419d6ea - [clang] Silence warning when compiling with MSVC targetting x86

2024-01-25 Thread Alexandre Ganea via cfe-commits

Author: Alexandre Ganea
Date: 2024-01-25T09:34:17-05:00
New Revision: 419d6ea135dd205e1eaab368a58ae14f9f52f699

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

LOG: [clang] Silence warning when compiling with MSVC targetting x86

This fixes:
```
[3963/6996] Building CXX object 
tools\clang\lib\CodeGen\CMakeFiles\obj.clangCodeGen.dir\CGExpr.cpp.obj
C:\git\llvm-project\clang\lib\CodeGen\CGExpr.cpp(3808): warning C4018: '<=': 
signed/unsigned mismatch
```

Added: 


Modified: 
clang/lib/CodeGen/CGExpr.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp
index c5f6b6d3a99f0b2..9196c953145b214 100644
--- a/clang/lib/CodeGen/CGExpr.cpp
+++ b/clang/lib/CodeGen/CGExpr.cpp
@@ -3805,7 +3805,7 @@ void CodeGenFunction::EmitTrapCheck(llvm::Value *Checked,
 
   // If we're optimizing, collapse all calls to trap down to just one per
   // check-type per function to save on code size.
-  if (TrapBBs.size() <= CheckHandlerID)
+  if ((int)TrapBBs.size() <= CheckHandlerID)
 TrapBBs.resize(CheckHandlerID + 1);
 
   llvm::BasicBlock *&TrapBB = TrapBBs[CheckHandlerID];



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


[clang] ee15e2b - [clang] Silence warning when building with MSVC targetting x86

2024-01-25 Thread Alexandre Ganea via cfe-commits

Author: Alexandre Ganea
Date: 2024-01-25T09:34:17-05:00
New Revision: ee15e2bd32a4677c40d927c732b26d33f88d7865

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

LOG: [clang] Silence warning when building with MSVC targetting x86

This fixes:
```
[3786/6996] Building CXX object 
tools\clang\lib\AST\CMakeFiles\obj.clangAST.dir\AttrDocTable.cpp.obj
C:\git\llvm-project\clang\lib\AST\AttrDocTable.cpp(24): warning C4018: '<': 
signed/unsigned mismatch
```

Added: 


Modified: 
clang/lib/AST/AttrDocTable.cpp

Removed: 




diff  --git a/clang/lib/AST/AttrDocTable.cpp b/clang/lib/AST/AttrDocTable.cpp
index df7e3d63a6c355a..56a143b9ed29be6 100644
--- a/clang/lib/AST/AttrDocTable.cpp
+++ b/clang/lib/AST/AttrDocTable.cpp
@@ -21,7 +21,7 @@ static const llvm::StringRef AttrDoc[] = {
 };
 
 llvm::StringRef clang::Attr::getDocumentation(clang::attr::Kind K) {
-  if (K < std::size(AttrDoc))
+  if (K < (int)std::size(AttrDoc))
 return AttrDoc[K];
   return "";
 }



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


[clang-tools-extra] f33f5a0 - [clangd] Silence warning when compiling with MSVC targetting x86

2024-01-25 Thread Alexandre Ganea via cfe-commits

Author: Alexandre Ganea
Date: 2024-01-25T09:34:17-05:00
New Revision: f33f5a04e9feeb9b473694825d84da8322f87df9

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

LOG: [clangd] Silence warning when compiling with MSVC targetting x86

This fixes:
```
[5240/6995] Building CXX object 
tools\clang\tools\extra\clangd\CMakeFiles\obj.clangDaemon.dir\InlayHints.cpp.obj
C:\git\llvm-project\clang-tools-extra\clangd\InlayHints.cpp(1098): warning 
C4018: '<': signed/unsigned mismatch
```

Added: 


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

Removed: 




diff  --git a/clang-tools-extra/clangd/InlayHints.cpp 
b/clang-tools-extra/clangd/InlayHints.cpp
index 5722ca8f66eb720..c7dce041474a1c8 100644
--- a/clang-tools-extra/clangd/InlayHints.cpp
+++ b/clang-tools-extra/clangd/InlayHints.cpp
@@ -1095,7 +1095,7 @@ class InlayHintVisitor : public 
RecursiveASTVisitor {
   if (auto *Def = Callee->getDefinition()) {
 auto I = std::distance(Callee->param_begin(),
llvm::find(Callee->parameters(), P));
-if (I < Callee->getNumParams()) {
+if (I < (int)Callee->getNumParams()) {
   return Def->getParamDecl(I);
 }
   }



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


[lld] [llvm] [clang] [llvm-driver] Fix usage of `InitLLVM` on Windows (PR #76306)

2024-01-11 Thread Alexandre Ganea via cfe-commits

https://github.com/aganea edited https://github.com/llvm/llvm-project/pull/76306
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[lld] [llvm] [clang] [llvm-driver] Fix usage of `InitLLVM` on Windows (PR #76306)

2024-01-11 Thread Alexandre Ganea via cfe-commits

https://github.com/aganea edited https://github.com/llvm/llvm-project/pull/76306
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [lld] [llvm-driver] Fix usage of `InitLLVM` on Windows (PR #76306)

2024-01-11 Thread Alexandre Ganea via cfe-commits

https://github.com/aganea closed https://github.com/llvm/llvm-project/pull/76306
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r369458 - [DebugInfo] Add debug location to dynamic atexit destructor

2019-08-20 Thread Alexandre Ganea via cfe-commits
Author: aganea
Date: Tue Aug 20 15:09:49 2019
New Revision: 369458

URL: http://llvm.org/viewvc/llvm-project?rev=369458&view=rev
Log:
[DebugInfo] Add debug location to dynamic atexit destructor

Fixes PR43012

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

Added:
cfe/trunk/test/CodeGenCXX/debug-info-atexit-stub.cpp
Modified:
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
cfe/trunk/lib/CodeGen/CGDeclCXX.cpp
cfe/trunk/test/CodeGenCXX/debug-info-global-ctor-dtor.cpp

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=369458&r1=369457&r2=369458&view=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Tue Aug 20 15:09:49 2019
@@ -3564,7 +3564,8 @@ void CGDebugInfo::EmitFunctionStart(Glob
   if (Name.startswith("\01"))
 Name = Name.substr(1);
 
-  if (!HasDecl || D->isImplicit() || D->hasAttr()) {
+  if (!HasDecl || D->isImplicit() || D->hasAttr() ||
+  (isa(D) && GD.getDynamicInitKind() == DynamicInitKind::AtExit)) 
{
 Flags |= llvm::DINode::FlagArtificial;
 // Artificial functions should not silently reuse CurLoc.
 CurLoc = SourceLocation();

Modified: cfe/trunk/lib/CodeGen/CGDeclCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDeclCXX.cpp?rev=369458&r1=369457&r2=369458&view=diff
==
--- cfe/trunk/lib/CodeGen/CGDeclCXX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDeclCXX.cpp Tue Aug 20 15:09:49 2019
@@ -247,6 +247,8 @@ llvm::Function *CodeGenFunction::createA
 
   CGF.StartFunction(GlobalDecl(&VD, DynamicInitKind::AtExit),
 CGM.getContext().VoidTy, fn, FI, FunctionArgList());
+  // Emit an artificial location for this function.
+  auto AL = ApplyDebugLocation::CreateArtificial(CGF);
 
   llvm::CallInst *call = CGF.Builder.CreateCall(dtor, addr);
 

Added: cfe/trunk/test/CodeGenCXX/debug-info-atexit-stub.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/debug-info-atexit-stub.cpp?rev=369458&view=auto
==
--- cfe/trunk/test/CodeGenCXX/debug-info-atexit-stub.cpp (added)
+++ cfe/trunk/test/CodeGenCXX/debug-info-atexit-stub.cpp Tue Aug 20 15:09:49 
2019
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -emit-llvm %s -gcodeview -debug-info-kind=limited -o - | 
FileCheck %s
+
+struct a {
+  ~a();
+};
+template  struct c : a {
+  c(void (b::*)());
+};
+struct B {
+  virtual void e();
+};
+c *d() { static c f(&B::e); return &f; }
+
+// CHECK: define internal void @"??__Ff@?1??d@@YAPEAU?$c@UBXZ@YAXXZ"()
+// CHECK-SAME: !dbg ![[SUBPROGRAM:[0-9]+]] {
+// CHECK: call void @"??1?$c@UBQEAA@XZ"(%struct.c* 
@"?f@?1??d@@YAPEAU?$c@UBXZ@4U2@A"), !dbg ![[LOCATION:[0-9]+]]
+// CHECK-NEXT: ret void, !dbg ![[LOCATION]]
+// CHECK: ![[SUBPROGRAM]] = distinct !DISubprogram(name: "`dynamic atexit 
destructor for 'f'"
+// CHECK-SAME: flags: DIFlagArtificial
+// CHECK: ![[LOCATION]] = !DILocation(line: 0, scope: ![[SUBPROGRAM]])

Modified: cfe/trunk/test/CodeGenCXX/debug-info-global-ctor-dtor.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/debug-info-global-ctor-dtor.cpp?rev=369458&r1=369457&r2=369458&view=diff
==
--- cfe/trunk/test/CodeGenCXX/debug-info-global-ctor-dtor.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/debug-info-global-ctor-dtor.cpp Tue Aug 20 
15:09:49 2019
@@ -30,24 +30,24 @@ A FooTpl::sdm_tpl(sizeof(U) + sizeof(
 template A FooTpl::sdm_tpl;
 
 // CHECK-NOKEXT: !DISubprogram(name: "__cxx_global_var_init",{{.*}} line: 
15,{{.*}} DISPFlagLocalToUnit | DISPFlagDefinition
-// CHECK-NOKEXT: !DISubprogram(name: "__dtor_glob",{{.*}} line: 15,{{.*}} 
DISPFlagLocalToUnit | DISPFlagDefinition
+// CHECK-NOKEXT: !DISubprogram(name: "__dtor_glob",{{.*}}: DISPFlagLocalToUnit 
| DISPFlagDefinition
 // CHECK-NOKEXT: !DISubprogram(name: "__cxx_global_var_init.1",{{.*}} line: 
16,{{.*}} DISPFlagLocalToUnit | DISPFlagDefinition
 // CHECK-NOKEXT: !DISubprogram(name: "__cxx_global_array_dtor",{{.*}} line: 
16,{{.*}} DISPFlagLocalToUnit | DISPFlagDefinition
-// CHECK-NOKEXT: !DISubprogram(name: "__dtor_array",{{.*}} line: 16,{{.*}} 
DISPFlagLocalToUnit | DISPFlagDefinition
-// CHECK-NOKEXT: !DISubprogram(name: "__dtor__ZZ3foovE4stat",{{.*}} line: 
19,{{.*}} DISPFlagLocalToUnit | DISPFlagDefinition
+// CHECK-NOKEXT: !DISubprogram(name: "__dtor_array",{{.*}}: 
DISPFlagLocalToUnit | DISPFlagDefinition
+// CHECK-NOKEXT: !DISubprogram(name: "__dtor__ZZ3foovE4stat",{{.*}} 
DISPFlagLocalToUnit | DISPFlagDefinition
 // CHECK-NOKEXT: !DISubprogram({{.*}} DISPFlagLocalToUnit | DISPFlagDefinition
 
 // CHECK-KEXT: !DISubprogram({{.*}} DISPFlagLocalToUnit | DISPFlagDefinition
 
 // CHECK-MSVC: !DISubprogram(na

r369986 - [clang-scan-deps] Minimizer: Correctly handle multi-line content with CR+LF line endings

2019-08-26 Thread Alexandre Ganea via cfe-commits
Author: aganea
Date: Mon Aug 26 16:19:21 2019
New Revision: 369986

URL: http://llvm.org/viewvc/llvm-project?rev=369986&view=rev
Log:
[clang-scan-deps] Minimizer: Correctly handle multi-line content with CR+LF 
line endings

Previously, an #error directive with quoted, multi-line content, along with 
CR+LF line endings wasn't handled correctly.

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

Added:

cfe/trunk/test/Lexer/minimize_source_to_dependency_directives_invalid_error.c
Modified:
cfe/trunk/lib/Lex/DependencyDirectivesSourceMinimizer.cpp

Modified: cfe/trunk/lib/Lex/DependencyDirectivesSourceMinimizer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/DependencyDirectivesSourceMinimizer.cpp?rev=369986&r1=369985&r2=369986&view=diff
==
--- cfe/trunk/lib/Lex/DependencyDirectivesSourceMinimizer.cpp (original)
+++ cfe/trunk/lib/Lex/DependencyDirectivesSourceMinimizer.cpp Mon Aug 26 
16:19:21 2019
@@ -196,15 +196,29 @@ static void skipString(const char *&Firs
 ++First; // Finish off the string.
 }
 
-static void skipNewline(const char *&First, const char *End) {
-  assert(isVerticalWhitespace(*First));
-  ++First;
+// Returns the length of EOL, either 0 (no end-of-line), 1 (\n) or 2 (\r\n)
+static unsigned isEOL(const char *First, const char *const End) {
   if (First == End)
-return;
+return 0;
+  if (End - First > 1 && isVerticalWhitespace(First[0]) &&
+  isVerticalWhitespace(First[1]) && First[0] != First[1])
+return 2;
+  return !!isVerticalWhitespace(First[0]);
+}
+
+// Returns the length of the skipped newline
+static unsigned skipNewline(const char *&First, const char *End) {
+  if (First == End)
+return 0;
+  assert(isVerticalWhitespace(*First));
+  unsigned Len = isEOL(First, End);
+  assert(Len && "expected newline");
+  First += Len;
+  return Len;
+}
 
-  // Check for "\n\r" and "\r\n".
-  if (LLVM_UNLIKELY(isVerticalWhitespace(*First) && First[-1] != First[0]))
-++First;
+static bool wasLineContinuation(const char *First, unsigned EOLLen) {
+  return *(First - (int)EOLLen - 1) == '\\';
 }
 
 static void skipToNewlineRaw(const char *&First, const char *const End) {
@@ -212,17 +226,21 @@ static void skipToNewlineRaw(const char
 if (First == End)
   return;
 
-if (isVerticalWhitespace(*First))
+unsigned Len = isEOL(First, End);
+if (Len)
   return;
 
-while (!isVerticalWhitespace(*First))
+do {
   if (++First == End)
 return;
+  Len = isEOL(First, End);
+} while (!Len);
 
 if (First[-1] != '\\')
   return;
 
-++First; // Keep going...
+First += Len;
+// Keep skipping lines...
   }
 }
 
@@ -277,7 +295,7 @@ static bool isQuoteCppDigitSeparator(con
 }
 
 static void skipLine(const char *&First, const char *const End) {
-  do {
+  for (;;) {
 assert(First <= End);
 if (First == End)
   return;
@@ -322,9 +340,10 @@ static void skipLine(const char *&First,
   return;
 
 // Skip over the newline.
-assert(isVerticalWhitespace(*First));
-skipNewline(First, End);
-  } while (First[-2] == '\\'); // Continue past line-continuations.
+unsigned Len = skipNewline(First, End);
+if (!wasLineContinuation(First, Len)) // Continue past line-continuations.
+  break;
+  }
 }
 
 static void skipDirective(StringRef Name, const char *&First,
@@ -379,6 +398,8 @@ void Minimizer::printToNewline(const cha
 // Print out the string.
 if (Last == End || Last == First || Last[-1] != '\\') {
   append(First, reverseOverSpaces(First, Last));
+  First = Last;
+  skipNewline(First, End);
   return;
 }
 

Added: 
cfe/trunk/test/Lexer/minimize_source_to_dependency_directives_invalid_error.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Lexer/minimize_source_to_dependency_directives_invalid_error.c?rev=369986&view=auto
==
--- 
cfe/trunk/test/Lexer/minimize_source_to_dependency_directives_invalid_error.c 
(added)
+++ 
cfe/trunk/test/Lexer/minimize_source_to_dependency_directives_invalid_error.c 
Mon Aug 26 16:19:21 2019
@@ -0,0 +1,16 @@
+// Test CF+LF are properly handled along with quoted, multi-line #error
+// RUN: cat %s | unix2dos | %clang_cc1 -DOTHER 
-print-dependency-directives-minimized-source 2>&1 | FileCheck %s
+
+#ifndef TEST
+#error "message \
+   more message \
+   even more"
+#endif
+
+#ifdef OTHER
+#include 
+#endif
+
+// CHECK:  #ifdef OTHER
+// CHECK-NEXT: #include 
+// CHECK-NEXT: #endif


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


r369988 - [clang-scan-deps] Minimizer: Correctly skip over double slashes in angle bracket #include

2019-08-26 Thread Alexandre Ganea via cfe-commits
Author: aganea
Date: Mon Aug 26 16:28:05 2019
New Revision: 369988

URL: http://llvm.org/viewvc/llvm-project?rev=369988&view=rev
Log:
[clang-scan-deps] Minimizer: Correctly skip over double slashes in angle 
bracket #include

Previously, double slashes (//) occurring in angle brackets #include were 
incorrectly interpreted as comments. eg. #include 

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

Added:
cfe/trunk/test/Lexer/minimize_source_to_dependency_directives_include.c
Modified:
cfe/trunk/lib/Lex/DependencyDirectivesSourceMinimizer.cpp

Modified: cfe/trunk/lib/Lex/DependencyDirectivesSourceMinimizer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/DependencyDirectivesSourceMinimizer.cpp?rev=369988&r1=369987&r2=369988&view=diff
==
--- cfe/trunk/lib/Lex/DependencyDirectivesSourceMinimizer.cpp (original)
+++ cfe/trunk/lib/Lex/DependencyDirectivesSourceMinimizer.cpp Mon Aug 26 
16:28:05 2019
@@ -186,8 +186,8 @@ static void skipRawString(const char *&F
 }
 
 static void skipString(const char *&First, const char *const End) {
-  assert(*First == '\'' || *First == '"');
-  const char Terminator = *First;
+  assert(*First == '\'' || *First == '"' || *First == '<');
+  const char Terminator = *First == '<' ? '>' : *First;
   for (++First; First != End && *First != Terminator; ++First)
 if (*First == '\\')
   if (++First == End)
@@ -363,7 +363,8 @@ void Minimizer::printToNewline(const cha
 const char *Last = First;
 do {
   // Iterate over strings correctly to avoid comments and newlines.
-  if (*Last == '"' || *Last == '\'') {
+  if (*Last == '"' || *Last == '\'' ||
+  (*Last == '<' && top() == pp_include)) {
 if (LLVM_UNLIKELY(isRawStringLiteral(First, Last)))
   skipRawString(Last, End);
 else

Added: cfe/trunk/test/Lexer/minimize_source_to_dependency_directives_include.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Lexer/minimize_source_to_dependency_directives_include.c?rev=369988&view=auto
==
--- cfe/trunk/test/Lexer/minimize_source_to_dependency_directives_include.c 
(added)
+++ cfe/trunk/test/Lexer/minimize_source_to_dependency_directives_include.c Mon 
Aug 26 16:28:05 2019
@@ -0,0 +1,8 @@
+// Test double slashes in #include directive along with angle brackets. 
Previously, this was interpreted as comments.
+// RUN: %clang_cc1 -DTEST -print-dependency-directives-minimized-source %s 
2>&1 | FileCheck %s
+
+#include "a//b.h"
+#include 
+
+// CHECK: #include "a//b.h"
+// CHECK: #include 


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


r369993 - [clang-scan-deps] Skip UTF-8 BOM in source minimizer

2019-08-26 Thread Alexandre Ganea via cfe-commits
Author: aganea
Date: Mon Aug 26 17:13:52 2019
New Revision: 369993

URL: http://llvm.org/viewvc/llvm-project?rev=369993&view=rev
Log:
[clang-scan-deps] Skip UTF-8 BOM in source minimizer

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

Added:
cfe/trunk/test/Lexer/minimize_source_to_dependency_directives_utf8bom.c
Modified:
cfe/trunk/lib/Lex/DependencyDirectivesSourceMinimizer.cpp

Modified: cfe/trunk/lib/Lex/DependencyDirectivesSourceMinimizer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/DependencyDirectivesSourceMinimizer.cpp?rev=369993&r1=369992&r2=369993&view=diff
==
--- cfe/trunk/lib/Lex/DependencyDirectivesSourceMinimizer.cpp (original)
+++ cfe/trunk/lib/Lex/DependencyDirectivesSourceMinimizer.cpp Mon Aug 26 
17:13:52 2019
@@ -834,7 +834,14 @@ bool Minimizer::lexPPLine(const char *&F
   return lexDefault(Kind, Id.Name, First, End);
 }
 
+static void skipUTF8ByteOrderMark(const char *&First, const char *const End) {
+  if ((End - First) >= 3 && First[0] == '\xef' && First[1] == '\xbb' &&
+  First[2] == '\xbf')
+First += 3;
+}
+
 bool Minimizer::minimizeImpl(const char *First, const char *const End) {
+  skipUTF8ByteOrderMark(First, End);
   while (First != End)
 if (lexPPLine(First, End))
   return true;

Added: cfe/trunk/test/Lexer/minimize_source_to_dependency_directives_utf8bom.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Lexer/minimize_source_to_dependency_directives_utf8bom.c?rev=369993&view=auto
==
--- cfe/trunk/test/Lexer/minimize_source_to_dependency_directives_utf8bom.c 
(added)
+++ cfe/trunk/test/Lexer/minimize_source_to_dependency_directives_utf8bom.c Mon 
Aug 26 17:13:52 2019
@@ -0,0 +1,10 @@
+// Test UTF8 BOM at start of file
+// RUN: printf '\xef\xbb\xbf' > %t.c
+// RUN: echo '#ifdef TEST\n' >> %t.c
+// RUN: echo '#include ' >> %t.c
+// RUN: echo '#endif' >> %t.c
+// RUN: %clang_cc1 -DTEST -print-dependency-directives-minimized-source %t.c 
2>&1 | FileCheck %s
+
+// CHECK:  #ifdef TEST
+// CHECK-NEXT: #include 
+// CHECK-NEXT: #endif


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


RE: r369986 - [clang-scan-deps] Minimizer: Correctly handle multi-line content with CR+LF line endings

2019-08-26 Thread Alexandre Ganea via cfe-commits
I’ve changed to using svn:eol-style instead. Could you please let me know if 
that sounds better? See: https://reviews.llvm.org/D66556

De : Richard Smith 
Envoyé : August 26, 2019 9:03 PM
À : Alexandre Ganea 
Cc : cfe-commits 
Objet : Re: r369986 - [clang-scan-deps] Minimizer: Correctly handle multi-line 
content with CR+LF line endings

On Mon, 26 Aug 2019 at 16:17, Alexandre Ganea via cfe-commits 
mailto:cfe-commits@lists.llvm.org>> wrote:
Author: aganea
Date: Mon Aug 26 16:19:21 2019
New Revision: 369986

URL: http://llvm.org/viewvc/llvm-project?rev=369986&view=rev
Log:
[clang-scan-deps] Minimizer: Correctly handle multi-line content with CR+LF 
line endings

Previously, an #error directive with quoted, multi-line content, along with 
CR+LF line endings wasn't handled correctly.

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

Added:

cfe/trunk/test/Lexer/minimize_source_to_dependency_directives_invalid_error.c
Modified:
cfe/trunk/lib/Lex/DependencyDirectivesSourceMinimizer.cpp

Modified: cfe/trunk/lib/Lex/DependencyDirectivesSourceMinimizer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/DependencyDirectivesSourceMinimizer.cpp?rev=369986&r1=369985&r2=369986&view=diff
==
--- cfe/trunk/lib/Lex/DependencyDirectivesSourceMinimizer.cpp (original)
+++ cfe/trunk/lib/Lex/DependencyDirectivesSourceMinimizer.cpp Mon Aug 26 
16:19:21 2019
@@ -196,15 +196,29 @@ static void skipString(const char *&Firs
 ++First; // Finish off the string.
 }

-static void skipNewline(const char *&First, const char *End) {
-  assert(isVerticalWhitespace(*First));
-  ++First;
+// Returns the length of EOL, either 0 (no end-of-line), 1 (\n) or 2 (\r\n)
+static unsigned isEOL(const char *First, const char *const End) {
   if (First == End)
-return;
+return 0;
+  if (End - First > 1 && isVerticalWhitespace(First[0]) &&
+  isVerticalWhitespace(First[1]) && First[0] != First[1])
+return 2;
+  return !!isVerticalWhitespace(First[0]);
+}
+
+// Returns the length of the skipped newline
+static unsigned skipNewline(const char *&First, const char *End) {
+  if (First == End)
+return 0;
+  assert(isVerticalWhitespace(*First));
+  unsigned Len = isEOL(First, End);
+  assert(Len && "expected newline");
+  First += Len;
+  return Len;
+}

-  // Check for "\n\r" and "\r\n".
-  if (LLVM_UNLIKELY(isVerticalWhitespace(*First) && First[-1] != First[0]))
-++First;
+static bool wasLineContinuation(const char *First, unsigned EOLLen) {
+  return *(First - (int)EOLLen - 1) == '\\';
 }

 static void skipToNewlineRaw(const char *&First, const char *const End) {
@@ -212,17 +226,21 @@ static void skipToNewlineRaw(const char
 if (First == End)
   return;

-if (isVerticalWhitespace(*First))
+unsigned Len = isEOL(First, End);
+if (Len)
   return;

-while (!isVerticalWhitespace(*First))
+do {
   if (++First == End)
 return;
+  Len = isEOL(First, End);
+} while (!Len);

 if (First[-1] != '\\')
   return;

-++First; // Keep going...
+First += Len;
+// Keep skipping lines...
   }
 }

@@ -277,7 +295,7 @@ static bool isQuoteCppDigitSeparator(con
 }

 static void skipLine(const char *&First, const char *const End) {
-  do {
+  for (;;) {
 assert(First <= End);
 if (First == End)
   return;
@@ -322,9 +340,10 @@ static void skipLine(const char *&First,
   return;

 // Skip over the newline.
-assert(isVerticalWhitespace(*First));
-skipNewline(First, End);
-  } while (First[-2] == '\\'); // Continue past line-continuations.
+unsigned Len = skipNewline(First, End);
+if (!wasLineContinuation(First, Len)) // Continue past line-continuations.
+  break;
+  }
 }

 static void skipDirective(StringRef Name, const char *&First,
@@ -379,6 +398,8 @@ void Minimizer::printToNewline(const cha
 // Print out the string.
 if (Last == End || Last == First || Last[-1] != '\\') {
   append(First, reverseOverSpaces(First, Last));
+  First = Last;
+  skipNewline(First, End);
   return;
 }


Added: 
cfe/trunk/test/Lexer/minimize_source_to_dependency_directives_invalid_error.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Lexer/minimize_source_to_dependency_directives_invalid_error.c?rev=369986&view=auto
==
--- 
cfe/trunk/test/Lexer/minimize_source_to_dependency_directives_invalid_error.c 
(added)
+++ 
cfe/trunk/test/Lexer/minimize_source_to_dependency_directives_invalid_error.c 
Mon Aug 26 16:19:21 2019
@@ -0,0 +1,16 @@
+// Test CF+LF are properly handled along with quoted, multi-line #error
+// RUN: cat %s | unix2dos | %clang_cc1 -DOTHER 
-print-dependency-d

r370129 - Re-land [clang-scan-deps] Minimizer: Correctly handle multi-line content with CR+LF line endings

2019-08-27 Thread Alexandre Ganea via cfe-commits
Author: aganea
Date: Tue Aug 27 17:04:06 2019
New Revision: 370129

URL: http://llvm.org/viewvc/llvm-project?rev=370129&view=rev
Log:
Re-land [clang-scan-deps] Minimizer: Correctly handle multi-line content with 
CR+LF line endings

Previously, an #error directive with quoted, multi-line content, along with 
CR+LF line endings wasn't handled correctly.

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

Added:
cfe/trunk/.gitattributes

cfe/trunk/test/Lexer/minimize_source_to_dependency_directives_invalid_error.c   
(contents, props changed)
  - copied, changed from r36, 
cfe/trunk/test/Lexer/minimize_source_to_dependency_directives_invalid_error.c
Modified:
cfe/trunk/lib/Lex/DependencyDirectivesSourceMinimizer.cpp

Added: cfe/trunk/.gitattributes
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/.gitattributes?rev=370129&view=auto
==
--- cfe/trunk/.gitattributes (added)
+++ cfe/trunk/.gitattributes Tue Aug 27 17:04:06 2019
@@ -0,0 +1,4 @@
+# Windows line ending tests
+test/Lexer/minimize_source_to_dependency_directives_invalid_error.c text 
eol=crlf
+test/FixIt/fixit-newline-style.c text eol=crlf
+test/Frontend/system-header-line-directive-ms-lineendings.c text eol=crlf

Modified: cfe/trunk/lib/Lex/DependencyDirectivesSourceMinimizer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/DependencyDirectivesSourceMinimizer.cpp?rev=370129&r1=370128&r2=370129&view=diff
==
--- cfe/trunk/lib/Lex/DependencyDirectivesSourceMinimizer.cpp (original)
+++ cfe/trunk/lib/Lex/DependencyDirectivesSourceMinimizer.cpp Tue Aug 27 
17:04:06 2019
@@ -196,15 +196,29 @@ static void skipString(const char *&Firs
 ++First; // Finish off the string.
 }
 
-static void skipNewline(const char *&First, const char *End) {
-  assert(isVerticalWhitespace(*First));
-  ++First;
+// Returns the length of EOL, either 0 (no end-of-line), 1 (\n) or 2 (\r\n)
+static unsigned isEOL(const char *First, const char *const End) {
   if (First == End)
-return;
+return 0;
+  if (End - First > 1 && isVerticalWhitespace(First[0]) &&
+  isVerticalWhitespace(First[1]) && First[0] != First[1])
+return 2;
+  return !!isVerticalWhitespace(First[0]);
+}
+
+// Returns the length of the skipped newline
+static unsigned skipNewline(const char *&First, const char *End) {
+  if (First == End)
+return 0;
+  assert(isVerticalWhitespace(*First));
+  unsigned Len = isEOL(First, End);
+  assert(Len && "expected newline");
+  First += Len;
+  return Len;
+}
 
-  // Check for "\n\r" and "\r\n".
-  if (LLVM_UNLIKELY(isVerticalWhitespace(*First) && First[-1] != First[0]))
-++First;
+static bool wasLineContinuation(const char *First, unsigned EOLLen) {
+  return *(First - (int)EOLLen - 1) == '\\';
 }
 
 static void skipToNewlineRaw(const char *&First, const char *const End) {
@@ -212,17 +226,21 @@ static void skipToNewlineRaw(const char
 if (First == End)
   return;
 
-if (isVerticalWhitespace(*First))
+unsigned Len = isEOL(First, End);
+if (Len)
   return;
 
-while (!isVerticalWhitespace(*First))
+do {
   if (++First == End)
 return;
+  Len = isEOL(First, End);
+} while (!Len);
 
 if (First[-1] != '\\')
   return;
 
-++First; // Keep going...
+First += Len;
+// Keep skipping lines...
   }
 }
 
@@ -277,7 +295,7 @@ static bool isQuoteCppDigitSeparator(con
 }
 
 static void skipLine(const char *&First, const char *const End) {
-  do {
+  for (;;) {
 assert(First <= End);
 if (First == End)
   return;
@@ -322,9 +340,10 @@ static void skipLine(const char *&First,
   return;
 
 // Skip over the newline.
-assert(isVerticalWhitespace(*First));
-skipNewline(First, End);
-  } while (First[-2] == '\\'); // Continue past line-continuations.
+unsigned Len = skipNewline(First, End);
+if (!wasLineContinuation(First, Len)) // Continue past line-continuations.
+  break;
+  }
 }
 
 static void skipDirective(StringRef Name, const char *&First,
@@ -380,6 +399,8 @@ void Minimizer::printToNewline(const cha
 // Print out the string.
 if (Last == End || Last == First || Last[-1] != '\\') {
   append(First, reverseOverSpaces(First, Last));
+  First = Last;
+  skipNewline(First, End);
   return;
 }
 

Copied: 
cfe/trunk/test/Lexer/minimize_source_to_dependency_directives_invalid_error.c 
(from r36, 
cfe/trunk/test/Lexer/minimize_source_to_dependency_directives_invalid_error.c)
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Lexer/minimize_source_to_dependency_directives_invalid_error.c?p2=cfe/trunk/test/Lexer/minimize_source_to_dependency_directives_invalid_error.c&p1=cfe/trunk/test/Lexer/minimize_source_to_dependency_directives_invalid_error.c&r1=36&r2=370129&rev=370129&view=diff
=

r370219 - Try fixing CRLF issues in Git with [clang-scan-deps] Minimizer: Correctly handle multi-line content with CR+LF line endings

2019-08-28 Thread Alexandre Ganea via cfe-commits
Author: aganea
Date: Wed Aug 28 08:14:37 2019
New Revision: 370219

URL: http://llvm.org/viewvc/llvm-project?rev=370219&view=rev
Log:
Try fixing CRLF issues in Git with [clang-scan-deps] Minimizer: Correctly 
handle multi-line content with CR+LF line endings

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

Added:

cfe/trunk/test/Lexer/minimize_source_to_dependency_directives_invalid_error.c   
(with props)
Removed:
cfe/trunk/.gitattributes

Removed: cfe/trunk/.gitattributes
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/.gitattributes?rev=370218&view=auto
==
--- cfe/trunk/.gitattributes (original)
+++ cfe/trunk/.gitattributes (removed)
@@ -1,3 +0,0 @@
-# Windows line ending tests
-test/Lexer/minimize_source_to_dependency_directives_invalid_error.c text 
eol=crlf
-test/FixIt/fixit-newline-style.c text eol=crlf

Added: 
cfe/trunk/test/Lexer/minimize_source_to_dependency_directives_invalid_error.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Lexer/minimize_source_to_dependency_directives_invalid_error.c?rev=370219&view=auto
==
--- 
cfe/trunk/test/Lexer/minimize_source_to_dependency_directives_invalid_error.c 
(added)
+++ 
cfe/trunk/test/Lexer/minimize_source_to_dependency_directives_invalid_error.c 
Wed Aug 28 08:14:37 2019
@@ -0,0 +1,16 @@
+// Test CF+LF are properly handled along with quoted, multi-line #error
+// RUN: %clang_cc1 -DOTHER -print-dependency-directives-minimized-source %s 
2>&1 | FileCheck %s
+
+#ifndef TEST
+#error "message \
+   more message \
+   even more"
+#endif
+
+#ifdef OTHER
+#include 
+#endif
+
+// CHECK:  #ifdef OTHER
+// CHECK-NEXT: #include 
+// CHECK-NEXT: #endif

Propchange: 
cfe/trunk/test/Lexer/minimize_source_to_dependency_directives_invalid_error.c
--
svn:eol-style = CRLF


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


r371080 - [DebugInfo] Add debug location to stubs generated by CGDeclCXX and mark them as artificial

2019-09-05 Thread Alexandre Ganea via cfe-commits
Author: aganea
Date: Thu Sep  5 08:24:49 2019
New Revision: 371080

URL: http://llvm.org/viewvc/llvm-project?rev=371080&view=rev
Log:
[DebugInfo] Add debug location to stubs generated by CGDeclCXX and mark them as 
artificial

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

Added:
cfe/trunk/test/CodeGenCXX/debug-info-atexit-stub.cpp
cfe/trunk/test/CodeGenCXX/debug-info-destroy-helper.cpp
Modified:
cfe/trunk/include/clang/AST/GlobalDecl.h
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
cfe/trunk/lib/CodeGen/CGDeclCXX.cpp
cfe/trunk/test/CodeGenCXX/debug-info-global-ctor-dtor.cpp
cfe/trunk/test/CodeGenCXX/debug-info-line.cpp

Modified: cfe/trunk/include/clang/AST/GlobalDecl.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/GlobalDecl.h?rev=371080&r1=371079&r2=371080&view=diff
==
--- cfe/trunk/include/clang/AST/GlobalDecl.h (original)
+++ cfe/trunk/include/clang/AST/GlobalDecl.h Thu Sep  5 08:24:49 2019
@@ -31,6 +31,7 @@ enum class DynamicInitKind : unsigned {
   NoStub = 0,
   Initializer,
   AtExit,
+  GlobalArrayDestructor
 };
 
 /// GlobalDecl - represents a global declaration. This can either be a

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=371080&r1=371079&r2=371080&view=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Thu Sep  5 08:24:49 2019
@@ -1910,7 +1910,8 @@ StringRef CGDebugInfo::getDynamicInitial
  llvm::Function *InitFn) {
   // If we're not emitting codeview, use the mangled name. For Itanium, this is
   // arbitrary.
-  if (!CGM.getCodeGenOpts().EmitCodeView)
+  if (!CGM.getCodeGenOpts().EmitCodeView ||
+  StubKind == DynamicInitKind::GlobalArrayDestructor)
 return InitFn->getName();
 
   // Print the normal qualified name for the variable, then break off the last
@@ -1935,6 +1936,7 @@ StringRef CGDebugInfo::getDynamicInitial
 
   switch (StubKind) {
   case DynamicInitKind::NoStub:
+  case DynamicInitKind::GlobalArrayDestructor:
 llvm_unreachable("not an initializer");
   case DynamicInitKind::Initializer:
 OS << "`dynamic initializer for '";
@@ -3569,7 +3571,8 @@ void CGDebugInfo::EmitFunctionStart(Glob
   if (Name.startswith("\01"))
 Name = Name.substr(1);
 
-  if (!HasDecl || D->isImplicit() || D->hasAttr()) {
+  if (!HasDecl || D->isImplicit() || D->hasAttr() ||
+  (isa(D) && GD.getDynamicInitKind() != DynamicInitKind::NoStub)) 
{
 Flags |= llvm::DINode::FlagArtificial;
 // Artificial functions should not silently reuse CurLoc.
 CurLoc = SourceLocation();

Modified: cfe/trunk/lib/CodeGen/CGDeclCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDeclCXX.cpp?rev=371080&r1=371079&r2=371080&view=diff
==
--- cfe/trunk/lib/CodeGen/CGDeclCXX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDeclCXX.cpp Thu Sep  5 08:24:49 2019
@@ -247,6 +247,8 @@ llvm::Function *CodeGenFunction::createA
 
   CGF.StartFunction(GlobalDecl(&VD, DynamicInitKind::AtExit),
 CGM.getContext().VoidTy, fn, FI, FunctionArgList());
+  // Emit an artificial location for this function.
+  auto AL = ApplyDebugLocation::CreateArtificial(CGF);
 
   llvm::CallInst *call = CGF.Builder.CreateCall(dtor, addr);
 
@@ -642,8 +644,9 @@ void CodeGenFunction::GenerateCXXGlobalV
 
   StartFunction(GlobalDecl(D, DynamicInitKind::Initializer),
 getContext().VoidTy, Fn, getTypes().arrangeNullaryFunction(),
-FunctionArgList(), D->getLocation(),
-D->getInit()->getExprLoc());
+FunctionArgList());
+  // Emit an artificial location for this function.
+  auto AL = ApplyDebugLocation::CreateArtificial(*this);
 
   // Use guarded initialization if the global variable is weak. This
   // occurs for, e.g., instantiated static data members and
@@ -768,7 +771,10 @@ llvm::Function *CodeGenFunction::generat
 
   CurEHLocation = VD->getBeginLoc();
 
-  StartFunction(VD, getContext().VoidTy, fn, FI, args);
+  StartFunction(GlobalDecl(VD, DynamicInitKind::GlobalArrayDestructor),
+getContext().VoidTy, fn, FI, args);
+  // Emit an artificial location for this function.
+  auto AL = ApplyDebugLocation::CreateArtificial(*this);
 
   emitDestroy(addr, type, destroyer, useEHCleanupForArray);
 

Added: cfe/trunk/test/CodeGenCXX/debug-info-atexit-stub.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/debug-info-atexit-stub.cpp?rev=371080&view=auto
==
--- cfe/trunk/test/CodeGenCXX/debug-info-atexit-stub.cpp (added)
+++ cfe/trunk/test/CodeGenCXX/debug-info-atexit-st

r371113 - Revert: [DebugInfo] Add debug location to stubs generated by CGDeclCXX and mark them as artificial

2019-09-05 Thread Alexandre Ganea via cfe-commits
Author: aganea
Date: Thu Sep  5 13:12:20 2019
New Revision: 371113

URL: http://llvm.org/viewvc/llvm-project?rev=371113&view=rev
Log:
Revert: [DebugInfo] Add debug location to stubs generated by CGDeclCXX and mark 
them as artificial

Removed:
cfe/trunk/test/CodeGenCXX/debug-info-atexit-stub.cpp
cfe/trunk/test/CodeGenCXX/debug-info-destroy-helper.cpp
Modified:
cfe/trunk/include/clang/AST/GlobalDecl.h
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
cfe/trunk/lib/CodeGen/CGDeclCXX.cpp
cfe/trunk/test/CodeGenCXX/debug-info-global-ctor-dtor.cpp
cfe/trunk/test/CodeGenCXX/debug-info-line.cpp

Modified: cfe/trunk/include/clang/AST/GlobalDecl.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/GlobalDecl.h?rev=371113&r1=371112&r2=371113&view=diff
==
--- cfe/trunk/include/clang/AST/GlobalDecl.h (original)
+++ cfe/trunk/include/clang/AST/GlobalDecl.h Thu Sep  5 13:12:20 2019
@@ -31,7 +31,6 @@ enum class DynamicInitKind : unsigned {
   NoStub = 0,
   Initializer,
   AtExit,
-  GlobalArrayDestructor
 };
 
 /// GlobalDecl - represents a global declaration. This can either be a

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=371113&r1=371112&r2=371113&view=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Thu Sep  5 13:12:20 2019
@@ -1910,8 +1910,7 @@ StringRef CGDebugInfo::getDynamicInitial
  llvm::Function *InitFn) {
   // If we're not emitting codeview, use the mangled name. For Itanium, this is
   // arbitrary.
-  if (!CGM.getCodeGenOpts().EmitCodeView ||
-  StubKind == DynamicInitKind::GlobalArrayDestructor)
+  if (!CGM.getCodeGenOpts().EmitCodeView)
 return InitFn->getName();
 
   // Print the normal qualified name for the variable, then break off the last
@@ -1936,7 +1935,6 @@ StringRef CGDebugInfo::getDynamicInitial
 
   switch (StubKind) {
   case DynamicInitKind::NoStub:
-  case DynamicInitKind::GlobalArrayDestructor:
 llvm_unreachable("not an initializer");
   case DynamicInitKind::Initializer:
 OS << "`dynamic initializer for '";
@@ -3571,8 +3569,7 @@ void CGDebugInfo::EmitFunctionStart(Glob
   if (Name.startswith("\01"))
 Name = Name.substr(1);
 
-  if (!HasDecl || D->isImplicit() || D->hasAttr() ||
-  (isa(D) && GD.getDynamicInitKind() != DynamicInitKind::NoStub)) 
{
+  if (!HasDecl || D->isImplicit() || D->hasAttr()) {
 Flags |= llvm::DINode::FlagArtificial;
 // Artificial functions should not silently reuse CurLoc.
 CurLoc = SourceLocation();

Modified: cfe/trunk/lib/CodeGen/CGDeclCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDeclCXX.cpp?rev=371113&r1=371112&r2=371113&view=diff
==
--- cfe/trunk/lib/CodeGen/CGDeclCXX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDeclCXX.cpp Thu Sep  5 13:12:20 2019
@@ -247,8 +247,6 @@ llvm::Function *CodeGenFunction::createA
 
   CGF.StartFunction(GlobalDecl(&VD, DynamicInitKind::AtExit),
 CGM.getContext().VoidTy, fn, FI, FunctionArgList());
-  // Emit an artificial location for this function.
-  auto AL = ApplyDebugLocation::CreateArtificial(CGF);
 
   llvm::CallInst *call = CGF.Builder.CreateCall(dtor, addr);
 
@@ -644,9 +642,8 @@ void CodeGenFunction::GenerateCXXGlobalV
 
   StartFunction(GlobalDecl(D, DynamicInitKind::Initializer),
 getContext().VoidTy, Fn, getTypes().arrangeNullaryFunction(),
-FunctionArgList());
-  // Emit an artificial location for this function.
-  auto AL = ApplyDebugLocation::CreateArtificial(*this);
+FunctionArgList(), D->getLocation(),
+D->getInit()->getExprLoc());
 
   // Use guarded initialization if the global variable is weak. This
   // occurs for, e.g., instantiated static data members and
@@ -771,10 +768,7 @@ llvm::Function *CodeGenFunction::generat
 
   CurEHLocation = VD->getBeginLoc();
 
-  StartFunction(GlobalDecl(VD, DynamicInitKind::GlobalArrayDestructor),
-getContext().VoidTy, fn, FI, args);
-  // Emit an artificial location for this function.
-  auto AL = ApplyDebugLocation::CreateArtificial(*this);
+  StartFunction(VD, getContext().VoidTy, fn, FI, args);
 
   emitDestroy(addr, type, destroyer, useEHCleanupForArray);
 

Removed: cfe/trunk/test/CodeGenCXX/debug-info-atexit-stub.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/debug-info-atexit-stub.cpp?rev=371112&view=auto
==
--- cfe/trunk/test/CodeGenCXX/debug-info-atexit-stub.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/debug-info-atexit-stub.cpp (removed)
@@ -1,20 +0,0 @@
-// RUN

RE: r371080 - [DebugInfo] Add debug location to stubs generated by CGDeclCXX and mark them as artificial

2019-09-09 Thread Alexandre Ganea via cfe-commits
Hi David,

I've reverted the patch in r371113. It was causing crashes in asan on Linux & 
Darwin.
Before re-landing the patch, it needs this: https://reviews.llvm.org/D67283

Alex.

-Message d'origine-
De : David Blaikie  
Envoyé : September 9, 2019 6:12 PM
À : Erik Pilkington 
Cc : Alexandre Ganea ; cfe-commits 

Objet : Re: r371080 - [DebugInfo] Add debug location to stubs generated by 
CGDeclCXX and mark them as artificial

Any resolution/discussion on this crash?

On Thu, Sep 5, 2019 at 12:49 PM Erik Pilkington via cfe-commits 
 wrote:
>
> Hi Alexandre,
>
> Looks like this commit is causing crashes on darwin, can you take a 
> look please? Here is a failing bot: 
> http://lab.llvm.org:8080/green/job/clang-stage1-RA/1671/
>
> Thanks!
> Erik
>
> On Thu, Sep 5, 2019 at 11:23 AM Alexandre Ganea via cfe-commits 
>  wrote:
>>
>> Author: aganea
>> Date: Thu Sep  5 08:24:49 2019
>> New Revision: 371080
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=371080&view=rev
>> Log:
>> [DebugInfo] Add debug location to stubs generated by CGDeclCXX and 
>> mark them as artificial
>>
>> Differential Revision: https://reviews.llvm.org/D66328
>>
>> Added:
>> cfe/trunk/test/CodeGenCXX/debug-info-atexit-stub.cpp
>> cfe/trunk/test/CodeGenCXX/debug-info-destroy-helper.cpp
>> Modified:
>> cfe/trunk/include/clang/AST/GlobalDecl.h
>> cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
>> cfe/trunk/lib/CodeGen/CGDeclCXX.cpp
>> cfe/trunk/test/CodeGenCXX/debug-info-global-ctor-dtor.cpp
>> cfe/trunk/test/CodeGenCXX/debug-info-line.cpp
>>
>> Modified: cfe/trunk/include/clang/AST/GlobalDecl.h
>> URL: 
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Globa
>> lDecl.h?rev=371080&r1=371079&r2=371080&view=diff
>> =
>> =
>> --- cfe/trunk/include/clang/AST/GlobalDecl.h (original)
>> +++ cfe/trunk/include/clang/AST/GlobalDecl.h Thu Sep  5 08:24:49 2019
>> @@ -31,6 +31,7 @@ enum class DynamicInitKind : unsigned {
>>NoStub = 0,
>>Initializer,
>>AtExit,
>> +  GlobalArrayDestructor
>>  };
>>
>>  /// GlobalDecl - represents a global declaration. This can either be 
>> a
>>
>> Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
>> URL: 
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo
>> .cpp?rev=371080&r1=371079&r2=371080&view=diff
>> =
>> =
>> --- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
>> +++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Thu Sep  5 08:24:49 2019
>> @@ -1910,7 +1910,8 @@ StringRef CGDebugInfo::getDynamicInitial
>>   llvm::Function *InitFn) {
>>// If we're not emitting codeview, use the mangled name. For Itanium, 
>> this is
>>// arbitrary.
>> -  if (!CGM.getCodeGenOpts().EmitCodeView)
>> +  if (!CGM.getCodeGenOpts().EmitCodeView ||
>> +  StubKind == DynamicInitKind::GlobalArrayDestructor)
>>  return InitFn->getName();
>>
>>// Print the normal qualified name for the variable, then break 
>> off the last @@ -1935,6 +1936,7 @@ StringRef 
>> CGDebugInfo::getDynamicInitial
>>
>>switch (StubKind) {
>>case DynamicInitKind::NoStub:
>> +  case DynamicInitKind::GlobalArrayDestructor:
>>  llvm_unreachable("not an initializer");
>>case DynamicInitKind::Initializer:
>>  OS << "`dynamic initializer for '"; @@ -3569,7 +3571,8 @@ void 
>> CGDebugInfo::EmitFunctionStart(Glob
>>if (Name.startswith("\01"))
>>  Name = Name.substr(1);
>>
>> -  if (!HasDecl || D->isImplicit() || D->hasAttr()) {
>> +  if (!HasDecl || D->isImplicit() || D->hasAttr() ||
>> +  (isa(D) && GD.getDynamicInitKind() != 
>> + DynamicInitKind::NoStub)) {
>>  Flags |= llvm::DINode::FlagArtificial;
>>  // Artificial functions should not silently reuse CurLoc.
>>  CurLoc = SourceLocation();
>>
>> Modified: cfe/trunk/lib/CodeGen/CGDeclCXX.cpp
>> URL: 
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDeclCXX.c
>> pp?rev=371080&r1=371079&r2=371080&view=diff
>> =
>> =
>> --- cfe/trunk/lib/CodeGen/CGDeclCXX.cpp (original)
>> +++ cfe/trunk/lib/CodeGen/CGDeclCXX.cpp Thu Sep  

[clang-tools-extra] 75eacbf - Fix issues reported by -Wrange-loop-analysis when building with latest Clang (trunk). NFC.

2020-01-07 Thread Alexandre Ganea via cfe-commits

Author: Alexandre Ganea
Date: 2020-01-07T13:58:26-05:00
New Revision: 75eacbf1a9fbc29432a6e0c5627e6c8e95683956

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

LOG: Fix issues reported by -Wrange-loop-analysis when building with latest 
Clang (trunk). NFC.

Fixes warning: loop variable 'E' of type 'const llvm::StringRef' creates a copy 
from type 'const llvm::StringRef' [-Wrange-loop-analysis]

Added: 


Modified: 
clang-tools-extra/clangd/unittests/ParsedASTTests.cpp
clang-tools-extra/clangd/unittests/RenameTests.cpp
llvm/lib/Support/Windows/Program.inc

Removed: 




diff  --git a/clang-tools-extra/clangd/unittests/ParsedASTTests.cpp 
b/clang-tools-extra/clangd/unittests/ParsedASTTests.cpp
index d7100980367d..85b8f436dd05 100644
--- a/clang-tools-extra/clangd/unittests/ParsedASTTests.cpp
+++ b/clang-tools-extra/clangd/unittests/ParsedASTTests.cpp
@@ -56,7 +56,7 @@ MATCHER_P(WithTemplateArgs, ArgName, "") {
   LangOptions LO;
   PrintingPolicy Policy(LO);
   Policy.adjustForCPlusPlus();
-  for (const auto Arg : Args->asArray()) {
+  for (const auto &Arg : Args->asArray()) {
 if (SpecializationArgs.size() > 0)
   SpecializationArgs += ",";
 SpecializationArgs += Arg.getAsType().getAsString(Policy);

diff  --git a/clang-tools-extra/clangd/unittests/RenameTests.cpp 
b/clang-tools-extra/clangd/unittests/RenameTests.cpp
index be491546aca8..6ced22bf3515 100644
--- a/clang-tools-extra/clangd/unittests/RenameTests.cpp
+++ b/clang-tools-extra/clangd/unittests/RenameTests.cpp
@@ -404,7 +404,7 @@ TEST(RenameTest, WithinFileRename) {
 template <> struct Bar<[[Foo]]> {};
   )cpp",
   };
-  for (const auto T : Tests) {
+  for (llvm::StringRef T : Tests) {
 Annotations Code(T);
 auto TU = TestTU::withCode(Code.code());
 TU.ExtraArgs.push_back("-fno-delayed-template-parsing");

diff  --git a/llvm/lib/Support/Windows/Program.inc 
b/llvm/lib/Support/Windows/Program.inc
index a23ed95fc390..a1482bf17c60 100644
--- a/llvm/lib/Support/Windows/Program.inc
+++ b/llvm/lib/Support/Windows/Program.inc
@@ -197,7 +197,7 @@ static bool Execute(ProcessInfo &PI, StringRef Program,
 // An environment block consists of a null-terminated block of
 // null-terminated strings. Convert the array of environment variables to
 // an environment block by concatenating them.
-for (const auto E : *Env) {
+for (StringRef E : *Env) {
   SmallVector EnvString;
   if (std::error_code ec = windows::UTF8ToUTF16(E, EnvString)) {
 SetLastError(ec.value());



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


[clang] de0a224 - Remove umask tests

2020-01-10 Thread Alexandre Ganea via cfe-commits

Author: Alexandre Ganea
Date: 2020-01-10T21:05:59-05:00
New Revision: de0a2247115729eade8249267a47f96f070a7666

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

LOG: Remove umask tests

These tests were added in 18627115f4d2db5dc73207e0b5312f52536be7dd and 
e08b59f81d950bd5c8b8528fcb3ac4230c7b736c for validating a refactoring.
Removing because they break on ACL-controlled folders on Ubuntu, and their 
added value is low.

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

Added: 


Modified: 


Removed: 
clang/test/Misc/permissions.cpp
llvm/test/Other/umask.ll



diff  --git a/clang/test/Misc/permissions.cpp b/clang/test/Misc/permissions.cpp
deleted file mode 100644
index 83f6c5720809..
--- a/clang/test/Misc/permissions.cpp
+++ /dev/null
@@ -1,11 +0,0 @@
-// REQUIRES: shell
-
-// RUN: umask 000
-// RUN: %clang_cc1 -emit-llvm-bc %s -o %t
-// RUN: ls -l %t | FileCheck --check-prefix=CHECK000 %s
-// CHECK000: rw-rw-rw-
-
-// RUN: umask 002
-// RUN: %clang_cc1 -emit-llvm-bc %s -o %t
-// RUN: ls -l %t | FileCheck --check-prefix=CHECK002 %s
-// CHECK002: rw-rw-r--

diff  --git a/llvm/test/Other/umask.ll b/llvm/test/Other/umask.ll
deleted file mode 100644
index 413458006a5a..
--- a/llvm/test/Other/umask.ll
+++ /dev/null
@@ -1,14 +0,0 @@
-; REQUIRES: shell
-; XFAIL: windows-gnu
-
-; RUN: umask 000
-; RUN: rm -f %t.000
-; RUN: llvm-as %s -o %t.000
-; RUN: ls -l %t.000 | FileCheck --check-prefix=CHECK000 %s
-; CHECK000: rw-rw-rw
-
-; RUN: umask 002
-; RUN: rm -f %t.002
-; RUN: llvm-as %s -o %t.002
-; RUN: ls -l %t.002 | FileCheck --check-prefix=CHECK002 %s
-; CHECK002: rw-rw-r-



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


[clang] b4a99a0 - [Clang][Driver] Re-use the calling process instead of creating a new process for the cc1 invocation

2020-01-13 Thread Alexandre Ganea via cfe-commits

Author: Alexandre Ganea
Date: 2020-01-13T10:40:18-05:00
New Revision: b4a99a061f517e60985667e39519f60186cbb469

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

LOG: [Clang][Driver] Re-use the calling process instead of creating a new 
process for the cc1 invocation

With this patch, the clang tool will now call the -cc1 invocation directly 
inside the same process. Previously, the -cc1 invocation was creating, and 
waiting for, a new process.
This patch therefore reduces the number of created processes during a build, 
thus it reduces build times on platforms where process creation can be costly 
(Windows) and/or impacted by a antivirus.
It also makes debugging a bit easier, as there's no need to attach to the 
secondary -cc1 process anymore, breakpoints will be hit inside the same process.

Crashes or signaling inside the -cc1 invocation will have the same side-effect 
as before, and will be reported through the same means.

This behavior can be controlled at compile-time through the CLANG_SPAWN_CC1 
cmake flag, which defaults to OFF. Setting it to ON will revert to the previous 
behavior, where any -cc1 invocation will create/fork a secondary process.
At run-time, it is also possible to tweak the CLANG_SPAWN_CC1 environment 
variable. Setting it and will override the compile-time setting. A value of 0 
calls -cc1 inside the calling process; a value of 1 will create a secondary 
process, as before.

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

Added: 
clang/test/Driver/cc1-spawnprocess.c

Modified: 
clang/CMakeLists.txt
clang/include/clang/Config/config.h.cmake
clang/include/clang/Driver/Driver.h
clang/include/clang/Driver/Job.h
clang/lib/Driver/Job.cpp
clang/lib/Driver/ToolChains/Clang.cpp
clang/test/CMakeLists.txt
clang/test/Driver/clang_f_opts.c
clang/test/Driver/fsanitize-blacklist.c
clang/test/Driver/unknown-arg.c
clang/test/Driver/warning-options_pedantic.cpp
clang/tools/driver/driver.cpp

Removed: 




diff  --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt
index bc172b468512..781c3eb7f2f2 100644
--- a/clang/CMakeLists.txt
+++ b/clang/CMakeLists.txt
@@ -237,6 +237,9 @@ set(ENABLE_X86_RELAX_RELOCATIONS OFF CACHE BOOL
 set(ENABLE_EXPERIMENTAL_NEW_PASS_MANAGER FALSE CACHE BOOL
   "Enable the experimental new pass manager by default.")
 
+set(CLANG_SPAWN_CC1 OFF CACHE BOOL
+"Whether clang should use a new process for the CC1 invocation")
+
 # TODO: verify the values against LangStandards.def?
 set(CLANG_DEFAULT_STD_C "" CACHE STRING
   "Default standard to use for C/ObjC code (IDENT from LangStandards.def, 
empty for platform default)")

diff  --git a/clang/include/clang/Config/config.h.cmake 
b/clang/include/clang/Config/config.h.cmake
index 68125dbc6d4b..261b3841b86f 100644
--- a/clang/include/clang/Config/config.h.cmake
+++ b/clang/include/clang/Config/config.h.cmake
@@ -80,4 +80,7 @@
 #cmakedefine01 CLANG_ENABLE_OBJC_REWRITER
 #cmakedefine01 CLANG_ENABLE_STATIC_ANALYZER
 
+/* Spawn a new process clang.exe for the CC1 tool invocation, when necessary */
+#cmakedefine01 CLANG_SPAWN_CC1
+
 #endif

diff  --git a/clang/include/clang/Driver/Driver.h 
b/clang/include/clang/Driver/Driver.h
index d667fcb1efef..fd25663bd358 100644
--- a/clang/include/clang/Driver/Driver.h
+++ b/clang/include/clang/Driver/Driver.h
@@ -204,6 +204,13 @@ class Driver {
   /// Whether the driver is generating diagnostics for debugging purposes.
   unsigned CCGenDiagnostics : 1;
 
+  /// Pointer to the ExecuteCC1Tool function, if available.
+  /// When the clangDriver lib is used through clang.exe, this provides a
+  /// shortcut for executing the -cc1 command-line directly, in the same
+  /// process.
+  typedef int (*CC1ToolFunc)(ArrayRef argv);
+  CC1ToolFunc CC1Main = nullptr;
+
 private:
   /// Raw target triple.
   std::string TargetTriple;

diff  --git a/clang/include/clang/Driver/Job.h 
b/clang/include/clang/Driver/Job.h
index 41d972280852..0765b3c67d4e 100644
--- a/clang/include/clang/Driver/Job.h
+++ b/clang/include/clang/Driver/Job.h
@@ -119,7 +119,7 @@ class Command {
   /// \param NewEnvironment An array of environment variables.
   /// \remark If the environment remains unset, then the environment
   /// from the parent process will be used.
-  void setEnvironment(llvm::ArrayRef NewEnvironment);
+  virtual void setEnvironment(llvm::ArrayRef NewEnvironment);
 
   const char *getExecutable() const { return Executable; }
 
@@ -130,6 +130,24 @@ class Command {
 
   /// Set whether to print the input filenames when executing.
   void setPrintInputFilenames(bool P) { PrintInputFilenames = P; }
+
+protected:
+  /// Optionally print the filenames to be compiled
+  void PrintFileNames() const;
+};
+
+/// Use the CC1 tool callback

[clang] 88b8cb7 - Fix NetBSD bot after b4a99a061f517e60985667e39519f60186cbb469 ([Clang][Driver] Re-use the calling process instead of creating a new process for the cc1 invocation)

2020-01-14 Thread Alexandre Ganea via cfe-commits

Author: Alexandre Ganea
Date: 2020-01-14T14:26:50-05:00
New Revision: 88b8cb7215d4333ab990c99f21c7f92262ef02ef

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

LOG: Fix NetBSD bot after b4a99a061f517e60985667e39519f60186cbb469 
([Clang][Driver] Re-use the calling process instead of creating a new process 
for the cc1 invocation)

Added: 


Modified: 
clang/test/Driver/cc1-spawnprocess.c

Removed: 




diff  --git a/clang/test/Driver/cc1-spawnprocess.c 
b/clang/test/Driver/cc1-spawnprocess.c
index 5b2129ad309e..db13d8ce85d9 100644
--- a/clang/test/Driver/cc1-spawnprocess.c
+++ b/clang/test/Driver/cc1-spawnprocess.c
@@ -1,4 +1,4 @@
-// RUN: env -u CLANG_SPAWN_CC1 %clang -c %s -o /dev/null
+// RUN: env CLANG_SPAWN_CC1= %clang -c %s -o /dev/null
 // RUN: env CLANG_SPAWN_CC1=0 %clang -c %s -o /dev/null
 // RUN: env CLANG_SPAWN_CC1=1 %clang -c %s -o /dev/null
 // RUN: env CLANG_SPAWN_CC1=test not %clang -c %s -o /dev/null



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


[clang] f5314d1 - [Support] On Unix, let the CrashRecoveryContext return the signal code

2020-09-24 Thread Alexandre Ganea via cfe-commits

Author: Alexandre Ganea
Date: 2020-09-24T08:21:43-04:00
New Revision: f5314d15af4f4514103ea12c74cb208538b8bef5

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

LOG: [Support] On Unix, let the CrashRecoveryContext return the signal code

Before this patch, the CrashRecoveryContext was returning -2 upon a signal, 
like ExecuteAndWait does. This didn't match the behavior on Windows, where the 
the exception code was returned.

We now return the signal's code, which optionally allows for re-throwing the 
signal later. Doing so requires all custom handlers to be removed first, 
through llvm::sys::unregisterHandlers() which we made a public API.

This is part of https://reviews.llvm.org/D70378

Added: 


Modified: 
clang/tools/driver/driver.cpp
llvm/include/llvm/Support/Signals.h
llvm/lib/Support/CrashRecoveryContext.cpp
llvm/lib/Support/Unix/Signals.inc
llvm/lib/Support/Windows/Signals.inc
llvm/unittests/Support/CrashRecoveryTest.cpp

Removed: 




diff  --git a/clang/tools/driver/driver.cpp b/clang/tools/driver/driver.cpp
index f24fd61e61a5..f67af6790fff 100644
--- a/clang/tools/driver/driver.cpp
+++ b/clang/tools/driver/driver.cpp
@@ -531,6 +531,13 @@ int main(int argc_, const char **argv_) {
   IsCrash = CommandRes < 0 || CommandRes == 70;
 #ifdef _WIN32
   IsCrash |= CommandRes == 3;
+#endif
+#if LLVM_ON_UNIX
+  // When running in integrated-cc1 mode, the CrashRecoveryContext returns
+  // the same codes as if the program crashed. See section "Exit Status for
+  // Commands":
+  // 
https://pubs.opengroup.org/onlinepubs/9699919799/xrat/V4_xcu_chap02.html
+  IsCrash |= CommandRes > 128;
 #endif
   if (IsCrash) {
 TheDriver.generateCompilationDiagnostics(*C, *FailingCommand);

diff  --git a/llvm/include/llvm/Support/Signals.h 
b/llvm/include/llvm/Support/Signals.h
index c5b94f5ac776..44f5a750ff5c 100644
--- a/llvm/include/llvm/Support/Signals.h
+++ b/llvm/include/llvm/Support/Signals.h
@@ -117,6 +117,8 @@ namespace sys {
   /// Context is a system-specific failure context: it is the signal type on
   /// Unix; the ExceptionContext on Windows.
   void CleanupOnSignal(uintptr_t Context);
+
+  void unregisterHandlers();
 } // End sys namespace
 } // End llvm namespace
 

diff  --git a/llvm/lib/Support/CrashRecoveryContext.cpp 
b/llvm/lib/Support/CrashRecoveryContext.cpp
index 2a41754c7786..7609f04cf68c 100644
--- a/llvm/lib/Support/CrashRecoveryContext.cpp
+++ b/llvm/lib/Support/CrashRecoveryContext.cpp
@@ -375,9 +375,10 @@ static void CrashRecoverySignalHandler(int Signal) {
   sigaddset(&SigMask, Signal);
   sigprocmask(SIG_UNBLOCK, &SigMask, nullptr);
 
-  // As per convention, -2 indicates a crash or timeout as opposed to failure 
to
-  // execute (see llvm/include/llvm/Support/Program.h)
-  int RetCode = -2;
+  // Return the same error code as if the program crashed, as mentioned in the
+  // section "Exit Status for Commands":
+  // https://pubs.opengroup.org/onlinepubs/9699919799/xrat/V4_xcu_chap02.html
+  int RetCode = 128 + Signal;
 
   // Don't consider a broken pipe as a crash (see clang/lib/Driver/Driver.cpp)
   if (Signal == SIGPIPE)

diff  --git a/llvm/lib/Support/Unix/Signals.inc 
b/llvm/lib/Support/Unix/Signals.inc
index 50b2ad4b5772..03181a713257 100644
--- a/llvm/lib/Support/Unix/Signals.inc
+++ b/llvm/lib/Support/Unix/Signals.inc
@@ -331,7 +331,7 @@ static void RegisterHandlers() { // Not signal-safe.
 registerHandler(S, SignalKind::IsInfo);
 }
 
-static void UnregisterHandlers() {
+void sys::unregisterHandlers() {
   // Restore all of the signal handlers to how they were before we showed up.
   for (unsigned i = 0, e = NumRegisteredSignals.load(); i != e; ++i) {
 sigaction(RegisteredSignalInfo[i].SigNo,
@@ -367,7 +367,7 @@ static RETSIGTYPE SignalHandler(int Sig) {
   // crashes when we return and the signal reissues.  This also ensures that if
   // we crash in our signal handler that the program will terminate immediately
   // instead of recursing in the signal handler.
-  UnregisterHandlers();
+  sys::unregisterHandlers();
 
   // Unmask all potentially blocked kill signals.
   sigset_t SigMask;

diff  --git a/llvm/lib/Support/Windows/Signals.inc 
b/llvm/lib/Support/Windows/Signals.inc
index 71dc6324e99f..3758582b35f7 100644
--- a/llvm/lib/Support/Windows/Signals.inc
+++ b/llvm/lib/Support/Windows/Signals.inc
@@ -869,3 +869,5 @@ static BOOL WINAPI LLVMConsoleCtrlHandler(DWORD dwCtrlType) 
{
  #pragma GCC diagnostic warning "-Wformat"
  #pragma GCC diagnostic warning "-Wformat-extra-args"
 #endif
+
+void sys::unregisterHandlers() {}

diff  --git a/llvm/unittests/Support/CrashRecoveryTest.cpp 
b/llvm/unittests/Support/CrashRecoveryTest.cpp
index a8040dc0110e..fc65bf6329b3 100644
--- a/llvm/unit

[clang] 33ce275 - [Clang] Fix tests following rG087047144210

2020-08-26 Thread Alexandre Ganea via cfe-commits

Author: Alexandre Ganea
Date: 2020-08-26T11:32:46-04:00
New Revision: 33ce275fc156c8b015acfad918937028b2cc235c

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

LOG: [Clang] Fix tests following rG087047144210

Added: 


Modified: 
clang/test/Driver/cl-options.c

Removed: 




diff  --git a/clang/test/Driver/cl-options.c b/clang/test/Driver/cl-options.c
index f4d2d66129b0..89dbdebbaf69 100644
--- a/clang/test/Driver/cl-options.c
+++ b/clang/test/Driver/cl-options.c
@@ -688,7 +688,7 @@
 
 // Validate that built-in include paths are based on the supplied path
 // RUN: %clang_cl -vctoolsdir "/fake" -### -- %s 2>&1 | FileCheck %s 
--check-prefix FAKEDIR
-// FAKEDIR: "-internal-isystem" "/fake{{.}}include"
-// FAKEDIR: "-internal-isystem" "/fake{{.}}atlmfc{{.}}include"
+// FAKEDIR: "-internal-isystem" "/fake{{/|}}include"
+// FAKEDIR: "-internal-isystem" "/fake{{/|}}atlmfc{{/|}}include"
 
 void f() { }



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


[clang] 69132d1 - [Clang] Reverse test to save on indentation. NFC.

2020-12-23 Thread Alexandre Ganea via cfe-commits

Author: Alexandre Ganea
Date: 2020-12-23T19:24:53-05:00
New Revision: 69132d12deae749a8e4c9def5498ffa354ce1fa6

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

LOG: [Clang] Reverse test to save on indentation. NFC.

Added: 


Modified: 
clang/lib/CodeGen/CodeGenAction.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CodeGenAction.cpp 
b/clang/lib/CodeGen/CodeGenAction.cpp
index 5b23b6d2b7f5..778d4df3c2e9 100644
--- a/clang/lib/CodeGen/CodeGenAction.cpp
+++ b/clang/lib/CodeGen/CodeGenAction.cpp
@@ -1078,78 +1078,74 @@ CodeGenAction::loadModule(MemoryBufferRef MBRef) {
 }
 
 void CodeGenAction::ExecuteAction() {
-  // If this is an IR file, we have to treat it specially.
-  if (getCurrentFileKind().getLanguage() == Language::LLVM_IR) {
-BackendAction BA = static_cast(Act);
-CompilerInstance &CI = getCompilerInstance();
-auto &CodeGenOpts = CI.getCodeGenOpts();
-auto &Diagnostics = CI.getDiagnostics();
-std::unique_ptr OS =
-GetOutputStream(CI, getCurrentFile(), BA);
-if (BA != Backend_EmitNothing && !OS)
-  return;
-
-SourceManager &SM = CI.getSourceManager();
-FileID FID = SM.getMainFileID();
-Optional MainFile = SM.getBufferOrNone(FID);
-if (!MainFile)
-  return;
+  if (getCurrentFileKind().getLanguage() != Language::LLVM_IR) {
+this->ASTFrontendAction::ExecuteAction();
+return;
+  }
 
-TheModule = loadModule(*MainFile);
-if (!TheModule)
-  return;
+  // If this is an IR file, we have to treat it specially.
+  BackendAction BA = static_cast(Act);
+  CompilerInstance &CI = getCompilerInstance();
+  auto &CodeGenOpts = CI.getCodeGenOpts();
+  auto &Diagnostics = CI.getDiagnostics();
+  std::unique_ptr OS =
+  GetOutputStream(CI, getCurrentFile(), BA);
+  if (BA != Backend_EmitNothing && !OS)
+return;
 
-const TargetOptions &TargetOpts = CI.getTargetOpts();
-if (TheModule->getTargetTriple() != TargetOpts.Triple) {
-  Diagnostics.Report(SourceLocation(),
- diag::warn_fe_override_module)
-  << TargetOpts.Triple;
-  TheModule->setTargetTriple(TargetOpts.Triple);
-}
+  SourceManager &SM = CI.getSourceManager();
+  FileID FID = SM.getMainFileID();
+  Optional MainFile = SM.getBufferOrNone(FID);
+  if (!MainFile)
+return;
 
-EmbedBitcode(TheModule.get(), CodeGenOpts, *MainFile);
-
-LLVMContext &Ctx = TheModule->getContext();
-Ctx.setInlineAsmDiagnosticHandler(BitcodeInlineAsmDiagHandler,
-  &Diagnostics);
-
-// Set clang diagnostic handler. To do this we need to create a fake
-// BackendConsumer.
-BackendConsumer Result(BA, CI.getDiagnostics(), CI.getHeaderSearchOpts(),
-   CI.getPreprocessorOpts(), CI.getCodeGenOpts(),
-   CI.getTargetOpts(), CI.getLangOpts(),
-   std::move(LinkModules), *VMContext, nullptr);
-// PR44896: Force DiscardValueNames as false. DiscardValueNames cannot be
-// true here because the valued names are needed for reading textual IR.
-Ctx.setDiscardValueNames(false);
-Ctx.setDiagnosticHandler(
-std::make_unique(CodeGenOpts, &Result));
-
-Expected> OptRecordFileOrErr =
-setupLLVMOptimizationRemarks(
-Ctx, CodeGenOpts.OptRecordFile, CodeGenOpts.OptRecordPasses,
-CodeGenOpts.OptRecordFormat, CodeGenOpts.DiagnosticsWithHotness,
-CodeGenOpts.DiagnosticsHotnessThreshold);
-
-if (Error E = OptRecordFileOrErr.takeError()) {
-  reportOptRecordError(std::move(E), Diagnostics, CodeGenOpts);
-  return;
-}
-std::unique_ptr OptRecordFile =
-std::move(*OptRecordFileOrErr);
+  TheModule = loadModule(*MainFile);
+  if (!TheModule)
+return;
 
-EmitBackendOutput(Diagnostics, CI.getHeaderSearchOpts(), CodeGenOpts,
-  TargetOpts, CI.getLangOpts(),
-  CI.getTarget().getDataLayout(), TheModule.get(), BA,
-  std::move(OS));
+  const TargetOptions &TargetOpts = CI.getTargetOpts();
+  if (TheModule->getTargetTriple() != TargetOpts.Triple) {
+Diagnostics.Report(SourceLocation(), diag::warn_fe_override_module)
+<< TargetOpts.Triple;
+TheModule->setTargetTriple(TargetOpts.Triple);
+  }
 
-if (OptRecordFile)
-  OptRecordFile->keep();
+  EmbedBitcode(TheModule.get(), CodeGenOpts, *MainFile);
+
+  LLVMContext &Ctx = TheModule->getContext();
+  Ctx.setInlineAsmDiagnosticHandler(BitcodeInlineAsmDiagHandler, &Diagnostics);
+
+  // Set clang diagnostic handler. To do this we need to create a fake
+  // BackendConsumer.
+  BackendConsumer Result(BA, CI.getDiagnostics(), CI.getHeaderSearchOpts(),
+ CI.getPreprocessorOpt

[clang] 66face6 - Re-land [DebugInfo] Add debug location to stubs generated by CGDeclCXX and mark them as artificial

2020-10-08 Thread Alexandre Ganea via cfe-commits

Author: Alexandre Ganea
Date: 2020-10-08T20:49:17-04:00
New Revision: 66face6aa0f5f68de56067b0dff3295e47fdf66c

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

LOG: Re-land [DebugInfo] Add debug location to stubs generated by CGDeclCXX and 
mark them as artificial

Previously, when clang was compiled with -DLLVM_ENABLE_ASSERTIONS=ON, the added 
tests were displaying:

inlinable function call in a function with debug info must have a !dbg location
  call void @"??1?$c@UBQEAA@XZ"(%struct.c* 
@"?f@?1??d@@YAPEAU?$c@UBXZ@4U2@A")
fatal error: error in backend: Broken module found, compilation aborted!
Stack dump:
0.  Program arguments:  -gcodeview -debug-info-kind=limited
1.   parser at end of file
2.  Per-function optimization

Fixes PR43012

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

Added: 
clang/test/CodeGenCXX/debug-info-atexit-stub.cpp
clang/test/CodeGenCXX/debug-info-destroy-helper.cpp

Modified: 
clang/include/clang/AST/GlobalDecl.h
clang/lib/CodeGen/CGDebugInfo.cpp
clang/lib/CodeGen/CGDeclCXX.cpp
clang/test/CodeGenCXX/aix-static-init-debug-info.cpp
clang/test/CodeGenCXX/debug-info-global-ctor-dtor.cpp
clang/test/CodeGenCXX/debug-info-line.cpp

Removed: 




diff  --git a/clang/include/clang/AST/GlobalDecl.h 
b/clang/include/clang/AST/GlobalDecl.h
index d8ac498be54f..8cb56fb4ae90 100644
--- a/clang/include/clang/AST/GlobalDecl.h
+++ b/clang/include/clang/AST/GlobalDecl.h
@@ -32,6 +32,7 @@ enum class DynamicInitKind : unsigned {
   NoStub = 0,
   Initializer,
   AtExit,
+  GlobalArrayDestructor
 };
 
 enum class KernelReferenceKind : unsigned {

diff  --git a/clang/lib/CodeGen/CGDebugInfo.cpp 
b/clang/lib/CodeGen/CGDebugInfo.cpp
index 88aace8b85dd..71ebd268f630 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -2041,7 +2041,8 @@ StringRef CGDebugInfo::getDynamicInitializerName(const 
VarDecl *VD,
  llvm::Function *InitFn) {
   // If we're not emitting codeview, use the mangled name. For Itanium, this is
   // arbitrary.
-  if (!CGM.getCodeGenOpts().EmitCodeView)
+  if (!CGM.getCodeGenOpts().EmitCodeView ||
+  StubKind == DynamicInitKind::GlobalArrayDestructor)
 return InitFn->getName();
 
   // Print the normal qualified name for the variable, then break off the last
@@ -2066,6 +2067,7 @@ StringRef CGDebugInfo::getDynamicInitializerName(const 
VarDecl *VD,
 
   switch (StubKind) {
   case DynamicInitKind::NoStub:
+  case DynamicInitKind::GlobalArrayDestructor:
 llvm_unreachable("not an initializer");
   case DynamicInitKind::Initializer:
 OS << "`dynamic initializer for '";
@@ -3832,7 +3834,8 @@ void CGDebugInfo::EmitFunctionStart(GlobalDecl GD, 
SourceLocation Loc,
   if (Name.startswith("\01"))
 Name = Name.substr(1);
 
-  if (!HasDecl || D->isImplicit() || D->hasAttr()) {
+  if (!HasDecl || D->isImplicit() || D->hasAttr() ||
+  (isa(D) && GD.getDynamicInitKind() != DynamicInitKind::NoStub)) 
{
 Flags |= llvm::DINode::FlagArtificial;
 // Artificial functions should not silently reuse CurLoc.
 CurLoc = SourceLocation();

diff  --git a/clang/lib/CodeGen/CGDeclCXX.cpp b/clang/lib/CodeGen/CGDeclCXX.cpp
index 3f6d0e23c685..b9ff561aa641 100644
--- a/clang/lib/CodeGen/CGDeclCXX.cpp
+++ b/clang/lib/CodeGen/CGDeclCXX.cpp
@@ -247,6 +247,8 @@ llvm::Function *CodeGenFunction::createAtExitStub(const 
VarDecl &VD,
   CGF.StartFunction(GlobalDecl(&VD, DynamicInitKind::AtExit),
 CGM.getContext().VoidTy, fn, FI, FunctionArgList(),
 VD.getLocation(), VD.getInit()->getExprLoc());
+  // Emit an artificial location for this function.
+  auto AL = ApplyDebugLocation::CreateArtificial(CGF);
 
   llvm::CallInst *call = CGF.Builder.CreateCall(dtor, addr);
 
@@ -672,8 +674,9 @@ void 
CodeGenFunction::GenerateCXXGlobalVarDeclInitFunc(llvm::Function *Fn,
 
   StartFunction(GlobalDecl(D, DynamicInitKind::Initializer),
 getContext().VoidTy, Fn, getTypes().arrangeNullaryFunction(),
-FunctionArgList(), D->getLocation(),
-D->getInit()->getExprLoc());
+FunctionArgList());
+  // Emit an artificial location for this function.
+  auto AL = ApplyDebugLocation::CreateArtificial(*this);
 
   // Use guarded initialization if the global variable is weak. This
   // occurs for, e.g., instantiated static data members and
@@ -807,7 +810,10 @@ llvm::Function *CodeGenFunction::generateDestroyHelper(
 
   CurEHLocation = VD->getBeginLoc();
 
-  StartFunction(VD, getContext().VoidTy, fn, FI, args);
+  StartFunction(GlobalDecl(VD, DynamicInitKind::GlobalArrayDestructor),
+getContext().VoidTy, fn, FI, args);
+  // Emit an artifi

[clang] 1dbf05f - [ThinLTO][Documentation] Mention possible values for concurrency flags

2020-10-13 Thread Alexandre Ganea via cfe-commits

Author: Alexandre Ganea
Date: 2020-10-13T09:57:58-04:00
New Revision: 1dbf05f5b44db17dcd8520b032e83061189ff4f8

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

LOG: [ThinLTO][Documentation] Mention possible values for concurrency flags

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

Added: 


Modified: 
clang/docs/ThinLTO.rst

Removed: 




diff  --git a/clang/docs/ThinLTO.rst b/clang/docs/ThinLTO.rst
index 528530c5ae98..0da822f498b9 100644
--- a/clang/docs/ThinLTO.rst
+++ b/clang/docs/ThinLTO.rst
@@ -123,6 +123,11 @@ be reduced to ``N`` via:
 - lld-link:
   ``/opt:lldltojobs=N``
 
+Other possible values for ``N`` are:
+- 0: Use one thread per physical core (default)
+- 1: Use a single thread only (disable multi-threading)
+- all: Use one thread per logical core (uses all hyper-threads)
+
 Incremental
 ---
 .. _incremental:



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


[clang] eded23d - [Clang] Silence a "unused variable" warning when building with MSVC

2023-01-09 Thread Alexandre Ganea via cfe-commits

Author: Alexandre Ganea
Date: 2023-01-09T23:45:20-05:00
New Revision: eded23dfdaf050793b70351d5f42400016d57c15

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

LOG: [Clang] Silence a "unused variable" warning when building with MSVC

Added: 


Modified: 
clang/lib/Lex/LiteralSupport.cpp

Removed: 




diff  --git a/clang/lib/Lex/LiteralSupport.cpp 
b/clang/lib/Lex/LiteralSupport.cpp
index 05575e8d6e2a7..fb2b14601a6ae 100644
--- a/clang/lib/Lex/LiteralSupport.cpp
+++ b/clang/lib/Lex/LiteralSupport.cpp
@@ -515,8 +515,9 @@ static void DiagnoseInvalidUnicodeCharacterName(
 
 std::string Str;
 llvm::UTF32 V = Match.Value;
-LLVM_ATTRIBUTE_UNUSED bool Converted =
+bool Converted =
 llvm::convertUTF32ToUTF8String(llvm::ArrayRef(&V, 1), 
Str);
+(void)Converted;
 assert(Converted && "Found a match wich is not a unicode character");
 
 Diag(Diags, Features, Loc, TokBegin, TokRangeBegin, TokRangeEnd,



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


[clang] Update GoogleTest to v1.14.0 (PR #65823)

2023-09-28 Thread Alexandre Ganea via cfe-commits

aganea wrote:

@zmodem Can you add `ENABLE_ASSERTS` on [this 
line](https://github.com/llvm/llvm-project/blob/720e3bacbd9fdba05645a4d621d43ad712c44df3/llvm/lib/Support/CMakeLists.txt#L107)
 and run the test again, see if that gives something interesting?



https://github.com/llvm/llvm-project/pull/65823
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Update GoogleTest to v1.14.0 (PR #65823)

2023-09-29 Thread Alexandre Ganea via cfe-commits

aganea wrote:

@zmodem I haven’t been able to repro with the recipe posted on 
https://crbug.com/1487548. I am using latest rpmalloc (main branch), latest VS 
2022, latest WinSDK. I am running on Win11, on a AMD Ryzen9 CPU. Are you 
running on WinServer2022? Are able to give more precision on the conditions for 
reproducing?

https://github.com/llvm/llvm-project/pull/65823
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Update GoogleTest to v1.14.0 (PR #65823)

2023-09-30 Thread Alexandre Ganea via cfe-commits

aganea wrote:

I managed to repro. It is actually this, still open, issue: 
https://github.com/microsoft/STL/issues/1066

https://github.com/llvm/llvm-project/pull/65823
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] -fsanitize=function: fix MSVC hashing to sugared type (PR #66816)

2023-10-02 Thread Alexandre Ganea via cfe-commits


@@ -3838,13 +3838,13 @@ void MicrosoftMangleContextImpl::mangleSEHFinallyBlock(
   Mangler.mangleName(EnclosingDecl);
 }
 
-void MicrosoftMangleContextImpl::mangleTypeName(
+void MicrosoftMangleContextImpl::mangleCanonicalTypeName(
 QualType T, raw_ostream &Out, bool NormalizeIntegers = false) {
   // This is just a made up unique string for the purposes of tbaa.  undname
   // does *not* know how to demangle it.
   MicrosoftCXXNameMangler Mangler(*this, Out);
   Mangler.getStream() << '?';
-  Mangler.mangleType(T, SourceRange());
+  Mangler.mangleType(T.getCanonicalType(), SourceRange());

aganea wrote:

Like @mizvekov suggested, we could only backport this line to `release/17.x` 
with a comment above, pointing to this patch?

https://github.com/llvm/llvm-project/pull/66816
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 49e483d - [CodeView] Replace GHASH hasher by BLAKE3

2022-11-19 Thread Alexandre Ganea via cfe-commits

Author: Alexandre Ganea
Date: 2022-11-19T15:17:42-05:00
New Revision: 49e483d3d62f6f62beb323e9c4160bab9e0ad619

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

LOG: [CodeView] Replace GHASH hasher by BLAKE3

Previously, we used SHA-1 for hashing the CodeView type records.
SHA-1 in `GloballyHashedType::hashType()` is coming top in the profiles. By 
simply replacing with BLAKE3, the link time is reduced in our case from 15 sec 
to 13 sec. I am only using MSVC .OBJs in this case. As a reference, the 
resulting .PDB is approx 2.1GiB and .EXE is approx 250MiB.

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

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
lld/COFF/DebugTypes.cpp
lld/docs/ReleaseNotes.rst
llvm/include/llvm/DebugInfo/CodeView/TypeHashing.h
llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
llvm/lib/DebugInfo/CodeView/TypeHashing.cpp
llvm/test/DebugInfo/COFF/global-type-hashes.ll
llvm/test/DebugInfo/PDB/obj-globalhash.test

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 640c52096c4a1..dcb5f132fce1b 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -519,6 +519,8 @@ Windows Support
   ``/guard:cf,nochecks`` in clang-cl) for enabling Control Flow Guard checks
   and generation of address-taken function table.
 
+- Switched from SHA1 to BLAKE3 for PDB type hashing / ``-gcodeview-ghash``
+
 AIX Support
 ---
 * When using ``-shared``, the clang driver now invokes llvm-nm to create an

diff  --git a/lld/COFF/DebugTypes.cpp b/lld/COFF/DebugTypes.cpp
index ff469685fb7fa..6786d064ca8df 100644
--- a/lld/COFF/DebugTypes.cpp
+++ b/lld/COFF/DebugTypes.cpp
@@ -275,7 +275,7 @@ static bool canUseDebugH(ArrayRef debugH) {
   debugH = debugH.drop_front(sizeof(object::debug_h_header));
   return header->Magic == COFF::DEBUG_HASHES_SECTION_MAGIC &&
  header->Version == 0 &&
- header->HashAlgorithm == uint16_t(GlobalTypeHashAlg::SHA1_8) &&
+ header->HashAlgorithm == uint16_t(GlobalTypeHashAlg::BLAKE3) &&
  (debugH.size() % 8 == 0);
 }
 

diff  --git a/lld/docs/ReleaseNotes.rst b/lld/docs/ReleaseNotes.rst
index 744baaf62efcf..0e9029bdcc097 100644
--- a/lld/docs/ReleaseNotes.rst
+++ b/lld/docs/ReleaseNotes.rst
@@ -43,6 +43,8 @@ COFF Improvements
 * The linker command line entry in ``S_ENVBLOCK`` of the PDB is now stripped
   from input files, to align with MSVC behavior.
   (`D137723 `_)
+* Switched from SHA1 to BLAKE3 for PDB type hashing / ``-gcodeview-ghash``
+  (`D137101 `_)
 
 MinGW Improvements
 --

diff  --git a/llvm/include/llvm/DebugInfo/CodeView/TypeHashing.h 
b/llvm/include/llvm/DebugInfo/CodeView/TypeHashing.h
index f49bc9b8e7909..1914f499f0ed4 100644
--- a/llvm/include/llvm/DebugInfo/CodeView/TypeHashing.h
+++ b/llvm/include/llvm/DebugInfo/CodeView/TypeHashing.h
@@ -61,7 +61,8 @@ struct LocallyHashedType {
 
 enum class GlobalTypeHashAlg : uint16_t {
   SHA1 = 0, // standard 20-byte SHA1 hash
-  SHA1_8// last 8-bytes of standard SHA1 hash
+  SHA1_8,   // last 8-bytes of standard SHA1 hash
+  BLAKE3,   // truncated 8-bytes BLAKE3
 };
 
 /// A globally hashed type represents a hash value that is sufficient to

diff  --git a/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp 
b/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
index 3bb0df4eeac93..7fd38b7b789fc 100644
--- a/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
@@ -760,7 +760,7 @@ void CodeViewDebug::emitTypeGlobalHashes() {
   OS.AddComment("Section Version");
   OS.emitInt16(0);
   OS.AddComment("Hash Algorithm");
-  OS.emitInt16(uint16_t(GlobalTypeHashAlg::SHA1_8));
+  OS.emitInt16(uint16_t(GlobalTypeHashAlg::BLAKE3));
 
   TypeIndex TI(TypeIndex::FirstNonSimpleIndex);
   for (const auto &GHR : TypeTable.hashes()) {

diff  --git a/llvm/lib/DebugInfo/CodeView/TypeHashing.cpp 
b/llvm/lib/DebugInfo/CodeView/TypeHashing.cpp
index fc85d8186eaad..877fde79ddd09 100644
--- a/llvm/lib/DebugInfo/CodeView/TypeHashing.cpp
+++ b/llvm/lib/DebugInfo/CodeView/TypeHashing.cpp
@@ -9,7 +9,7 @@
 #include "llvm/DebugInfo/CodeView/TypeHashing.h"
 
 #include "llvm/DebugInfo/CodeView/TypeIndexDiscovery.h"
-#include "llvm/Support/SHA1.h"
+#include "llvm/Support/BLAKE3.h"
 
 using namespace llvm;
 using namespace llvm::codeview;
@@ -35,7 +35,7 @@ GloballyHashedType::hashType(ArrayRef RecordData,
  ArrayRef PreviousIds) {
   SmallVector Refs;
   discoverTypeIndices(RecordData, Refs);
-  SHA1 S;
+  TruncatedBLAKE3<8> S;
   S.init();
   uint32_t Off = 0;
   S.update(RecordData.take_front(sizeof(RecordPrefix)));
@@ -76,6 +76,5 @@ GloballyHashedType::h

[clang] ae918c7 - [clang-format] Add .inc extension to git-clang-format

2022-12-03 Thread Alexandre Ganea via cfe-commits

Author: Alexandre Ganea
Date: 2022-12-03T09:24:03-05:00
New Revision: ae918c78b51ae7e19053b9ae9deb9fee35084256

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

LOG: [clang-format] Add .inc extension to git-clang-format

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

Added: 


Modified: 
clang/tools/clang-format/git-clang-format

Removed: 




diff  --git a/clang/tools/clang-format/git-clang-format 
b/clang/tools/clang-format/git-clang-format
index 7ce6b60a8e65..054978c3dbdf 100755
--- a/clang/tools/clang-format/git-clang-format
+++ b/clang/tools/clang-format/git-clang-format
@@ -88,7 +88,7 @@ def main():
   'c', 'h',  # C
   'm',  # ObjC
   'mm',  # ObjC++
-  'cc', 'cp', 'cpp', 'c++', 'cxx', 'hh', 'hpp', 'hxx',  # C++
+  'cc', 'cp', 'cpp', 'c++', 'cxx', 'hh', 'hpp', 'hxx', 'inc',  # C++
   'ccm', 'cppm', 'cxxm', 'c++m',  # C++ Modules
   'cu', 'cuh',  # CUDA
   # Other languages that clang-format supports



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


[clang] 5896e2d - [Clang] Fix HIP tests when running on Windows with the LLVM toolchain is in the path

2020-03-23 Thread Alexandre Ganea via cfe-commits

Author: Alexandre Ganea
Date: 2020-03-23T16:54:48-04:00
New Revision: 5896e2df45dab7680be321ee63903431a673817b

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

LOG: [Clang] Fix HIP tests when running on Windows with the LLVM toolchain is 
in the path

On Windows, when the LLVM toolchain is in the current path (%PATH%), fusing the 
linker yields c:\{path}\lld.exe whereas the hip tests did not expect the .exe 
part.
This only happens if LLD is not present in the build folder, which consequently 
makes the code in Driver::GetProgramPath() to fall back to %PATH% and 
platform-specific search, which includes the .exe part (see 
https://github.com/llvm/llvm-project/blob/master/clang/lib/Driver/Driver.cpp#L4733).

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

Added: 


Modified: 
clang/test/Driver/hip-device-compile.hip
clang/test/Driver/hip-toolchain-no-rdc.hip
clang/test/Driver/hip-toolchain-rdc.hip

Removed: 




diff  --git a/clang/test/Driver/hip-device-compile.hip 
b/clang/test/Driver/hip-device-compile.hip
index b6f1f1cf218e..c442d23581ce 100644
--- a/clang/test/Driver/hip-device-compile.hip
+++ b/clang/test/Driver/hip-device-compile.hip
@@ -42,7 +42,7 @@
 // CHECK-NOT: {{"*.llvm-link"}}
 // CHECK-NOT: {{".*opt"}}
 // CHECK-NOT: {{".*llc"}}
-// CHECK-NOT: {{".*lld"}}
+// CHECK-NOT: {{".*lld.*"}}
 // CHECK-NOT: {{".*clang-offload-bundler"}}
 // CHECK-NOT: {{".*ld.*"}}
 
@@ -67,6 +67,6 @@
 // BUNDLE: {{"*.llvm-link"}}
 // BUNDLE: {{".*opt"}}
 // BUNDLE: {{".*llc"}}
-// BUNDLE: {{".*lld"}}
+// BUNDLE: {{".*lld.*"}}
 // BUNDLE: {{".*clang-offload-bundler"}}
 

diff  --git a/clang/test/Driver/hip-toolchain-no-rdc.hip 
b/clang/test/Driver/hip-toolchain-no-rdc.hip
index cda852e2d8c7..4371334577f7 100644
--- a/clang/test/Driver/hip-toolchain-no-rdc.hip
+++ b/clang/test/Driver/hip-toolchain-no-rdc.hip
@@ -38,7 +38,7 @@
 // CHECK-SAME: "-filetype=obj"
 // CHECK-SAME: "-o" [[OBJ_DEV_A_803:".*-gfx803-.*o"]]
 
-// CHECK: [[LLD: ".*lld"]] "-flavor" "gnu" "-shared"
+// CHECK: [[LLD: ".*lld.*"]] "-flavor" "gnu" "-shared"
 // CHECK-SAME: "-o" "[[IMG_DEV_A_803:.*out]]" [[OBJ_DEV_A_803]]
 
 //
@@ -67,7 +67,7 @@
 // CHECK-SAME: "-filetype=obj"
 // CHECK-SAME: "-o" [[OBJ_DEV_A_900:".*-gfx900-.*o"]]
 
-// CHECK: [[LLD: ".*lld"]] "-flavor" "gnu" "-shared"
+// CHECK: [[LLD]] "-flavor" "gnu" "-shared"
 // CHECK-SAME: "-o" "[[IMG_DEV_A_900:.*out]]" [[OBJ_DEV_A_900]]
 
 //
@@ -112,7 +112,7 @@
 // CHECK-SAME: "-filetype=obj"
 // CHECK-SAME: "-o" [[OBJ_DEV_B_803:".*-gfx803-.*o"]]
 
-// CHECK: [[LLD: ".*lld"]] "-flavor" "gnu" "-shared"
+// CHECK: [[LLD]] "-flavor" "gnu" "-shared"
 // CHECK-SAME: "-o" "[[IMG_DEV_B_803:.*out]]" [[OBJ_DEV_B_803]]
 
 //
@@ -141,7 +141,7 @@
 // CHECK-SAME: "-filetype=obj"
 // CHECK-SAME: "-o" [[OBJ_DEV_B_900:".*-gfx900-.*o"]]
 
-// CHECK: [[LLD: ".*lld"]] "-flavor" "gnu" "-shared"
+// CHECK: [[LLD]] "-flavor" "gnu" "-shared"
 // CHECK-SAME: "-o" "[[IMG_DEV_B_900:.*out]]" [[OBJ_DEV_B_900]]
 
 //

diff  --git a/clang/test/Driver/hip-toolchain-rdc.hip 
b/clang/test/Driver/hip-toolchain-rdc.hip
index 18fd1d7b09a0..203784f2ab43 100644
--- a/clang/test/Driver/hip-toolchain-rdc.hip
+++ b/clang/test/Driver/hip-toolchain-rdc.hip
@@ -44,7 +44,7 @@
 // CHECK-SAME: "-filetype=obj"
 // CHECK-SAME: "-o" [[OBJ_DEV1:".*-gfx803-.*o"]]
 
-// CHECK: [[LLD: ".*lld"]] "-flavor" "gnu" "-shared"
+// CHECK: [[LLD: ".*lld.*"]] "-flavor" "gnu" "-shared"
 // CHECK-SAME: "-o" "[[IMG_DEV1:.*out]]" [[OBJ_DEV1]]
 
 // CHECK: [[CLANG]] "-cc1" "-triple" "amdgcn-amd-amdhsa"



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


[clang] 0915825 - [ThinLTO] Allow usage of all hardware threads in the system

2020-03-27 Thread Alexandre Ganea via cfe-commits

Author: Alexandre Ganea
Date: 2020-03-27T10:20:58-04:00
New Revision: 09158252f777c2e2f06a86b154c44abcbcf9bb74

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

LOG: [ThinLTO] Allow usage of all hardware threads in the system

Before this patch, it wasn't possible to extend the ThinLTO threads to all 
SMT/CMT threads in the system. Only one thread per core was allowed, instructed 
by usage of llvm::heavyweight_hardware_concurrency() in the ThinLTO code. Any 
number passed to the LLD flag /opt:lldltojobs=..., or any other 
ThinLTO-specific flag, was previously interpreted in the context of 
llvm::heavyweight_hardware_concurrency(), which means SMT disabled.

One can now say in LLD:
/opt:lldltojobs=0 -- Use one std::thread / hardware core in the system (no 
SMT). Default value if flag not specified.
/opt:lldltojobs=N -- Limit usage to N threads, regardless of usage of 
heavyweight_hardware_concurrency().
/opt:lldltojobs=all -- Use all hardware threads in the system. Equivalent to 
/opt:lldltojobs=$(nproc) on Linux and /opt:lldltojobs=%NUMBER_OF_PROCESSORS% on 
Windows. When an affinity mask is set for the process, threads will be created 
only for the cores selected by the mask.

When N > number-of-hardware-threads-in-the-system, the threads in the thread 
pool will be dispatched equally on all CPU sockets (tested only on Windows).
When N <= number-of-hardware-threads-on-a-CPU-socket, the threads will remain 
on the CPU socket where the process started (only on Windows).

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

Added: 


Modified: 
clang/lib/Driver/ToolChains/CommonArgs.cpp
clang/lib/Driver/ToolChains/CommonArgs.h
clang/lib/Driver/ToolChains/Darwin.cpp
lld/COFF/Config.h
lld/COFF/Driver.cpp
lld/COFF/LTO.cpp
lld/ELF/Config.h
lld/ELF/Driver.cpp
lld/ELF/LTO.cpp
lld/test/COFF/thinlto.ll
lld/test/ELF/basic.s
lld/test/ELF/lto/thinlto.ll
lld/test/wasm/lto/thinlto.ll
lld/wasm/Config.h
lld/wasm/Driver.cpp
lld/wasm/LTO.cpp
llvm/include/llvm/LTO/LTO.h
llvm/include/llvm/Support/Threading.h
llvm/lib/LTO/LTO.cpp
llvm/lib/Support/Threading.cpp
llvm/lib/Support/Unix/Threading.inc
llvm/lib/Support/Windows/Threading.inc
llvm/tools/gold/gold-plugin.cpp
llvm/tools/llvm-lto2/llvm-lto2.cpp

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp 
b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index 51b2e5f3c34d..303ced52454c 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -50,6 +50,7 @@
 #include "llvm/Support/Program.h"
 #include "llvm/Support/ScopedPrinter.h"
 #include "llvm/Support/TargetParser.h"
+#include "llvm/Support/Threading.h"
 #include "llvm/Support/VirtualFileSystem.h"
 #include "llvm/Support/YAMLParser.h"
 
@@ -338,14 +339,14 @@ std::string tools::getCPUName(const ArgList &Args, const 
llvm::Triple &T,
   }
 }
 
-unsigned tools::getLTOParallelism(const ArgList &Args, const Driver &D) {
-  unsigned Parallelism = 0;
+llvm::StringRef tools::getLTOParallelism(const ArgList &Args, const Driver &D) 
{
   Arg *LtoJobsArg = Args.getLastArg(options::OPT_flto_jobs_EQ);
-  if (LtoJobsArg &&
-  StringRef(LtoJobsArg->getValue()).getAsInteger(10, Parallelism))
-D.Diag(diag::err_drv_invalid_int_value) << LtoJobsArg->getAsString(Args)
-<< LtoJobsArg->getValue();
-  return Parallelism;
+  if (!LtoJobsArg)
+return {};
+  if (!llvm::get_threadpool_strategy(LtoJobsArg->getValue()))
+D.Diag(diag::err_drv_invalid_int_value)
+<< LtoJobsArg->getAsString(Args) << LtoJobsArg->getValue();
+  return LtoJobsArg->getValue();
 }
 
 // CloudABI uses -ffunction-sections and -fdata-sections by default.
@@ -410,7 +411,8 @@ void tools::addLTOOptions(const ToolChain &ToolChain, const 
ArgList &Args,
   if (IsThinLTO)
 CmdArgs.push_back("-plugin-opt=thinlto");
 
-  if (unsigned Parallelism = getLTOParallelism(Args, ToolChain.getDriver()))
+  StringRef Parallelism = getLTOParallelism(Args, ToolChain.getDriver());
+  if (!Parallelism.empty())
 CmdArgs.push_back(
 Args.MakeArgString("-plugin-opt=jobs=" + Twine(Parallelism)));
 

diff  --git a/clang/lib/Driver/ToolChains/CommonArgs.h 
b/clang/lib/Driver/ToolChains/CommonArgs.h
index 984f3ee98af1..c94b2b828c9b 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.h
+++ b/clang/lib/Driver/ToolChains/CommonArgs.h
@@ -88,7 +88,8 @@ llvm::opt::Arg *getLastProfileSampleUseArg(const 
llvm::opt::ArgList &Args);
 
 bool isObjCAutoRefCount(const llvm::opt::ArgList &Args);
 
-unsigned getLTOParallelism(const llvm::opt::ArgList &Args, const Driver &D);
+llvm::StringRef getLTOParallelism(const llvm::opt::ArgList &Args,
+   

[clang] 3ab3f3c - After 09158252f777c2e2f06a86b154c44abcbcf9bb74, fix build when -DLLVM_ENABLE_THREADS=OFF

2020-03-28 Thread Alexandre Ganea via cfe-commits

Author: Alexandre Ganea
Date: 2020-03-28T13:54:58-04:00
New Revision: 3ab3f3c5d5825476dc1be15992f7c964629de688

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

LOG: After 09158252f777c2e2f06a86b154c44abcbcf9bb74, fix build when 
-DLLVM_ENABLE_THREADS=OFF

Tested on Linux with Clang 9, and on Windows with Visual Studio 2019 16.5.1 
with -DLLVM_ENABLE_THREADS=ON and OFF.

Added: 


Modified: 
clang/test/Driver/lto-jobs.c
llvm/lib/Support/Threading.cpp

Removed: 




diff  --git a/clang/test/Driver/lto-jobs.c b/clang/test/Driver/lto-jobs.c
index 539867713b07..c28d0ad300f4 100644
--- a/clang/test/Driver/lto-jobs.c
+++ b/clang/test/Driver/lto-jobs.c
@@ -8,4 +8,4 @@
 // RUN: %clang -target x86_64-apple-darwin13.3.0 -### %s -flto=thin 
-flto-jobs=5 2> %t
 // RUN: FileCheck -check-prefix=CHECK-LINK-THIN-JOBS2-ACTION < %t %s
 //
-// CHECK-LINK-THIN-JOBS2-ACTION: "-mllvm" "-threads=5"
+// CHECK-LINK-THIN-JOBS2-ACTION: "-mllvm" "-threads={{[0-9]+}}"

diff  --git a/llvm/lib/Support/Threading.cpp b/llvm/lib/Support/Threading.cpp
index 39de05892981..4bf373ddbd72 100644
--- a/llvm/lib/Support/Threading.cpp
+++ b/llvm/lib/Support/Threading.cpp
@@ -94,26 +94,6 @@ unsigned llvm::ThreadPoolStrategy::compute_thread_count() 
const {
   return MaxThreadCount;
 }
 
-Optional
-llvm::get_threadpool_strategy(StringRef Num, ThreadPoolStrategy Default) {
-  if (Num == "all")
-return llvm::hardware_concurrency();
-  if (Num.empty())
-return Default;
-  unsigned V;
-  if (Num.getAsInteger(10, V))
-return None; // malformed 'Num' value
-  if (V == 0)
-return Default;
-
-  // Do not take the Default into account. This effectively disables
-  // heavyweight_hardware_concurrency() if the user asks for any number of
-  // threads on the cmd-line.
-  ThreadPoolStrategy S = llvm::hardware_concurrency();
-  S.ThreadsRequested = V;
-  return S;
-}
-
 namespace {
 struct SyncThreadInfo {
   void (*UserFn)(void *);
@@ -150,3 +130,23 @@ void llvm::llvm_execute_on_thread_async(
 }
 
 #endif
+
+Optional
+llvm::get_threadpool_strategy(StringRef Num, ThreadPoolStrategy Default) {
+  if (Num == "all")
+return llvm::hardware_concurrency();
+  if (Num.empty())
+return Default;
+  unsigned V;
+  if (Num.getAsInteger(10, V))
+return None; // malformed 'Num' value
+  if (V == 0)
+return Default;
+
+  // Do not take the Default into account. This effectively disables
+  // heavyweight_hardware_concurrency() if the user asks for any number of
+  // threads on the cmd-line.
+  ThreadPoolStrategy S = llvm::hardware_concurrency();
+  S.ThreadsRequested = V;
+  return S;
+}



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


RE: [PATCH] D73242: [WPD/LowerTypeTests] Delay lowering/removal of type tests until after ICP

2020-02-20 Thread Alexandre Ganea via cfe-commits
No need to revert, I can wait.
Thanks!

De : Teresa Johnson 
Envoyé : February 20, 2020 5:07 PM
À : reviews+d73242+public+5822844df8563...@reviews.llvm.org
Cc : Peter Collingbourne ; Evgeny Leviant 
; Alexandre Ganea ; 
joker@gmail.com; piotr.padlew...@gmail.com; hiradi...@msn.com; 
steve...@apple.com; dexonsm...@apple.com; arpha...@gmail.com; 
davi...@google.com; cfe-commits@lists.llvm.org; llvm-comm...@lists.llvm.org; 
mlek...@skidmore.edu; blitzrak...@gmail.com; shen...@google.com; 
ju...@samsung.com; l...@inglorion.net; yuanfang.c...@sony.com
Objet : Re: [PATCH] D73242: [WPD/LowerTypeTests] Delay lowering/removal of type 
tests until after ICP

I'm currently traveling but will take a look tomorrow. If necessary go ahead 
and revert, I will not be able to do so myself until tomorrow. Teresa

On Tue, Feb 18, 2020, 8:48 PM Alexandre Ganea via Phabricator 
mailto:revi...@reviews.llvm.org>> wrote:
aganea added a comment.

There seems to be still an issue with this patch, when linking the LLVM unit 
tests on a two-stage build, it ends with:

  FAILED: tools/clang/unittests/StaticAnalyzer/StaticAnalysisTests.exe
  cmd.exe /C "cd . && "C:\Program Files\CMake\bin\cmake.exe" -E vs_link_exe 
--intdir=tools\clang\unittests\StaticAnalyzer\CMakeFiles\StaticAnalysisTests.dir
 --rc=C:\PROGRA~2\WI3CF2~1\10\bin\100183~1.0\x64\rc.exe 
--mt=C:\PROGRA~2\WI3CF2~1\10\bin\100183~1.0\x64\mt.exe --manifests  -- 
D:\llvm-project\buildninjaRel\bin\lld-link.exe /nologo 
tools\clang\unittests\StaticAnalyzer\CMakeFiles\StaticAnalysisTests.dir\AnalyzerOptionsTest.cpp.obj
 
tools\clang\unittests\StaticAnalyzer\CMakeFiles\StaticAnalysisTests.dir\CallDescriptionTest.cpp.obj
 
tools\clang\unittests\StaticAnalyzer\CMakeFiles\StaticAnalysisTests.dir\StoreTest.cpp.obj
 
tools\clang\unittests\StaticAnalyzer\CMakeFiles\StaticAnalysisTests.dir\RegisterCustomCheckersTest.cpp.obj
 
tools\clang\unittests\StaticAnalyzer\CMakeFiles\StaticAnalysisTests.dir\SymbolReaperTest.cpp.obj
 
tools\clang\unittests\StaticAnalyzer\CMakeFiles\StaticAnalysisTests.dir\D_\llvm-project\llvm\resources\windows_version_resource.rc.res
  /out:tools\clang\unittests\StaticAnalyzer\StaticAnalysisTests.exe 
/implib:tools\clang\unittests\StaticAnalyzer\StaticAnalysisTests.lib 
/pdb:tools\clang\unittests\StaticAnalyzer\StaticAnalysisTests.pdb /version:0.0  
/machine:x64 -fuse-ld=lld /STACK:1000 /DEBUG /OPT:REF /OPT:ICF 
/lldltocache:D:/llvm-project/buildninjaRelMiMalloc/lto.cache /INCREMENTAL:NO 
/subsystem:console  lib\LLVMSupport.lib  lib\LLVMSupport.lib  
lib\gtest_main.lib  lib\gtest.lib  lib\clangBasic.lib  lib\clangAnalysis.lib  
lib\clangAST.lib  lib\clangASTMatchers.lib  lib\clangCrossTU.lib  
lib\clangFrontend.lib  lib\clangSerialization.lib  
lib\clangStaticAnalyzerCore.lib  lib\clangStaticAnalyzerFrontend.lib  
lib\clangTooling.lib  lib\clangStaticAnalyzerCheckers.lib  
lib\clangStaticAnalyzerCore.lib  lib\clangCrossTU.lib  lib\clangIndex.lib  
lib\clangFrontend.lib  lib\clangParse.lib  lib\clangSerialization.lib  
lib\clangSema.lib  lib\clangAnalysis.lib  lib\clangASTMatchers.lib  
lib\clangEdit.lib  lib\clangDriver.lib  version.lib  lib\LLVMOption.lib  
lib\clangFormat.lib  lib\clangToolingInclusions.lib  lib\clangToolingCore.lib  
lib\clangAST.lib  lib\LLVMFrontendOpenMP.lib  lib\LLVMTransformUtils.lib  
lib\LLVMAnalysis.lib  lib\LLVMProfileData.lib  lib\LLVMObject.lib  
lib\LLVMBitReader.lib  lib\LLVMMCParser.lib  lib\LLVMTextAPI.lib  
lib\clangRewrite.lib  lib\clangLex.lib  lib\clangBasic.lib  lib\LLVMCore.lib  
lib\LLVMRemarks.lib  lib\LLVMBitstreamReader.lib  lib\LLVMMC.lib  
lib\LLVMBinaryFormat.lib  lib\LLVMDebugInfoCodeView.lib  
lib\LLVMDebugInfoMSF.lib  lib\LLVMSupport.lib  psapi.lib  shell32.lib  
ole32.lib  uuid.lib  advapi32.lib  delayimp.lib  -delayload:shell32.dll  
-delayload:ole32.dll  lib\LLVMDemangle.lib  kernel32.lib user32.lib gdi32.lib 
winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib 
advapi32.lib && cd ."
  LINK: command "D:\llvm-project\buildninjaRel\bin\lld-link.exe /nologo 
tools\clang\unittests\StaticAnalyzer\CMakeFiles\StaticAnalysisTests.dir\AnalyzerOptionsTest.cpp.obj
 
tools\clang\unittests\StaticAnalyzer\CMakeFiles\StaticAnalysisTests.dir\CallDescriptionTest.cpp.obj
 
tools\clang\unittests\StaticAnalyzer\CMakeFiles\StaticAnalysisTests.dir\StoreTest.cpp.obj
 
tools\clang\unittests\StaticAnalyzer\CMakeFiles\StaticAnalysisTests.dir\RegisterCustomCheckersTest.cpp.obj
 
tools\clang\unittests\StaticAnalyzer\CMakeFiles\StaticAnalysisTests.dir\SymbolReaperTest.cpp.obj
 
tools\clang\unittests\StaticAnalyzer\CMakeFiles\StaticAnalysisTests.dir\D_\llvm-project\llvm\resources\windows_version_resource.rc.res
 /out:tools\clang\unittests\StaticAnalyzer\StaticAnalysisTests.exe 
/implib:tools\clang\unittests\StaticAnalyzer\StaticAnalysisTests.lib 
/pdb:tools\clang\unittests\StaticAnalyzer\StaticAnalysisTests.pdb /version:0.0 
/machine:x64 -fuse-ld=lld /STACK:1000 /DEBUG /OPT:REF /OPT:ICF 
/lldltocache:D:/llvm-projec

[clang] 7e77cf4 - [Clang] Fix Hurd toolchain test on a two-stage build with ThinLTO

2020-03-02 Thread Alexandre Ganea via cfe-commits

Author: Alexandre Ganea
Date: 2020-03-02T15:42:33-05:00
New Revision: 7e77cf473ac9d8f8b65db017d660892f1c8f4b75

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

LOG: [Clang] Fix Hurd toolchain test on a two-stage build with ThinLTO

A two-stage ThinLTO build previously failed the clang/test/Driver/hurd.c test 
because of a static_cast in "tools::gnutools::Linker::ConstructJob()" which 
wrongly converted an instance of "clang::driver::toolchains::Hurd" into that of 
"clang::driver::toolchains::Linux". ThinLTO would later devirtualize the 
"ToolChain.getDynamicLinker(Args)" call and use "Linux::getDynamicLinker()" 
instead, causing the test to generate a wrong "-dynamic-linker" linker flag 
(/lib/ld-linux.so.2 instead of /lib/ld.so)

Fixes PR45061.

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

Added: 


Modified: 
clang/lib/Driver/ToolChains/Gnu.cpp
clang/lib/Driver/ToolChains/Gnu.h
clang/lib/Driver/ToolChains/Hurd.cpp
clang/lib/Driver/ToolChains/Hurd.h
clang/lib/Driver/ToolChains/Linux.cpp
clang/lib/Driver/ToolChains/Linux.h

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Gnu.cpp 
b/clang/lib/Driver/ToolChains/Gnu.cpp
index c356657541fa..d20d62987589 100644
--- a/clang/lib/Driver/ToolChains/Gnu.cpp
+++ b/clang/lib/Driver/ToolChains/Gnu.cpp
@@ -309,7 +309,7 @@ static const char *getLDMOption(const llvm::Triple &T, 
const ArgList &Args) {
   }
 }
 
-static bool getPIE(const ArgList &Args, const toolchains::Linux &ToolChain) {
+static bool getPIE(const ArgList &Args, const ToolChain &TC) {
   if (Args.hasArg(options::OPT_shared) || Args.hasArg(options::OPT_static) ||
   Args.hasArg(options::OPT_r) || Args.hasArg(options::OPT_static_pie))
 return false;
@@ -317,17 +317,16 @@ static bool getPIE(const ArgList &Args, const 
toolchains::Linux &ToolChain) {
   Arg *A = Args.getLastArg(options::OPT_pie, options::OPT_no_pie,
options::OPT_nopie);
   if (!A)
-return ToolChain.isPIEDefault();
+return TC.isPIEDefault();
   return A->getOption().matches(options::OPT_pie);
 }
 
-static bool getStaticPIE(const ArgList &Args,
- const toolchains::Linux &ToolChain) {
+static bool getStaticPIE(const ArgList &Args, const ToolChain &TC) {
   bool HasStaticPIE = Args.hasArg(options::OPT_static_pie);
   // -no-pie is an alias for -nopie. So, handling -nopie takes care of
   // -no-pie as well.
   if (HasStaticPIE && Args.hasArg(options::OPT_nopie)) {
-const Driver &D = ToolChain.getDriver();
+const Driver &D = TC.getDriver();
 const llvm::opt::OptTable &Opts = D.getOpts();
 const char *StaticPIEName = Opts.getOptionName(options::OPT_static_pie);
 const char *NoPIEName = Opts.getOptionName(options::OPT_nopie);
@@ -346,8 +345,12 @@ void tools::gnutools::Linker::ConstructJob(Compilation &C, 
const JobAction &JA,
const InputInfoList &Inputs,
const ArgList &Args,
const char *LinkingOutput) const {
-  const toolchains::Linux &ToolChain =
-  static_cast(getToolChain());
+  // FIXME: The Linker class constructor takes a ToolChain and not a
+  // Generic_ELF, so the static_cast might return a reference to a invalid
+  // instance (see PR45061). Ideally, the Linker constructor needs to take a
+  // Generic_ELF instead.
+  const toolchains::Generic_ELF &ToolChain =
+  static_cast(getToolChain());
   const Driver &D = ToolChain.getDriver();
 
   const llvm::Triple &Triple = getToolChain().getEffectiveTriple();
@@ -418,8 +421,7 @@ void tools::gnutools::Linker::ConstructJob(Compilation &C, 
const JobAction &JA,
   if (isAndroid)
   CmdArgs.push_back("--warn-shared-textrel");
 
-  for (const auto &Opt : ToolChain.ExtraOpts)
-CmdArgs.push_back(Opt.c_str());
+  ToolChain.addExtraOpts(CmdArgs);
 
   CmdArgs.push_back("--eh-frame-hdr");
 

diff  --git a/clang/lib/Driver/ToolChains/Gnu.h 
b/clang/lib/Driver/ToolChains/Gnu.h
index 083f74c05477..fa50b56bf954 100644
--- a/clang/lib/Driver/ToolChains/Gnu.h
+++ b/clang/lib/Driver/ToolChains/Gnu.h
@@ -356,6 +356,12 @@ class LLVM_LIBRARY_VISIBILITY Generic_ELF : public 
Generic_GCC {
   void addClangTargetOptions(const llvm::opt::ArgList &DriverArgs,
  llvm::opt::ArgStringList &CC1Args,
  Action::OffloadKind DeviceOffloadKind) const 
override;
+
+  virtual std::string getDynamicLinker(const llvm::opt::ArgList &Args) const {
+return {};
+  }
+
+  virtual void addExtraOpts(llvm::opt::ArgStringList &CmdArgs) const {}
 };
 
 } // end namespace toolchains

diff  --git a/clang/lib/Driver/ToolChains/Hurd.cpp 
b/clang/lib/Driver/ToolChains/Hurd.cpp
index 7228

[clang] 9c1baa2 - re-land [DebugInfo] Add debug location to stubs generated by CGDeclCXX and mark them as artificial

2019-11-16 Thread Alexandre Ganea via cfe-commits

Author: Alexandre Ganea
Date: 2019-11-15T16:01:39-05:00
New Revision: 9c1baa23526c6d7d06eafefbf82d73bfe9bb3aaf

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

LOG: re-land [DebugInfo] Add debug location to stubs generated by CGDeclCXX and 
mark them as artificial

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

Added: 
clang/test/CodeGenCXX/debug-info-atexit-stub.cpp
clang/test/CodeGenCXX/debug-info-destroy-helper.cpp

Modified: 
clang/include/clang/AST/GlobalDecl.h
clang/lib/CodeGen/CGDebugInfo.cpp
clang/lib/CodeGen/CGDeclCXX.cpp
clang/test/CodeGenCXX/debug-info-global-ctor-dtor.cpp
clang/test/CodeGenCXX/debug-info-line.cpp

Removed: 




diff  --git a/clang/include/clang/AST/GlobalDecl.h 
b/clang/include/clang/AST/GlobalDecl.h
index 145e961a23a3..ab14d9678812 100644
--- a/clang/include/clang/AST/GlobalDecl.h
+++ b/clang/include/clang/AST/GlobalDecl.h
@@ -31,6 +31,7 @@ enum class DynamicInitKind : unsigned {
   NoStub = 0,
   Initializer,
   AtExit,
+  GlobalArrayDestructor
 };
 
 /// GlobalDecl - represents a global declaration. This can either be a

diff  --git a/clang/lib/CodeGen/CGDebugInfo.cpp 
b/clang/lib/CodeGen/CGDebugInfo.cpp
index 75c4b2ae2339..41459018a3bf 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -1944,7 +1944,8 @@ StringRef CGDebugInfo::getDynamicInitializerName(const 
VarDecl *VD,
  llvm::Function *InitFn) {
   // If we're not emitting codeview, use the mangled name. For Itanium, this is
   // arbitrary.
-  if (!CGM.getCodeGenOpts().EmitCodeView)
+  if (!CGM.getCodeGenOpts().EmitCodeView ||
+  StubKind == DynamicInitKind::GlobalArrayDestructor)
 return InitFn->getName();
 
   // Print the normal qualified name for the variable, then break off the last
@@ -1969,6 +1970,7 @@ StringRef CGDebugInfo::getDynamicInitializerName(const 
VarDecl *VD,
 
   switch (StubKind) {
   case DynamicInitKind::NoStub:
+  case DynamicInitKind::GlobalArrayDestructor:
 llvm_unreachable("not an initializer");
   case DynamicInitKind::Initializer:
 OS << "`dynamic initializer for '";
@@ -3644,7 +3646,8 @@ void CGDebugInfo::EmitFunctionStart(GlobalDecl GD, 
SourceLocation Loc,
   if (Name.startswith("\01"))
 Name = Name.substr(1);
 
-  if (!HasDecl || D->isImplicit() || D->hasAttr()) {
+  if (!HasDecl || D->isImplicit() || D->hasAttr() ||
+  (isa(D) && GD.getDynamicInitKind() != DynamicInitKind::NoStub)) 
{
 Flags |= llvm::DINode::FlagArtificial;
 // Artificial functions should not silently reuse CurLoc.
 CurLoc = SourceLocation();

diff  --git a/clang/lib/CodeGen/CGDeclCXX.cpp b/clang/lib/CodeGen/CGDeclCXX.cpp
index 5b172a3480be..95bd00010395 100644
--- a/clang/lib/CodeGen/CGDeclCXX.cpp
+++ b/clang/lib/CodeGen/CGDeclCXX.cpp
@@ -244,6 +244,8 @@ llvm::Function *CodeGenFunction::createAtExitStub(const 
VarDecl &VD,
 
   CGF.StartFunction(GlobalDecl(&VD, DynamicInitKind::AtExit),
 CGM.getContext().VoidTy, fn, FI, FunctionArgList());
+  // Emit an artificial location for this function.
+  auto AL = ApplyDebugLocation::CreateArtificial(CGF);
 
   llvm::CallInst *call = CGF.Builder.CreateCall(dtor, addr);
 
@@ -644,8 +646,9 @@ void 
CodeGenFunction::GenerateCXXGlobalVarDeclInitFunc(llvm::Function *Fn,
 
   StartFunction(GlobalDecl(D, DynamicInitKind::Initializer),
 getContext().VoidTy, Fn, getTypes().arrangeNullaryFunction(),
-FunctionArgList(), D->getLocation(),
-D->getInit()->getExprLoc());
+FunctionArgList());
+  // Emit an artificial location for this function.
+  auto AL = ApplyDebugLocation::CreateArtificial(*this);
 
   // Use guarded initialization if the global variable is weak. This
   // occurs for, e.g., instantiated static data members and
@@ -770,7 +773,10 @@ llvm::Function *CodeGenFunction::generateDestroyHelper(
 
   CurEHLocation = VD->getBeginLoc();
 
-  StartFunction(VD, getContext().VoidTy, fn, FI, args);
+  StartFunction(GlobalDecl(VD, DynamicInitKind::GlobalArrayDestructor),
+getContext().VoidTy, fn, FI, args);
+  // Emit an artificial location for this function.
+  auto AL = ApplyDebugLocation::CreateArtificial(*this);
 
   emitDestroy(addr, type, destroyer, useEHCleanupForArray);
 

diff  --git a/clang/test/CodeGenCXX/debug-info-atexit-stub.cpp 
b/clang/test/CodeGenCXX/debug-info-atexit-stub.cpp
new file mode 100644
index ..8ff2ca5d2f2c
--- /dev/null
+++ b/clang/test/CodeGenCXX/debug-info-atexit-stub.cpp
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -emit-llvm %s -triple x86_64-windows-msvc -gcodeview 
-debug-info-kind=limited -o - | FileCheck %s
+
+struct a {
+  ~a();
+};
+template  struct c : a {
+  c(void (b:

[clang] caf3166 - Revert "re-land [DebugInfo] Add debug location to stubs generated by CGDeclCXX and mark them as artificial"

2019-11-16 Thread Alexandre Ganea via cfe-commits

Author: Alexandre Ganea
Date: 2019-11-15T16:21:17-05:00
New Revision: caf3166d40ffbb0d61b29f423318ce6cfbcf4a9f

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

LOG: Revert "re-land [DebugInfo] Add debug location to stubs generated by 
CGDeclCXX and mark them as artificial"

This reverts commit 9c1baa23526c6d7d06eafefbf82d73bfe9bb3aaf.

Added: 


Modified: 
clang/include/clang/AST/GlobalDecl.h
clang/lib/CodeGen/CGDebugInfo.cpp
clang/lib/CodeGen/CGDeclCXX.cpp
clang/test/CodeGenCXX/debug-info-global-ctor-dtor.cpp
clang/test/CodeGenCXX/debug-info-line.cpp

Removed: 
clang/test/CodeGenCXX/debug-info-atexit-stub.cpp
clang/test/CodeGenCXX/debug-info-destroy-helper.cpp



diff  --git a/clang/include/clang/AST/GlobalDecl.h 
b/clang/include/clang/AST/GlobalDecl.h
index ab14d9678812..145e961a23a3 100644
--- a/clang/include/clang/AST/GlobalDecl.h
+++ b/clang/include/clang/AST/GlobalDecl.h
@@ -31,7 +31,6 @@ enum class DynamicInitKind : unsigned {
   NoStub = 0,
   Initializer,
   AtExit,
-  GlobalArrayDestructor
 };
 
 /// GlobalDecl - represents a global declaration. This can either be a

diff  --git a/clang/lib/CodeGen/CGDebugInfo.cpp 
b/clang/lib/CodeGen/CGDebugInfo.cpp
index 41459018a3bf..75c4b2ae2339 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -1944,8 +1944,7 @@ StringRef CGDebugInfo::getDynamicInitializerName(const 
VarDecl *VD,
  llvm::Function *InitFn) {
   // If we're not emitting codeview, use the mangled name. For Itanium, this is
   // arbitrary.
-  if (!CGM.getCodeGenOpts().EmitCodeView ||
-  StubKind == DynamicInitKind::GlobalArrayDestructor)
+  if (!CGM.getCodeGenOpts().EmitCodeView)
 return InitFn->getName();
 
   // Print the normal qualified name for the variable, then break off the last
@@ -1970,7 +1969,6 @@ StringRef CGDebugInfo::getDynamicInitializerName(const 
VarDecl *VD,
 
   switch (StubKind) {
   case DynamicInitKind::NoStub:
-  case DynamicInitKind::GlobalArrayDestructor:
 llvm_unreachable("not an initializer");
   case DynamicInitKind::Initializer:
 OS << "`dynamic initializer for '";
@@ -3646,8 +3644,7 @@ void CGDebugInfo::EmitFunctionStart(GlobalDecl GD, 
SourceLocation Loc,
   if (Name.startswith("\01"))
 Name = Name.substr(1);
 
-  if (!HasDecl || D->isImplicit() || D->hasAttr() ||
-  (isa(D) && GD.getDynamicInitKind() != DynamicInitKind::NoStub)) 
{
+  if (!HasDecl || D->isImplicit() || D->hasAttr()) {
 Flags |= llvm::DINode::FlagArtificial;
 // Artificial functions should not silently reuse CurLoc.
 CurLoc = SourceLocation();

diff  --git a/clang/lib/CodeGen/CGDeclCXX.cpp b/clang/lib/CodeGen/CGDeclCXX.cpp
index 95bd00010395..5b172a3480be 100644
--- a/clang/lib/CodeGen/CGDeclCXX.cpp
+++ b/clang/lib/CodeGen/CGDeclCXX.cpp
@@ -244,8 +244,6 @@ llvm::Function *CodeGenFunction::createAtExitStub(const 
VarDecl &VD,
 
   CGF.StartFunction(GlobalDecl(&VD, DynamicInitKind::AtExit),
 CGM.getContext().VoidTy, fn, FI, FunctionArgList());
-  // Emit an artificial location for this function.
-  auto AL = ApplyDebugLocation::CreateArtificial(CGF);
 
   llvm::CallInst *call = CGF.Builder.CreateCall(dtor, addr);
 
@@ -646,9 +644,8 @@ void 
CodeGenFunction::GenerateCXXGlobalVarDeclInitFunc(llvm::Function *Fn,
 
   StartFunction(GlobalDecl(D, DynamicInitKind::Initializer),
 getContext().VoidTy, Fn, getTypes().arrangeNullaryFunction(),
-FunctionArgList());
-  // Emit an artificial location for this function.
-  auto AL = ApplyDebugLocation::CreateArtificial(*this);
+FunctionArgList(), D->getLocation(),
+D->getInit()->getExprLoc());
 
   // Use guarded initialization if the global variable is weak. This
   // occurs for, e.g., instantiated static data members and
@@ -773,10 +770,7 @@ llvm::Function *CodeGenFunction::generateDestroyHelper(
 
   CurEHLocation = VD->getBeginLoc();
 
-  StartFunction(GlobalDecl(VD, DynamicInitKind::GlobalArrayDestructor),
-getContext().VoidTy, fn, FI, args);
-  // Emit an artificial location for this function.
-  auto AL = ApplyDebugLocation::CreateArtificial(*this);
+  StartFunction(VD, getContext().VoidTy, fn, FI, args);
 
   emitDestroy(addr, type, destroyer, useEHCleanupForArray);
 

diff  --git a/clang/test/CodeGenCXX/debug-info-atexit-stub.cpp 
b/clang/test/CodeGenCXX/debug-info-atexit-stub.cpp
deleted file mode 100644
index 8ff2ca5d2f2c..
--- a/clang/test/CodeGenCXX/debug-info-atexit-stub.cpp
+++ /dev/null
@@ -1,20 +0,0 @@
-// RUN: %clang_cc1 -emit-llvm %s -triple x86_64-windows-msvc -gcodeview 
-debug-info-kind=limited -o - | FileCheck %s
-
-struct a {
-  ~a();
-};
-template  struct c

[clang] f55cd39 - [C-index] Fix test when using Debug target & MSVC STL

2019-11-19 Thread Alexandre Ganea via cfe-commits

Author: Alexandre Ganea
Date: 2019-11-19T13:30:40-05:00
New Revision: f55cd39f19134392b16bc1fd6c558214778a3bb8

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

LOG: [C-index] Fix test when using Debug target & MSVC STL

Avoids a deadlock in "clang/test/Index/crash-recovery-modules.m" when building 
with the MSVC STL & _ITERATOR_DEBUG_LEVEL == 2 (meaning a DEBUG build)

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

Added: 


Modified: 
clang/include/clang/Frontend/FrontendOptions.h

Removed: 




diff  --git a/clang/include/clang/Frontend/FrontendOptions.h 
b/clang/include/clang/Frontend/FrontendOptions.h
index 09d83adf579b..70eb3425b0da 100644
--- a/clang/include/clang/Frontend/FrontendOptions.h
+++ b/clang/include/clang/Frontend/FrontendOptions.h
@@ -366,7 +366,7 @@ class FrontendOptions {
   std::string ARCMTMigrateReportOut;
 
   /// The input files and their types.
-  std::vector Inputs;
+  SmallVector Inputs;
 
   /// When the input is a module map, the original module map file from which
   /// that map was inferred, if any (for umbrella modules).



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


[clang] 1abd4c9 - [Clang] Bypass distro detection on non-Linux hosts

2019-11-28 Thread Alexandre Ganea via cfe-commits

Author: Alexandre Ganea
Date: 2019-11-28T17:02:06-05:00
New Revision: 1abd4c94d7575e4cd288e0024c1ec79f17b048a9

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

LOG: [Clang] Bypass distro detection on non-Linux hosts

Skip distro detection when we're not running on Linux, or when the target 
triple is not Linux. This saves a few OS calls for each invocation of clang.exe.

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

Added: 


Modified: 
clang/include/clang/Driver/Distro.h
clang/lib/Driver/Distro.cpp
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Driver/ToolChains/Cuda.cpp
clang/lib/Driver/ToolChains/Linux.cpp
clang/unittests/Driver/DistroTest.cpp

Removed: 




diff  --git a/clang/include/clang/Driver/Distro.h 
b/clang/include/clang/Driver/Distro.h
index da8f819dee96..d382cf77a8b2 100644
--- a/clang/include/clang/Driver/Distro.h
+++ b/clang/include/clang/Driver/Distro.h
@@ -9,6 +9,7 @@
 #ifndef LLVM_CLANG_DRIVER_DISTRO_H
 #define LLVM_CLANG_DRIVER_DISTRO_H
 
+#include "llvm/ADT/Triple.h"
 #include "llvm/Support/VirtualFileSystem.h"
 
 namespace clang {
@@ -84,7 +85,7 @@ class Distro {
   Distro(DistroType D) : DistroVal(D) {}
 
   /// Detects the distribution using specified VFS.
-  explicit Distro(llvm::vfs::FileSystem &VFS);
+  explicit Distro(llvm::vfs::FileSystem &VFS, const llvm::Triple 
&TargetOrHost);
 
   bool operator==(const Distro &Other) const {
 return DistroVal == Other.DistroVal;

diff  --git a/clang/lib/Driver/Distro.cpp b/clang/lib/Driver/Distro.cpp
index 92e04108a7e2..06707fefc9d0 100644
--- a/clang/lib/Driver/Distro.cpp
+++ b/clang/lib/Driver/Distro.cpp
@@ -13,11 +13,28 @@
 #include "llvm/ADT/StringSwitch.h"
 #include "llvm/Support/ErrorOr.h"
 #include "llvm/Support/MemoryBuffer.h"
+#include "llvm/ADT/Triple.h"
 
 using namespace clang::driver;
 using namespace clang;
 
-static Distro::DistroType DetectDistro(llvm::vfs::FileSystem &VFS) {
+static Distro::DistroType DetectDistro(llvm::vfs::FileSystem &VFS,
+   const llvm::Triple &TargetOrHost) {
+  // If we don't target Linux, no need to check the distro. This saves a few
+  // OS calls.
+  if (!TargetOrHost.isOSLinux())
+return Distro::UnknownDistro;
+
+  // If the host is not running Linux, and we're backed by a real file system,
+  // no need to check the distro. This is the case where someone is
+  // cross-compiling from BSD or Windows to Linux, and it would be meaningless
+  // to try to figure out the "distro" of the non-Linux host.
+  IntrusiveRefCntPtr RealFS =
+  llvm::vfs::getRealFileSystem();
+  llvm::Triple HostTriple(llvm::sys::getProcessTriple());
+  if (!HostTriple.isOSLinux() && &VFS == RealFS.get())
+return Distro::UnknownDistro;
+
   llvm::ErrorOr> File =
   VFS.getBufferForFile("/etc/lsb-release");
   if (File) {
@@ -149,4 +166,5 @@ static Distro::DistroType 
DetectDistro(llvm::vfs::FileSystem &VFS) {
   return Distro::UnknownDistro;
 }
 
-Distro::Distro(llvm::vfs::FileSystem &VFS) : DistroVal(DetectDistro(VFS)) {}
+Distro::Distro(llvm::vfs::FileSystem &VFS, const llvm::Triple &TargetOrHost)
+: DistroVal(DetectDistro(VFS, TargetOrHost)) {}

diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 26d13c714670..03a6de812047 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -5619,7 +5619,7 @@ void Clang::ConstructJob(Compilation &C, const JobAction 
&JA,
 TC.getTriple().isOSBinFormatCOFF()) &&
   !TC.getTriple().isPS4() &&
   !TC.getTriple().isOSNetBSD() &&
-  !Distro(D.getVFS()).IsGentoo() &&
+  !Distro(D.getVFS(), TC.getTriple()).IsGentoo() &&
   !TC.getTriple().isAndroid() &&
TC.useIntegratedAs()))
 CmdArgs.push_back("-faddrsig");

diff  --git a/clang/lib/Driver/ToolChains/Cuda.cpp 
b/clang/lib/Driver/ToolChains/Cuda.cpp
index 8c704a3078ad..02871d2ce411 100644
--- a/clang/lib/Driver/ToolChains/Cuda.cpp
+++ b/clang/lib/Driver/ToolChains/Cuda.cpp
@@ -115,7 +115,8 @@ CudaInstallationDetector::CudaInstallationDetector(
 for (const char *Ver : Versions)
   Candidates.emplace_back(D.SysRoot + "/usr/local/cuda-" + Ver);
 
-if (Distro(D.getVFS()).IsDebian() || Distro(D.getVFS()).IsUbuntu())
+Distro Dist(D.getVFS(), llvm::Triple(llvm::sys::getProcessTriple()));
+if (Dist.IsDebian() || Dist.IsUbuntu())
   // Special case for Debian to have nvidia-cuda-toolkit work
   // out of the box. More info on http://bugs.debian.org/882505
   Candidates.emplace_back(D.SysRoot + "/usr/lib/cuda");

diff  --git a/clang/lib/Driver/ToolChains/Linux.cpp 
b/clang

[clang] 471d060 - [CIndex] Fix annotate-deep-statements test when using a Debug build

2019-11-29 Thread Alexandre Ganea via cfe-commits

Author: Alexandre Ganea
Date: 2019-11-29T10:52:20-05:00
New Revision: 471d06020a6a12c621131c508e58878890db3906

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

LOG: [CIndex] Fix annotate-deep-statements test when using a Debug build

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

Added: 


Modified: 
clang/lib/Sema/SemaChecking.cpp
clang/tools/libclang/CIndex.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index adefca7fe4e7..ed42833531d4 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -12950,7 +12950,8 @@ class SequenceChecker : public 
EvaluatedExprVisitor {
 //   expression or statement in the body of the function [and thus before
 //   the value computation of its result].
 SequencedSubexpression Sequenced(*this);
-Base::VisitCallExpr(CE);
+SemaRef.runWithSufficientStackSpace(CE->getExprLoc(),
+[&] { Base::VisitCallExpr(CE); });
 
 // FIXME: CXXNewExpr and CXXDeleteExpr implicitly call functions.
   }

diff  --git a/clang/tools/libclang/CIndex.cpp b/clang/tools/libclang/CIndex.cpp
index 2078e4719522..a8222356db44 100644
--- a/clang/tools/libclang/CIndex.cpp
+++ b/clang/tools/libclang/CIndex.cpp
@@ -3595,6 +3595,7 @@ enum CXErrorCode clang_parseTranslationUnit2(
 const char *const *command_line_args, int num_command_line_args,
 struct CXUnsavedFile *unsaved_files, unsigned num_unsaved_files,
 unsigned options, CXTranslationUnit *out_TU) {
+  noteBottomOfStack();
   SmallVector Args;
   Args.push_back("clang");
   Args.append(command_line_args, command_line_args + num_command_line_args);
@@ -3619,6 +3620,7 @@ enum CXErrorCode clang_parseTranslationUnit2FullArgv(
 
   CXErrorCode result = CXError_Failure;
   auto ParseTranslationUnitImpl = [=, &result] {
+noteBottomOfStack();
 result = clang_parseTranslationUnit_Impl(
 CIdx, source_filename, command_line_args, num_command_line_args,
 llvm::makeArrayRef(unsaved_files, num_unsaved_files), options, out_TU);
@@ -6622,9 +6624,10 @@ void clang_enableStackTraces(void) {
 
 void clang_executeOnThread(void (*fn)(void*), void *user_data,
unsigned stack_size) {
-  llvm::llvm_execute_on_thread(
-  fn, user_data,
-  stack_size == 0 ? llvm::None : llvm::Optional(stack_size));
+  llvm::llvm_execute_on_thread(fn, user_data,
+   stack_size == 0
+   ? clang::DesiredStackSize
+   : llvm::Optional(stack_size));
 }
 
 
//===--===//



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


[clang] 3b0b753 - On Windows, fix fuse-ld.c test when lld is provided explictly in -DCMAKE_LINKER

2019-11-29 Thread Alexandre Ganea via cfe-commits

Author: Alexandre Ganea
Date: 2019-11-29T11:28:49-05:00
New Revision: 3b0b7536a3182c1c69ade2bee80cdf954813a059

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

LOG: On Windows, fix fuse-ld.c test when lld is provided explictly in 
-DCMAKE_LINKER

Added: 


Modified: 
clang/test/Driver/fuse-ld.c

Removed: 




diff  --git a/clang/test/Driver/fuse-ld.c b/clang/test/Driver/fuse-ld.c
index 4b2ec7b1bb2a..13e709ccfdfa 100644
--- a/clang/test/Driver/fuse-ld.c
+++ b/clang/test/Driver/fuse-ld.c
@@ -79,13 +79,13 @@
 // RUN: %clang %s -### -fuse-ld=lld \
 // RUN: -target i686-unknown-windows-msvc 2>&1 \
 // RUN:   | FileCheck %s --check-prefix CHECK-WINDOWS-MSVC-LLD
-// CHECK-WINDOWS-MSVC-LLD: "{{.*}}lld-link"
+// CHECK-WINDOWS-MSVC-LLD: "{{.*}}lld-link{{\.exe"|"}}
 // CHECK-WINDOWS-MSVC-LLD-SAME: "-out:{{.*}}"
 
 // RUN: %clang %s -### -fuse-ld=lld-link \
 // RUN: -target i686-unknown-windows-msvc 2>&1 \
 // RUN:   | FileCheck %s --check-prefix CHECK-WINDOWS-MSVC-LLD-LINK
-// CHECK-WINDOWS-MSVC-LLD-LINK: "{{.*}}lld-link"
+// CHECK-WINDOWS-MSVC-LLD-LINK: "{{.*}}lld-link{{\.exe"|"}}
 // CHECK-WINDOWS-MSVC-LLD-LINK-SAME: "-out:{{.*}}"
 
 // RUN: %clang %s -### -fuse-ld=bfd \



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


[clang] 28ad9fc - [Clang][Driver] In -fintegrated-cc1 mode, avoid crashing on exit after a compiler crash

2020-03-13 Thread Alexandre Ganea via cfe-commits

Author: Alexandre Ganea
Date: 2020-03-13T08:15:35-04:00
New Revision: 28ad9fc20823678881baa0d723834b88ea9e8e3a

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

LOG: [Clang][Driver] In -fintegrated-cc1 mode, avoid crashing on exit after a 
compiler crash

After a crash catched by the CrashRecoveryContext, this patch prevents from 
accessing dangling pointers in TimerGroup structures before the clang tool 
exits. Previously, the default TimerGroup had internal linked lists which were 
still pointing to old Timer or TimerGroup instances, which lived in stack 
frames released by the CrashRecoveryContext.

Fixes PR45164.

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

Added: 


Modified: 
clang/lib/Lex/Pragma.cpp
clang/tools/driver/driver.cpp
llvm/include/llvm/Support/ManagedStatic.h
llvm/include/llvm/Support/Timer.h
llvm/lib/Support/Timer.cpp

Removed: 




diff  --git a/clang/lib/Lex/Pragma.cpp b/clang/lib/Lex/Pragma.cpp
index a8cd18b123b0..57a95815488e 100644
--- a/clang/lib/Lex/Pragma.cpp
+++ b/clang/lib/Lex/Pragma.cpp
@@ -42,6 +42,7 @@
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Compiler.h"
 #include "llvm/Support/ErrorHandling.h"
+#include "llvm/Support/Timer.h"
 #include 
 #include 
 #include 
@@ -1038,6 +1039,8 @@ struct PragmaDebugHandler : public PragmaHandler {
   if (!PP.getPreprocessorOpts().DisablePragmaDebugCrash)
 llvm_unreachable("This is an assertion!");
 } else if (II->isStr("crash")) {
+  llvm::Timer T("crash", "pragma crash");
+  llvm::TimeRegion R(&T);
   if (!PP.getPreprocessorOpts().DisablePragmaDebugCrash)
 LLVM_BUILTIN_TRAP;
 } else if (II->isStr("parser_crash")) {

diff  --git a/clang/tools/driver/driver.cpp b/clang/tools/driver/driver.cpp
index 843fa4bdbca2..c59752178b66 100644
--- a/clang/tools/driver/driver.cpp
+++ b/clang/tools/driver/driver.cpp
@@ -30,6 +30,7 @@
 #include "llvm/Option/ArgList.h"
 #include "llvm/Option/OptTable.h"
 #include "llvm/Option/Option.h"
+#include "llvm/Support/BuryPointer.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/CrashRecoveryContext.h"
 #include "llvm/Support/ErrorHandling.h"
@@ -491,6 +492,7 @@ int main(int argc_, const char **argv_) {
 
   std::unique_ptr C(TheDriver.BuildCompilation(argv));
   int Res = 1;
+  bool IsCrash = false;
   if (C && !C->containsError()) {
 SmallVector, 4> FailingCommands;
 Res = TheDriver.ExecuteCompilation(*C, FailingCommands);
@@ -517,11 +519,11 @@ int main(int argc_, const char **argv_) {
   // If result status is 70, then the driver command reported a fatal 
error.
   // On Windows, abort will return an exit code of 3.  In these cases,
   // generate additional diagnostic information if possible.
-  bool DiagnoseCrash = CommandRes < 0 || CommandRes == 70;
+  IsCrash = CommandRes < 0 || CommandRes == 70;
 #ifdef _WIN32
-  DiagnoseCrash |= CommandRes == 3;
+  IsCrash |= CommandRes == 3;
 #endif
-  if (DiagnoseCrash) {
+  if (IsCrash) {
 TheDriver.generateCompilationDiagnostics(*C, *FailingCommand);
 break;
   }
@@ -530,10 +532,16 @@ int main(int argc_, const char **argv_) {
 
   Diags.getClient()->finish();
 
-  // If any timers were active but haven't been destroyed yet, print their
-  // results now.  This happens in -disable-free mode.
-  llvm::TimerGroup::printAll(llvm::errs());
-  llvm::TimerGroup::clearAll();
+  if (!UseNewCC1Process && IsCrash) {
+// When crashing in -fintegrated-cc1 mode, bury the timer pointers, because
+// the internal linked list might point to already released stack frames.
+llvm::BuryPointer(llvm::TimerGroup::aquireDefaultGroup());
+  } else {
+// If any timers were active but haven't been destroyed yet, print their
+// results now.  This happens in -disable-free mode.
+llvm::TimerGroup::printAll(llvm::errs());
+llvm::TimerGroup::clearAll();
+  }
 
 #ifdef _WIN32
   // Exit status should not be negative on Win32, unless abnormal termination.

diff  --git a/llvm/include/llvm/Support/ManagedStatic.h 
b/llvm/include/llvm/Support/ManagedStatic.h
index e65bb051f181..bbd0d04ed040 100644
--- a/llvm/include/llvm/Support/ManagedStatic.h
+++ b/llvm/include/llvm/Support/ManagedStatic.h
@@ -102,6 +102,12 @@ class ManagedStatic : public ManagedStaticBase {
   }
 
   const C *operator->() const { return &**this; }
+
+  // Extract the instance, leaving the ManagedStatic uninitialized. The
+  // user is then responsible for the lifetime of the returned instance.
+  C *claim() {
+return static_cast(Ptr.exchange(nullptr));
+  }
 };
 
 /// llvm_shutdown - Deallocate and destroy all ManagedStatic variables.

diff  --git a/llvm/include/llvm/Support/Timer.h 
b/llvm/include/llvm/Support/Time

[clang] 8ecde3a - [Clang] Remove unused #pragma clang __debug handle_crash

2020-02-06 Thread Alexandre Ganea via cfe-commits

Author: Alexandre Ganea
Date: 2020-02-06T15:27:04-05:00
New Revision: 8ecde3ac34bbb5a8d53d8ec5cd32867658646df1

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

LOG: [Clang] Remove unused #pragma clang __debug handle_crash

As discussed in D70568, remove this because it isn't used anywhere, and I think 
it's better to go through real crashes for testing (#pragma clang __debug 
crash).
Also remove the support function llvm::CrashRecoveryContext::HandleCrash() 
which was added at the same time by @ddunbar.

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

Added: 


Modified: 
clang/lib/Lex/Pragma.cpp
llvm/include/llvm/Support/CrashRecoveryContext.h
llvm/lib/Support/CrashRecoveryContext.cpp

Removed: 




diff  --git a/clang/lib/Lex/Pragma.cpp b/clang/lib/Lex/Pragma.cpp
index e4636265a72b..c881bcac9f38 100644
--- a/clang/lib/Lex/Pragma.cpp
+++ b/clang/lib/Lex/Pragma.cpp
@@ -39,7 +39,6 @@
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringSwitch.h"
 #include "llvm/ADT/StringRef.h"
-#include "llvm/Support/CrashRecoveryContext.h"
 #include "llvm/Support/Compiler.h"
 #include "llvm/Support/ErrorHandling.h"
 #include 
@@ -1105,10 +1104,6 @@ struct PragmaDebugHandler : public PragmaHandler {
   M->dump();
 } else if (II->isStr("overflow_stack")) {
   DebugOverflowStack();
-} else if (II->isStr("handle_crash")) {
-  llvm::CrashRecoveryContext *CRC 
=llvm::CrashRecoveryContext::GetCurrent();
-  if (CRC)
-CRC->HandleCrash();
 } else if (II->isStr("captured")) {
   HandleCaptured(PP);
 } else {

diff  --git a/llvm/include/llvm/Support/CrashRecoveryContext.h 
b/llvm/include/llvm/Support/CrashRecoveryContext.h
index 9522c4742244..beeb855c7c58 100644
--- a/llvm/include/llvm/Support/CrashRecoveryContext.h
+++ b/llvm/include/llvm/Support/CrashRecoveryContext.h
@@ -97,10 +97,6 @@ class CrashRecoveryContext {
 return RunSafelyOnThread([&]() { Fn(UserData); }, RequestedStackSize);
   }
 
-  /// Explicitly trigger a crash recovery in the current process, and
-  /// return failure from RunSafely(). This function does not return.
-  void HandleCrash();
-
   /// In case of a crash, this is the crash identifier.
   int RetCode = 0;
 

diff  --git a/llvm/lib/Support/CrashRecoveryContext.cpp 
b/llvm/lib/Support/CrashRecoveryContext.cpp
index 510f46abe4b5..a24bf7bf2557 100644
--- a/llvm/lib/Support/CrashRecoveryContext.cpp
+++ b/llvm/lib/Support/CrashRecoveryContext.cpp
@@ -406,14 +406,6 @@ bool CrashRecoveryContext::RunSafely(function_ref 
Fn) {
 
 #endif // !_MSC_VER
 
-void CrashRecoveryContext::HandleCrash() {
-  CrashRecoveryContextImpl *CRCI = (CrashRecoveryContextImpl *) Impl;
-  assert(CRCI && "Crash recovery context never initialized!");
-  // As per convention, -2 indicates a crash or timeout as opposed to failure 
to
-  // execute (see llvm/include/llvm/Support/Program.h)
-  CRCI->HandleCrash(-2, 0);
-}
-
 // FIXME: Portability.
 static void setThreadBackgroundPriority() {
 #ifdef __APPLE__



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


[clang] 5fedc2b - [Clang] Avoid crashing when generating crash diagnostics when '#pragma clang __debug [assert|crash|parser_crash|llvm_fatal_error|llvm_unreachable|overflow_stack]' are used

2020-02-06 Thread Alexandre Ganea via cfe-commits

Author: Alexandre Ganea
Date: 2020-02-06T15:48:51-05:00
New Revision: 5fedc2b410853a6aef05e8edf19ebfc4e071e28f

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

LOG: [Clang] Avoid crashing when generating crash diagnostics when '#pragma 
clang __debug 
[assert|crash|parser_crash|llvm_fatal_error|llvm_unreachable|overflow_stack]' 
are used

Previously, when the above '#pragma clang __debug' were used, 
Driver::generateCompilationDiagnostics() wouldn't work as expected.
The 'clang -E' process created for diagnostics would crash, because it would 
reach again the intended crash in Pragma.cpp, 
PragmaDebugHandler::HandlePragma() while preprocessing.

When generating crash diagnostics, we now disable the intended crashing 
behavior with a new cc1 flag -disable-pragma-debug-crash.

Notes:
- #pragma clang __debug llvm_report_fatal isn't currently tested by 
crash-report.c, because it needs exit() to be handled differently in 
-fintegrated-cc1 mode. See https://reviews.llvm.org/D73742 for an upcoming fix.
- This is also needed to further validate that -MF is removed from the 'clang 
-E ' crash diagnostic cmd-line (currently not the case). See 
https://reviews.llvm.org/D74076 for an upcoming fix.

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

Added: 


Modified: 
clang/include/clang/Driver/CC1Options.td
clang/include/clang/Lex/PreprocessorOptions.h
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Frontend/CompilerInvocation.cpp
clang/lib/Lex/Pragma.cpp
clang/test/Driver/crash-report.c
clang/test/Driver/output-file-cleanup.c

Removed: 




diff  --git a/clang/include/clang/Driver/CC1Options.td 
b/clang/include/clang/Driver/CC1Options.td
index 0d0b05f8961c..733a1080be52 100644
--- a/clang/include/clang/Driver/CC1Options.td
+++ b/clang/include/clang/Driver/CC1Options.td
@@ -866,6 +866,8 @@ def detailed_preprocessing_record : Flag<["-"], 
"detailed-preprocessing-record">
   HelpText<"include a detailed record of preprocessing actions">;
 def setup_static_analyzer : Flag<["-"], "setup-static-analyzer">,
   HelpText<"Set up preprocessor for static analyzer (done automatically when 
static analyzer is run).">;
+def disable_pragma_debug_crash : Flag<["-"], "disable-pragma-debug-crash">,
+  HelpText<"Disable any #pragma clang __debug that can lead to crashing 
behavior. This is meant for testing.">;
 
 
//===--===//
 // OpenCL Options

diff  --git a/clang/include/clang/Lex/PreprocessorOptions.h 
b/clang/include/clang/Lex/PreprocessorOptions.h
index c281cd51e266..c551f87e0d7b 100644
--- a/clang/include/clang/Lex/PreprocessorOptions.h
+++ b/clang/include/clang/Lex/PreprocessorOptions.h
@@ -189,6 +189,9 @@ class PreprocessorOptions {
   /// Set up preprocessor for RunAnalysis action.
   bool SetUpStaticAnalyzer = false;
 
+  /// Prevents intended crashes when using #pragma clang __debug. For testing.
+  bool DisablePragmaDebugCrash = false;
+
 public:
   PreprocessorOptions() : PrecompiledPreambleBytes(0, false) {}
 

diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 65039ac64b5a..9e2279e90b7e 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -4750,6 +4750,11 @@ void Clang::ConstructJob(Compilation &C, const JobAction 
&JA,
  : "-");
   }
 
+  // Give the gen diagnostics more chances to succeed, by avoiding intentional
+  // crashes.
+  if (D.CCGenDiagnostics)
+CmdArgs.push_back("-disable-pragma-debug-crash");
+
   bool UseSeparateSections = isUseSeparateSections(Triple);
 
   if (Args.hasFlag(options::OPT_ffunction_sections,

diff  --git a/clang/lib/Frontend/CompilerInvocation.cpp 
b/clang/lib/Frontend/CompilerInvocation.cpp
index 2fd66b6f546b..f95e8b4f0417 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -3470,6 +3470,7 @@ static void ParsePreprocessorArgs(PreprocessorOptions 
&Opts, ArgList &Args,
 Opts.LexEditorPlaceholders = false;
 
   Opts.SetUpStaticAnalyzer = Args.hasArg(OPT_setup_static_analyzer);
+  Opts.DisablePragmaDebugCrash = Args.hasArg(OPT_disable_pragma_debug_crash);
 }
 
 static void ParsePreprocessorOutputArgs(PreprocessorOutputOptions &Opts,

diff  --git a/clang/lib/Lex/Pragma.cpp b/clang/lib/Lex/Pragma.cpp
index c881bcac9f38..a8cd18b123b0 100644
--- a/clang/lib/Lex/Pragma.cpp
+++ b/clang/lib/Lex/Pragma.cpp
@@ -30,6 +30,7 @@
 #include "clang/Lex/PPCallbacks.h"
 #include "clang/Lex/Preprocessor.h"
 #include "clang/Lex/PreprocessorLexer.h"
+#include "clang/Lex/PreprocessorOptions.h"
 #include "clang/Lex/Token.h"
 #include "clang/Lex/TokenLexer.h"
 #include "llvm/ADT/ArrayRef

[clang] f41ec70 - [Clang][Driver] Remove -M group options before generating crash diagnostics

2020-02-06 Thread Alexandre Ganea via cfe-commits

Author: Alexandre Ganea
Date: 2020-02-06T16:23:25-05:00
New Revision: f41ec709d9d388dc43469e6ac7f51b6313f7e4af

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

LOG: [Clang][Driver] Remove -M group options before generating crash diagnostics

Previously, when using '-MF file.d' on the command line, 'file.d' would not be 
deleted after a compiler crash.

The code path in Compilation::initCompilationForDiagnostics()  that was 
modifying 'TranslatedArgs' had no effect, because 'TCArgs' was already created 
after the crash.

This was covered by clang/test/Driver/output-file-cleanup.c, the test was 
succeeding by fluke because Driver::generateCompilationDiagnostics() would fail 
to launch the subsequent clang -E (see D74070 for a fix for this). So the test 
was only covering Driver.cpp, C.CleanupFileMap().
After this patch, both cleanup and removal of -MF are exercised.

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

Added: 


Modified: 
clang/lib/Driver/Compilation.cpp
clang/test/Driver/output-file-cleanup.c

Removed: 




diff  --git a/clang/lib/Driver/Compilation.cpp 
b/clang/lib/Driver/Compilation.cpp
index 25aec3690f21..52477576b2eb 100644
--- a/clang/lib/Driver/Compilation.cpp
+++ b/clang/lib/Driver/Compilation.cpp
@@ -258,14 +258,23 @@ void Compilation::initCompilationForDiagnostics() {
 
   // Remove any user specified output.  Claim any unclaimed arguments, so as
   // to avoid emitting warnings about unused args.
-  OptSpecifier OutputOpts[] = { options::OPT_o, options::OPT_MD,
-options::OPT_MMD };
+  OptSpecifier OutputOpts[] = {
+  options::OPT_o,  options::OPT_MD, options::OPT_MMD, options::OPT_M,
+  options::OPT_MM, options::OPT_MF, options::OPT_MG,  options::OPT_MJ,
+  options::OPT_MQ, options::OPT_MT, options::OPT_MV};
   for (unsigned i = 0, e = llvm::array_lengthof(OutputOpts); i != e; ++i) {
 if (TranslatedArgs->hasArg(OutputOpts[i]))
   TranslatedArgs->eraseArg(OutputOpts[i]);
   }
   TranslatedArgs->ClaimAllArgs();
 
+  // Force re-creation of the toolchain Args, otherwise our modifications just
+  // above will have no effect.
+  for (auto Arg : TCArgs)
+if (Arg.second != TranslatedArgs)
+  delete Arg.second;
+  TCArgs.clear();
+
   // Redirect stdout/stderr to /dev/null.
   Redirects = {None, {""}, {""}};
 

diff  --git a/clang/test/Driver/output-file-cleanup.c 
b/clang/test/Driver/output-file-cleanup.c
index 4dcb5ae5d938..c572b25cecef 100644
--- a/clang/test/Driver/output-file-cleanup.c
+++ b/clang/test/Driver/output-file-cleanup.c
@@ -1,7 +1,4 @@
 
-// Temporarily disable this test until the -MF flag is properly removed from 
the diagnostics generation.
-// XFAIL: *
-
 // RUN: rm -f "%t.d" "%t1.s" "%t2.s" "%t3.s" "%t4.s" "%t5.s"
 //
 // RUN: touch %t.s



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


[clang] 75f09b5 - Re-land "[Clang][Driver] Remove -M group options ..." and "[Clang] Avoid crashing when generating crash diagnostics when '#pragma clang __debug ..."

2020-02-07 Thread Alexandre Ganea via cfe-commits

Author: Alexandre Ganea
Date: 2020-02-07T09:51:09-05:00
New Revision: 75f09b54429bee17a96e2ba7a2ac0f0a8a7f7e74

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

LOG: Re-land "[Clang][Driver] Remove -M group options ..." and "[Clang] Avoid 
crashing when generating crash diagnostics when '#pragma clang __debug ..."

This re-lands commits f41ec709d9d388dc43469e6ac7f51b6313f7e4af 
(https://reviews.llvm.org/D74076)
and commit 5fedc2b410853a6aef05e8edf19ebfc4e071e28f 
(https://reviews.llvm.org/D74070)

The previous build break was caused by '#pragma clang __debug llvm_unreachable' 
used in a non-assert build. Move it to a separate test in 
crash-report-with-asserts.c.

Added: 
clang/test/Driver/crash-report-with-asserts.c

Modified: 
clang/include/clang/Driver/CC1Options.td
clang/include/clang/Lex/PreprocessorOptions.h
clang/lib/Driver/Compilation.cpp
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Frontend/CompilerInvocation.cpp
clang/lib/Lex/Pragma.cpp
clang/test/Driver/crash-report.c

Removed: 




diff  --git a/clang/include/clang/Driver/CC1Options.td 
b/clang/include/clang/Driver/CC1Options.td
index 0d0b05f8961c..733a1080be52 100644
--- a/clang/include/clang/Driver/CC1Options.td
+++ b/clang/include/clang/Driver/CC1Options.td
@@ -866,6 +866,8 @@ def detailed_preprocessing_record : Flag<["-"], 
"detailed-preprocessing-record">
   HelpText<"include a detailed record of preprocessing actions">;
 def setup_static_analyzer : Flag<["-"], "setup-static-analyzer">,
   HelpText<"Set up preprocessor for static analyzer (done automatically when 
static analyzer is run).">;
+def disable_pragma_debug_crash : Flag<["-"], "disable-pragma-debug-crash">,
+  HelpText<"Disable any #pragma clang __debug that can lead to crashing 
behavior. This is meant for testing.">;
 
 
//===--===//
 // OpenCL Options

diff  --git a/clang/include/clang/Lex/PreprocessorOptions.h 
b/clang/include/clang/Lex/PreprocessorOptions.h
index c281cd51e266..c551f87e0d7b 100644
--- a/clang/include/clang/Lex/PreprocessorOptions.h
+++ b/clang/include/clang/Lex/PreprocessorOptions.h
@@ -189,6 +189,9 @@ class PreprocessorOptions {
   /// Set up preprocessor for RunAnalysis action.
   bool SetUpStaticAnalyzer = false;
 
+  /// Prevents intended crashes when using #pragma clang __debug. For testing.
+  bool DisablePragmaDebugCrash = false;
+
 public:
   PreprocessorOptions() : PrecompiledPreambleBytes(0, false) {}
 

diff  --git a/clang/lib/Driver/Compilation.cpp 
b/clang/lib/Driver/Compilation.cpp
index 25aec3690f21..52477576b2eb 100644
--- a/clang/lib/Driver/Compilation.cpp
+++ b/clang/lib/Driver/Compilation.cpp
@@ -258,14 +258,23 @@ void Compilation::initCompilationForDiagnostics() {
 
   // Remove any user specified output.  Claim any unclaimed arguments, so as
   // to avoid emitting warnings about unused args.
-  OptSpecifier OutputOpts[] = { options::OPT_o, options::OPT_MD,
-options::OPT_MMD };
+  OptSpecifier OutputOpts[] = {
+  options::OPT_o,  options::OPT_MD, options::OPT_MMD, options::OPT_M,
+  options::OPT_MM, options::OPT_MF, options::OPT_MG,  options::OPT_MJ,
+  options::OPT_MQ, options::OPT_MT, options::OPT_MV};
   for (unsigned i = 0, e = llvm::array_lengthof(OutputOpts); i != e; ++i) {
 if (TranslatedArgs->hasArg(OutputOpts[i]))
   TranslatedArgs->eraseArg(OutputOpts[i]);
   }
   TranslatedArgs->ClaimAllArgs();
 
+  // Force re-creation of the toolchain Args, otherwise our modifications just
+  // above will have no effect.
+  for (auto Arg : TCArgs)
+if (Arg.second != TranslatedArgs)
+  delete Arg.second;
+  TCArgs.clear();
+
   // Redirect stdout/stderr to /dev/null.
   Redirects = {None, {""}, {""}};
 

diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 65039ac64b5a..9e2279e90b7e 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -4750,6 +4750,11 @@ void Clang::ConstructJob(Compilation &C, const JobAction 
&JA,
  : "-");
   }
 
+  // Give the gen diagnostics more chances to succeed, by avoiding intentional
+  // crashes.
+  if (D.CCGenDiagnostics)
+CmdArgs.push_back("-disable-pragma-debug-crash");
+
   bool UseSeparateSections = isUseSeparateSections(Triple);
 
   if (Args.hasFlag(options::OPT_ffunction_sections,

diff  --git a/clang/lib/Frontend/CompilerInvocation.cpp 
b/clang/lib/Frontend/CompilerInvocation.cpp
index d1d9a773f959..17e190627881 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -3471,6 +3471,7 @@ static void ParsePreprocessorArgs(PreprocessorOpt

[clang] faace36 - [Clang][Driver] After default -fintegrated-cc1, make llvm::report_fatal_error() generate preprocessed source + reproducer.sh again.

2020-02-11 Thread Alexandre Ganea via cfe-commits

Author: Alexandre Ganea
Date: 2020-02-11T10:17:30-05:00
New Revision: faace365088a2a3a4cb1050a9facfc34a7a56577

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

LOG: [Clang][Driver] After default -fintegrated-cc1, make 
llvm::report_fatal_error() generate preprocessed source + reproducer.sh again.

Added a test for #pragma clang __debug llvm_fatal_error to test for the 
original issue.
Added llvm::sys::Process::Exit() and replaced ::exit() in places where it was 
appropriate. This new function would call the current CrashRecoveryContext if 
one is running on the same thread; or call ::exit() otherwise.

Fixes PR44705.

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

Added: 


Modified: 
clang/test/Driver/crash-report.c
clang/tools/driver/cc1_main.cpp
clang/tools/driver/cc1as_main.cpp
llvm/include/llvm/Support/CrashRecoveryContext.h
llvm/include/llvm/Support/Process.h
llvm/lib/Support/CrashRecoveryContext.cpp
llvm/lib/Support/ErrorHandling.cpp
llvm/lib/Support/Process.cpp

Removed: 




diff  --git a/clang/test/Driver/crash-report.c 
b/clang/test/Driver/crash-report.c
index 3a77a21c62b4..ceb16cb6e18a 100644
--- a/clang/test/Driver/crash-report.c
+++ b/clang/test/Driver/crash-report.c
@@ -21,12 +21,20 @@
 // RUN: cat %t/crash-report-*.c | FileCheck --check-prefix=CHECKSRC %s
 // RUN: cat %t/crash-report-*.sh | FileCheck --check-prefix=CHECKSH %s
 
+// RUN: env TMPDIR=%t TEMP=%t TMP=%t RC_DEBUG_OPTIONS=1  \
+// RUN:  CC_PRINT_HEADERS=1 CC_LOG_DIAGNOSTICS=1 \
+// RUN:  not %clang %s @%t.rsp -DFATAL 2>&1 | FileCheck %s
+// RUN: cat %t/crash-report-*.c | FileCheck --check-prefix=CHECKSRC %s
+// RUN: cat %t/crash-report-*.sh | FileCheck --check-prefix=CHECKSH %s
+
 // REQUIRES: crash-recovery
 
 #ifdef PARSER
 #pragma clang __debug parser_crash
 #elif CRASH
 #pragma clang __debug crash
+#elif FATAL
+#pragma clang __debug llvm_fatal_error
 #endif
 
 // CHECK: Preprocessed source(s) and associated run script(s) are located at:

diff  --git a/clang/tools/driver/cc1_main.cpp b/clang/tools/driver/cc1_main.cpp
index b551e9f4cf82..6d1a67f2a4fa 100644
--- a/clang/tools/driver/cc1_main.cpp
+++ b/clang/tools/driver/cc1_main.cpp
@@ -36,6 +36,7 @@
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/ManagedStatic.h"
 #include "llvm/Support/Path.h"
+#include "llvm/Support/Process.h"
 #include "llvm/Support/Signals.h"
 #include "llvm/Support/TargetRegistry.h"
 #include "llvm/Support/TargetSelect.h"
@@ -69,7 +70,7 @@ static void LLVMErrorHandler(void *UserData, const 
std::string &Message,
   // We cannot recover from llvm errors.  When reporting a fatal error, exit
   // with status 70 to generate crash diagnostics.  For BSD systems this is
   // defined as an internal software error.  Otherwise, exit with status 1.
-  exit(GenCrashDiag ? 70 : 1);
+  llvm::sys::Process::Exit(GenCrashDiag ? 70 : 1);
 }
 
 #ifdef CLANG_HAVE_RLIMITS

diff  --git a/clang/tools/driver/cc1as_main.cpp 
b/clang/tools/driver/cc1as_main.cpp
index ce390b9f3b17..110f1dc70223 100644
--- a/clang/tools/driver/cc1as_main.cpp
+++ b/clang/tools/driver/cc1as_main.cpp
@@ -46,6 +46,7 @@
 #include "llvm/Support/Host.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/Path.h"
+#include "llvm/Support/Process.h"
 #include "llvm/Support/Signals.h"
 #include "llvm/Support/SourceMgr.h"
 #include "llvm/Support/TargetRegistry.h"
@@ -555,7 +556,7 @@ static void LLVMErrorHandler(void *UserData, const 
std::string &Message,
   Diags.Report(diag::err_fe_error_backend) << Message;
 
   // We cannot recover from llvm errors.
-  exit(1);
+  sys::Process::Exit(1);
 }
 
 int cc1as_main(ArrayRef Argv, const char *Argv0, void *MainAddr) 
{

diff  --git a/llvm/include/llvm/Support/CrashRecoveryContext.h 
b/llvm/include/llvm/Support/CrashRecoveryContext.h
index beeb855c7c58..61a1bd405a4d 100644
--- a/llvm/include/llvm/Support/CrashRecoveryContext.h
+++ b/llvm/include/llvm/Support/CrashRecoveryContext.h
@@ -97,6 +97,11 @@ class CrashRecoveryContext {
 return RunSafelyOnThread([&]() { Fn(UserData); }, RequestedStackSize);
   }
 
+  /// Explicitly trigger a crash recovery in the current process, and
+  /// return failure from RunSafely(). This function does not return.
+  LLVM_ATTRIBUTE_NORETURN
+  void HandleExit(int RetCode);
+
   /// In case of a crash, this is the crash identifier.
   int RetCode = 0;
 

diff  --git a/llvm/include/llvm/Support/Process.h 
b/llvm/include/llvm/Support/Process.h
index 9444e165e142..bb5c33dfb38d 100644
--- a/llvm/include/llvm/Support/Process.h
+++ b/llvm/include/llvm/Support/Process.h
@@ -201,6 +201,12 @@ class Process {
   /// Get the result of a process wide random number generator. The
   /// generator will be automatic

[clang] 60cba34 - [Clang] When -ftime-trace is used, clean CompilerInstance::OutputFiles before exiting cc_main()

2020-02-12 Thread Alexandre Ganea via cfe-commits

Author: Alexandre Ganea
Date: 2020-02-12T17:02:57-05:00
New Revision: 60cba345ca395ea991d7f2596c4a93439fbf9924

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

LOG: [Clang] When -ftime-trace is used, clean CompilerInstance::OutputFiles 
before exiting cc_main()

This fixes cc1 execution when '-disable-free' is not used (currently not the 
case, that flag is always used for cc1).

Added: 


Modified: 
clang/tools/driver/cc1_main.cpp

Removed: 




diff  --git a/clang/tools/driver/cc1_main.cpp b/clang/tools/driver/cc1_main.cpp
index 6d1a67f2a4fa..d8c22f21706b 100644
--- a/clang/tools/driver/cc1_main.cpp
+++ b/clang/tools/driver/cc1_main.cpp
@@ -259,6 +259,7 @@ int cc1_main(ArrayRef Argv, const char 
*Argv0, void *MainAddr) {
   // FIXME(ibiryukov): make profilerOutput flush in destructor instead.
   profilerOutput->flush();
   llvm::timeTraceProfilerCleanup();
+  Clang->clearOutputFiles(false);
 }
   }
 



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


[clang] 20f1abe - [Clang] Limit -fintegrated-cc1 to only one TU

2020-02-12 Thread Alexandre Ganea via cfe-commits

Author: Alexandre Ganea
Date: 2020-02-12T17:02:57-05:00
New Revision: 20f1abe306d030e99f56185a3aa077ffadf59b8a

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

LOG: [Clang] Limit -fintegrated-cc1 to only one TU

As discussed in https://reviews.llvm.org/D74447, this patch disables 
integrated-cc1 behavior if there's more than one job to be executed. This is 
meant to limit memory bloating, given that currently jobs don't clean up after 
execution (-disable-free is always active in cc1 mode).

I see this behavior as temporary until release 10.0 ships (to ease merging of 
this patch), then we'll reevaluate the situation, see if D74447 makes more 
sense on the long term.

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

Added: 


Modified: 
clang/include/clang/Driver/Job.h
clang/lib/Driver/Driver.cpp
clang/lib/Driver/Job.cpp
clang/lib/Driver/ToolChains/Clang.cpp
clang/test/Driver/cc1-spawnprocess.c

Removed: 




diff  --git a/clang/include/clang/Driver/Job.h 
b/clang/include/clang/Driver/Job.h
index 0765b3c67d4e..9a3cad23363b 100644
--- a/clang/include/clang/Driver/Job.h
+++ b/clang/include/clang/Driver/Job.h
@@ -55,9 +55,6 @@ class Command {
   /// The list of program arguments which are inputs.
   llvm::opt::ArgStringList InputFilenames;
 
-  /// Whether to print the input filenames when executing.
-  bool PrintInputFilenames = false;
-
   /// Response file name, if this command is set to use one, or nullptr
   /// otherwise
   const char *ResponseFile = nullptr;
@@ -86,6 +83,12 @@ class Command {
   void writeResponseFile(raw_ostream &OS) const;
 
 public:
+  /// Whether to print the input filenames when executing.
+  bool PrintInputFilenames = false;
+
+  /// Whether the command will be executed in this process or not.
+  bool InProcess = false;
+
   Command(const Action &Source, const Tool &Creator, const char *Executable,
   const llvm::opt::ArgStringList &Arguments,
   ArrayRef Inputs);
@@ -128,9 +131,6 @@ class Command {
   /// Print a command argument, and optionally quote it.
   static void printArg(llvm::raw_ostream &OS, StringRef Arg, bool Quote);
 
-  /// Set whether to print the input filenames when executing.
-  void setPrintInputFilenames(bool P) { PrintInputFilenames = P; }
-
 protected:
   /// Optionally print the filenames to be compiled
   void PrintFileNames() const;
@@ -139,7 +139,9 @@ class Command {
 /// Use the CC1 tool callback when available, to avoid creating a new process
 class CC1Command : public Command {
 public:
-  using Command::Command;
+  CC1Command(const Action &Source, const Tool &Creator, const char *Executable,
+ const llvm::opt::ArgStringList &Arguments,
+ ArrayRef Inputs);
 
   void Print(llvm::raw_ostream &OS, const char *Terminator, bool Quote,
  CrashReportInfo *CrashInfo = nullptr) const override;

diff  --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index f35aab19e83d..642b00b57fb6 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -3753,6 +3753,11 @@ void Driver::BuildJobs(Compilation &C) const {
/*TargetDeviceOffloadKind*/ Action::OFK_None);
   }
 
+  // If we have more than one job, then disable integrated-cc1 for now.
+  if (C.getJobs().size() > 1)
+for (auto &J : C.getJobs())
+  J.InProcess = false;
+
   // If the user passed -Qunused-arguments or there were errors, don't warn
   // about any unused arguments.
   if (Diags.hasErrorOccurred() ||

diff  --git a/clang/lib/Driver/Job.cpp b/clang/lib/Driver/Job.cpp
index 7dab2a022d92..6d1e7e61ba1d 100644
--- a/clang/lib/Driver/Job.cpp
+++ b/clang/lib/Driver/Job.cpp
@@ -371,14 +371,29 @@ int Command::Execute(ArrayRef> 
Redirects,
/*memoryLimit*/ 0, ErrMsg, ExecutionFailed);
 }
 
+CC1Command::CC1Command(const Action &Source, const Tool &Creator,
+   const char *Executable,
+   const llvm::opt::ArgStringList &Arguments,
+   ArrayRef Inputs)
+: Command(Source, Creator, Executable, Arguments, Inputs) {
+  InProcess = true;
+}
+
 void CC1Command::Print(raw_ostream &OS, const char *Terminator, bool Quote,
CrashReportInfo *CrashInfo) const {
-  OS << " (in-process)\n";
+  if (InProcess)
+OS << " (in-process)\n";
   Command::Print(OS, Terminator, Quote, CrashInfo);
 }
 
-int CC1Command::Execute(ArrayRef> /*Redirects*/,
+int CC1Command::Execute(ArrayRef> Redirects,
 std::string *ErrMsg, bool *ExecutionFailed) const {
+  // FIXME: Currently, if there're more than one job, we disable
+  // -fintegrate-cc1. If we're no longer a integrated-cc1 job, fallback to
+  // out-of-process execution. See d

[clang-tools-extra] 47abb43 - [clang-tidy] Fix performance-noexcept-move-constructor-fix test on non-English locale

2020-02-13 Thread Alexandre Ganea via cfe-commits

Author: Alexandre Ganea
Date: 2020-02-13T14:46:44-05:00
New Revision: 47abb43fc36433154eb796bd1d098f100503473e

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

LOG: [clang-tidy] Fix performance-noexcept-move-constructor-fix test on 
non-English locale

When running on Windows under the following locale:

D:\llvm-project>python
Python 3.8.0 (tags/v3.8.0:fa919fd, Oct 14 2019, 19:37:50) [MSC v.1916 64 bit 
(AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import locale
>>> locale.getlocale()
('French_Canada', '1252')

This patch fixes the following issue:

# command stderr:
Traceback (most recent call last):
  File 
"D:/llvm-project/clang-tools-extra/test/../test\clang-tidy\check_clang_tidy.py",
 line 249, in 
main()
  File 
"D:/llvm-project/clang-tools-extra/test/../test\clang-tidy\check_clang_tidy.py",
 line 245, in main
run_test_once(args, extra_args)
  File 
"D:/llvm-project/clang-tools-extra/test/../test\clang-tidy\check_clang_tidy.py",
 line 162, in run_test_once
diff_output.decode() +
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe0 in position 2050: 
invalid continuation byte
This is caused by diff reporting no EOL on the last line, and unfortunately 
this is written in French with accentuation on my locale.

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

Added: 


Modified: 
clang-tools-extra/test/clang-tidy/check_clang_tidy.py

Removed: 




diff  --git a/clang-tools-extra/test/clang-tidy/check_clang_tidy.py 
b/clang-tools-extra/test/clang-tidy/check_clang_tidy.py
index 368b674d2d32..8567c18bf9a0 100755
--- a/clang-tools-extra/test/clang-tidy/check_clang_tidy.py
+++ b/clang-tools-extra/test/clang-tidy/check_clang_tidy.py
@@ -159,7 +159,7 @@ def run_test_once(args, extra_args):
 
diff _output = e.output
 
   print('-- Fixes -\n' 
+
-
diff _output.decode() +
+
diff _output.decode(errors='ignore') +
 '\n--')
 
   if has_check_fixes:



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


[clang] d9049e8 - [clang-scan-deps] Switch to using a ThreadPool

2020-02-14 Thread Alexandre Ganea via cfe-commits

Author: Alexandre Ganea
Date: 2020-02-14T10:24:22-05:00
New Revision: d9049e871f309199a3d8fd7d3c0f76c86af9db91

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

LOG: [clang-scan-deps] Switch to using a ThreadPool

Use a ThreadPool instead of plain std::threads in clang-scan-deps.
This is needed to further support https://reviews.llvm.org/D71775.

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

Added: 


Modified: 
clang/tools/clang-scan-deps/ClangScanDeps.cpp

Removed: 




diff  --git a/clang/tools/clang-scan-deps/ClangScanDeps.cpp 
b/clang/tools/clang-scan-deps/ClangScanDeps.cpp
index 50788cb7cf8b..c499048fdb52 100644
--- a/clang/tools/clang-scan-deps/ClangScanDeps.cpp
+++ b/clang/tools/clang-scan-deps/ClangScanDeps.cpp
@@ -18,6 +18,7 @@
 #include "llvm/Support/JSON.h"
 #include "llvm/Support/Program.h"
 #include "llvm/Support/Signals.h"
+#include "llvm/Support/ThreadPool.h"
 #include "llvm/Support/Threading.h"
 #include 
 #include 
@@ -490,6 +491,7 @@ int main(int argc, const char **argv) {
 #else
   unsigned NumWorkers = 1;
 #endif
+  llvm::ThreadPool Pool(NumWorkers);
   std::vector> WorkerTools;
   for (unsigned I = 0; I < NumWorkers; ++I)
 WorkerTools.push_back(std::make_unique(Service));
@@ -499,7 +501,6 @@ int main(int argc, const char **argv) {
AdjustingCompilations->getAllCompileCommands())
 Inputs.emplace_back(Cmd);
 
-  std::vector WorkerThreads;
   std::atomic HadErrors(false);
   FullDeps FD;
   std::mutex Lock;
@@ -510,8 +511,8 @@ int main(int argc, const char **argv) {
  << " files using " << NumWorkers << " workers\n";
   }
   for (unsigned I = 0; I < NumWorkers; ++I) {
-auto Worker = [I, &Lock, &Index, &Inputs, &HadErrors, &FD, &WorkerTools,
-   &DependencyOS, &Errs]() {
+Pool.async([I, &Lock, &Index, &Inputs, &HadErrors, &FD, &WorkerTools,
+&DependencyOS, &Errs]() {
   llvm::StringSet<> AlreadySeenModules;
   while (true) {
 const SingleCommandCompilationDatabase *Input;
@@ -543,16 +544,9 @@ int main(int argc, const char **argv) {
 HadErrors = true;
 }
   }
-};
-#if LLVM_ENABLE_THREADS
-WorkerThreads.emplace_back(std::move(Worker));
-#else
-// Run the worker without spawning a thread when threads are disabled.
-Worker();
-#endif
+});
   }
-  for (auto &W : WorkerThreads)
-W.join();
+  Pool.wait();
 
   if (Format == ScanningOutputFormat::Full)
 FD.printFullOutput(llvm::outs());



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


[clang-tools-extra] 8404aeb - [Support] On Windows, ensure hardware_concurrency() extends to all CPU sockets and all NUMA groups

2020-02-14 Thread Alexandre Ganea via cfe-commits

Author: Alexandre Ganea
Date: 2020-02-14T10:24:22-05:00
New Revision: 8404aeb56a73ab24f9b295111de3b37a37f0b841

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

LOG: [Support] On Windows, ensure hardware_concurrency() extends to all CPU 
sockets and all NUMA groups

The goal of this patch is to maximize CPU utilization on multi-socket or high 
core count systems, so that parallel computations such as LLD/ThinLTO can use 
all hardware threads in the system. Before this patch, on Windows, a maximum of 
64 hardware threads could be used at most, in some cases dispatched only on one 
CPU socket.

== Background ==
Windows doesn't have a flat cpu_set_t like Linux. Instead, it projects hardware 
CPUs (or NUMA nodes) to applications through a concept of "processor groups". A 
"processor" is the smallest unit of execution on a CPU, that is, an 
hyper-thread if SMT is active; a core otherwise. There's a limit of 32-bit 
processors on older 32-bit versions of Windows, which later was raised to 
64-processors with 64-bit versions of Windows. This limit comes from the 
affinity mask, which historically is represented by the sizeof(void*). 
Consequently, the concept of "processor groups" was introduced for dealing with 
systems with more than 64 hyper-threads.

By default, the Windows OS assigns only one "processor group" to each starting 
application, in a round-robin manner. If the application wants to use more 
processors, it needs to programmatically enable it, by assigning threads to 
other "processor groups". This also means that affinity cannot cross "processor 
group" boundaries; one can only specify a "preferred" group on start-up, but 
the application is free to allocate more groups if it wants to.

This creates a peculiar situation, where newer CPUs like the AMD EPYC 7702P 
(64-cores, 128-hyperthreads) are projected by the OS as two (2) "processor 
groups". This means that by default, an application can only use half of the 
cores. This situation could only get worse in the years to come, as dies with 
more cores will appear on the market.

== The problem ==
The heavyweight_hardware_concurrency() API was introduced so that only *one 
hardware thread per core* was used. Once that API returns, that original 
intention is lost, only the number of threads is retained. Consider a 
situation, on Windows, where the system has 2 CPU sockets, 18 cores each, each 
core having 2 hyper-threads, for a total of 72 hyper-threads. Both 
heavyweight_hardware_concurrency() and hardware_concurrency() currently return 
36, because on Windows they are simply wrappers over 
std::thread::hardware_concurrency() -- which can only return processors from 
the current "processor group".

== The changes in this patch ==
To solve this situation, we capture (and retain) the initial intention until 
the point of usage, through a new ThreadPoolStrategy class. The number of 
threads to use is deferred as late as possible, until the moment where the 
std::threads are created (ThreadPool in the case of ThinLTO).

When using hardware_concurrency(), setting ThreadCount to 0 now means to use 
all the possible hardware CPU (SMT) threads. Providing a ThreadCount above to 
the maximum number of threads will have no effect, the maximum will be used 
instead.
The heavyweight_hardware_concurrency() is similar to hardware_concurrency(), 
except that only one thread per hardware *core* will be used.

When LLVM_ENABLE_THREADS is OFF, the threading APIs will always return 1, to 
ensure any caller loops will be exercised at least once.

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

Added: 


Modified: 
clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
clang-tools-extra/clangd/TUScheduler.cpp
clang-tools-extra/clangd/index/Background.cpp
clang-tools-extra/clangd/index/Background.h
clang-tools-extra/clangd/index/BackgroundRebuild.h
clang/lib/Tooling/AllTUsExecution.cpp
clang/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp
clang/tools/clang-scan-deps/ClangScanDeps.cpp
lld/ELF/SyntheticSections.cpp
llvm/include/llvm/LTO/LTO.h
llvm/include/llvm/Support/ThreadPool.h
llvm/include/llvm/Support/Threading.h
llvm/lib/CodeGen/ParallelCG.cpp
llvm/lib/DWARFLinker/DWARFLinker.cpp
llvm/lib/DebugInfo/GSYM/DwarfTransformer.cpp
llvm/lib/ExecutionEngine/Orc/LLJIT.cpp
llvm/lib/LTO/LTO.cpp
llvm/lib/LTO/LTOBackend.cpp
llvm/lib/LTO/ThinLTOCodeGenerator.cpp
llvm/lib/Support/Host.cpp
llvm/lib/Support/Parallel.cpp
llvm/lib/Support/ThreadPool.cpp
llvm/lib/Support/Threading.cpp
llvm/lib/Support/Unix/Threading.inc
llvm/lib/Support/Windows/Threading.inc
llvm/tools/dsymutil/dsymutil.cpp
llvm/tools/gold/gold-plugin.cpp
llvm/tools/llvm-cov/CodeCoverage.cpp
llvm/tools/llvm-cov/CoverageExporterJson.cpp
llvm/

[clang] a688301 - [Clang] Un-break scan-build after integrated-cc1 change

2020-01-21 Thread Alexandre Ganea via cfe-commits

Author: Alexandre Ganea
Date: 2020-01-21T11:58:24-05:00
New Revision: a6883017ea9af529e89d7f89af2477378b6eafca

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

LOG: [Clang] Un-break scan-build after integrated-cc1 change

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

Added: 


Modified: 
clang/lib/Driver/Job.cpp
clang/test/Driver/cuda-simple.cu
clang/test/Driver/offloading-interoperability.c
clang/test/Driver/option-aliases.c

Removed: 




diff  --git a/clang/lib/Driver/Job.cpp b/clang/lib/Driver/Job.cpp
index d57c3a1cdbb8..7dab2a022d92 100644
--- a/clang/lib/Driver/Job.cpp
+++ b/clang/lib/Driver/Job.cpp
@@ -373,7 +373,7 @@ int Command::Execute(ArrayRef> 
Redirects,
 
 void CC1Command::Print(raw_ostream &OS, const char *Terminator, bool Quote,
CrashReportInfo *CrashInfo) const {
-  OS << " (in-process)";
+  OS << " (in-process)\n";
   Command::Print(OS, Terminator, Quote, CrashInfo);
 }
 

diff  --git a/clang/test/Driver/cuda-simple.cu 
b/clang/test/Driver/cuda-simple.cu
index b6840be4e2e5..54e18403108b 100644
--- a/clang/test/Driver/cuda-simple.cu
+++ b/clang/test/Driver/cuda-simple.cu
@@ -5,10 +5,10 @@
 // Verify that we pass -x cuda-cpp-output to compiler after
 // preprocessing a CUDA file
 // RUN: %clang  -Werror -### -save-temps -c %s 2>&1 | FileCheck %s
-// CHECK: "-cc1"
+// CHECK-LABEL: "-cc1"
 // CHECK: "-E"
 // CHECK: "-x" "cuda"
-// CHECK-NEXT: "-cc1"
+// CHECK-LABEL: "-cc1"
 // CHECK: "-x" "cuda-cpp-output"
 //
 // Verify that compiler accepts CUDA syntax with "-x cuda-cpp-output".

diff  --git a/clang/test/Driver/offloading-interoperability.c 
b/clang/test/Driver/offloading-interoperability.c
index 9c80d91d1d78..c3a72f0dfe2a 100644
--- a/clang/test/Driver/offloading-interoperability.c
+++ b/clang/test/Driver/offloading-interoperability.c
@@ -8,10 +8,10 @@
 // RUN: %clang -no-canonical-prefixes -### -x cuda -target 
powerpc64le-linux-gnu -std=c++11 --cuda-gpu-arch=sm_35 -fopenmp=libomp %s 2>&1 \
 // RUN: | FileCheck %s --check-prefix NO-OPENMP-FLAGS-FOR-CUDA-DEVICE
 //
-// NO-OPENMP-FLAGS-FOR-CUDA-DEVICE:  clang{{.*}}" "-cc1" "-triple" 
"nvptx64-nvidia-cuda"
+// NO-OPENMP-FLAGS-FOR-CUDA-DEVICE-LABEL:clang{{.*}}" "-cc1" "-triple" 
"nvptx64-nvidia-cuda"
 // NO-OPENMP-FLAGS-FOR-CUDA-DEVICE-NOT:  -fopenmp
 // NO-OPENMP-FLAGS-FOR-CUDA-DEVICE-NEXT: ptxas" "-m64"
 // NO-OPENMP-FLAGS-FOR-CUDA-DEVICE-NEXT: fatbinary"{{( "--cuda")?}} "-64"
-// NO-OPENMP-FLAGS-FOR-CUDA-DEVICE-NEXT: clang{{.*}}" "-cc1" "-triple" 
"powerpc64le-unknown-linux-gnu"
+// NO-OPENMP-FLAGS-FOR-CUDA-DEVICE-LABEL:clang{{.*}}" "-cc1" "-triple" 
"powerpc64le-unknown-linux-gnu"
 // NO-OPENMP-FLAGS-FOR-CUDA-DEVICE:  -fopenmp
 // NO-OPENMP-FLAGS-FOR-CUDA-DEVICE-NEXT: {{ld(.exe)?"}} {{.*}}"-m" "elf64lppc"

diff  --git a/clang/test/Driver/option-aliases.c 
b/clang/test/Driver/option-aliases.c
index 9cd9252a4832..e50289cc3bdf 100644
--- a/clang/test/Driver/option-aliases.c
+++ b/clang/test/Driver/option-aliases.c
@@ -3,12 +3,12 @@
 // RUN: --param=FOO --output=FOO %s 2>&1 | \
 // RUN: FileCheck %s
 
-// CHECK: "-cc1"
+// CHECK-LABEL: "-cc1"
 // CHECK: "-E"
 // CHECK: "-U" "FOO"
 // CHECK: "-U" "BAR"
 // CHECK: "-o" "option-aliases.i"
 
-// CHECK-NEXT: "-cc1"
+// CHECK-LABEL: "-cc1"
 // CHECK: "-S"
 // CHECK: "-o" "FOO"



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


[clang] b0b2b7e - Revert "[Clang] Un-break scan-build after integrated-cc1 change"

2020-01-21 Thread Alexandre Ganea via cfe-commits

Author: Alexandre Ganea
Date: 2020-01-21T16:06:36-05:00
New Revision: b0b2b7e09926cdde4d82978a7c14b5e2d38db35c

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

LOG: Revert "[Clang] Un-break scan-build after integrated-cc1 change"

This reverts commit a6883017ea9af529e89d7f89af2477378b6eafca.

Added: 


Modified: 
clang/lib/Driver/Job.cpp
clang/test/Driver/cuda-simple.cu
clang/test/Driver/offloading-interoperability.c
clang/test/Driver/option-aliases.c

Removed: 




diff  --git a/clang/lib/Driver/Job.cpp b/clang/lib/Driver/Job.cpp
index 7dab2a022d92..d57c3a1cdbb8 100644
--- a/clang/lib/Driver/Job.cpp
+++ b/clang/lib/Driver/Job.cpp
@@ -373,7 +373,7 @@ int Command::Execute(ArrayRef> 
Redirects,
 
 void CC1Command::Print(raw_ostream &OS, const char *Terminator, bool Quote,
CrashReportInfo *CrashInfo) const {
-  OS << " (in-process)\n";
+  OS << " (in-process)";
   Command::Print(OS, Terminator, Quote, CrashInfo);
 }
 

diff  --git a/clang/test/Driver/cuda-simple.cu 
b/clang/test/Driver/cuda-simple.cu
index 54e18403108b..b6840be4e2e5 100644
--- a/clang/test/Driver/cuda-simple.cu
+++ b/clang/test/Driver/cuda-simple.cu
@@ -5,10 +5,10 @@
 // Verify that we pass -x cuda-cpp-output to compiler after
 // preprocessing a CUDA file
 // RUN: %clang  -Werror -### -save-temps -c %s 2>&1 | FileCheck %s
-// CHECK-LABEL: "-cc1"
+// CHECK: "-cc1"
 // CHECK: "-E"
 // CHECK: "-x" "cuda"
-// CHECK-LABEL: "-cc1"
+// CHECK-NEXT: "-cc1"
 // CHECK: "-x" "cuda-cpp-output"
 //
 // Verify that compiler accepts CUDA syntax with "-x cuda-cpp-output".

diff  --git a/clang/test/Driver/offloading-interoperability.c 
b/clang/test/Driver/offloading-interoperability.c
index c3a72f0dfe2a..9c80d91d1d78 100644
--- a/clang/test/Driver/offloading-interoperability.c
+++ b/clang/test/Driver/offloading-interoperability.c
@@ -8,10 +8,10 @@
 // RUN: %clang -no-canonical-prefixes -### -x cuda -target 
powerpc64le-linux-gnu -std=c++11 --cuda-gpu-arch=sm_35 -fopenmp=libomp %s 2>&1 \
 // RUN: | FileCheck %s --check-prefix NO-OPENMP-FLAGS-FOR-CUDA-DEVICE
 //
-// NO-OPENMP-FLAGS-FOR-CUDA-DEVICE-LABEL:clang{{.*}}" "-cc1" "-triple" 
"nvptx64-nvidia-cuda"
+// NO-OPENMP-FLAGS-FOR-CUDA-DEVICE:  clang{{.*}}" "-cc1" "-triple" 
"nvptx64-nvidia-cuda"
 // NO-OPENMP-FLAGS-FOR-CUDA-DEVICE-NOT:  -fopenmp
 // NO-OPENMP-FLAGS-FOR-CUDA-DEVICE-NEXT: ptxas" "-m64"
 // NO-OPENMP-FLAGS-FOR-CUDA-DEVICE-NEXT: fatbinary"{{( "--cuda")?}} "-64"
-// NO-OPENMP-FLAGS-FOR-CUDA-DEVICE-LABEL:clang{{.*}}" "-cc1" "-triple" 
"powerpc64le-unknown-linux-gnu"
+// NO-OPENMP-FLAGS-FOR-CUDA-DEVICE-NEXT: clang{{.*}}" "-cc1" "-triple" 
"powerpc64le-unknown-linux-gnu"
 // NO-OPENMP-FLAGS-FOR-CUDA-DEVICE:  -fopenmp
 // NO-OPENMP-FLAGS-FOR-CUDA-DEVICE-NEXT: {{ld(.exe)?"}} {{.*}}"-m" "elf64lppc"

diff  --git a/clang/test/Driver/option-aliases.c 
b/clang/test/Driver/option-aliases.c
index e50289cc3bdf..9cd9252a4832 100644
--- a/clang/test/Driver/option-aliases.c
+++ b/clang/test/Driver/option-aliases.c
@@ -3,12 +3,12 @@
 // RUN: --param=FOO --output=FOO %s 2>&1 | \
 // RUN: FileCheck %s
 
-// CHECK-LABEL: "-cc1"
+// CHECK: "-cc1"
 // CHECK: "-E"
 // CHECK: "-U" "FOO"
 // CHECK: "-U" "BAR"
 // CHECK: "-o" "option-aliases.i"
 
-// CHECK-LABEL: "-cc1"
+// CHECK-NEXT: "-cc1"
 // CHECK: "-S"
 // CHECK: "-o" "FOO"



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


[clang] 133a7e6 - [PATCH] Reland [Clang] Un-break scan-build after integrated-cc1 change

2020-01-21 Thread Alexandre Ganea via cfe-commits

Author: Alexandre Ganea
Date: 2020-01-21T17:03:00-05:00
New Revision: 133a7e631cee97965e310f0d110739217427fd3d

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

LOG: [PATCH] Reland [Clang] Un-break scan-build after integrated-cc1 change

The issue was reported by @xazax.hun here: 
https://reviews.llvm.org/D69825#1827826

"This patch (D69825) breaks scan-build-py which parses the output of "-###" to 
get -cc1 command. There might be other tools with the same problems. Could we 
either remove (in-process) from CC1Command::Print or add a line break?

Having the last line as a valid invocation is valuable and there might be tools 
relying on that."

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

Added: 


Modified: 
clang/lib/Driver/Compilation.cpp
clang/lib/Driver/Job.cpp
clang/test/Driver/cc-print-options.c
clang/test/Driver/cuda-simple.cu
clang/test/Driver/offloading-interoperability.c
clang/test/Driver/option-aliases.c

Removed: 




diff  --git a/clang/lib/Driver/Compilation.cpp 
b/clang/lib/Driver/Compilation.cpp
index ba188f5c4083..25aec3690f21 100644
--- a/clang/lib/Driver/Compilation.cpp
+++ b/clang/lib/Driver/Compilation.cpp
@@ -172,7 +172,7 @@ int Compilation::ExecuteCommand(const Command &C,
 }
 
 if (getDriver().CCPrintOptions)
-  *OS << "[Logging clang options]";
+  *OS << "[Logging clang options]\n";
 
 C.Print(*OS, "\n", /*Quote=*/getDriver().CCPrintOptions);
   }

diff  --git a/clang/lib/Driver/Job.cpp b/clang/lib/Driver/Job.cpp
index d57c3a1cdbb8..7dab2a022d92 100644
--- a/clang/lib/Driver/Job.cpp
+++ b/clang/lib/Driver/Job.cpp
@@ -373,7 +373,7 @@ int Command::Execute(ArrayRef> 
Redirects,
 
 void CC1Command::Print(raw_ostream &OS, const char *Terminator, bool Quote,
CrashReportInfo *CrashInfo) const {
-  OS << " (in-process)";
+  OS << " (in-process)\n";
   Command::Print(OS, Terminator, Quote, CrashInfo);
 }
 

diff  --git a/clang/test/Driver/cc-print-options.c 
b/clang/test/Driver/cc-print-options.c
index 77dd0fef5f98..dc7f4a3ac35c 100644
--- a/clang/test/Driver/cc-print-options.c
+++ b/clang/test/Driver/cc-print-options.c
@@ -3,5 +3,6 @@
 // RUN: %clang -no-canonical-prefixes -S -o %t.s %s
 // RUN: FileCheck %s < %t.log
 
-// CHECK: [Logging clang options]{{.*}}clang{{.*}}"-S"
+// CHECK: [Logging clang options]
+// CHECK: {{.*}}clang{{.*}}"-S"
 

diff  --git a/clang/test/Driver/cuda-simple.cu 
b/clang/test/Driver/cuda-simple.cu
index b6840be4e2e5..54e18403108b 100644
--- a/clang/test/Driver/cuda-simple.cu
+++ b/clang/test/Driver/cuda-simple.cu
@@ -5,10 +5,10 @@
 // Verify that we pass -x cuda-cpp-output to compiler after
 // preprocessing a CUDA file
 // RUN: %clang  -Werror -### -save-temps -c %s 2>&1 | FileCheck %s
-// CHECK: "-cc1"
+// CHECK-LABEL: "-cc1"
 // CHECK: "-E"
 // CHECK: "-x" "cuda"
-// CHECK-NEXT: "-cc1"
+// CHECK-LABEL: "-cc1"
 // CHECK: "-x" "cuda-cpp-output"
 //
 // Verify that compiler accepts CUDA syntax with "-x cuda-cpp-output".

diff  --git a/clang/test/Driver/offloading-interoperability.c 
b/clang/test/Driver/offloading-interoperability.c
index 9c80d91d1d78..c3a72f0dfe2a 100644
--- a/clang/test/Driver/offloading-interoperability.c
+++ b/clang/test/Driver/offloading-interoperability.c
@@ -8,10 +8,10 @@
 // RUN: %clang -no-canonical-prefixes -### -x cuda -target 
powerpc64le-linux-gnu -std=c++11 --cuda-gpu-arch=sm_35 -fopenmp=libomp %s 2>&1 \
 // RUN: | FileCheck %s --check-prefix NO-OPENMP-FLAGS-FOR-CUDA-DEVICE
 //
-// NO-OPENMP-FLAGS-FOR-CUDA-DEVICE:  clang{{.*}}" "-cc1" "-triple" 
"nvptx64-nvidia-cuda"
+// NO-OPENMP-FLAGS-FOR-CUDA-DEVICE-LABEL:clang{{.*}}" "-cc1" "-triple" 
"nvptx64-nvidia-cuda"
 // NO-OPENMP-FLAGS-FOR-CUDA-DEVICE-NOT:  -fopenmp
 // NO-OPENMP-FLAGS-FOR-CUDA-DEVICE-NEXT: ptxas" "-m64"
 // NO-OPENMP-FLAGS-FOR-CUDA-DEVICE-NEXT: fatbinary"{{( "--cuda")?}} "-64"
-// NO-OPENMP-FLAGS-FOR-CUDA-DEVICE-NEXT: clang{{.*}}" "-cc1" "-triple" 
"powerpc64le-unknown-linux-gnu"
+// NO-OPENMP-FLAGS-FOR-CUDA-DEVICE-LABEL:clang{{.*}}" "-cc1" "-triple" 
"powerpc64le-unknown-linux-gnu"
 // NO-OPENMP-FLAGS-FOR-CUDA-DEVICE:  -fopenmp
 // NO-OPENMP-FLAGS-FOR-CUDA-DEVICE-NEXT: {{ld(.exe)?"}} {{.*}}"-m" "elf64lppc"

diff  --git a/clang/test/Driver/option-aliases.c 
b/clang/test/Driver/option-aliases.c
index 9cd9252a4832..e50289cc3bdf 100644
--- a/clang/test/Driver/option-aliases.c
+++ b/clang/test/Driver/option-aliases.c
@@ -3,12 +3,12 @@
 // RUN: --param=FOO --output=FOO %s 2>&1 | \
 // RUN: FileCheck %s
 
-// CHECK: "-cc1"
+// CHECK-LABEL: "-cc1"
 // CHECK: "-E"
 // CHECK: "-U" "FOO"
 // CHECK: "-U" "BAR"
 // CHECK: "-o" "option-aliases.i"
 
-// CHECK-NEXT: "-cc1"
+// CHECK-LABEL: "-cc1"
 // CHECK: "-S"
 // CHECK: "-o" "FOO"



_

[clang] 68d7f06 - Clang] Fix expansion of response files in -Wp after integrated-cc1 change

2020-01-22 Thread Alexandre Ganea via cfe-commits

Author: Alexandre Ganea
Date: 2020-01-22T16:53:44-05:00
New Revision: 68d7f06092e56b17eb0cddf560a9d9fe8afb7dd8

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

LOG: Clang] Fix expansion of response files in -Wp after integrated-cc1 change

After rGb4a99a061f517e60985667e39519f60186cbb469, passing a response file such 
as -Wp,@a.rsp wasn't working anymore because .rsp expansion happens inside 
clang's main() function.

This patch adds response file expansion in the -cc1 tool.

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

Added: 


Modified: 
clang/include/clang/Driver/Driver.h
clang/test/Driver/Wp-args.c
clang/tools/driver/driver.cpp

Removed: 




diff  --git a/clang/include/clang/Driver/Driver.h 
b/clang/include/clang/Driver/Driver.h
index fd25663bd358..6c3feaba0568 100644
--- a/clang/include/clang/Driver/Driver.h
+++ b/clang/include/clang/Driver/Driver.h
@@ -208,7 +208,7 @@ class Driver {
   /// When the clangDriver lib is used through clang.exe, this provides a
   /// shortcut for executing the -cc1 command-line directly, in the same
   /// process.
-  typedef int (*CC1ToolFunc)(ArrayRef argv);
+  typedef int (*CC1ToolFunc)(SmallVectorImpl &ArgV);
   CC1ToolFunc CC1Main = nullptr;
 
 private:

diff  --git a/clang/test/Driver/Wp-args.c b/clang/test/Driver/Wp-args.c
index e01e2a2651f0..587b7b83e4ca 100644
--- a/clang/test/Driver/Wp-args.c
+++ b/clang/test/Driver/Wp-args.c
@@ -19,3 +19,13 @@
 // MMD: "-cc1"
 // MMD-NOT: -MMD
 // MMD: "-dependency-file" "Wp-args.d"
+
+// Ensure response files are properly expanded with -Wp
+// RUN: echo -DTEST > %t.rsp
+// RUN: %clang -Wp,@%t.rsp -E %s | FileCheck -check-prefix RSP %s
+
+#ifdef TEST
+void foo();
+#endif
+
+// RSP: foo()

diff  --git a/clang/tools/driver/driver.cpp b/clang/tools/driver/driver.cpp
index 39f6c7f62be4..4457e40ff04b 100644
--- a/clang/tools/driver/driver.cpp
+++ b/clang/tools/driver/driver.cpp
@@ -241,8 +241,6 @@ static void getCLEnvVarOptions(std::string &EnvValue, 
llvm::StringSaver &Saver,
   *NumberSignPtr = '=';
 }
 
-static int ExecuteCC1Tool(ArrayRef argv);
-
 static void SetBackdoorDriverOutputsFromEnvVars(Driver &TheDriver) {
   // Handle CC_PRINT_OPTIONS and CC_PRINT_OPTIONS_FILE.
   TheDriver.CCPrintOptions = !!::getenv("CC_PRINT_OPTIONS");
@@ -313,21 +311,27 @@ static void SetInstallDir(SmallVectorImpl 
&argv,
 TheDriver.setInstalledDir(InstalledPathParent);
 }
 
-static int ExecuteCC1Tool(ArrayRef argv) {
+static int ExecuteCC1Tool(SmallVectorImpl &ArgV) {
   // If we call the cc1 tool from the clangDriver library (through
   // Driver::CC1Main), we need to clean up the options usage count. The options
   // are currently global, and they might have been used previously by the
   // driver.
   llvm::cl::ResetAllOptionOccurrences();
-  StringRef Tool = argv[1];
-  void *GetExecutablePathVP = (void *)(intptr_t) GetExecutablePath;
+
+  llvm::BumpPtrAllocator A;
+  llvm::StringSaver Saver(A);
+  llvm::cl::ExpandResponseFiles(Saver, &llvm::cl::TokenizeGNUCommandLine, ArgV,
+/*MarkEOLs=*/false);
+  StringRef Tool = ArgV[1];
+  void *GetExecutablePathVP = (void *)(intptr_t)GetExecutablePath;
   if (Tool == "-cc1")
-return cc1_main(argv.slice(2), argv[0], GetExecutablePathVP);
+return cc1_main(makeArrayRef(ArgV).slice(2), ArgV[0], GetExecutablePathVP);
   if (Tool == "-cc1as")
-return cc1as_main(argv.slice(2), argv[0], GetExecutablePathVP);
+return cc1as_main(makeArrayRef(ArgV).slice(2), ArgV[0],
+  GetExecutablePathVP);
   if (Tool == "-cc1gen-reproducer")
-return cc1gen_reproducer_main(argv.slice(2), argv[0], GetExecutablePathVP);
-
+return cc1gen_reproducer_main(makeArrayRef(ArgV).slice(2), ArgV[0],
+  GetExecutablePathVP);
   // Reject unknown tools.
   llvm::errs() << "error: unknown integrated tool '" << Tool << "'. "
<< "Valid tools include '-cc1' and '-cc1as'.\n";



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


[clang] [llvm] [mlir] Rename `ThreadPool::getThreadCount()` to `getMaxConcurrency()` (NFC) (PR #82296)

2024-02-19 Thread Alexandre Ganea via cfe-commits

https://github.com/aganea approved this pull request.

Lg, thanks!

https://github.com/llvm/llvm-project/pull/82296
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [CodeView] Flatten cmd args in frontend for LF_BUILDINFO (PR #106369)

2024-09-05 Thread Alexandre Ganea via cfe-commits

aganea wrote:

The code LG but I’d like please @nebulark if you can explain de unit tests 
changes? Why those offset changes? The code should emit the same thing as 
before?

https://github.com/llvm/llvm-project/pull/106369
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [CodeView] Flatten cmd args in frontend for LF_BUILDINFO (PR #106369)

2024-09-06 Thread Alexandre Ganea via cfe-commits

aganea wrote:

> I always set Argv0 and Commandline, even if they are just an empty string. 
> Some tools had issues if those were not set. We already did use the empty 
> string for BuildInfoRecord::TypeServerPDB, so now its also more consistent.

Ah yes, that's good. Looks good, thanks again!


https://github.com/llvm/llvm-project/pull/106369
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [CodeView] Flatten cmd args in frontend for LF_BUILDINFO (PR #106369)

2024-09-06 Thread Alexandre Ganea via cfe-commits

https://github.com/aganea approved this pull request.


https://github.com/llvm/llvm-project/pull/106369
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang][CodeGen] Fix bad codegen when building Clang with latest MSVC (PR #102681)

2024-08-09 Thread Alexandre Ganea via cfe-commits

https://github.com/aganea created 
https://github.com/llvm/llvm-project/pull/102681

Before this PR, when using the latest MSVC `Microsoft (R) C/C++ Optimizing 
Compiler Version 19.40.33813 for x64` one of the Clang unit test used to fail: 
`CodeGenObjC/gnustep2-direct-method.m`, see full failure log 
[here](https://github.com/llvm/llvm-project/pull/100517#issuecomment-2266269490).

This seems to have been introduced by 
https://github.com/llvm/llvm-project/commit/c9e5af3944e85c5f1272c48522b4e9eda398b462
 however further inspection shows that commit only triggers a bug in the MSVC 
compiler.

It seems that the symptom is bad alignement generated in one of the load 
instructions:
```
huge alignment values are unsupported
  %2 = load i64, ptr %1, align 9223372036854775808
```
When `Builder.CreateLoad` is called 
[here](https://github.com/llvm/llvm-project/blob/main/clang/lib/CodeGen/CGObjCGNU.cpp#L2096),
 somehow [this 
call](https://github.com/llvm/llvm-project/blob/main/clang/lib/CodeGen/CGBuilder.h#L110)
 to `Addr.getAlignment().getAsAlign()` returns a bad alignement. The problem 
occurs at the highlighted line in the screenshot (`sub bh,cl`):

![Screenshot 2024-08-09 
154835](https://github.com/user-attachments/assets/48a9a0a9-39f0-4d8e-bc14-77fe1de13e59)

The code line on the right is translated to the assembly on the right. 
`llvm::count_zero` returns a proper value (as seen in `rcx`), however `sub bh, 
cl` uses a bad constant in `bh` (it is not 63 as expected). I think the 
optimizer meant to use `dil` not `bh`. A few lines below it does `mov byte ptr 
[rsp + 40h], dil`. If after `sub` is executed I manually set 6 in `rdi`, as it 
should have been, the test passes.

I'll fix a bug with Microsoft will cross post it here.

>From 16efda65bb3d30b67b3215d7e8d69a105e2d771c Mon Sep 17 00:00:00 2001
From: Alexandre Ganea 
Date: Fri, 9 Aug 2024 16:32:09 -0400
Subject: [PATCH] [Clang][CodeGen] Fix a bad codegen when building Clang with
 latest MSVC

---
 clang/lib/CodeGen/CGObjCGNU.cpp | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/clang/lib/CodeGen/CGObjCGNU.cpp b/clang/lib/CodeGen/CGObjCGNU.cpp
index 948b10954ebbed..56a3ed1b87b35f 100644
--- a/clang/lib/CodeGen/CGObjCGNU.cpp
+++ b/clang/lib/CodeGen/CGObjCGNU.cpp
@@ -2092,10 +2092,10 @@ class CGObjCGNUstep2 : public CGObjCGNUstep {
 auto *classStart =
 llvm::StructType::get(PtrTy, PtrTy, PtrTy, LongTy, LongTy);
 auto &astContext = CGM.getContext();
-auto flags = Builder.CreateLoad(
-Address{Builder.CreateStructGEP(classStart, selfValue, 4), LongTy,
-CharUnits::fromQuantity(
-astContext.getTypeAlign(astContext.UnsignedLongTy))});
+llvm::Value *Val = Builder.CreateStructGEP(classStart, selfValue, 4);
+auto Align = CharUnits::fromQuantity(
+astContext.getTypeAlign(astContext.UnsignedLongTy));
+auto flags = Builder.CreateLoad(Address{Val, LongTy, Align});
 auto isInitialized =
 Builder.CreateAnd(flags, ClassFlags::ClassFlagInitialized);
 llvm::BasicBlock *notInitializedBlock =

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


[clang] [Clang][CodeGen] Fix bad codegen when building Clang with latest MSVC (PR #102681)

2024-08-09 Thread Alexandre Ganea via cfe-commits

https://github.com/aganea edited 
https://github.com/llvm/llvm-project/pull/102681
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang][CodeGen] Fix bad codegen when building Clang with latest MSVC (PR #102681)

2024-08-09 Thread Alexandre Ganea via cfe-commits

https://github.com/aganea edited 
https://github.com/llvm/llvm-project/pull/102681
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang][CodeGen] Fix bad codegen when building Clang with latest MSVC (PR #102681)

2024-08-09 Thread Alexandre Ganea via cfe-commits

https://github.com/aganea edited 
https://github.com/llvm/llvm-project/pull/102681
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang][CodeGen] Fix bad codegen when building Clang with latest MSVC (PR #102681)

2024-08-09 Thread Alexandre Ganea via cfe-commits

https://github.com/aganea edited 
https://github.com/llvm/llvm-project/pull/102681
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang][CodeGen] Fix bad codegen when building Clang with latest MSVC (PR #102681)

2024-08-09 Thread Alexandre Ganea via cfe-commits

https://github.com/aganea edited 
https://github.com/llvm/llvm-project/pull/102681
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Stop adjusting the module cache path (PR #102540)

2024-08-10 Thread Alexandre Ganea via cfe-commits

aganea wrote:

> This enables more efficient implementation of the caching VFS in #88800.

Thanks @jansvoboda11 for working on this, I appreciate. One question, what do 
you mean by "more efficient"?

https://github.com/llvm/llvm-project/pull/102540
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][deps] Only bypass scanning VFS for the module cache (PR #88800)

2024-08-10 Thread Alexandre Ganea via cfe-commits

https://github.com/aganea approved this pull request.

This solves the performance issue I was seeing on Windows with a C++ clang 
database. Thanks again for doing this @jansvoboda11!

https://github.com/llvm/llvm-project/pull/88800
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang][CodeGen] Fix bad codegen when building Clang with latest MSVC (PR #102681)

2024-08-10 Thread Alexandre Ganea via cfe-commits

aganea wrote:

> Might be nice to clean this up in the future when Microsoft releases a fix.

I can add a comment to that effect.

https://github.com/llvm/llvm-project/pull/102681
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang][CodeGen] Fix bad codegen when building Clang with latest MSVC (PR #102681)

2024-08-10 Thread Alexandre Ganea via cfe-commits

https://github.com/aganea updated 
https://github.com/llvm/llvm-project/pull/102681

>From 16efda65bb3d30b67b3215d7e8d69a105e2d771c Mon Sep 17 00:00:00 2001
From: Alexandre Ganea 
Date: Fri, 9 Aug 2024 16:32:09 -0400
Subject: [PATCH 1/2] [Clang][CodeGen] Fix a bad codegen when building Clang
 with latest MSVC

---
 clang/lib/CodeGen/CGObjCGNU.cpp | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/clang/lib/CodeGen/CGObjCGNU.cpp b/clang/lib/CodeGen/CGObjCGNU.cpp
index 948b10954ebbed..56a3ed1b87b35f 100644
--- a/clang/lib/CodeGen/CGObjCGNU.cpp
+++ b/clang/lib/CodeGen/CGObjCGNU.cpp
@@ -2092,10 +2092,10 @@ class CGObjCGNUstep2 : public CGObjCGNUstep {
 auto *classStart =
 llvm::StructType::get(PtrTy, PtrTy, PtrTy, LongTy, LongTy);
 auto &astContext = CGM.getContext();
-auto flags = Builder.CreateLoad(
-Address{Builder.CreateStructGEP(classStart, selfValue, 4), LongTy,
-CharUnits::fromQuantity(
-astContext.getTypeAlign(astContext.UnsignedLongTy))});
+llvm::Value *Val = Builder.CreateStructGEP(classStart, selfValue, 4);
+auto Align = CharUnits::fromQuantity(
+astContext.getTypeAlign(astContext.UnsignedLongTy));
+auto flags = Builder.CreateLoad(Address{Val, LongTy, Align});
 auto isInitialized =
 Builder.CreateAnd(flags, ClassFlags::ClassFlagInitialized);
 llvm::BasicBlock *notInitializedBlock =

>From 34b84af7a41cab1eab1e0ed046e656bbaa783fdc Mon Sep 17 00:00:00 2001
From: Alexandre Ganea 
Date: Sat, 10 Aug 2024 16:16:22 -0400
Subject: [PATCH 2/2] Add comment

---
 clang/lib/CodeGen/CGObjCGNU.cpp | 5 +
 1 file changed, 5 insertions(+)

diff --git a/clang/lib/CodeGen/CGObjCGNU.cpp b/clang/lib/CodeGen/CGObjCGNU.cpp
index 56a3ed1b87b35f..ca5804018227ea 100644
--- a/clang/lib/CodeGen/CGObjCGNU.cpp
+++ b/clang/lib/CodeGen/CGObjCGNU.cpp
@@ -2092,6 +2092,11 @@ class CGObjCGNUstep2 : public CGObjCGNUstep {
 auto *classStart =
 llvm::StructType::get(PtrTy, PtrTy, PtrTy, LongTy, LongTy);
 auto &astContext = CGM.getContext();
+// FIXME: The following few lines up to and including the call to
+// `CreateLoad` were known to miscompile when MSVC 19.40.33813 is used
+// to build Clang. When the bug is fixed in future MSVC releases, we
+// should revert these lines to their previous state. See discussion in
+// https://github.com/llvm/llvm-project/pull/102681
 llvm::Value *Val = Builder.CreateStructGEP(classStart, selfValue, 4);
 auto Align = CharUnits::fromQuantity(
 astContext.getTypeAlign(astContext.UnsignedLongTy));

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


[clang] [Clang][CodeGen] Fix bad codegen when building Clang with latest MSVC (PR #102681)

2024-08-10 Thread Alexandre Ganea via cfe-commits

https://github.com/aganea closed 
https://github.com/llvm/llvm-project/pull/102681
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Ensure `--print-runtime-dir` path exists (PR #102834)

2024-08-11 Thread Alexandre Ganea via cfe-commits

https://github.com/aganea created 
https://github.com/llvm/llvm-project/pull/102834

Before this PR, `clang --print-runtime-dir` used to report a non-existant 
directory if `LLVM_ENABLE_PER_TARGET_RUNTIME_DIR=OFF`.

We now check if any of the known runtime directories exist before printing on 
stdout. If it doesn't, we print `(runtime dir is not present)`.

>From d1d1340b6876d83d48949306e43c723696bf4753 Mon Sep 17 00:00:00 2001
From: Alexandre Ganea 
Date: Sun, 11 Aug 2024 19:03:14 -0400
Subject: [PATCH] [clang] Ensure --print-runtime-dir exits

Before this PR, `clang --print-runtime-dir` used to report a non-existant
directory if LLVM_ENABLE_PER_TARGET_RUNTIME_DIR=OFF.

We now check if any of the known runtime directories exist before
printing on stdout.
---
 clang/lib/Driver/Driver.cpp | 12 
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index f4e909b79389bc..4c8cd36dd118ee 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -2230,10 +2230,14 @@ bool Driver::HandleImmediateArgs(Compilation &C) {
   }
 
   if (C.getArgs().hasArg(options::OPT_print_runtime_dir)) {
-if (std::optional RuntimePath = TC.getRuntimePath())
-  llvm::outs() << *RuntimePath << '\n';
-else
-  llvm::outs() << TC.getCompilerRTPath() << '\n';
+for (auto RuntimePath :
+ {TC.getRuntimePath(), std::make_optional(TC.getCompilerRTPath())}) {
+  if (RuntimePath && getVFS().exists(*RuntimePath)) {
+llvm::outs() << *RuntimePath << '\n';
+return false;
+  }
+}
+llvm::outs() << "(runtime dir is not present)" << '\n';
 return false;
   }
 

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


[clang] [clang] Ensure `--print-runtime-dir` path exists (PR #102834)

2024-08-11 Thread Alexandre Ganea via cfe-commits

https://github.com/aganea edited 
https://github.com/llvm/llvm-project/pull/102834
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Ensure `--print-runtime-dir` path exists (PR #102834)

2024-08-11 Thread Alexandre Ganea via cfe-commits

https://github.com/aganea edited 
https://github.com/llvm/llvm-project/pull/102834
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


  1   2   3   >