[PATCH] D43700: Emit proper CodeView even when not using the cl driver.

2018-02-26 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea added a comment.

Thanks for fixing this @zturner. I simply want to back-up what @probinson says 
above - most of the games we do at Ubisoft are currently using a different 
compilation toolchains for each platform (we ship at least 4-5 platforms for 
each top game). It can be clang or it can be MSVC; and most of the time it's 
different versions of clang. Our long-term goal is to preferably have only one 
toolchain for all our platforms & all our targets - that means one set of 
common g++ like flags, including Windows.


https://reviews.llvm.org/D43700



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


[PATCH] D51380: Fix incorrect usage of std::error_category

2018-08-28 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea created this revision.
aganea added reviewers: ilya-biryukov, zturner.
Herald added a subscriber: cfe-commits.

As mentionned here , this change 
prevents a dangling pointer in `std:error_code` by using a singleton.


Repository:
  rC Clang

https://reviews.llvm.org/D51380

Files:
  lib/Frontend/PrecompiledPreamble.cpp


Index: lib/Frontend/PrecompiledPreamble.cpp
===
--- lib/Frontend/PrecompiledPreamble.cpp
+++ lib/Frontend/PrecompiledPreamble.cpp
@@ -742,8 +742,10 @@
   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 {


Index: lib/Frontend/PrecompiledPreamble.cpp
===
--- lib/Frontend/PrecompiledPreamble.cpp
+++ lib/Frontend/PrecompiledPreamble.cpp
@@ -742,8 +742,10 @@
   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


[PATCH] D51380: Fix incorrect usage of std::error_category

2018-08-29 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea added a comment.

Thank you!


Repository:
  rC Clang

https://reviews.llvm.org/D51380



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


[PATCH] D51380: Fix incorrect usage of std::error_category

2018-08-29 Thread Alexandre Ganea via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC340929: [Preamble] Fix incorrect usage of 
std::error_category (authored by aganea, committed by ).

Repository:
  rC Clang

https://reviews.llvm.org/D51380

Files:
  lib/Frontend/PrecompiledPreamble.cpp


Index: lib/Frontend/PrecompiledPreamble.cpp
===
--- lib/Frontend/PrecompiledPreamble.cpp
+++ lib/Frontend/PrecompiledPreamble.cpp
@@ -742,8 +742,10 @@
   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 {


Index: lib/Frontend/PrecompiledPreamble.cpp
===
--- lib/Frontend/PrecompiledPreamble.cpp
+++ lib/Frontend/PrecompiledPreamble.cpp
@@ -742,8 +742,10 @@
   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


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

2018-09-07 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea created this revision.
aganea added reviewers: thakis, ddunbar, hans.
Herald added a subscriber: cfe-commits.

Currently, `-march` does not work in the `clang-cl` driver.

We are currently migrating from MSVC. The project size makes that we have to 
stick with `clang-cl` for a little while. However, we don't want to loose 
optimisation oportunities in the runtime code, and the MSVC flag `/arch` only 
supports a limited set of options.


Repository:
  rC Clang

https://reviews.llvm.org/D51806

Files:
  include/clang/Driver/Options.td


Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -1931,7 +1931,7 @@
 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;


Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -1931,7 +1931,7 @@
 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;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2018-09-10 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea added a comment.

@hans I want to target precisely a given CPU when using `clang-cl`. The options 
in the `m_x86_Features_Group` are too granular. It is easier to just add 
`-march=skylake` on the cmd-line. Is there any other way?


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


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

2018-09-10 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea updated this revision to Diff 164666.
aganea added a comment.

Updated diff with coverage test as requested.


Repository:
  rC Clang

https://reviews.llvm.org/D51806

Files:
  include/clang/Driver/Options.td
  test/Driver/cl-options.c


Index: test/Driver/cl-options.c
===
--- test/Driver/cl-options.c
+++ test/Driver/cl-options.c
@@ -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
 
Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -1931,7 +1931,7 @@
 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;


Index: test/Driver/cl-options.c
===
--- test/Driver/cl-options.c
+++ test/Driver/cl-options.c
@@ -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
 
Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -1931,7 +1931,7 @@
 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;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2018-09-10 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea added a comment.

@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.


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


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

2018-09-10 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea added a comment.

Thank you!


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


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

2018-09-10 Thread Alexandre Ganea via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC341847: [clang-cl] Enable -march option (authored by aganea, 
committed by ).

Repository:
  rC Clang

https://reviews.llvm.org/D51806

Files:
  include/clang/Driver/Options.td
  test/Driver/cl-options.c


Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -1931,7 +1931,7 @@
 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;
Index: test/Driver/cl-options.c
===
--- test/Driver/cl-options.c
+++ test/Driver/cl-options.c
@@ -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
 


Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -1931,7 +1931,7 @@
 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;
Index: test/Driver/cl-options.c
===
--- test/Driver/cl-options.c
+++ test/Driver/cl-options.c
@@ -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


[PATCH] D52193: RFC: [clang] Multithreaded compilation support

2018-10-05 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea added a comment.

In https://reviews.llvm.org/D52193#1243456, @thakis wrote:

> ...and to reword this a bit: Clang taking a long time to start up in some 
> configurations is a bug we should profile and fix :-)


This is time spent in `ntdll.dll` loading various low-level libraries like 
`kernel32.dll`, `KernelBase.dll`, `combase.dll` and so on. So at least 20ms 
just getting to main(). Then, about ~10ms spent loading `dbghelp.dll` while 
installing the exception handler in `llvm::RegisterHandler`. So a lot of wasted 
time. The easiest would be to just not invoke a new child process!



New timings without the child `clang-cl.exe` being invoked (hacked from 
https://reviews.llvm.org/D52411). The improvement **is significant**. Tested at 
r343846.

**Config 1:** Intel Xeon Haswell 6 cores / 12 HW threads, 3.5 GHz, 15M cache, 
128 GB RAM, SSD 550 MB/s

__Ninja:__

| MSVC cl  | (37min 19sec)  
   |
| clang-cl //(built with Clang)//  | //(in progress-will update a bit 
later)// |
| clang-cl no child //(built with Clang)// | //(in progress-will update a bit 
later)// |
|

**Config 2:** Intel Xeon Skylake 18 cores / 36 HW threads, x2 (Dual CPU), 72 HW 
threads total, 2.3 GHz, 24.75M cache, 128 GB RAM, NVMe SSD 4.6 GB/s

__Ninja:__

| MSVC cl  | (7min 33sec)|
| clang-cl //(built with Clang)//  | (9min 2sec) |
| **clang-cl no child //(built with Clang)//** | **(7min 9sec)** |
|

This asks whether the improvement will be of the same order, if invoking just 
one `clang-cl.exe` for the whole compilation process. A sort of local 
compilation-as-a-service.
In that scenario, Ninja could invoke `clang-cl.exe` and pass it all the files 
to be compiled, and let clang iterate and multi-thread internally. That could 
be quite a significant change, however the improvements //could be// important.
However that would probably break the concept behind //Goma //I suppose. Unless 
you split the invocations to precisely one `clang-cl` per available (remote) 
agent.


Repository:
  rC Clang

https://reviews.llvm.org/D52193



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


[PATCH] D52193: RFC: [clang] Multithreaded compilation support

2018-10-10 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea added a comment.

In https://reviews.llvm.org/D52193#1260862, @zturner wrote:

> I can try to get some timings from my machine.  How do we handle crash
>  recovery in the case where we don't spawn a child process?  I thought the
>  whole reason for spawning the cc1 driver as a separate process was so that
>  we could collect and report crash information in a nice way.  Not having
>  that seems like a heavy price to pay.


`clang.exe` has already a general exception handler (installed by 
`InitLLVM::InitLLVM/sys::PrintStackTraceOnErrorSignal`), which prints the 
callstack in case of a crash. So you wouldn't need the child process to do 
post-crash processing.

However, when running within a parent `clang.exe`, the parents calls 
`Driver::generateCompilationDiagnostics()` after a crash to create the repro 
(preprocessed source).

In a scenario where a single `clang.exe` is running (no child) we could modify 
`Driver::generateCompilationDiagnostics()` so it gets called from within the 
exception handler, and invoke a child process to collect the preprocessed 
source.

I wrote a fully fledged crash reporting system which does that, so I know 
that's possible. The tricky thing is to ensure 
`Driver::generateCompilationDiagnostics()` doesn't touch potentially invalid 
structures (if a crash occured) or allocate memory. The way around that is to 
pre-allocate and pre-copy the structures that you will be accessing in the case 
of a crash. But I don't see it as a hurdle in this case.


Repository:
  rC Clang

https://reviews.llvm.org/D52193



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


[PATCH] D52193: RFC: [clang] Multithreaded compilation support

2018-10-10 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea added a comment.

Updated tests again. This time I've closed all applications, all unused 
services, and tried to have a "clean" machine.

New timings without the child `clang-cl.exe` being invoked (hacked from 
https://reviews.llvm.org/D52411). The test consists in building Clang+LLVM+LLD 
at r343846 using the compiler specified on each line of the table.

**Config 1:** Intel Xeon Haswell 6 cores / 12 HW threads, 3.5 GHz, 15 MB cache, 
128 GB RAM, SSD 550 MB/s (Windows 10 Fall Creators update 1709)

__Ninja:__

| MSVC 15.8.6 (cl + link)   
  | 29 min 4 sec  |
| clang-cl + lld-link 7.0 official release  
  | 25 min 45 sec |
| clang-cl + lld-link 8.0 r343846 //built with clang-cl 7.0 official// **(no 
child)** | **23 min 27 sec** |
|

**Config 2:** Intel Xeon Skylake 18 cores / 36 HW threads, x2 (Dual CPU), 72 HW 
threads total, 2.3 GHz, 24.75 MB cache each, 128 GB RAM, NVMe SSD 4.6 GB/s 
(Windows 10 Fall Creators update 1709)

__Ninja:__

| MSVC 15.8.6 (cl + link)   
  | 6 min 40 sec |
| clang-cl + lld-link 7.0 official release  
  | 6 min 24 sec |
| clang-cl + lld-link 8.0 r343846 //built with clang-cl 7.0 official// **(no 
child)** | **5 min 10 sec** |
|

I'm wondering if the improvement is of the same order on Linux. I'd be 
interested to see your build times, out of curiosity? Can any of you try it 
with and without https://reviews.llvm.org/D52411?


Repository:
  rC Clang

https://reviews.llvm.org/D52193



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


[PATCH] D52193: RFC: [clang] Multithreaded compilation support

2018-09-20 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea added a comment.

In https://reviews.llvm.org/D52193#1241056, @zturner wrote:

> The process stuff looks cool and useful independently of `/MP`.  Would it be 
> possible to break that into a separate patch, and add a unit test for the 
> behavior of the `WaitAll` flag?


Of course, will do.


Repository:
  rC Clang

https://reviews.llvm.org/D52193



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


[PATCH] D52193: RFC: [clang] Multithreaded compilation support

2018-09-20 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea marked an inline comment as done.
aganea added a comment.

It seems Reid's change has done good: `cmake` is not as significant as before 
in the build process. See below the improved timings:

The tests consist in a full cleanup (delete build folder), cmake to regenerate, 
then a full rebuild of LLVM + Clang + LLD (at r342552), Release target, 
optimized tablegen.
VS2017 15.8.3, Ninja 1.8.2, CMake 3.12.2
For the `clang-cl` tests, I'm not using any official LLVM release, only the 
binaries I built myself. `lld-link` is used in that case.

//(built with MSVC)// means the LLVM toolchain used to perfom this test was 
compiled in a previous run with MSVC cl 15.8.3
//(built with Clang)// means the LLVM toolchain used to perform this test was 
compiled in a previous run with Clang at r342552

I took the best figures from several runs (ran in a random order).

---

**Config 1 :** Intel Xeon Haswell 6 cores / 12 HW threads, 3.5 GHz, 15M cache, 
128 GB RAM, SSD 550 MB/s

__MSBuild :__

| MSVC cl /MP | (50min 26sec) | 2 parallel msbuild  
|
| MSVC cl /MP | (40min 23sec) | 8 parallel msbuild  
|
| MSVC cl /MP | (40min 5sec)  | 16 parallel msbuild 
|
| clang-cl //(built with MSVC)//  | (43min 36sec) | 16 parallel msbuild 
|
| clang-cl //(built with Clang//) | (43min 42sec) | 16 parallel msbuild 
|
| clang-cl **/MP** //(built with MSVC)//  | not tested| 
|
| clang-cl **/MP** //(built with Clang)// | (36min 13sec) | 8 parallel msbuild  
|
| clang-cl **/MP** //(built with Clang)// | (34min 57sec) | 16 parallel msbuild 
|
|

__Ninja:__

| MSVC cl | (33min 29sec) |
| clang-cl //(built with MSVC)//  | (30min 2sec)  |
| clang-cl //(built with Clang)// | (28min 29sec) |
|



-

**Config 2 :** Intel Xeon Skylake 18 cores / 36 HW threads, x2 (Dual CPU), 72 
HW threads total, 2.3 GHz, 24.75M cache, 128 GB RAM, NVMe 4.6 GB/s

__MSBuild :__

| MSVC cl /MP | (10min 3sec)  | 32 parallel msbuild 
|
| clang-cl //(built with MSVC)//  | (24min 15sec) | 32 parallel msbuild 
|
| clang-cl //(built with Clang)// | (21min 21sec) | 32 parallel msbuild 
|
| clang-cl **/MP** //(built with MSVC)//  | (7min 52sec)  | 32 parallel msbuild 
|
| clang-cl **/MP** //(built with Clang)// | (7min 30sec)  | 32 parallel msbuild 
|
|

__Ninja:__

| MSVC cl | (7min 25sec) |
| clang-cl //(built with MSVC)//  | (8min 23sec) |
| clang-cl //(built with Clang)// | (8min)   |
|




Comment at: llvm/trunk/lib/Support/Windows/Program.inc:424
 
-ProcessInfo sys::Wait(const ProcessInfo , unsigned SecondsToWait,
-  bool WaitUntilChildTerminates, std::string *ErrMsg) {
-  assert(PI.Pid && "invalid pid to wait on, process not started?");
-  assert((PI.Process && PI.Process != INVALID_HANDLE_VALUE) &&
- "invalid process handle to wait on, process not started?");
+bool sys::WaitMany(MutableArrayRef PIArray, bool WaitOnAll,
+   unsigned SecondsToWait, bool WaitUntilProcessTerminates) {

rnk wrote:
> I guess no Posix implementation? It's kind of hard to know if we made the 
> right abstractions without doing it for Windows and *nix.
Yes, I currenly don't have an Unix box at hand. But I will implement it shortly 
as it needs to be atomically commited with the Windows part.


Repository:
  rC Clang

https://reviews.llvm.org/D52193



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


[PATCH] D52193: RFC: [clang] Multithreaded compilation support

2018-09-20 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea added a comment.

> clang-cl isn't supposed to do (explicit) registry accesses when you hold it 
> right (pass in -fms-compatibility-version etc). Have you seen registry access 
> costs, or is that speculation?

Please see this log: F7268226: clang-cl-log.zip 
 - the child `clang-cl -cc1` takes about 
~117ms until it gets into the global initializers. This is on my Haswell PC. On 
the Skylake, this takes "only" ~60ms.
This probably explains why Ninja is slower on the Skylake when using `clang-cl` 
as a compiler. There should be a shorter codepath maybe when only a single .cpp 
is being compiled, and avoid running the child process.


Repository:
  rC Clang

https://reviews.llvm.org/D52193



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


[PATCH] D52193: RFC: [clang] Multithreaded compilation support

2018-09-19 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea added a comment.

In https://reviews.llvm.org/D52193#1239171, @hans wrote:

> Thanks for adding the Ninja numbers. It confirms that Ninja is significantly 
> faster than MSBuild + /MP.


It is true for the 6-cores Xeon, but not for the dual-18-cores. I think there 
are two issues there, somehow unrelated to /MP: 1. Invoking the child clang-cl 
-cc1 for **each** cpp file makes things much slower. I’ve clocked the 
invocation at about 60-100ms (which is caused mainly by loading dlls & 
registery accesses). Most likely Reid’s change about delay loading dlls should 
improve that. 2. The other issue is, I think, the process context switching at 
the OS-level. This link:  
https://www.phoronix.com/scan.php?page=article=2990wx-linux-windows=4 
- shows that multi-threading is significantly faster on a Linux machine, as far 
as high cores count goes (when compared with the same test ran on the same 
machine under Windows 10).

> Since that's the case, maybe we should be poking MS about making MSBuild 
> faster instead of adding /MP support to Clang? Or making it easier to use 
> Ninja in VS projects? Your patch says RFC after all :-)

Sad for Microsoft, but at this point it is a _design_ change MSBuild needs. And 
as a PM I would rather invest in bindings to better build systems (Ninja, 
Fastbuild). However I expect there are still users of MSBuild out there, and 
without /MP this means essentially that migrating to clang-cl requires also 
changing their build system and their VS2017 integration with the said build 
system.


Repository:
  rC Clang

https://reviews.llvm.org/D52193



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


[PATCH] D52193: RFC: [clang] Multithreaded compilation support

2018-09-19 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea added a comment.

> clang-cl isn't supposed to do (explicit) registry accesses when you hold it 
> right (pass in -fms-compatibility-version etc). Have you seen registry access 
> costs, or is that speculation?

No speculation, I will share the FileMon logs shortly. It is indirectly 
dependent DLLs that access the registry, not clang-cl itself.


Repository:
  rC Clang

https://reviews.llvm.org/D52193



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


[PATCH] D11850: Delay emitting members of dllexport classes until the class is fully parsed (PR23542)

2018-12-18 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea added subscribers: belkiss, rnk, aganea.
aganea added a comment.
Herald added a subscriber: llvm-commits.

Cross-referencing PR40006 . It 
seems to be a different manifestation of this same bug.

@hans Could you possibly take a look at the bug above whenever you have time? 
Many thanks!


Repository:
  rL LLVM

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

https://reviews.llvm.org/D11850



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


[PATCH] D52193: RFC: [clang] Multithreaded compilation support

2018-09-17 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea created this revision.
aganea added reviewers: rnk, hans, zturner.
Herald added a reviewer: JDevlieghere.
Herald added a subscriber: cfe-commits.

This is very preliminary change which adds support for (`clang-cl`) `/MP` 
(Build with multiple processes). Doc for `/MP` is here 
.

Support for `-j` to the `clang` driver could also be added along the way.

I would simply like a general advice on this change. **I don't plan to commit 
this as it is**. If the general idea seems good, I'll cut it down in several 
smaller pieces.

The change about having explicit return codes (`Program.h / enum 
ProgramReturnCode`) should probably be discussed separately, although if you 
have an opinion about that, please do.

Some timings //(I ran each configuration several time to ensure the figures are 
stable)//

  Build LLVM + Clang + LLD (at r341847) inside VS2017:
  
  (Intel Xeon Haswell 6 cores / 12 HW threads, 3.5 GHz, 15M cache, 128 GB RAM, 
SSD 550 MB/s)
  
  - With VS2017 15.8.3: (56m 43 sec) 2 parallel msbuild
  - With Clang /MP + LLD (trunk r341847) [1]: (51m 8sec) 2 parallel msbuild
  
  
  (Intel Xeon Skylake 18 cores / 36 HW threads, x2 (Dual CPU), 72 HW threads 
total, 2.3 GHz, 24.75M cache, 128 GB RAM, NVMe 4.6 GB/s)
  
  - With VS2017 15.8.3: (12m 8sec) 32 parallel msbuild
  - With Clang /MP + LLD (trunk r341847) [1]: (9m 22sec) 32 parallel msbuild
  
  [1] running clang-cl.exe compiled with VS2017 15.8.3 at r341847

Please add anyone who might want to review this. Many thanks in advance!


Repository:
  rC Clang

https://reviews.llvm.org/D52193

Files:
  clang/trunk/include/clang/Driver/CLCompatOptions.td
  clang/trunk/include/clang/Driver/Compilation.h
  clang/trunk/include/clang/Driver/Driver.h
  clang/trunk/include/clang/Driver/Job.h
  clang/trunk/lib/Driver/Compilation.cpp
  clang/trunk/lib/Driver/Driver.cpp
  clang/trunk/lib/Driver/Job.cpp
  clang/trunk/tools/driver/cc1_main.cpp
  clang/trunk/tools/driver/cc1as_main.cpp
  clang/trunk/tools/driver/cc1gen_reproducer_main.cpp
  clang/trunk/tools/driver/driver.cpp
  llvm/trunk/include/llvm/Support/Program.h
  llvm/trunk/lib/Support/GraphWriter.cpp
  llvm/trunk/lib/Support/Program.cpp
  llvm/trunk/lib/Support/Windows/DynamicLibrary.inc
  llvm/trunk/lib/Support/Windows/Process.inc
  llvm/trunk/lib/Support/Windows/Program.inc
  llvm/trunk/lib/Support/Windows/WindowsSupport.h
  llvm/trunk/tools/bugpoint/ExecutionDriver.cpp
  llvm/trunk/tools/bugpoint/OptimizerDriver.cpp
  llvm/trunk/tools/bugpoint/ToolRunner.cpp
  llvm/trunk/tools/bugpoint/ToolRunner.h
  llvm/trunk/tools/dsymutil/MachOUtils.cpp
  llvm/trunk/tools/llvm-cov/CodeCoverage.cpp
  llvm/trunk/unittests/Support/ProgramTest.cpp
  llvm/trunk/utils/not/not.cpp

Index: clang/trunk/tools/driver/driver.cpp
===
--- clang/trunk/tools/driver/driver.cpp
+++ clang/trunk/tools/driver/driver.cpp
@@ -199,11 +199,11 @@
   }
 }
 
-extern int cc1_main(ArrayRef Argv, const char *Argv0,
+extern bool cc1_main(ArrayRef Argv, const char *Argv0,
 void *MainAddr);
-extern int cc1as_main(ArrayRef Argv, const char *Argv0,
+extern bool cc1as_main(ArrayRef Argv, const char *Argv0,
   void *MainAddr);
-extern int cc1gen_reproducer_main(ArrayRef Argv,
+extern bool cc1gen_reproducer_main(ArrayRef Argv,
   const char *Argv0, void *MainAddr);
 
 static void insertTargetAndModeArgs(const ParsedClangName ,
@@ -304,7 +304,7 @@
 TheDriver.setInstalledDir(InstalledPathParent);
 }
 
-static int ExecuteCC1Tool(ArrayRef argv, StringRef Tool) {
+static bool ExecuteCC1Tool(ArrayRef argv, StringRef Tool) {
   void *GetExecutablePathVP = (void *)(intptr_t) GetExecutablePath;
   if (Tool == "")
 return cc1_main(argv.slice(2), argv[0], GetExecutablePathVP);
@@ -316,15 +316,15 @@
   // Reject unknown tools.
   llvm::errs() << "error: unknown integrated tool '" << Tool << "'. "
<< "Valid tools include '-cc1' and '-cc1as'.\n";
-  return 1;
+  return false;
 }
 
 int main(int argc_, const char **argv_) {
   llvm::InitLLVM X(argc_, argv_);
   SmallVector argv(argv_, argv_ + argc_);
 
   if (llvm::sys::Process::FixupStandardFileDescriptors())
-return 1;
+return (int)llvm::sys::ProgramReturnCode::Failure;
 
   llvm::InitializeAllTargets();
   auto TargetAndMode = ToolChain::getTargetAndModeFromProgramName(argv[0]);
@@ -379,7 +379,9 @@
   auto newEnd = std::remove(argv.begin(), argv.end(), nullptr);
   argv.resize(newEnd - argv.begin());
 }
-return ExecuteCC1Tool(argv, argv[1] + 4);
+bool R = ExecuteCC1Tool(argv, argv[1] + 4);
+return int(R ? llvm::sys::ProgramReturnCode::Success
+ : llvm::sys::ProgramReturnCode::Failure);
   }
 
   bool CanonicalPrefixes = true;
@@ -456,39 +458,32 @@
   SetBackdoorDriverOutputsFromEnvVars(TheDriver);
 
   std::unique_ptr 

[PATCH] D52193: RFC: [clang] Multithreaded compilation support

2018-09-18 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea added a comment.

In https://reviews.llvm.org/D52193#1238944, @zturner wrote:

> In https://reviews.llvm.org/D52193#1238923, @aganea wrote:
>
> > The goal of this change is frictionless compilation into VS2017 when using 
> > `clang-cl` as a compiler. We've realized that compiling Clang+LLD with 
> > Clang generates a faster executable that with MSVC (even latest one).
> >  I currently can't see a good way of generating the Visual Studio solution 
> > with CMake, while using Ninja+clang-cl for compilation. They are two 
> > orthogonal configurations. Any suggestions?
>
>
> I don't think this is necessary.  I think your updated Matrix is pretty good.
>
> I'm surprised to see that Ninja + Clang is slower than Ninja + MSVC.  Are you 
> using lld here?


Yes, all the ‘Clang’ rows use both clang-cl and lld-link.
Like stated above, I think this is caused by a lot more processes 
(clang-cl.exe) being invoked. In contrast, cl.exe does not invoke a child 
process. There are about 3200 files to compiles, which makes 6400 calls to 
clang-cl. At about ~60ms lead time per process, that adds up to an extra ~3min 
wall clock time. It is the simplest explanation I could find.


Repository:
  rC Clang

https://reviews.llvm.org/D52193



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


[PATCH] D52193: RFC: [clang] Multithreaded compilation support

2018-09-18 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea added a comment.

The goal of this change is frictionless compilation into VS2017 when using 
`clang-cl` as a compiler. We've realized that compiling Clang+LLD with Clang 
generates a faster executable that with MSVC (even latest one).
I currently can't see a good way of generating the Visual Studio solution with 
CMake, while using Ninja+clang-cl for compilation. They are two orthogonal 
configurations. Any suggestions?


Repository:
  rC Clang

https://reviews.llvm.org/D52193



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


[PATCH] D60018: [codeview] Remove Type member from CVRecord

2019-04-02 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea accepted this revision.
aganea added a comment.
This revision is now accepted and ready to land.

LGTM. With a few minor comments:




Comment at: llvm/include/llvm/DebugInfo/CodeView/TypeDeserializer.h:122
   ~FieldListDeserializer() override {
-CVType FieldList;
-FieldList.Type = TypeLeafKind::LF_FIELDLIST;
+RecordPrefix Pre;
+Pre.RecordLen = 2;

`RecordPrefix Pre(TypeLeafKind::LF_FIELDLIST);` like the other places? And 
above.



Comment at: llvm/lib/DebugInfo/PDB/Native/GSIStreamBuilder.cpp:40
+  static CVSymbol Tombstone(
+  ArrayRef(DenseMapInfo::getTombstoneKey(), 1));
   return Tombstone;

rnk wrote:
> aganea wrote:
> > I suppose you've chosen 1 because that's a invalid record size? Comment 
> > maybe?
> Actually, the reason I did this was to avoid ambiguity between the `T* begin, 
> T* end` ctor and the `T* base, size_t count` ctor. If I use zero, it's 
> ambiguous. Implicit null strikes again. :)
Oh I see. Why not `static CVSymbol 
Tombstone(DenseMapInfo>::getTombstoneKey());` then?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D60018



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


[PATCH] D60018: [codeview] Remove Type member from CVRecord

2019-04-01 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea added inline comments.



Comment at: llvm/include/llvm/DebugInfo/CodeView/CVRecord.h:29
+/// Carrying the size separately instead of trusting the size stored in the
+/// record prefix provides some extra safety and flexibility.
 template  class CVRecord {

To add to what you said in a comment above, do you think that if we could add 
`assert(Data.size() == ((RecordPrefix *)RecordData.data())->RecordPrefix + 2)` 
at relevant places below; and then after a while we could simply switch to 
`RecordPrefix *`, once issues are ironed out?



Comment at: llvm/include/llvm/DebugInfo/CodeView/SymbolSerializer.h:56
+RecordPrefix *Prefix = reinterpret_cast([0]);
+Prefix->RecordLen = 0;
+Prefix->RecordKind = uint16_t(Sym.Kind);

rnk wrote:
> aganea wrote:
> > Should be 2.
> I could say 2, but this is the seralizer, so really it just gets overwritten. 
> Do you think I should leave it uninitialized, 2, -1, 0?
I'd say "2" because you want as much as possible to keep data coherent in time. 
Regardless of what comes after. I think the code should be correct before being 
optimal. If someone looks for `RecordPrefix` and then tries to understand how 
it works, it'd be nice if the code displays the same, correct, behavior 
everywhere.

But then, you can argue that `RecordPrefix.RecordLen` is simply a constrait, 
tied to the amount data that comes after. And maybe the calculation logic for 
that `.RecordLen` field should be hidden inside the `RecordPrefix` class. In 
that case, to avoid screwing the init order, ideally you could simply say:
```
RecordPrefix Prefix{uint16_t(Sym.Kind)};
CVSymbol Result();
```
...and let `RecordPrefix` (or `CVSymbol`) handle sizing?



Comment at: llvm/include/llvm/DebugInfo/CodeView/TypeDeserializer.h:125
+Pre.RecordKind = uint16_t(TypeLeafKind::LF_FIELDLIST);
+CVType FieldList(, sizeof(Pre));
 consumeError(Mapping.Mapping.visitTypeEnd(FieldList));

Applying what I said above would give:
```
RecordPrefix Pre{uint16_t(TypeLeafKind::LF_FIELDLIST)};
CVType FieldList();
```



Comment at: llvm/lib/DebugInfo/CodeView/SimpleTypeSerializer.cpp:37
 
+  CVType CVT(ArrayRef(ScratchBuffer.data(), sizeof(RecordPrefix)));
   cantFail(Mapping.visitTypeBegin(CVT));

Here it is the same thing: `writeRecordPrefix()` writes a `.RecordLen = 0`, but 
it could very well write 2 to be coherent, then you would be able to //trust// 
the `RecordPrefix *`.



Comment at: llvm/lib/DebugInfo/PDB/Native/GSIStreamBuilder.cpp:40
+  static CVSymbol Tombstone(
+  ArrayRef(DenseMapInfo::getTombstoneKey(), 1));
   return Tombstone;

I suppose you've chosen 1 because that's a invalid record size? Comment maybe?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D60018



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


[PATCH] D60018: [codeview] Remove Type member from CVRecord

2019-04-01 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea marked an inline comment as done.
aganea added inline comments.



Comment at: llvm/include/llvm/DebugInfo/CodeView/CVRecord.h:29
+/// Carrying the size separately instead of trusting the size stored in the
+/// record prefix provides some extra safety and flexibility.
 template  class CVRecord {

aganea wrote:
> To add to what you said in a comment above, do you think that if we could add 
> `assert(Data.size() == ((RecordPrefix *)RecordData.data())->RecordPrefix + 
> 2)` at relevant places below; and then after a while we could simply switch 
> to `RecordPrefix *`, once issues are ironed out?
I didn't mean now.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D60018



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


[PATCH] D60283: [clang-cl] Don't emit checksums when compiling a preprocessed CPP

2019-04-04 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea created this revision.
aganea added reviewers: rnk, scott.linder, uabelho, aprantl.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

When compiling from an already preprocessed CPP, the checksums generated in the 
debug info would be those of the (input) preprocessed CPP, not those of the 
actual #includes.
Note how all the files have the same checksum below:

  ** Module: "E:\RD\tests\clang_hash\main.obj"
  
   0 E:\RD\tests\clang_hash\lib.h (MD5: 136293700AE501A1FB76EBD273C8D288)
   1 C:\Program Files (x86)\Windows 
Kits\10\Include\10.0.17763.0\ucrt\stdio.h (MD5: 
136293700AE501A1FB76EBD273C8D288)
   2 E:\RD\tests\clang_hash\main.cpp (MD5: 136293700AE501A1FB76EBD273C8D288)
   3 C:\Program Files (x86)\Windows 
Kits\10\Include\10.0.17763.0\ucrt\corecrt_stdio_config.h (MD5: 
136293700AE501A1FB76EBD273C8D288)

When debugging in Visual Studio an EXE linked with the OBJ above, Visual Studio 
complains about the source files being different from when they were compiled, 
since the sources are compared by hash.

This patch simply clears the checksums to match MSVC behavior. Visual Studio 
will simply bypass the hash checking in that case, and hapily open the source 
file.

  ** Module: "E:\RD\tests\clang_hash\main.obj"
  
   0 c:\program files (x86)\windows 
kits\10\include\10.0.17763.0\ucrt\stdio.h (None)
   1 c:\program files (x86)\windows 
kits\10\include\10.0.17763.0\ucrt\corecrt_wstdio.h (None)
   2 c:\program files (x86)\windows 
kits\10\include\10.0.17763.0\ucrt\corecrt_stdio_config.h (None)
   3 c:\program files (x86)\microsoft visual 
studio\2017\professional\vc\tools\msvc\14.16.27023\include\vcruntime_new.h 
(None)
   4 e:\rd\tests\clang_hash\main.cpp (None)
   5 e:\rd\tests\clang_hash\lib.h (None)

We could write more complicated code to open the files from the corresponding 
#line directives, but we have no guarantee the preprocessed CPP is compiled in 
the same conditions as when it was pre-processed. Actually, when using 
Fastbuild, the files are preprocessed locally on the user's PC; then the 
preprocessed content is sent and compiled remotely on another PC that does not 
have the source code.

Fixes PR41215


Repository:
  rC Clang

https://reviews.llvm.org/D60283

Files:
  lib/CodeGen/CGDebugInfo.cpp
  test/Driver/cl-preprocess-md5.cpp


Index: test/Driver/cl-preprocess-md5.cpp
===
--- test/Driver/cl-preprocess-md5.cpp
+++ test/Driver/cl-preprocess-md5.cpp
@@ -0,0 +1,15 @@
+// RUN: %clang_cl /c %s /Z7 /Fo%t.obj
+// RUN: llvm-pdbutil dump -l %t.obj | grep -E " \(MD5: ([0-9A-F]+)\)" | sed -n 
-e 's/^.*MD5: //p' | sort | uniq | wc -l | FileCheck %s --check-prefix=GOOD-SIZE
+// GOOD-SIZE-NOT: 1
+
+// RUN: %clang_cl /c %s /Z7 /E >%t.cpp
+// RUN: %clang_cl /c %t.cpp /Z7 /Fo%t.obj
+// RUN: llvm-pdbutil dump -l %t.obj | not grep -E " \(MD5: ([0-9A-F]+)\)"
+// RUN: llvm-pdbutil dump -l %t.obj | grep " (no checksum)"
+// 
+
+#include 
+int main() {
+  std::string A{"a"};
+  return 0;
+}
Index: lib/CodeGen/CGDebugInfo.cpp
===
--- lib/CodeGen/CGDebugInfo.cpp
+++ lib/CodeGen/CGDebugInfo.cpp
@@ -421,13 +421,18 @@
   return cast(V);
   }
 
+  const FileID foundIdFromLoc = SM.getFileID(Loc);
   SmallString<32> Checksum;
-  Optional CSKind =
-  computeChecksum(SM.getFileID(Loc), Checksum);
+  Optional CSKind;
   Optional> CSInfo;
-  if (CSKind)
-CSInfo.emplace(*CSKind, Checksum);
-  return createFile(FileName, CSInfo, getSource(SM, SM.getFileID(Loc)));
+  const FileEntry *fileEntry = SM.getFileEntryForID(foundIdFromLoc);
+  if (!fileEntry || fileEntry->getName().empty() ||
+  fileEntry->getName().equals(FileName)) {
+CSKind = computeChecksum(foundIdFromLoc, Checksum);
+if (CSKind)
+  CSInfo.emplace(*CSKind, Checksum);
+  }
+  return createFile(FileName, CSInfo, getSource(SM, foundIdFromLoc));
 }
 
 llvm::DIFile *


Index: test/Driver/cl-preprocess-md5.cpp
===
--- test/Driver/cl-preprocess-md5.cpp
+++ test/Driver/cl-preprocess-md5.cpp
@@ -0,0 +1,15 @@
+// RUN: %clang_cl /c %s /Z7 /Fo%t.obj
+// RUN: llvm-pdbutil dump -l %t.obj | grep -E " \(MD5: ([0-9A-F]+)\)" | sed -n -e 's/^.*MD5: //p' | sort | uniq | wc -l | FileCheck %s --check-prefix=GOOD-SIZE
+// GOOD-SIZE-NOT: 1
+
+// RUN: %clang_cl /c %s /Z7 /E >%t.cpp
+// RUN: %clang_cl /c %t.cpp /Z7 /Fo%t.obj
+// RUN: llvm-pdbutil dump -l %t.obj | not grep -E " \(MD5: ([0-9A-F]+)\)"
+// RUN: llvm-pdbutil dump -l %t.obj | grep " (no checksum)"
+// 
+
+#include 
+int main() {
+  std::string A{"a"};
+  return 0;
+}
Index: lib/CodeGen/CGDebugInfo.cpp
===
--- lib/CodeGen/CGDebugInfo.cpp
+++ lib/CodeGen/CGDebugInfo.cpp
@@ -421,13 +421,18 @@
   return cast(V);
   }
 
+  const FileID foundIdFromLoc = SM.getFileID(Loc);
   

[PATCH] D60283: [clang-cl] Don't emit checksums when compiling a preprocessed CPP

2019-04-05 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea updated this revision to Diff 193886.
aganea marked 2 inline comments as done.
aganea edited the summary of this revision.
aganea added a comment.

I made a more elegant change, where no additional lookups or string compares 
are required.

I noted btw that clang /E does not generate `#line` directives, but simply `#`. 
In contrast, MSVC cl /E generates `#line` in the preprocessed output. The issue 
is that MSVC doesn't like `#` alone and throws an error. ie:

  $ cat test.cpp
  void test() { }
  
  $ clang-cl /c /E test.cpp >test-pre.cpp
  
  $ cat test-pre.cpp
  # 1 "C:\\Users\\aganea\\Desktop\\test\\test.cpp"
  # 1 "" 1
  # 1 "" 3
  # 361 "" 3
  # 1 "" 1
  # 1 "" 2
  # 1 "C:\\Users\\aganea\\Desktop\\test\\test.cpp" 2
  void test() { }
  
  $ cl /c test-pre.cpp
  Microsoft (R) C/C++ Optimizing Compiler Version 19.16.27027.1 for x64
  Copyright (C) Microsoft Corporation.  All rights reserved.
  
  test-pre.cpp
  C:\Users\aganea\Desktop\test\test-pre.cpp(1): error C2019: expected 
preprocessor directive, found '1'
  C:\Users\aganea\Desktop\test\test-pre.cpp(2): error C2019: expected 
preprocessor directive, found '1'
  C:\Users\aganea\Desktop\test\test-pre.cpp(3): error C2019: expected 
preprocessor directive, found '1'
  C:\Users\aganea\Desktop\test\test-pre.cpp(4): error C2019: expected 
preprocessor directive, found '3'
  C:\Users\aganea\Desktop\test\test-pre.cpp(5): error C2019: expected 
preprocessor directive, found '1'
  C:\Users\aganea\Desktop\test\test-pre.cpp(6): error C2019: expected 
preprocessor directive, found '1'
  C:\Users\aganea\Desktop\test\test-pre.cpp(7): error C2019: expected 
preprocessor directive, found '1'
  
  $ cl /c /E test.cpp >test-pre.cpp
  
  $ cat test-pre.cpp
  #line 1 "C:\\Users\\aganea\\Desktop\\test\\test.cpp"
  void test() { }
  
  $ cl /c test-pre.cpp
  Microsoft (R) C/C++ Optimizing Compiler Version 19.16.27027.1 for x64
  Copyright (C) Microsoft Corporation.  All rights reserved.
  
  test-pre.cpp


Repository:
  rC Clang

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

https://reviews.llvm.org/D60283

Files:
  include/clang/Basic/SourceLocation.h
  lib/Basic/SourceManager.cpp
  lib/CodeGen/CGDebugInfo.cpp
  test/CodeGen/Inputs/debug-info-file-checksum-pre.cpp
  test/CodeGen/debug-info-file-checksum.c

Index: test/CodeGen/debug-info-file-checksum.c
===
--- test/CodeGen/debug-info-file-checksum.c
+++ test/CodeGen/debug-info-file-checksum.c
@@ -4,3 +4,11 @@
 // Check that "checksum" is created correctly for the compiled file.
 
 // CHECK: !DIFile(filename:{{.*}}, directory:{{.*}}, checksumkind: CSK_MD5, checksum: "a3b7d27af071accdeccaa933fc603608")
+
+// Ensure #line directives (in already pre-processed files) do not emit checksums
+
+// RUN: %clang -emit-llvm -S -g -gcodeview -x c %S/Inputs/debug-info-file-checksum-pre.cpp -o - | FileCheck %s --check-prefix NOCHECKSUM
+
+// NOCHECKSUM-LABEL: !DIFile(filename: "{{.*}}code-coverage-filter1.h", directory: "{{[^"]*}}")
+// NOCHECKSUM-LABEL: !DIFile(filename: "{{.*}}code-coverage-filter2.h", directory: "{{[^"]*}}")
+// NOCHECKSUM-LABEL: !DIFile(filename: "{{.*}}debug-info-file-checksum.c", directory: "{{[^"]*}}")
Index: test/CodeGen/Inputs/debug-info-file-checksum-pre.cpp
===
--- test/CodeGen/Inputs/debug-info-file-checksum-pre.cpp
+++ test/CodeGen/Inputs/debug-info-file-checksum-pre.cpp
@@ -0,0 +1,10 @@
+#line 1 "F:\\svn\\clang\\test\\CodeGen\\Inputs\\debug-info-file-checksum.c"
+#line 1 "f:\\svn\\clang\\test\\codegen\\inputs\\code-coverage-filter1.h"
+void test1() {}
+#line 2 "F:\\svn\\clang\\test\\CodeGen\\Inputs\\debug-info-file-checksum.c"
+#line 1 "f:\\svn\\clang\\test\\codegen\\inputs\\code-coverage-filter2.h"
+void test2() {}
+#line 3 "F:\\svn\\clang\\test\\CodeGen\\Inputs\\debug-info-file-checksum.c"
+int foo(int x) {
+  return x+1;
+}
Index: lib/CodeGen/CGDebugInfo.cpp
===
--- lib/CodeGen/CGDebugInfo.cpp
+++ lib/CodeGen/CGDebugInfo.cpp
@@ -422,11 +422,18 @@
   }
 
   SmallString<32> Checksum;
-  Optional CSKind =
-  computeChecksum(SM.getFileID(Loc), Checksum);
   Optional> CSInfo;
-  if (CSKind)
-CSInfo.emplace(*CSKind, Checksum);
+
+  // Don't compute checksums if the location is affected by a #line directive.
+  // We would otherwise end up with the same checksum for all the files referred
+  // by #line. Instead we simply leave the checksum empty, and the debugger will
+  // open the file without checksums.
+  if (!PLoc.isAffectedByLineDirective()) {
+Optional CSKind =
+computeChecksum(SM.getFileID(Loc), Checksum);
+if (CSKind)
+  CSInfo.emplace(*CSKind, Checksum);
+  }
   return createFile(FileName, CSInfo, getSource(SM, SM.getFileID(Loc)));
 }
 
Index: lib/Basic/SourceManager.cpp
===
--- 

[PATCH] D60283: [clang-cl] Don't emit checksums when compiling a preprocessed CPP

2019-04-05 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea added a comment.

I'll try profiling several solution on a large unity/jumbo file and get back 
with some results.


Repository:
  rC Clang

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

https://reviews.llvm.org/D60283



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


[PATCH] D60283: [clang-cl] Don't emit checksums when compiling a preprocessed CPP

2019-04-05 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea added a comment.

In D60283#1456497 , @thakis wrote:

> See 
> http://llvm-cs.pcc.me.uk/tools/clang/lib/Frontend/VerifyDiagnosticConsumer.cpp#756
>  for a "is same file" example. I'm not sure adding a bool to PresumedLoc is 
> worth it for this.


Yeah that works. However I'm getting two conflicting directions - I thought the 
worry was to avoid an extra runtime cost when comparing strings (see first 
version ). @rnk wanted 
at first a compare by FileID, although it looks like it's more costly to do 
that, because all paths end up in `SourceManager::getFileIDSlow`. Just by 
tracing the code on a small preprocessed CPP, it looks like a costly solution. 
Using `IsFromSameFile` ends up in `SourceManager::getFileIDSlow` several times 
per iteration - whereas the solution proposed above (boolean) has zero runtime 
cost. I'm worried that large files with lots of `#line` will be much slower to 
compile. What do you think?


Repository:
  rC Clang

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

https://reviews.llvm.org/D60283



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


[PATCH] D52193: RFC: [clang] Multithreaded compilation support -- NOT FOR SUBMIT

2019-04-07 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea added a comment.

That is strange. As you can’t mix /Yc and /Yu on the command line, MSBuild 
should issue two different calls to clang-cl, one with /Yc and one /Yu /MP. Can 
you check with ProcMon that commands are issued in the right order?


Repository:
  rC Clang

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

https://reviews.llvm.org/D52193



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


[PATCH] D60283: [DebugInfo] Don't emit checksums when compiling a preprocessed CPP

2019-05-15 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea updated this revision to Diff 199659.
aganea marked 3 inline comments as done.
aganea added a comment.

In D60283#1503256 , @probinson wrote:

> Minor stuff.  This solution is surprisingly simple, the main question being 
> (and I don't have an answer) whether increasing the size of PresumedLoc is 
> okay.


Thanks Paul! `PresumedLoc` seems to be used only as a temporary (on the stack).


Repository:
  rC Clang

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

https://reviews.llvm.org/D60283

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

Index: test/CodeGen/debug-info-file-checksum.c
===
--- test/CodeGen/debug-info-file-checksum.c
+++ test/CodeGen/debug-info-file-checksum.c
@@ -4,3 +4,15 @@
 // Check that "checksum" is created correctly for the compiled file.
 
 // CHECK: !DIFile(filename:{{.*}}, directory:{{.*}}, checksumkind: CSK_MD5, checksum: "a3b7d27af071accdeccaa933fc603608")
+
+// Ensure #line directives (in already pre-processed files) do not emit checksums
+// RUN: %clang -emit-llvm -S -g -gcodeview -x c %S/Inputs/debug-info-file-checksum-pre.cpp -o - | FileCheck %s --check-prefix NOCHECKSUM
+
+// NOCHECKSUM: !DIFile(filename: "{{.*}}code-coverage-filter1.h", directory: "{{[^"]*}}")
+// NOCHECKSUM: !DIFile(filename: "{{.*}}code-coverage-filter2.h", directory: "{{[^"]*}}")
+// NOCHECKSUM: !DIFile(filename: "{{.*}}debug-info-file-checksum.c", directory: "{{[^"]*}}")
+
+// Ensure #line directives without name do emit checksums
+// RUN: %clang -emit-llvm -S -g -gcodeview -x c %S/Inputs/debug-info-file-checksum-line.cpp -o - | FileCheck %s --check-prefix CHECKSUM
+
+// CHECKSUM: !DIFile(filename: "{{.*}}debug-info-file-checksum-line.cpp", directory:{{.*}}, checksumkind: CSK_MD5, checksum: "7b568574d0e3c56c28e5e0234d1f4a06")
Index: test/CodeGen/Inputs/debug-info-file-checksum-pre.cpp
===
--- test/CodeGen/Inputs/debug-info-file-checksum-pre.cpp
+++ test/CodeGen/Inputs/debug-info-file-checksum-pre.cpp
@@ -0,0 +1,10 @@
+#line 1 "F:\\svn\\clang\\test\\CodeGen\\Inputs\\debug-info-file-checksum.c"
+#line 1 "f:\\svn\\clang\\test\\codegen\\inputs\\code-coverage-filter1.h"
+void test1() {}
+#line 2 "F:\\svn\\clang\\test\\CodeGen\\Inputs\\debug-info-file-checksum.c"
+#line 1 "f:\\svn\\clang\\test\\codegen\\inputs\\code-coverage-filter2.h"
+void test2() {}
+#line 3 "F:\\svn\\clang\\test\\CodeGen\\Inputs\\debug-info-file-checksum.c"
+int foo(int x) {
+  return x+1;
+}
Index: test/CodeGen/Inputs/debug-info-file-checksum-line.cpp
===
--- test/CodeGen/Inputs/debug-info-file-checksum-line.cpp
+++ test/CodeGen/Inputs/debug-info-file-checksum-line.cpp
@@ -0,0 +1,9 @@
+int foo(int x) {
+  return x+1;
+}
+
+#line 100
+void test1() {}
+
+#line 200
+void test2() {}
Index: lib/CodeGen/CGDebugInfo.cpp
===
--- lib/CodeGen/CGDebugInfo.cpp
+++ lib/CodeGen/CGDebugInfo.cpp
@@ -422,8 +422,12 @@
   }
 
   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);
Index: lib/Basic/SourceManager.cpp
===
--- lib/Basic/SourceManager.cpp
+++ lib/Basic/SourceManager.cpp
@@ -1430,6 +1430,7 @@
   // 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 @@
 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 @@
 }
   }
 
-  return PresumedLoc(Filename.data(), LineNo, ColNo, IncludeLoc);
+  return 

[PATCH] D61914: [Support][Test] Time profiler: add regression test

2019-06-07 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea accepted this revision.
aganea added a comment.
This revision is now accepted and ready to land.

Thanks Anton!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61914



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


[PATCH] D60233: [clang-scan-deps] initial outline of the tool that runs preprocessor to find dependencies over a JSON compilation database

2019-06-07 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea added inline comments.



Comment at: clang/test/ClangScanDeps/Inputs/regular_cdb.json:4
+  "directory": "DIR",
+  "command": "clang -c DIR/regular_cdb.cpp -IInputs -MD -MF DIR/regular_cdb.d",
+  "file": "DIR/regular_cdb.cpp"

Is `-MD -MF` required for clang-scan-deps to work? Can't we append those 
arguments automatically, so that only include paths are needed in the CDB?

Would it possible for the tool to produce a collated file? A real-world usage 
would otherwise produce tens of thousands of files. Which then would be 
opened/parsed by the calling application.



Comment at: clang/test/ClangScanDeps/regular_cdb.cpp:8
+// RUN: sed -e "s|DIR|%/t.dir|g" %S/Inputs/regular_cdb.json > %t.cdb
+// RUN: clang-scan-deps -compilation-database %t.cdb -j 1
+// RUN: cat %t.dir/regular_cdb.d | FileCheck %s

Add a second test to excercice multi-threading? (by providing a few more files 
in the CDB)



Comment at: clang/tools/clang-scan-deps/ClangScanDeps.cpp:140
+int main(int argc, const char **argv) {
+  llvm::cl::ResetAllOptionOccurrences();
+  llvm::cl::HideUnrelatedOptions(DependencyScannerCategory);

`InitLLVM X(argc, argv);` is missing here to print callstacks in case of a 
crash, like the other tools.


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

https://reviews.llvm.org/D60233



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


[PATCH] D60233: [clang-scan-deps] initial outline of the tool that runs preprocessor to find dependencies over a JSON compilation database

2019-06-10 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea accepted this revision.
aganea added inline comments.
This revision is now accepted and ready to land.



Comment at: clang/test/ClangScanDeps/Inputs/regular_cdb.json:4
+  "directory": "DIR",
+  "command": "clang -c DIR/regular_cdb.cpp -IInputs -MD -MF DIR/regular_cdb.d",
+  "file": "DIR/regular_cdb.cpp"

arphaman wrote:
> aganea wrote:
> > Is `-MD -MF` required for clang-scan-deps to work? Can't we append those 
> > arguments automatically, so that only include paths are needed in the CDB?
> > 
> > Would it possible for the tool to produce a collated file? A real-world 
> > usage would otherwise produce tens of thousands of files. Which then would 
> > be opened/parsed by the calling application.
> I agree, the tool shouldn't rely on those options being there. `-MD -MF` in 
> this test right now a crutch to get the dependencies printed somewhere.
> 
> I think the tool by default should print out the collated dependencies to 
> STDOUT instead of writing them to files that were specified for the build. 
> The `-MD -MF` options will not be required as well. This implementation 
> requires some changes in the dependency collector, which I am planning to do 
> as part of clang-scan-deps in the follow-up patches. Will it be ok to keep 
> this patch as it is right now, and transition to printing out the collated 
> dependencies without requiring the options as a follow-up?
> 
> 
Sounds good! Please cc me on the upcoming reviews, we have a good use-case for 
clang-scan-deps in [[ http://www.fastbuild.org/docs/home.html | Fastbuild ]]!



Comment at: clang/tools/clang-scan-deps/CMakeLists.txt:3
+Core
+Support
+)

Two space indent.


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

https://reviews.llvm.org/D60233



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


[PATCH] D63290: Unify DependencyFileGenerator class and DependencyCollector interface

2019-06-17 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea added a reviewer: benlangmuir.
aganea added inline comments.



Comment at: clang/include/clang/Frontend/Utils.h:118
 
 /// Builds a depdenency file when attached to a Preprocessor (for includes) and
 /// ASTReader (for module imports), and writes it out at the end of processing

s/depdenency/dependency/



Comment at: clang/lib/Frontend/DependencyFile.cpp:78
   SrcMgr::CharacteristicKind FileType) override {
 if (!File)
   DepCollector.maybeAddDependency(FileName, /*FromModule*/false,

Given that `llvm::sys::path::remove_leading_dotslash` is not called here, but 
it is for the function above, could you end up with two entries in 
`DependencyCollector::Seen` when `DependencyCollector::sawDependency` is 
overriden?



Comment at: clang/lib/Frontend/DependencyFile.cpp:165
bool IsMissing) {
-  return !isSpecialFilename(Filename) &&
+  return !IsMissing && !isSpecialFilename(Filename) &&
  (needSystemDependencies() || !IsSystem);

Why `!IsMissing` wasn't considered before? Just wondering.


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

https://reviews.llvm.org/D63290



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


[PATCH] D63290: Unify DependencyFileGenerator class and DependencyCollector interface

2019-06-19 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea accepted this revision.
aganea added a comment.
This revision is now accepted and ready to land.

LGTM.


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

https://reviews.llvm.org/D63290



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


[PATCH] D63579: [clang-scan-deps] print the dependencies to stdout and remove the need to use -MD options in the CDB

2019-06-20 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea added inline comments.



Comment at: clang/tools/clang-scan-deps/ClangScanDeps.cpp:32
 
+class DependencyCollectorFactory {
+public:

Do you envision future uses for this factory?



Comment at: clang/tools/clang-scan-deps/ClangScanDeps.cpp:50
+std::unique_ptr Opts) override {
+  std::unique_lock LockGuard(SharedLock);
+  return std::make_shared(std::move(Opts), SharedLock,

Do you need the blocking behavior here? You're simply passing the Lock by 
reference, but not using the stream that it protects.



Comment at: clang/tools/clang-scan-deps/ClangScanDeps.cpp:73
+  std::unique_ptr Opts;
+  std::mutex 
+  raw_ostream 

I think it would be better to keep together the lock with what it protects 
(thus my question above about the factory).
What about:
```
class SharedStream {
public:
  SharedStream(raw_ostream ) : OS(OS) {}
  template  void applyLocked(Fn f) {
std::unique_lock LockGuard(Lock);
f(OS);
OS.flush();
  }

private:
  std::mutex Lock;
  raw_ostream 
};

/// Prints out all of the gathered dependencies into one output stream instead
/// of using the output dependency file.
class DependencyPrinter : public DependencyFileGenerator {
public:
  DependencyPrinter(std::unique_ptr Opts,
SharedStream )
  : DependencyFileGenerator(*Opts), Opts(std::move(Opts)), S(S) {}

  void finishedMainFile(DiagnosticsEngine ) override {
S.applyLocked([](raw_ostream ) { outputDependencyFile(OS); });
  }

private:
  std::unique_ptr Opts;
  SharedStream 
};
```
WDYT?



Comment at: clang/tools/clang-scan-deps/ClangScanDeps.cpp:115
+  Opts->Targets = {"clang-scan-deps dependency"};
+Compiler.addDependencyCollector(
+DepCollectorFactory.createDependencyCollector(std::move(Opts)));

..and in that case here we would say: 
`Compiler.addDependencyCollector(std::make_shared(DepOpts, 
SharedOS))`



Comment at: clang/tools/clang-scan-deps/ClangScanDeps.cpp:245
+  // Print out the dependency results to STDOUT by default.
+  DependencyPrinter::Factory DepPrintFactory(llvm::outs());
   unsigned NumWorkers =

...and then here: `SharedStream S(llvm::outs);`.


Repository:
  rC Clang

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

https://reviews.llvm.org/D63579



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


[PATCH] D63579: [clang-scan-deps] print the dependencies to stdout and remove the need to use -MD options in the CDB

2019-06-20 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea added inline comments.



Comment at: clang/tools/clang-scan-deps/ClangScanDeps.cpp:32
 
+class DependencyCollectorFactory {
+public:

arphaman wrote:
> aganea wrote:
> > Do you envision future uses for this factory?
> Most likely, yes.
> 
> I don't want to lock-in into creating the dependency printer in the 
> `PreprocessorOnlyTool`, as the eventual goal is to have it in a library, and 
> allow clients to consume modular dependencies not only using 
> `clang-scan-deps` tool itself, but using the C++ library directly 
> (potentially through a libclang C interface as well). The printer should be 
> in `clang-scan-deps` tool itself though, so it wouldn't be ideal to reference 
> it from `PreprocessorOnlyTool` now.
My initial question was, what are the future planned factories? (and thus the 
other `DependencyCollector` implementations?)

Do you think we could have the printer in the library as well?

On a related note - we're already testing `clang-scan-deps` compiled as a DLL. 
Our use-case right now is to call it from each of [[ 
https://github.com/fastbuild/fastbuild | Fastbuild ]]'s worker threads. We are 
using `main()` below almost as-is (except for the multithreading part which 
Fastbuild already does). The CDB JSON is passed by value from the Fastbuild 
thread, so it doesn't go through a file. I'd like to get back 
dependencies-as-a-string instead of `llvm::outs()`. The bottleneck currently 
is, as you can imagine, reading / writing files (seen in ETW traces), this 
patch should improve things a bit. I can send a sample of how we're using it 
after you commit.


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

https://reviews.llvm.org/D63579



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


[PATCH] D63579: [clang-scan-deps] print the dependencies to stdout and remove the need to use -MD options in the CDB

2019-06-21 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea accepted this revision.
aganea added a comment.
This revision is now accepted and ready to land.

LGTM! Thank you!


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

https://reviews.llvm.org/D63579



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


[PATCH] D63648: [Preprocessor] Honor absolute paths in diagnostics

2019-06-21 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea created this revision.
aganea added reviewers: hans, thakis, rsmith.
aganea added a project: clang.

Previously, `-fdiagnostics-absolute-paths` did not have an effect in some 
cases, for example: when using relative include paths, or relative CPP paths, 
or `--show-includes`, or `-E` or displaying notes. We have a peculiar use-case 
on our end with Fastbuild, where all this was exposed: CPP files are being are 
preprocessed on one PC, then compiled on another PC (which doesn't have the 
source-code); then the compiler's stdout is displayed on the first PC.


Repository:
  rC Clang

https://reviews.llvm.org/D63648

Files:
  include/clang/Frontend/TextDiagnostic.h
  lib/Frontend/HeaderIncludeGen.cpp
  lib/Frontend/PrintPreprocessedOutput.cpp
  lib/Frontend/TextDiagnostic.cpp
  test/Frontend/absolute-paths.c
  test/Modules/build-fail-notes.m
  test/Preprocessor/pp-modules.c

Index: test/Preprocessor/pp-modules.c
===
--- test/Preprocessor/pp-modules.c
+++ test/Preprocessor/pp-modules.c
@@ -13,3 +13,30 @@
 #include "pp-modules.h" // CHECK: # 1 "{{.*}}pp-modules.h" 1
 // CHECK: #pragma clang module import Module /* clang -E: implicit import for #include  */{{$}}
 // CHECK: # 14 "{{.*}}pp-modules.c" 2
+
+// Also test path canonicalization 
+// RUN: cd %S
+// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -x objective-c pp-modules.c -F %S/../Modules/Inputs -E -o - | FileCheck -check-prefix=CHECK-RELATIVE %s
+
+// CHECK-RELATIVE: # 1 "pp-modules.c"
+// CHECK-RELATIVE-NEXT: # 1 "" 1
+// CHECK-RELATIVE-NEXT: # 1 "" 3
+// CHECK-RELATIVE-NEXT: # {{[0-9]+}} "" 3
+// CHECK-RELATIVE-NEXT: # 1 "" 1
+// CHECK-RELATIVE-NEXT: # 1 "" 2
+// CHECK-RELATIVE-NEXT: # 1 "pp-modules.c" 2
+// CHECK-RELATIVE: # 1 "./pp-modules.h" 1
+// CHECK-RELATIVE: # 14 "pp-modules.c" 2
+
+// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -x objective-c pp-modules.c -F %S/../Modules/Inputs -E -o - -fdiagnostics-absolute-paths | FileCheck -check-prefix=CHECK-ABSOLUTE %s
+
+// CHECK-ABSOLUTE: # 1 "{{.+(/|)test(/|)Preprocessor(/|)}}pp-modules.c"
+// CHECK-ABSOLUTE-NEXT: # 1 "" 1
+// CHECK-ABSOLUTE-NEXT: # 1 "" 3
+// CHECK-ABSOLUTE-NEXT: # {{[0-9]+}} "" 3
+// CHECK-ABSOLUTE-NEXT: # 1 "" 1
+// CHECK-ABSOLUTE-NEXT: # 1 "" 2
+// CHECK-ABSOLUTE-NEXT: # 1 "{{.+(/|)test(/|)Preprocessor(/|)}}pp-modules.c" 2
+
+// CHECK-ABSOLUTE: # 1 "{{.+(/|)test(/|)Preprocessor(/|)}}pp-modules.h" 1
+// CHECK-ABSOLUTE: # 14 "{{.+(/|)test(/|)Preprocessor(/|)}}pp-modules.c" 2
Index: test/Modules/build-fail-notes.m
===
--- test/Modules/build-fail-notes.m
+++ test/Modules/build-fail-notes.m
@@ -29,3 +29,16 @@
 // CHECK-SDIAG: DependsOnModule.h:1:10: fatal: could not build module 'Module'
 // CHECK-SDIAG: build-fail-notes.m:4:9: note: while building module 'DependsOnModule' imported from
 
+// Also test path canonicalization 
+// RUN: cd %S
+// RUN: not %clang_cc1 -Wincomplete-umbrella -fmodules-cache-path=%t -fmodules -fimplicit-module-maps -F Inputs -DgetModuleVersion="epic fail" -serialize-diagnostic-file %t/tmp.diag build-fail-notes.m 2>&1 -fdiagnostics-show-note-include-stack | FileCheck -check-prefix=CHECK-RELATIVE %s
+// CHECK-RELATIVE: While building module 'DependsOnModule' imported from build-fail-notes.m:4:
+// CHECK-RELATIVE-NEXT: While building module 'Module' imported from Inputs{{/|\\}}DependsOnModule.framework{{/|\\}}Headers{{/|\\}}DependsOnModule.h:1:
+// CHECK-RELATIVE-NEXT: In file included from :1:
+// CHECK-RELATIVE-NEXT: Inputs{{/|\\}}Module.framework{{/|\\}}Headers{{/|\\}}Module.h:9:13: error: expected ';' after top level declarator
+
+// RUN: not %clang_cc1 -Wincomplete-umbrella -fmodules-cache-path=%t -fmodules -fimplicit-module-maps -F Inputs -DgetModuleVersion="epic fail" -serialize-diagnostic-file %t/tmp.diag build-fail-notes.m 2>&1 -fdiagnostics-show-note-include-stack -fdiagnostics-absolute-paths | FileCheck -check-prefix=CHECK-ABSOLUTE %s
+// CHECK-ABSOLUTE: While building module 'DependsOnModule' imported from {{.+(/|\\)test(/|\\)Modules(/|\\)}}build-fail-notes.m:4:
+// CHECK-ABSOLUTE-NEXT: While building module 'Module' imported from {{.+(/|\\)test(/|\\)Modules(/|\\)Inputs(/|\\)DependsOnModule.framework(/|\\)Headers(/|\\)}}DependsOnModule.h:1:
+// CHECK-ABSOLUTE-NEXT: In file included from {{.+(/|\\)test(/|\\)Modules(/|\\)}}:1:
+// CHECK-ABSOLUTE-NEXT: {{.+(/|\\)test(/|\\)Modules(/|\\)Inputs(/|\\)Module.framework(/|\\)Headers(/|\\)}}Module.h:9:13: error: expected ';' after top level declarator
Index: test/Frontend/absolute-paths.c
===
--- test/Frontend/absolute-paths.c
+++ test/Frontend/absolute-paths.c
@@ -15,3 +15,19 @@
 int g() {}
 // NORMAL: non-existant.c:123:10: warning: control reaches end of non-void function
 // ABSOLUTE: non-existant.c:123:10: 

[PATCH] D61496: Fixed tests where grep was not matching the linefeed

2019-05-10 Thread Alexandre Ganea via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC360467: Fixed tests where grep was not matching the linefeed 
(authored by aganea, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D61496?vs=197990=199069#toc

Repository:
  rC Clang

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

https://reviews.llvm.org/D61496

Files:
  test/Preprocessor/indent_macro.c
  test/Preprocessor/macro_fn_varargs_named.c
  test/Preprocessor/macro_not_define.c
  test/Preprocessor/macro_rparen_scan.c


Index: test/Preprocessor/macro_rparen_scan.c
===
--- test/Preprocessor/macro_rparen_scan.c
+++ test/Preprocessor/macro_rparen_scan.c
@@ -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 
Index: test/Preprocessor/macro_fn_varargs_named.c
===
--- test/Preprocessor/macro_fn_varargs_named.c
+++ test/Preprocessor/macro_fn_varargs_named.c
@@ -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)
Index: test/Preprocessor/macro_not_define.c
===
--- test/Preprocessor/macro_not_define.c
+++ test/Preprocessor/macro_not_define.c
@@ -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 
Index: test/Preprocessor/indent_macro.c
===
--- test/Preprocessor/indent_macro.c
+++ test/Preprocessor/indent_macro.c
@@ -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


Index: test/Preprocessor/macro_rparen_scan.c
===
--- test/Preprocessor/macro_rparen_scan.c
+++ test/Preprocessor/macro_rparen_scan.c
@@ -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 
Index: test/Preprocessor/macro_fn_varargs_named.c
===
--- test/Preprocessor/macro_fn_varargs_named.c
+++ test/Preprocessor/macro_fn_varargs_named.c
@@ -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)
Index: test/Preprocessor/macro_not_define.c
===
--- test/Preprocessor/macro_not_define.c
+++ test/Preprocessor/macro_not_define.c
@@ -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 
Index: test/Preprocessor/indent_macro.c
===
--- test/Preprocessor/indent_macro.c
+++ test/Preprocessor/indent_macro.c
@@ -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
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D61914: [Support][Test] Time profiler: add regression test

2019-05-22 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea added a comment.

Could you please move the test to a more approriate location? (ie. 
clang/trunk/test/Driver/)




Comment at: clang/tools/driver/cc1_main.cpp:245
+
+llvm::errs() << "Time trace json-file dumped to " << Path.str() << "\n";
+llvm::errs()

This seems a bit too chatty. Suround these two lines with `if 
(Config->Verbose)` ?



Comment at: llvm/test/Support/check-time-trace.cxx:4
+
+// CHECK: "args":{"name":"clang"}
+

I don't see any other `-ftime-trace` tests, I would add a few more exhaustive 
file format checks here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61914



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


[PATCH] D60283: [DebugInfo] Don't emit checksums when compiling a preprocessed CPP

2019-05-20 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea added a comment.

Ping! Any further comments?


Repository:
  rC Clang

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

https://reviews.llvm.org/D60283



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


[PATCH] D60283: [DebugInfo] Don't emit checksums when compiling a preprocessed CPP

2019-05-21 Thread Alexandre Ganea via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC361296: [DebugInfo] Dont emit checksums when compiling 
a preprocessed CPP (authored by aganea, committed by ).

Repository:
  rC Clang

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

https://reviews.llvm.org/D60283

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

Index: include/clang/Basic/SourceLocation.h
===
--- include/clang/Basic/SourceLocation.h
+++ include/clang/Basic/SourceLocation.h
@@ -282,13 +282,15 @@
 /// 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 @@
 return Filename;
   }
 
+  FileID getFileID() const {
+assert(isValid());
+return ID;
+  }
+
   /// Return the presumed line number of this location.
   ///
   /// This can be affected by \#line etc.
Index: test/CodeGen/debug-info-file-checksum.c
===
--- test/CodeGen/debug-info-file-checksum.c
+++ test/CodeGen/debug-info-file-checksum.c
@@ -4,3 +4,15 @@
 // Check that "checksum" is created correctly for the compiled file.
 
 // CHECK: !DIFile(filename:{{.*}}, directory:{{.*}}, checksumkind: CSK_MD5, checksum: "a3b7d27af071accdeccaa933fc603608")
+
+// Ensure #line directives (in already pre-processed files) do not emit checksums
+// RUN: %clang -emit-llvm -S -g -gcodeview -x c %S/Inputs/debug-info-file-checksum-pre.cpp -o - | FileCheck %s --check-prefix NOCHECKSUM
+
+// NOCHECKSUM: !DIFile(filename: "{{.*}}code-coverage-filter1.h", directory: "{{[^"]*}}")
+// NOCHECKSUM: !DIFile(filename: "{{.*}}code-coverage-filter2.h", directory: "{{[^"]*}}")
+// NOCHECKSUM: !DIFile(filename: "{{.*}}debug-info-file-checksum.c", directory: "{{[^"]*}}")
+
+// Ensure #line directives without name do emit checksums
+// RUN: %clang -emit-llvm -S -g -gcodeview -x c %S/Inputs/debug-info-file-checksum-line.cpp -o - | FileCheck %s --check-prefix CHECKSUM
+
+// CHECKSUM: !DIFile(filename: "{{.*}}debug-info-file-checksum-line.cpp", directory:{{.*}}, checksumkind: CSK_MD5, checksum: "7b568574d0e3c56c28e5e0234d1f4a06")
Index: test/CodeGen/Inputs/debug-info-file-checksum-line.cpp
===
--- test/CodeGen/Inputs/debug-info-file-checksum-line.cpp
+++ test/CodeGen/Inputs/debug-info-file-checksum-line.cpp
@@ -0,0 +1,9 @@
+int foo(int x) {
+  return x+1;
+}
+
+#line 100
+void test1() {}
+
+#line 200
+void test2() {}
Index: test/CodeGen/Inputs/debug-info-file-checksum-pre.cpp
===
--- test/CodeGen/Inputs/debug-info-file-checksum-pre.cpp
+++ test/CodeGen/Inputs/debug-info-file-checksum-pre.cpp
@@ -0,0 +1,10 @@
+#line 1 "F:\\svn\\clang\\test\\CodeGen\\Inputs\\debug-info-file-checksum.c"
+#line 1 "f:\\svn\\clang\\test\\codegen\\inputs\\code-coverage-filter1.h"
+void test1() {}
+#line 2 "F:\\svn\\clang\\test\\CodeGen\\Inputs\\debug-info-file-checksum.c"
+#line 1 "f:\\svn\\clang\\test\\codegen\\inputs\\code-coverage-filter2.h"
+void test2() {}
+#line 3 "F:\\svn\\clang\\test\\CodeGen\\Inputs\\debug-info-file-checksum.c"
+int foo(int x) {
+  return x+1;
+}
Index: lib/Basic/SourceManager.cpp
===
--- lib/Basic/SourceManager.cpp
+++ lib/Basic/SourceManager.cpp
@@ -1430,6 +1430,7 @@
   // 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 @@
 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 

[PATCH] D61945: ftime-trace as a CoreOption

2019-05-16 Thread Alexandre Ganea via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL360907: ftime-trace as a CoreOption (authored by aganea, 
committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D61945?vs=199604=199836#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D61945

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


Index: cfe/trunk/include/clang/Driver/Options.td
===
--- cfe/trunk/include/clang/Driver/Options.td
+++ cfe/trunk/include/clang/Driver/Options.td
@@ -1747,7 +1747,7 @@
 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">;
Index: cfe/trunk/test/Driver/cl-options.c
===
--- cfe/trunk/test/Driver/cl-options.c
+++ cfe/trunk/test/Driver/cl-options.c
@@ -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
 


Index: cfe/trunk/include/clang/Driver/Options.td
===
--- cfe/trunk/include/clang/Driver/Options.td
+++ cfe/trunk/include/clang/Driver/Options.td
@@ -1747,7 +1747,7 @@
 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">;
Index: cfe/trunk/test/Driver/cl-options.c
===
--- cfe/trunk/test/Driver/cl-options.c
+++ cfe/trunk/test/Driver/cl-options.c
@@ -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


[PATCH] D60283: [DebugInfo] Don't emit checksums when compiling a preprocessed CPP

2019-05-15 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea updated this revision to Diff 199599.
aganea marked an inline comment as done.
aganea added a comment.

Updated again with a different solution. We can't just act on 
`Entry.getFile().hasLineDirectives()` because a directive such as `#line 100` 
simply overrides the `__LINE__`, not `__FILE__` (we need to retain and hash the 
previous `__FILE__` in that case). Please see an example here 

 in the IBM documentation.
Also we can't compare by `FileID` because a `LineEntry` simply stores a string 
(called filename) but the buffer for that file isn't stored in the 
SourceManager.


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

https://reviews.llvm.org/D60283

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

Index: test/CodeGen/debug-info-file-checksum.c
===
--- test/CodeGen/debug-info-file-checksum.c
+++ test/CodeGen/debug-info-file-checksum.c
@@ -4,3 +4,15 @@
 // Check that "checksum" is created correctly for the compiled file.
 
 // CHECK: !DIFile(filename:{{.*}}, directory:{{.*}}, checksumkind: CSK_MD5, checksum: "a3b7d27af071accdeccaa933fc603608")
+
+// Ensure #line directives (in already pre-processed files) do not emit checksums
+// RUN: %clang -emit-llvm -S -g -gcodeview -x c %S/Inputs/debug-info-file-checksum-pre.cpp -o - | FileCheck %s --check-prefix NOCHECKSUM
+
+// NOCHECKSUM-LABEL: !DIFile(filename: "{{.*}}code-coverage-filter1.h", directory: "{{[^"]*}}")
+// NOCHECKSUM-LABEL: !DIFile(filename: "{{.*}}code-coverage-filter2.h", directory: "{{[^"]*}}")
+// NOCHECKSUM-LABEL: !DIFile(filename: "{{.*}}debug-info-file-checksum.c", directory: "{{[^"]*}}")
+
+// Ensure #line directives without name do emit checksums
+// RUN: %clang -emit-llvm -S -g -gcodeview -x c %S/Inputs/debug-info-file-checksum-line.cpp -o - | FileCheck %s --check-prefix CHECKSUM
+
+// CHECKSUM: !DIFile(filename: "{{.*}}debug-info-file-checksum-line.cpp", directory:{{.*}}, checksumkind: CSK_MD5, checksum: "7b568574d0e3c56c28e5e0234d1f4a06")
Index: test/CodeGen/Inputs/debug-info-file-checksum-pre.cpp
===
--- test/CodeGen/Inputs/debug-info-file-checksum-pre.cpp
+++ test/CodeGen/Inputs/debug-info-file-checksum-pre.cpp
@@ -0,0 +1,10 @@
+#line 1 "F:\\svn\\clang\\test\\CodeGen\\Inputs\\debug-info-file-checksum.c"
+#line 1 "f:\\svn\\clang\\test\\codegen\\inputs\\code-coverage-filter1.h"
+void test1() {}
+#line 2 "F:\\svn\\clang\\test\\CodeGen\\Inputs\\debug-info-file-checksum.c"
+#line 1 "f:\\svn\\clang\\test\\codegen\\inputs\\code-coverage-filter2.h"
+void test2() {}
+#line 3 "F:\\svn\\clang\\test\\CodeGen\\Inputs\\debug-info-file-checksum.c"
+int foo(int x) {
+  return x+1;
+}
Index: test/CodeGen/Inputs/debug-info-file-checksum-line.cpp
===
--- test/CodeGen/Inputs/debug-info-file-checksum-line.cpp
+++ test/CodeGen/Inputs/debug-info-file-checksum-line.cpp
@@ -0,0 +1,10 @@
+int foo(int x) {
+  vprintf("test %d", x);
+  return x+1;
+}
+
+#line 100
+void test1() {}
+
+#line 200
+void test2() {}
Index: lib/CodeGen/CGDebugInfo.cpp
===
--- lib/CodeGen/CGDebugInfo.cpp
+++ lib/CodeGen/CGDebugInfo.cpp
@@ -422,8 +422,13 @@
   }
 
   SmallString<32> Checksum;
+
+  // Don't compute checksums if the location is affected by a #line directive
+  // that refers to a file. We would otherwise end up with the same checksum for
+  // all the files referred by #line. Instead the checksum remains empty,
+  // leaving to the debugger to open the file without checksum validation.
   Optional CSKind =
-  computeChecksum(SM.getFileID(Loc), Checksum);
+  computeChecksum(PLoc.getFileID(), Checksum);
   Optional> CSInfo;
   if (CSKind)
 CSInfo.emplace(*CSKind, Checksum);
Index: lib/Basic/SourceManager.cpp
===
--- lib/Basic/SourceManager.cpp
+++ lib/Basic/SourceManager.cpp
@@ -1430,6 +1430,7 @@
   // 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,11 @@
 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);
+FID = FileID::get(0); 

[PATCH] D61945: ftime-trace as a CoreOption

2019-05-15 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea created this revision.
aganea added reviewers: thakis, anton-afanasyev.
aganea added a project: clang.

As suggested here  by @thakis , make 
so that `-ftime-trace` can be used directly in clang-cl without `-Xclang`


Repository:
  rC Clang

https://reviews.llvm.org/D61945

Files:
  include/clang/Driver/Options.td
  test/Driver/cl-options.c


Index: test/Driver/cl-options.c
===
--- test/Driver/cl-options.c
+++ test/Driver/cl-options.c
@@ -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
 
Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -1747,7 +1747,7 @@
 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">;


Index: test/Driver/cl-options.c
===
--- test/Driver/cl-options.c
+++ test/Driver/cl-options.c
@@ -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
 
Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -1747,7 +1747,7 @@
 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">;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D61046: Fix compilation warnings when compiling with GCC 7.3

2019-05-01 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea added a comment.

Ping! Is this good to go?


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

https://reviews.llvm.org/D61046



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


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

2019-05-01 Thread Alexandre Ganea via Phabricator via cfe-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



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


[PATCH] D61046: Fix compilation warnings when compiling with GCC 7.3

2019-05-06 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea marked an inline comment as done.
aganea added a comment.

In D61046#1486850 , @rnk wrote:

> The only remaining change I find questionable is the R600 backend change


creduce'd and reported here: 
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63477#c4 - it is still present 
with GCC 9.1


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

https://reviews.llvm.org/D61046



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


[PATCH] D61046: Fix compilation warnings when compiling with GCC 7.3

2019-05-06 Thread Alexandre Ganea via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL360044: Fix compilation warnings when compiling with GCC 7.3 
(authored by aganea, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D61046?vs=196655=198265#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D61046

Files:
  llvm/trunk/lib/Target/AMDGPU/R600ISelLowering.cpp
  llvm/trunk/unittests/IR/ConstantRangeTest.cpp
  llvm/trunk/unittests/Support/TypeTraitsTest.cpp
  llvm/trunk/unittests/Transforms/Scalar/CMakeLists.txt
  llvm/trunk/unittests/Transforms/Scalar/LoopPassManagerTest.cpp

Index: llvm/trunk/lib/Target/AMDGPU/R600ISelLowering.cpp
===
--- llvm/trunk/lib/Target/AMDGPU/R600ISelLowering.cpp
+++ llvm/trunk/lib/Target/AMDGPU/R600ISelLowering.cpp
@@ -1714,6 +1714,12 @@
 
 if (NewBldVec[i].isUndef())
   continue;
+// Fix spurious warning with gcc 7.3 -O3
+//warning: array subscript is above array bounds [-Warray-bounds]
+//if (NewBldVec[i] == NewBldVec[j]) {
+//~~~^
+if (i >= 4)
+  continue;
 for (unsigned j = 0; j < i; j++) {
   if (NewBldVec[i] == NewBldVec[j]) {
 NewBldVec[i] = DAG.getUNDEF(NewBldVec[i].getValueType());
Index: llvm/trunk/unittests/Transforms/Scalar/CMakeLists.txt
===
--- llvm/trunk/unittests/Transforms/Scalar/CMakeLists.txt
+++ llvm/trunk/unittests/Transforms/Scalar/CMakeLists.txt
@@ -10,3 +10,8 @@
 add_llvm_unittest(ScalarTests
   LoopPassManagerTest.cpp
   )
+
+# Workaround for the gcc 6.1 bug https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80916.
+if (CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 6.0 AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 9.0)
+  set_source_files_properties(LoopPassManagerTest.cpp PROPERTIES COMPILE_FLAGS -Wno-unused-function)
+endif()
Index: llvm/trunk/unittests/Transforms/Scalar/LoopPassManagerTest.cpp
===
--- llvm/trunk/unittests/Transforms/Scalar/LoopPassManagerTest.cpp
+++ llvm/trunk/unittests/Transforms/Scalar/LoopPassManagerTest.cpp
@@ -20,19 +20,9 @@
 #include "llvm/IR/PassManager.h"
 #include "llvm/Support/SourceMgr.h"
 
-// Workaround for the gcc 6.1 bug PR80916.
-#if defined(__GNUC__) && __GNUC__ > 5
-#  pragma GCC diagnostic push
-#  pragma GCC diagnostic ignored "-Wunused-function"
-#endif
-
 #include "gmock/gmock.h"
 #include "gtest/gtest.h"
 
-#if defined(__GNUC__) && __GNUC__ > 5
-#  pragma GCC diagnostic pop
-#endif
-
 using namespace llvm;
 
 namespace {
Index: llvm/trunk/unittests/Support/TypeTraitsTest.cpp
===
--- llvm/trunk/unittests/Support/TypeTraitsTest.cpp
+++ llvm/trunk/unittests/Support/TypeTraitsTest.cpp
@@ -7,6 +7,7 @@
 //===--===//
 
 #include "llvm/Support/type_traits.h"
+#include "gtest/gtest.h"
 
 namespace {
 
@@ -71,6 +72,26 @@
 template void TrivialityTester();
 template void TrivialityTester();
 
+TEST(Triviality, Tester) {
+  TrivialityTester();
+  TrivialityTester();
+  TrivialityTester();
+  TrivialityTester();
+
+  TrivialityTester();
+  TrivialityTester();
+  TrivialityTester();
+  TrivialityTester();
+  TrivialityTester();
+
+  TrivialityTester();
+  TrivialityTester();
+  TrivialityTester();
+  TrivialityTester();
+  TrivialityTester();
+  TrivialityTester();
+}
+
 } // namespace triviality
 
 } // end anonymous namespace
Index: llvm/trunk/unittests/IR/ConstantRangeTest.cpp
===
--- llvm/trunk/unittests/IR/ConstantRangeTest.cpp
+++ llvm/trunk/unittests/IR/ConstantRangeTest.cpp
@@ -459,6 +459,7 @@
   }
 }
 
+(void)HaveInterrupt3;
 assert(!HaveInterrupt3 && "Should have at most three ranges");
 
 ConstantRange SmallestCR = OpFn(CR1, CR2, ConstantRange::Smallest);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D61496: Fixed tests where grep was not matching the linefeed

2019-05-06 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea marked an inline comment as done.
aganea added inline comments.



Comment at: clang/trunk/test/Preprocessor/indent_macro.c:1-2
-// RUN: %clang_cc1 -E %s | grep '^   zzap$'
+// RUN: %clang_cc1 -E %s | FileCheck %s --match-full-lines --strict-whitespace
+// CHECK:   zzap
 

lebedev.ri wrote:
> Separate with newline
What do you mean? Between RUN and CHECK? There's already a newline a L3.


Repository:
  rC Clang

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

https://reviews.llvm.org/D61496



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


[PATCH] D61496: Fixed tests where grep was not matching the linefeed

2019-05-03 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea added a comment.

In D61496#1489523 , @probinson wrote:

> Checked-in files should not have CRLF endings, in general (there are a very 
> few exceptions, and these aren't among them).
>  If the checked-in files have LF endings but your tool checks them out with 
> CRLF then that is a problem with your config, or with the tool.
>  Adding dos2unix to the RUN lines is the wrong fix, either way.


Yeah I've realized that :) This is caused by svn on Windows which sets 
`svn:eol-style=native` by default, which causes local files to be saved in the 
"native" format, which is CRLF on Windows (even though in upstream they are LF) 
When files are commited, normally svn should convert them back to LF (or at 
least that's the contract 
 
for `svn:eol-style=native`).

  native
  This causes the file to contain the EOL markers that are native to the 
operating system on which Subversion was run. In other words, if a user on a 
Windows machine checks out a working copy that contains a file with an 
svn:eol-style property set to native, that file will contain CRLF EOL markers. 
A Unix user checking out a working copy that contains the same file will see LF 
EOL markers in his copy of the file.
  
  Note that Subversion will actually store the file in the repository using 
normalized LF EOL markers regardless of the operating system. This is basically 
transparent to the user, though.

I'm using the MINGW32 bash to run the tests/`check-all` because it comes with 
all the Unix tools (grep, sed, ...) that Windows doesn't have.
The bug here is that the GNU grep only matches LF, not CRLF.


Repository:
  rC Clang

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

https://reviews.llvm.org/D61496



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


[PATCH] D61496: Fixed tests where grep was not matching the linefeed

2019-05-03 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea updated this revision to Diff 197990.
aganea added a comment.

Changed to use `FileCheck` instead of `grep`


Repository:
  rC Clang

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

https://reviews.llvm.org/D61496

Files:
  clang/trunk/test/Preprocessor/indent_macro.c
  clang/trunk/test/Preprocessor/macro_fn_varargs_named.c
  clang/trunk/test/Preprocessor/macro_not_define.c
  clang/trunk/test/Preprocessor/macro_rparen_scan.c


Index: clang/trunk/test/Preprocessor/macro_rparen_scan.c
===
--- clang/trunk/test/Preprocessor/macro_rparen_scan.c
+++ clang/trunk/test/Preprocessor/macro_rparen_scan.c
@@ -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 
Index: clang/trunk/test/Preprocessor/macro_not_define.c
===
--- clang/trunk/test/Preprocessor/macro_not_define.c
+++ clang/trunk/test/Preprocessor/macro_not_define.c
@@ -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 
Index: clang/trunk/test/Preprocessor/macro_fn_varargs_named.c
===
--- clang/trunk/test/Preprocessor/macro_fn_varargs_named.c
+++ clang/trunk/test/Preprocessor/macro_fn_varargs_named.c
@@ -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 1
+// 1:a: x
+// RUN: %clang_cc1 -E %s | FileCheck %s --match-full-lines --strict-whitespace 
--check-prefix 2
+// 2:b: x y, z,h
+// RUN: %clang_cc1 -E %s | FileCheck %s --match-full-lines --strict-whitespace 
--check-prefix 3
+// 3:c: foo(x)
 
 #define A(b, c...) b c
 a: A(x)
Index: clang/trunk/test/Preprocessor/indent_macro.c
===
--- clang/trunk/test/Preprocessor/indent_macro.c
+++ clang/trunk/test/Preprocessor/indent_macro.c
@@ -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


Index: clang/trunk/test/Preprocessor/macro_rparen_scan.c
===
--- clang/trunk/test/Preprocessor/macro_rparen_scan.c
+++ clang/trunk/test/Preprocessor/macro_rparen_scan.c
@@ -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 
Index: clang/trunk/test/Preprocessor/macro_not_define.c
===
--- clang/trunk/test/Preprocessor/macro_not_define.c
+++ clang/trunk/test/Preprocessor/macro_not_define.c
@@ -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 
Index: clang/trunk/test/Preprocessor/macro_fn_varargs_named.c
===
--- clang/trunk/test/Preprocessor/macro_fn_varargs_named.c
+++ clang/trunk/test/Preprocessor/macro_fn_varargs_named.c
@@ -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 1
+// 1:a: x
+// RUN: %clang_cc1 -E %s | FileCheck %s --match-full-lines --strict-whitespace --check-prefix 2
+// 2:b: x y, z,h
+// RUN: %clang_cc1 -E %s | FileCheck %s --match-full-lines --strict-whitespace --check-prefix 3
+// 3:c: foo(x)
 
 #define A(b, c...) b c
 a: A(x)
Index: clang/trunk/test/Preprocessor/indent_macro.c
===
--- clang/trunk/test/Preprocessor/indent_macro.c
+++ clang/trunk/test/Preprocessor/indent_macro.c
@@ -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
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D61496: Fixed tests where grep was not matching the linefeed

2019-05-03 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea created this revision.
aganea added reviewers: rnk, jlebar.
aganea added a project: clang.
Herald added a subscriber: mstorsjo.
aganea edited the summary of this revision.

The files below have been synced by Tortoise as CRLF, and it looks like they 
are like that in the depot as well (I'm still using the SVN setup)
Strangely `svn diff` shows them as LF.
The issue is that `grep 'something$'` doesn't match the newline inside the 
MINGW32 bash (mintty).


Repository:
  rC Clang

https://reviews.llvm.org/D61496

Files:
  clang/trunk/test/Preprocessor/indent_macro.c
  clang/trunk/test/Preprocessor/macro_fn_varargs_named.c
  clang/trunk/test/Preprocessor/macro_not_define.c
  clang/trunk/test/Preprocessor/macro_rparen_scan.c


Index: clang/trunk/test/Preprocessor/macro_rparen_scan.c
===
--- clang/trunk/test/Preprocessor/macro_rparen_scan.c
+++ clang/trunk/test/Preprocessor/macro_rparen_scan.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -E %s | grep '^3 ;$'
+// RUN: %clang_cc1 -E %s | dos2unix | grep '^3 ;$'
 
 /* Right paren scanning, hard case.  Should expand to 3. */
 #define i(x) 3 
Index: clang/trunk/test/Preprocessor/macro_not_define.c
===
--- clang/trunk/test/Preprocessor/macro_not_define.c
+++ clang/trunk/test/Preprocessor/macro_not_define.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -E %s | grep '^ # define X 3$'
+// RUN: %clang_cc1 -E %s | dos2unix | grep '^ # define X 3$'
 
 #define H # 
  #define D define 
Index: clang/trunk/test/Preprocessor/macro_fn_varargs_named.c
===
--- clang/trunk/test/Preprocessor/macro_fn_varargs_named.c
+++ clang/trunk/test/Preprocessor/macro_fn_varargs_named.c
@@ -1,6 +1,6 @@
-// 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 | dos2unix | grep '^a: x$'
+// RUN: %clang_cc1 -E %s | dos2unix | grep '^b: x y, z,h$'
+// RUN: %clang_cc1 -E %s | dos2unix | grep '^c: foo(x)$'
 
 #define A(b, c...) b c
 a: A(x)
Index: clang/trunk/test/Preprocessor/indent_macro.c
===
--- clang/trunk/test/Preprocessor/indent_macro.c
+++ clang/trunk/test/Preprocessor/indent_macro.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -E %s | grep '^   zzap$'
+// RUN: %clang_cc1 -E %s | dos2unix | grep '^   zzap$'
 
 // zzap is on a new line, should be indented.
 #define BLAH  zzap


Index: clang/trunk/test/Preprocessor/macro_rparen_scan.c
===
--- clang/trunk/test/Preprocessor/macro_rparen_scan.c
+++ clang/trunk/test/Preprocessor/macro_rparen_scan.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -E %s | grep '^3 ;$'
+// RUN: %clang_cc1 -E %s | dos2unix | grep '^3 ;$'
 
 /* Right paren scanning, hard case.  Should expand to 3. */
 #define i(x) 3 
Index: clang/trunk/test/Preprocessor/macro_not_define.c
===
--- clang/trunk/test/Preprocessor/macro_not_define.c
+++ clang/trunk/test/Preprocessor/macro_not_define.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -E %s | grep '^ # define X 3$'
+// RUN: %clang_cc1 -E %s | dos2unix | grep '^ # define X 3$'
 
 #define H # 
  #define D define 
Index: clang/trunk/test/Preprocessor/macro_fn_varargs_named.c
===
--- clang/trunk/test/Preprocessor/macro_fn_varargs_named.c
+++ clang/trunk/test/Preprocessor/macro_fn_varargs_named.c
@@ -1,6 +1,6 @@
-// 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 | dos2unix | grep '^a: x$'
+// RUN: %clang_cc1 -E %s | dos2unix | grep '^b: x y, z,h$'
+// RUN: %clang_cc1 -E %s | dos2unix | grep '^c: foo(x)$'
 
 #define A(b, c...) b c
 a: A(x)
Index: clang/trunk/test/Preprocessor/indent_macro.c
===
--- clang/trunk/test/Preprocessor/indent_macro.c
+++ clang/trunk/test/Preprocessor/indent_macro.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -E %s | grep '^   zzap$'
+// RUN: %clang_cc1 -E %s | dos2unix | grep '^   zzap$'
 
 // zzap is on a new line, should be indented.
 #define BLAH  zzap
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D63681: [clang-scan-deps] Introduce the DependencyScanning library with the thread worker code and better error handling

2019-06-26 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea added a subscriber: rnk.
aganea added a comment.

A bit more detail on what we're seeing on our end (specs in the post above). 
The 'Count' column represents the number of 1ms samples taken in that function. 
The 'Weight' column is cumulated times for all cores, for a given process, in 
ms.

Image below shows most of the time is spent in `clang-scan-deps.dll` and 
indirectly, in `ntoskrnl.exe`. The graph at the bottom also shows that 
preprocessing the ~600 unity .CPP files in the project issues 16 million IOPS. 
The graphs on the right show no bottlenecks on the disk I/O on the OS I/O-side.

F9417850: clang-scan-deps.jpg 

Top functions in `ntoskrnl.exe`, most callstacks end up in 
`clang-scan-deps.dll`:

F9417863: clang-scan-deps2.jpg 

A good chunk of all this is caused by `llvm::sys::status()`, even though is 
goes through the `FileSystemStatCache`, like I was suggesting previously 
 (ping @rnk)
//(beware, the callstacks are reversed in the image below)//

F9417870: clang-status.JPG 

I can take a look at `llvm::sys::status()` after the vacations (somewhere in 
August)


Repository:
  rC Clang

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

https://reviews.llvm.org/D63681



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


[PATCH] D61046: Fix compilation warnings when compiling with GCC 7.3

2019-04-24 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea marked 3 inline comments as done.
aganea added inline comments.



Comment at: clang/trunk/unittests/AST/ASTImporterTest.cpp:4054
+}
   }
 

rnk wrote:
> nikic wrote:
> > shafik wrote:
> > > aganea wrote:
> > > > Fixes
> > > > ```
> > > > [2097/2979] Building CXX object 
> > > > tools/clang/unittests/Tooling/CMakeFiles/ToolingTests.dir/LookupTest.cpp.o
> > > > /mnt/f/svn/clang/unittests/Tooling/LookupTest.cpp: In lambda function:
> > > > /mnt/f/svn/clang/unittests/Tooling/LookupTest.cpp:220:8: warning: 
> > > > suggest explicit braces to avoid ambiguous ‘else’ [-Wdangling-else]
> > > >  if (Type.getDecl()->getQualifiedNameAsString() == "x::y::Old")
> > > > ^
> > > > ```
> > > You mixed up the error messages but I see what is going on.
> > > 
> > > So you may want to add a comment since it is not apparent that what is 
> > > going on is due the `EXPECT_TRUE` macro eventually expanding to an 
> > > `if..else` which is what is triggering the warning. Since someone may 
> > > come by in the future and just remove the braces since it is not apparent 
> > > why they are there.
> > > 
> > > Same below as well.
> > EXPECT_* inside if is quite common, I don't think we should add a comment 
> > every time it is used.
> This is a longstanding issue. gtest even includes this beautiful snippet of 
> code:
> 
> ```
> // The GNU compiler emits a warning if nested "if" statements are followed by
> // an "else" statement and braces are not used to explicitly disambiguate the
> // "else" binding.  This leads to problems with code like:
> //
> //   if (gate)
> // ASSERT_*(condition) << "Some message";
> //
> // The "switch (0) case 0:" idiom is used to suppress this.
> #ifdef __INTEL_COMPILER
> # define GTEST_AMBIGUOUS_ELSE_BLOCKER_
> #else
> # define GTEST_AMBIGUOUS_ELSE_BLOCKER_ switch (0) case 0: default:  // NOLINT
> #endif
> ```
> https://github.com/llvm/llvm-project/blob/a974b33a10745b528c34f0accbd230b0a4e1fb87/llvm/utils/unittest/googletest/include/gtest/internal/gtest-port.h#L834
> 
> The expansion looks something like this:
> ```
> if (user_cond)
>   switch (0) case 0: default:
> if (const TestResult res = ...);
> else fail(res, ...) << "User streaming can follow"
> ```
> 
> It seems new versions of GCC have gotten "smarter" and this pattern no longer 
> suppresses the warning as desired. It might be worth disabling 
> -Wdangling-else for GCC at this point, since this will be an ongoing problem 
> because LLVM typically elides braces when possible.
> 
> Oh, we even reported it back in 2017:
> https://github.com/google/googletest/issues/1119
> ... and it was closed as inactive. Woohoo. :(
So revert those braces and disable -Wdangling-else if CMAKE_COMPILER_IS_GNUCXX 
? (somewhere in HandleLLVMOptions.cmake)



Comment at: llvm/trunk/unittests/Transforms/Scalar/CMakeLists.txt:14-17
+# Workaround for the gcc 6.1 bug 
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80916.
+if (CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 
6.0)
+  set_source_files_properties(LoopPassManagerTest.cpp PROPERTIES COMPILE_FLAGS 
-Wno-unused-function)
+endif()

tstellar wrote:
> aganea wrote:
> > tstellar wrote:
> > > Same thing here too.
> > Not sure I understand, there're plenty of compiler-specific examples in the 
> > .cmake files. Is there an alternate way to fix this?
> I know there are some, but I don't think a warning like this is important 
> enough to fix with a compiler specific work-around.
You mean more like
```
# Workaround for the gcc 6.1 bug 
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80916.
if (NOT MSVC)
  set_source_files_properties(LoopPassManagerTest.cpp PROPERTIES COMPILE_FLAGS 
-Wno-unused-function)
endif()
```
Or leave the warning? There's already an #ifdef below in 
LoopPassManagerTest.cpp but it's not at the right place, this simply corrects 
it.


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

https://reviews.llvm.org/D61046



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


[PATCH] D61046: Fix compilation warnings when compiling with GCC 7.3

2019-04-24 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea updated this revision to Diff 196505.
aganea marked 7 inline comments as done.
aganea added a comment.

Adressed some of the comments.


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

https://reviews.llvm.org/D61046

Files:
  clang/trunk/unittests/AST/ASTImporterTest.cpp
  clang/trunk/unittests/Tooling/LookupTest.cpp
  llvm/trunk/lib/Target/AMDGPU/R600ISelLowering.cpp
  llvm/trunk/unittests/IR/ConstantRangeTest.cpp
  llvm/trunk/unittests/Support/TypeTraitsTest.cpp
  llvm/trunk/unittests/Transforms/Scalar/CMakeLists.txt
  llvm/trunk/unittests/Transforms/Scalar/LoopPassManagerTest.cpp

Index: llvm/trunk/unittests/Transforms/Scalar/LoopPassManagerTest.cpp
===
--- llvm/trunk/unittests/Transforms/Scalar/LoopPassManagerTest.cpp
+++ llvm/trunk/unittests/Transforms/Scalar/LoopPassManagerTest.cpp
@@ -20,19 +20,9 @@
 #include "llvm/IR/PassManager.h"
 #include "llvm/Support/SourceMgr.h"
 
-// Workaround for the gcc 6.1 bug PR80916.
-#if defined(__GNUC__) && __GNUC__ > 5
-#  pragma GCC diagnostic push
-#  pragma GCC diagnostic ignored "-Wunused-function"
-#endif
-
 #include "gmock/gmock.h"
 #include "gtest/gtest.h"
 
-#if defined(__GNUC__) && __GNUC__ > 5
-#  pragma GCC diagnostic pop
-#endif
-
 using namespace llvm;
 
 namespace {
Index: llvm/trunk/unittests/Transforms/Scalar/CMakeLists.txt
===
--- llvm/trunk/unittests/Transforms/Scalar/CMakeLists.txt
+++ llvm/trunk/unittests/Transforms/Scalar/CMakeLists.txt
@@ -10,3 +10,8 @@
 add_llvm_unittest(ScalarTests
   LoopPassManagerTest.cpp
   )
+
+# Workaround for the gcc 6.1 bug https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80916.
+if (CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 6.0)
+  set_source_files_properties(LoopPassManagerTest.cpp PROPERTIES COMPILE_FLAGS -Wno-unused-function)
+endif()
Index: llvm/trunk/unittests/Support/TypeTraitsTest.cpp
===
--- llvm/trunk/unittests/Support/TypeTraitsTest.cpp
+++ llvm/trunk/unittests/Support/TypeTraitsTest.cpp
@@ -7,6 +7,7 @@
 //===--===//
 
 #include "llvm/Support/type_traits.h"
+#include "gtest/gtest.h"
 
 namespace {
 
@@ -71,6 +72,26 @@
 template void TrivialityTester();
 template void TrivialityTester();
 
+TEST(Triviality, Tester) {
+  TrivialityTester();
+  TrivialityTester();
+  TrivialityTester();
+  TrivialityTester();
+
+  TrivialityTester();
+  TrivialityTester();
+  TrivialityTester();
+  TrivialityTester();
+  TrivialityTester();
+
+  TrivialityTester();
+  TrivialityTester();
+  TrivialityTester();
+  TrivialityTester();
+  TrivialityTester();
+  TrivialityTester();
+}
+
 } // namespace triviality
 
 } // end anonymous namespace
Index: llvm/trunk/unittests/IR/ConstantRangeTest.cpp
===
--- llvm/trunk/unittests/IR/ConstantRangeTest.cpp
+++ llvm/trunk/unittests/IR/ConstantRangeTest.cpp
@@ -459,6 +459,8 @@
   }
 }
 
+// Silence warning: variable 'HaveInterrupt3' set but not used
+(void)HaveInterrupt3;
 assert(!HaveInterrupt3 && "Should have at most three ranges");
 
 ConstantRange SmallestCR = OpFn(CR1, CR2, ConstantRange::Smallest);
Index: llvm/trunk/lib/Target/AMDGPU/R600ISelLowering.cpp
===
--- llvm/trunk/lib/Target/AMDGPU/R600ISelLowering.cpp
+++ llvm/trunk/lib/Target/AMDGPU/R600ISelLowering.cpp
@@ -1714,6 +1714,12 @@
 
 if (NewBldVec[i].isUndef())
   continue;
+// Fix spurious warning with gcc 7.3 -O3
+//warning: array subscript is above array bounds [-Warray-bounds]
+//if (NewBldVec[i] == NewBldVec[j]) {
+//~~~^
+if (i >= 4)
+  continue;
 for (unsigned j = 0; j < i; j++) {
   if (NewBldVec[i] == NewBldVec[j]) {
 NewBldVec[i] = DAG.getUNDEF(NewBldVec[i].getValueType());
Index: clang/trunk/unittests/Tooling/LookupTest.cpp
===
--- clang/trunk/unittests/Tooling/LookupTest.cpp
+++ clang/trunk/unittests/Tooling/LookupTest.cpp
@@ -217,8 +217,9 @@
   // `x::y::Foo` in c.cc [1], it should not make "Foo" at [0] ambiguous because
   // it's not visible at [0].
   Visitor.OnRecordTypeLoc = [&](RecordTypeLoc Type) {
-if (Type.getDecl()->getQualifiedNameAsString() == "x::y::Old")
+if (Type.getDecl()->getQualifiedNameAsString() == "x::y::Old") {
   EXPECT_EQ("Foo", replaceRecordTypeLoc(Type, "::x::Foo"));
+}
   };
   Visitor.runOver(R"(
 // a.h
Index: clang/trunk/unittests/AST/ASTImporterTest.cpp
===
--- clang/trunk/unittests/AST/ASTImporterTest.cpp
+++ clang/trunk/unittests/AST/ASTImporterTest.cpp
@@ -4048,8 +4048,9 @@
 auto 

[PATCH] D61046: Fix compilation warnings when compiling with GCC 7.3

2019-04-24 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea added inline comments.



Comment at: llvm/trunk/lib/Target/AMDGPU/R600ISelLowering.cpp:1717-1722
+// Fix spurious warning with gcc 7.3 -O3 for NewBldVec[i] below
+// warning: array subscript is above array bounds [-Warray-bounds]
+#if defined(__GNUC__) && __GNUC__ >= 7 && __GNUC_MINOR__ >= 3
+if (i >= 4)
+  continue;
+#endif

tstellar wrote:
> We don't want to  have ifdefs for specific compilers, can this be fixed 
> another way or dropped from the patch?
Removed ifdefs, but I kept the test. This looks like an optimizer issue in GCC, 
however the regression tests are unaffected by this change. I will c-reduce and 
report it if it's still there in the latest GCC.



Comment at: llvm/trunk/unittests/Transforms/Scalar/CMakeLists.txt:14-17
+# Workaround for the gcc 6.1 bug 
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80916.
+if (CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 
6.0)
+  set_source_files_properties(LoopPassManagerTest.cpp PROPERTIES COMPILE_FLAGS 
-Wno-unused-function)
+endif()

tstellar wrote:
> Same thing here too.
Not sure I understand, there're plenty of compiler-specific examples in the 
.cmake files. Is there an alternate way to fix this?


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

https://reviews.llvm.org/D61046



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


[PATCH] D61046: Fix compilation warnings when compiling with GCC 7.3

2019-04-25 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea updated this revision to Diff 196655.
aganea marked 3 inline comments as done.
aganea added a comment.

Please let me know if other changes are needed.


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

https://reviews.llvm.org/D61046

Files:
  clang/trunk/unittests/AST/ASTImporterTest.cpp
  clang/trunk/unittests/Tooling/LookupTest.cpp
  llvm/trunk/lib/Target/AMDGPU/R600ISelLowering.cpp
  llvm/trunk/unittests/IR/ConstantRangeTest.cpp
  llvm/trunk/unittests/Support/TypeTraitsTest.cpp
  llvm/trunk/unittests/Transforms/Scalar/CMakeLists.txt
  llvm/trunk/unittests/Transforms/Scalar/LoopPassManagerTest.cpp

Index: llvm/trunk/unittests/Transforms/Scalar/LoopPassManagerTest.cpp
===
--- llvm/trunk/unittests/Transforms/Scalar/LoopPassManagerTest.cpp
+++ llvm/trunk/unittests/Transforms/Scalar/LoopPassManagerTest.cpp
@@ -20,19 +20,9 @@
 #include "llvm/IR/PassManager.h"
 #include "llvm/Support/SourceMgr.h"
 
-// Workaround for the gcc 6.1 bug PR80916.
-#if defined(__GNUC__) && __GNUC__ > 5
-#  pragma GCC diagnostic push
-#  pragma GCC diagnostic ignored "-Wunused-function"
-#endif
-
 #include "gmock/gmock.h"
 #include "gtest/gtest.h"
 
-#if defined(__GNUC__) && __GNUC__ > 5
-#  pragma GCC diagnostic pop
-#endif
-
 using namespace llvm;
 
 namespace {
Index: llvm/trunk/unittests/Transforms/Scalar/CMakeLists.txt
===
--- llvm/trunk/unittests/Transforms/Scalar/CMakeLists.txt
+++ llvm/trunk/unittests/Transforms/Scalar/CMakeLists.txt
@@ -10,3 +10,8 @@
 add_llvm_unittest(ScalarTests
   LoopPassManagerTest.cpp
   )
+
+# Workaround for the gcc 6.1 bug https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80916.
+if (CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 6.0 AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 9.0)
+  set_source_files_properties(LoopPassManagerTest.cpp PROPERTIES COMPILE_FLAGS -Wno-unused-function)
+endif()
Index: llvm/trunk/unittests/Support/TypeTraitsTest.cpp
===
--- llvm/trunk/unittests/Support/TypeTraitsTest.cpp
+++ llvm/trunk/unittests/Support/TypeTraitsTest.cpp
@@ -7,6 +7,7 @@
 //===--===//
 
 #include "llvm/Support/type_traits.h"
+#include "gtest/gtest.h"
 
 namespace {
 
@@ -71,6 +72,26 @@
 template void TrivialityTester();
 template void TrivialityTester();
 
+TEST(Triviality, Tester) {
+  TrivialityTester();
+  TrivialityTester();
+  TrivialityTester();
+  TrivialityTester();
+
+  TrivialityTester();
+  TrivialityTester();
+  TrivialityTester();
+  TrivialityTester();
+  TrivialityTester();
+
+  TrivialityTester();
+  TrivialityTester();
+  TrivialityTester();
+  TrivialityTester();
+  TrivialityTester();
+  TrivialityTester();
+}
+
 } // namespace triviality
 
 } // end anonymous namespace
Index: llvm/trunk/unittests/IR/ConstantRangeTest.cpp
===
--- llvm/trunk/unittests/IR/ConstantRangeTest.cpp
+++ llvm/trunk/unittests/IR/ConstantRangeTest.cpp
@@ -459,6 +459,8 @@
   }
 }
 
+// Silence warning: variable 'HaveInterrupt3' set but not used
+(void)HaveInterrupt3;
 assert(!HaveInterrupt3 && "Should have at most three ranges");
 
 ConstantRange SmallestCR = OpFn(CR1, CR2, ConstantRange::Smallest);
Index: llvm/trunk/lib/Target/AMDGPU/R600ISelLowering.cpp
===
--- llvm/trunk/lib/Target/AMDGPU/R600ISelLowering.cpp
+++ llvm/trunk/lib/Target/AMDGPU/R600ISelLowering.cpp
@@ -1714,6 +1714,12 @@
 
 if (NewBldVec[i].isUndef())
   continue;
+// Fix spurious warning with gcc 7.3 -O3
+//warning: array subscript is above array bounds [-Warray-bounds]
+//if (NewBldVec[i] == NewBldVec[j]) {
+//~~~^
+if (i >= 4)
+  continue;
 for (unsigned j = 0; j < i; j++) {
   if (NewBldVec[i] == NewBldVec[j]) {
 NewBldVec[i] = DAG.getUNDEF(NewBldVec[i].getValueType());
Index: clang/trunk/unittests/Tooling/LookupTest.cpp
===
--- clang/trunk/unittests/Tooling/LookupTest.cpp
+++ clang/trunk/unittests/Tooling/LookupTest.cpp
@@ -217,8 +217,9 @@
   // `x::y::Foo` in c.cc [1], it should not make "Foo" at [0] ambiguous because
   // it's not visible at [0].
   Visitor.OnRecordTypeLoc = [&](RecordTypeLoc Type) {
-if (Type.getDecl()->getQualifiedNameAsString() == "x::y::Old")
+if (Type.getDecl()->getQualifiedNameAsString() == "x::y::Old") {
   EXPECT_EQ("Foo", replaceRecordTypeLoc(Type, "::x::Foo"));
+}
   };
   Visitor.runOver(R"(
 // a.h
Index: clang/trunk/unittests/AST/ASTImporterTest.cpp
===
--- clang/trunk/unittests/AST/ASTImporterTest.cpp
+++ 

[PATCH] D61046: Fix compilation warnings when compiling with GCC 7.3

2019-04-25 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea added inline comments.



Comment at: llvm/trunk/unittests/Transforms/Scalar/CMakeLists.txt:14-17
+# Workaround for the gcc 6.1 bug 
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80916.
+if (CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 
6.0)
+  set_source_files_properties(LoopPassManagerTest.cpp PROPERTIES COMPILE_FLAGS 
-Wno-unused-function)
+endif()

tstellar wrote:
> aganea wrote:
> > tstellar wrote:
> > > aganea wrote:
> > > > tstellar wrote:
> > > > > Same thing here too.
> > > > Not sure I understand, there're plenty of compiler-specific examples in 
> > > > the .cmake files. Is there an alternate way to fix this?
> > > I know there are some, but I don't think a warning like this is important 
> > > enough to fix with a compiler specific work-around.
> > You mean more like
> > ```
> > # Workaround for the gcc 6.1 bug 
> > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80916.
> > if (NOT MSVC)
> >   set_source_files_properties(LoopPassManagerTest.cpp PROPERTIES 
> > COMPILE_FLAGS -Wno-unused-function)
> > endif()
> > ```
> > Or leave the warning? There's already an #ifdef below in 
> > LoopPassManagerTest.cpp but it's not at the right place, this simply 
> > corrects it.
> Ok, I see in this case you are just moving the ifdef out of the code and into 
> CMake.  I really don't like either approach, but I guess this is fine.  I 
> would limit the work-around to only known broken compilers though.  It looks 
> like this might be fixed in gcc 9.
Scoping this issue under GCC version range [6.1, 9.0)


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

https://reviews.llvm.org/D61046



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


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

2019-04-25 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea added a comment.
Herald added a project: LLVM.

Just a quick heads-up - the `cuda-detect-path.cu` test fails on WSL/Ubuntu 
18.04:

  aganea@MTL-BJ842:/mnt/f/svn/buildWSL$ /usr/bin/python3.6 bin/llvm-lit -vv 
../clang/test/Driver/cuda-detect-path.cu
  llvm-lit: /mnt/f/svn/llvm/utils/lit/lit/llvm/config.py:341: note: using 
clang: /mnt/f/svn/buildWSL/bin/clang
  -- Testing: 1 tests, single process --
  FAIL: Clang :: Driver/cuda-detect-path.cu (1 of 1)
   TEST 'Clang :: Driver/cuda-detect-path.cu' FAILED 

  
  (output chopped)
  
  + env PATH=/mnt/f/svn/clang/test/Driver/Inputs/CUDA-symlinks/usr/bin 
/mnt/f/svn/buildWSL/bin/clang -v --target=i386-unknown-linux 
--sysroot=/mnt/f/svn/clang/test/Driver/no-cuda-there
  + /mnt/f/svn/buildWSL/bin/FileCheck 
/mnt/f/svn/clang/test/Driver/cuda-detect-path.cu --check-prefix SYMLINKS
  /mnt/f/svn/clang/test/Driver/cuda-detect-path.cu:82:14: error: SYMLINKS: 
expected string not found in input
  // SYMLINKS: Found CUDA installation: {{.*}}/Inputs/CUDA-symlinks/opt/cuda
   ^
  :1:1: note: scanning from here
  clang version 9.0.0 (trunk)
  ^
  :4:1: note: possible intended match here
  InstalledDir: /mnt/f/svn/buildWSL/bin
  ^
  
  aganea@MTL-BJ842:/mnt/f/svn/buildWSL$ env 
PATH=/mnt/f/svn/clang/test/Driver/Inputs/CUDA-symlinks/usr/bin 
/mnt/f/svn/buildWSL/bin/clang -v --target=i386-unknown-linux 
--sysroot=/mnt/f/svn/clang/test/Driver/no-cuda-there
  clang version 9.0.0 (trunk)
  Target: i386-unknown-linux
  Thread model: posix
  InstalledDir: /mnt/f/svn/buildWSL/bin
  aganea@MTL-BJ842:/mnt/f/svn/buildWSL$ ls -l 
/mnt/f/svn/clang/test/Driver/Inputs/CUDA-symlinks/usr/bin
  total 0
  -rwxrwxrwx 1 aganea aganea 29 Feb  1  2018 ptxas


Repository:
  rL LLVM

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

https://reviews.llvm.org/D42642



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


[PATCH] D60283: [DebugInfo] Don't emit checksums when compiling a preprocessed CPP

2019-04-23 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea updated this revision to Diff 196321.
aganea retitled this revision from "[clang-cl] Don't emit checksums when 
compiling a preprocessed CPP" to "[DebugInfo] Don't emit checksums when 
compiling a preprocessed CPP".
aganea added a comment.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Steal one bit from `PresumedLoc::Column` as suggested by @rnk.
Ping @rsmith !


Repository:
  rL LLVM

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

https://reviews.llvm.org/D60283

Files:
  include/clang/Basic/SourceLocation.h
  lib/Basic/SourceManager.cpp
  lib/CodeGen/CGDebugInfo.cpp
  test/CodeGen/Inputs/debug-info-file-checksum-pre.cpp
  test/CodeGen/debug-info-file-checksum.c

Index: test/CodeGen/debug-info-file-checksum.c
===
--- test/CodeGen/debug-info-file-checksum.c
+++ test/CodeGen/debug-info-file-checksum.c
@@ -4,3 +4,11 @@
 // Check that "checksum" is created correctly for the compiled file.
 
 // CHECK: !DIFile(filename:{{.*}}, directory:{{.*}}, checksumkind: CSK_MD5, checksum: "a3b7d27af071accdeccaa933fc603608")
+
+// Ensure #line directives (in already pre-processed files) do not emit checksums
+
+// RUN: %clang -emit-llvm -S -g -gcodeview -x c %S/Inputs/debug-info-file-checksum-pre.cpp -o - | FileCheck %s --check-prefix NOCHECKSUM
+
+// NOCHECKSUM-LABEL: !DIFile(filename: "{{.*}}code-coverage-filter1.h", directory: "{{[^"]*}}")
+// NOCHECKSUM-LABEL: !DIFile(filename: "{{.*}}code-coverage-filter2.h", directory: "{{[^"]*}}")
+// NOCHECKSUM-LABEL: !DIFile(filename: "{{.*}}debug-info-file-checksum.c", directory: "{{[^"]*}}")
Index: test/CodeGen/Inputs/debug-info-file-checksum-pre.cpp
===
--- test/CodeGen/Inputs/debug-info-file-checksum-pre.cpp
+++ test/CodeGen/Inputs/debug-info-file-checksum-pre.cpp
@@ -0,0 +1,10 @@
+#line 1 "F:\\svn\\clang\\test\\CodeGen\\Inputs\\debug-info-file-checksum.c"
+#line 1 "f:\\svn\\clang\\test\\codegen\\inputs\\code-coverage-filter1.h"
+void test1() {}
+#line 2 "F:\\svn\\clang\\test\\CodeGen\\Inputs\\debug-info-file-checksum.c"
+#line 1 "f:\\svn\\clang\\test\\codegen\\inputs\\code-coverage-filter2.h"
+void test2() {}
+#line 3 "F:\\svn\\clang\\test\\CodeGen\\Inputs\\debug-info-file-checksum.c"
+int foo(int x) {
+  return x+1;
+}
Index: lib/CodeGen/CGDebugInfo.cpp
===
--- lib/CodeGen/CGDebugInfo.cpp
+++ lib/CodeGen/CGDebugInfo.cpp
@@ -422,11 +422,18 @@
   }
 
   SmallString<32> Checksum;
-  Optional CSKind =
-  computeChecksum(SM.getFileID(Loc), Checksum);
   Optional> CSInfo;
-  if (CSKind)
-CSInfo.emplace(*CSKind, Checksum);
+
+  // Don't compute checksums if the location is affected by a #line directive.
+  // We would otherwise end up with the same checksum for all the files referred
+  // by #line. Instead the checksum remains empty, leaving to the debugger to
+  // open the file without checksum validation.
+  if (!PLoc.isAffectedByLineDirective()) {
+Optional CSKind =
+computeChecksum(SM.getFileID(Loc), Checksum);
+if (CSKind)
+  CSInfo.emplace(*CSKind, Checksum);
+  }
   return createFile(FileName, CSInfo, getSource(SM, SM.getFileID(Loc)));
 }
 
Index: lib/Basic/SourceManager.cpp
===
--- lib/Basic/SourceManager.cpp
+++ lib/Basic/SourceManager.cpp
@@ -1444,6 +1444,7 @@
 return PresumedLoc();
 
   SourceLocation IncludeLoc = FI.getIncludeLoc();
+  bool LineDirective = false;
 
   // If we have #line directives in this file, update and overwrite the physical
   // location info if appropriate.
@@ -1470,10 +1471,11 @@
 IncludeLoc = getLocForStartOfFile(LocInfo.first);
 IncludeLoc = IncludeLoc.getLocWithOffset(Entry->IncludeOffset);
   }
+  LineDirective = true;
 }
   }
 
-  return PresumedLoc(Filename.data(), LineNo, ColNo, IncludeLoc);
+  return PresumedLoc(Filename.data(), LineNo, ColNo, IncludeLoc, LineDirective);
 }
 
 /// Returns whether the PresumedLoc for a given SourceLocation is
Index: include/clang/Basic/SourceLocation.h
===
--- include/clang/Basic/SourceLocation.h
+++ include/clang/Basic/SourceLocation.h
@@ -282,13 +282,17 @@
 /// You can get a PresumedLoc from a SourceLocation with SourceManager.
 class PresumedLoc {
   const char *Filename = nullptr;
-  unsigned Line, Col;
+  unsigned Line;
+  unsigned Col : 31;
+  unsigned InLineDirective : 1;
   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, unsigned Ln, unsigned Co, SourceLocation IL,
+  bool InLine)
+  : Filename(FN), Line(Ln), Col(Co), InLineDirective(InLine),
+IncludeLoc(IL) {}
 
   

[PATCH] D61046: Fix compilation warnings when compiling with GCC 7.3

2019-04-23 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea marked 5 inline comments as done.
aganea added inline comments.



Comment at: clang/trunk/unittests/AST/ASTImporterTest.cpp:4054
+}
   }
 

Fixes
```
[2097/2979] Building CXX object 
tools/clang/unittests/Tooling/CMakeFiles/ToolingTests.dir/LookupTest.cpp.o
/mnt/f/svn/clang/unittests/Tooling/LookupTest.cpp: In lambda function:
/mnt/f/svn/clang/unittests/Tooling/LookupTest.cpp:220:8: warning: suggest 
explicit braces to avoid ambiguous ‘else’ [-Wdangling-else]
 if (Type.getDecl()->getQualifiedNameAsString() == "x::y::Old")
^
```



Comment at: clang/trunk/unittests/Tooling/LookupTest.cpp:222
   EXPECT_EQ("Foo", replaceRecordTypeLoc(Type, "::x::Foo"));
+}
   };

Fixes
```
[2107/2979] Building CXX object 
tools/clang/unittests/AST/CMakeFiles/ASTTests.dir/ASTImporterTest.cpp.o
/mnt/f/svn/clang/unittests/AST/ASTImporterTest.cpp: In member function ‘void 
clang::ast_matchers::RedeclChain::TypedTest_PrototypeShouldBeImportedAsAPrototypeWhenThereIsNoDefinition()’:
/mnt/f/svn/clang/unittests/AST/ASTImporterTest.cpp:4051:8: warning: suggest 
explicit braces to avoid ambiguous ‘else’ [-Wdangling-else]
 if (auto *ToT = dyn_cast(ToD))
^
```



Comment at: lld/trunk/ELF/LinkerScript.cpp:892
+SHF_EXECINSTR);
 
 if (IsEmpty && isDiscardable(*Sec)) {

Fixes
```
[2238/2979] Building CXX object 
tools/lld/ELF/CMakeFiles/lldELF.dir/LinkerScript.cpp.o
/mnt/f/svn/lld/ELF/LinkerScript.cpp: In member function ‘void 
lld::elf::LinkerScript::adjustSectionsBeforeSorting()’:
/mnt/f/svn/lld/ELF/LinkerScript.cpp:891:35: warning: enumeral and non-enumeral 
type in conditional expression [-Wextra]
   Flags & ((Sec->NonAlloc ? 0 : SHF_ALLOC) | SHF_WRITE | 
SHF_EXECINSTR);
 ~~^~~
```



Comment at: llvm/trunk/unittests/Support/TypeTraitsTest.cpp:95
+
 } // namespace triviality
 

Fixes a bunch of
```
[2828/2979] Building CXX object 
unittests/Support/CMakeFiles/SupportTests.dir/TypeTraitsTest.cpp.o
/mnt/f/svn/llvm/unittests/Support/TypeTraitsTest.cpp:20:6: warning: ‘void 
{anonymous}::triviality::TrivialityTester() [with T = 
{anonymous}::triviality::B&&; bool IsTriviallyCopyConstructible = false; bool 
IsTriviallyMoveConstructible = true]’ defined but not used [-Wunused-function]
 void TrivialityTester() {
  ^~~~
```



Comment at: llvm/trunk/unittests/Transforms/Scalar/CMakeLists.txt:17
+  set_source_files_properties(LoopPassManagerTest.cpp PROPERTIES COMPILE_FLAGS 
-Wno-unused-function)
+endif()

Fixes
```
[2894/2979] Building CXX object 
unittests/Transforms/Scalar/CMakeFiles/ScalarTests.dir/LoopPassManagerTest.cpp.o
In file included from 
/mnt/f/svn/llvm/utils/unittest/googlemock/include/gmock/gmock-generated-function-mockers.h:43:0,
 from 
/mnt/f/svn/llvm/utils/unittest/googlemock/include/gmock/gmock.h:61,
 from 
/mnt/f/svn/llvm/unittests/Transforms/Scalar/LoopPassManagerTest.cpp:29:
/mnt/f/svn/llvm/utils/unittest/googlemock/include/gmock/gmock-spec-builders.h:896:11:
 warning: ‘testing::internal::TypedExpectation::~TypedExpectation() noexcept 
[with F = 
{anonymous}::MockAnalysisHandleBase<{anonymous}::MockFunctionAnalysisHandle, 
llvm::Function>::Analysis::Result(llvm::Function&, 
llvm::AnalysisManager&)]’ declared ‘static’ but never defined 
[-Wunused-function]
   virtual ~TypedExpectation() {
   ^
```



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

https://reviews.llvm.org/D61046



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


[PATCH] D61046: Fix compilation warnings when compiling with GCC 7.3

2019-04-23 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea created this revision.
aganea added reviewers: spatel, rnk, nikic, chandlerc, MaskRay, martong, ioeric.
aganea added projects: LLVM, clang, lld.
Herald added subscribers: rnkovacs, arichardson, mgorny, nhaehnle, jvesely, 
mehdi_amini, emaste, arsenm.
Herald added a reviewer: espindola.
Herald added a reviewer: shafik.

This fixes some warnings when compiling Clang & LLD on a out-of-the-box 
WSL/Ubuntu 18.04 shell.


https://reviews.llvm.org/D61046

Files:
  clang/trunk/unittests/AST/ASTImporterTest.cpp
  clang/trunk/unittests/Tooling/LookupTest.cpp
  lld/trunk/ELF/LinkerScript.cpp
  llvm/trunk/include/llvm/BinaryFormat/ELF.h
  llvm/trunk/lib/Target/AMDGPU/R600ISelLowering.cpp
  llvm/trunk/unittests/IR/ConstantRangeTest.cpp
  llvm/trunk/unittests/Support/TypeTraitsTest.cpp
  llvm/trunk/unittests/Transforms/Scalar/CMakeLists.txt
  llvm/trunk/unittests/Transforms/Scalar/LoopPassManagerTest.cpp

Index: llvm/trunk/unittests/Transforms/Scalar/LoopPassManagerTest.cpp
===
--- llvm/trunk/unittests/Transforms/Scalar/LoopPassManagerTest.cpp
+++ llvm/trunk/unittests/Transforms/Scalar/LoopPassManagerTest.cpp
@@ -20,19 +20,9 @@
 #include "llvm/IR/PassManager.h"
 #include "llvm/Support/SourceMgr.h"
 
-// Workaround for the gcc 6.1 bug PR80916.
-#if defined(__GNUC__) && __GNUC__ > 5
-#  pragma GCC diagnostic push
-#  pragma GCC diagnostic ignored "-Wunused-function"
-#endif
-
 #include "gmock/gmock.h"
 #include "gtest/gtest.h"
 
-#if defined(__GNUC__) && __GNUC__ > 5
-#  pragma GCC diagnostic pop
-#endif
-
 using namespace llvm;
 
 namespace {
Index: llvm/trunk/unittests/Transforms/Scalar/CMakeLists.txt
===
--- llvm/trunk/unittests/Transforms/Scalar/CMakeLists.txt
+++ llvm/trunk/unittests/Transforms/Scalar/CMakeLists.txt
@@ -10,3 +10,8 @@
 add_llvm_unittest(ScalarTests
   LoopPassManagerTest.cpp
   )
+
+# Workaround for the gcc 6.1 bug https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80916.
+if (CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 6.1)
+  set_source_files_properties(LoopPassManagerTest.cpp PROPERTIES COMPILE_FLAGS -Wno-unused-function)
+endif()
Index: llvm/trunk/unittests/Support/TypeTraitsTest.cpp
===
--- llvm/trunk/unittests/Support/TypeTraitsTest.cpp
+++ llvm/trunk/unittests/Support/TypeTraitsTest.cpp
@@ -7,6 +7,7 @@
 //===--===//
 
 #include "llvm/Support/type_traits.h"
+#include "gtest/gtest.h"
 
 namespace {
 
@@ -71,6 +72,26 @@
 template void TrivialityTester();
 template void TrivialityTester();
 
+TEST(Triviality, Tester) {
+  TrivialityTester();
+  TrivialityTester();
+  TrivialityTester();
+  TrivialityTester();
+
+  TrivialityTester();
+  TrivialityTester();
+  TrivialityTester();
+  TrivialityTester();
+  TrivialityTester();
+
+  TrivialityTester();
+  TrivialityTester();
+  TrivialityTester();
+  TrivialityTester();
+  TrivialityTester();
+  TrivialityTester();
+}
+
 } // namespace triviality
 
 } // end anonymous namespace
Index: llvm/trunk/unittests/IR/ConstantRangeTest.cpp
===
--- llvm/trunk/unittests/IR/ConstantRangeTest.cpp
+++ llvm/trunk/unittests/IR/ConstantRangeTest.cpp
@@ -395,6 +395,10 @@
   }
 }
 
+#if defined(__GNUC__) && __GNUC__ >= 7
+// Silence warning: variable 'HaveInterrupt3' set but not used
+(void)
+#endif
 assert(!HaveInterrupt3 && "Should have at most three ranges");
 
 ConstantRange SmallestCR = OpFn(CR1, CR2, ConstantRange::Smallest);
Index: llvm/trunk/lib/Target/AMDGPU/R600ISelLowering.cpp
===
--- llvm/trunk/lib/Target/AMDGPU/R600ISelLowering.cpp
+++ llvm/trunk/lib/Target/AMDGPU/R600ISelLowering.cpp
@@ -1714,6 +1714,10 @@
 
 if (NewBldVec[i].isUndef())
   continue;
+// Fix spurious warning with gcc 7.3 -O3 for NewBldVec[i] below
+// warning: array subscript is above array bounds [-Warray-bounds]
+if (i >= 4)
+  continue;
 for (unsigned j = 0; j < i; j++) {
   if (NewBldVec[i] == NewBldVec[j]) {
 NewBldVec[i] = DAG.getUNDEF(NewBldVec[i].getValueType());
Index: llvm/trunk/include/llvm/BinaryFormat/ELF.h
===
--- llvm/trunk/include/llvm/BinaryFormat/ELF.h
+++ llvm/trunk/include/llvm/BinaryFormat/ELF.h
@@ -875,6 +875,8 @@
 
 // Section flags.
 enum : unsigned {
+  SHF_NONE,
+
   // Section data should be writable during execution.
   SHF_WRITE = 0x1,
 
Index: lld/trunk/ELF/LinkerScript.cpp
===
--- lld/trunk/ELF/LinkerScript.cpp
+++ lld/trunk/ELF/LinkerScript.cpp
@@ -887,8 +887,8 @@
 // in case it is empty.
 bool IsEmpty = 

[PATCH] D61046: Fix compilation warnings when compiling with GCC 7.3

2019-04-23 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea updated this revision to Diff 196358.

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

https://reviews.llvm.org/D61046

Files:
  clang/trunk/unittests/AST/ASTImporterTest.cpp
  clang/trunk/unittests/Tooling/LookupTest.cpp
  lld/trunk/ELF/LinkerScript.cpp
  llvm/trunk/include/llvm/BinaryFormat/ELF.h
  llvm/trunk/lib/Target/AMDGPU/R600ISelLowering.cpp
  llvm/trunk/unittests/IR/ConstantRangeTest.cpp
  llvm/trunk/unittests/Support/TypeTraitsTest.cpp
  llvm/trunk/unittests/Transforms/Scalar/CMakeLists.txt
  llvm/trunk/unittests/Transforms/Scalar/LoopPassManagerTest.cpp

Index: llvm/trunk/unittests/Transforms/Scalar/LoopPassManagerTest.cpp
===
--- llvm/trunk/unittests/Transforms/Scalar/LoopPassManagerTest.cpp
+++ llvm/trunk/unittests/Transforms/Scalar/LoopPassManagerTest.cpp
@@ -20,19 +20,9 @@
 #include "llvm/IR/PassManager.h"
 #include "llvm/Support/SourceMgr.h"
 
-// Workaround for the gcc 6.1 bug PR80916.
-#if defined(__GNUC__) && __GNUC__ > 5
-#  pragma GCC diagnostic push
-#  pragma GCC diagnostic ignored "-Wunused-function"
-#endif
-
 #include "gmock/gmock.h"
 #include "gtest/gtest.h"
 
-#if defined(__GNUC__) && __GNUC__ > 5
-#  pragma GCC diagnostic pop
-#endif
-
 using namespace llvm;
 
 namespace {
Index: llvm/trunk/unittests/Transforms/Scalar/CMakeLists.txt
===
--- llvm/trunk/unittests/Transforms/Scalar/CMakeLists.txt
+++ llvm/trunk/unittests/Transforms/Scalar/CMakeLists.txt
@@ -10,3 +10,8 @@
 add_llvm_unittest(ScalarTests
   LoopPassManagerTest.cpp
   )
+
+# Workaround for the gcc 6.1 bug https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80916.
+if (CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 6.0)
+  set_source_files_properties(LoopPassManagerTest.cpp PROPERTIES COMPILE_FLAGS -Wno-unused-function)
+endif()
Index: llvm/trunk/unittests/Support/TypeTraitsTest.cpp
===
--- llvm/trunk/unittests/Support/TypeTraitsTest.cpp
+++ llvm/trunk/unittests/Support/TypeTraitsTest.cpp
@@ -7,6 +7,7 @@
 //===--===//
 
 #include "llvm/Support/type_traits.h"
+#include "gtest/gtest.h"
 
 namespace {
 
@@ -71,6 +72,26 @@
 template void TrivialityTester();
 template void TrivialityTester();
 
+TEST(Triviality, Tester) {
+  TrivialityTester();
+  TrivialityTester();
+  TrivialityTester();
+  TrivialityTester();
+
+  TrivialityTester();
+  TrivialityTester();
+  TrivialityTester();
+  TrivialityTester();
+  TrivialityTester();
+
+  TrivialityTester();
+  TrivialityTester();
+  TrivialityTester();
+  TrivialityTester();
+  TrivialityTester();
+  TrivialityTester();
+}
+
 } // namespace triviality
 
 } // end anonymous namespace
Index: llvm/trunk/unittests/IR/ConstantRangeTest.cpp
===
--- llvm/trunk/unittests/IR/ConstantRangeTest.cpp
+++ llvm/trunk/unittests/IR/ConstantRangeTest.cpp
@@ -395,6 +395,10 @@
   }
 }
 
+#if defined(__GNUC__) && __GNUC__ >= 7
+// Silence warning: variable 'HaveInterrupt3' set but not used
+(void)
+#endif
 assert(!HaveInterrupt3 && "Should have at most three ranges");
 
 ConstantRange SmallestCR = OpFn(CR1, CR2, ConstantRange::Smallest);
Index: llvm/trunk/lib/Target/AMDGPU/R600ISelLowering.cpp
===
--- llvm/trunk/lib/Target/AMDGPU/R600ISelLowering.cpp
+++ llvm/trunk/lib/Target/AMDGPU/R600ISelLowering.cpp
@@ -1714,6 +1714,12 @@
 
 if (NewBldVec[i].isUndef())
   continue;
+// Fix spurious warning with gcc 7.3 -O3 for NewBldVec[i] below
+// warning: array subscript is above array bounds [-Warray-bounds]
+#if defined(__GNUC__) && __GNUC__ >= 7 && __GNUC_MINOR__ >= 3
+if (i >= 4)
+  continue;
+#endif
 for (unsigned j = 0; j < i; j++) {
   if (NewBldVec[i] == NewBldVec[j]) {
 NewBldVec[i] = DAG.getUNDEF(NewBldVec[i].getValueType());
Index: llvm/trunk/include/llvm/BinaryFormat/ELF.h
===
--- llvm/trunk/include/llvm/BinaryFormat/ELF.h
+++ llvm/trunk/include/llvm/BinaryFormat/ELF.h
@@ -875,6 +875,8 @@
 
 // Section flags.
 enum : unsigned {
+  SHF_NONE,
+
   // Section data should be writable during execution.
   SHF_WRITE = 0x1,
 
Index: lld/trunk/ELF/LinkerScript.cpp
===
--- lld/trunk/ELF/LinkerScript.cpp
+++ lld/trunk/ELF/LinkerScript.cpp
@@ -887,8 +887,8 @@
 // in case it is empty.
 bool IsEmpty = getInputSections(Sec).empty();
 if (IsEmpty)
-  Sec->Flags =
-  Flags & ((Sec->NonAlloc ? 0 : SHF_ALLOC) | SHF_WRITE | SHF_EXECINSTR);
+  Sec->Flags = Flags & ((Sec->NonAlloc ? SHF_NONE : SHF_ALLOC) | SHF_WRITE |
+

[PATCH] D60283: [DebugInfo] Don't emit checksums when compiling a preprocessed CPP

2019-04-26 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea added a comment.

Thanks Paul, your solution is even better. I'll apply rL11 
 locally - if everything's fine, do you mind 
if I re-land it again?


Repository:
  rC Clang

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

https://reviews.llvm.org/D60283



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


[PATCH] D63648: [Preprocessor] Honor absolute paths in diagnostics

2019-07-16 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea added a comment.

Ping!


Repository:
  rC Clang

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

https://reviews.llvm.org/D63648



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


[PATCH] D63681: [clang-scan-deps] Introduce the DependencyScanning library with the thread worker code and better error handling

2019-06-25 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea added a comment.

LGTM!

Some quick stats on our end (running Windows 10 on a Intel W-2135, 6-core, 3.7 
GHz, NVMe SSD): on a large .SLN compiling approx. 16,000 .CPP files through 600 
unity .CPPs and 23,000 .H files, out of **86 secs** spent in `ClangScanDeps`, 
about **32 secs** are spent in `DirectoryLookup::LookUpFile`.




Comment at: 
clang/include/clang/Tooling/DependencyScanning/DependencyScanningWorker.h:29
+/// sources either using a fast mode where the source files are minimized, or
+/// using the regular processing run.
+class DependencyScanningWorker {

How do you actually select between the fast mode or the regular preprocess?


Repository:
  rC Clang

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

https://reviews.llvm.org/D63681



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


[PATCH] D66328: [DebugInfo] Add debug location to dynamic atexit destructor

2019-08-15 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea created this revision.
aganea added reviewers: rnk, aprantl.
aganea added a project: clang.

Previously, when clang was compiled with -DLLVM_ENABLE_ASSERTIONS=ON, the 
attached test was yielding:

  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


Repository:
  rC Clang

https://reviews.llvm.org/D66328

Files:
  lib/CodeGen/CGDeclCXX.cpp
  test/CodeGen/debug-info-no-location.cpp


Index: test/CodeGen/debug-info-no-location.cpp
===
--- test/CodeGen/debug-info-no-location.cpp
+++ test/CodeGen/debug-info-no-location.cpp
@@ -0,0 +1,16 @@
+// RUN: %clang -cc1 -emit-llvm %s -gcodeview -debug-info-kind=limited -o - | 
FileCheck %s
+// CHECK: call void @"??1?$c@UBQEAA@XZ"(%struct.c* 
@"?f@?1??d@@YAPEAU?$c@UBXZ@4U2@A"), !dbg !51
+// CHECK-NEXT: ret void, !dbg !51
+// CHECK: !48 = distinct !DISubprogram(name: "`dynamic atexit destructor for 
'f'", scope: !3, file: !3, line: 16, type: !49, scopeLine: 16, spFlags: 
DISPFlagLocalToUnit | DISPFlagDefinition, unit: !27, retainedNodes: !29)
+// CHECK: !51 = !DILocation(line: 16, scope: !48)
+
+struct a {
+  ~a();
+};
+template  struct c : a {
+  c(void (b::*)());
+};
+struct B {
+  virtual void e();
+};
+c *d() { static c f(::e); return  }
Index: lib/CodeGen/CGDeclCXX.cpp
===
--- lib/CodeGen/CGDeclCXX.cpp
+++ lib/CodeGen/CGDeclCXX.cpp
@@ -246,7 +246,8 @@
   CodeGenFunction CGF(CGM);
 
   CGF.StartFunction(GlobalDecl(, DynamicInitKind::AtExit),
-CGM.getContext().VoidTy, fn, FI, FunctionArgList());
+CGM.getContext().VoidTy, fn, FI, FunctionArgList(),
+VD.getLocation(), VD.getInit()->getExprLoc());
 
   llvm::CallInst *call = CGF.Builder.CreateCall(dtor, addr);
 


Index: test/CodeGen/debug-info-no-location.cpp
===
--- test/CodeGen/debug-info-no-location.cpp
+++ test/CodeGen/debug-info-no-location.cpp
@@ -0,0 +1,16 @@
+// RUN: %clang -cc1 -emit-llvm %s -gcodeview -debug-info-kind=limited -o - | FileCheck %s
+// CHECK: call void @"??1?$c@UBQEAA@XZ"(%struct.c* @"?f@?1??d@@YAPEAU?$c@UBXZ@4U2@A"), !dbg !51
+// CHECK-NEXT: ret void, !dbg !51
+// CHECK: !48 = distinct !DISubprogram(name: "`dynamic atexit destructor for 'f'", scope: !3, file: !3, line: 16, type: !49, scopeLine: 16, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition, unit: !27, retainedNodes: !29)
+// CHECK: !51 = !DILocation(line: 16, scope: !48)
+
+struct a {
+  ~a();
+};
+template  struct c : a {
+  c(void (b::*)());
+};
+struct B {
+  virtual void e();
+};
+c *d() { static c f(::e); return  }
Index: lib/CodeGen/CGDeclCXX.cpp
===
--- lib/CodeGen/CGDeclCXX.cpp
+++ lib/CodeGen/CGDeclCXX.cpp
@@ -246,7 +246,8 @@
   CodeGenFunction CGF(CGM);
 
   CGF.StartFunction(GlobalDecl(, DynamicInitKind::AtExit),
-CGM.getContext().VoidTy, fn, FI, FunctionArgList());
+CGM.getContext().VoidTy, fn, FI, FunctionArgList(),
+VD.getLocation(), VD.getInit()->getExprLoc());
 
   llvm::CallInst *call = CGF.Builder.CreateCall(dtor, addr);
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D66328: [DebugInfo] Add debug location to dynamic atexit destructor

2019-08-19 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea updated this revision to Diff 216046.
aganea marked 4 inline comments as done.
aganea added a comment.

As requested.


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

https://reviews.llvm.org/D66328

Files:
  lib/CodeGen/CGDebugInfo.cpp
  lib/CodeGen/CGDeclCXX.cpp
  test/CodeGenCXX/debug-info-atexit-stub.cpp
  test/CodeGenCXX/debug-info-global-ctor-dtor.cpp


Index: test/CodeGenCXX/debug-info-global-ctor-dtor.cpp
===
--- test/CodeGenCXX/debug-info-global-ctor-dtor.cpp
+++ test/CodeGenCXX/debug-info-global-ctor-dtor.cpp
@@ -30,24 +30,24 @@
 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(name: "`dynamic initializer for 'glob'",{{.*}} 
line: 15,{{.*}}: DISPFlagLocalToUnit | DISPFlagDefinition
-// CHECK-MSVC: !DISubprogram(name: "`dynamic atexit destructor for 
'glob'",{{.*}} line: 15,{{.*}}: DISPFlagLocalToUnit | DISPFlagDefinition
+// CHECK-MSVC: !DISubprogram(name: "`dynamic atexit destructor for 
'glob'",{{.*}}: DISPFlagLocalToUnit | DISPFlagDefinition
 // CHECK-MSVC: !DISubprogram(name: "`dynamic initializer for 'array'",{{.*}} 
line: 16,{{.*}}: DISPFlagLocalToUnit | DISPFlagDefinition
 // CHECK-MSVC: !DISubprogram(name: "__cxx_global_array_dtor",{{.*}} line: 
16,{{.*}}: DISPFlagLocalToUnit | DISPFlagDefinition
-// CHECK-MSVC: !DISubprogram(name: "`dynamic atexit destructor for 
'array'",{{.*}} line: 16,{{.*}}: DISPFlagLocalToUnit | DISPFlagDefinition
-// CHECK-MSVC: !DISubprogram(name: "`dynamic atexit destructor for 
'stat'",{{.*}} line: 19,{{.*}}: DISPFlagLocalToUnit | DISPFlagDefinition
+// CHECK-MSVC: !DISubprogram(name: "`dynamic atexit destructor for 
'array'",{{.*}}: DISPFlagLocalToUnit | DISPFlagDefinition
+// CHECK-MSVC: !DISubprogram(name: "`dynamic atexit destructor for 
'stat'",{{.*}}: DISPFlagLocalToUnit | DISPFlagDefinition
 
 // MSVC does weird stuff when templates are involved, so we don't match 
exactly,
 // but these names are reasonable.
 // FIXME: These should not be marked DISPFlagLocalToUnit.
 // CHECK-MSVC: !DISubprogram(name: "FooTpl::`dynamic initializer for 
'sdm_tpl'",{{.*}} line: 29,{{.*}}: DISPFlagLocalToUnit | DISPFlagDefinition
-// CHECK-MSVC: !DISubprogram(name: "FooTpl::`dynamic atexit destructor 
for 'sdm_tpl'",{{.*}} line: 29,{{.*}}: DISPFlagLocalToUnit | 
DISPFlagDefinition
+// CHECK-MSVC: !DISubprogram(name: "FooTpl::`dynamic atexit destructor 
for 'sdm_tpl'",{{.*}}: DISPFlagLocalToUnit | DISPFlagDefinition
Index: test/CodeGenCXX/debug-info-atexit-stub.cpp
===
--- test/CodeGenCXX/debug-info-atexit-stub.cpp
+++ test/CodeGenCXX/debug-info-atexit-stub.cpp
@@ -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(::e); return  }
+
+// 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]])
Index: lib/CodeGen/CGDeclCXX.cpp
===
--- lib/CodeGen/CGDeclCXX.cpp
+++ lib/CodeGen/CGDeclCXX.cpp
@@ -247,6 +247,8 @@
 
   CGF.StartFunction(GlobalDecl(, DynamicInitKind::AtExit),
 CGM.getContext().VoidTy, fn, FI, 

[PATCH] D65906: [clang-scan-deps] Fix edge cases in the minimizer

2019-08-21 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea abandoned this revision.
aganea added a comment.

Please see the other reviews I've sent.


Repository:
  rC Clang

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

https://reviews.llvm.org/D65906



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


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

2019-08-21 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea updated this revision to Diff 216474.
aganea added a comment.

Use proper test file.


Repository:
  rC Clang

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

https://reviews.llvm.org/D66556

Files:
  lib/Lex/DependencyDirectivesSourceMinimizer.cpp
  test/Lexer/minimize_source_to_dependency_directives_invalid_error.c

Index: test/Lexer/minimize_source_to_dependency_directives_invalid_error.c
===
--- test/Lexer/minimize_source_to_dependency_directives_invalid_error.c
+++ test/Lexer/minimize_source_to_dependency_directives_invalid_error.c
@@ -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
Index: lib/Lex/DependencyDirectivesSourceMinimizer.cpp
===
--- lib/Lex/DependencyDirectivesSourceMinimizer.cpp
+++ lib/Lex/DependencyDirectivesSourceMinimizer.cpp
@@ -196,15 +196,27 @@
 ++First; // Finish off the string.
 }
 
-static void skipNewline(const char *, 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]);
+}
 
-  // Check for "\n\r" and "\r\n".
-  if (LLVM_UNLIKELY(isVerticalWhitespace(*First) && First[-1] != First[0]))
-++First;
+// Returns the length of the skipped newline
+static unsigned skipNewline(const char *, const char *End) {
+  assert(isVerticalWhitespace(*First));
+  unsigned Len = isEOL(First, End);
+  assert(Len);
+  First += Len;
+  return Len;
+}
+
+static bool wasLineContinuation(const char *First, unsigned Len) {
+  return *(First - (int)Len - 1) == '\\';
 }
 
 static void skipToNewlineRaw(const char *, const char *const End) {
@@ -212,17 +224,22 @@
 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);
+
+First += Len;
 
-if (First[-1] != '\\')
+if (!wasLineContinuation(First, Len))
   return;
 
-++First; // Keep going...
+// Keep skipping lines...
   }
 }
 
@@ -277,7 +294,7 @@
 }
 
 static void skipLine(const char *, const char *const End) {
-  do {
+  for (;;) {
 assert(First <= End);
 if (First == End)
   return;
@@ -322,9 +339,10 @@
   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 *,
@@ -379,6 +397,8 @@
 // Print out the string.
 if (Last == End || Last == First || Last[-1] != '\\') {
   append(First, reverseOverSpaces(First, Last));
+  First = Last;
+  skipNewline(First, End);
   return;
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2019-08-21 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea created this revision.
aganea added reviewers: arphaman, dexonsmith, Bigcheese.
aganea added a project: clang.
Herald added a subscriber: tschuett.

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


Repository:
  rC Clang

https://reviews.llvm.org/D66556

Files:
  lib/Lex/DependencyDirectivesSourceMinimizer.cpp
  test/Lexer/minimize_source_to_dependency_directives_include.c

Index: test/Lexer/minimize_source_to_dependency_directives_include.c
===
--- test/Lexer/minimize_source_to_dependency_directives_include.c
+++ test/Lexer/minimize_source_to_dependency_directives_include.c
@@ -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 
Index: lib/Lex/DependencyDirectivesSourceMinimizer.cpp
===
--- lib/Lex/DependencyDirectivesSourceMinimizer.cpp
+++ lib/Lex/DependencyDirectivesSourceMinimizer.cpp
@@ -196,15 +196,27 @@
 ++First; // Finish off the string.
 }
 
-static void skipNewline(const char *, 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]);
+}
 
-  // Check for "\n\r" and "\r\n".
-  if (LLVM_UNLIKELY(isVerticalWhitespace(*First) && First[-1] != First[0]))
-++First;
+// Returns the length of the skipped newline
+static unsigned skipNewline(const char *, const char *End) {
+  assert(isVerticalWhitespace(*First));
+  unsigned Len = isEOL(First, End);
+  assert(Len);
+  First += Len;
+  return Len;
+}
+
+static bool wasLineContinuation(const char *First, unsigned Len) {
+  return *(First - (int)Len - 1) == '\\';
 }
 
 static void skipToNewlineRaw(const char *, const char *const End) {
@@ -212,17 +224,22 @@
 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);
+
+First += Len;
 
-if (First[-1] != '\\')
+if (!wasLineContinuation(First, Len))
   return;
 
-++First; // Keep going...
+// Keep skipping lines...
   }
 }
 
@@ -277,7 +294,7 @@
 }
 
 static void skipLine(const char *, const char *const End) {
-  do {
+  for (;;) {
 assert(First <= End);
 if (First == End)
   return;
@@ -322,9 +339,10 @@
   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 *,
@@ -379,6 +397,8 @@
 // Print out the string.
 if (Last == End || Last == First || Last[-1] != '\\') {
   append(First, reverseOverSpaces(First, Last));
+  First = Last;
+  skipNewline(First, End);
   return;
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2019-08-21 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea created this revision.
aganea added reviewers: arphaman, dexonsmith, Bigcheese.
aganea added a project: clang.
Herald added a subscriber: tschuett.
aganea retitled this revision from "[clang-scan-deps] Correctly skip over 
double slashes in angle bracket #include" to "[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 `


Repository:
  rC Clang

https://reviews.llvm.org/D66550

Files:
  lib/Lex/DependencyDirectivesSourceMinimizer.cpp
  test/Lexer/minimize_source_to_dependency_directives_include.c


Index: test/Lexer/minimize_source_to_dependency_directives_include.c
===
--- test/Lexer/minimize_source_to_dependency_directives_include.c
+++ test/Lexer/minimize_source_to_dependency_directives_include.c
@@ -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 
Index: lib/Lex/DependencyDirectivesSourceMinimizer.cpp
===
--- lib/Lex/DependencyDirectivesSourceMinimizer.cpp
+++ lib/Lex/DependencyDirectivesSourceMinimizer.cpp
@@ -186,8 +186,8 @@
 }
 
 static void skipString(const char *, 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)
@@ -344,7 +344,8 @@
 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


Index: test/Lexer/minimize_source_to_dependency_directives_include.c
===
--- test/Lexer/minimize_source_to_dependency_directives_include.c
+++ test/Lexer/minimize_source_to_dependency_directives_include.c
@@ -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 
Index: lib/Lex/DependencyDirectivesSourceMinimizer.cpp
===
--- lib/Lex/DependencyDirectivesSourceMinimizer.cpp
+++ lib/Lex/DependencyDirectivesSourceMinimizer.cpp
@@ -186,8 +186,8 @@
 }
 
 static void skipString(const char *, 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)
@@ -344,7 +344,8 @@
 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
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D66328: [DebugInfo] Add debug location to dynamic atexit destructor

2019-08-20 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea updated this revision to Diff 216233.
aganea marked 2 inline comments as done.

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

https://reviews.llvm.org/D66328

Files:
  lib/CodeGen/CGDebugInfo.cpp
  lib/CodeGen/CGDeclCXX.cpp
  test/CodeGenCXX/debug-info-atexit-stub.cpp
  test/CodeGenCXX/debug-info-global-ctor-dtor.cpp


Index: test/CodeGenCXX/debug-info-global-ctor-dtor.cpp
===
--- test/CodeGenCXX/debug-info-global-ctor-dtor.cpp
+++ test/CodeGenCXX/debug-info-global-ctor-dtor.cpp
@@ -30,24 +30,24 @@
 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(name: "`dynamic initializer for 'glob'",{{.*}} 
line: 15,{{.*}}: DISPFlagLocalToUnit | DISPFlagDefinition
-// CHECK-MSVC: !DISubprogram(name: "`dynamic atexit destructor for 
'glob'",{{.*}} line: 15,{{.*}}: DISPFlagLocalToUnit | DISPFlagDefinition
+// CHECK-MSVC: !DISubprogram(name: "`dynamic atexit destructor for 
'glob'",{{.*}}: DISPFlagLocalToUnit | DISPFlagDefinition
 // CHECK-MSVC: !DISubprogram(name: "`dynamic initializer for 'array'",{{.*}} 
line: 16,{{.*}}: DISPFlagLocalToUnit | DISPFlagDefinition
 // CHECK-MSVC: !DISubprogram(name: "__cxx_global_array_dtor",{{.*}} line: 
16,{{.*}}: DISPFlagLocalToUnit | DISPFlagDefinition
-// CHECK-MSVC: !DISubprogram(name: "`dynamic atexit destructor for 
'array'",{{.*}} line: 16,{{.*}}: DISPFlagLocalToUnit | DISPFlagDefinition
-// CHECK-MSVC: !DISubprogram(name: "`dynamic atexit destructor for 
'stat'",{{.*}} line: 19,{{.*}}: DISPFlagLocalToUnit | DISPFlagDefinition
+// CHECK-MSVC: !DISubprogram(name: "`dynamic atexit destructor for 
'array'",{{.*}}: DISPFlagLocalToUnit | DISPFlagDefinition
+// CHECK-MSVC: !DISubprogram(name: "`dynamic atexit destructor for 
'stat'",{{.*}}: DISPFlagLocalToUnit | DISPFlagDefinition
 
 // MSVC does weird stuff when templates are involved, so we don't match 
exactly,
 // but these names are reasonable.
 // FIXME: These should not be marked DISPFlagLocalToUnit.
 // CHECK-MSVC: !DISubprogram(name: "FooTpl::`dynamic initializer for 
'sdm_tpl'",{{.*}} line: 29,{{.*}}: DISPFlagLocalToUnit | DISPFlagDefinition
-// CHECK-MSVC: !DISubprogram(name: "FooTpl::`dynamic atexit destructor 
for 'sdm_tpl'",{{.*}} line: 29,{{.*}}: DISPFlagLocalToUnit | 
DISPFlagDefinition
+// CHECK-MSVC: !DISubprogram(name: "FooTpl::`dynamic atexit destructor 
for 'sdm_tpl'",{{.*}}: DISPFlagLocalToUnit | DISPFlagDefinition
Index: test/CodeGenCXX/debug-info-atexit-stub.cpp
===
--- test/CodeGenCXX/debug-info-atexit-stub.cpp
+++ 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::*)());
+};
+struct B {
+  virtual void e();
+};
+c *d() { static c f(::e); return  }
+
+// 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]])
Index: lib/CodeGen/CGDeclCXX.cpp
===
--- lib/CodeGen/CGDeclCXX.cpp
+++ lib/CodeGen/CGDeclCXX.cpp
@@ -247,6 +247,8 @@
 
   CGF.StartFunction(GlobalDecl(, DynamicInitKind::AtExit),
 CGM.getContext().VoidTy, fn, FI, FunctionArgList());
+  // 

[PATCH] D66328: [DebugInfo] Add debug location to dynamic atexit destructor

2019-08-20 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea added inline comments.



Comment at: test/CodeGenCXX/debug-info-atexit-stub.cpp:14
+
+// CHECK: define internal void @"??__Ff@?1??d@@YAPEAU?$c@UBXZ@YAXXZ"()
+// CHECK-SAME: !dbg ![[SUBPROGRAM:[0-9]+]] {

probinson wrote:
> Do these Windows-mangled names work on Linux?
Ensure Microsoft mangling is always used.


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

https://reviews.llvm.org/D66328



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


[PATCH] D66328: [DebugInfo] Add debug location to dynamic atexit destructor

2019-08-20 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea added a comment.

Thank you!


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

https://reviews.llvm.org/D66328



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


[PATCH] D66511: [clang-scan-deps] Skip UTF-8 BOM in source minimizer

2019-08-20 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea created this revision.
aganea added reviewers: arphaman, dexonsmith, Bigcheese.
aganea added a project: clang.
Herald added a subscriber: tschuett.

As per title.


Repository:
  rC Clang

https://reviews.llvm.org/D66511

Files:
  lib/Lex/DependencyDirectivesSourceMinimizer.cpp
  test/Lexer/minimize_source_to_dependency_directives_utf8bom.c


Index: test/Lexer/minimize_source_to_dependency_directives_utf8bom.c
===
--- test/Lexer/minimize_source_to_dependency_directives_utf8bom.c
+++ test/Lexer/minimize_source_to_dependency_directives_utf8bom.c
@@ -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
Index: lib/Lex/DependencyDirectivesSourceMinimizer.cpp
===
--- lib/Lex/DependencyDirectivesSourceMinimizer.cpp
+++ lib/Lex/DependencyDirectivesSourceMinimizer.cpp
@@ -812,7 +812,14 @@
   return lexDefault(Kind, Id.Name, First, End);
 }
 
+static void skipUTF8ByteOrderMark(const char *, 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;


Index: test/Lexer/minimize_source_to_dependency_directives_utf8bom.c
===
--- test/Lexer/minimize_source_to_dependency_directives_utf8bom.c
+++ test/Lexer/minimize_source_to_dependency_directives_utf8bom.c
@@ -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
Index: lib/Lex/DependencyDirectivesSourceMinimizer.cpp
===
--- lib/Lex/DependencyDirectivesSourceMinimizer.cpp
+++ lib/Lex/DependencyDirectivesSourceMinimizer.cpp
@@ -812,7 +812,14 @@
   return lexDefault(Kind, Id.Name, First, End);
 }
 
+static void skipUTF8ByteOrderMark(const char *, 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;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D66328: [DebugInfo] Add debug location to dynamic atexit destructor

2019-08-20 Thread Alexandre Ganea via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL369458: [DebugInfo] Add debug location to dynamic atexit 
destructor (authored by aganea, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D66328?vs=216233=216263#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D66328

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


Index: cfe/trunk/test/CodeGenCXX/debug-info-global-ctor-dtor.cpp
===
--- cfe/trunk/test/CodeGenCXX/debug-info-global-ctor-dtor.cpp
+++ cfe/trunk/test/CodeGenCXX/debug-info-global-ctor-dtor.cpp
@@ -30,24 +30,24 @@
 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(name: "`dynamic initializer for 'glob'",{{.*}} 
line: 15,{{.*}}: DISPFlagLocalToUnit | DISPFlagDefinition
-// CHECK-MSVC: !DISubprogram(name: "`dynamic atexit destructor for 
'glob'",{{.*}} line: 15,{{.*}}: DISPFlagLocalToUnit | DISPFlagDefinition
+// CHECK-MSVC: !DISubprogram(name: "`dynamic atexit destructor for 
'glob'",{{.*}}: DISPFlagLocalToUnit | DISPFlagDefinition
 // CHECK-MSVC: !DISubprogram(name: "`dynamic initializer for 'array'",{{.*}} 
line: 16,{{.*}}: DISPFlagLocalToUnit | DISPFlagDefinition
 // CHECK-MSVC: !DISubprogram(name: "__cxx_global_array_dtor",{{.*}} line: 
16,{{.*}}: DISPFlagLocalToUnit | DISPFlagDefinition
-// CHECK-MSVC: !DISubprogram(name: "`dynamic atexit destructor for 
'array'",{{.*}} line: 16,{{.*}}: DISPFlagLocalToUnit | DISPFlagDefinition
-// CHECK-MSVC: !DISubprogram(name: "`dynamic atexit destructor for 
'stat'",{{.*}} line: 19,{{.*}}: DISPFlagLocalToUnit | DISPFlagDefinition
+// CHECK-MSVC: !DISubprogram(name: "`dynamic atexit destructor for 
'array'",{{.*}}: DISPFlagLocalToUnit | DISPFlagDefinition
+// CHECK-MSVC: !DISubprogram(name: "`dynamic atexit destructor for 
'stat'",{{.*}}: DISPFlagLocalToUnit | DISPFlagDefinition
 
 // MSVC does weird stuff when templates are involved, so we don't match 
exactly,
 // but these names are reasonable.
 // FIXME: These should not be marked DISPFlagLocalToUnit.
 // CHECK-MSVC: !DISubprogram(name: "FooTpl::`dynamic initializer for 
'sdm_tpl'",{{.*}} line: 29,{{.*}}: DISPFlagLocalToUnit | DISPFlagDefinition
-// CHECK-MSVC: !DISubprogram(name: "FooTpl::`dynamic atexit destructor 
for 'sdm_tpl'",{{.*}} line: 29,{{.*}}: DISPFlagLocalToUnit | 
DISPFlagDefinition
+// CHECK-MSVC: !DISubprogram(name: "FooTpl::`dynamic atexit destructor 
for 'sdm_tpl'",{{.*}}: DISPFlagLocalToUnit | DISPFlagDefinition
Index: cfe/trunk/test/CodeGenCXX/debug-info-atexit-stub.cpp
===
--- cfe/trunk/test/CodeGenCXX/debug-info-atexit-stub.cpp
+++ cfe/trunk/test/CodeGenCXX/debug-info-atexit-stub.cpp
@@ -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(::e); return  }
+
+// 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]] = 

[PATCH] D63648: [Preprocessor] Honor absolute paths in diagnostics

2019-08-20 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea added a comment.

In D63648#1593619 , @thakis wrote:

> - Does fastbuild have something like distcc-pump?


Fastbuild works like plain distcc and unfortunately it does not have pump mode.

> - IIRC we used to use fdiagnostics-absolute-paths in Chromium but eventually 
> stopped because someone figured out how to make MSVC's jump-to-diag work even 
> with relative paths (?)

Let me know if you find out what was your solution ;) Otherwise we could 
absolutize paths in Fastbuild.

While I think we will go the relative paths route -  do you think the changes 
in this patch related to `--show-includes` and `note:` make sense? Could 
`-fdiagnostics-absolute-paths` affect `--show-includes` as well? I am just 
wondering. Otherwise I'll drop the patch.


Repository:
  rC Clang

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

https://reviews.llvm.org/D63648



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


[PATCH] D66511: [clang-scan-deps] Skip UTF-8 BOM in source minimizer

2019-08-24 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea marked an inline comment as done.
aganea added inline comments.



Comment at: lib/Lex/DependencyDirectivesSourceMinimizer.cpp:822
 bool Minimizer::minimizeImpl(const char *First, const char *const End) {
+  skipUTF8ByteOrderMark(First, End);
   while (First != End)

dexonsmith wrote:
> Is skipping this the right thing, or should it also be copied to the output?
The code in `Lexer::InitLexer()` assumes the files are always encoded as UTF-8, 
it simply skips over the BOM like we do here.


Repository:
  rC Clang

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

https://reviews.llvm.org/D66511



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


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

2019-08-26 Thread Alexandre Ganea via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL369988: [clang-scan-deps] Minimizer: Correctly skip over 
double slashes in angle… (authored by aganea, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D66550?vs=216461=217264#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D66550

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


Index: cfe/trunk/test/Lexer/minimize_source_to_dependency_directives_include.c
===
--- cfe/trunk/test/Lexer/minimize_source_to_dependency_directives_include.c
+++ cfe/trunk/test/Lexer/minimize_source_to_dependency_directives_include.c
@@ -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 
Index: cfe/trunk/lib/Lex/DependencyDirectivesSourceMinimizer.cpp
===
--- cfe/trunk/lib/Lex/DependencyDirectivesSourceMinimizer.cpp
+++ cfe/trunk/lib/Lex/DependencyDirectivesSourceMinimizer.cpp
@@ -186,8 +186,8 @@
 }
 
 static void skipString(const char *, 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 @@
 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


Index: cfe/trunk/test/Lexer/minimize_source_to_dependency_directives_include.c
===
--- cfe/trunk/test/Lexer/minimize_source_to_dependency_directives_include.c
+++ cfe/trunk/test/Lexer/minimize_source_to_dependency_directives_include.c
@@ -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 
Index: cfe/trunk/lib/Lex/DependencyDirectivesSourceMinimizer.cpp
===
--- cfe/trunk/lib/Lex/DependencyDirectivesSourceMinimizer.cpp
+++ cfe/trunk/lib/Lex/DependencyDirectivesSourceMinimizer.cpp
@@ -186,8 +186,8 @@
 }
 
 static void skipString(const char *, 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 @@
 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
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2019-08-26 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea updated this revision to Diff 217292.
aganea added a reviewer: rsmith.
aganea added a comment.

This failed the build - I've changed `unix2dos` to `svn:eol-style CRLF` instead.


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

https://reviews.llvm.org/D66556

Files:
  lib/Lex/DependencyDirectivesSourceMinimizer.cpp
  test/Lexer/minimize_source_to_dependency_directives_invalid_error.c

Index: test/Lexer/minimize_source_to_dependency_directives_invalid_error.c
===
--- test/Lexer/minimize_source_to_dependency_directives_invalid_error.c
+++ test/Lexer/minimize_source_to_dependency_directives_invalid_error.c
@@ -1,5 +1,5 @@
 // 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
+// RUN: %clang_cc1 -DOTHER -print-dependency-directives-minimized-source %s 2>&1 | FileCheck %s
 
 #ifndef TEST
 #error "message \
Index: lib/Lex/DependencyDirectivesSourceMinimizer.cpp
===
--- lib/Lex/DependencyDirectivesSourceMinimizer.cpp
+++ lib/Lex/DependencyDirectivesSourceMinimizer.cpp
@@ -196,15 +196,29 @@
 ++First; // Finish off the string.
 }
 
-static void skipNewline(const char *, 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]);
+}
 
-  // Check for "\n\r" and "\r\n".
-  if (LLVM_UNLIKELY(isVerticalWhitespace(*First) && First[-1] != First[0]))
-++First;
+// Returns the length of the skipped newline
+static unsigned skipNewline(const char *, const char *End) {
+  if (First == End)
+return 0;
+  assert(isVerticalWhitespace(*First));
+  unsigned Len = isEOL(First, End);
+  assert(Len && "expected newline");
+  First += Len;
+  return Len;
+}
+
+static bool wasLineContinuation(const char *First, unsigned EOLLen) {
+  return *(First - (int)EOLLen - 1) == '\\';
 }
 
 static void skipToNewlineRaw(const char *, const char *const End) {
@@ -212,17 +226,21 @@
 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 void skipLine(const char *, const char *const End) {
-  do {
+  for (;;) {
 assert(First <= End);
 if (First == End)
   return;
@@ -322,9 +340,10 @@
   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 *,
@@ -380,6 +399,8 @@
 // Print out the string.
 if (Last == End || Last == First || Last[-1] != '\\') {
   append(First, reverseOverSpaces(First, Last));
+  First = Last;
+  skipNewline(First, End);
   return;
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D66328: [DebugInfo] Add debug location to dynamic atexit destructor

2019-08-26 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea updated this revision to Diff 217298.

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

https://reviews.llvm.org/D66328

Files:
  lib/CodeGen/CGDebugInfo.cpp
  lib/CodeGen/CGDeclCXX.cpp
  test/CodeGenCXX/debug-info-atexit-stub.cpp
  test/CodeGenCXX/debug-info-destroy-helper.cpp
  test/CodeGenCXX/debug-info-global-ctor-dtor.cpp
  test/CodeGenCXX/debug-info-line.cpp

Index: test/CodeGenCXX/debug-info-line.cpp
===
--- test/CodeGenCXX/debug-info-line.cpp
+++ test/CodeGenCXX/debug-info-line.cpp
@@ -314,7 +314,7 @@
 // CHECK: [[DBG_F9]] = !DILocation(line: 1000,
 // CHECK: [[DBG_F10_STORE]] = !DILocation(line: 1100,
 // CHECK: [[DBG_GLBL_CTOR_B]] = !DILocation(line: 1200,
-// CHECK: [[DBG_GLBL_DTOR_B]] = !DILocation(line: 1200,
+// CHECK: [[DBG_GLBL_DTOR_B]] = !DILocation(line: 0,
 // CHECK: [[DBG_F11]] = !DILocation(line: 1300,
 // CHECK: [[DBG_F12]] = !DILocation(line: 1400,
 // CHECK: [[DBG_F13]] = !DILocation(line: 1500,
Index: test/CodeGenCXX/debug-info-global-ctor-dtor.cpp
===
--- test/CodeGenCXX/debug-info-global-ctor-dtor.cpp
+++ test/CodeGenCXX/debug-info-global-ctor-dtor.cpp
@@ -30,24 +30,24 @@
 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(name: "`dynamic initializer for 'glob'",{{.*}} line: 15,{{.*}}: DISPFlagLocalToUnit | DISPFlagDefinition
-// CHECK-MSVC: !DISubprogram(name: "`dynamic atexit destructor for 'glob'",{{.*}} line: 15,{{.*}}: DISPFlagLocalToUnit | DISPFlagDefinition
+// CHECK-MSVC: !DISubprogram(name: "`dynamic atexit destructor for 'glob'",{{.*}}: DISPFlagLocalToUnit | DISPFlagDefinition
 // CHECK-MSVC: !DISubprogram(name: "`dynamic initializer for 'array'",{{.*}} line: 16,{{.*}}: DISPFlagLocalToUnit | DISPFlagDefinition
 // CHECK-MSVC: !DISubprogram(name: "__cxx_global_array_dtor",{{.*}} line: 16,{{.*}}: DISPFlagLocalToUnit | DISPFlagDefinition
-// CHECK-MSVC: !DISubprogram(name: "`dynamic atexit destructor for 'array'",{{.*}} line: 16,{{.*}}: DISPFlagLocalToUnit | DISPFlagDefinition
-// CHECK-MSVC: !DISubprogram(name: "`dynamic atexit destructor for 'stat'",{{.*}} line: 19,{{.*}}: DISPFlagLocalToUnit | DISPFlagDefinition
+// CHECK-MSVC: !DISubprogram(name: "`dynamic atexit destructor for 'array'",{{.*}}: DISPFlagLocalToUnit | DISPFlagDefinition
+// CHECK-MSVC: !DISubprogram(name: "`dynamic atexit destructor for 'stat'",{{.*}}: DISPFlagLocalToUnit | DISPFlagDefinition
 
 // MSVC does weird stuff when templates are involved, so we don't match exactly,
 // but these names are reasonable.
 // FIXME: These should not be marked DISPFlagLocalToUnit.
 // CHECK-MSVC: !DISubprogram(name: "FooTpl::`dynamic initializer for 'sdm_tpl'",{{.*}} line: 29,{{.*}}: DISPFlagLocalToUnit | DISPFlagDefinition
-// CHECK-MSVC: !DISubprogram(name: "FooTpl::`dynamic atexit destructor for 'sdm_tpl'",{{.*}} line: 29,{{.*}}: DISPFlagLocalToUnit | DISPFlagDefinition
+// CHECK-MSVC: !DISubprogram(name: "FooTpl::`dynamic atexit destructor for 'sdm_tpl'",{{.*}}: DISPFlagLocalToUnit | DISPFlagDefinition
\ No newline at end of file
Index: test/CodeGenCXX/debug-info-destroy-helper.cpp
===
--- test/CodeGenCXX/debug-info-destroy-helper.cpp
+++ test/CodeGenCXX/debug-info-destroy-helper.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 b {
+  b(char *);
+  ~b();
+};
+struct a {
+  ~a();
+};
+struct {
+  b c;
+  const a 
+} e[]{nullptr, {}};
+
+// CHECK: arraydestroy.body
+// CHECK: %arraydestroy.elementPast =
+// CHECK-SAME: !dbg ![[LOCATION:[0-9]+]]
+// CHECK: call void @"??1@@QEAA@XZ"(%struct.anon* 

[PATCH] D66511: [clang-scan-deps] Skip UTF-8 BOM in source minimizer

2019-08-26 Thread Alexandre Ganea via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL369993: [clang-scan-deps] Skip UTF-8 BOM in source minimizer 
(authored by aganea, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D66511?vs=216311=217275#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D66511

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


Index: cfe/trunk/lib/Lex/DependencyDirectivesSourceMinimizer.cpp
===
--- cfe/trunk/lib/Lex/DependencyDirectivesSourceMinimizer.cpp
+++ cfe/trunk/lib/Lex/DependencyDirectivesSourceMinimizer.cpp
@@ -834,7 +834,14 @@
   return lexDefault(Kind, Id.Name, First, End);
 }
 
+static void skipUTF8ByteOrderMark(const char *, 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;
Index: cfe/trunk/test/Lexer/minimize_source_to_dependency_directives_utf8bom.c
===
--- cfe/trunk/test/Lexer/minimize_source_to_dependency_directives_utf8bom.c
+++ cfe/trunk/test/Lexer/minimize_source_to_dependency_directives_utf8bom.c
@@ -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


Index: cfe/trunk/lib/Lex/DependencyDirectivesSourceMinimizer.cpp
===
--- cfe/trunk/lib/Lex/DependencyDirectivesSourceMinimizer.cpp
+++ cfe/trunk/lib/Lex/DependencyDirectivesSourceMinimizer.cpp
@@ -834,7 +834,14 @@
   return lexDefault(Kind, Id.Name, First, End);
 }
 
+static void skipUTF8ByteOrderMark(const char *, 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;
Index: cfe/trunk/test/Lexer/minimize_source_to_dependency_directives_utf8bom.c
===
--- cfe/trunk/test/Lexer/minimize_source_to_dependency_directives_utf8bom.c
+++ cfe/trunk/test/Lexer/minimize_source_to_dependency_directives_utf8bom.c
@@ -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


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

2019-08-26 Thread Alexandre Ganea via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL369986: [clang-scan-deps] Minimizer: Correctly handle 
multi-line content with CR+LF… (authored by aganea, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D66556?vs=217179=217262#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D66556

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

Index: cfe/trunk/lib/Lex/DependencyDirectivesSourceMinimizer.cpp
===
--- cfe/trunk/lib/Lex/DependencyDirectivesSourceMinimizer.cpp
+++ cfe/trunk/lib/Lex/DependencyDirectivesSourceMinimizer.cpp
@@ -196,15 +196,29 @@
 ++First; // Finish off the string.
 }
 
-static void skipNewline(const char *, 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]);
+}
 
-  // Check for "\n\r" and "\r\n".
-  if (LLVM_UNLIKELY(isVerticalWhitespace(*First) && First[-1] != First[0]))
-++First;
+// Returns the length of the skipped newline
+static unsigned skipNewline(const char *, const char *End) {
+  if (First == End)
+return 0;
+  assert(isVerticalWhitespace(*First));
+  unsigned Len = isEOL(First, End);
+  assert(Len && "expected newline");
+  First += Len;
+  return Len;
+}
+
+static bool wasLineContinuation(const char *First, unsigned EOLLen) {
+  return *(First - (int)EOLLen - 1) == '\\';
 }
 
 static void skipToNewlineRaw(const char *, const char *const End) {
@@ -212,17 +226,21 @@
 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 void skipLine(const char *, const char *const End) {
-  do {
+  for (;;) {
 assert(First <= End);
 if (First == End)
   return;
@@ -322,9 +340,10 @@
   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 *,
@@ -379,6 +398,8 @@
 // Print out the string.
 if (Last == End || Last == First || Last[-1] != '\\') {
   append(First, reverseOverSpaces(First, Last));
+  First = Last;
+  skipNewline(First, End);
   return;
 }
 
Index: cfe/trunk/test/Lexer/minimize_source_to_dependency_directives_invalid_error.c
===
--- cfe/trunk/test/Lexer/minimize_source_to_dependency_directives_invalid_error.c
+++ cfe/trunk/test/Lexer/minimize_source_to_dependency_directives_invalid_error.c
@@ -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


[PATCH] D66328: [DebugInfo] Add debug location to dynamic atexit destructor

2019-08-26 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea reopened this revision.
aganea added a reviewer: hans.
aganea added a comment.
This revision is now accepted and ready to land.

Re-opening this because the previous commit broke 
 Chromium.

- Added a new test `debug-info-destroy-helper.cpp` to cover the Chromium issue.
- Also added `CGDeclCXX.cpp, L775` to create an artificial location for 
`__cxx_global_array_dtor`.

Would you possibly please take another look?


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

https://reviews.llvm.org/D66328



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


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

2019-08-26 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea updated this revision to Diff 217179.
aganea added a comment.

Fixed unit tests.


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

https://reviews.llvm.org/D66556

Files:
  lib/Lex/DependencyDirectivesSourceMinimizer.cpp
  test/Lexer/minimize_source_to_dependency_directives_invalid_error.c

Index: test/Lexer/minimize_source_to_dependency_directives_invalid_error.c
===
--- test/Lexer/minimize_source_to_dependency_directives_invalid_error.c
+++ test/Lexer/minimize_source_to_dependency_directives_invalid_error.c
@@ -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
Index: lib/Lex/DependencyDirectivesSourceMinimizer.cpp
===
--- lib/Lex/DependencyDirectivesSourceMinimizer.cpp
+++ lib/Lex/DependencyDirectivesSourceMinimizer.cpp
@@ -196,15 +196,29 @@
 ++First; // Finish off the string.
 }
 
-static void skipNewline(const char *, 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]);
+}
 
-  // Check for "\n\r" and "\r\n".
-  if (LLVM_UNLIKELY(isVerticalWhitespace(*First) && First[-1] != First[0]))
-++First;
+// Returns the length of the skipped newline
+static unsigned skipNewline(const char *, const char *End) {
+  if (First == End)
+return 0;
+  assert(isVerticalWhitespace(*First));
+  unsigned Len = isEOL(First, End);
+  assert(Len && "expected newline");
+  First += Len;
+  return Len;
+}
+
+static bool wasLineContinuation(const char *First, unsigned EOLLen) {
+  return *(First - (int)EOLLen - 1) == '\\';
 }
 
 static void skipToNewlineRaw(const char *, const char *const End) {
@@ -212,17 +226,21 @@
 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 void skipLine(const char *, const char *const End) {
-  do {
+  for (;;) {
 assert(First <= End);
 if (First == End)
   return;
@@ -322,9 +340,10 @@
   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 *,
@@ -379,6 +398,8 @@
 // Print out the string.
 if (Last == End || Last == First || Last[-1] != '\\') {
   append(First, reverseOverSpaces(First, Last));
+  First = Last;
+  skipNewline(First, End);
   return;
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2019-08-27 Thread Alexandre Ganea via Phabricator via cfe-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rL370129: Re-land [clang-scan-deps] Minimizer: Correctly 
handle multi-line content with… (authored by aganea, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D66556?vs=217527=217535#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D66556

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

Index: cfe/trunk/test/Lexer/minimize_source_to_dependency_directives_invalid_error.c
===
--- cfe/trunk/test/Lexer/minimize_source_to_dependency_directives_invalid_error.c
+++ cfe/trunk/test/Lexer/minimize_source_to_dependency_directives_invalid_error.c
@@ -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
Index: cfe/trunk/.gitattributes
===
--- cfe/trunk/.gitattributes
+++ cfe/trunk/.gitattributes
@@ -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
Index: cfe/trunk/lib/Lex/DependencyDirectivesSourceMinimizer.cpp
===
--- cfe/trunk/lib/Lex/DependencyDirectivesSourceMinimizer.cpp
+++ cfe/trunk/lib/Lex/DependencyDirectivesSourceMinimizer.cpp
@@ -196,15 +196,29 @@
 ++First; // Finish off the string.
 }
 
-static void skipNewline(const char *, 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]);
+}
 
-  // Check for "\n\r" and "\r\n".
-  if (LLVM_UNLIKELY(isVerticalWhitespace(*First) && First[-1] != First[0]))
-++First;
+// Returns the length of the skipped newline
+static unsigned skipNewline(const char *, const char *End) {
+  if (First == End)
+return 0;
+  assert(isVerticalWhitespace(*First));
+  unsigned Len = isEOL(First, End);
+  assert(Len && "expected newline");
+  First += Len;
+  return Len;
+}
+
+static bool wasLineContinuation(const char *First, unsigned EOLLen) {
+  return *(First - (int)EOLLen - 1) == '\\';
 }
 
 static void skipToNewlineRaw(const char *, const char *const End) {
@@ -212,17 +226,21 @@
 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 void skipLine(const char *, const char *const End) {
-  do {
+  for (;;) {
 assert(First <= End);
 if (First == End)
   return;
@@ -322,9 +340,10 @@
   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 *,
@@ -380,6 +399,8 @@
 // Print out the string.
 if (Last == End || Last == First || Last[-1] != '\\') {
   append(First, reverseOverSpaces(First, Last));
+  First = Last;
+  skipNewline(First, End);
   return;
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2019-08-27 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea updated this revision to Diff 217527.
aganea added subscribers: jyknight, rnk.
aganea added a comment.

In D66556#1647669 , @arphaman wrote:

> Will the git monorepo handle `svn:eol-style` correctly?


Other files in the repo already use `svn:eol-style`. I'm not sure what happens 
with SVN properties when commits are replicated in git. @jyknight @rnk ? I've 
added `.gitattributes` to ensure these files are checked out from git with the 
proper line ending.


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

https://reviews.llvm.org/D66556

Files:
  .gitattributes
  lib/Lex/DependencyDirectivesSourceMinimizer.cpp
  test/Lexer/minimize_source_to_dependency_directives_invalid_error.c

Index: test/Lexer/minimize_source_to_dependency_directives_invalid_error.c
===
--- test/Lexer/minimize_source_to_dependency_directives_invalid_error.c
+++ test/Lexer/minimize_source_to_dependency_directives_invalid_error.c
@@ -1,5 +1,5 @@
 // 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
+// RUN: %clang_cc1 -DOTHER -print-dependency-directives-minimized-source %s 2>&1 | FileCheck %s
 
 #ifndef TEST
 #error "message \
Index: lib/Lex/DependencyDirectivesSourceMinimizer.cpp
===
--- lib/Lex/DependencyDirectivesSourceMinimizer.cpp
+++ lib/Lex/DependencyDirectivesSourceMinimizer.cpp
@@ -196,15 +196,29 @@
 ++First; // Finish off the string.
 }
 
-static void skipNewline(const char *, 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]);
+}
 
-  // Check for "\n\r" and "\r\n".
-  if (LLVM_UNLIKELY(isVerticalWhitespace(*First) && First[-1] != First[0]))
-++First;
+// Returns the length of the skipped newline
+static unsigned skipNewline(const char *, const char *End) {
+  if (First == End)
+return 0;
+  assert(isVerticalWhitespace(*First));
+  unsigned Len = isEOL(First, End);
+  assert(Len && "expected newline");
+  First += Len;
+  return Len;
+}
+
+static bool wasLineContinuation(const char *First, unsigned EOLLen) {
+  return *(First - (int)EOLLen - 1) == '\\';
 }
 
 static void skipToNewlineRaw(const char *, const char *const End) {
@@ -212,17 +226,21 @@
 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 void skipLine(const char *, const char *const End) {
-  do {
+  for (;;) {
 assert(First <= End);
 if (First == End)
   return;
@@ -322,9 +340,10 @@
   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 *,
@@ -380,6 +399,8 @@
 // Print out the string.
 if (Last == End || Last == First || Last[-1] != '\\') {
   append(First, reverseOverSpaces(First, Last));
+  First = Last;
+  skipNewline(First, End);
   return;
 }
 
Index: .gitattributes
===
--- .gitattributes
+++ .gitattributes
@@ -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
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D66328: [DebugInfo] Add debug location to stubs generated by CGDeclCXX and mark them as artificial

2019-09-03 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea marked an inline comment as done.
aganea added inline comments.



Comment at: lib/CodeGen/CGDebugInfo.cpp:3581
+llvm::DILocalScope *PrevScope =
+!LexicalBlockStack.empty()
+? dyn_cast(LexicalBlockStack.back())

aganea wrote:
> rnk wrote:
> > Is it OK to look up the lexical block stack at this point? The block stack 
> > isn't function local, it's part of CGDebugInfo, which is for the whole 
> > module, unlike CodeGenFunction. If we start emitting one of these thunks 
> > while we're emitting some other function, we could get some strange 
> > results. Does anything ensure we've pushed at least one scope by the time 
> > we come here?
> You're right, it was looking too much like smart code. Replaced by a new flag 
> `DynamicInitKind::Global` to make explicit the decision to emit an artificial 
> function.
Actually, it is `DynamicInitKind::GlobalDestructor`, sorry about that.


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

https://reviews.llvm.org/D66328



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


[PATCH] D66328: [DebugInfo] Add debug location to stubs generated by CGDeclCXX and mark them as artificial

2019-09-03 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea added inline comments.



Comment at: lib/CodeGen/CGDebugInfo.cpp:3581
+llvm::DILocalScope *PrevScope =
+!LexicalBlockStack.empty()
+? dyn_cast(LexicalBlockStack.back())

rnk wrote:
> Is it OK to look up the lexical block stack at this point? The block stack 
> isn't function local, it's part of CGDebugInfo, which is for the whole 
> module, unlike CodeGenFunction. If we start emitting one of these thunks 
> while we're emitting some other function, we could get some strange results. 
> Does anything ensure we've pushed at least one scope by the time we come here?
You're right, it was looking too much like smart code. Replaced by a new flag 
`DynamicInitKind::Global` to make explicit the decision to emit an artificial 
function.


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

https://reviews.llvm.org/D66328



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


[PATCH] D66328: [DebugInfo] Add debug location to stubs generated by CGDeclCXX and mark them as artificial

2019-09-03 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea updated this revision to Diff 218515.
aganea marked 2 inline comments as done.

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

https://reviews.llvm.org/D66328

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

Index: test/CodeGenCXX/debug-info-line.cpp
===
--- test/CodeGenCXX/debug-info-line.cpp
+++ test/CodeGenCXX/debug-info-line.cpp
@@ -314,7 +314,7 @@
 // CHECK: [[DBG_F9]] = !DILocation(line: 1000,
 // CHECK: [[DBG_F10_STORE]] = !DILocation(line: 1100,
 // CHECK: [[DBG_GLBL_CTOR_B]] = !DILocation(line: 1200,
-// CHECK: [[DBG_GLBL_DTOR_B]] = !DILocation(line: 1200,
+// CHECK: [[DBG_GLBL_DTOR_B]] = !DILocation(line: 0,
 // CHECK: [[DBG_F11]] = !DILocation(line: 1300,
 // CHECK: [[DBG_F12]] = !DILocation(line: 1400,
 // CHECK: [[DBG_F13]] = !DILocation(line: 1500,
Index: test/CodeGenCXX/debug-info-global-ctor-dtor.cpp
===
--- test/CodeGenCXX/debug-info-global-ctor-dtor.cpp
+++ test/CodeGenCXX/debug-info-global-ctor-dtor.cpp
@@ -29,25 +29,26 @@
 A FooTpl::sdm_tpl(sizeof(U) + sizeof(T));
 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: "__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: "__cxx_global_var_init",{{.*}} flags: DIFlagArtificial, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition
+// CHECK-NOKEXT: !DISubprogram(name: "__dtor_glob",{{.*}} flags: DIFlagArtificial, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition
+// CHECK-NOKEXT: !DISubprogram(name: "__cxx_global_var_init.1",{{.*}} flags: DIFlagArtificial, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition
+// CHECK-NOKEXT: !DISubprogram(name: "__cxx_global_array_dtor",{{.*}} flags: DIFlagArtificial, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition
+// CHECK-NOKEXT: !DISubprogram(name: "__dtor_array",{{.*}} flags: DIFlagArtificial, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition
+// CHECK-NOKEXT: !DISubprogram(name: "__dtor__ZZ3foovE4stat",{{.*}} flags: DIFlagArtificial, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition
 // CHECK-NOKEXT: !DISubprogram({{.*}} DISPFlagLocalToUnit | DISPFlagDefinition
 
 // CHECK-KEXT: !DISubprogram({{.*}} DISPFlagLocalToUnit | DISPFlagDefinition
 
-// CHECK-MSVC: !DISubprogram(name: "`dynamic initializer for 'glob'",{{.*}} line: 15,{{.*}}: DISPFlagLocalToUnit | DISPFlagDefinition
-// CHECK-MSVC: !DISubprogram(name: "`dynamic atexit destructor for 'glob'",{{.*}} line: 15,{{.*}}: DISPFlagLocalToUnit | DISPFlagDefinition
-// CHECK-MSVC: !DISubprogram(name: "`dynamic initializer for 'array'",{{.*}} line: 16,{{.*}}: DISPFlagLocalToUnit | DISPFlagDefinition
-// CHECK-MSVC: !DISubprogram(name: "__cxx_global_array_dtor",{{.*}} line: 16,{{.*}}: DISPFlagLocalToUnit | DISPFlagDefinition
-// CHECK-MSVC: !DISubprogram(name: "`dynamic atexit destructor for 'array'",{{.*}} line: 16,{{.*}}: DISPFlagLocalToUnit | DISPFlagDefinition
-// CHECK-MSVC: !DISubprogram(name: "`dynamic atexit destructor for 'stat'",{{.*}} line: 19,{{.*}}: DISPFlagLocalToUnit | DISPFlagDefinition
+// CHECK-MSVC: !DISubprogram(name: "`dynamic initializer for 'glob'",{{.*}} flags: DIFlagArtificial, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition
+// CHECK-MSVC: !DISubprogram(name: "`dynamic atexit destructor for 'glob'",{{.*}} flags: DIFlagArtificial, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition
+// CHECK-MSVC: !DISubprogram(name: "`dynamic initializer for 'array'",{{.*}} flags: DIFlagArtificial, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition
+// CHECK-MSVC: !DISubprogram(name: "__cxx_global_array_dtor",{{.*}} flags: DIFlagArtificial, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition
+// CHECK-MSVC: !DISubprogram(name: "`dynamic atexit destructor for 'array'",{{.*}} flags: DIFlagArtificial, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition
+// CHECK-MSVC: !DISubprogram(name: "`dynamic atexit destructor for 'stat'",{{.*}} flags: DIFlagArtificial, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition
 
 // MSVC does weird stuff when templates are involved, so we don't match exactly,
 

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

2019-08-28 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea added a comment.

In D66556#1648591 , @hans wrote:

> In D66556#1648118 , @dexonsmith 
> wrote:
>
> > In D66556#1648109 , @rnk wrote:
> >
> > > I'm not sure what happens, but I see you added .gitattributes. I'd commit 
> > > it as is. Buildbots using svn will keep working. You can check that the 
> > > monorepo has the right line endings afterwards, and try again if not.
> >
> >
> > SGTM.
>
>
> This broke users of the monorepo, where the file would show up as having 
> changed locally, and with no way to reset it. I'm guessing that's because it 
> was checked in with LF endings and then because of the .gitattributes file, 
> it changes at checkout. I think the correct solution would be to check in the 
> file with CRLF endings and not set any attributes or stuff. (Though this is 
> all super confusing and I might have got it wrong.)
>
> I've deleted the test file in r370175 to unblock development in the meantime.


It already had CRLF endings locally before commit.
It is strange, the file shows up as having CRLF endings in the old revision in 
git, before the revert: 
https://raw.githubusercontent.com/llvm/llvm-project/9774a2ba279aea35f166b8ca489d0e8292026c38/clang/test/Lexer/minimize_source_to_dependency_directives_invalid_error.c
The same kind of problem occured in rL311683 
, later fixed by rL311732 
.
If you're fine with that, I'll do the same thing: remove `.gitattributes` and 
just re-commit the file 
`minimize_source_to_dependency_directives_invalid_error.c` with `svn:eol-style 
CRLF`.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D66556



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


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

2019-08-28 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea added a comment.

rL370219  and rG3c307370c8f8 



Repository:
  rL LLVM

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

https://reviews.llvm.org/D66556



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


[PATCH] D66328: [DebugInfo] Add debug location to stubs generated by CGDeclCXX and mark them as artificial

2019-08-29 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea updated this revision to Diff 217968.
aganea retitled this revision from "[DebugInfo] Add debug location to dynamic 
atexit destructor" to "[DebugInfo] Add debug location to stubs generated by 
CGDeclCXX and mark them as artificial".
aganea added a comment.

More tagging functions as artificial.


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

https://reviews.llvm.org/D66328

Files:
  lib/CodeGen/CGDebugInfo.cpp
  lib/CodeGen/CGDeclCXX.cpp
  test/CodeGenCXX/debug-info-atexit-stub.cpp
  test/CodeGenCXX/debug-info-destroy-helper.cpp
  test/CodeGenCXX/debug-info-global-ctor-dtor.cpp
  test/CodeGenCXX/debug-info-line.cpp

Index: test/CodeGenCXX/debug-info-line.cpp
===
--- test/CodeGenCXX/debug-info-line.cpp
+++ test/CodeGenCXX/debug-info-line.cpp
@@ -314,7 +314,7 @@
 // CHECK: [[DBG_F9]] = !DILocation(line: 1000,
 // CHECK: [[DBG_F10_STORE]] = !DILocation(line: 1100,
 // CHECK: [[DBG_GLBL_CTOR_B]] = !DILocation(line: 1200,
-// CHECK: [[DBG_GLBL_DTOR_B]] = !DILocation(line: 1200,
+// CHECK: [[DBG_GLBL_DTOR_B]] = !DILocation(line: 0,
 // CHECK: [[DBG_F11]] = !DILocation(line: 1300,
 // CHECK: [[DBG_F12]] = !DILocation(line: 1400,
 // CHECK: [[DBG_F13]] = !DILocation(line: 1500,
Index: test/CodeGenCXX/debug-info-global-ctor-dtor.cpp
===
--- test/CodeGenCXX/debug-info-global-ctor-dtor.cpp
+++ test/CodeGenCXX/debug-info-global-ctor-dtor.cpp
@@ -29,25 +29,26 @@
 A FooTpl::sdm_tpl(sizeof(U) + sizeof(T));
 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: "__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: "__cxx_global_var_init",{{.*}} flags: DIFlagArtificial, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition
+// CHECK-NOKEXT: !DISubprogram(name: "__dtor_glob",{{.*}} flags: DIFlagArtificial, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition
+// CHECK-NOKEXT: !DISubprogram(name: "__cxx_global_var_init.1",{{.*}} flags: DIFlagArtificial, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition
+// CHECK-NOKEXT: !DISubprogram(name: "__cxx_global_array_dtor",{{.*}} flags: DIFlagArtificial | DIFlagPrototyped, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition
+// CHECK-NOKEXT: !DISubprogram(name: "__dtor_array",{{.*}} flags: DIFlagArtificial, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition
+// CHECK-NOKEXT: !DISubprogram(name: "__dtor__ZZ3foovE4stat",{{.*}} flags: DIFlagArtificial, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition
 // CHECK-NOKEXT: !DISubprogram({{.*}} DISPFlagLocalToUnit | DISPFlagDefinition
 
 // CHECK-KEXT: !DISubprogram({{.*}} DISPFlagLocalToUnit | DISPFlagDefinition
 
-// CHECK-MSVC: !DISubprogram(name: "`dynamic initializer for 'glob'",{{.*}} line: 15,{{.*}}: DISPFlagLocalToUnit | DISPFlagDefinition
-// CHECK-MSVC: !DISubprogram(name: "`dynamic atexit destructor for 'glob'",{{.*}} line: 15,{{.*}}: DISPFlagLocalToUnit | DISPFlagDefinition
-// CHECK-MSVC: !DISubprogram(name: "`dynamic initializer for 'array'",{{.*}} line: 16,{{.*}}: DISPFlagLocalToUnit | DISPFlagDefinition
-// CHECK-MSVC: !DISubprogram(name: "__cxx_global_array_dtor",{{.*}} line: 16,{{.*}}: DISPFlagLocalToUnit | DISPFlagDefinition
-// CHECK-MSVC: !DISubprogram(name: "`dynamic atexit destructor for 'array'",{{.*}} line: 16,{{.*}}: DISPFlagLocalToUnit | DISPFlagDefinition
-// CHECK-MSVC: !DISubprogram(name: "`dynamic atexit destructor for 'stat'",{{.*}} line: 19,{{.*}}: DISPFlagLocalToUnit | DISPFlagDefinition
+// CHECK-MSVC: !DISubprogram(name: "`dynamic initializer for 'glob'",{{.*}} flags: DIFlagArtificial, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition
+// CHECK-MSVC: !DISubprogram(name: "`dynamic atexit destructor for 'glob'",{{.*}} flags: DIFlagArtificial, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition
+// CHECK-MSVC: !DISubprogram(name: "`dynamic initializer for 'array'",{{.*}} flags: DIFlagArtificial, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition
+// CHECK-MSVC: !DISubprogram(name: "__cxx_global_array_dtor",{{.*}} flags: DIFlagArtificial | DIFlagPrototyped, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition
+// CHECK-MSVC: !DISubprogram(name: "`dynamic atexit destructor for 'array'",{{.*}} flags: DIFlagArtificial, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition
+// CHECK-MSVC: 

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

2019-08-25 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea updated this revision to Diff 217055.
aganea marked 2 inline comments as done.
aganea added a comment.

As requested.


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

https://reviews.llvm.org/D66556

Files:
  lib/Lex/DependencyDirectivesSourceMinimizer.cpp
  test/Lexer/minimize_source_to_dependency_directives_invalid_error.c

Index: test/Lexer/minimize_source_to_dependency_directives_invalid_error.c
===
--- test/Lexer/minimize_source_to_dependency_directives_invalid_error.c
+++ test/Lexer/minimize_source_to_dependency_directives_invalid_error.c
@@ -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
Index: lib/Lex/DependencyDirectivesSourceMinimizer.cpp
===
--- lib/Lex/DependencyDirectivesSourceMinimizer.cpp
+++ lib/Lex/DependencyDirectivesSourceMinimizer.cpp
@@ -196,15 +196,27 @@
 ++First; // Finish off the string.
 }
 
-static void skipNewline(const char *, 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]);
+}
 
-  // Check for "\n\r" and "\r\n".
-  if (LLVM_UNLIKELY(isVerticalWhitespace(*First) && First[-1] != First[0]))
-++First;
+// Returns the length of the skipped newline
+static unsigned skipNewline(const char *, const char *End) {
+  assert(isVerticalWhitespace(*First));
+  unsigned Len = isEOL(First, End);
+  assert(Len && "expected newline");
+  First += Len;
+  return Len;
+}
+
+static bool wasLineContinuation(const char *First, unsigned EOLLen) {
+  return *(First - (int)EOLLen - 1) == '\\';
 }
 
 static void skipToNewlineRaw(const char *, const char *const End) {
@@ -212,17 +224,21 @@
 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 +293,7 @@
 }
 
 static void skipLine(const char *, const char *const End) {
-  do {
+  for (;;) {
 assert(First <= End);
 if (First == End)
   return;
@@ -322,9 +338,10 @@
   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 *,
@@ -379,6 +396,8 @@
 // Print out the string.
 if (Last == End || Last == First || Last[-1] != '\\') {
   append(First, reverseOverSpaces(First, Last));
+  First = Last;
+  skipNewline(First, End);
   return;
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D66328: [DebugInfo] Add debug location to dynamic atexit destructor

2019-08-27 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea added a comment.

In D66328#1647062 , @probinson wrote:

> I don't see a test for the __cxx_global_array_dtor case?


It is actually the `arraydestroy.*` loop that is covered (generated by 
`CodeGenFunction::emitArrayDestroy`), please see 
`debug-info-destroy-helper.cpp` below.


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

https://reviews.llvm.org/D66328



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


[PATCH] D66328: [DebugInfo] Add debug location to stubs generated by CGDeclCXX and mark them as artificial

2019-09-05 Thread Alexandre Ganea via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL371080: [DebugInfo] Add debug location to stubs generated by 
CGDeclCXX and mark them as… (authored by aganea, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D66328?vs=218515=218928#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D66328

Files:
  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-atexit-stub.cpp
  cfe/trunk/test/CodeGenCXX/debug-info-destroy-helper.cpp
  cfe/trunk/test/CodeGenCXX/debug-info-global-ctor-dtor.cpp
  cfe/trunk/test/CodeGenCXX/debug-info-line.cpp

Index: cfe/trunk/lib/CodeGen/CGDeclCXX.cpp
===
--- cfe/trunk/lib/CodeGen/CGDeclCXX.cpp
+++ cfe/trunk/lib/CodeGen/CGDeclCXX.cpp
@@ -247,6 +247,8 @@
 
   CGF.StartFunction(GlobalDecl(, 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 @@
 
   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 @@
 
   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);
 
Index: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
===
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
@@ -1910,7 +1910,8 @@
  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 @@
 
   switch (StubKind) {
   case DynamicInitKind::NoStub:
+  case DynamicInitKind::GlobalArrayDestructor:
 llvm_unreachable("not an initializer");
   case DynamicInitKind::Initializer:
 OS << "`dynamic initializer for '";
@@ -3569,7 +3571,8 @@
   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();
Index: cfe/trunk/include/clang/AST/GlobalDecl.h
===
--- cfe/trunk/include/clang/AST/GlobalDecl.h
+++ cfe/trunk/include/clang/AST/GlobalDecl.h
@@ -31,6 +31,7 @@
   NoStub = 0,
   Initializer,
   AtExit,
+  GlobalArrayDestructor
 };
 
 /// GlobalDecl - represents a global declaration. This can either be a
Index: cfe/trunk/test/CodeGenCXX/debug-info-atexit-stub.cpp
===
--- cfe/trunk/test/CodeGenCXX/debug-info-atexit-stub.cpp
+++ cfe/trunk/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::*)());
+};
+struct B {
+  virtual void e();
+};
+c *d() { static c f(::e); return  }
+
+// 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]])
\ No newline at end of file

  1   2   3   4   5   >