[PATCH] D66862: Make lround builtin constexpr (and others)

2019-09-11 Thread Zoe Carver via Phabricator via cfe-commits
zoecarver added a comment.

Ping. Anything else I am missing?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66862



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


[PATCH] D67208: [WebAssembly] Add -fwasm-exceptions for wasm EH

2019-09-11 Thread Heejin Ahn via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL371708: [WebAssembly] Add -fwasm-exceptions for wasm EH 
(authored by aheejin, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D67208?vs=219203=219846#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D67208

Files:
  cfe/trunk/include/clang/Basic/LangOptions.def
  cfe/trunk/include/clang/Driver/Options.td
  cfe/trunk/lib/CodeGen/BackendUtil.cpp
  cfe/trunk/lib/CodeGen/CGException.cpp
  cfe/trunk/lib/Driver/ToolChains/Clang.cpp
  cfe/trunk/lib/Driver/ToolChains/WebAssembly.cpp
  cfe/trunk/lib/Frontend/CompilerInvocation.cpp
  cfe/trunk/test/CodeGenCXX/wasm-eh.cpp
  cfe/trunk/test/Driver/wasm-toolchain.c

Index: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
===
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp
@@ -4981,9 +4981,9 @@
 addExceptionArgs(Args, InputType, TC, KernelOrKext, Runtime, CmdArgs);
 
   // Handle exception personalities
-  Arg *A = Args.getLastArg(options::OPT_fsjlj_exceptions,
-   options::OPT_fseh_exceptions,
-   options::OPT_fdwarf_exceptions);
+  Arg *A = Args.getLastArg(
+  options::OPT_fsjlj_exceptions, options::OPT_fseh_exceptions,
+  options::OPT_fdwarf_exceptions, options::OPT_fwasm_exceptions);
   if (A) {
 const Option  = A->getOption();
 if (Opt.matches(options::OPT_fsjlj_exceptions))
@@ -4992,6 +4992,8 @@
   CmdArgs.push_back("-fseh-exceptions");
 if (Opt.matches(options::OPT_fdwarf_exceptions))
   CmdArgs.push_back("-fdwarf-exceptions");
+if (Opt.matches(options::OPT_fwasm_exceptions))
+  CmdArgs.push_back("-fwasm-exceptions");
   } else {
 switch (TC.GetExceptionModel(Args)) {
 default:
Index: cfe/trunk/lib/Driver/ToolChains/WebAssembly.cpp
===
--- cfe/trunk/lib/Driver/ToolChains/WebAssembly.cpp
+++ cfe/trunk/lib/Driver/ToolChains/WebAssembly.cpp
@@ -166,6 +166,26 @@
 CC1Args.push_back("-target-feature");
 CC1Args.push_back("+mutable-globals");
   }
+
+  if (DriverArgs.getLastArg(options::OPT_fwasm_exceptions)) {
+// '-fwasm-exceptions' is not compatible with '-mno-exception-handling'
+if (DriverArgs.hasFlag(options::OPT_mno_exception_handing,
+   options::OPT_mexception_handing, false))
+  getDriver().Diag(diag::err_drv_argument_not_allowed_with)
+  << "-fwasm-exceptions"
+  << "-mno-exception-handling";
+// '-fwasm-exceptions' is not compatible with
+// '-mllvm -enable-emscripten-cxx-exceptions'
+for (const Arg *A : DriverArgs.filtered(options::OPT_mllvm)) {
+  if (StringRef(A->getValue(0)) == "-enable-emscripten-cxx-exceptions")
+getDriver().Diag(diag::err_drv_argument_not_allowed_with)
+<< "-fwasm-exceptions"
+<< "-mllvm -enable-emscripten-cxx-exceptions";
+}
+// '-fwasm-exceptions' implies exception-handling
+CC1Args.push_back("-target-feature");
+CC1Args.push_back("+exception-handling");
+  }
 }
 
 ToolChain::RuntimeLibType WebAssembly::GetDefaultRuntimeLibType() const {
Index: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
===
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp
@@ -2686,9 +2686,9 @@
   Opts.FixedPoint;
 
   // Handle exception personalities
-  Arg *A = Args.getLastArg(options::OPT_fsjlj_exceptions,
-   options::OPT_fseh_exceptions,
-   options::OPT_fdwarf_exceptions);
+  Arg *A = Args.getLastArg(
+  options::OPT_fsjlj_exceptions, options::OPT_fseh_exceptions,
+  options::OPT_fdwarf_exceptions, options::OPT_fwasm_exceptions);
   if (A) {
 const Option  = A->getOption();
 llvm::Triple T(TargetOpts.Triple);
@@ -2699,6 +2699,7 @@
 Opts.SjLjExceptions = Opt.matches(options::OPT_fsjlj_exceptions);
 Opts.SEHExceptions = Opt.matches(options::OPT_fseh_exceptions);
 Opts.DWARFExceptions = Opt.matches(options::OPT_fdwarf_exceptions);
+Opts.WasmExceptions = Opt.matches(options::OPT_fwasm_exceptions);
   }
 
   Opts.ExternCNoUnwind = Args.hasArg(OPT_fexternc_nounwind);
Index: cfe/trunk/lib/CodeGen/BackendUtil.cpp
===
--- cfe/trunk/lib/CodeGen/BackendUtil.cpp
+++ cfe/trunk/lib/CodeGen/BackendUtil.cpp
@@ -468,6 +468,8 @@
 Options.ExceptionModel = llvm::ExceptionHandling::WinEH;
   if (LangOpts.DWARFExceptions)
 Options.ExceptionModel = llvm::ExceptionHandling::DwarfCFI;
+  if (LangOpts.WasmExceptions)
+Options.ExceptionModel = llvm::ExceptionHandling::Wasm;
 
   

r371708 - [WebAssembly] Add -fwasm-exceptions for wasm EH

2019-09-11 Thread Heejin Ahn via cfe-commits
Author: aheejin
Date: Wed Sep 11 21:01:37 2019
New Revision: 371708

URL: http://llvm.org/viewvc/llvm-project?rev=371708=rev
Log:
[WebAssembly] Add -fwasm-exceptions for wasm EH

Summary:
This adds `-fwasm-exceptions` (in similar fashion with
`-fdwarf-exceptions` or `-fsjlj-exceptions`) that turns on everything
with wasm exception handling from the frontend to the backend.

We currently have `-mexception-handling` in clang frontend, but this is
only about the architecture capability and does not turn on other
necessary options such as the exception model in the backend. (This can
be turned on with `llc -exception-model=wasm`, but llc is not invoked
separately as a command line tool, so this option has to be transferred
from clang.)

Turning on `-fwasm-exceptions` in clang also turns on
`-mexception-handling` if not specified, and will error out if
`-mno-exception-handling` is specified.

Reviewers: dschuff, tlively, sbc100

Subscribers: aprantl, jgravelle-google, sunfish, cfe-commits

Tags: #clang

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

Modified:
cfe/trunk/include/clang/Basic/LangOptions.def
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/lib/CodeGen/BackendUtil.cpp
cfe/trunk/lib/CodeGen/CGException.cpp
cfe/trunk/lib/Driver/ToolChains/Clang.cpp
cfe/trunk/lib/Driver/ToolChains/WebAssembly.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/test/CodeGenCXX/wasm-eh.cpp
cfe/trunk/test/Driver/wasm-toolchain.c

Modified: cfe/trunk/include/clang/Basic/LangOptions.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/LangOptions.def?rev=371708=371707=371708=diff
==
--- cfe/trunk/include/clang/Basic/LangOptions.def (original)
+++ cfe/trunk/include/clang/Basic/LangOptions.def Wed Sep 11 21:01:37 2019
@@ -128,6 +128,7 @@ LANGOPT(CXXExceptions , 1, 0, "C++ e
 LANGOPT(DWARFExceptions   , 1, 0, "dwarf exception handling")
 LANGOPT(SjLjExceptions, 1, 0, "setjmp-longjump exception handling")
 LANGOPT(SEHExceptions , 1, 0, "SEH .xdata exception handling")
+LANGOPT(WasmExceptions, 1, 0, "WebAssembly exception handling")
 LANGOPT(ExternCNoUnwind   , 1, 0, "Assume extern C functions don't unwind")
 LANGOPT(TraditionalCPP, 1, 0, "traditional CPP emulation")
 LANGOPT(RTTI  , 1, 1, "run-time type information")

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=371708=371707=371708=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Wed Sep 11 21:01:37 2019
@@ -904,6 +904,8 @@ def fsjlj_exceptions : Flag<["-"], "fsjl
   Flags<[CC1Option]>, HelpText<"Use SjLj style exceptions">;
 def fseh_exceptions : Flag<["-"], "fseh-exceptions">, Group,
   Flags<[CC1Option]>, HelpText<"Use SEH style exceptions">;
+def fwasm_exceptions : Flag<["-"], "fwasm-exceptions">, Group,
+  Flags<[CC1Option]>, HelpText<"Use WebAssembly style exceptions">;
 def fexcess_precision_EQ : Joined<["-"], "fexcess-precision=">,
 Group;
 def : Flag<["-"], "fexpensive-optimizations">, 
Group;

Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=371708=371707=371708=diff
==
--- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original)
+++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Wed Sep 11 21:01:37 2019
@@ -468,6 +468,8 @@ static void initTargetOptions(llvm::Targ
 Options.ExceptionModel = llvm::ExceptionHandling::WinEH;
   if (LangOpts.DWARFExceptions)
 Options.ExceptionModel = llvm::ExceptionHandling::DwarfCFI;
+  if (LangOpts.WasmExceptions)
+Options.ExceptionModel = llvm::ExceptionHandling::Wasm;
 
   Options.NoInfsFPMath = CodeGenOpts.NoInfsFPMath;
   Options.NoNaNsFPMath = CodeGenOpts.NoNaNsFPMath;

Modified: cfe/trunk/lib/CodeGen/CGException.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGException.cpp?rev=371708=371707=371708=diff
==
--- cfe/trunk/lib/CodeGen/CGException.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGException.cpp Wed Sep 11 21:01:37 2019
@@ -165,10 +165,7 @@ static const EHPersonality 
 return EHPersonality::GNU_CPlusPlus;
   if (L.SEHExceptions)
 return EHPersonality::GNU_CPlusPlus_SEH;
-  // Wasm EH is a non-MVP feature for now.
-  if (Target.hasFeature("exception-handling") &&
-  (T.getArch() == llvm::Triple::wasm32 ||
-   T.getArch() == llvm::Triple::wasm64))
+  if (L.WasmExceptions)
 return EHPersonality::GNU_Wasm_CPlusPlus;
   return EHPersonality::GNU_CPlusPlus;
 }

Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
URL: 

[PATCH] D67473: [clang-tidy] Fix build with -DBUILD_SHARED_LIB=ON

2019-09-11 Thread Heejin Ahn via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL371706: [clang-tidy] Fix build with -DBUILD_SHARED_LIB=ON 
(authored by aheejin, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D67473?vs=219833=219843#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D67473

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


Index: clang-tools-extra/trunk/clang-tidy/CMakeLists.txt
===
--- clang-tools-extra/trunk/clang-tidy/CMakeLists.txt
+++ clang-tools-extra/trunk/clang-tidy/CMakeLists.txt
@@ -16,6 +16,7 @@
   ClangSACheckers
 
   LINK_LIBS
+  clangAnalysis
   clangAST
   clangASTMatchers
   clangBasic


Index: clang-tools-extra/trunk/clang-tidy/CMakeLists.txt
===
--- clang-tools-extra/trunk/clang-tidy/CMakeLists.txt
+++ clang-tools-extra/trunk/clang-tidy/CMakeLists.txt
@@ -16,6 +16,7 @@
   ClangSACheckers
 
   LINK_LIBS
+  clangAnalysis
   clangAST
   clangASTMatchers
   clangBasic
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D67473: [clang-tidy] Fix build with -DBUILD_SHARED_LIB=ON

2019-09-11 Thread Heejin Ahn via Phabricator via cfe-commits
aheejin added a comment.

I think that's it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67473



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


[clang-tools-extra] r371706 - [clang-tidy] Fix build with -DBUILD_SHARED_LIB=ON

2019-09-11 Thread Heejin Ahn via cfe-commits
Author: aheejin
Date: Wed Sep 11 20:10:57 2019
New Revision: 371706

URL: http://llvm.org/viewvc/llvm-project?rev=371706=rev
Log:
[clang-tidy] Fix build with -DBUILD_SHARED_LIB=ON

Summary: This fixes build failures with `-DBUILD_SHARED_LIB=ON` after D67419.

Reviewers: NoQ

Subscribers: mgorny, xazax.hun, cfe-commits

Tags: #clang

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

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

Modified: clang-tools-extra/trunk/clang-tidy/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/CMakeLists.txt?rev=371706=371705=371706=diff
==
--- clang-tools-extra/trunk/clang-tidy/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clang-tidy/CMakeLists.txt Wed Sep 11 20:10:57 2019
@@ -16,6 +16,7 @@ add_clang_library(clangTidy
   ClangSACheckers
 
   LINK_LIBS
+  clangAnalysis
   clangAST
   clangASTMatchers
   clangBasic


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


[PATCH] D67463: [MS] Warn when shadowing template parameters under -fms-compatibility

2019-09-11 Thread Nico Weber via Phabricator via cfe-commits
thakis accepted this revision.
thakis added a comment.
This revision is now accepted and ready to land.

Nice!

Hopefully this is rare enough that putting it under an existing warning flag 
won't be too inconvenient.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67463



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


[PATCH] D64943: [Clang][OpenMP offload] Eliminate use of OpenMP linker script

2019-09-11 Thread Sergey Dmitriev via Phabricator via cfe-commits
sdmitriev added a comment.

In D64943#1666924 , @JonChesterfield 
wrote:

> In D64943#1666849 , @sdmitriev wrote:
>
> > In D64943#136 , 
> > @JonChesterfield wrote:
> >
> > > I'm not sure copying the crtbegin/crtend mechanism from the early days of 
> > > C runtime is ideal. Since the data is stored in a common section anyway, 
> > > please could we rename it to __omp_offloading_entries in which case the 
> > > linker will provide start/end symbols automatically?
> >
> >
> > Well, I never said that it is an ideal solution, but it is a known 
> > mechanism that works well in many cases and can also be reused for the 
> > offloading entry table.
> >  I do not fully understand your suggestion for renaming entries section, 
> > how it will help with providing start/end symbols for the entries. Can you 
> > please provide more details?
>
>
> Given a custom elf section with a C identifier as a name, the linker will 
> provide definitions of `__start_name`/`__stop_name` to satisfy unresolved 
> symbols. I don't believe this occurs if the section name is not a C 
> identifier, e.g. contains a period. So unless I've misinterpreted the purpose 
> of the two object files, they can be removed in exchange for renaming the 
> section.
>
> - had to Google for the Microsoft equivalent, 
> https://stackoverflow.com/questions/3808053/how-to-get-a-pointer-to-a-binary-section-in-msvc


Hm, I was not aware of this Linux linker feature, thanks a lot for the 
explanation! I see only one problem with using it as a replacement for the 
begin/end objects – it looks like `__start_name`/`__stop_name` symbols are 
created with `default` visibility instead of `hidden`. I guess it will cause 
problems for offload programs that use shared libraries because DSO’s 
`__start_name`/`__stop_name` symbols will be preempted by the executable’s 
symbols and that is not what we want. Is there any way to change this behavior?

As for the Windows support, you are right, 
`__omp_offloading_entries_begin`/`__omp_offloading_entries_end` symbols can be 
defined in the wrapper bit-code file with a help of the sections grouping 
(https://docs.microsoft.com/en-us/windows/win32/Debug/pe-format#grouped-sections-object-only).
 We were going to add this code to the wrapper tool later while adding Windows 
support.


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

https://reviews.llvm.org/D64943



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


[PATCH] D67473: [clang-tidy] Fix build with -DBUILD_SHARED_LIB=ON

2019-09-11 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ accepted this revision.
NoQ added a comment.
This revision is now accepted and ready to land.

Aha, nice, thank you!!

Is this 
http://lab.llvm.org:8011/builders/clang-ppc64le-linux-multistage/builds/10728 ?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67473



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


r371697 - [clang-scan-deps] Add dependency targets

2019-09-11 Thread Jan Korous via cfe-commits
Author: jkorous
Date: Wed Sep 11 17:48:45 2019
New Revision: 371697

URL: http://llvm.org/viewvc/llvm-project?rev=371697=rev
Log:
[clang-scan-deps] Add dependency targets

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

Modified:
cfe/trunk/test/ClangScanDeps/Inputs/subframework_header_dir_symlink_cdb.json
cfe/trunk/test/ClangScanDeps/Inputs/symlink_cdb.json
cfe/trunk/test/ClangScanDeps/Inputs/vfsoverlay_cdb.json
cfe/trunk/test/ClangScanDeps/header_stat_before_open.m
cfe/trunk/test/ClangScanDeps/regular_cdb.cpp
cfe/trunk/test/ClangScanDeps/subframework_header_dir_symlink.m
cfe/trunk/test/ClangScanDeps/vfsoverlay.cpp
cfe/trunk/tools/clang-scan-deps/ClangScanDeps.cpp

Modified: 
cfe/trunk/test/ClangScanDeps/Inputs/subframework_header_dir_symlink_cdb.json
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ClangScanDeps/Inputs/subframework_header_dir_symlink_cdb.json?rev=371697=371696=371697=diff
==
--- 
cfe/trunk/test/ClangScanDeps/Inputs/subframework_header_dir_symlink_cdb.json 
(original)
+++ 
cfe/trunk/test/ClangScanDeps/Inputs/subframework_header_dir_symlink_cdb.json 
Wed Sep 11 17:48:45 2019
@@ -2,11 +2,11 @@
 {
   "directory": "DIR",
   "command": "clang -E DIR/subframework_header_dir_symlink_input.m -D EMPTY 
-iframework Inputs/frameworks",
-  "file": "DIR/subframework_header_dir_symlink.m"
+  "file": "DIR/subframework_header_dir_symlink_input.m"
 },
 {
   "directory": "DIR",
   "command": "clang -E DIR/subframework_header_dir_symlink_input2.m 
-FInputs/frameworks -iframework Inputs/frameworks_symlink",
-  "file": "DIR/subframework_header_dir_symlink2.m"
+  "file": "DIR/subframework_header_dir_symlink_input2.m"
 }
 ]

Modified: cfe/trunk/test/ClangScanDeps/Inputs/symlink_cdb.json
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ClangScanDeps/Inputs/symlink_cdb.json?rev=371697=371696=371697=diff
==
--- cfe/trunk/test/ClangScanDeps/Inputs/symlink_cdb.json (original)
+++ cfe/trunk/test/ClangScanDeps/Inputs/symlink_cdb.json Wed Sep 11 17:48:45 
2019
@@ -2,11 +2,11 @@
 {
   "directory": "DIR",
   "command": "clang -E DIR/symlink_input.cpp -IInputs",
-  "file": "DIR/symlink.cpp"
+  "file": "DIR/symlink_input.cpp"
 },
 {
   "directory": "DIR",
   "command": "clang -E DIR/symlink_input2.cpp -IInputs",
-  "file": "DIR/symlink2.cpp"
+  "file": "DIR/symlink_input2.cpp"
 }
 ]

Modified: cfe/trunk/test/ClangScanDeps/Inputs/vfsoverlay_cdb.json
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ClangScanDeps/Inputs/vfsoverlay_cdb.json?rev=371697=371696=371697=diff
==
--- cfe/trunk/test/ClangScanDeps/Inputs/vfsoverlay_cdb.json (original)
+++ cfe/trunk/test/ClangScanDeps/Inputs/vfsoverlay_cdb.json Wed Sep 11 17:48:45 
2019
@@ -2,6 +2,6 @@
 {
   "directory": "DIR",
   "command": "clang -E DIR/vfsoverlay_input.cpp -IInputs -ivfsoverlay 
DIR/vfsoverlay.yaml",
-  "file": "DIR/vfsoverlay.cpp"
+  "file": "DIR/vfsoverlay_input.cpp"
 }
 ]

Modified: cfe/trunk/test/ClangScanDeps/header_stat_before_open.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ClangScanDeps/header_stat_before_open.m?rev=371697=371696=371697=diff
==
--- cfe/trunk/test/ClangScanDeps/header_stat_before_open.m (original)
+++ cfe/trunk/test/ClangScanDeps/header_stat_before_open.m Wed Sep 11 17:48:45 
2019
@@ -12,7 +12,7 @@
 #include "Framework/Framework.h"
 #include "Framework/PrivateHeader.h"
 
-// CHECK: clang-scan-deps dependency
+// CHECK: header_stat_before_open_input.o
 // CHECK-NEXT: header_stat_before_open_input.m
 // CHECK-NEXT: 
Inputs{{/|\\}}frameworks{{/|\\}}Framework.framework{{/|\\}}Headers{{/|\\}}Framework.h
 // CHECK-NEXT: 
Inputs{{/|\\}}frameworks{{/|\\}}Framework.framework{{/|\\}}PrivateHeaders{{/|\\}}PrivateHeader.h

Modified: cfe/trunk/test/ClangScanDeps/regular_cdb.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ClangScanDeps/regular_cdb.cpp?rev=371697=371696=371697=diff
==
--- cfe/trunk/test/ClangScanDeps/regular_cdb.cpp (original)
+++ cfe/trunk/test/ClangScanDeps/regular_cdb.cpp Wed Sep 11 17:48:45 2019
@@ -36,6 +36,7 @@
 #include "header.h"
 
 // CHECK1: regular_cdb_input2.cpp
+// CHECK1-NEXT: regular_cdb_input2.cpp
 // CHECK1-NEXT: Inputs{{/|\\}}header.h
 // CHECK1-NEXT: Inputs{{/|\\}}header2.h
 

Modified: cfe/trunk/test/ClangScanDeps/subframework_header_dir_symlink.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ClangScanDeps/subframework_header_dir_symlink.m?rev=371697=371696=371697=diff
==
--- cfe/trunk/test/ClangScanDeps/subframework_header_dir_symlink.m (original)
+++ 

[PATCH] D67460: clang-tidy: modernize-use-using work with multi-argument templates

2019-09-11 Thread Conrad Poelman via Phabricator via cfe-commits
poelmanc added a comment.

Wow, thanks for the super-quick testing, feedback and a new test case! I added 
a slightly enhanced version of your test case to the modernize-use-using.cpp 
test file and got it passing by treating tok::less and tok::right as 
AngleBrackets //only when ParenLevel == 0//. See updated patch above. Holler if 
you think of any other stressing cases!

P.S. What do we think of actually handling the comma cases? (A) that's probably 
hard, and (B) as a C++ programmer I don't use them myself, so would we expand:

  typedef S<(0 < 0)> S_t, *S_p;

to:

  using S_t = S<(0 < 0)>;
  using S_p = S_t*;

?


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D67460



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


[PATCH] D67460: clang-tidy: modernize-use-using work with multi-argument templates

2019-09-11 Thread Conrad Poelman via Phabricator via cfe-commits
poelmanc updated this revision to Diff 219834.
poelmanc edited the summary of this revision.

Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D67460

Files:
  clang-tools-extra/clang-tidy/modernize/UseUsingCheck.cpp
  clang-tools-extra/test/clang-tidy/modernize-use-using.cpp


Index: clang-tools-extra/test/clang-tidy/modernize-use-using.cpp
===
--- clang-tools-extra/test/clang-tidy/modernize-use-using.cpp
+++ clang-tools-extra/test/clang-tidy/modernize-use-using.cpp
@@ -182,4 +182,22 @@
 class E : public C {
   void f() override { super::f(); }
 };
+
+template 
+class TwoArgTemplate {
+  typedef TwoArgTemplate self;
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use 'using' instead of 'typedef'
+  // CHECK-FIXES: using self = TwoArgTemplate;
+};
 }
+
+template 
+struct S {};
+
+typedef S<(0 > 0 && (3 < 1)), int> S_t, *S_p;
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use 'using' instead of 'typedef'
+// CHECK-FIXES: typedef S<(0 > 0 && (3 < 1)), int> S_t, *S_p;
+
+typedef S<(0 > 0 && (3 < 1)), int> S2_t;
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use 'using' instead of 'typedef'
+// CHECK-FIXES: using S2_t = S<(0 > 0 && (3 < 1)), int>;
Index: clang-tools-extra/clang-tidy/modernize/UseUsingCheck.cpp
===
--- clang-tools-extra/clang-tidy/modernize/UseUsingCheck.cpp
+++ clang-tools-extra/clang-tidy/modernize/UseUsingCheck.cpp
@@ -40,6 +40,7 @@
 
   Token Tok;
   int ParenLevel = 0;
+  int AngleBracketLevel = 0;
   bool FoundTypedef = false;
 
   while (!DeclLexer.LexFromRawLexer(Tok) && !Tok.is(tok::semi)) {
@@ -54,10 +55,20 @@
 case tok::r_paren:
   ParenLevel--;
   break;
+case tok::less:
+  // '<' starts a template if not within parentheses like (0 < 1)
+  if (ParenLevel == 0)
+AngleBracketLevel++;
+  break;
+case tok::greater:
+  // '>' ends a template if not within parentheses like (0 > 1)
+  if (ParenLevel == 0)
+AngleBracketLevel--;
+  break;
 case tok::comma:
-  if (ParenLevel == 0) {
-// If there is comma and we are not between open parenthesis then it is
-// two or more declarations in this chain.
+  if (ParenLevel == 0 && AngleBracketLevel == 0) {
+// If there is comma and we are not between open parenthesis or between
+// open angle brackets then it is two or more declarations in this 
chain.
 return false;
   }
   break;
@@ -88,8 +99,7 @@
   if (StartLoc.isMacroID() && IgnoreMacros)
 return;
 
-  auto Diag =
-  diag(StartLoc, "use 'using' instead of 'typedef'");
+  auto Diag = diag(StartLoc, "use 'using' instead of 'typedef'");
 
   // do not fix if there is macro or array
   if (MatchedDecl->getUnderlyingType()->isArrayType() || StartLoc.isMacroID())


Index: clang-tools-extra/test/clang-tidy/modernize-use-using.cpp
===
--- clang-tools-extra/test/clang-tidy/modernize-use-using.cpp
+++ clang-tools-extra/test/clang-tidy/modernize-use-using.cpp
@@ -182,4 +182,22 @@
 class E : public C {
   void f() override { super::f(); }
 };
+
+template 
+class TwoArgTemplate {
+  typedef TwoArgTemplate self;
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use 'using' instead of 'typedef'
+  // CHECK-FIXES: using self = TwoArgTemplate;
+};
 }
+
+template 
+struct S {};
+
+typedef S<(0 > 0 && (3 < 1)), int> S_t, *S_p;
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use 'using' instead of 'typedef'
+// CHECK-FIXES: typedef S<(0 > 0 && (3 < 1)), int> S_t, *S_p;
+
+typedef S<(0 > 0 && (3 < 1)), int> S2_t;
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use 'using' instead of 'typedef'
+// CHECK-FIXES: using S2_t = S<(0 > 0 && (3 < 1)), int>;
Index: clang-tools-extra/clang-tidy/modernize/UseUsingCheck.cpp
===
--- clang-tools-extra/clang-tidy/modernize/UseUsingCheck.cpp
+++ clang-tools-extra/clang-tidy/modernize/UseUsingCheck.cpp
@@ -40,6 +40,7 @@
 
   Token Tok;
   int ParenLevel = 0;
+  int AngleBracketLevel = 0;
   bool FoundTypedef = false;
 
   while (!DeclLexer.LexFromRawLexer(Tok) && !Tok.is(tok::semi)) {
@@ -54,10 +55,20 @@
 case tok::r_paren:
   ParenLevel--;
   break;
+case tok::less:
+  // '<' starts a template if not within parentheses like (0 < 1)
+  if (ParenLevel == 0)
+AngleBracketLevel++;
+  break;
+case tok::greater:
+  // '>' ends a template if not within parentheses like (0 > 1)
+  if (ParenLevel == 0)
+AngleBracketLevel--;
+  break;
 case tok::comma:
-  if (ParenLevel == 0) {
-// If there is comma and we are not between open parenthesis then it is
-// two or more declarations in this chain.
+  if (ParenLevel == 0 && AngleBracketLevel == 0) {
+// If 

Buildbot numbers for the week of 08/18/2019 - 08/24/2019

2019-09-11 Thread Galina Kistanova via cfe-commits
Hello everyone,

Below are some buildbot numbers for the week of 08/18/2019 - 08/24/2019.

Please see the same data in attached csv files:

The longest time each builder was red during the week;
"Status change ratio" by active builder (percent of builds that changed the
builder status from greed to red or from red to green);
Count of commits by project;
Number of completed builds, failed builds and average build time for
successful builds per active builder;
Average waiting time for a revision to get build result per active builder
(response time).

Thanks

Galina


The longest time each builder was red during the week:
  buildername  | was_red
---+-
 clang-native-arm-lnt-perf | 97:14:01
 libcxx-libcxxabi-x86_64-linux-ubuntu-32bit| 75:48:45
 sanitizer-ppc64le-linux   | 74:06:53
 clang-with-thin-lto-ubuntu| 73:48:18
 sanitizer-ppc64be-linux   | 73:07:19
 clang-with-lto-ubuntu | 72:14:44
 sanitizer-windows | 44:30:19
 sanitizer-x86_64-linux| 33:19:24
 libcxx-libcxxabi-x86_64-linux-ubuntu-ubsan| 33:02:19
 libcxx-libcxxabi-x86_64-linux-ubuntu-msan | 28:34:43
 libcxx-libcxxabi-x86_64-linux-ubuntu-cxx03| 28:26:45
 libcxx-libcxxabi-x86_64-linux-ubuntu-cxx17| 28:20:02
 libcxx-libcxxabi-x86_64-linux-ubuntu-cxx14| 28:16:02
 libcxx-libcxxabi-x86_64-linux-ubuntu-cxx2a| 27:57:33
 libcxx-libcxxabi-x86_64-linux-ubuntu-cxx11| 27:50:39
 libcxx-libcxxabi-x86_64-linux-ubuntu-tsan | 27:43:27
 libcxx-libcxxabi-libunwind-x86_64-linux-ubuntu| 27:33:07
 libcxx-libcxxabi-x86_64-linux-ubuntu-asan | 27:27:49
 sanitizer-x86_64-linux-bootstrap-ubsan| 22:49:22
 sanitizer-x86_64-linux-fast   | 21:41:42
 clang-cmake-aarch64-quick | 21:00:46
 clang-cmake-aarch64-global-isel   | 20:59:06
 sanitizer-x86_64-linux-bootstrap-msan | 20:06:35
 clang-cmake-aarch64-lld   | 19:25:07
 sanitizer-x86_64-linux-gn | 19:20:18
 lld-x86_64-darwin13   | 10:43:15
 clang-cmake-armv7-selfhost-neon   | 09:56:38
 clang-lld-x86_64-2stage   | 08:49:57
 sanitizer-x86_64-linux-android| 07:31:20
 llvm-clang-x86_64-expensive-checks-win| 06:54:55
 libcxx-libcxxabi-libunwind-aarch64-linux  | 05:49:06
 clang-ppc64le-linux-multistage| 05:48:06
 libcxx-libcxxabi-libunwind-armv8-linux| 05:44:11
 libcxx-libcxxabi-libunwind-aarch64-linux-noexceptions | 05:42:00
 libcxx-libcxxabi-libunwind-armv8-linux-noexceptions   | 05:36:10
 clang-cmake-aarch64-full  | 05:33:20
 clang-ppc64le-linux   | 05:25:31
 sanitizer-x86_64-linux-autoconf   | 05:24:50
 libcxx-libcxxabi-libunwind-armv7-linux| 05:23:03
 clang-cmake-armv7-full| 05:15:06
 libcxx-libcxxabi-libunwind-armv7-linux-noexceptions   | 05:06:52
 clang-cmake-armv8-lld | 04:37:20
 clang-x64-windows-msvc| 04:22:55
 clang-cmake-armv7-lnt | 04:16:47
 clang-ppc64be-linux-multistage| 04:13:25
 clang-cmake-armv7-selfhost| 04:12:10
 sanitizer-x86_64-linux-bootstrap  | 04:05:22
 clang-atom-d525-fedora-rel| 04:04:26
 clang-ppc64be-linux   | 03:59:01
 clang-ppc64be-linux-lnt   | 03:54:09
 lld-x86_64-ubuntu-fast| 03:44:18
 lld-x86_64-freebsd| 03:44:03
 lld-x86_64-win7   | 03:37:03
 sanitizer-x86_64-linux-fuzzer | 03:21:57
 clang-ppc64le-linux-lnt   | 03:06:39
 clang-cmake-x86_64-avx2-linux | 03:04:54
 clang-cmake-x86_64-sde-avx512-linux   | 03:03:34
 clang-cmake-x86_64-avx2-linux-perf| 02:57:09
 clang-cuda-build  | 02:47:47
 clang-cmake-armv7-global-isel | 02:32:20
 llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast| 02:27:06
 clang-x86_64-linux-abi-test   | 02:07:24
 llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast  | 02:05:00
 reverse-iteration | 01:59:49
 

Buildbot numbers for the week of 08/25/2019 - 08/31/2019

2019-09-11 Thread Galina Kistanova via cfe-commits
Hello everyone,

Below are some buildbot numbers for the week of 08/25/2019 - 08/31/2019.

Please see the same data in attached csv files:

The longest time each builder was red during the week;
"Status change ratio" by active builder (percent of builds that changed the
builder status from greed to red or from red to green);
Count of commits by project;
Number of completed builds, failed builds and average build time for
successful builds per active builder;
Average waiting time for a revision to get build result per active builder
(response time).

Thanks

Galina


The longest time each builder was red during the week:
 buildername |  was_red
-+--
 clang-lld-x86_64-2stage | 100:57:17
 lld-x86_64-darwin13 | 85:06:58
 aosp-O3-polly-before-vectorizer-unprofitable| 72:42:48
 sanitizer-x86_64-linux  | 68:19:24
 sanitizer-x86_64-linux-bootstrap-msan   | 53:39:49
 clang-cuda-build| 37:00:09
 sanitizer-x86_64-linux-gn   | 34:55:13
 llvm-clang-x86_64-expensive-checks-win  | 32:08:27
 lldb-x64-windows-ninja  | 31:50:15
 clang-cmake-armv7-full  | 31:35:28
 clang-ppc64be-linux | 26:38:36
 clang-cmake-aarch64-lld | 26:22:45
 clang-cmake-x86_64-sde-avx512-linux | 24:20:40
 llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast  | 24:12:13
 clang-cmake-x86_64-avx2-linux   | 23:27:09
 llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast| 22:58:41
 clang-cmake-thumbv7-full-sh | 22:32:07
 libcxx-libcxxabi-x86_64-linux-ubuntu-cxx03  | 21:26:40
 clang-cmake-x86_64-avx2-linux-perf  | 18:13:10
 lld-perf-testsuite  | 17:53:38
 sanitizer-x86_64-linux-fast | 17:53:09
 sanitizer-x86_64-linux-bootstrap-ubsan  | 17:21:01
 sanitizer-x86_64-linux-bootstrap| 15:18:28
 clang-ppc64be-linux-multistage  | 14:16:24
 clang-ppc64le-linux-lnt | 13:59:16
 clang-native-arm-lnt-perf   | 13:19:48
 sanitizer-ppc64be-linux | 13:05:00
 libcxx-libcxxabi-libunwind-armv8-linux-noexceptions | 11:59:47
 clang-cmake-armv8-lld   | 11:47:01
 clang-cmake-aarch64-quick   | 11:25:22
 sanitizer-x86_64-linux-autoconf | 11:18:44
 clang-cmake-armv7-selfhost-neon | 10:49:14
 clang-with-lto-ubuntu   | 10:43:06
 clang-with-thin-lto-ubuntu  | 10:40:43
 lld-sphinx-docs | 10:18:26
 libcxx-libcxxabi-x86_64-linux-ubuntu-ubsan  | 10:09:17
 clang-cmake-armv7-selfhost  | 10:07:29
 clang-cmake-armv7-quick | 10:03:59
 libcxx-sphinx-docs  | 09:58:17
 libcxx-libcxxabi-x86_64-linux-ubuntu-msan   | 09:50:32
 libcxx-libcxxabi-x86_64-linux-ubuntu-asan   | 09:45:51
 lld-x86_64-win7 | 09:41:08
 lld-x86_64-ubuntu-fast  | 09:35:30
 libcxx-libcxxabi-libunwind-x86_64-linux-ubuntu  | 09:30:09
 clang-ppc64le-linux-multistage  | 09:06:12
 clang-cmake-aarch64-full| 08:34:29
 clang-cmake-armv7-global-isel   | 08:19:01
 clang-cmake-aarch64-global-isel | 07:52:39
 clang-ppc64le-linux | 07:26:16
 clang-armv7-linux-build-cache   | 07:19:58
 clang-ppc64be-linux-lnt | 06:49:33
 llvm-sphinx-docs| 06:29:43
 lldb-sphinx-docs| 06:26:02
 clang-tools-sphinx-docs | 06:18:43
 sanitizer-x86_64-linux-fuzzer   | 06:18:13
 sanitizer-ppc64le-linux | 05:59:41
 clang-cmake-armv7-lnt   | 05:47:40
 polly-arm-linux | 05:23:41
 llvm-hexagon-elf| 05:19:08
 reverse-iteration   | 05:10:23
 sanitizer-x86_64-linux-android  | 05:10:19
 clang-aarch64-linux-build-cache | 05:08:29
 clang-sphinx-docs   | 05:02:15
 clang-atom-d525-fedora-rel  | 04:18:05
 clang-hexagon-elf   | 02:02:11
 clang-x64-windows-msvc  | 01:47:04
 

[PATCH] D67473: [clang-tidy] Fix build with -DBUILD_SHARED_LIB=ON

2019-09-11 Thread Heejin Ahn via Phabricator via cfe-commits
aheejin created this revision.
aheejin added a reviewer: NoQ.
Herald added subscribers: cfe-commits, xazax.hun, mgorny.
Herald added a project: clang.

This fixes build failures with `-DBUILD_SHARED_LIB=ON` after D67419 
.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D67473

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


Index: clang-tools-extra/clang-tidy/CMakeLists.txt
===
--- clang-tools-extra/clang-tidy/CMakeLists.txt
+++ clang-tools-extra/clang-tidy/CMakeLists.txt
@@ -16,6 +16,7 @@
   ClangSACheckers
 
   LINK_LIBS
+  clangAnalysis
   clangAST
   clangASTMatchers
   clangBasic


Index: clang-tools-extra/clang-tidy/CMakeLists.txt
===
--- clang-tools-extra/clang-tidy/CMakeLists.txt
+++ clang-tools-extra/clang-tidy/CMakeLists.txt
@@ -16,6 +16,7 @@
   ClangSACheckers
 
   LINK_LIBS
+  clangAnalysis
   clangAST
   clangASTMatchers
   clangBasic
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r371694 - [X86] Enable -mprefer-vector-width=256 by default for Skylake-avx512 and later Intel CPUs.

2019-09-11 Thread Craig Topper via cfe-commits
Author: ctopper
Date: Wed Sep 11 16:54:36 2019
New Revision: 371694

URL: http://llvm.org/viewvc/llvm-project?rev=371694=rev
Log:
[X86] Enable -mprefer-vector-width=256 by default for Skylake-avx512 and later 
Intel CPUs.

AVX512 instructions can cause a frequency drop on these CPUs. This
can negate the performance gains from using wider vectors. Enabling
prefer-vector-width=256 will prevent generation of zmm registers
unless explicit 512 bit operations are used in the original source
code.

I believe gcc and icc both do something similar to this by default.

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

Modified:
cfe/trunk/docs/ReleaseNotes.rst

Modified: cfe/trunk/docs/ReleaseNotes.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ReleaseNotes.rst?rev=371694=371693=371694=diff
==
--- cfe/trunk/docs/ReleaseNotes.rst (original)
+++ cfe/trunk/docs/ReleaseNotes.rst Wed Sep 11 16:54:36 2019
@@ -56,8 +56,12 @@ Improvements to Clang's diagnostics
 Non-comprehensive list of changes in this release
 -
 
-- ...
-
+- For X86 target, -march=skylake-avx512, -march=icelake-client,
+  -march=icelake-server, -march=cascadelake, -march=cooperlake will default to
+  not using 512-bit zmm registers in vectorized code unless 512-bit intrinsics
+  are used in the source code. 512-bit operations are known to cause the CPUs
+  to run at a lower frequency which can impact performance. This behavior can 
be
+  changed by passing -mprefer-vector-width=512 on the command line.
 
 New Compiler Flags
 --


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


[PATCH] D67422: [analyzer] NFC: Move path diagnostic consumer implementations to libAnalysis.

2019-09-11 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ updated this revision to Diff 219829.
NoQ added a comment.
Herald added a subscriber: mgorny.

Unforget to actually move the consumer implementations to `libAnalysis`, not 
just their headers.

Casually  rename 
`ClangDiagPathDiagConsumer` to `TextDiagnostics` according to the local naming 
tradition.


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

https://reviews.llvm.org/D67422

Files:
  clang/include/clang/Analysis/PathDiagnosticConsumers.def
  clang/include/clang/Analysis/PathDiagnosticConsumers.h
  clang/include/clang/StaticAnalyzer/Core/Analyses.def
  clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
  clang/include/clang/StaticAnalyzer/Core/PathDiagnosticConsumers.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h
  clang/lib/Analysis/CMakeLists.txt
  clang/lib/Analysis/HTMLDiagnostics.cpp
  clang/lib/Analysis/PlistDiagnostics.cpp
  clang/lib/Analysis/PlistHTMLDiagnostics.cpp
  clang/lib/Analysis/SarifDiagnostics.cpp
  clang/lib/Analysis/TextDiagnostics.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/StaticAnalyzer/Core/CMakeLists.txt
  clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
  clang/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp
  clang/lib/StaticAnalyzer/Core/SarifDiagnostics.cpp
  clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp

Index: clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
===
--- clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
+++ clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
@@ -13,6 +13,7 @@
 #include "clang/StaticAnalyzer/Frontend/AnalysisConsumer.h"
 #include "ModelInjector.h"
 #include "clang/Analysis/PathDiagnostic.h"
+#include "clang/Analysis/PathDiagnosticConsumers.h"
 #include "clang/AST/Decl.h"
 #include "clang/AST/DeclCXX.h"
 #include "clang/AST/DeclObjC.h"
@@ -29,7 +30,6 @@
 #include "clang/StaticAnalyzer/Core/AnalyzerOptions.h"
 #include "clang/StaticAnalyzer/Core/BugReporter/BugReporter.h"
 #include "clang/StaticAnalyzer/Core/CheckerManager.h"
-#include "clang/StaticAnalyzer/Core/PathDiagnosticConsumers.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h"
 #include "clang/StaticAnalyzer/Frontend/CheckerRegistration.h"
@@ -60,116 +60,6 @@
 STATISTIC(PercentReachableBlocks, "The % of reachable basic blocks.");
 STATISTIC(MaxCFGSize, "The maximum number of basic blocks in a function.");
 
-//===--===//
-// Special PathDiagnosticConsumers.
-//===--===//
-
-void ento::createPlistHTMLDiagnosticConsumer(
-PathDiagnosticConsumerOptions &, PathDiagnosticConsumers ,
-const std::string , const Preprocessor ,
-const cross_tu::CrossTranslationUnitContext ) {
-  // Duplicate the DiagOpts object into both consumers.
-  createHTMLDiagnosticConsumer(PathDiagnosticConsumerOptions(DiagOpts), C,
-   llvm::sys::path::parent_path(prefix), PP, CTU);
-  createPlistMultiFileDiagnosticConsumer(
-  PathDiagnosticConsumerOptions(DiagOpts), C, prefix, PP, CTU);
-}
-
-namespace {
-class ClangDiagPathDiagConsumer : public PathDiagnosticConsumer {
-  DiagnosticsEngine 
-  bool IncludePath = false, ShouldEmitAsError = false, FixitsAsRemarks = false;
-
-public:
-  ClangDiagPathDiagConsumer(PathDiagnosticConsumerOptions &,
-DiagnosticsEngine )
-  : Diag(Diag), IncludePath(DiagOpts.ShouldDisplayPathNotes),
-ShouldEmitAsError(DiagOpts.ShouldDisplayWarningsAsErrors),
-FixitsAsRemarks(DiagOpts.ShouldEmitFixItHintsAsRemarks) {}
-  ~ClangDiagPathDiagConsumer() override {}
-  StringRef getName() const override { return "ClangDiags"; }
-
-  bool supportsLogicalOpControlFlow() const override { return true; }
-  bool supportsCrossFileDiagnostics() const override { return true; }
-
-  PathGenerationScheme getGenerationScheme() const override {
-return IncludePath ? Minimal : None;
-  }
-
-  void FlushDiagnosticsImpl(std::vector ,
-FilesMade *filesMade) override {
-unsigned WarnID =
-ShouldEmitAsError
-? Diag.getCustomDiagID(DiagnosticsEngine::Error, "%0")
-: Diag.getCustomDiagID(DiagnosticsEngine::Warning, "%0");
-unsigned NoteID = Diag.getCustomDiagID(DiagnosticsEngine::Note, "%0");
-unsigned RemarkID = Diag.getCustomDiagID(DiagnosticsEngine::Remark, "%0");
-
-auto reportPiece =
-[&](unsigned ID, SourceLocation Loc, StringRef String,
-ArrayRef Ranges, ArrayRef Fixits) {
-  if (!FixitsAsRemarks) {
-Diag.Report(Loc, ID) << String << Ranges << Fixits;
-  } else {
-Diag.Report(Loc, ID) << String << Ranges;
-for (const FixItHint  : Fixits) 

[PATCH] D49466: Initial implementation of -fmacro-prefix-map and -ffile-prefix-map

2019-09-11 Thread Petr Hosek via Phabricator via cfe-commits
phosek added a comment.

@dankm do you still plan to work on this? We would really like to see this 
landed and we could help if needed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D49466



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


[PATCH] D67249: [Modules][PCH] Hash input files content

2019-09-11 Thread Juergen Ributzka via Phabricator via cfe-commits
ributzka added a comment.

Did you try xxHash64?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67249



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


[PATCH] D67420: [analyzer] NFC: Separate PathDiagnosticConsumer options from AnalyzerOptions.

2019-09-11 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ updated this revision to Diff 219826.
NoQ added a comment.

Clean up a tiny bit of dead code.


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

https://reviews.llvm.org/D67420

Files:
  clang/include/clang/Analysis/PathDiagnostic.h
  clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
  clang/include/clang/StaticAnalyzer/Core/PathDiagnosticConsumers.h
  clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
  clang/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp
  clang/lib/StaticAnalyzer/Core/SarifDiagnostics.cpp
  clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp

Index: clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
===
--- clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
+++ clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
@@ -65,19 +65,14 @@
 //===--===//
 
 void ento::createPlistHTMLDiagnosticConsumer(
-AnalyzerOptions , PathDiagnosticConsumers ,
+PathDiagnosticConsumerOptions &, PathDiagnosticConsumers ,
 const std::string , const Preprocessor ,
 const cross_tu::CrossTranslationUnitContext ) {
-  createHTMLDiagnosticConsumer(AnalyzerOpts, C,
+  // Duplicate the DiagOpts object into both consumers.
+  createHTMLDiagnosticConsumer(PathDiagnosticConsumerOptions(DiagOpts), C,
llvm::sys::path::parent_path(prefix), PP, CTU);
-  createPlistMultiFileDiagnosticConsumer(AnalyzerOpts, C, prefix, PP, CTU);
-}
-
-void ento::createTextPathDiagnosticConsumer(
-AnalyzerOptions , PathDiagnosticConsumers ,
-const std::string , const clang::Preprocessor ,
-const cross_tu::CrossTranslationUnitContext ) {
-  llvm_unreachable("'text' consumer should be enabled on ClangDiags");
+  createPlistMultiFileDiagnosticConsumer(
+  PathDiagnosticConsumerOptions(DiagOpts), C, prefix, PP, CTU);
 }
 
 namespace {
@@ -86,8 +81,11 @@
   bool IncludePath = false, ShouldEmitAsError = false, FixitsAsRemarks = false;
 
 public:
-  ClangDiagPathDiagConsumer(DiagnosticsEngine )
-  : Diag(Diag) {}
+  ClangDiagPathDiagConsumer(PathDiagnosticConsumerOptions &,
+DiagnosticsEngine )
+  : Diag(Diag), IncludePath(DiagOpts.ShouldDisplayPathNotes),
+ShouldEmitAsError(DiagOpts.ShouldDisplayWarningsAsErrors),
+FixitsAsRemarks(DiagOpts.ShouldEmitFixItHintsAsRemarks) {}
   ~ClangDiagPathDiagConsumer() override {}
   StringRef getName() const override { return "ClangDiags"; }
 
@@ -98,10 +96,6 @@
 return IncludePath ? Minimal : None;
   }
 
-  void enablePaths() { IncludePath = true; }
-  void enableWerror() { ShouldEmitAsError = true; }
-  void enableFixitsAsRemarks() { FixitsAsRemarks = true; }
-
   void FlushDiagnosticsImpl(std::vector ,
 FilesMade *filesMade) override {
 unsigned WarnID =
@@ -168,6 +162,14 @@
 };
 } // end anonymous namespace
 
+void ento::createTextPathDiagnosticConsumer(
+PathDiagnosticConsumerOptions &, PathDiagnosticConsumers ,
+const std::string , const clang::Preprocessor ,
+const cross_tu::CrossTranslationUnitContext ) {
+  C.push_back(
+  new ClangDiagPathDiagConsumer(std::move(DiagOpts), PP.getDiagnostics()));
+}
+
 //===--===//
 // AnalysisConsumer declaration.
 //===--===//
@@ -254,26 +256,21 @@
 
   void DigestAnalyzerOptions() {
 if (Opts->AnalysisDiagOpt != PD_NONE) {
-  // Create the PathDiagnosticConsumer.
-  ClangDiagPathDiagConsumer *clangDiags =
-  new ClangDiagPathDiagConsumer(PP.getDiagnostics());
-  PathConsumers.push_back(clangDiags);
-
-  if (Opts->AnalyzerWerror)
-clangDiags->enableWerror();
-
-  if (Opts->ShouldEmitFixItHintsAsRemarks)
-clangDiags->enableFixitsAsRemarks();
-
-  if (Opts->AnalysisDiagOpt == PD_TEXT) {
-clangDiags->enablePaths();
-
-  } else if (!OutDir.empty()) {
+  // Create the text consumer unconditionally. It will display warnings
+  // on the console even if other consumers display the warning to the user
+  // in a more sophisticated format.
+  PathDiagnosticConsumerOptions TextDiagOpts = Opts->getDiagOpts();
+  TextDiagOpts.ShouldDisplayPathNotes = (Opts->AnalysisDiagOpt == PD_TEXT);
+  createTextPathDiagnosticConsumer(std::move(TextDiagOpts), PathConsumers,
+   OutDir, PP, CTU);
+
+  // Create other consumers if requested.
+  if (Opts->AnalysisDiagOpt != PD_TEXT  && !OutDir.empty()) {
 switch (Opts->AnalysisDiagOpt) {
 default:
 #define ANALYSIS_DIAGNOSTICS(NAME, CMDFLAG, DESC, CREATEFN)\
   case PD_##NAME:  \
-CREATEFN(*Opts.get(), PathConsumers, OutDir, PP, CTU); 

[PATCH] D67460: clang-tidy: modernize-use-using work with multi-argument templates

2019-09-11 Thread Jonathan Meier via Phabricator via cfe-commits
jonathanmeier added a comment.

With non-type template parameters we can have expressions inside template 
arguments, including comparison operators like `<`, `<=`, `>` and `>=`, which 
lets us write typedefs like this:

  template 
  struct S {};
  
  typedef S<(0 < 0)> S_t, *S_p;

Unfortunately, for this example your patch breaks the check in the `tok::comma` 
case, which should abort the removal when there are multiple declarations in 
the declaration chain. It thinks the comma is still part of the template 
argument, since it expects a matching end template angle bracket for the less 
than operator which was erroneously interpreted as the start of a template 
argument.

With the `-fix` option, clang-tidy produces the following invalid using 
declaration for the example above:

  using S_t = S<(0 < 0)>, *S_p;


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D67460



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


[PATCH] D67421: [analyzer] NFC: Move IssueHash to libAnalysis.

2019-09-11 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ updated this revision to Diff 219824.
NoQ added a comment.

Rename `BugType` to `WarningMessage`, add comments.

Get rid of an unnecessary `SourceManager` parameter.


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

https://reviews.llvm.org/D67421

Files:
  clang/include/clang/Analysis/IssueHash.h
  clang/include/clang/StaticAnalyzer/Core/IssueHash.h
  clang/lib/Analysis/CMakeLists.txt
  clang/lib/Analysis/IssueHash.cpp
  clang/lib/StaticAnalyzer/Checkers/ExprInspectionChecker.cpp
  clang/lib/StaticAnalyzer/Core/CMakeLists.txt
  clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
  clang/lib/StaticAnalyzer/Core/IssueHash.cpp
  clang/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp

Index: clang/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp
===
--- clang/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp
+++ clang/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp
@@ -10,6 +10,7 @@
 //
 //===--===//
 
+#include "clang/Analysis/IssueHash.h"
 #include "clang/Analysis/PathDiagnostic.h"
 #include "clang/Basic/FileManager.h"
 #include "clang/Basic/PlistSupport.h"
@@ -20,7 +21,6 @@
 #include "clang/Lex/Preprocessor.h"
 #include "clang/Lex/TokenConcatenation.h"
 #include "clang/Rewrite/Core/HTMLRewrite.h"
-#include "clang/StaticAnalyzer/Core/IssueHash.h"
 #include "clang/StaticAnalyzer/Core/PathDiagnosticConsumers.h"
 #include "llvm/ADT/SmallPtrSet.h"
 #include "llvm/ADT/SmallVector.h"
@@ -680,9 +680,8 @@
 : D->getLocation().asLocation()),
 SM);
 const Decl *DeclWithIssue = D->getDeclWithIssue();
-EmitString(o, GetIssueHash(SM, L, D->getCheckName(), D->getBugType(),
-   DeclWithIssue, LangOpts))
-<< '\n';
+EmitString(o, GetIssueHash(L, D->getCheckName(), D->getBugType(),
+   DeclWithIssue, LangOpts)) << '\n';
 
 // Output information about the semantic context where
 // the issue occurred.
Index: clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
===
--- clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
+++ clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
@@ -10,6 +10,7 @@
 //
 //===--===//
 
+#include "clang/Analysis/IssueHash.h"
 #include "clang/Analysis/PathDiagnostic.h"
 #include "clang/AST/Decl.h"
 #include "clang/AST/DeclBase.h"
@@ -23,7 +24,6 @@
 #include "clang/Lex/Token.h"
 #include "clang/Rewrite/Core/HTMLRewrite.h"
 #include "clang/Rewrite/Core/Rewriter.h"
-#include "clang/StaticAnalyzer/Core/IssueHash.h"
 #include "clang/StaticAnalyzer/Core/PathDiagnosticConsumers.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/SmallString.h"
@@ -554,7 +554,7 @@
 os  << "\n\n";
 
 os << "\n\n";
 
 os << 

[PATCH] D67420: [analyzer] NFC: Separate PathDiagnosticConsumer options from AnalyzerOptions.

2019-09-11 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ updated this revision to Diff 219821.
NoQ added a comment.

Unforget to do the same for the text consumer. As a side effect, the factory 
function for the text consumer is no longer special, which will be less 
confusing when put in libAnalysis.

Address minor comments, don't address major comments.


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

https://reviews.llvm.org/D67420

Files:
  clang/include/clang/Analysis/PathDiagnostic.h
  clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
  clang/include/clang/StaticAnalyzer/Core/PathDiagnosticConsumers.h
  clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
  clang/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp
  clang/lib/StaticAnalyzer/Core/SarifDiagnostics.cpp
  clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp

Index: clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
===
--- clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
+++ clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
@@ -65,19 +65,14 @@
 //===--===//
 
 void ento::createPlistHTMLDiagnosticConsumer(
-AnalyzerOptions , PathDiagnosticConsumers ,
+PathDiagnosticConsumerOptions &, PathDiagnosticConsumers ,
 const std::string , const Preprocessor ,
 const cross_tu::CrossTranslationUnitContext ) {
-  createHTMLDiagnosticConsumer(AnalyzerOpts, C,
+  // Duplicate the DiagOpts object into both consumers.
+  createHTMLDiagnosticConsumer(PathDiagnosticConsumerOptions(DiagOpts), C,
llvm::sys::path::parent_path(prefix), PP, CTU);
-  createPlistMultiFileDiagnosticConsumer(AnalyzerOpts, C, prefix, PP, CTU);
-}
-
-void ento::createTextPathDiagnosticConsumer(
-AnalyzerOptions , PathDiagnosticConsumers ,
-const std::string , const clang::Preprocessor ,
-const cross_tu::CrossTranslationUnitContext ) {
-  llvm_unreachable("'text' consumer should be enabled on ClangDiags");
+  createPlistMultiFileDiagnosticConsumer(
+  PathDiagnosticConsumerOptions(DiagOpts), C, prefix, PP, CTU);
 }
 
 namespace {
@@ -86,8 +81,11 @@
   bool IncludePath = false, ShouldEmitAsError = false, FixitsAsRemarks = false;
 
 public:
-  ClangDiagPathDiagConsumer(DiagnosticsEngine )
-  : Diag(Diag) {}
+  ClangDiagPathDiagConsumer(PathDiagnosticConsumerOptions &,
+DiagnosticsEngine )
+  : Diag(Diag), IncludePath(DiagOpts.ShouldDisplayPathNotes),
+ShouldEmitAsError(DiagOpts.ShouldDisplayWarningsAsErrors),
+FixitsAsRemarks(DiagOpts.ShouldEmitFixItHintsAsRemarks) {}
   ~ClangDiagPathDiagConsumer() override {}
   StringRef getName() const override { return "ClangDiags"; }
 
@@ -168,6 +166,14 @@
 };
 } // end anonymous namespace
 
+void ento::createTextPathDiagnosticConsumer(
+PathDiagnosticConsumerOptions &, PathDiagnosticConsumers ,
+const std::string , const clang::Preprocessor ,
+const cross_tu::CrossTranslationUnitContext ) {
+  C.push_back(
+  new ClangDiagPathDiagConsumer(std::move(DiagOpts), PP.getDiagnostics()));
+}
+
 //===--===//
 // AnalysisConsumer declaration.
 //===--===//
@@ -254,26 +260,21 @@
 
   void DigestAnalyzerOptions() {
 if (Opts->AnalysisDiagOpt != PD_NONE) {
-  // Create the PathDiagnosticConsumer.
-  ClangDiagPathDiagConsumer *clangDiags =
-  new ClangDiagPathDiagConsumer(PP.getDiagnostics());
-  PathConsumers.push_back(clangDiags);
-
-  if (Opts->AnalyzerWerror)
-clangDiags->enableWerror();
-
-  if (Opts->ShouldEmitFixItHintsAsRemarks)
-clangDiags->enableFixitsAsRemarks();
-
-  if (Opts->AnalysisDiagOpt == PD_TEXT) {
-clangDiags->enablePaths();
-
-  } else if (!OutDir.empty()) {
+  // Create the text consumer unconditionally. It will display warnings
+  // on the console even if other consumers display the warning to the user
+  // in a more sophisticated format.
+  PathDiagnosticConsumerOptions TextDiagOpts = Opts->getDiagOpts();
+  TextDiagOpts.ShouldDisplayPathNotes = (Opts->AnalysisDiagOpt == PD_TEXT);
+  createTextPathDiagnosticConsumer(std::move(TextDiagOpts), PathConsumers,
+   OutDir, PP, CTU);
+
+  // Create other consumers if requested.
+  if (Opts->AnalysisDiagOpt != PD_TEXT  && !OutDir.empty()) {
 switch (Opts->AnalysisDiagOpt) {
 default:
 #define ANALYSIS_DIAGNOSTICS(NAME, CMDFLAG, DESC, CREATEFN)\
   case PD_##NAME:  \
-CREATEFN(*Opts.get(), PathConsumers, OutDir, PP, CTU); \
+CREATEFN(Opts->getDiagOpts(), PathConsumers, OutDir, PP, CTU); \
 break;
 #include "clang/StaticAnalyzer/Core/Analyses.def"

[PATCH] D66856: [Sema] Suppress -Wformat diagnostics for bool types when printed using %hhd

2019-09-11 Thread Erik Pilkington via Phabricator via cfe-commits
erik.pilkington added a comment.

In D66856#116 , @aaron.ballman 
wrote:

> The reflector discussion is still happening and there are issues with 
> ambiguities that we are pretty sure we want to correct. I've got a paper out 
> that touches on some of this: 
> http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2420.pdf


Nice, thanks for digging into this!




Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:8123
+def warn_format_bool_as_character : Warning<
+  "format specifies a character but argument has boolean value">,
+  InGroup;

aaron.ballman wrote:
> How about: `using '%0' format specifier, but argument has boolean value` and 
> then pass in the character specifier used?
Sure, copied that verbatim. 



Comment at: clang/test/Sema/format-bool.c:26
+#ifdef PEDANTIC
+  // expected-warning@-2 {{format specifies type 'short' but the argument has 
type}}
+#endif

aaron.ballman wrote:
> Just an FYI (not related to your patch): it seems that at least some people 
> think this should be diagnosed as something other than by 
> `-Wformat-pedantic`. Their thinking is that `-Wformat-pedantic` is for things 
> that are required to have a diagnostic according to the standard but are not 
> sufficiently interesting to warn about by default. This particular case is 
> not required to be warned on by the standard, so it's not really a "pedantic" 
> warning. It sounds like there may be interest in having `-Wformat-pedantic` 
> for that understanding of pedantic, and introduce something like 
> `-Wformat-type-mismatch` for these other cases where there is type confusion 
> but not sufficiently dangerous to warrant warning by default?
That seems like a good idea to me, I agree that "pedantic" in the context of 
warnings means "technically incorrect according to the standard, but not really 
a big deal", which isn't really what -Wformat-pedantic is doing right now.


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

https://reviews.llvm.org/D66856



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


[PATCH] D66856: [Sema] Suppress -Wformat diagnostics for bool types when printed using %hhd

2019-09-11 Thread Erik Pilkington via Phabricator via cfe-commits
erik.pilkington updated this revision to Diff 219815.
erik.pilkington marked 6 inline comments as done.
erik.pilkington added a comment.

Update the diagnostic text.


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

https://reviews.llvm.org/D66856

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/AST/Expr.cpp
  clang/lib/AST/FormatString.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/test/Sema/format-bool.c

Index: clang/test/Sema/format-bool.c
===
--- /dev/null
+++ clang/test/Sema/format-bool.c
@@ -0,0 +1,46 @@
+// RUN: %clang_cc1 -xc %s -verify -DBOOL=_Bool
+// RUN: %clang_cc1 -xc++ %s -verify -DBOOL=bool
+// RUN: %clang_cc1 -xobjective-c %s -verify -DBOOL=_Bool
+// RUN: %clang_cc1 -xc %s -verify -DBOOL=_Bool -Wformat-pedantic -DPEDANTIC
+// RUN: %clang_cc1 -xc++ %s -verify -DBOOL=bool -Wformat-pedantic -DPEDANTIC
+
+__attribute__((format(__printf__, 1, 2)))
+int p(const char *fmt, ...);
+
+BOOL b;
+
+#ifdef __OBJC__
+@interface NSString
++(NSString *)stringWithFormat:(NSString *)fmt, ...
+__attribute__((format(__NSString__, 1, 2)));
+@end
+
+#define YES __objc_yes
+#define NO __objc_no
+#endif
+
+int main() {
+  p("%d", b);
+  p("%hd", b);
+#ifdef PEDANTIC
+  // expected-warning@-2 {{format specifies type 'short' but the argument has type}}
+#endif
+  p("%hhd", b);
+  p("%u", b);
+  p("%hu", b);
+#ifdef PEDANTIC
+  // expected-warning@-2 {{format specifies type 'unsigned short' but the argument has type}}
+#endif
+  p("%hhu", b);
+  p("%c", b); // expected-warning {{using '%c' format specifier, but argument has boolean value}}
+  p("%lc", b); // expected-warning {{using '%lc' format specifier, but argument has boolean value}}
+  p("%c", 1 == 1); // expected-warning {{using '%c' format specifier, but argument has boolean value}}
+  p("%f", b); // expected-warning{{format specifies type 'double' but the argument has type}}
+  p("%ld", b); // expected-warning{{format specifies type 'long' but the argument has type}}
+  p("%lld", b); // expected-warning{{format specifies type 'long long' but the argument has type}}
+
+#ifdef __OBJC__
+  [NSString stringWithFormat: @"%c", 0]; // probably fine?
+  [NSString stringWithFormat: @"%c", NO]; // expected-warning {{using '%c' format specifier, but argument has boolean value}}
+#endif
+}
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -8109,6 +8109,22 @@
 ExprTy = TET->getUnderlyingExpr()->getType();
   }
 
+  // Diagnose attempts to print a boolean value as a character. Unlike other
+  // -Wformat diagnostics, this is fine from a type perspective, but it still
+  // doesn't make sense.
+  if (FS.getConversionSpecifier().getKind() == ConversionSpecifier::cArg &&
+  E->isKnownToHaveBooleanValue()) {
+const CharSourceRange  =
+getSpecifierRange(StartSpecifier, SpecifierLen);
+SmallString<4> FSString;
+llvm::raw_svector_ostream os(FSString);
+FS.toString(os);
+EmitFormatDiagnostic(S.PDiag(diag::warn_format_bool_as_character)
+ << FSString,
+ E->getExprLoc(), false, CSR);
+return true;
+  }
+
   const analyze_printf::ArgType::MatchKind Match =
   AT.matchesType(S.Context, ExprTy);
   bool Pedantic = Match == analyze_printf::ArgType::NoMatchPedantic;
Index: clang/lib/AST/FormatString.cpp
===
--- clang/lib/AST/FormatString.cpp
+++ clang/lib/AST/FormatString.cpp
@@ -359,6 +359,7 @@
   case BuiltinType::SChar:
   case BuiltinType::UChar:
   case BuiltinType::Char_U:
+  case BuiltinType::Bool:
 return Match;
 }
   return NoMatch;
@@ -386,6 +387,7 @@
   case BuiltinType::SChar:
   case BuiltinType::Char_U:
   case BuiltinType::UChar:
+  case BuiltinType::Bool:
 if (T == C.UnsignedShortTy || T == C.ShortTy)
   return NoMatchPedantic;
 return T == C.UnsignedCharTy || T == C.SignedCharTy ? Match
Index: clang/lib/AST/Expr.cpp
===
--- clang/lib/AST/Expr.cpp
+++ clang/lib/AST/Expr.cpp
@@ -185,6 +185,9 @@
 return CO->getTrueExpr()->isKnownToHaveBooleanValue() &&
CO->getFalseExpr()->isKnownToHaveBooleanValue();
 
+  if (isa(E))
+return true;
+
   return false;
 }
 
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -8119,6 +8119,9 @@
 def warn_scanf_scanlist_incomplete : Warning<
   "no closing ']' for '%%[' in scanf format string">,
   InGroup;
+def warn_format_bool_as_character : Warning<
+  "using '%0' 

LLVM buildmaster will be updated and restarted tonight

2019-09-11 Thread Galina Kistanova via cfe-commits
 Hello everyone,

LLVM buildmaster will be updated and restarted after 5PM Pacific time today.

Thanks

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


[PATCH] D67467: [ARM] Update clang for removal of vfp2d16 and vfp2d16sp

2019-09-11 Thread Eli Friedman via Phabricator via cfe-commits
efriedma created this revision.
efriedma added a reviewer: ostannard.
Herald added a subscriber: kristof.beyls.
Herald added a project: clang.

Matching fix for https://reviews.llvm.org/D67375 .


Repository:
  rC Clang

https://reviews.llvm.org/D67467

Files:
  lib/Basic/Targets/ARM.cpp
  lib/Driver/ToolChains/Arch/ARM.cpp
  test/CodeGen/arm-target-features.c
  test/Driver/arm-mfpu.c

Index: test/Driver/arm-mfpu.c
===
--- test/Driver/arm-mfpu.c
+++ test/Driver/arm-mfpu.c
@@ -35,7 +35,7 @@
 // CHECK-SOFT-ABI-FP-2-DAG: "-target-feature" "-fp-armv8d16sp"
 // CHECK-SOFT-ABI-FP-2-DAG: "-target-feature" "-neon"
 // CHECK-SOFT-ABI-FP-2-DAG: "-target-feature" "-crypto"
-// CHECK-SOFT-ABI-FP-2-DAG: "-target-feature" "-vfp2d16sp"
+// CHECK-SOFT-ABI-FP-2-DAG: "-target-feature" "-vfp2sp"
 
 // RUN: %clang -target arm-linux-eabi -mfpu=vfp3 %s -### -o %t.o 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-VFP3 %s
@@ -50,7 +50,7 @@
 // CHECK-VFP3-DAG: "-target-feature" "-fp-armv8d16sp"
 // CHECK-VFP3-DAG: "-target-feature" "-neon"
 // CHECK-SOFT-ABI-FP-3-DAG: "-target-feature" "+soft-float-abi"
-// CHECK-SOFT-ABI-FP-3-DAG: "-target-feature" "-vfp2d16sp"
+// CHECK-SOFT-ABI-FP-3-DAG: "-target-feature" "-vfp2sp"
 // CHECK-SOFT-ABI-FP-3-DAG: "-target-feature" "-vfp4d16sp"
 // CHECK-SOFT-ABI-FP-3-DAG: "-target-feature" "-fp-armv8d16sp"
 // CHECK-SOFT-ABI-FP-3-DAG: "-target-feature" "-neon"
@@ -144,7 +144,7 @@
 // CHECK-VFP4-DAG: "-target-feature" "-fp-armv8d16sp"
 // CHECK-VFP4-DAG: "-target-feature" "-neon"
 // CHECK-SOFT-ABI-FP-4-DAG: "-target-feature" "+soft-float-abi"
-// CHECK-SOFT-ABI-FP-4-DAG: "-target-feature" "-vfp2d16sp"
+// CHECK-SOFT-ABI-FP-4-DAG: "-target-feature" "-vfp2sp"
 // CHECK-SOFT-ABI-FP-4-DAG: "-target-feature" "-vfp3d16sp"
 // CHECK-SOFT-ABI-FP-4-DAG: "-target-feature" "-fp-armv8d16sp"
 // CHECK-SOFT-ABI-FP-4-DAG: "-target-feature" "-neon"
@@ -208,7 +208,7 @@
 // CHECK-FP5-DP-D16-DAG: "-target-feature" "-crypto"
 // CHECK-SOFT-ABI-FP-5-DAG: "-target-feature" "+soft-float"
 // CHECK-SOFT-ABI-FP-5-DAG: "-target-feature" "+soft-float-abi"
-// CHECK-SOFT-ABI-FP-5-DAG: "-target-feature" "-vfp2d16sp"
+// CHECK-SOFT-ABI-FP-5-DAG: "-target-feature" "-vfp2sp"
 // CHECK-SOFT-ABI-FP-5-DAG: "-target-feature" "-vfp3d16sp"
 // CHECK-SOFT-ABI-FP-5-DAG: "-target-feature" "-vfp4d16sp"
 // CHECK-SOFT-ABI-FP-5-DAG: "-target-feature" "-neon"
@@ -222,7 +222,7 @@
 // CHECK-NEON-NOT: "-target-feature" "+soft-float"
 // CHECK-NEON-DAG: "-target-feature" "+neon"
 // CHECK-SOFT-ABI-FP-6-DAG: "-target-feature" "+soft-float-abi"
-// CHECK-SOFT-ABI-FP-6-DAG: "-target-feature" "-vfp2d16sp"
+// CHECK-SOFT-ABI-FP-6-DAG: "-target-feature" "-vfp2sp"
 // CHECK-SOFT-ABI-FP-6-DAG: "-target-feature" "-vfp4d16sp"
 // CHECK-SOFT-ABI-FP-6-DAG: "-target-feature" "-fp-armv8d16sp"
 // CHECK-SOFT-ABI-FP-6-DAG: "-target-feature" "-crypto"
@@ -262,7 +262,7 @@
 // CHECK-NEON-VFPV4-DAG: "-target-feature" "+vfp4"
 // CHECK-NEON-VFPV4-DAG: "-target-feature" "+neon"
 // CHECK-SOFT-ABI-FP-7-DAG: "-target-feature" "+soft-float-abi"
-// CHECK-SOFT-ABI-FP-7-DAG: "-target-feature" "-vfp2d16sp"
+// CHECK-SOFT-ABI-FP-7-DAG: "-target-feature" "-vfp2sp"
 // CHECK-SOFT-ABI-FP-7-DAG: "-target-feature" "-vfp3d16sp"
 // CHECK-SOFT-ABI-FP-7-DAG: "-target-feature" "-fp-armv8d16sp"
 // CHECK-SOFT-ABI-FP-7-DAG: "-target-feature" "-crypto"
@@ -276,7 +276,7 @@
 // RUN: %clang -target armv8a -mfpu=neon %s -### -c 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-SOFT-ABI-FP-8 %s
 // CHECK-SOFT-ABI-FP-8-DAG: "-target-feature" "+soft-float-abi"
-// CHECK-SOFT-ABI-FP-8-DAG: "-target-feature" "-vfp2d16sp"
+// CHECK-SOFT-ABI-FP-8-DAG: "-target-feature" "-vfp2sp"
 // CHECK-SOFT-ABI-FP-8-DAG: "-target-feature" "-vfp4d16sp"
 // CHECK-SOFT-ABI-FP-8-DAG: "-target-feature" "-fp-armv8d16sp"
 // CHECK-SOFT-ABI-FP-8-DAG: "-target-feature" "-crypto"
@@ -319,7 +319,7 @@
 // CHECK-NO-FP-NOT: "-target-feature" "+soft-float"
 // CHECK-NO-FP-DAG: "-target-feature" "+soft-float-abi"
 // CHECK-NO-FP-DAG: "-target-feature" "-fpregs"
-// CHECK-NO-FP-DAG: "-target-feature" "-vfp2d16sp"
+// CHECK-NO-FP-DAG: "-target-feature" "-vfp2sp"
 // CHECK-NO-FP-DAG: "-target-feature" "-vfp3d16sp"
 // CHECK-NO-FP-DAG: "-target-feature" "-vfp4d16sp"
 // CHECK-NO-FP-DAG: "-target-feature" "-fp-armv8d16sp"
@@ -358,7 +358,7 @@
 // RUN:   | FileCheck --check-prefix=CHECK-SOFT-ABI-FP %s
 // CHECK-SOFT-ABI-FP-DAG: "-target-feature" "+soft-float"
 // CHECK-SOFT-ABI-FP-DAG: "-target-feature" "+soft-float-abi"
-// CHECK-SOFT-ABI-FP-DAG: "-target-feature" "-vfp2d16sp"
+// CHECK-SOFT-ABI-FP-DAG: "-target-feature" "-vfp2sp"
 // CHECK-SOFT-ABI-FP-DAG: "-target-feature" "-vfp3d16sp"
 // CHECK-SOFT-ABI-FP-DAG: "-target-feature" "-vfp4d16sp"
 // CHECK-SOFT-ABI-FP-DAG: "-target-feature" "-fp-armv8d16sp"
Index: test/CodeGen/arm-target-features.c
===
--- test/CodeGen/arm-target-features.c
+++ 

r371665 - Fix up a test updated in r371655 - require case-insensitive file system.

2019-09-11 Thread Volodymyr Sapsai via cfe-commits
Author: vsapsai
Date: Wed Sep 11 14:19:27 2019
New Revision: 371665

URL: http://llvm.org/viewvc/llvm-project?rev=371665=rev
Log:
Fix up a test updated in r371655 - require case-insensitive file system.

On case-sensitive file systems include with wrong case is not found instead of
showing a warning.

Modified:
cfe/trunk/test/Preprocessor/nonportable-include-with-hmap.c

Modified: cfe/trunk/test/Preprocessor/nonportable-include-with-hmap.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/nonportable-include-with-hmap.c?rev=371665=371664=371665=diff
==
--- cfe/trunk/test/Preprocessor/nonportable-include-with-hmap.c (original)
+++ cfe/trunk/test/Preprocessor/nonportable-include-with-hmap.c Wed Sep 11 
14:19:27 2019
@@ -1,4 +1,5 @@
 // REQUIRES: shell
+// REQUIRES: case-insensitive-filesystem
 
 // RUN: rm -f %t.hmap
 // RUN: sed -e "s:INPUTS_DIR:%S/Inputs:g" \


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


[PATCH] D64943: [Clang][OpenMP offload] Eliminate use of OpenMP linker script

2019-09-11 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield added a comment.

In D64943#1666849 , @sdmitriev wrote:

> In D64943#136 , @JonChesterfield 
> wrote:
>
> > I'm not sure copying the crtbegin/crtend mechanism from the early days of C 
> > runtime is ideal. Since the data is stored in a common section anyway, 
> > please could we rename it to __omp_offloading_entries in which case the 
> > linker will provide start/end symbols automatically?
>
>
> Well, I never said that it is an ideal solution, but it is a known mechanism 
> that works well in many cases and can also be reused for the offloading entry 
> table.
>  I do not fully understand your suggestion for renaming entries section, how 
> it will help with providing start/end symbols for the entries. Can you please 
> provide more details?


Given a custom elf section with a C identifier as a name, the linker will 
provide definitions of `__start_name`/`__stop_name` to satisfy unresolved 
symbols. I don't believe this occurs if the section name is not a C identifier, 
e.g. contains a period. So unless I've misinterpreted the purpose of the two 
object files, they can be removed in exchange for renaming the section.


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

https://reviews.llvm.org/D64943



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


r371664 - [clang-scan-deps] cast Result to ErrorOr> explicitly to avoid s390x-linux buildbot failure

2019-09-11 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Wed Sep 11 14:00:13 2019
New Revision: 371664

URL: http://llvm.org/viewvc/llvm-project?rev=371664=rev
Log:
[clang-scan-deps] cast Result to ErrorOr> explicitly to 
avoid s390x-linux buildbot failure

Modified:
cfe/trunk/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp

Modified: 
cfe/trunk/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp?rev=371664=371663=371664=diff
==
--- cfe/trunk/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp 
(original)
+++ cfe/trunk/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp 
Wed Sep 11 14:00:13 2019
@@ -203,7 +203,8 @@ createFile(const CachedFileSystemEntry *
   if (!Entry->getPPSkippedRangeMapping().empty() && PPSkipMappings)
 (*PPSkipMappings)[Result->getBufferPtr()] =
 >getPPSkippedRangeMapping();
-  return Result;
+  return llvm::ErrorOr>(
+  std::unique_ptr(std::move(Result)));
 }
 
 } // end anonymous namespace


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


[PATCH] D67454: Start porting ivfsoverlay tests to Windows

2019-09-11 Thread Reid Kleckner via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL371663: Start porting ivfsoverlay tests to Windows (authored 
by rnk, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D67454?vs=219753=219798#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D67454

Files:
  cfe/trunk/test/Index/index-module-with-vfs.m
  cfe/trunk/test/Modules/crash-vfs-ivfsoverlay.m
  cfe/trunk/test/Modules/double-quotes.m
  cfe/trunk/test/Modules/framework-public-includes-private.m
  cfe/trunk/test/VFS/external-names.c
  cfe/trunk/test/VFS/framework-import.m
  cfe/trunk/test/VFS/implicit-include.c
  cfe/trunk/test/VFS/include-mixed-real-and-virtual.c
  cfe/trunk/test/VFS/include-real-from-virtual.c
  cfe/trunk/test/VFS/include-virtual-from-real.c
  cfe/trunk/test/VFS/include.c
  cfe/trunk/test/VFS/incomplete-umbrella.m
  cfe/trunk/test/VFS/module-import.m
  cfe/trunk/test/VFS/module_missing_vfs.m
  cfe/trunk/test/VFS/real-path-found-first.m
  cfe/trunk/test/VFS/relative-path.c
  cfe/trunk/test/VFS/subframework-symlink.m
  cfe/trunk/test/VFS/test_nonmodular.c
  cfe/trunk/test/VFS/umbrella-framework-import-skipnonexist.m
  cfe/trunk/test/VFS/vfsroot-include.c
  cfe/trunk/test/VFS/vfsroot-module.m
  cfe/trunk/test/VFS/vfsroot-with-overlay.c

Index: cfe/trunk/test/Modules/framework-public-includes-private.m
===
--- cfe/trunk/test/Modules/framework-public-includes-private.m
+++ cfe/trunk/test/Modules/framework-public-includes-private.m
@@ -1,4 +1,5 @@
-// REQUIRES: shell
+// FIXME: PR43272
+// XFAIL: windows
 
 // RUN: rm -rf %t
 // RUN: mkdir %t
@@ -6,7 +7,7 @@
 // RUN: %hmaptool write %S/Inputs/framework-public-includes-private/a.hmap.json %t/a.hmap
 // RUN: %hmaptool write %S/Inputs/framework-public-includes-private/z.hmap.json %t/z.hmap
 
-// RUN: sed -e "s:TEST_DIR:%S/Inputs/framework-public-includes-private:g" \
+// RUN: sed -e "s@TEST_DIR@%/S/Inputs/framework-public-includes-private@g" \
 // RUN:   %S/Inputs/framework-public-includes-private/z.yaml > %t/z.yaml
 
 // The output with and without modules should be the same, without modules first.
Index: cfe/trunk/test/Modules/crash-vfs-ivfsoverlay.m
===
--- cfe/trunk/test/Modules/crash-vfs-ivfsoverlay.m
+++ cfe/trunk/test/Modules/crash-vfs-ivfsoverlay.m
@@ -1,9 +1,9 @@
-// REQUIRES: crash-recovery, shell, system-darwin
+// REQUIRES: crash-recovery, system-darwin
 
 // RUN: rm -rf %t
 // RUN: mkdir -p %t/m
 // RUN: cp %S/../VFS/Inputs/actual_module2.map %t/actual_module2.map
-// RUN: sed -e "s:INPUT_DIR:%t:g" -e "s:OUT_DIR:%t/example:g" \
+// RUN: sed -e "s@INPUT_DIR@%/t@g" -e "s@OUT_DIR@%/t/example@g" \
 // RUN:   %S/../VFS/Inputs/vfsoverlay2.yaml > %t/srcvfs.yaml
 
 // RUN: not env FORCE_CLANG_DIAGNOSTICS_CRASH= TMPDIR=%t TEMP=%t TMP=%t \
Index: cfe/trunk/test/Modules/double-quotes.m
===
--- cfe/trunk/test/Modules/double-quotes.m
+++ cfe/trunk/test/Modules/double-quotes.m
@@ -1,4 +1,5 @@
-// REQUIRES: shell
+// FIXME: PR43272
+// XFAIL: windows
 
 // RUN: rm -rf %t
 // RUN: mkdir %t
@@ -6,7 +7,7 @@
 // RUN: %hmaptool write %S/Inputs/double-quotes/a.hmap.json %t/a.hmap
 // RUN: %hmaptool write %S/Inputs/double-quotes/x.hmap.json %t/x.hmap
 
-// RUN: sed -e "s:TEST_DIR:%S/Inputs/double-quotes:g" \
+// RUN: sed -e "s@TEST_DIR@%/S/Inputs/double-quotes@g" \
 // RUN:   %S/Inputs/double-quotes/z.yaml > %t/z.yaml
 
 // The output with and without modules should be the same
Index: cfe/trunk/test/VFS/subframework-symlink.m
===
--- cfe/trunk/test/VFS/subframework-symlink.m
+++ cfe/trunk/test/VFS/subframework-symlink.m
@@ -1,4 +1,5 @@
-// REQUIRES: shell
+// FIXME: PR43272
+// XFAIL: windows
 
 // Test that when a subframework is a symlink to another framework, we don't
 // add it as a submodule to the enclosing framework. We also need to make clang
@@ -17,7 +18,7 @@
 
 // Adding VFS overlay shouldn't change this behavior.
 //
-// RUN: sed -e "s:INPUT_DIR:/InvalidPath:g" -e "s:OUT_DIR:/InvalidPath:g" %S/Inputs/vfsoverlay.yaml > %t/overlay.yaml
+// RUN: sed -e "s@INPUT_DIR@/InvalidPath@g" -e "s@OUT_DIR@/InvalidPath@g" %S/Inputs/vfsoverlay.yaml > %t/overlay.yaml
 // RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t/cache2 -F %t -fsyntax-only %s -ivfsoverlay %t/overlay.yaml
 
 #import 
Index: cfe/trunk/test/VFS/relative-path.c
===
--- cfe/trunk/test/VFS/relative-path.c
+++ cfe/trunk/test/VFS/relative-path.c
@@ -1,8 +1,10 @@
 // RUN: mkdir -p %t
 // RUN: cd %t
-// RUN: sed -e "s:INPUT_DIR:%S/Inputs:g" -e "s:OUT_DIR:%t:g" %S/Inputs/vfsoverlay.yaml > %t.yaml
+// RUN: 

r371663 - Start porting ivfsoverlay tests to Windows

2019-09-11 Thread Reid Kleckner via cfe-commits
Author: rnk
Date: Wed Sep 11 13:56:25 2019
New Revision: 371663

URL: http://llvm.org/viewvc/llvm-project?rev=371663=rev
Log:
Start porting ivfsoverlay tests to Windows

Part of PR43272, the changes are:

1. Use @ as the sed pattern delimiter instead of : so that the drive
letter in lit substitutions isn't an issue.

2. Use the %/t and %/S substitutions to get paths with forward slashes
to work around string quoting issues in the yaml file.

3. Replace REQUIRES:shell with XFAIL:windows. These tests should pass on
Windows, but do not for reasons that are not yet understood. We would
like to know if they pass unexpectedly.

I was able to remove the XFAILs from two tests, since they already pass
with my sed fix:
  clang/test/VFS/module_missing_vfs.m
  clang/test/VFS/test_nonmodular.c

Reviewers: amccarth

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

Modified:
cfe/trunk/test/Index/index-module-with-vfs.m
cfe/trunk/test/Modules/crash-vfs-ivfsoverlay.m
cfe/trunk/test/Modules/double-quotes.m
cfe/trunk/test/Modules/framework-public-includes-private.m
cfe/trunk/test/VFS/external-names.c
cfe/trunk/test/VFS/framework-import.m
cfe/trunk/test/VFS/implicit-include.c
cfe/trunk/test/VFS/include-mixed-real-and-virtual.c
cfe/trunk/test/VFS/include-real-from-virtual.c
cfe/trunk/test/VFS/include-virtual-from-real.c
cfe/trunk/test/VFS/include.c
cfe/trunk/test/VFS/incomplete-umbrella.m
cfe/trunk/test/VFS/module-import.m
cfe/trunk/test/VFS/module_missing_vfs.m
cfe/trunk/test/VFS/real-path-found-first.m
cfe/trunk/test/VFS/relative-path.c
cfe/trunk/test/VFS/subframework-symlink.m
cfe/trunk/test/VFS/test_nonmodular.c
cfe/trunk/test/VFS/umbrella-framework-import-skipnonexist.m
cfe/trunk/test/VFS/vfsroot-include.c
cfe/trunk/test/VFS/vfsroot-module.m
cfe/trunk/test/VFS/vfsroot-with-overlay.c

Modified: cfe/trunk/test/Index/index-module-with-vfs.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/index-module-with-vfs.m?rev=371663=371662=371663=diff
==
--- cfe/trunk/test/Index/index-module-with-vfs.m (original)
+++ cfe/trunk/test/Index/index-module-with-vfs.m Wed Sep 11 13:56:25 2019
@@ -1,4 +1,6 @@
-// REQUIRES: shell
+// FIXME: PR43272
+// XFAIL: windows
+
 @import ModuleNeedsVFS;
 
 void foo() {
@@ -7,11 +9,11 @@ void foo() {
 }
 
 // RUN: rm -rf %t.cache
-// RUN: sed -e "s:INPUT_DIR:%S/Inputs:g" -e "s:OUT_DIR:%t:g" 
%S/Inputs/vfsoverlay.yaml > %t.yaml
+// RUN: sed -e "s@INPUT_DIR@%/S/Inputs@g" -e "s@OUT_DIR@%/t@g" 
%S/Inputs/vfsoverlay.yaml > %t.yaml
 // RUN: c-index-test -index-file %s -fmodules-cache-path=%t.cache -fmodules -F 
%t -I %t \
 // RUN:  -ivfsoverlay %t.yaml -Xclang -fdisable-module-hash | 
FileCheck %s
 
-// CHECK: [importedASTFile]: {{.*}}ModuleNeedsVFS.pcm | loc: 2:1 | name: 
"ModuleNeedsVFS" | isImplicit: 0
+// CHECK: [importedASTFile]: {{.*}}ModuleNeedsVFS.pcm | loc: 4:1 | name: 
"ModuleNeedsVFS" | isImplicit: 0
 // CHECK: [indexEntityReference]: kind: function | name: module_needs_vfs
 // CHECK: [indexEntityReference]: kind: function | name: base_module_needs_vfs
 

Modified: cfe/trunk/test/Modules/crash-vfs-ivfsoverlay.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/crash-vfs-ivfsoverlay.m?rev=371663=371662=371663=diff
==
--- cfe/trunk/test/Modules/crash-vfs-ivfsoverlay.m (original)
+++ cfe/trunk/test/Modules/crash-vfs-ivfsoverlay.m Wed Sep 11 13:56:25 2019
@@ -1,9 +1,9 @@
-// REQUIRES: crash-recovery, shell, system-darwin
+// REQUIRES: crash-recovery, system-darwin
 
 // RUN: rm -rf %t
 // RUN: mkdir -p %t/m
 // RUN: cp %S/../VFS/Inputs/actual_module2.map %t/actual_module2.map
-// RUN: sed -e "s:INPUT_DIR:%t:g" -e "s:OUT_DIR:%t/example:g" \
+// RUN: sed -e "s@INPUT_DIR@%/t@g" -e "s@OUT_DIR@%/t/example@g" \
 // RUN:   %S/../VFS/Inputs/vfsoverlay2.yaml > %t/srcvfs.yaml
 
 // RUN: not env FORCE_CLANG_DIAGNOSTICS_CRASH= TMPDIR=%t TEMP=%t TMP=%t \

Modified: cfe/trunk/test/Modules/double-quotes.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/double-quotes.m?rev=371663=371662=371663=diff
==
--- cfe/trunk/test/Modules/double-quotes.m (original)
+++ cfe/trunk/test/Modules/double-quotes.m Wed Sep 11 13:56:25 2019
@@ -1,4 +1,5 @@
-// REQUIRES: shell
+// FIXME: PR43272
+// XFAIL: windows
 
 // RUN: rm -rf %t
 // RUN: mkdir %t
@@ -6,7 +7,7 @@
 // RUN: %hmaptool write %S/Inputs/double-quotes/a.hmap.json %t/a.hmap
 // RUN: %hmaptool write %S/Inputs/double-quotes/x.hmap.json %t/x.hmap
 
-// RUN: sed -e "s:TEST_DIR:%S/Inputs/double-quotes:g" \
+// RUN: sed -e "s@TEST_DIR@%/S/Inputs/double-quotes@g" \
 // RUN:   %S/Inputs/double-quotes/z.yaml > %t/z.yaml
 
 // The output with and without modules should be the same

Modified: 

[PATCH] D67382: [analyzer] NFC: Move getStmt() and createEndOfPath() out of PathDiagnostic.

2019-09-11 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL371659: [analyzer] NFC: Move getStmt() and createEndOfPath() 
out of PathDiagnostic. (authored by dergachev, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D67382?vs=219455=219794#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D67382

Files:
  cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h
  cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h
  cfe/trunk/lib/StaticAnalyzer/Checkers/DeleteWithNonVirtualDtorChecker.cpp
  cfe/trunk/lib/StaticAnalyzer/Checkers/DynamicTypeChecker.cpp
  cfe/trunk/lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp
  cfe/trunk/lib/StaticAnalyzer/Checkers/InnerPointerChecker.cpp
  cfe/trunk/lib/StaticAnalyzer/Checkers/MacOSKeychainAPIChecker.cpp
  cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
  cfe/trunk/lib/StaticAnalyzer/Checkers/MoveChecker.cpp
  cfe/trunk/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
  
cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.cpp
  
cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.h
  cfe/trunk/lib/StaticAnalyzer/Checkers/Taint.cpp
  cfe/trunk/lib/StaticAnalyzer/Checkers/ValistChecker.cpp
  cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp
  cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
  cfe/trunk/lib/StaticAnalyzer/Core/ExplodedGraph.cpp
  cfe/trunk/lib/StaticAnalyzer/Core/LoopUnrolling.cpp
  cfe/trunk/lib/StaticAnalyzer/Core/PathDiagnostic.cpp

Index: cfe/trunk/lib/StaticAnalyzer/Core/LoopUnrolling.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Core/LoopUnrolling.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Core/LoopUnrolling.cpp
@@ -165,7 +165,9 @@
 return true;
 
   while (!N->pred_empty()) {
-const Stmt *S = PathDiagnosticLocation::getStmt(N);
+// FIXME: getStmtForDiagnostics() does nasty things in order to provide
+// a valid statement for body farms, do we need this behavior here?
+const Stmt *S = N->getStmtForDiagnostics();
 if (!S) {
   N = N->getFirstPred();
   continue;
Index: cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
@@ -308,9 +308,7 @@
 BugReporterVisitor::getDefaultEndPath(const BugReporterContext ,
   const ExplodedNode *EndPathNode,
   const PathSensitiveBugReport ) {
-  PathDiagnosticLocation L =
-  PathDiagnosticLocation::createEndOfPath(EndPathNode);
-
+  PathDiagnosticLocation L = BR.getLocation();
   const auto  = BR.getRanges();
 
   // Only add the statement itself as a range if we didn't specify any
@@ -852,7 +850,7 @@
   /// \return Source location of right hand side of an assignment
   /// into \c RegionOfInterest, empty optional if none found.
   Optional matchAssignment(const ExplodedNode *N) {
-const Stmt *S = PathDiagnosticLocation::getStmt(N);
+const Stmt *S = N->getStmtForDiagnostics();
 ProgramStateRef State = N->getState();
 auto *LCtx = N->getLocationContext();
 if (!S)
@@ -1919,7 +1917,7 @@
 static const ExplodedNode* findNodeForExpression(const ExplodedNode *N,
  const Expr *Inner) {
   while (N) {
-if (PathDiagnosticLocation::getStmt(N) == Inner)
+if (N->getStmtForDiagnostics() == Inner)
   return N;
 N = N->getFirstPred();
   }
Index: cfe/trunk/lib/StaticAnalyzer/Core/PathDiagnostic.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Core/PathDiagnostic.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Core/PathDiagnostic.cpp
@@ -30,7 +30,6 @@
 #include "clang/Basic/SourceLocation.h"
 #include "clang/Basic/SourceManager.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h"
-#include "clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/FoldingSet.h"
 #include "llvm/ADT/None.h"
@@ -524,12 +523,12 @@
 // PathDiagnosticLocation methods.
 //===--===//
 
-static SourceLocation getValidSourceLocation(const Stmt* S,
- LocationOrAnalysisDeclContext LAC,
- bool UseEnd = false) {
-  SourceLocation L = UseEnd ? S->getEndLoc() : S->getBeginLoc();
-  assert(!LAC.isNull() && "A valid LocationContext or AnalysisDeclContext should "
-  "be passed to PathDiagnosticLocation upon creation.");
+SourceLocation 

[PATCH] D67418: [analyzer] NFC: Move PathDiagnostic::resetDiagnosticLocationToMainFile to bug reporter.

2019-09-11 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL371660: [analyzer] NFC: Move 
resetDiagnosticLocationToMainFile() to BugReporter. (authored by dergachev, 
committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D67418?vs=219624=219795#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D67418

Files:
  cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h
  cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp
  cfe/trunk/lib/StaticAnalyzer/Core/PathDiagnostic.cpp

Index: cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h
===
--- cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h
@@ -792,11 +792,6 @@
 VerboseDesc += S;
   }
 
-  /// If the last piece of the report point to the header file, resets
-  /// the location of the report to be the last location in the main source
-  /// file.
-  void resetDiagnosticLocationToMainFile();
-
   StringRef getVerboseDescription() const { return VerboseDesc; }
 
   StringRef getShortDescription() const {
@@ -807,11 +802,6 @@
   StringRef getBugType() const { return BugType; }
   StringRef getCategory() const { return Category; }
 
-  /// Return the semantic context where an issue occurred.  If the
-  /// issue occurs along a path, this represents the "central" area
-  /// where the bug manifests.
-  const Decl *getDeclWithIssue() const { return DeclWithIssue; }
-
   using meta_iterator = std::deque::const_iterator;
 
   meta_iterator meta_begin() const { return OtherDesc.begin(); }
@@ -826,10 +816,23 @@
 return *ExecutedLines;
   }
 
+  /// Return the semantic context where an issue occurred.  If the
+  /// issue occurs along a path, this represents the "central" area
+  /// where the bug manifests.
+  const Decl *getDeclWithIssue() const { return DeclWithIssue; }
+
+  void setDeclWithIssue(const Decl *D) {
+DeclWithIssue = D;
+  }
+
   PathDiagnosticLocation getLocation() const {
 return Loc;
   }
 
+  void setLocation(PathDiagnosticLocation NewLoc) {
+Loc = NewLoc;
+  }
+
   /// Get the location on which the report should be uniqued.
   PathDiagnosticLocation getUniqueingLoc() const {
 return UniqueingLoc;
Index: cfe/trunk/lib/StaticAnalyzer/Core/PathDiagnostic.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Core/PathDiagnostic.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Core/PathDiagnostic.cpp
@@ -29,7 +29,6 @@
 #include "clang/Basic/LLVM.h"
 #include "clang/Basic/SourceLocation.h"
 #include "clang/Basic/SourceManager.h"
-#include "clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/FoldingSet.h"
 #include "llvm/ADT/None.h"
@@ -130,69 +129,6 @@
   UniqueingDecl(DeclToUnique), ExecutedLines(std::move(ExecutedLines)),
   path(pathImpl) {}
 
-static PathDiagnosticCallPiece *
-getFirstStackedCallToHeaderFile(PathDiagnosticCallPiece *CP,
-const SourceManager ) {
-  SourceLocation CallLoc = CP->callEnter.asLocation();
-
-  // If the call is within a macro, don't do anything (for now).
-  if (CallLoc.isMacroID())
-return nullptr;
-
-  assert(AnalysisManager::isInCodeFile(CallLoc, SMgr) &&
- "The call piece should not be in a header file.");
-
-  // Check if CP represents a path through a function outside of the main file.
-  if (!AnalysisManager::isInCodeFile(CP->callEnterWithin.asLocation(), SMgr))
-return CP;
-
-  const PathPieces  = CP->path;
-  if (Path.empty())
-return nullptr;
-
-  // Check if the last piece in the callee path is a call to a function outside
-  // of the main file.
-  if (auto *CPInner = dyn_cast(Path.back().get()))
-return getFirstStackedCallToHeaderFile(CPInner, SMgr);
-
-  // Otherwise, the last piece is in the main file.
-  return nullptr;
-}
-
-void PathDiagnostic::resetDiagnosticLocationToMainFile() {
-  if (path.empty())
-return;
-
-  PathDiagnosticPiece *LastP = path.back().get();
-  assert(LastP);
-  const SourceManager  = LastP->getLocation().getManager();
-
-  // We only need to check if the report ends inside headers, if the last piece
-  // is a call piece.
-  if (auto *CP = dyn_cast(LastP)) {
-CP = getFirstStackedCallToHeaderFile(CP, SMgr);
-if (CP) {
-  // Mark the piece.
-   CP->setAsLastInMainSourceFile();
-
-  // Update the path diagnostic message.
-  const auto *ND = dyn_cast(CP->getCallee());
-  if (ND) {
-SmallString<200> buf;
-llvm::raw_svector_ostream os(buf);
-os << " (within a call to '" << ND->getDeclName() << "')";
-appendToDesc(os.str());
-  }
-
-  // Reset the report 

[PATCH] D67381: [analyzer] NFC: Move stack hints to a side map.

2019-09-11 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL371658: [analyzer] NFC: Re-implement stack hints as a side 
map in BugReport. (authored by dergachev, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D67381?vs=219451=219793#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D67381

Files:
  cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h
  cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h
  cfe/trunk/lib/StaticAnalyzer/Checkers/DeleteWithNonVirtualDtorChecker.cpp
  cfe/trunk/lib/StaticAnalyzer/Checkers/DynamicTypeChecker.cpp
  cfe/trunk/lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp
  cfe/trunk/lib/StaticAnalyzer/Checkers/InnerPointerChecker.cpp
  cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
  cfe/trunk/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
  cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp
  cfe/trunk/lib/StaticAnalyzer/Core/PathDiagnostic.cpp

Index: cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h
===
--- cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h
@@ -502,65 +502,13 @@
   }
 };
 
-/// Interface for classes constructing Stack hints.
-///
-/// If a PathDiagnosticEvent occurs in a different frame than the final
-/// diagnostic the hints can be used to summarize the effect of the call.
-class StackHintGenerator {
-public:
-  virtual ~StackHintGenerator() = 0;
-
-  /// Construct the Diagnostic message for the given ExplodedNode.
-  virtual std::string getMessage(const ExplodedNode *N) = 0;
-};
-
-/// Constructs a Stack hint for the given symbol.
-///
-/// The class knows how to construct the stack hint message based on
-/// traversing the CallExpr associated with the call and checking if the given
-/// symbol is returned or is one of the arguments.
-/// The hint can be customized by redefining 'getMessageForX()' methods.
-class StackHintGeneratorForSymbol : public StackHintGenerator {
-private:
-  SymbolRef Sym;
-  std::string Msg;
-
-public:
-  StackHintGeneratorForSymbol(SymbolRef S, StringRef M) : Sym(S), Msg(M) {}
-  ~StackHintGeneratorForSymbol() override = default;
-
-  /// Search the call expression for the symbol Sym and dispatch the
-  /// 'getMessageForX()' methods to construct a specific message.
-  std::string getMessage(const ExplodedNode *N) override;
-
-  /// Produces the message of the following form:
-  ///   'Msg via Nth parameter'
-  virtual std::string getMessageForArg(const Expr *ArgE, unsigned ArgIndex);
-
-  virtual std::string getMessageForReturn(const CallExpr *CallExpr) {
-return Msg;
-  }
-
-  virtual std::string getMessageForSymbolNotFound() {
-return Msg;
-  }
-};
-
 class PathDiagnosticEventPiece : public PathDiagnosticSpotPiece {
   Optional IsPrunable;
 
-  /// If the event occurs in a different frame than the final diagnostic,
-  /// supply a message that will be used to construct an extra hint on the
-  /// returns from all the calls on the stack from this event to the final
-  /// diagnostic.
-  std::unique_ptr CallStackHint;
-
 public:
   PathDiagnosticEventPiece(const PathDiagnosticLocation ,
-   StringRef s, bool addPosRange = true,
-   StackHintGenerator *stackHint = nullptr)
-  : PathDiagnosticSpotPiece(pos, s, Event, addPosRange),
-CallStackHint(stackHint) {}
+   StringRef s, bool addPosRange = true)
+  : PathDiagnosticSpotPiece(pos, s, Event, addPosRange) {}
   ~PathDiagnosticEventPiece() override;
 
   /// Mark the diagnostic piece as being potentially prunable.  This
@@ -577,16 +525,6 @@
 return IsPrunable.hasValue() ? IsPrunable.getValue() : false;
   }
 
-  bool hasCallStackHint() { return (bool)CallStackHint; }
-
-  /// Produce the hint for the given node. The node contains
-  /// information about the call for which the diagnostic can be generated.
-  std::string getCallStackMessage(const ExplodedNode *N) {
-if (CallStackHint)
-  return CallStackHint->getMessage(N);
-return {};
-  }
-
   void dump() const override;
 
   static bool classof(const PathDiagnosticPiece *P) {
Index: cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h
===
--- cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h
@@ -70,6 +70,50 @@
 using DiagnosticForConsumerMapTy =
 llvm::DenseMap>;
 
+/// Interface for classes constructing Stack hints.
+///
+/// If a PathDiagnosticEvent occurs in a different frame than the final
+/// diagnostic the 

[PATCH] D67419: [analyzer] NFC: Move PathDiagnostic to libAnalysis.

2019-09-11 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ marked 2 inline comments as done.
NoQ added a comment.

In D67419#1665993 , @Szelethus wrote:

> Looks great! Are we sure that `PathDiagnostic.h` is a good header name?


Not really, but i haven't come up with a better name yet (see also the summary 
of D67422 ).

P.S. Sry, i seem to have had a spam streak today.


Repository:
  rC Clang

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

https://reviews.llvm.org/D67419



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


[PATCH] D67381: [analyzer] NFC: Move stack hints to a side map.

2019-09-11 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ marked 2 inline comments as done.
NoQ added a comment.

In D67381#1665930 , @Szelethus wrote:

> Side note, now that you had to work with the freshly rewritten file, do you 
> have any feedback on it?


Dunno, i'm a very functional / pure / stateless person. "I debugged, I edited, 
I forgot ". "I suffer from 
short-term memory loss 
".

But given that it was fairly easy for me to focus on the task at hand and this 
whole thing was definitely not traumatizing, i suspect that the file ended up 
in a fairly good shape and i can't complain.


Repository:
  rC Clang

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

https://reviews.llvm.org/D67381



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


[clang-tools-extra] r371661 - [analyzer] NFC: Move PathDiagnostic classes to libAnalysis.

2019-09-11 Thread Artem Dergachev via cfe-commits
Author: dergachev
Date: Wed Sep 11 13:54:27 2019
New Revision: 371661

URL: http://llvm.org/viewvc/llvm-project?rev=371661=rev
Log:
[analyzer] NFC: Move PathDiagnostic classes to libAnalysis.

At this point the PathDiagnostic, PathDiagnosticLocation, PathDiagnosticPiece
structures no longer rely on anything specific to Static Analyzer, so we can
move them out of it for everybody to use.

PathDiagnosticConsumers are still to be handed off.

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

Modified:
clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp

Modified: clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp?rev=371661=371660=371661=diff
==
--- clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp Wed Sep 11 13:54:27 2019
@@ -36,10 +36,6 @@
 #include "clang/Rewrite/Frontend/FixItRewriter.h"
 #include "clang/Rewrite/Frontend/FrontendActions.h"
 #include "clang/Tooling/Core/Diagnostic.h"
-#if CLANG_ENABLE_STATIC_ANALYZER
-#include "clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h"
-#include "clang/StaticAnalyzer/Frontend/AnalysisConsumer.h"
-#endif // CLANG_ENABLE_STATIC_ANALYZER
 #include "clang/Tooling/DiagnosticsYaml.h"
 #include "clang/Tooling/Refactoring.h"
 #include "clang/Tooling/ReplacementsYaml.h"
@@ -49,6 +45,11 @@
 #include 
 #include 
 
+#if CLANG_ENABLE_STATIC_ANALYZER
+#include "clang/Analysis/PathDiagnostic.h"
+#include "clang/StaticAnalyzer/Frontend/AnalysisConsumer.h"
+#endif // CLANG_ENABLE_STATIC_ANALYZER
+
 using namespace clang::ast_matchers;
 using namespace clang::driver;
 using namespace clang::tooling;


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


r371659 - [analyzer] NFC: Move getStmt() and createEndOfPath() out of PathDiagnostic.

2019-09-11 Thread Artem Dergachev via cfe-commits
Author: dergachev
Date: Wed Sep 11 13:54:21 2019
New Revision: 371659

URL: http://llvm.org/viewvc/llvm-project?rev=371659=rev
Log:
[analyzer] NFC: Move getStmt() and createEndOfPath() out of PathDiagnostic.

These static functions deal with ExplodedNodes which is something we don't want
the PathDiagnostic interface to know anything about, as it's planned to be
moved out of libStaticAnalyzerCore.

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

Modified:
cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h
cfe/trunk/lib/StaticAnalyzer/Checkers/DeleteWithNonVirtualDtorChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/DynamicTypeChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/InnerPointerChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/MacOSKeychainAPIChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/MoveChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp

cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.cpp

cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.h
cfe/trunk/lib/StaticAnalyzer/Checkers/Taint.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/ValistChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp
cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
cfe/trunk/lib/StaticAnalyzer/Core/ExplodedGraph.cpp
cfe/trunk/lib/StaticAnalyzer/Core/LoopUnrolling.cpp
cfe/trunk/lib/StaticAnalyzer/Core/PathDiagnostic.cpp

Modified: 
cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h?rev=371659=371658=371659=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h 
(original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h 
Wed Sep 11 13:54:21 2019
@@ -52,11 +52,6 @@ class SourceManager;
 
 namespace ento {
 
-class ExplodedNode;
-class SymExpr;
-
-using SymbolRef = const SymExpr *;
-
 
//===--===//
 // High-level interface for handlers of path-sensitive diagnostics.
 
//===--===//
@@ -276,18 +271,21 @@ public:
   static PathDiagnosticLocation createDeclEnd(const LocationContext *LC,
const SourceManager );
 
-  /// Create a location corresponding to the given valid ExplodedNode.
+  /// Create a location corresponding to the given valid ProgramPoint.
   static PathDiagnosticLocation create(const ProgramPoint ,
const SourceManager );
 
-  /// Create a location corresponding to the next valid ExplodedNode as end
-  /// of path location.
-  static PathDiagnosticLocation createEndOfPath(const ExplodedNode* N);
-
   /// Convert the given location into a single kind location.
   static PathDiagnosticLocation createSingleLocation(
  const PathDiagnosticLocation 
);
 
+  /// Construct a source location that corresponds to either the beginning
+  /// or the end of the given statement, or a nearby valid source location
+  /// if the statement does not have a valid source location of its own.
+  static SourceLocation
+  getValidSourceLocation(const Stmt *S, LocationOrAnalysisDeclContext LAC,
+ bool UseEndOfStatement = false);
+
   bool operator==(const PathDiagnosticLocation ) const {
 return K == X.K && Loc == X.Loc && Range == X.Range;
   }
@@ -332,13 +330,6 @@ public:
   void Profile(llvm::FoldingSetNodeID ) const;
 
   void dump() const;
-
-  /// Given an exploded node, retrieve the statement that should be used
-  /// for the diagnostic location.
-  static const Stmt *getStmt(const ExplodedNode *N);
-
-  /// Retrieve the statement corresponding to the successor node.
-  static const Stmt *getNextStmt(const ExplodedNode *N);
 };
 
 class PathDiagnosticLocationPair {

Modified: 
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h?rev=371659=371658=371659=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h 
(original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h 
Wed Sep 11 13:54:21 2019
@@ -267,6 +267,30 @@ public:
   /// Trivial nodes may be skipped while printing exploded graph.
   bool isTrivial() 

r371660 - [analyzer] NFC: Move resetDiagnosticLocationToMainFile() to BugReporter.

2019-09-11 Thread Artem Dergachev via cfe-commits
Author: dergachev
Date: Wed Sep 11 13:54:24 2019
New Revision: 371660

URL: http://llvm.org/viewvc/llvm-project?rev=371660=rev
Log:
[analyzer] NFC: Move resetDiagnosticLocationToMainFile() to BugReporter.

This method of PathDiagnostic is a part of Static Analyzer's particular
path diagnostic construction scheme. As such, it doesn't belong to
the PathDiagnostic class, but to the Analyzer.

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

Modified:
cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h
cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp
cfe/trunk/lib/StaticAnalyzer/Core/PathDiagnostic.cpp

Modified: 
cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h?rev=371660=371659=371660=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h 
(original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h 
Wed Sep 11 13:54:24 2019
@@ -792,11 +792,6 @@ public:
 VerboseDesc += S;
   }
 
-  /// If the last piece of the report point to the header file, resets
-  /// the location of the report to be the last location in the main source
-  /// file.
-  void resetDiagnosticLocationToMainFile();
-
   StringRef getVerboseDescription() const { return VerboseDesc; }
 
   StringRef getShortDescription() const {
@@ -807,11 +802,6 @@ public:
   StringRef getBugType() const { return BugType; }
   StringRef getCategory() const { return Category; }
 
-  /// Return the semantic context where an issue occurred.  If the
-  /// issue occurs along a path, this represents the "central" area
-  /// where the bug manifests.
-  const Decl *getDeclWithIssue() const { return DeclWithIssue; }
-
   using meta_iterator = std::deque::const_iterator;
 
   meta_iterator meta_begin() const { return OtherDesc.begin(); }
@@ -826,10 +816,23 @@ public:
 return *ExecutedLines;
   }
 
+  /// Return the semantic context where an issue occurred.  If the
+  /// issue occurs along a path, this represents the "central" area
+  /// where the bug manifests.
+  const Decl *getDeclWithIssue() const { return DeclWithIssue; }
+
+  void setDeclWithIssue(const Decl *D) {
+DeclWithIssue = D;
+  }
+
   PathDiagnosticLocation getLocation() const {
 return Loc;
   }
 
+  void setLocation(PathDiagnosticLocation NewLoc) {
+Loc = NewLoc;
+  }
+
   /// Get the location on which the report should be uniqued.
   PathDiagnosticLocation getUniqueingLoc() const {
 return UniqueingLoc;

Modified: cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp?rev=371660=371659=371660=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp Wed Sep 11 13:54:24 2019
@@ -3125,6 +3125,71 @@ BugReporter::generateDiagnosticForConsum
   return Out;
 }
 
+static PathDiagnosticCallPiece *
+getFirstStackedCallToHeaderFile(PathDiagnosticCallPiece *CP,
+const SourceManager ) {
+  SourceLocation CallLoc = CP->callEnter.asLocation();
+
+  // If the call is within a macro, don't do anything (for now).
+  if (CallLoc.isMacroID())
+return nullptr;
+
+  assert(AnalysisManager::isInCodeFile(CallLoc, SMgr) &&
+ "The call piece should not be in a header file.");
+
+  // Check if CP represents a path through a function outside of the main file.
+  if (!AnalysisManager::isInCodeFile(CP->callEnterWithin.asLocation(), SMgr))
+return CP;
+
+  const PathPieces  = CP->path;
+  if (Path.empty())
+return nullptr;
+
+  // Check if the last piece in the callee path is a call to a function outside
+  // of the main file.
+  if (auto *CPInner = dyn_cast(Path.back().get()))
+return getFirstStackedCallToHeaderFile(CPInner, SMgr);
+
+  // Otherwise, the last piece is in the main file.
+  return nullptr;
+}
+
+static void resetDiagnosticLocationToMainFile(PathDiagnostic ) {
+  if (PD.path.empty())
+return;
+
+  PathDiagnosticPiece *LastP = PD.path.back().get();
+  assert(LastP);
+  const SourceManager  = LastP->getLocation().getManager();
+
+  // We only need to check if the report ends inside headers, if the last piece
+  // is a call piece.
+  if (auto *CP = dyn_cast(LastP)) {
+CP = getFirstStackedCallToHeaderFile(CP, SMgr);
+if (CP) {
+  // Mark the piece.
+   CP->setAsLastInMainSourceFile();
+
+  // Update the path diagnostic message.
+  const auto *ND = dyn_cast(CP->getCallee());
+  if (ND) {
+SmallString<200> buf;
+llvm::raw_svector_ostream os(buf);
+os << " (within a call to '" << ND->getDeclName() << "')";
+PD.appendToDesc(os.str());
+  

r371658 - [analyzer] NFC: Re-implement stack hints as a side map in BugReport.

2019-09-11 Thread Artem Dergachev via cfe-commits
Author: dergachev
Date: Wed Sep 11 13:54:17 2019
New Revision: 371658

URL: http://llvm.org/viewvc/llvm-project?rev=371658=rev
Log:
[analyzer] NFC: Re-implement stack hints as a side map in BugReport.

That's one of the few random entities in the PathDiagnostic interface that
are specific to the Static Analyzer. By moving them out we could let
everybody use path diagnostics without linking against Static Analyzer.

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

Modified:
cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h
cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h
cfe/trunk/lib/StaticAnalyzer/Checkers/DeleteWithNonVirtualDtorChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/DynamicTypeChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/InnerPointerChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp
cfe/trunk/lib/StaticAnalyzer/Core/PathDiagnostic.cpp

Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h?rev=371658=371657=371658=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h 
(original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h Wed 
Sep 11 13:54:17 2019
@@ -70,6 +70,50 @@ class SValBuilder;
 using DiagnosticForConsumerMapTy =
 llvm::DenseMap>;
 
+/// Interface for classes constructing Stack hints.
+///
+/// If a PathDiagnosticEvent occurs in a different frame than the final
+/// diagnostic the hints can be used to summarize the effect of the call.
+class StackHintGenerator {
+public:
+  virtual ~StackHintGenerator() = 0;
+
+  /// Construct the Diagnostic message for the given ExplodedNode.
+  virtual std::string getMessage(const ExplodedNode *N) = 0;
+};
+
+/// Constructs a Stack hint for the given symbol.
+///
+/// The class knows how to construct the stack hint message based on
+/// traversing the CallExpr associated with the call and checking if the given
+/// symbol is returned or is one of the arguments.
+/// The hint can be customized by redefining 'getMessageForX()' methods.
+class StackHintGeneratorForSymbol : public StackHintGenerator {
+private:
+  SymbolRef Sym;
+  std::string Msg;
+
+public:
+  StackHintGeneratorForSymbol(SymbolRef S, StringRef M) : Sym(S), Msg(M) {}
+  ~StackHintGeneratorForSymbol() override = default;
+
+  /// Search the call expression for the symbol Sym and dispatch the
+  /// 'getMessageForX()' methods to construct a specific message.
+  std::string getMessage(const ExplodedNode *N) override;
+
+  /// Produces the message of the following form:
+  ///   'Msg via Nth parameter'
+  virtual std::string getMessageForArg(const Expr *ArgE, unsigned ArgIndex);
+
+  virtual std::string getMessageForReturn(const CallExpr *CallExpr) {
+return Msg;
+  }
+
+  virtual std::string getMessageForSymbolNotFound() {
+return Msg;
+  }
+};
+
 /// This class provides an interface through which checkers can create
 /// individual bug reports.
 class BugReport {
@@ -313,6 +357,14 @@ protected:
 
   const Stmt *getStmt() const;
 
+  /// If an event occurs in a different frame than the final diagnostic,
+  /// supply a message that will be used to construct an extra hint on the
+  /// returns from all the calls on the stack from this event to the final
+  /// diagnostic.
+  // FIXME: Allow shared_ptr keys in DenseMap?
+  std::map>
+  StackHints;
+
 public:
   PathSensitiveBugReport(const BugType , StringRef desc,
  const ExplodedNode *errorNode)
@@ -455,6 +507,26 @@ public:
   bool addTrackedCondition(const ExplodedNode *Cond) {
 return TrackedConditions.insert(Cond).second;
   }
+
+  void addCallStackHint(PathDiagnosticPieceRef Piece,
+std::unique_ptr StackHint) {
+StackHints[Piece] = std::move(StackHint);
+  }
+
+  bool hasCallStackHint(PathDiagnosticPieceRef Piece) const {
+return StackHints.count(Piece) > 0;
+  }
+
+  /// Produce the hint for the given node. The node contains
+  /// information about the call for which the diagnostic can be generated.
+  std::string
+  getCallStackMessage(PathDiagnosticPieceRef Piece,
+  const ExplodedNode *N) const {
+auto I = StackHints.find(Piece);
+if (I != StackHints.end())
+  return I->second->getMessage(N);
+return "";
+  }
 };
 
 
//===--===//

Modified: 
cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h
URL: 

[PATCH] D67455: [Clang][CodeGen] support alias attribute w/ gnu_inline

2019-09-11 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers updated this revision to Diff 219790.
nickdesaulniers added a comment.

- adjust parens


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67455

Files:
  clang/lib/AST/Decl.cpp
  clang/test/CodeGen/alias.c


Index: clang/test/CodeGen/alias.c
===
--- clang/test/CodeGen/alias.c
+++ clang/test/CodeGen/alias.c
@@ -99,3 +99,8 @@
 // CHECKGLOBALS-NOT: @test11_foo = dso_local
 void test11(void) {}
 static void test11_foo(void) __attribute__((alias("test11")));
+
+// Test that gnu_inline+alias work.
+// CHECKGLOBALS: @test12_alias = alias void (), void ()* @test12
+void test12(void) {}
+inline void test12_alias(void) __attribute__((gnu_inline, alias("test12")));
Index: clang/lib/AST/Decl.cpp
===
--- clang/lib/AST/Decl.cpp
+++ clang/lib/AST/Decl.cpp
@@ -3348,7 +3348,8 @@
 /// an externally visible symbol, but "extern inline" will not create an
 /// externally visible symbol.
 bool FunctionDecl::isInlineDefinitionExternallyVisible() const {
-  assert((doesThisDeclarationHaveABody() || willHaveBody()) &&
+  assert((doesThisDeclarationHaveABody() || willHaveBody() ||
+  hasAttr()) &&
  "Must be a function definition");
   assert(isInlined() && "Function must be inline");
   ASTContext  = getASTContext();


Index: clang/test/CodeGen/alias.c
===
--- clang/test/CodeGen/alias.c
+++ clang/test/CodeGen/alias.c
@@ -99,3 +99,8 @@
 // CHECKGLOBALS-NOT: @test11_foo = dso_local
 void test11(void) {}
 static void test11_foo(void) __attribute__((alias("test11")));
+
+// Test that gnu_inline+alias work.
+// CHECKGLOBALS: @test12_alias = alias void (), void ()* @test12
+void test12(void) {}
+inline void test12_alias(void) __attribute__((gnu_inline, alias("test12")));
Index: clang/lib/AST/Decl.cpp
===
--- clang/lib/AST/Decl.cpp
+++ clang/lib/AST/Decl.cpp
@@ -3348,7 +3348,8 @@
 /// an externally visible symbol, but "extern inline" will not create an
 /// externally visible symbol.
 bool FunctionDecl::isInlineDefinitionExternallyVisible() const {
-  assert((doesThisDeclarationHaveABody() || willHaveBody()) &&
+  assert((doesThisDeclarationHaveABody() || willHaveBody() ||
+  hasAttr()) &&
  "Must be a function definition");
   assert(isInlined() && "Function must be inline");
   ASTContext  = getASTContext();
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D67127: [clang-scan-deps] add skip excluded conditional preprocessor block preprocessing optimization

2019-09-11 Thread Alex Lorenz via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL371656: [clang-scan-deps] add skip excluded conditional 
preprocessor block… (authored by arphaman, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D67127?vs=218821=219789#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D67127

Files:
  cfe/trunk/include/clang/Lex/DependencyDirectivesSourceMinimizer.h
  cfe/trunk/include/clang/Lex/Lexer.h
  cfe/trunk/include/clang/Lex/Preprocessor.h
  
cfe/trunk/include/clang/Lex/PreprocessorExcludedConditionalDirectiveSkipMapping.h
  cfe/trunk/include/clang/Lex/PreprocessorOptions.h
  
cfe/trunk/include/clang/Tooling/DependencyScanning/DependencyScanningFilesystem.h
  cfe/trunk/include/clang/Tooling/DependencyScanning/DependencyScanningService.h
  cfe/trunk/include/clang/Tooling/DependencyScanning/DependencyScanningWorker.h
  cfe/trunk/lib/Lex/DependencyDirectivesSourceMinimizer.cpp
  cfe/trunk/lib/Lex/Lexer.cpp
  cfe/trunk/lib/Lex/PPDirectives.cpp
  cfe/trunk/lib/Lex/Preprocessor.cpp
  cfe/trunk/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp
  cfe/trunk/lib/Tooling/DependencyScanning/DependencyScanningService.cpp
  cfe/trunk/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
  cfe/trunk/test/ClangScanDeps/regular_cdb.cpp
  cfe/trunk/tools/clang-scan-deps/ClangScanDeps.cpp
  cfe/trunk/unittests/Lex/DependencyDirectivesSourceMinimizerTest.cpp

Index: cfe/trunk/lib/Lex/Preprocessor.cpp
===
--- cfe/trunk/lib/Lex/Preprocessor.cpp
+++ cfe/trunk/lib/Lex/Preprocessor.cpp
@@ -158,6 +158,11 @@
 
   if (this->PPOpts->GeneratePreamble)
 PreambleConditionalStack.startRecording();
+
+  ExcludedConditionalDirectiveSkipMappings =
+  this->PPOpts->ExcludedConditionalDirectiveSkipMappings;
+  if (ExcludedConditionalDirectiveSkipMappings)
+ExcludedConditionalDirectiveSkipMappings->clear();
 }
 
 Preprocessor::~Preprocessor() {
Index: cfe/trunk/lib/Lex/Lexer.cpp
===
--- cfe/trunk/lib/Lex/Lexer.cpp
+++ cfe/trunk/lib/Lex/Lexer.cpp
@@ -218,6 +218,15 @@
   return L;
 }
 
+bool Lexer::skipOver(unsigned NumBytes) {
+  IsAtPhysicalStartOfLine = true;
+  IsAtStartOfLine = true;
+  if ((BufferPtr + NumBytes) > BufferEnd)
+return true;
+  BufferPtr += NumBytes;
+  return false;
+}
+
 template  static void StringifyImpl(T , char Quote) {
   typename T::size_type i = 0, e = Str.size();
   while (i < e) {
Index: cfe/trunk/lib/Lex/DependencyDirectivesSourceMinimizer.cpp
===
--- cfe/trunk/lib/Lex/DependencyDirectivesSourceMinimizer.cpp
+++ cfe/trunk/lib/Lex/DependencyDirectivesSourceMinimizer.cpp
@@ -865,6 +865,54 @@
   return Error;
 }
 
+bool clang::minimize_source_to_dependency_directives::computeSkippedRanges(
+ArrayRef Input, llvm::SmallVectorImpl ) {
+  struct Directive {
+enum DirectiveKind {
+  If,  // if/ifdef/ifndef
+  Else // elif,else
+};
+int Offset;
+DirectiveKind Kind;
+  };
+  llvm::SmallVector Offsets;
+  for (const Token  : Input) {
+switch (T.K) {
+case pp_if:
+case pp_ifdef:
+case pp_ifndef:
+  Offsets.push_back({T.Offset, Directive::If});
+  break;
+
+case pp_elif:
+case pp_else: {
+  if (Offsets.empty())
+return true;
+  int PreviousOffset = Offsets.back().Offset;
+  Range.push_back({PreviousOffset, T.Offset - PreviousOffset});
+  Offsets.push_back({T.Offset, Directive::Else});
+  break;
+}
+
+case pp_endif: {
+  if (Offsets.empty())
+return true;
+  int PreviousOffset = Offsets.back().Offset;
+  Range.push_back({PreviousOffset, T.Offset - PreviousOffset});
+  do {
+Directive::DirectiveKind Kind = Offsets.pop_back_val().Kind;
+if (Kind == Directive::If)
+  break;
+  } while (!Offsets.empty());
+  break;
+}
+default:
+  break;
+}
+  }
+  return false;
+}
+
 bool clang::minimizeSourceToDependencyDirectives(
 StringRef Input, SmallVectorImpl ,
 SmallVectorImpl , DiagnosticsEngine *Diags,
Index: cfe/trunk/lib/Lex/PPDirectives.cpp
===
--- cfe/trunk/lib/Lex/PPDirectives.cpp
+++ cfe/trunk/lib/Lex/PPDirectives.cpp
@@ -370,6 +370,37 @@
   return DiscardUntilEndOfDirective().getEnd();
 }
 
+Optional Preprocessor::getSkippedRangeForExcludedConditionalBlock(
+SourceLocation HashLoc) {
+  if (!ExcludedConditionalDirectiveSkipMappings)
+return None;
+  if (!HashLoc.isFileID())
+return None;
+
+  std::pair HashFileOffset =
+  SourceMgr.getDecomposedLoc(HashLoc);
+  const llvm::MemoryBuffer *Buf = SourceMgr.getBuffer(HashFileOffset.first);
+  auto It = 

[PATCH] D58094: Fix -Wnonportable-include-path suppression for header maps with absolute paths.

2019-09-11 Thread Volodymyr Sapsai via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL371655: Fix -Wnonportable-include-path suppression for 
header maps with absolute paths. (authored by vsapsai, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D58094?vs=219194=219788#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D58094

Files:
  cfe/trunk/include/clang/Lex/DirectoryLookup.h
  cfe/trunk/lib/Lex/HeaderSearch.cpp
  cfe/trunk/test/Preprocessor/Inputs/nonportable-hmaps/foo.hmap.json
  cfe/trunk/test/Preprocessor/Inputs/nonportable-hmaps/headers/foo/Bar.h
  cfe/trunk/test/Preprocessor/Inputs/nonportable-hmaps/headers/foo/Baz.h
  cfe/trunk/test/Preprocessor/nonportable-include-with-hmap.c

Index: cfe/trunk/lib/Lex/HeaderSearch.cpp
===
--- cfe/trunk/lib/Lex/HeaderSearch.cpp
+++ cfe/trunk/lib/Lex/HeaderSearch.cpp
@@ -341,9 +341,10 @@
 SmallVectorImpl *SearchPath, SmallVectorImpl *RelativePath,
 Module *RequestingModule, ModuleMap::KnownHeader *SuggestedModule,
 bool , bool ,
-bool , SmallVectorImpl ) const {
+bool , SmallVectorImpl ) const {
   InUserSpecifiedSystemFramework = false;
-  HasBeenMapped = false;
+  IsInHeaderMap = false;
+  MappedName.clear();
 
   SmallString<1024> TmpDir;
   if (isNormalDir()) {
@@ -377,6 +378,8 @@
   if (Dest.empty())
 return None;
 
+  IsInHeaderMap = true;
+
   auto FixupSearchPath = [&]() {
 if (SearchPath) {
   StringRef SearchPathRef(getName());
@@ -393,10 +396,8 @@
   // ("Foo.h" -> "Foo/Foo.h"), in which case continue header lookup using the
   // framework include.
   if (llvm::sys::path::is_relative(Dest)) {
-MappedName.clear();
 MappedName.append(Dest.begin(), Dest.end());
 Filename = StringRef(MappedName.begin(), MappedName.size());
-HasBeenMapped = true;
 Optional Result = HM->LookupFile(Filename, HS.getFileMgr());
 if (Result) {
   FixupSearchPath();
@@ -883,18 +884,22 @@
   // Check each directory in sequence to see if it contains this file.
   for (; i != SearchDirs.size(); ++i) {
 bool InUserSpecifiedSystemFramework = false;
-bool HasBeenMapped = false;
+bool IsInHeaderMap = false;
 bool IsFrameworkFoundInDir = false;
 Optional File = SearchDirs[i].LookupFile(
 Filename, *this, IncludeLoc, SearchPath, RelativePath, RequestingModule,
 SuggestedModule, InUserSpecifiedSystemFramework, IsFrameworkFoundInDir,
-HasBeenMapped, MappedName);
-if (HasBeenMapped) {
+IsInHeaderMap, MappedName);
+if (!MappedName.empty()) {
+  assert(IsInHeaderMap && "MappedName should come from a header map");
   CacheLookup.MappedName =
-  copyString(Filename, LookupFileCache.getAllocator());
-  if (IsMapped)
-*IsMapped = true;
+  copyString(MappedName, LookupFileCache.getAllocator());
 }
+if (IsMapped)
+  // A filename is mapped when a header map remapped it to a relative path
+  // used in subsequent header search or to an absolute path pointing to an
+  // existing file.
+  *IsMapped |= (!MappedName.empty() || (IsInHeaderMap && File));
 if (IsFrameworkFound)
   // Because we keep a filename remapped for subsequent search directory
   // lookups, ignore IsFrameworkFoundInDir after the first remapping and not
Index: cfe/trunk/include/clang/Lex/DirectoryLookup.h
===
--- cfe/trunk/include/clang/Lex/DirectoryLookup.h
+++ cfe/trunk/include/clang/Lex/DirectoryLookup.h
@@ -183,7 +183,7 @@
  SmallVectorImpl *RelativePath, Module *RequestingModule,
  ModuleMap::KnownHeader *SuggestedModule,
  bool , bool ,
- bool , SmallVectorImpl ) const;
+ bool , SmallVectorImpl ) const;
 
 private:
   Optional DoFrameworkLookup(
Index: cfe/trunk/test/Preprocessor/Inputs/nonportable-hmaps/foo.hmap.json
===
--- cfe/trunk/test/Preprocessor/Inputs/nonportable-hmaps/foo.hmap.json
+++ cfe/trunk/test/Preprocessor/Inputs/nonportable-hmaps/foo.hmap.json
@@ -1,6 +1,9 @@
 {
   "mappings" :
 {
- "Foo/Foo.h" : "headers/foo/Foo.h"
+ "Foo/Foo.h" : "headers/foo/Foo.h",
+ "Bar.h" : "headers/foo/Bar.h",
+ "Foo/Bar.h" : "INPUTS_DIR/nonportable-hmaps/headers/foo/Bar.h",
+ "headers/Foo/Baz.h" : "/not/existing/absolute/path/Baz.h"
 }
 }
Index: cfe/trunk/test/Preprocessor/nonportable-include-with-hmap.c
===
--- cfe/trunk/test/Preprocessor/nonportable-include-with-hmap.c
+++ cfe/trunk/test/Preprocessor/nonportable-include-with-hmap.c
@@ -1,5 +1,9 @@
+// REQUIRES: shell
+
 // RUN: rm -f %t.hmap
-// RUN: %hmaptool write 

r371656 - [clang-scan-deps] add skip excluded conditional preprocessor block preprocessing optimization

2019-09-11 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Wed Sep 11 13:40:31 2019
New Revision: 371656

URL: http://llvm.org/viewvc/llvm-project?rev=371656=rev
Log:
[clang-scan-deps] add skip excluded conditional preprocessor block 
preprocessing optimization

This commit adds an optimization to clang-scan-deps and clang's preprocessor 
that skips excluded preprocessor
blocks by bumping the lexer pointer, and not lexing the tokens until reaching 
appropriate #else/#endif directive.
The skip positions and lexer offsets are computed when the file is minimized, 
directly from the minimized tokens.

On an 18-core iMacPro with macOS Catalina Beta I got 10-15% speed-up from this 
optimization when running clang-scan-deps on
the compilation database for a recent LLVM and Clang (3511 files).

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

Added:

cfe/trunk/include/clang/Lex/PreprocessorExcludedConditionalDirectiveSkipMapping.h
Modified:
cfe/trunk/include/clang/Lex/DependencyDirectivesSourceMinimizer.h
cfe/trunk/include/clang/Lex/Lexer.h
cfe/trunk/include/clang/Lex/Preprocessor.h
cfe/trunk/include/clang/Lex/PreprocessorOptions.h

cfe/trunk/include/clang/Tooling/DependencyScanning/DependencyScanningFilesystem.h

cfe/trunk/include/clang/Tooling/DependencyScanning/DependencyScanningService.h

cfe/trunk/include/clang/Tooling/DependencyScanning/DependencyScanningWorker.h
cfe/trunk/lib/Lex/DependencyDirectivesSourceMinimizer.cpp
cfe/trunk/lib/Lex/Lexer.cpp
cfe/trunk/lib/Lex/PPDirectives.cpp
cfe/trunk/lib/Lex/Preprocessor.cpp
cfe/trunk/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp
cfe/trunk/lib/Tooling/DependencyScanning/DependencyScanningService.cpp
cfe/trunk/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
cfe/trunk/test/ClangScanDeps/regular_cdb.cpp
cfe/trunk/tools/clang-scan-deps/ClangScanDeps.cpp
cfe/trunk/unittests/Lex/DependencyDirectivesSourceMinimizerTest.cpp

Modified: cfe/trunk/include/clang/Lex/DependencyDirectivesSourceMinimizer.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/DependencyDirectivesSourceMinimizer.h?rev=371656=371655=371656=diff
==
--- cfe/trunk/include/clang/Lex/DependencyDirectivesSourceMinimizer.h (original)
+++ cfe/trunk/include/clang/Lex/DependencyDirectivesSourceMinimizer.h Wed Sep 
11 13:40:31 2019
@@ -66,6 +66,24 @@ struct Token {
   Token(TokenKind K, int Offset) : K(K), Offset(Offset) {}
 };
 
+/// Simplified token range to track the range of a potentially skippable PP
+/// directive.
+struct SkippedRange {
+  /// Offset into the output byte stream of where the skipped directive begins.
+  int Offset;
+
+  /// The number of bytes that can be skipped before the preprocessing must
+  /// resume.
+  int Length;
+};
+
+/// Computes the potential source ranges that can be skipped by the 
preprocessor
+/// when skipping a directive like #if, #ifdef or #elsif.
+///
+/// \returns false on success, true on error.
+bool computeSkippedRanges(ArrayRef Input,
+  llvm::SmallVectorImpl );
+
 } // end namespace minimize_source_to_dependency_directives
 
 /// Minimize the input down to the preprocessor directives that might have

Modified: cfe/trunk/include/clang/Lex/Lexer.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/Lexer.h?rev=371656=371655=371656=diff
==
--- cfe/trunk/include/clang/Lex/Lexer.h (original)
+++ cfe/trunk/include/clang/Lex/Lexer.h Wed Sep 11 13:40:31 2019
@@ -265,6 +265,21 @@ public:
   /// Return the current location in the buffer.
   const char *getBufferLocation() const { return BufferPtr; }
 
+  /// Returns the current lexing offset.
+  unsigned getCurrentBufferOffset() {
+assert(BufferPtr >= BufferStart && "Invalid buffer state");
+return BufferPtr - BufferStart;
+  }
+
+  /// Skip over \p NumBytes bytes.
+  ///
+  /// If the skip is successful, the next token will be lexed from the new
+  /// offset. The lexer also assumes that we skipped to the start of the line.
+  ///
+  /// \returns true if the skip failed (new offset would have been past the
+  /// end of the buffer), false otherwise.
+  bool skipOver(unsigned NumBytes);
+
   /// Stringify - Convert the specified string into a C string by i) escaping
   /// '\\' and " characters and ii) replacing newline character(s) with "\\n".
   /// If Charify is true, this escapes the ' character instead of ".

Modified: cfe/trunk/include/clang/Lex/Preprocessor.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/Preprocessor.h?rev=371656=371655=371656=diff
==
--- cfe/trunk/include/clang/Lex/Preprocessor.h (original)
+++ cfe/trunk/include/clang/Lex/Preprocessor.h Wed Sep 11 13:40:31 2019
@@ -28,6 +28,7 @@
 #include 

r371655 - Fix -Wnonportable-include-path suppression for header maps with absolute paths.

2019-09-11 Thread Volodymyr Sapsai via cfe-commits
Author: vsapsai
Date: Wed Sep 11 13:39:04 2019
New Revision: 371655

URL: http://llvm.org/viewvc/llvm-project?rev=371655=rev
Log:
Fix -Wnonportable-include-path suppression for header maps with absolute paths.

In `DirectoryLookup::LookupFile` parameter `HasBeenMapped` doesn't cover
the case when clang finds a file through a header map but doesn't remap
the lookup filename because the target path is an absolute path. As a
result, -Wnonportable-include-path suppression for header maps
introduced in r301592 wasn't triggered.

Change parameter `HasBeenMapped` to `IsInHeaderMap` and use parameter
`MappedName` to track the filename remapping. This way we can handle
both relative and absolute paths in header maps, and account for their
specific properties, like filename remapping being a property preserved
across lookups in multiple directories.

rdar://problem/39516483

Reviewers: dexonsmith, bruno

Reviewed By: dexonsmith

Subscribers: jkorous, cfe-commits, ributzka

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

Added:
cfe/trunk/test/Preprocessor/Inputs/nonportable-hmaps/headers/foo/Bar.h
cfe/trunk/test/Preprocessor/Inputs/nonportable-hmaps/headers/foo/Baz.h
Modified:
cfe/trunk/include/clang/Lex/DirectoryLookup.h
cfe/trunk/lib/Lex/HeaderSearch.cpp
cfe/trunk/test/Preprocessor/Inputs/nonportable-hmaps/foo.hmap.json
cfe/trunk/test/Preprocessor/nonportable-include-with-hmap.c

Modified: cfe/trunk/include/clang/Lex/DirectoryLookup.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/DirectoryLookup.h?rev=371655=371654=371655=diff
==
--- cfe/trunk/include/clang/Lex/DirectoryLookup.h (original)
+++ cfe/trunk/include/clang/Lex/DirectoryLookup.h Wed Sep 11 13:39:04 2019
@@ -183,7 +183,7 @@ public:
  SmallVectorImpl *RelativePath, Module *RequestingModule,
  ModuleMap::KnownHeader *SuggestedModule,
  bool , bool ,
- bool , SmallVectorImpl ) const;
+ bool , SmallVectorImpl ) const;
 
 private:
   Optional DoFrameworkLookup(

Modified: cfe/trunk/lib/Lex/HeaderSearch.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/HeaderSearch.cpp?rev=371655=371654=371655=diff
==
--- cfe/trunk/lib/Lex/HeaderSearch.cpp (original)
+++ cfe/trunk/lib/Lex/HeaderSearch.cpp Wed Sep 11 13:39:04 2019
@@ -341,9 +341,10 @@ Optional DirectoryLookup::
 SmallVectorImpl *SearchPath, SmallVectorImpl *RelativePath,
 Module *RequestingModule, ModuleMap::KnownHeader *SuggestedModule,
 bool , bool ,
-bool , SmallVectorImpl ) const {
+bool , SmallVectorImpl ) const {
   InUserSpecifiedSystemFramework = false;
-  HasBeenMapped = false;
+  IsInHeaderMap = false;
+  MappedName.clear();
 
   SmallString<1024> TmpDir;
   if (isNormalDir()) {
@@ -377,6 +378,8 @@ Optional DirectoryLookup::
   if (Dest.empty())
 return None;
 
+  IsInHeaderMap = true;
+
   auto FixupSearchPath = [&]() {
 if (SearchPath) {
   StringRef SearchPathRef(getName());
@@ -393,10 +396,8 @@ Optional DirectoryLookup::
   // ("Foo.h" -> "Foo/Foo.h"), in which case continue header lookup using the
   // framework include.
   if (llvm::sys::path::is_relative(Dest)) {
-MappedName.clear();
 MappedName.append(Dest.begin(), Dest.end());
 Filename = StringRef(MappedName.begin(), MappedName.size());
-HasBeenMapped = true;
 Optional Result = HM->LookupFile(Filename, HS.getFileMgr());
 if (Result) {
   FixupSearchPath();
@@ -883,18 +884,22 @@ Optional HeaderSearch::Loo
   // Check each directory in sequence to see if it contains this file.
   for (; i != SearchDirs.size(); ++i) {
 bool InUserSpecifiedSystemFramework = false;
-bool HasBeenMapped = false;
+bool IsInHeaderMap = false;
 bool IsFrameworkFoundInDir = false;
 Optional File = SearchDirs[i].LookupFile(
 Filename, *this, IncludeLoc, SearchPath, RelativePath, 
RequestingModule,
 SuggestedModule, InUserSpecifiedSystemFramework, IsFrameworkFoundInDir,
-HasBeenMapped, MappedName);
-if (HasBeenMapped) {
+IsInHeaderMap, MappedName);
+if (!MappedName.empty()) {
+  assert(IsInHeaderMap && "MappedName should come from a header map");
   CacheLookup.MappedName =
-  copyString(Filename, LookupFileCache.getAllocator());
-  if (IsMapped)
-*IsMapped = true;
+  copyString(MappedName, LookupFileCache.getAllocator());
 }
+if (IsMapped)
+  // A filename is mapped when a header map remapped it to a relative path
+  // used in subsequent header search or to an absolute path pointing to an
+  // existing file.
+  *IsMapped |= (!MappedName.empty() || (IsInHeaderMap && File));
 if (IsFrameworkFound)
   // Because we keep a filename remapped for subsequent search directory
   // lookups, ignore 

[PATCH] D64943: [Clang][OpenMP offload] Eliminate use of OpenMP linker script

2019-09-11 Thread Sergey Dmitriev via Phabricator via cfe-commits
sdmitriev added a comment.

In D64943#136 , @JonChesterfield 
wrote:

> I'm not sure copying the crtbegin/crtend mechanism from the early days of C 
> runtime is ideal. Since the data is stored in a common section anyway, please 
> could we rename it to __omp_offloading_entries in which case the linker will 
> provide start/end symbols automatically?


Well, I never said that it is an ideal solution, but it is a known mechanism 
that works well in many cases and can also be reused for the offloading entry 
table.
I do not fully understand your suggestion for renaming entries section, how it 
will help with providing start/end symbols for the entries. Can you please 
provide more details?


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

https://reviews.llvm.org/D64943



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


[PATCH] D58094: Fix -Wnonportable-include-path suppression for header maps with absolute paths.

2019-09-11 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai marked 2 inline comments as done.
vsapsai added a comment.

Thanks for the review.




Comment at: clang/lib/Lex/HeaderSearch.cpp:892-902
+IsInHeaderMap, MappedName);
+if (!MappedName.empty()) {
+  assert(IsInHeaderMap && "MappedName should come from a header map");
   CacheLookup.MappedName =
-  copyString(Filename, LookupFileCache.getAllocator());
-  if (IsMapped)
-*IsMapped = true;
+  copyString(MappedName, LookupFileCache.getAllocator());
 }
+if (IsMapped)

dexonsmith wrote:
> I wonder if this would be easier to follow if you refactored like this:
> 
> ```
> if (!MappedName.empty()) {
>   // other logic.
>   if (IsMapped)
> *IsMapped = true;
> } else if (IsInHeaderMap && File) {
>   if (IsMapped)
> *IsMapped = true;
> }
> ```
> 
> but maybe my aesthetics are being thrown off by all the intervening comments 
> in Phab.  I'll leave it up to you.
I've tried the suggested approach but don't find it better. It is a personal 
preference but I like how `*IsMapped |= ...` conveys the value is an 
"aggregate" of the previous file lookups.


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

https://reviews.llvm.org/D58094



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


[PATCH] D67425: [WebAssembly] Narrowing and widening SIMD ops

2019-09-11 Thread Thomas Lively via Phabricator via cfe-commits
tlively updated this revision to Diff 219784.
tlively added a comment.

- Make narrows binary ops


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67425

Files:
  clang/include/clang/Basic/BuiltinsWebAssembly.def
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/builtins-wasm.c
  llvm/include/llvm/IR/IntrinsicsWebAssembly.td
  llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td
  llvm/test/CodeGen/WebAssembly/simd-intrinsics.ll
  llvm/test/MC/WebAssembly/simd-encodings.s

Index: llvm/test/MC/WebAssembly/simd-encodings.s
===
--- llvm/test/MC/WebAssembly/simd-encodings.s
+++ llvm/test/MC/WebAssembly/simd-encodings.s
@@ -463,4 +463,40 @@
 # CHECK: f64x2.convert_i64x2_u # encoding: [0xfd,0xb2,0x01]
 f64x2.convert_i64x2_u
 
+# CHECK: i8x16.narrow_i16x8_s # encoding: [0xfd,0xc6,0x01]
+i8x16.narrow_i16x8_s
+
+# CHECK: i8x16.narrow_i16x8_u # encoding: [0xfd,0xc7,0x01]
+i8x16.narrow_i16x8_u
+
+# CHECK: i16x8.narrow_i32x4_s # encoding: [0xfd,0xc8,0x01]
+i16x8.narrow_i32x4_s
+
+# CHECK: i16x8.narrow_i32x4_u # encoding: [0xfd,0xc9,0x01]
+i16x8.narrow_i32x4_u
+
+# CHECK: i16x8.widen_low_i8x16_s # encoding: [0xfd,0xca,0x01]
+i16x8.widen_low_i8x16_s
+
+# CHECK: i16x8.widen_high_i8x16_s # encoding: [0xfd,0xcb,0x01]
+i16x8.widen_high_i8x16_s
+
+# CHECK: i16x8.widen_low_i8x16_u # encoding: [0xfd,0xcc,0x01]
+i16x8.widen_low_i8x16_u
+
+# CHECK: i16x8.widen_high_i8x16_u # encoding: [0xfd,0xcd,0x01]
+i16x8.widen_high_i8x16_u
+
+# CHECK: i32x4.widen_low_i16x8_s # encoding: [0xfd,0xce,0x01]
+i32x4.widen_low_i16x8_s
+
+# CHECK: i32x4.widen_high_i16x8_s # encoding: [0xfd,0xcf,0x01]
+i32x4.widen_high_i16x8_s
+
+# CHECK: i32x4.widen_low_i16x8_u # encoding: [0xfd,0xd0,0x01]
+i32x4.widen_low_i16x8_u
+
+# CHECK: i32x4.widen_high_i16x8_u # encoding: [0xfd,0xd1,0x01]
+i32x4.widen_high_i16x8_u
+
 end_function
Index: llvm/test/CodeGen/WebAssembly/simd-intrinsics.ll
===
--- llvm/test/CodeGen/WebAssembly/simd-intrinsics.ll
+++ llvm/test/CodeGen/WebAssembly/simd-intrinsics.ll
@@ -87,6 +87,30 @@
   ret <16 x i8> %a
 }
 
+; CHECK-LABEL: narrow_signed_v16i8:
+; SIMD128-NEXT: .functype narrow_signed_v16i8 (v128, v128) -> (v128){{$}}
+; SIMD128-NEXT: i8x16.narrow_i16x8_s $push[[R:[0-9]+]]=, $0, $1{{$}}
+; SIMD128-NEXT: return $pop[[R]]{{$}}
+declare <16 x i8> @llvm.wasm.narrow.signed.v16i8.v8i16(<8 x i16>, <8 x i16>)
+define <16 x i8> @narrow_signed_v16i8(<8 x i16> %low, <8 x i16> %high) {
+  %a = call <16 x i8> @llvm.wasm.narrow.signed.v16i8.v8i16(
+<8 x i16> %low, <8 x i16> %high
+  )
+  ret <16 x i8> %a
+}
+
+; CHECK-LABEL: narrow_unsigned_v16i8:
+; SIMD128-NEXT: .functype narrow_unsigned_v16i8 (v128, v128) -> (v128){{$}}
+; SIMD128-NEXT: i8x16.narrow_i16x8_u $push[[R:[0-9]+]]=, $0, $1{{$}}
+; SIMD128-NEXT: return $pop[[R]]{{$}}
+declare <16 x i8> @llvm.wasm.narrow.unsigned.v16i8.v8i16(<8 x i16>, <8 x i16>)
+define <16 x i8> @narrow_unsigned_v16i8(<8 x i16> %low, <8 x i16> %high) {
+  %a = call <16 x i8> @llvm.wasm.narrow.unsigned.v16i8.v8i16(
+<8 x i16> %low, <8 x i16> %high
+  )
+  ret <16 x i8> %a
+}
+
 ; ==
 ; 8 x i16
 ; ==
@@ -166,6 +190,70 @@
   ret <8 x i16> %a
 }
 
+; CHECK-LABEL: narrow_signed_v8i16:
+; SIMD128-NEXT: .functype narrow_signed_v8i16 (v128, v128) -> (v128){{$}}
+; SIMD128-NEXT: i16x8.narrow_i32x4_s $push[[R:[0-9]+]]=, $0, $1{{$}}
+; SIMD128-NEXT: return $pop[[R]]{{$}}
+declare <8 x i16> @llvm.wasm.narrow.signed.v8i16.v4i32(<4 x i32>, <4 x i32>)
+define <8 x i16> @narrow_signed_v8i16(<4 x i32> %low, <4 x i32> %high) {
+  %a = call <8 x i16> @llvm.wasm.narrow.signed.v8i16.v4i32(
+<4 x i32> %low, <4 x i32> %high
+  )
+  ret <8 x i16> %a
+}
+
+; CHECK-LABEL: narrow_unsigned_v8i16:
+; SIMD128-NEXT: .functype narrow_unsigned_v8i16 (v128, v128) -> (v128){{$}}
+; SIMD128-NEXT: i16x8.narrow_i32x4_u $push[[R:[0-9]+]]=, $0, $1{{$}}
+; SIMD128-NEXT: return $pop[[R]]{{$}}
+declare <8 x i16> @llvm.wasm.narrow.unsigned.v8i16.v4i32(<4 x i32>, <4 x i32>)
+define <8 x i16> @narrow_unsigned_v8i16(<4 x i32> %low, <4 x i32> %high) {
+  %a = call <8 x i16> @llvm.wasm.narrow.unsigned.v8i16.v4i32(
+<4 x i32> %low, <4 x i32> %high
+  )
+  ret <8 x i16> %a
+}
+
+; CHECK-LABEL: widen_low_signed_v8i16:
+; SIMD128-NEXT: .functype widen_low_signed_v8i16 (v128) -> (v128){{$}}
+; SIMD128-NEXT: i16x8.widen_low_i8x16_s $push[[R:[0-9]+]]=, $0{{$}}
+; SIMD128-NEXT: return $pop[[R]]{{$}}
+declare <8 x i16> @llvm.wasm.widen.low.signed.v8i16.v16i8(<16 x i8>)
+define <8 x i16> @widen_low_signed_v8i16(<16 x i8> %v) {
+  %a = call <8 x i16> 

RE: [PATCH] D64943: [Clang][OpenMP offload] Eliminate use of OpenMP linker script

2019-09-11 Thread Narayanaswamy, Ravi via cfe-commits
Microsoft linker does not support linker script. 
We need to solution that works with all linkers.   The begin/end is supported 
by most linker of interest.

-Original Message-
From: Jon Chesterfield via Phabricator [mailto:revi...@reviews.llvm.org] 
Sent: Wednesday, September 11, 2019 12:21 PM
To: Dmitriev, Serguei N ; hfin...@anl.gov; 
a.bat...@hotmail.com; Narayanaswamy, Ravi ; 
jdoerf...@anl.gov; gheorghe-teod.ber...@ibm.com; Rokos, Georgios 

Cc: lebedev...@gmail.com; jonathanchesterfi...@gmail.com; Zakharin, Vyacheslav 
P ; sando...@cray.com; 
openmp-comm...@lists.llvm.org; cfe-commits@lists.llvm.org; mgo...@gentoo.org; 
zhang.guans...@gmail.com; mgrang.1...@gmail.com; t...@google.com; 
ztur...@roblox.com; peter.wal...@arm.com
Subject: [PATCH] D64943: [Clang][OpenMP offload] Eliminate use of OpenMP linker 
script

JonChesterfield added a comment.

In D64943#173 , @ABataev wrote:

> In D64943#158 , @JonChesterfield 
> wrote:
>
> > > OpenMP linker script is known to cause problems for gold and lld linkers 
> > > on Linux and it will also cause problems for Windows enabling in future
> >
> > What are the known problems with the linker script? I'm wondering if they 
> > can be resolved without the overhead of introducing a new tool.
>
>
> They just do not support linker script. And, thus, cannot be used for 
> offloading. Only `ld` supports it.


In what respect? I've used linker scripts with both gold and lld, and both 
instances of --help text claim to support them. In the case of lld, a very 
complicated script hit a few internal errors, but I believe they've all been 
fixed since.


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

https://reviews.llvm.org/D64943



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


[PATCH] D67454: Start porting ivfsoverlay tests to Windows

2019-09-11 Thread Adrian McCarthy via Phabricator via cfe-commits
amccarth accepted this revision.
amccarth added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67454



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


[PATCH] D67463: [MS] Warn when shadowing template parameters under -fms-compatibility

2019-09-11 Thread Reid Kleckner via Phabricator via cfe-commits
rnk created this revision.
rnk added reviewers: thakis, hans.
Herald added a project: clang.

C++ does not allow shadowing template parameters, but previously we
allowed it under -fms-extensions. Now this behavior is controlled by
-fms-compatibility, and we emit a -Wmicrosoft-template warning when it
happens.

Fixes PR43265


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D67463

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaTemplate.cpp
  clang/test/Parser/DelayedTemplateParsing.cpp
  clang/test/SemaCXX/MicrosoftCompatibility.cpp


Index: clang/test/SemaCXX/MicrosoftCompatibility.cpp
===
--- clang/test/SemaCXX/MicrosoftCompatibility.cpp
+++ clang/test/SemaCXX/MicrosoftCompatibility.cpp
@@ -366,3 +366,21 @@
 int S::fn() { return 0; } // expected-warning {{is missing exception 
specification}}
 }
 
+namespace PR43265 {
+template  // expected-note {{template parameter is declared here}}
+struct Foo {
+  static const int N = 42; // expected-warning {{declaration of 'N' shadows 
template parameter}}
+};
+}
+
+namespace Inner_Outer_same_template_param_name {
+template  // expected-note {{template parameter is declared here}}
+struct Outmost {
+  template  // expected-warning {{declaration of 'T' shadows 
template parameter}}
+  struct Inner {
+void f() {
+  T *var;
+}
+  };
+};
+}
Index: clang/test/Parser/DelayedTemplateParsing.cpp
===
--- clang/test/Parser/DelayedTemplateParsing.cpp
+++ clang/test/Parser/DelayedTemplateParsing.cpp
@@ -48,22 +48,6 @@
 
   
 
-namespace Inner_Outer_same_template_param_name {  
-
-template 
-class Outmost {
-public:
-template 
-class Inner {
-public:
-void f() {
-T* var;
-}
-   };
-};
-
-}
-
 
 namespace PR11931 {
 
Index: clang/lib/Sema/SemaTemplate.cpp
===
--- clang/lib/Sema/SemaTemplate.cpp
+++ clang/lib/Sema/SemaTemplate.cpp
@@ -849,15 +849,14 @@
 void Sema::DiagnoseTemplateParameterShadow(SourceLocation Loc, Decl *PrevDecl) 
{
   assert(PrevDecl->isTemplateParameter() && "Not a template parameter");
 
-  // Microsoft Visual C++ permits template parameters to be shadowed.
-  if (getLangOpts().MicrosoftExt)
-return;
-
   // C++ [temp.local]p4:
   //   A template-parameter shall not be redeclared within its
   //   scope (including nested scopes).
-  Diag(Loc, diag::err_template_param_shadow)
-<< cast(PrevDecl)->getDeclName();
+  //
+  // Make this a warning when MSVC compatibility is requested.
+  unsigned DiagId = getLangOpts().MSVCCompat ? diag::ext_template_param_shadow
+ : diag::err_template_param_shadow;
+  Diag(Loc, DiagId) << cast(PrevDecl)->getDeclName();
   Diag(PrevDecl->getLocation(), diag::note_template_param_here);
 }
 
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -4000,6 +4000,8 @@
 // C++ Template Declarations
 def err_template_param_shadow : Error<
   "declaration of %0 shadows template parameter">;
+def ext_template_param_shadow : ExtWarn<
+  err_template_param_shadow.Text>, InGroup;
 def note_template_param_here : Note<"template parameter is declared here">;
 def warn_template_export_unsupported : Warning<
   "exported templates are unsupported">;


Index: clang/test/SemaCXX/MicrosoftCompatibility.cpp
===
--- clang/test/SemaCXX/MicrosoftCompatibility.cpp
+++ clang/test/SemaCXX/MicrosoftCompatibility.cpp
@@ -366,3 +366,21 @@
 int S::fn() { return 0; } // expected-warning {{is missing exception specification}}
 }
 
+namespace PR43265 {
+template  // expected-note {{template parameter is declared here}}
+struct Foo {
+  static const int N = 42; // expected-warning {{declaration of 'N' shadows template parameter}}
+};
+}
+
+namespace Inner_Outer_same_template_param_name {
+template  // expected-note {{template parameter is declared here}}
+struct Outmost {
+  template  // expected-warning {{declaration of 'T' shadows template parameter}}
+  struct Inner {
+void f() {
+  T *var;
+}
+  };
+};
+}
Index: clang/test/Parser/DelayedTemplateParsing.cpp
===
--- clang/test/Parser/DelayedTemplateParsing.cpp
+++ clang/test/Parser/DelayedTemplateParsing.cpp
@@ -48,22 +48,6 @@
 
   
 
-namespace Inner_Outer_same_template_param_name {  
-
-template 
-class Outmost {
-public:
-template 
-class Inner {
-public:
-void f() {
-T* var;
-}
-   };
-};
-
-}
-
 
 namespace PR11931 {
 
Index: clang/lib/Sema/SemaTemplate.cpp

[PATCH] D64943: [Clang][OpenMP offload] Eliminate use of OpenMP linker script

2019-09-11 Thread Sergey Dmitriev via Phabricator via cfe-commits
sdmitriev added a comment.

In D64943#193 , @JonChesterfield 
wrote:

> In D64943#179 , @ABataev wrote:
>
> > In D64943#178 , 
> > @JonChesterfield wrote:
> >
> > > In D64943#173 , @ABataev 
> > > wrote:
> > >
> > > > In D64943#158 , 
> > > > @JonChesterfield wrote:
> > > >
> > > > > > OpenMP linker script is known to cause problems for gold and lld 
> > > > > > linkers on Linux and it will also cause problems for Windows 
> > > > > > enabling in future
> > > > >
> > > > > What are the known problems with the linker script? I'm wondering if 
> > > > > they can be resolved without the overhead of introducing a new tool.
> > > >
> > > >
> > > > They just do not support linker script. And, thus, cannot be used for 
> > > > offloading. Only `ld` supports it.
> > >
> > >
> > > In what respect? I've used linker scripts with both gold and lld, and 
> > > both instances of --help text claim to support them. In the case of lld, 
> > > a very complicated script hit a few internal errors, but I believe 
> > > they've all been fixed since.
> >
> >
> > Hmm, I tried it with gold some time ago and it just did not work for me. 
> > The linking failed with diagnostics that some of the commands in the script 
> > are unknown.
>
>
> The problem turns out to be the 'insert before' statement. ld and lld support 
> it, gold does not. According to 
> https://bugzilla.redhat.com/show_bug.cgi?id=927573, the recommended 
> workaround is essentially that implemented in this differential. See also 
> https://sourceware.org/bugzilla/show_bug.cgi?id=15373.


A small example that I presented on the OpenMP multi company meeting earlier:

  bash-4.2$ cat foo.c
  #include 
  
  int main() {
int X = 0;
  
  #pragma omp target map(tofrom: X)
X += 3;
  
printf("X = %d\n", X);
return 0;
  }
  
  bash-4.2$ clang -fopenmp -fopenmp-targets=x86_64-pc-linux-gnu -fuse-ld=gold 
foo.c
  /usr/bin/ld.gold: error: /tmp/a-c699cd.lk:25:8: syntax error, unexpected 
STRING
  /usr/bin/ld.gold: fatal error: unable to parse script file /tmp/a-c699cd.lk
  clang-10: error: linker command failed with exit code 1 (use -v to see 
invocation)
  bash-4.2$ clang -fopenmp -fopenmp-targets=x86_64-pc-linux-gnu -fuse-ld=lld 
foo.c
  ld.lld: error: unable to INSERT AFTER/BEFORE .data: section not defined
  clang-10: error: linker command failed with exit code 1 (use -v to see 
invocation)
  bash-4.2$ 

Also OpenMP linker script will obviously cause problems on Windows once we 
start enabling offload on Windows.


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

https://reviews.llvm.org/D64943



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


[PATCH] D67460: clang-tidy: modernize-use-using work with multi-argument templates

2019-09-11 Thread Conrad Poelman via Phabricator via cfe-commits
poelmanc created this revision.
poelmanc added reviewers: alexfh, alexfh_.
poelmanc added a project: clang-tools-extra.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

clang-tidy's modernize-use-using feature is great! But if it finds any commas 
that are not within parentheses, it won't create a fix. That means it won't 
change lines like:
`  typedef std::pair Point;`
to
`  using Point = std::pair;`
or even:
`  typedef std::map MyMap;`
`  typedef std::vector> MyVector;`

This patch allows the fix to apply to lines with commas if they are within 
parentheses //or// angle brackets.

One test is include


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D67460

Files:
  clang-tools-extra/clang-tidy/modernize/UseUsingCheck.cpp
  clang-tools-extra/test/clang-tidy/modernize-use-using.cpp


Index: clang-tools-extra/test/clang-tidy/modernize-use-using.cpp
===
--- clang-tools-extra/test/clang-tidy/modernize-use-using.cpp
+++ clang-tools-extra/test/clang-tidy/modernize-use-using.cpp
@@ -182,4 +182,11 @@
 class E : public C {
   void f() override { super::f(); }
 };
+
+template 
+class TwoArgTemplate {
+  typedef TwoArgTemplate self;
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use 'using' instead of 'typedef'
+  // CHECK-FIXES: using self = TwoArgTemplate;
+};
 }
Index: clang-tools-extra/clang-tidy/modernize/UseUsingCheck.cpp
===
--- clang-tools-extra/clang-tidy/modernize/UseUsingCheck.cpp
+++ clang-tools-extra/clang-tidy/modernize/UseUsingCheck.cpp
@@ -40,6 +40,7 @@
 
   Token Tok;
   int ParenLevel = 0;
+  int AngleBracketLevel = 0;
   bool FoundTypedef = false;
 
   while (!DeclLexer.LexFromRawLexer(Tok) && !Tok.is(tok::semi)) {
@@ -54,10 +55,16 @@
 case tok::r_paren:
   ParenLevel--;
   break;
+case tok::less: // '<', start template
+  AngleBracketLevel++;
+  break;
+case tok::greater: // '>', end template
+  AngleBracketLevel--;
+  break;
 case tok::comma:
-  if (ParenLevel == 0) {
-// If there is comma and we are not between open parenthesis then it is
-// two or more declarations in this chain.
+  if (ParenLevel == 0 && AngleBracketLevel == 0) {
+// If there is comma and we are not between open parenthesis or between
+// open angle brackets then it is two or more declarations in this 
chain.
 return false;
   }
   break;
@@ -88,8 +95,7 @@
   if (StartLoc.isMacroID() && IgnoreMacros)
 return;
 
-  auto Diag =
-  diag(StartLoc, "use 'using' instead of 'typedef'");
+  auto Diag = diag(StartLoc, "use 'using' instead of 'typedef'");
 
   // do not fix if there is macro or array
   if (MatchedDecl->getUnderlyingType()->isArrayType() || StartLoc.isMacroID())


Index: clang-tools-extra/test/clang-tidy/modernize-use-using.cpp
===
--- clang-tools-extra/test/clang-tidy/modernize-use-using.cpp
+++ clang-tools-extra/test/clang-tidy/modernize-use-using.cpp
@@ -182,4 +182,11 @@
 class E : public C {
   void f() override { super::f(); }
 };
+
+template 
+class TwoArgTemplate {
+  typedef TwoArgTemplate self;
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use 'using' instead of 'typedef'
+  // CHECK-FIXES: using self = TwoArgTemplate;
+};
 }
Index: clang-tools-extra/clang-tidy/modernize/UseUsingCheck.cpp
===
--- clang-tools-extra/clang-tidy/modernize/UseUsingCheck.cpp
+++ clang-tools-extra/clang-tidy/modernize/UseUsingCheck.cpp
@@ -40,6 +40,7 @@
 
   Token Tok;
   int ParenLevel = 0;
+  int AngleBracketLevel = 0;
   bool FoundTypedef = false;
 
   while (!DeclLexer.LexFromRawLexer(Tok) && !Tok.is(tok::semi)) {
@@ -54,10 +55,16 @@
 case tok::r_paren:
   ParenLevel--;
   break;
+case tok::less: // '<', start template
+  AngleBracketLevel++;
+  break;
+case tok::greater: // '>', end template
+  AngleBracketLevel--;
+  break;
 case tok::comma:
-  if (ParenLevel == 0) {
-// If there is comma and we are not between open parenthesis then it is
-// two or more declarations in this chain.
+  if (ParenLevel == 0 && AngleBracketLevel == 0) {
+// If there is comma and we are not between open parenthesis or between
+// open angle brackets then it is two or more declarations in this chain.
 return false;
   }
   break;
@@ -88,8 +95,7 @@
   if (StartLoc.isMacroID() && IgnoreMacros)
 return;
 
-  auto Diag =
-  diag(StartLoc, "use 'using' instead of 'typedef'");
+  auto Diag = diag(StartLoc, "use 'using' instead of 'typedef'");
 
   // do not fix if there is macro or array
   if (MatchedDecl->getUnderlyingType()->isArrayType() || StartLoc.isMacroID())
___
cfe-commits mailing list

[PATCH] D64943: [Clang][OpenMP offload] Eliminate use of OpenMP linker script

2019-09-11 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield added a comment.

In D64943#179 , @ABataev wrote:

> In D64943#178 , @JonChesterfield 
> wrote:
>
> > In D64943#173 , @ABataev wrote:
> >
> > > In D64943#158 , 
> > > @JonChesterfield wrote:
> > >
> > > > > OpenMP linker script is known to cause problems for gold and lld 
> > > > > linkers on Linux and it will also cause problems for Windows enabling 
> > > > > in future
> > > >
> > > > What are the known problems with the linker script? I'm wondering if 
> > > > they can be resolved without the overhead of introducing a new tool.
> > >
> > >
> > > They just do not support linker script. And, thus, cannot be used for 
> > > offloading. Only `ld` supports it.
> >
> >
> > In what respect? I've used linker scripts with both gold and lld, and both 
> > instances of --help text claim to support them. In the case of lld, a very 
> > complicated script hit a few internal errors, but I believe they've all 
> > been fixed since.
>
>
> Hmm, I tried it with gold some time ago and it just did not work for me. The 
> linking failed with diagnostics that some of the commands in the script are 
> unknown.


The problem turns out to be the 'insert before' statement. ld and lld support 
it, gold does not. According to 
https://bugzilla.redhat.com/show_bug.cgi?id=927573, the recommended workaround 
is essentially that implemented in this differential.


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

https://reviews.llvm.org/D64943



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


[PATCH] D64943: [Clang][OpenMP offload] Eliminate use of OpenMP linker script

2019-09-11 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added a comment.

In D64943#178 , @JonChesterfield 
wrote:

> In D64943#173 , @ABataev wrote:
>
> > In D64943#158 , 
> > @JonChesterfield wrote:
> >
> > > > OpenMP linker script is known to cause problems for gold and lld 
> > > > linkers on Linux and it will also cause problems for Windows enabling 
> > > > in future
> > >
> > > What are the known problems with the linker script? I'm wondering if they 
> > > can be resolved without the overhead of introducing a new tool.
> >
> >
> > They just do not support linker script. And, thus, cannot be used for 
> > offloading. Only `ld` supports it.
>
>
> In what respect? I've used linker scripts with both gold and lld, and both 
> instances of --help text claim to support them. In the case of lld, a very 
> complicated script hit a few internal errors, but I believe they've all been 
> fixed since.


Hmm, I tried it with gold some time ago and it just did not work for me. The 
linking failed with diagnostics that some of the commands in the script are 
unknown.


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

https://reviews.llvm.org/D64943



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


[PATCH] D64943: [Clang][OpenMP offload] Eliminate use of OpenMP linker script

2019-09-11 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield added a comment.

In D64943#173 , @ABataev wrote:

> In D64943#158 , @JonChesterfield 
> wrote:
>
> > > OpenMP linker script is known to cause problems for gold and lld linkers 
> > > on Linux and it will also cause problems for Windows enabling in future
> >
> > What are the known problems with the linker script? I'm wondering if they 
> > can be resolved without the overhead of introducing a new tool.
>
>
> They just do not support linker script. And, thus, cannot be used for 
> offloading. Only `ld` supports it.


In what respect? I've used linker scripts with both gold and lld, and both 
instances of --help text claim to support them. In the case of lld, a very 
complicated script hit a few internal errors, but I believe they've all been 
fixed since.


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

https://reviews.llvm.org/D64943



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


[PATCH] D52524: Add -Wpoison-system-directories warning

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

Aside from a minor nit, this LGTM. However, I'm not the most familiar with how 
cross-compiling works in the first place, so I may be the wrong one to approve 
this.




Comment at: clang/lib/Frontend/InitHeaderSearch.cpp:141-143
+  if (HasSysroot) {
+if (MappedPathStr.startswith("/usr/include") ||
+MappedPathStr.startswith("/usr/local/include")) {

These should be combined into a single if statement:
```
if (HasSysroot && (MappedPathStr.startswith(...) || 
MappedPathStr.startswith(...))) {
```


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

https://reviews.llvm.org/D52524



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


[PATCH] D67382: [analyzer] NFC: Move getStmt() and createEndOfPath() out of PathDiagnostic.

2019-09-11 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ marked 2 inline comments as done.
NoQ added inline comments.



Comment at: clang/lib/StaticAnalyzer/Core/ExplodedGraph.cpp:302-303
   // Find the node's current statement in the CFG.
-  if (const Stmt *S = PathDiagnosticLocation::getStmt(this))
+  // FIXME: getStmtForDiagnostics() does nasty things in order to provide
+  // a valid statement for body farms, do we need this behavior here?
+  if (const Stmt *S = getStmtForDiagnostics())

Szelethus wrote:
> But still fails...
Well, not everything is a statement.



Comment at: clang/lib/StaticAnalyzer/Core/PathDiagnostic.cpp:565-566
 
   // FIXME: Ironically, this assert actually fails in some cases.
   //assert(L.isValid());
   return L;

Szelethus wrote:
> I guess didn't change much :^)
Indeed :)


Repository:
  rC Clang

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

https://reviews.llvm.org/D67382



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


[PATCH] D64943: [Clang][OpenMP offload] Eliminate use of OpenMP linker script

2019-09-11 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added a comment.

In D64943#158 , @JonChesterfield 
wrote:

> > OpenMP linker script is known to cause problems for gold and lld linkers on 
> > Linux and it will also cause problems for Windows enabling in future
>
> What are the known problems with the linker script? I'm wondering if they can 
> be resolved without the overhead of introducing a new tool.


They just do not support linker script. And, thus, cannot be used for 
offloading. Only `ld` supports it.


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

https://reviews.llvm.org/D64943



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


[PATCH] D64943: [Clang][OpenMP offload] Eliminate use of OpenMP linker script

2019-09-11 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield added a comment.

> OpenMP linker script is known to cause problems for gold and lld linkers on 
> Linux and it will also cause problems for Windows enabling in future

What are the known problems with the linker script? I'm wondering if they can 
be resolved without the overhead of introducing a new tool.


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

https://reviews.llvm.org/D64943



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


[PATCH] D67429: Improve code generation for thread_local variables:

2019-09-11 Thread John McCall via Phabricator via cfe-commits
rjmccall accepted this revision.
rjmccall added a comment.
This revision is now accepted and ready to land.

LGTM.


Repository:
  rC Clang

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

https://reviews.llvm.org/D67429



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


[PATCH] D47358: : Implement {un,}synchronized_pool_resource.

2019-09-11 Thread Arthur O'Dwyer via Phabricator via cfe-commits
Quuxplusone updated this revision to Diff 219758.
Quuxplusone added a comment.

Rebased on master.


Repository:
  rCXX libc++

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

https://reviews.llvm.org/D47358

Files:
  include/experimental/memory_resource
  src/experimental/memory_resource.cpp
  
test/libcxx/experimental/memory/memory.resource.pool/memory.resource.pool.mem/unsynchronized_buffer.pass.cpp
  
test/std/experimental/memory/memory.resource.pool/memory.resource.pool.ctor/ctor_does_not_allocate.pass.cpp
  
test/std/experimental/memory/memory.resource.pool/memory.resource.pool.ctor/sync_with_default_resource.pass.cpp
  
test/std/experimental/memory/memory.resource.pool/memory.resource.pool.ctor/unsync_with_default_resource.pass.cpp
  
test/std/experimental/memory/memory.resource.pool/memory.resource.pool.mem/equality.pass.cpp
  
test/std/experimental/memory/memory.resource.pool/memory.resource.pool.mem/sync_allocate.pass.cpp
  
test/std/experimental/memory/memory.resource.pool/memory.resource.pool.mem/sync_allocate_overaligned_request.pass.cpp
  
test/std/experimental/memory/memory.resource.pool/memory.resource.pool.mem/sync_allocate_reuse_blocks.pass.cpp
  
test/std/experimental/memory/memory.resource.pool/memory.resource.pool.mem/sync_deallocate_matches_allocate.pass.cpp
  
test/std/experimental/memory/memory.resource.pool/memory.resource.pool.mem/sync_options.pass.cpp
  
test/std/experimental/memory/memory.resource.pool/memory.resource.pool.mem/sync_upstream_resource.pass.cpp
  
test/std/experimental/memory/memory.resource.pool/memory.resource.pool.mem/unsync_allocate.pass.cpp
  
test/std/experimental/memory/memory.resource.pool/memory.resource.pool.mem/unsync_allocate_overaligned_request.pass.cpp
  
test/std/experimental/memory/memory.resource.pool/memory.resource.pool.mem/unsync_allocate_reuse_blocks.pass.cpp
  
test/std/experimental/memory/memory.resource.pool/memory.resource.pool.mem/unsync_deallocate_matches_allocate.pass.cpp
  
test/std/experimental/memory/memory.resource.pool/memory.resource.pool.mem/unsync_options.pass.cpp
  
test/std/experimental/memory/memory.resource.pool/memory.resource.pool.mem/unsync_upstream_resource.pass.cpp
  test/std/experimental/memory/memory.resource.pool/pool_options.pass.cpp
  test/support/count_new.h

Index: test/support/count_new.h
===
--- test/support/count_new.h
+++ test/support/count_new.h
@@ -210,6 +210,11 @@
 return disable_checking || n != delete_called;
 }
 
+bool checkDeleteCalledGreaterThan(int n) const
+{
+return disable_checking || delete_called > n;
+}
+
 bool checkAlignedNewCalledEq(int n) const
 {
 return disable_checking || n == aligned_new_called;
Index: test/std/experimental/memory/memory.resource.pool/pool_options.pass.cpp
===
--- /dev/null
+++ test/std/experimental/memory/memory.resource.pool/pool_options.pass.cpp
@@ -0,0 +1,28 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// REQUIRES: c++experimental
+// UNSUPPORTED: c++98, c++03, c++11, c++14
+// UNSUPPORTED: apple-clang-7
+
+// 
+
+// struct pool_options
+
+#include 
+#include 
+
+int main(int, char**)
+{
+const std::experimental::pmr::pool_options p;
+assert(p.max_blocks_per_chunk == 0);
+assert(p.largest_required_pool_block == 0);
+
+return 0;
+}
Index: test/std/experimental/memory/memory.resource.pool/memory.resource.pool.mem/unsync_upstream_resource.pass.cpp
===
--- /dev/null
+++ test/std/experimental/memory/memory.resource.pool/memory.resource.pool.mem/unsync_upstream_resource.pass.cpp
@@ -0,0 +1,28 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// REQUIRES: c++experimental
+// UNSUPPORTED: c++98, c++03
+
+// 
+
+// class unsynchronized_pool_resource
+
+#include 
+#include 
+
+#include "count_new.h"
+
+int main(int, char**)
+{
+std::experimental::pmr::unsynchronized_pool_resource unsync;
+LIBCPP_ASSERT_NOEXCEPT(unsync.upstream_resource());
+
+return 0;
+}
Index: test/std/experimental/memory/memory.resource.pool/memory.resource.pool.mem/unsync_options.pass.cpp
===
--- /dev/null
+++ 

[PATCH] D64943: [Clang][OpenMP offload] Eliminate use of OpenMP linker script

2019-09-11 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield added a comment.

I'm not sure copying the crtbegin/crtend mechanism from the early days of C 
runtime is ideal. Since the data is stored in a common section anyway, please 
could we rename it to __omp_offloading_entries in which case the linker will 
provide start/end symbols automatically? That removes the two object files and 
the link order dependency which is a hazard to bitcode libraries.


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

https://reviews.llvm.org/D64943



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


[PATCH] D66121: Debug Info: Nest Objective-C property function decls inside their container.

2019-09-11 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

Right, that sounds reasonable.  You should be making them link up exactly like 
a normal method implementation, so if SemaObjC doesn't consider normal method 
implementations to be redeclarations, then I guess these aren't either.  And if 
we want to change that in the future, then we'll change it for these, too.


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

https://reviews.llvm.org/D66121



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


[PATCH] D47111: : Implement monotonic_buffer_resource.

2019-09-11 Thread Arthur O'Dwyer via Phabricator via cfe-commits
Quuxplusone updated this revision to Diff 219756.
Quuxplusone added a comment.
Herald added a subscriber: dexonsmith.

Rebased on master.


Repository:
  rCXX libc++

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

https://reviews.llvm.org/D47111

Files:
  include/experimental/memory_resource
  src/experimental/memory_resource.cpp
  
test/libcxx/experimental/memory/memory.resource.monotonic.buffer/monotonic.buffer.mem/allocate_in_geometric_progression.pass.cpp
  
test/std/experimental/memory/memory.resource.monotonic.buffer/monotonic.buffer.ctor/copy_move.pass.cpp
  
test/std/experimental/memory/memory.resource.monotonic.buffer/monotonic.buffer.ctor/with_default_resource.pass.cpp
  
test/std/experimental/memory/memory.resource.monotonic.buffer/monotonic.buffer.ctor/without_buffer.pass.cpp
  
test/std/experimental/memory/memory.resource.monotonic.buffer/monotonic.buffer.mem/allocate_deallocate.pass.cpp
  
test/std/experimental/memory/memory.resource.monotonic.buffer/monotonic.buffer.mem/allocate_exception_safety.pass.cpp
  
test/std/experimental/memory/memory.resource.monotonic.buffer/monotonic.buffer.mem/allocate_from_initial_buffer.pass.cpp
  
test/std/experimental/memory/memory.resource.monotonic.buffer/monotonic.buffer.mem/allocate_from_underaligned_buffer.pass.cpp
  
test/std/experimental/memory/memory.resource.monotonic.buffer/monotonic.buffer.mem/allocate_from_zero_sized_buffer.pass.cpp
  
test/std/experimental/memory/memory.resource.monotonic.buffer/monotonic.buffer.mem/allocate_in_geometric_progression.pass.cpp
  
test/std/experimental/memory/memory.resource.monotonic.buffer/monotonic.buffer.mem/allocate_overaligned_request.pass.cpp
  
test/std/experimental/memory/memory.resource.monotonic.buffer/monotonic.buffer.mem/allocate_with_initial_size.pass.cpp
  
test/std/experimental/memory/memory.resource.monotonic.buffer/monotonic.buffer.mem/equality.pass.cpp

Index: test/std/experimental/memory/memory.resource.monotonic.buffer/monotonic.buffer.mem/equality.pass.cpp
===
--- /dev/null
+++ test/std/experimental/memory/memory.resource.monotonic.buffer/monotonic.buffer.mem/equality.pass.cpp
@@ -0,0 +1,64 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// REQUIRES: c++experimental
+// UNSUPPORTED: c++98, c++03
+
+// 
+
+// class monotonic_buffer_resource
+
+#include 
+#include 
+#include 
+#include 
+
+struct assert_on_compare : public std::experimental::pmr::memory_resource
+{
+protected:
+void *do_allocate(size_t, size_t)
+{ assert(false); }
+
+void do_deallocate(void *, size_t, size_t)
+{ assert(false); }
+
+bool do_is_equal(std::experimental::pmr::memory_resource const &) const noexcept
+{ assert(false); }
+};
+
+int main(int, char**)
+{
+// Same object
+{
+std::experimental::pmr::monotonic_buffer_resource r1;
+std::experimental::pmr::monotonic_buffer_resource r2;
+assert(r1 == r1);
+assert(r1 != r2);
+
+std::experimental::pmr::memory_resource & p1 = r1;
+std::experimental::pmr::memory_resource & p2 = r2;
+assert(p1 == p1);
+assert(p1 != p2);
+assert(p1 == r1);
+assert(r1 == p1);
+assert(p1 != r2);
+assert(r2 != p1);
+}
+// Different types
+{
+std::experimental::pmr::monotonic_buffer_resource mono1;
+std::experimental::pmr::memory_resource & r1 = mono1;
+assert_on_compare c;
+std::experimental::pmr::memory_resource & r2 = c;
+assert(r1 != r2);
+assert(!(r1 == r2));
+}
+
+  return 0;
+}
Index: test/std/experimental/memory/memory.resource.monotonic.buffer/monotonic.buffer.mem/allocate_with_initial_size.pass.cpp
===
--- /dev/null
+++ test/std/experimental/memory/memory.resource.monotonic.buffer/monotonic.buffer.mem/allocate_with_initial_size.pass.cpp
@@ -0,0 +1,53 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// REQUIRES: c++experimental
+// UNSUPPORTED: c++98, c++03
+
+// 
+
+// class monotonic_buffer_resource
+
+#include 
+#include 
+
+#include "count_new.h"
+
+void test(size_t initial_buffer_size)
+{
+globalMemCounter.reset();
+
+std::experimental::pmr::monotonic_buffer_resource mono1(
+initial_buffer_size,
+

Re: r371605 - [Diagnostics] Add -Wsizeof-array-div

2019-09-11 Thread Dávid Bolvanský via cfe-commits
Thanks,

Reproduced with -triple armv7–. Added triple to run line, hopefully it will fix 
the bots. I will check this buildbot if all ok.

rL371646

Dňa 11. 9. 2019 o 20:35 užívateľ Yvan Roux  napísal:

> Hi David,
> 
> This commit broken ARMv7 bots, logs are available here:
> 
> http://lab.llvm.org:8011/builders/clang-cmake-armv7-quick/builds/10203/steps/ninja%20check%201/logs/FAIL%3A%20Clang%3A%3Adiv-sizeof-array.cpp
> 
> Thanks,
> Yvan
> 
> 
> 
> On Wed, 11 Sep 2019 at 12:58, David Bolvansky via cfe-commits
>  wrote:
>> 
>> Author: xbolva00
>> Date: Wed Sep 11 03:59:47 2019
>> New Revision: 371605
>> 
>> URL: http://llvm.org/viewvc/llvm-project?rev=371605=rev
>> Log:
>> [Diagnostics] Add -Wsizeof-array-div
>> 
>> Summary: Clang version of https://www.viva64.com/en/examples/v706/
>> 
>> Reviewers: rsmith
>> 
>> Differential Revision: https://reviews.llvm.org/D67287
>> 
>> Added:
>>cfe/trunk/test/Sema/div-sizeof-array.cpp
>> Modified:
>>cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
>>cfe/trunk/lib/Sema/SemaExpr.cpp
>> 
>> Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
>> URL: 
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=371605=371604=371605=diff
>> ==
>> --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
>> +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Wed Sep 11 03:59:47 
>> 2019
>> @@ -3406,6 +3406,10 @@ def note_pointer_declared_here : Note<
>> def warn_division_sizeof_ptr : Warning<
>>   "'%0' will return the size of the pointer, not the array itself">,
>>   InGroup>;
>> +def warn_division_sizeof_array : Warning<
>> +  "expression does not compute the number of elements in this array; 
>> element "
>> +  "type is %0, not %1">,
>> +  InGroup>;
>> 
>> def note_function_warning_silence : Note<
>> "prefix with the address-of operator to silence this warning">;
>> 
>> Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
>> URL: 
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=371605=371604=371605=diff
>> ==
>> --- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
>> +++ cfe/trunk/lib/Sema/SemaExpr.cpp Wed Sep 11 03:59:47 2019
>> @@ -9158,17 +9158,28 @@ static void DiagnoseDivisionSizeofPointe
>>   else
>> RHSTy = RUE->getArgumentExpr()->IgnoreParens()->getType();
>> 
>> -  if (!LHSTy->isPointerType() || RHSTy->isPointerType())
>> -return;
>> -  if (LHSTy->getPointeeType().getCanonicalType().getUnqualifiedType() !=
>> -  RHSTy.getCanonicalType().getUnqualifiedType())
>> -return;
>> +  if (LHSTy->isPointerType() && !RHSTy->isPointerType()) {
>> +if (!S.Context.hasSameUnqualifiedType(LHSTy->getPointeeType(), RHSTy))
>> +  return;
>> 
>> -  S.Diag(Loc, diag::warn_division_sizeof_ptr) << LHS << 
>> LHS->getSourceRange();
>> -  if (const auto *DRE = dyn_cast(LHSArg)) {
>> -if (const ValueDecl *LHSArgDecl = DRE->getDecl())
>> -  S.Diag(LHSArgDecl->getLocation(), diag::note_pointer_declared_here)
>> -  << LHSArgDecl;
>> +S.Diag(Loc, diag::warn_division_sizeof_ptr) << LHS << 
>> LHS->getSourceRange();
>> +if (const auto *DRE = dyn_cast(LHSArg)) {
>> +  if (const ValueDecl *LHSArgDecl = DRE->getDecl())
>> +S.Diag(LHSArgDecl->getLocation(), diag::note_pointer_declared_here)
>> +<< LHSArgDecl;
>> +}
>> +  } else if (const auto *ArrayTy = S.Context.getAsArrayType(LHSTy)) {
>> +QualType ArrayElemTy = ArrayTy->getElementType();
>> +if (ArrayElemTy->isDependentType() || RHSTy->isDependentType() ||
>> +S.Context.getTypeSize(ArrayElemTy) == S.Context.getTypeSize(RHSTy))
>> +  return;
>> +S.Diag(Loc, diag::warn_division_sizeof_array)
>> +<< LHSArg->getSourceRange() << ArrayElemTy << RHSTy;
>> +if (const auto *DRE = dyn_cast(LHSArg)) {
>> +  if (const ValueDecl *LHSArgDecl = DRE->getDecl())
>> +S.Diag(LHSArgDecl->getLocation(), diag::note_array_declared_here)
>> +<< LHSArgDecl;
>> +}
>>   }
>> }
>> 
>> 
>> Added: cfe/trunk/test/Sema/div-sizeof-array.cpp
>> URL: 
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/div-sizeof-array.cpp?rev=371605=auto
>> ==
>> --- cfe/trunk/test/Sema/div-sizeof-array.cpp (added)
>> +++ cfe/trunk/test/Sema/div-sizeof-array.cpp Wed Sep 11 03:59:47 2019
>> @@ -0,0 +1,28 @@
>> +// RUN: %clang_cc1 %s -verify -Wsizeof-array-div -fsyntax-only
>> +
>> +template 
>> +int f(Ty ()[N]) {
>> +  return sizeof(Array) / sizeof(Ty); // Should not warn
>> +}
>> +
>> +typedef int int32;
>> +
>> +void test(void) {
>> +  int arr[12];// expected-note 2 {{array 'arr' declared 
>> here}}
>> +  unsigned long long arr2[4];
>> +  int *p = [0];
>> +  int a1 = sizeof(arr) / sizeof(*arr);
>> +  int a2 = sizeof arr 

r371646 - [NFC] Added triple to test file to avoid arm buildbots failures

2019-09-11 Thread David Bolvansky via cfe-commits
Author: xbolva00
Date: Wed Sep 11 11:55:56 2019
New Revision: 371646

URL: http://llvm.org/viewvc/llvm-project?rev=371646=rev
Log:
[NFC] Added triple to test file to avoid arm buildbots failures

Modified:
cfe/trunk/test/Sema/div-sizeof-array.cpp

Modified: cfe/trunk/test/Sema/div-sizeof-array.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/div-sizeof-array.cpp?rev=371646=371645=371646=diff
==
--- cfe/trunk/test/Sema/div-sizeof-array.cpp (original)
+++ cfe/trunk/test/Sema/div-sizeof-array.cpp Wed Sep 11 11:55:56 2019
@@ -1,4 +1,5 @@
-// RUN: %clang_cc1 %s -verify -Wsizeof-array-div -fsyntax-only
+// RUN: %clang_cc1 %s -verify -Wsizeof-array-div -fsyntax-only 
-triple=x86_64-linux-gnu
+// RUN: %clang_cc1 %s -verify -fsyntax-only -triple=x86_64-linux-gnu
 
 template 
 int f(Ty ()[N]) {


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


[PATCH] D67422: [analyzer] NFC: Move path diagnostic consumer implementations to libAnalysis.

2019-09-11 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

Hmm, does anybody want me to write an example tool that emits path diagnostics 
but doesn't link to `libStaticAnalyzer*`?


Repository:
  rC Clang

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

https://reviews.llvm.org/D67422



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


[PATCH] D67455: [Clang][CodeGen] support alias attribute w/ gnu_inline

2019-09-11 Thread Andrew Kelley via Phabricator via cfe-commits
andrewrk requested changes to this revision.
andrewrk added inline comments.
This revision now requires changes to proceed.



Comment at: clang/lib/AST/Decl.cpp:3352
+  assert((doesThisDeclarationHaveABody() || willHaveBody()) ||
+ hasAttr() && "Must be a function definition");
   assert(isInlined() && "Function must be inline");

It looks like the rparen is in the wrong place. I'd expect:

assert((doesThisDeclarationHaveABody() || willHaveBody() ||
 hasAttr()) && "Must be a function definition");


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67455



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


[PATCH] D52524: Add -Wpoison-system-directories warning

2019-09-11 Thread Denis Nikitin via Phabricator via cfe-commits
denik added a comment.

Ping @aaron.ballman , please verify the change.


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

https://reviews.llvm.org/D52524



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


[PATCH] D66856: [Sema] Suppress -Wformat diagnostics for bool types when printed using %hhd

2019-09-11 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D66856#1650803 , @aaron.ballman 
wrote:

> To me, actual problems at runtime belong in -Wformat and logical 
> inconsistencies that don't cause runtime problems belong in 
> -Wformat-pedantic. However, I think it's a defect that the C standard has no 
> clearly UB-free way to print a _Bool value. I will bring this up on the 
> reflectors to ask if we can clarify the standard here.


The reflector discussion is still happening and there are issues with 
ambiguities that we are pretty sure we want to correct. I've got a paper out 
that touches on some of this: 
http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2420.pdf




Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:8123
+def warn_format_bool_as_character : Warning<
+  "format specifies a character but argument has boolean value">,
+  InGroup;

How about: `using '%0' format specifier, but argument has boolean value` and 
then pass in the character specifier used?



Comment at: clang/test/Sema/format-bool.c:26
+#ifdef PEDANTIC
+  // expected-warning@-2 {{format specifies type 'short' but the argument has 
type}}
+#endif

Just an FYI (not related to your patch): it seems that at least some people 
think this should be diagnosed as something other than by `-Wformat-pedantic`. 
Their thinking is that `-Wformat-pedantic` is for things that are required to 
have a diagnostic according to the standard but are not sufficiently 
interesting to warn about by default. This particular case is not required to 
be warned on by the standard, so it's not really a "pedantic" warning. It 
sounds like there may be interest in having `-Wformat-pedantic` for that 
understanding of pedantic, and introduce something like 
`-Wformat-type-mismatch` for these other cases where there is type confusion 
but not sufficiently dangerous to warrant warning by default?



Comment at: clang/test/Sema/format-bool.c:37
+  p("%lc", b); // expected-warning {{format specifies a character but argument 
has boolean value}}
+  p("%c", 1 == 1); // expected-warning {{format specifies a character but 
argument has boolean value}}
+  p("%f", b); // expected-warning{{format specifies type 'double' but the 
argument has type}}

The diagnostic is both correct and incorrect. Maybe that's fine. However, `==` 
returns an `int` in C and `int` is reasonable to pass in to `%c`, so the 
diagnostic seems a bit strange when it claims the argument has a boolean value. 
Then again, the results really are boolean despite the type being an int.

I think I've convinced myself this is fine as-is. :-)



Comment at: clang/test/Sema/format-bool.c:43
+#ifdef __OBJC__
+  [NSString stringWithFormat: @"%c", 0]; // probably fine?
+  [NSString stringWithFormat: @"%c", NO]; // expected-warning {{format 
specifies a character but argument has boolean value}}

Seems correct to me.


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

https://reviews.llvm.org/D66856



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


[PATCH] D67455: [Clang][CodeGen] support alias attribute w/ gnu_inline

2019-09-11 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers created this revision.
nickdesaulniers added reviewers: aaron.ballman, rsmith, erichkeane.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

r369705 did not consider the addition of gnu_inline on function
declarations of alias attributed functions. This resulted in a reported
regression in the clang-9-rc4 release from the Zig developers building
glibc, which was observable as a failed assertion:

llvm-project/clang/lib/AST/Decl.cpp:3336: bool
clang::FunctionDecl::isInlineDefinitionExternallyVisible() const:
Assertion `(doesThisDeclarationHaveABody() || willHaveBody()) && "Must
be a function definition"' failed.

Alias function declarations do not have bodies, so allow us to proceed
if we have the alias function attribute but no body/definition, and add
a test case.  The emitted symbols and their linkage matches GCC for the
added test case.

Link: https://bugs.llvm.org/show_bug.cgi?id=43268


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D67455

Files:
  clang/lib/AST/Decl.cpp
  clang/test/CodeGen/alias.c


Index: clang/test/CodeGen/alias.c
===
--- clang/test/CodeGen/alias.c
+++ clang/test/CodeGen/alias.c
@@ -99,3 +99,8 @@
 // CHECKGLOBALS-NOT: @test11_foo = dso_local
 void test11(void) {}
 static void test11_foo(void) __attribute__((alias("test11")));
+
+// Test that gnu_inline+alias work.
+// CHECKGLOBALS: @test12_alias = alias void (), void ()* @test12
+void test12(void) {}
+inline void test12_alias(void) __attribute__((gnu_inline, alias("test12")));
Index: clang/lib/AST/Decl.cpp
===
--- clang/lib/AST/Decl.cpp
+++ clang/lib/AST/Decl.cpp
@@ -3348,8 +3348,8 @@
 /// an externally visible symbol, but "extern inline" will not create an
 /// externally visible symbol.
 bool FunctionDecl::isInlineDefinitionExternallyVisible() const {
-  assert((doesThisDeclarationHaveABody() || willHaveBody()) &&
- "Must be a function definition");
+  assert((doesThisDeclarationHaveABody() || willHaveBody()) ||
+ hasAttr() && "Must be a function definition");
   assert(isInlined() && "Function must be inline");
   ASTContext  = getASTContext();
 


Index: clang/test/CodeGen/alias.c
===
--- clang/test/CodeGen/alias.c
+++ clang/test/CodeGen/alias.c
@@ -99,3 +99,8 @@
 // CHECKGLOBALS-NOT: @test11_foo = dso_local
 void test11(void) {}
 static void test11_foo(void) __attribute__((alias("test11")));
+
+// Test that gnu_inline+alias work.
+// CHECKGLOBALS: @test12_alias = alias void (), void ()* @test12
+void test12(void) {}
+inline void test12_alias(void) __attribute__((gnu_inline, alias("test12")));
Index: clang/lib/AST/Decl.cpp
===
--- clang/lib/AST/Decl.cpp
+++ clang/lib/AST/Decl.cpp
@@ -3348,8 +3348,8 @@
 /// an externally visible symbol, but "extern inline" will not create an
 /// externally visible symbol.
 bool FunctionDecl::isInlineDefinitionExternallyVisible() const {
-  assert((doesThisDeclarationHaveABody() || willHaveBody()) &&
- "Must be a function definition");
+  assert((doesThisDeclarationHaveABody() || willHaveBody()) ||
+ hasAttr() && "Must be a function definition");
   assert(isInlined() && "Function must be inline");
   ASTContext  = getASTContext();
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D65130: [clang][OpenMP] Add clang-offload-wrapper tool

2019-09-11 Thread Sergey Dmitriev via Phabricator via cfe-commits
sdmitriev updated this revision to Diff 219750.
sdmitriev added a comment.

Rebase


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

https://reviews.llvm.org/D65130

Files:
  clang/test/Driver/clang-offload-wrapper.c
  clang/tools/CMakeLists.txt
  clang/tools/clang-offload-wrapper/CMakeLists.txt
  clang/tools/clang-offload-wrapper/ClangOffloadWrapper.cpp

Index: clang/tools/clang-offload-wrapper/ClangOffloadWrapper.cpp
===
--- /dev/null
+++ clang/tools/clang-offload-wrapper/ClangOffloadWrapper.cpp
@@ -0,0 +1,360 @@
+//===-- clang-offload-wrapper/ClangOffloadWrapper.cpp ---*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+///
+/// \file
+/// Implementation of the offload wrapper tool. It takes offload target binaries
+/// as input and creates wrapper bitcode from them which registers given
+/// binaries in offload runtime.
+///
+//===--===//
+
+#include "clang/Basic/Version.h"
+#include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/Triple.h"
+#include "llvm/Bitcode/BitcodeWriter.h"
+#include "llvm/IR/Constants.h"
+#include "llvm/IR/GlobalVariable.h"
+#include "llvm/IR/IRBuilder.h"
+#include "llvm/IR/LLVMContext.h"
+#include "llvm/IR/Module.h"
+#include "llvm/Support/CommandLine.h"
+#include "llvm/Support/Errc.h"
+#include "llvm/Support/Error.h"
+#include "llvm/Support/ErrorOr.h"
+#include "llvm/Support/MemoryBuffer.h"
+#include "llvm/Support/Signals.h"
+#include "llvm/Support/ToolOutputFile.h"
+#include "llvm/Support/WithColor.h"
+#include "llvm/Support/raw_ostream.h"
+#include "llvm/Transforms/Utils/ModuleUtils.h"
+#include 
+#include 
+
+using namespace llvm;
+
+static cl::opt Help("h", cl::desc("Alias for -help"), cl::Hidden);
+
+// Mark all our options with this category, everything else (except for -version
+// and -help) will be hidden.
+static cl::OptionCategory
+ClangOffloadWrapperCategory("clang-offload-wrapper options");
+
+static cl::opt Output("o", cl::Required,
+   cl::desc("Output filename"),
+   cl::value_desc("filename"),
+   cl::cat(ClangOffloadWrapperCategory));
+
+static cl::list Inputs(cl::Positional, cl::OneOrMore,
+cl::desc(""),
+cl::cat(ClangOffloadWrapperCategory));
+
+static cl::opt Target("target", cl::Required,
+   cl::desc("Target triple"),
+   cl::value_desc("triple"),
+   cl::cat(ClangOffloadWrapperCategory));
+
+namespace {
+
+class BinaryWrapper {
+  LLVMContext C;
+  Module M;
+
+  StructType *EntryTy = nullptr;
+  StructType *ImageTy = nullptr;
+  StructType *DescTy = nullptr;
+
+private:
+  IntegerType *getSizeTTy() {
+switch (M.getDataLayout().getPointerTypeSize(Type::getInt8PtrTy(C))) {
+case 4u:
+  return Type::getInt32Ty(C);
+case 8u:
+  return Type::getInt64Ty(C);
+}
+llvm_unreachable("unsupported pointer type size");
+  }
+
+  // struct __tgt_offload_entry {
+  //   void *addr;
+  //   char *name;
+  //   size_t size;
+  //   int32_t flags;
+  //   int32_t reserved;
+  // };
+  StructType *getEntryTy() {
+if (!EntryTy)
+  EntryTy = StructType::create("__tgt_offload_entry", Type::getInt8PtrTy(C),
+   Type::getInt8PtrTy(C), getSizeTTy(),
+   Type::getInt32Ty(C), Type::getInt32Ty(C));
+return EntryTy;
+  }
+
+  PointerType *getEntryPtrTy() { return PointerType::getUnqual(getEntryTy()); }
+
+  // struct __tgt_device_image {
+  //   void *ImageStart;
+  //   void *ImageEnd;
+  //   __tgt_offload_entry *EntriesBegin;
+  //   __tgt_offload_entry *EntriesEnd;
+  // };
+  StructType *getDeviceImageTy() {
+if (!ImageTy)
+  ImageTy = StructType::create("__tgt_device_image", Type::getInt8PtrTy(C),
+   Type::getInt8PtrTy(C), getEntryPtrTy(),
+   getEntryPtrTy());
+return ImageTy;
+  }
+
+  PointerType *getDeviceImagePtrTy() {
+return PointerType::getUnqual(getDeviceImageTy());
+  }
+
+  // struct __tgt_bin_desc {
+  //   int32_t NumDeviceImages;
+  //   __tgt_device_image *DeviceImages;
+  //   __tgt_offload_entry *HostEntriesBegin;
+  //   __tgt_offload_entry *HostEntriesEnd;
+  // };
+  StructType *getBinDescTy() {
+if (!DescTy)
+  DescTy = StructType::create("__tgt_bin_desc", Type::getInt32Ty(C),
+  getDeviceImagePtrTy(), getEntryPtrTy(),
+  

[PATCH] D67454: Start porting ivfsoverlay tests to Windows

2019-09-11 Thread Reid Kleckner via Phabricator via cfe-commits
rnk created this revision.
rnk added a reviewer: amccarth.
Herald added a subscriber: arphaman.
Herald added a project: clang.

Part of PR43272, the changes are:

1. Use @ as the sed pattern delimiter instead of : so that the drive

letter in lit substitutions isn't an issue.

2. Use the %/t and %/S substitutions to get paths with forward slashes

to work around string quoting issues in the yaml file.

3. Replace REQUIRES:shell with XFAIL:windows. These tests should pass on

Windows, but do not for reasons that are not yet understood. We would
like to know if they pass unexpectedly.

I was able to remove the XFAILs from two tests, since they already pass
with my sed fix:

  clang/test/VFS/module_missing_vfs.m
  clang/test/VFS/test_nonmodular.c


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D67454

Files:
  clang/test/Index/index-module-with-vfs.m
  clang/test/Modules/crash-vfs-ivfsoverlay.m
  clang/test/Modules/double-quotes.m
  clang/test/Modules/framework-public-includes-private.m
  clang/test/VFS/external-names.c
  clang/test/VFS/framework-import.m
  clang/test/VFS/implicit-include.c
  clang/test/VFS/include-mixed-real-and-virtual.c
  clang/test/VFS/include-real-from-virtual.c
  clang/test/VFS/include-virtual-from-real.c
  clang/test/VFS/include.c
  clang/test/VFS/incomplete-umbrella.m
  clang/test/VFS/module-import.m
  clang/test/VFS/module_missing_vfs.m
  clang/test/VFS/real-path-found-first.m
  clang/test/VFS/relative-path.c
  clang/test/VFS/subframework-symlink.m
  clang/test/VFS/test_nonmodular.c
  clang/test/VFS/umbrella-framework-import-skipnonexist.m
  clang/test/VFS/vfsroot-include.c
  clang/test/VFS/vfsroot-module.m
  clang/test/VFS/vfsroot-with-overlay.c

Index: clang/test/VFS/vfsroot-with-overlay.c
===
--- clang/test/VFS/vfsroot-with-overlay.c
+++ clang/test/VFS/vfsroot-with-overlay.c
@@ -1,8 +1,10 @@
-// REQUIRES: shell
+// FIXME: PR43272
+// XFAIL: windows
+
 // RUN: rm -rf %t
 // RUN: mkdir -p %t
-// RUN: sed -e "s:TEST_DIR:%S:g" -e "s:OUT_DIR:%t:g" %S/Inputs/vfsroot.yaml > %t.yaml
-// RUN: sed -e "s:INPUT_DIR:/indirect-vfs-root-files:g" -e "s:OUT_DIR:/overlay-dir:g" %S/Inputs/vfsoverlay.yaml > %t/vfsoverlay.yaml
+// RUN: sed -e "s@TEST_DIR@%/S@g" -e "s@OUT_DIR@%/t@g" %S/Inputs/vfsroot.yaml > %t.yaml
+// RUN: sed -e "s@INPUT_DIR@/indirect-vfs-root-files@g" -e "s@OUT_DIR@/overlay-dir@g" %S/Inputs/vfsoverlay.yaml > %t/vfsoverlay.yaml
 // RUN: %clang_cc1 -Werror -ivfsoverlay %t.yaml -ivfsoverlay /direct-vfs-root-files/vfsoverlay.yaml -I /overlay-dir -fsyntax-only /tests/vfsroot-with-overlay.c
 
 #include "not_real.h"
Index: clang/test/VFS/vfsroot-module.m
===
--- clang/test/VFS/vfsroot-module.m
+++ clang/test/VFS/vfsroot-module.m
@@ -1,7 +1,9 @@
-// REQUIRES: shell
+// FIXME: PR43272
+// XFAIL: windows
+
 // RUN: rm -rf %t
 // RUN: mkdir -p %t
-// RUN: sed -e "s:TEST_DIR:%S:g" -e "s:OUT_DIR:%t:g" %S/Inputs/vfsroot.yaml > %t.yaml
+// RUN: sed -e "s@TEST_DIR@%/S@g" -e "s@OUT_DIR@%/t@g" %S/Inputs/vfsroot.yaml > %t.yaml
 // RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fdisable-module-hash -fmodules-cache-path=%t/cache -ivfsoverlay %t.yaml -F %S/Inputs -fsyntax-only /tests/vfsroot-module.m
 
 // Test that a file missing from the VFS root is not found, even if it is
Index: clang/test/VFS/vfsroot-include.c
===
--- clang/test/VFS/vfsroot-include.c
+++ clang/test/VFS/vfsroot-include.c
@@ -1,7 +1,9 @@
-// REQUIRES: shell
+// FIXME: PR43272
+// XFAIL: windows
+
 // RUN: rm -rf %t
 // RUN: mkdir -p %t
-// RUN: sed -e "s:TEST_DIR:%S:g" -e "s:OUT_DIR:%t:g" %S/Inputs/vfsroot.yaml > %t.yaml
+// RUN: sed -e "s@TEST_DIR@%/S@g" -e "s@OUT_DIR@%/t@g" %S/Inputs/vfsroot.yaml > %t.yaml
 // RUN: not %clang_cc1 -Werror -ivfsoverlay %t.yaml -I %S/Inputs -I /direct-vfs-root-files -fsyntax-only /tests/vfsroot-include.c 2>&1 | FileCheck %s
 // The line above tests that the compiler input file is looked up through VFS.
 
Index: clang/test/VFS/umbrella-framework-import-skipnonexist.m
===
--- clang/test/VFS/umbrella-framework-import-skipnonexist.m
+++ clang/test/VFS/umbrella-framework-import-skipnonexist.m
@@ -1,13 +1,13 @@
-// REQUIRES: crash-recovery, shell
+// REQUIRES: crash-recovery
 
-// FIXME: This XFAIL is cargo-culted from crash-report.c. Do we need it?
-// XFAIL: windows-gnu
+// FIXME: PR43272
+// XFAIL: windows
 
 // RUN: rm -rf %t
 // RUN: mkdir -p %t/vdir %t/outdir %t/cache
 // RUN: cp -R %S/Inputs/Bar.framework %t/outdir/
 //
-// RUN: sed -e "s:VDIR:%t/vdir:g" -e "s:OUT_DIR:%t/outdir:g" %S/Inputs/bar-headers.yaml > %t/vdir/bar-headers.yaml
+// RUN: sed -e "s@VDIR@%/t/vdir@g" -e "s@OUT_DIR@%/t/outdir@g" %S/Inputs/bar-headers.yaml > %t/vdir/bar-headers.yaml
 // RUN: rm -f %t/outdir/Bar.framework/Headers/B.h
 // RUN: %clang_cc1 -fmodules 

[PATCH] D67420: [analyzer] NFC: Separate PathDiagnosticConsumer options from AnalyzerOptions.

2019-09-11 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

In D67420#1666050 , @gribozavr wrote:

> Are you planning to move users of these options -- like `PlistDiagnostics` -- 
> to libAnalysis?


Yup, i was supposed to do that in D67422  :)


Repository:
  rC Clang

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

https://reviews.llvm.org/D67420



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


[PATCH] D67420: [analyzer] NFC: Separate PathDiagnosticConsumer options from AnalyzerOptions.

2019-09-11 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

In D67420#1666141 , @Szelethus wrote:

> - For these select 4 options that suffer compatibility issues, manually check 
> `AnalyzerOptions::ConfigTable`.


*3 options. `ToolInvocation` is not really an option that you're ever supposed 
to adjust manually. Which is one more reason for me to think of this structure 
as of an implementation detail - an interface through which diagnostic 
consumers' behavior can be tweaked, regardless of why the tool wants it to be 
tweaked (because the human told it to or because the tool itself knows better).


Repository:
  rC Clang

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

https://reviews.llvm.org/D67420



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


Re: r371605 - [Diagnostics] Add -Wsizeof-array-div

2019-09-11 Thread Yvan Roux via cfe-commits
Hi David,

This commit broken ARMv7 bots, logs are available here:

http://lab.llvm.org:8011/builders/clang-cmake-armv7-quick/builds/10203/steps/ninja%20check%201/logs/FAIL%3A%20Clang%3A%3Adiv-sizeof-array.cpp

Thanks,
Yvan



On Wed, 11 Sep 2019 at 12:58, David Bolvansky via cfe-commits
 wrote:
>
> Author: xbolva00
> Date: Wed Sep 11 03:59:47 2019
> New Revision: 371605
>
> URL: http://llvm.org/viewvc/llvm-project?rev=371605=rev
> Log:
> [Diagnostics] Add -Wsizeof-array-div
>
> Summary: Clang version of https://www.viva64.com/en/examples/v706/
>
> Reviewers: rsmith
>
> Differential Revision: https://reviews.llvm.org/D67287
>
> Added:
> cfe/trunk/test/Sema/div-sizeof-array.cpp
> Modified:
> cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
> cfe/trunk/lib/Sema/SemaExpr.cpp
>
> Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=371605=371604=371605=diff
> ==
> --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
> +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Wed Sep 11 03:59:47 
> 2019
> @@ -3406,6 +3406,10 @@ def note_pointer_declared_here : Note<
>  def warn_division_sizeof_ptr : Warning<
>"'%0' will return the size of the pointer, not the array itself">,
>InGroup>;
> +def warn_division_sizeof_array : Warning<
> +  "expression does not compute the number of elements in this array; element 
> "
> +  "type is %0, not %1">,
> +  InGroup>;
>
>  def note_function_warning_silence : Note<
>  "prefix with the address-of operator to silence this warning">;
>
> Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=371605=371604=371605=diff
> ==
> --- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaExpr.cpp Wed Sep 11 03:59:47 2019
> @@ -9158,17 +9158,28 @@ static void DiagnoseDivisionSizeofPointe
>else
>  RHSTy = RUE->getArgumentExpr()->IgnoreParens()->getType();
>
> -  if (!LHSTy->isPointerType() || RHSTy->isPointerType())
> -return;
> -  if (LHSTy->getPointeeType().getCanonicalType().getUnqualifiedType() !=
> -  RHSTy.getCanonicalType().getUnqualifiedType())
> -return;
> +  if (LHSTy->isPointerType() && !RHSTy->isPointerType()) {
> +if (!S.Context.hasSameUnqualifiedType(LHSTy->getPointeeType(), RHSTy))
> +  return;
>
> -  S.Diag(Loc, diag::warn_division_sizeof_ptr) << LHS << 
> LHS->getSourceRange();
> -  if (const auto *DRE = dyn_cast(LHSArg)) {
> -if (const ValueDecl *LHSArgDecl = DRE->getDecl())
> -  S.Diag(LHSArgDecl->getLocation(), diag::note_pointer_declared_here)
> -  << LHSArgDecl;
> +S.Diag(Loc, diag::warn_division_sizeof_ptr) << LHS << 
> LHS->getSourceRange();
> +if (const auto *DRE = dyn_cast(LHSArg)) {
> +  if (const ValueDecl *LHSArgDecl = DRE->getDecl())
> +S.Diag(LHSArgDecl->getLocation(), diag::note_pointer_declared_here)
> +<< LHSArgDecl;
> +}
> +  } else if (const auto *ArrayTy = S.Context.getAsArrayType(LHSTy)) {
> +QualType ArrayElemTy = ArrayTy->getElementType();
> +if (ArrayElemTy->isDependentType() || RHSTy->isDependentType() ||
> +S.Context.getTypeSize(ArrayElemTy) == S.Context.getTypeSize(RHSTy))
> +  return;
> +S.Diag(Loc, diag::warn_division_sizeof_array)
> +<< LHSArg->getSourceRange() << ArrayElemTy << RHSTy;
> +if (const auto *DRE = dyn_cast(LHSArg)) {
> +  if (const ValueDecl *LHSArgDecl = DRE->getDecl())
> +S.Diag(LHSArgDecl->getLocation(), diag::note_array_declared_here)
> +<< LHSArgDecl;
> +}
>}
>  }
>
>
> Added: cfe/trunk/test/Sema/div-sizeof-array.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/div-sizeof-array.cpp?rev=371605=auto
> ==
> --- cfe/trunk/test/Sema/div-sizeof-array.cpp (added)
> +++ cfe/trunk/test/Sema/div-sizeof-array.cpp Wed Sep 11 03:59:47 2019
> @@ -0,0 +1,28 @@
> +// RUN: %clang_cc1 %s -verify -Wsizeof-array-div -fsyntax-only
> +
> +template 
> +int f(Ty ()[N]) {
> +  return sizeof(Array) / sizeof(Ty); // Should not warn
> +}
> +
> +typedef int int32;
> +
> +void test(void) {
> +  int arr[12];// expected-note 2 {{array 'arr' declared 
> here}}
> +  unsigned long long arr2[4];
> +  int *p = [0];
> +  int a1 = sizeof(arr) / sizeof(*arr);
> +  int a2 = sizeof arr / sizeof p; // expected-warning {{expression does not 
> compute the number of elements in this array; element type is 'int', not 'int 
> *'}}
> +  int a4 = sizeof arr2 / sizeof p;
> +  int a5 = sizeof(arr) / sizeof(short); // expected-warning {{expression 
> does not compute the number of elements in this array; element type is 'int', 
> 

[PATCH] D67420: [analyzer] NFC: Separate PathDiagnosticConsumer options from AnalyzerOptions.

2019-09-11 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

In D67420#1666141 , @Szelethus wrote:

> I do!


Hmm, it sounds like you want to force both Clang frontend and Clang-Tidy to use 
the same set of flags to control these options (?) Much like 
`-analyzer-config`, these flags will have different "style" compared to other 
flags in the tool. Which is probably not too bad for hidden frontend flags that 
control the Analyzer because they're anyway set by a separate GUI checkbox, but 
the inconsistency with other flags would be super glaring in case of Clang-Tidy 
CLI. Do we really want to go in that direction? I'll be much more comfortable 
with letting each tool deal with its flags the way it prefers - this doesn't 
look like a good place for code reuse to me.


Repository:
  rC Clang

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

https://reviews.llvm.org/D67420



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


[PATCH] D67422: [analyzer] NFC: Move path diagnostic consumer implementations to libAnalysis.

2019-09-11 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ marked an inline comment as done.
NoQ added inline comments.



Comment at: clang/include/clang/Analysis/PathDiagnosticConsumers.h:37
 const cross_tu::CrossTranslationUnitContext );
-#include "clang/StaticAnalyzer/Core/Analyses.def"
+#include "clang/Analysis/PathDiagnosticConsumers.def"
 

gribozavr wrote:
> Does this code declare e.g., createPlistDiagnosticConsumer? That function is 
> defined in libStaticAnalyzer. Declaring it libAnalysis is not appropriate, 
> and effectively introduces a layering violation. Users who link against 
> libAnalysis will get link errors if they don't link against libStaticAnalyzer.
> 
Oh crap, i forgot to move them.


Repository:
  rC Clang

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

https://reviews.llvm.org/D67422



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


[PATCH] D67421: [analyzer] NFC: Move IssueHash to libAnalysis.

2019-09-11 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

In D67421#1666058 , @gribozavr wrote:

> The "bugtype" in IssueHash is specific to Static Analyzer (or at least not 
> documented sufficiently abstractly).


Yeah, i'll need to document this.

That's basically the warning message; it doesn't have to have anything to do 
with the Analyzer's `BugType` structure. But if the warning message contains 
fragile stuff (eg., mentions a name of a variable or (why??) a line number), 
the user may want to wipe it out of the hash, and in this case Analyzer 
`BugType`s turn out to be fairly handy.


Repository:
  rC Clang

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

https://reviews.llvm.org/D67421



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


[PATCH] D67368: [NFCI]Create CommonAttributeInfo Type as base type of *Attr and ParsedAttr.

2019-09-11 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

Thank you for doing all this work -- in general, this is looking great and 
really cleans things up!




Comment at: clang/include/clang/Basic/Attr.td:2266
   let Spellings = [CXX11<"", "maybe_unused", 201603>, GCC<"unused">,
-   C2x<"", "maybe_unused">];
+   C2x<"", "maybe_unused">, Pragma<"", "unused">];
   let Subjects = SubjectList<[Var, ObjCIvar, Type, Enum, EnumConstant, Label,

I'm surprised to see this as part of an NFC refactoring. Hopefully it will 
become more obvious later. :-D



Comment at: clang/include/clang/Basic/AttributeCommonInfo.h:66-69
+  unsigned AttrKind : 16;
+  /// Corresponds to the Syntax enum.
+  unsigned SyntaxUsed : 3;
+  unsigned SpellingIndex : 4;

Do you want to do `= 0` here to give them in-class initializers? (well, 
`SpellingIndex` should probably be `SpellingNotCalculated`).



Comment at: clang/include/clang/Lex/Preprocessor.h:373
 
-  /// The source location of the currently-active
+  /// The source location and identifier of the currently-active
   /// \#pragma clang arc_cf_code_audited begin.

Can you correct the order in the comment to be the same as the order in the 
pair?



Comment at: clang/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp:298-300
+  AttributeCommonInfo({}, AttributeCommonInfo::AT_Aligned,
+  AttributeCommonInfo::AS_GNU,
+  AlignedAttr::GNU_aligned)));

I'm surprised we'd give a parse syntax to an implicit attribute. Wouldn't we 
rather note that these have no associated syntax or spelling?



Comment at: clang/lib/Sema/SemaAttr.cpp:892
 = (VisibilityAttr::VisibilityType) rawType;
+
   SourceLocation loc = Stack->back().second;

Spurious change?



Comment at: clang/lib/Sema/SemaDecl.cpp:8962-8965
+SourceLocation Loc = D.getDeclSpec().getNoreturnSpecLoc();
+AttributeCommonInfo Info(SourceRange{Loc}, 
AttributeCommonInfo::AT_NoReturn,
+ AttributeCommonInfo::AS_Keyword);
+NewFD->addAttr(::new (Context) C11NoReturnAttr(Context, Info));

It would be nice if we didn't have to repeat information, if possible. The 
previous version of this didn't need to specify `AT_NoReturn` because the 
`C11NoReturnAttr` was sufficient to glean that information. It would be awesome 
if we could find a way to make this more succinct. Perhaps 
`ConcreteAttr::Create(Context, Range, Syntax, Spelling = DefaultValue)` or 
something along those lines?



Comment at: clang/lib/Sema/SemaDecl.cpp:13880
   fmt = "NSString";
-FD->addAttr(FormatAttr::CreateImplicit(Context,
-   (fmt),
-   FormatIdx+1,
-   HasVAListArg ? 0 : FormatIdx+2,
-   FD->getLocation()));
+FD->addAttr(FormatAttr::CreateImplicit(
+Context, (fmt), FormatIdx + 1,

Spurious formatting change? Same for the next three changes.



Comment at: clang/lib/Sema/SemaDeclCXX.cpp:3349
+AttributeCommonInfo Info{SourceRange(VS.getOverrideLoc()),
+ AttributeCommonInfo::UnknownAttribute,
+ AttributeCommonInfo::AS_Keyword, 0};

Can we use something other than `UnknownAttribute` here? That implies we don't 
know the spelling of the attribute name, which seems wrong.



Comment at: clang/lib/Sema/SemaDeclObjC.cpp:4464-4465
 // merge the attribute into implementation.
-method->addAttr(
-  ObjCRequiresSuperAttr::CreateImplicit(S.Context,
-method->getLocation()));
+method->addAttr(ObjCRequiresSuperAttr::CreateImplicit(
+S.Context, method->getLocation()));
   }

Spurious formatting change.



Comment at: clang/lib/Sema/SemaObjCProperty.cpp:2414-2415
 if (property->hasAttr())
-  GetterMethod->addAttr(NSReturnsNotRetainedAttr::CreateImplicit(Context,
- Loc));
+  GetterMethod->addAttr(
+  NSReturnsNotRetainedAttr::CreateImplicit(Context, Loc));
 

I'll stop pointing out the formatting changes, but you should probably drop 
these from the patch.



Comment at: clang/lib/Sema/SemaStmtAttr.cpp:50
   FnScope->setHasFallthroughStmt();
-  return ::new (S.Context) auto(Attr);
+  return ::new (S.Context) FallThroughAttr(S.Context, A);
 }

Thank you for this change. I have no idea how the original code made it through 
a code review.



Comment at: clang/lib/Sema/SemaType.cpp:3942
   

[PATCH] D67382: [analyzer] NFC: Move getStmt() and createEndOfPath() out of PathDiagnostic.

2019-09-11 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ marked an inline comment as done.
NoQ added inline comments.



Comment at: clang/lib/StaticAnalyzer/Core/BugReporter.cpp:2185
   } else {
-assert(ErrorNode);
-hash.AddPointer(GetCurrentOrPreviousStmt(ErrorNode));

NoQ wrote:
> Szelethus wrote:
> > Why delete the assert?
> Because it's enforced by the type system these days. This is a method on 
> `PathSensitiveBugReport` that always has an error node, as asserted in its 
> constructor. I should have removed this assert in D66572.
Previously this assert was on the generic `BugReport::Profile` and it was there 
to state that "either a report has an error node, or a manually set location". 
Now have a clear separation between path-sensitive and path-insensitive reports 
in our type system, so it doesn't make sense to enforce this alternative 
manually.

Also, no, it wasn't failing :)


Repository:
  rC Clang

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

https://reviews.llvm.org/D67382



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


[PATCH] D47956: [MS] Consder constexpr globals to be inline, as in C++17

2019-09-11 Thread Reid Kleckner via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL371642: [MS] Consder constexpr globals to be inline, as in 
C++17 (authored by rnk, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D47956?vs=219638=219746#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D47956

Files:
  cfe/trunk/lib/Sema/SemaDecl.cpp
  cfe/trunk/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p1.cpp
  cfe/trunk/test/CXX/drs/dr7xx.cpp
  cfe/trunk/test/CodeGenCXX/ms-constexpr-static-data-member.cpp
  cfe/trunk/test/CodeGenCXX/ms-integer-static-data-members-exported.cpp
  cfe/trunk/test/CodeGenCXX/ms-integer-static-data-members.cpp
  cfe/trunk/test/SemaCXX/cxx1y-variable-templates_in_class.cpp
  cfe/trunk/test/SemaCXX/dllexport.cpp
  cfe/trunk/test/SemaCXX/dllimport.cpp

Index: cfe/trunk/test/SemaCXX/dllimport.cpp
===
--- cfe/trunk/test/SemaCXX/dllimport.cpp
+++ cfe/trunk/test/SemaCXX/dllimport.cpp
@@ -2,6 +2,7 @@
 // RUN: %clang_cc1 -triple x86_64-win32   -fsyntax-only -fms-extensions -verify -std=c++1y -Wunsupported-dll-base-class-template -DMS %s
 // RUN: %clang_cc1 -triple i686-mingw32   -fsyntax-only -fms-extensions -verify -std=c++1y -Wunsupported-dll-base-class-template -DGNU %s
 // RUN: %clang_cc1 -triple x86_64-mingw32 -fsyntax-only -fms-extensions -verify -std=c++11 -Wunsupported-dll-base-class-template -DGNU %s
+// RUN: %clang_cc1 -triple x86_64-mingw32 -fsyntax-only -fms-extensions -verify -std=c++17 -Wunsupported-dll-base-class-template -DGNU %s
 
 // Helper structs to make templates more expressive.
 struct ImplicitInst_Imported {};
@@ -586,7 +587,10 @@
   __declspec(dllimport) static  const  int  StaticConstFieldEqualInit = 1;
   __declspec(dllimport) static  const  int  StaticConstFieldBraceInit{1};
   __declspec(dllimport) constexpr static int ConstexprField = 1;
-  __declspec(dllimport) constexpr static int ConstexprFieldDef = 1; // expected-note{{attribute is here}}
+#if __cplusplus < 201703L && !defined(MS)
+  // expected-note@+2{{attribute is here}}
+#endif
+  __declspec(dllimport) constexpr static int ConstexprFieldDef = 1;
 };
 
 #ifdef MS
@@ -631,7 +635,10 @@
 
int  ImportMembers::StaticFieldDef; // expected-error{{definition of dllimport static field not allowed}}
 const  int  ImportMembers::StaticConstFieldDef = 1; // expected-error{{definition of dllimport static field not allowed}}
-constexpr int ImportMembers::ConstexprFieldDef; // expected-error{{definition of dllimport static field not allowed}}
+#if __cplusplus < 201703L && !defined(MS)
+// expected-error@+2{{definition of dllimport static field not allowed}}
+#endif
+constexpr int ImportMembers::ConstexprFieldDef;
 
 
 // Import on member definitions.
@@ -667,7 +674,11 @@
 
 __declspec(dllimport)int  ImportMemberDefs::StaticField; // expected-error{{definition of dllimport static field not allowed}} expected-note{{attribute is here}}
 __declspec(dllimport) const  int  ImportMemberDefs::StaticConstField = 1; // expected-error{{definition of dllimport static field not allowed}} expected-note{{attribute is here}}
-__declspec(dllimport) constexpr int ImportMemberDefs::ConstexprField; // expected-error{{definition of dllimport static field not allowed}} expected-note{{attribute is here}}
+#if __cplusplus < 201703L && !defined(MS)
+// expected-error@+3{{definition of dllimport static field not allowed}}
+// expected-note@+2{{attribute is here}}
+#endif
+__declspec(dllimport) constexpr int ImportMemberDefs::ConstexprField;
 
 
 // Import special member functions.
@@ -800,7 +811,7 @@
 
   static int  StaticField; // expected-note{{previous declaration is here}}
   static  const  int  StaticConstField;// expected-note{{previous declaration is here}}
-  constexpr static int ConstexprField = 1; // expected-note{{previous declaration is here}}
+  constexpr static int ConstexprField = 1; // expected-note-re{{previous {{(declaration|definition)}} is here}}
 };
 
 __declspec(dllimport)void MemberRedecl::normalDef() {} // expected-error{{redeclaration of 'MemberRedecl::normalDef' cannot add 'dllimport' attribute}}
@@ -831,9 +842,15 @@
 __declspec(dllimport) const  int  MemberRedecl::StaticConstField = 1;  // expected-error{{redeclaration of 'MemberRedecl::StaticConstField' cannot add 'dllimport' attribute}}
// expected-error@-1{{definition of dllimport static field not allowed}}
// expected-note@-2{{attribute is here}}
-__declspec(dllimport) constexpr int MemberRedecl::ConstexprField;  // expected-error{{redeclaration of 'MemberRedecl::ConstexprField' cannot add 'dllimport' attribute}}
-   

r371642 - [MS] Consder constexpr globals to be inline, as in C++17

2019-09-11 Thread Reid Kleckner via cfe-commits
Author: rnk
Date: Wed Sep 11 11:09:10 2019
New Revision: 371642

URL: http://llvm.org/viewvc/llvm-project?rev=371642=rev
Log:
[MS] Consder constexpr globals to be inline, as in C++17

Summary:
Microsoft seems to do this regardless of the language mode, so we must
also do it in order to be ABI compatible.

Fixes PR36125

Reviewers: thakis

Subscribers: cfe-commits

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

Added:
cfe/trunk/test/CodeGenCXX/ms-constexpr-static-data-member.cpp
Modified:
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p1.cpp
cfe/trunk/test/CXX/drs/dr7xx.cpp
cfe/trunk/test/CodeGenCXX/ms-integer-static-data-members-exported.cpp
cfe/trunk/test/CodeGenCXX/ms-integer-static-data-members.cpp
cfe/trunk/test/SemaCXX/cxx1y-variable-templates_in_class.cpp
cfe/trunk/test/SemaCXX/dllexport.cpp
cfe/trunk/test/SemaCXX/dllimport.cpp

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=371642=371641=371642=diff
==
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Wed Sep 11 11:09:10 2019
@@ -6846,7 +6846,9 @@ NamedDecl *Sema::ActOnVariableDeclarator
 // C++1z [dcl.spec.constexpr]p1:
 //   A static data member declared with the constexpr specifier is
 //   implicitly an inline variable.
-if (NewVD->isStaticDataMember() && getLangOpts().CPlusPlus17)
+if (NewVD->isStaticDataMember() &&
+(getLangOpts().CPlusPlus17 ||
+ Context.getTargetInfo().getCXXABI().isMicrosoft()))
   NewVD->setImplicitlyInline();
 break;
 
@@ -12003,7 +12005,8 @@ void Sema::ActOnUninitializedDecl(Decl *
   if (Var->isStaticDataMember()) {
 // C++1z removes the relevant rule; the in-class declaration is always
 // a definition there.
-if (!getLangOpts().CPlusPlus17) {
+if (!getLangOpts().CPlusPlus17 &&
+!Context.getTargetInfo().getCXXABI().isMicrosoft()) {
   Diag(Var->getLocation(),
diag::err_constexpr_static_mem_var_requires_init)
 << Var->getDeclName();

Modified: cfe/trunk/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p1.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p1.cpp?rev=371642=371641=371642=diff
==
--- cfe/trunk/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p1.cpp (original)
+++ cfe/trunk/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p1.cpp Wed Sep 11 
11:09:10 2019
@@ -1,6 +1,10 @@
-// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
-// RUN: %clang_cc1 -fsyntax-only -verify -std=c++14 %s
-// RUN: %clang_cc1 -fsyntax-only -verify -std=c++1z %s
+// RUN: %clang_cc1 -triple %itanium_abi_triple -fsyntax-only -verify 
-std=c++11 %s
+// RUN: %clang_cc1 -triple %itanium_abi_triple -fsyntax-only -verify 
-std=c++14 %s
+// RUN: %clang_cc1 -triple %itanium_abi_triple -fsyntax-only -verify 
-std=c++1z %s
+
+// MSVC always adopted the C++17 rule that implies that constexpr variables are
+// implicitly inline, so do the test again.
+// RUN: %clang_cc1 -triple x86_64-windows-msvc -DMS_ABI -fsyntax-only -verify 
-std=c++11 %s
 
 struct notlit { // expected-note {{not literal because}}
   notlit() {}
@@ -29,7 +33,7 @@ void f2(constexpr int i) {} // expected-
 struct s2 {
   constexpr int mi1; // expected-error {{non-static data member cannot be 
constexpr; did you intend to make it const?}}
   static constexpr int mi2;
-#if __cplusplus <= 201402L
+#if __cplusplus <= 201402L && !defined(MS_ABI)
   // expected-error@-2 {{requires an initializer}}
 #else
   // expected-error@-4 {{default initialization of an object of const}}

Modified: cfe/trunk/test/CXX/drs/dr7xx.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/drs/dr7xx.cpp?rev=371642=371641=371642=diff
==
--- cfe/trunk/test/CXX/drs/dr7xx.cpp (original)
+++ cfe/trunk/test/CXX/drs/dr7xx.cpp Wed Sep 11 11:09:10 2019
@@ -1,8 +1,8 @@
-// RUN: %clang_cc1 -std=c++98 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors
-// RUN: %clang_cc1 -std=c++11 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors
-// RUN: %clang_cc1 -std=c++14 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors
-// RUN: %clang_cc1 -std=c++17 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors
-// RUN: %clang_cc1 -std=c++2a %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors
+// RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++98 %s -verify 
-fexceptions -fcxx-exceptions -pedantic-errors
+// RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++11 %s -verify 
-fexceptions -fcxx-exceptions -pedantic-errors
+// RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++14 %s -verify 
-fexceptions -fcxx-exceptions 

[PATCH] D67382: [analyzer] NFC: Move getStmt() and createEndOfPath() out of PathDiagnostic.

2019-09-11 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ marked an inline comment as done.
NoQ added inline comments.



Comment at: clang/lib/StaticAnalyzer/Core/BugReporter.cpp:2185
   } else {
-assert(ErrorNode);
-hash.AddPointer(GetCurrentOrPreviousStmt(ErrorNode));

Szelethus wrote:
> Why delete the assert?
Because it's enforced by the type system these days. This is a method on 
`PathSensitiveBugReport` that always has an error node, as asserted in its 
constructor. I should have removed this assert in D66572.


Repository:
  rC Clang

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

https://reviews.llvm.org/D67382



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


[PATCH] D67381: [analyzer] NFC: Move stack hints to a side map.

2019-09-11 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ marked an inline comment as done.
NoQ added inline comments.



Comment at: clang/lib/StaticAnalyzer/Core/PathDiagnostic.cpp:34
 #include "clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h"
-#include "clang/StaticAnalyzer/Core/PathSensitive/SVals.h"
 #include "llvm/ADT/ArrayRef.h"

Szelethus wrote:
> Nice, how did you catch this? Some compiler warning?
No, it's just that removing these includes is the whole point of the patch. In 
order to be able to move this file out of static analyzer, it should not 
include headers from static analyzer. This patch removes one such include.


Repository:
  rC Clang

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

https://reviews.llvm.org/D67381



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


[PATCH] D67246: clang-format: Add support for formatting lambdas with explicit template parameters.

2019-09-11 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

Do you think this should land with the comment FIXME for now? It improves 
formatting of this language feature when that heuristic is not used, and 
changing the heuristic is independent of the rest of this patch.


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

https://reviews.llvm.org/D67246



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


[PATCH] D67031: [Clang][Bundler] Error reporting improvements

2019-09-11 Thread Sergey Dmitriev via Phabricator via cfe-commits
sdmitriev updated this revision to Diff 219742.
sdmitriev added a reviewer: Hahnfeld.
sdmitriev added a comment.

Rebase


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

https://reviews.llvm.org/D67031

Files:
  clang/test/Driver/clang-offload-bundler.c
  clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp

Index: clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
===
--- clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
+++ clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
@@ -26,15 +26,17 @@
 #include "llvm/Object/ObjectFile.h"
 #include "llvm/Support/Casting.h"
 #include "llvm/Support/CommandLine.h"
+#include "llvm/Support/Errc.h"
 #include "llvm/Support/Error.h"
 #include "llvm/Support/ErrorOr.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/Program.h"
-#include "llvm/Support/raw_ostream.h"
 #include "llvm/Support/Signals.h"
 #include "llvm/Support/StringSaver.h"
+#include "llvm/Support/WithColor.h"
+#include "llvm/Support/raw_ostream.h"
 #include 
 #include 
 #include 
@@ -42,6 +44,7 @@
 #include 
 #include 
 #include 
+#include 
 
 using namespace llvm;
 using namespace llvm::object;
@@ -122,35 +125,36 @@
 
   /// Update the file handler with information from the header of the bundled
   /// file
-  virtual void ReadHeader(MemoryBuffer ) = 0;
+  virtual Error ReadHeader(MemoryBuffer ) = 0;
 
   /// Read the marker of the next bundled to be read in the file. The triple of
   /// the target associated with that bundle is returned. An empty string is
   /// returned if there are no more bundles to be read.
-  virtual StringRef ReadBundleStart(MemoryBuffer ) = 0;
+  virtual Expected>
+  ReadBundleStart(MemoryBuffer ) = 0;
 
   /// Read the marker that closes the current bundle.
-  virtual void ReadBundleEnd(MemoryBuffer ) = 0;
+  virtual Error ReadBundleEnd(MemoryBuffer ) = 0;
 
   /// Read the current bundle and write the result into the stream \a OS.
-  virtual void ReadBundle(raw_fd_ostream , MemoryBuffer ) = 0;
+  virtual Error ReadBundle(raw_fd_ostream , MemoryBuffer ) = 0;
 
   /// Write the header of the bundled file to \a OS based on the information
   /// gathered from \a Inputs.
-  virtual void WriteHeader(raw_fd_ostream ,
-   ArrayRef> Inputs) = 0;
+  virtual Error WriteHeader(raw_fd_ostream ,
+ArrayRef> Inputs) = 0;
 
   /// Write the marker that initiates a bundle for the triple \a TargetTriple to
   /// \a OS.
-  virtual void WriteBundleStart(raw_fd_ostream , StringRef TargetTriple) = 0;
+  virtual Error WriteBundleStart(raw_fd_ostream ,
+ StringRef TargetTriple) = 0;
 
   /// Write the marker that closes a bundle for the triple \a TargetTriple to \a
-  /// OS. Return true if any error was found.
-
-  virtual bool WriteBundleEnd(raw_fd_ostream , StringRef TargetTriple) = 0;
+  /// OS.
+  virtual Error WriteBundleEnd(raw_fd_ostream , StringRef TargetTriple) = 0;
 
   /// Write the bundle from \a Input into \a OS.
-  virtual void WriteBundle(raw_fd_ostream , MemoryBuffer ) = 0;
+  virtual Error WriteBundle(raw_fd_ostream , MemoryBuffer ) = 0;
 };
 
 /// Handler for binary files. The bundled file will have the following format
@@ -222,7 +226,7 @@
 
   ~BinaryFileHandler() final {}
 
-  void ReadHeader(MemoryBuffer ) final {
+  Error ReadHeader(MemoryBuffer ) final {
 StringRef FC = Input.getBuffer();
 
 // Initialize the current bundle with the end of the container.
@@ -231,16 +235,16 @@
 // Check if buffer is smaller than magic string.
 size_t ReadChars = sizeof(OFFLOAD_BUNDLER_MAGIC_STR) - 1;
 if (ReadChars > FC.size())
-  return;
+  return Error::success();
 
 // Check if no magic was found.
 StringRef Magic(FC.data(), sizeof(OFFLOAD_BUNDLER_MAGIC_STR) - 1);
 if (!Magic.equals(OFFLOAD_BUNDLER_MAGIC_STR))
-  return;
+  return Error::success();
 
 // Read number of bundles.
 if (ReadChars + 8 > FC.size())
-  return;
+  return Error::success();
 
 uint64_t NumberOfBundles = Read8byteIntegerFromBuffer(FC, ReadChars);
 ReadChars += 8;
@@ -250,35 +254,35 @@
 
   // Read offset.
   if (ReadChars + 8 > FC.size())
-return;
+return Error::success();
 
   uint64_t Offset = Read8byteIntegerFromBuffer(FC, ReadChars);
   ReadChars += 8;
 
   // Read size.
   if (ReadChars + 8 > FC.size())
-return;
+return Error::success();
 
   uint64_t Size = Read8byteIntegerFromBuffer(FC, ReadChars);
   ReadChars += 8;
 
   // Read triple size.
   if (ReadChars + 8 > FC.size())
-return;
+return Error::success();
 
   uint64_t TripleSize = Read8byteIntegerFromBuffer(FC, ReadChars);
   ReadChars += 8;
 
   // Read triple.
   if (ReadChars + TripleSize > FC.size())
-

[PATCH] D61446: Generalize the pass registration mechanism used by Polly to any third-party tool

2019-09-11 Thread serge via Phabricator via cfe-commits
serge-sans-paille added a comment.

Up :-)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61446



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


[PATCH] D67452: [clang] [unittest] Import LLVMTestingSupport if necessary

2019-09-11 Thread Michał Górny via Phabricator via cfe-commits
mgorny created this revision.
mgorny added reviewers: sammccall, gribozavr, compnerd.
Herald added subscribers: kadircet, ilya-biryukov.

Add LLVMTestingSupport directory from LLVM_MAIN_SRC_DIR when building
clang stand-alone and LLVMTestingSupport library is not present.  This
is needed to fix stand-alone builds without clang-tools-extra.

// The code is copied verbatim from clangd unittests


https://reviews.llvm.org/D67452

Files:
  clang/unittests/CMakeLists.txt


Index: clang/unittests/CMakeLists.txt
===
--- clang/unittests/CMakeLists.txt
+++ clang/unittests/CMakeLists.txt
@@ -1,6 +1,15 @@
 add_custom_target(ClangUnitTests)
 set_target_properties(ClangUnitTests PROPERTIES FOLDER "Clang tests")
 
+if(CLANG_BUILT_STANDALONE)
+  # LLVMTestingSupport library is needed for some of the unittests.
+  if (EXISTS ${LLVM_MAIN_SRC_DIR}/lib/Testing/Support
+  AND NOT TARGET LLVMTestingSupport)
+add_subdirectory(${LLVM_MAIN_SRC_DIR}/lib/Testing/Support
+  lib/Testing/Support)
+  endif()
+endif()
+
 # add_clang_unittest(test_dirname file1.cpp file2.cpp)
 #
 # Will compile the list of files together and link against the clang


Index: clang/unittests/CMakeLists.txt
===
--- clang/unittests/CMakeLists.txt
+++ clang/unittests/CMakeLists.txt
@@ -1,6 +1,15 @@
 add_custom_target(ClangUnitTests)
 set_target_properties(ClangUnitTests PROPERTIES FOLDER "Clang tests")
 
+if(CLANG_BUILT_STANDALONE)
+  # LLVMTestingSupport library is needed for some of the unittests.
+  if (EXISTS ${LLVM_MAIN_SRC_DIR}/lib/Testing/Support
+  AND NOT TARGET LLVMTestingSupport)
+add_subdirectory(${LLVM_MAIN_SRC_DIR}/lib/Testing/Support
+  lib/Testing/Support)
+  endif()
+endif()
+
 # add_clang_unittest(test_dirname file1.cpp file2.cpp)
 #
 # Will compile the list of files together and link against the clang
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r371637 - [Clang][Bundler] Replace std::vector by SmallVector [NFC]

2019-09-11 Thread Sergey Dmitriev via cfe-commits
Author: sdmitriev
Date: Wed Sep 11 09:28:47 2019
New Revision: 371637

URL: http://llvm.org/viewvc/llvm-project?rev=371637=rev
Log:
[Clang][Bundler] Replace std::vector by SmallVector [NFC]

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

Modified:
cfe/trunk/tools/clang-offload-bundler/ClangOffloadBundler.cpp

Modified: cfe/trunk/tools/clang-offload-bundler/ClangOffloadBundler.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-offload-bundler/ClangOffloadBundler.cpp?rev=371637=371636=371637=diff
==
--- cfe/trunk/tools/clang-offload-bundler/ClangOffloadBundler.cpp (original)
+++ cfe/trunk/tools/clang-offload-bundler/ClangOffloadBundler.cpp Wed Sep 11 
09:28:47 2019
@@ -17,6 +17,7 @@
 #include "clang/Basic/Version.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/SmallString.h"
+#include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringMap.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/StringSwitch.h"
@@ -41,7 +42,6 @@
 #include 
 #include 
 #include 
-#include 
 
 using namespace llvm;
 using namespace llvm::object;
@@ -658,10 +658,8 @@ static bool BundleFiles() {
   }
 
   // Open input files.
-  std::vector> InputBuffers(
-  InputFileNames.size());
-
-  unsigned Idx = 0;
+  SmallVector, 8u> InputBuffers;
+  InputBuffers.reserve(InputFileNames.size());
   for (auto  : InputFileNames) {
 ErrorOr> CodeOrErr =
 MemoryBuffer::getFileOrSTDIN(I);
@@ -669,7 +667,7 @@ static bool BundleFiles() {
   errs() << "error: Can't open file " << I << ": " << EC.message() << "\n";
   return true;
 }
-InputBuffers[Idx++] = std::move(CodeOrErr.get());
+InputBuffers.emplace_back(std::move(CodeOrErr.get()));
   }
 
   // Get the file handler. We use the host buffer as reference.


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


[PATCH] D66324: clang-misexpect: Profile Guided Validation of Performance Annotations in LLVM

2019-09-11 Thread Petr Hosek via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL371635: Reland clang-misexpect: Profile Guided 
Validation of Performance Annotations… (authored by phosek, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D66324?vs=219728=219733#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D66324

Files:
  cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td
  cfe/trunk/include/clang/Basic/DiagnosticGroups.td
  cfe/trunk/lib/CodeGen/CodeGenAction.cpp
  cfe/trunk/lib/Frontend/CompilerInvocation.cpp
  cfe/trunk/test/Profile/Inputs/misexpect-branch-nonconst-expect-arg.proftext
  cfe/trunk/test/Profile/Inputs/misexpect-branch.proftext
  cfe/trunk/test/Profile/Inputs/misexpect-switch-default-only.proftext
  cfe/trunk/test/Profile/Inputs/misexpect-switch-default.proftext
  cfe/trunk/test/Profile/Inputs/misexpect-switch-nonconst.proftext
  cfe/trunk/test/Profile/Inputs/misexpect-switch.proftext
  cfe/trunk/test/Profile/misexpect-branch-cold.c
  cfe/trunk/test/Profile/misexpect-branch-nonconst-expected-val.c
  cfe/trunk/test/Profile/misexpect-branch-unpredictable.c
  cfe/trunk/test/Profile/misexpect-branch.c
  cfe/trunk/test/Profile/misexpect-switch-default.c
  cfe/trunk/test/Profile/misexpect-switch-nonconst.c
  cfe/trunk/test/Profile/misexpect-switch-only-default-case.c
  cfe/trunk/test/Profile/misexpect-switch.c
  llvm/trunk/include/llvm/IR/DiagnosticInfo.h
  llvm/trunk/include/llvm/IR/FixedMetadataKinds.def
  llvm/trunk/include/llvm/IR/MDBuilder.h
  llvm/trunk/include/llvm/Transforms/Utils/MisExpect.h
  llvm/trunk/lib/IR/DiagnosticInfo.cpp
  llvm/trunk/lib/IR/MDBuilder.cpp
  llvm/trunk/lib/Transforms/IPO/SampleProfile.cpp
  llvm/trunk/lib/Transforms/Instrumentation/PGOInstrumentation.cpp
  llvm/trunk/lib/Transforms/Scalar/LowerExpectIntrinsic.cpp
  llvm/trunk/lib/Transforms/Utils/CMakeLists.txt
  llvm/trunk/lib/Transforms/Utils/MisExpect.cpp
  llvm/trunk/test/ThinLTO/X86/lazyload_metadata.ll
  llvm/trunk/test/Transforms/LowerExpectIntrinsic/basic.ll
  llvm/trunk/test/Transforms/PGOProfile/Inputs/misexpect-branch-correct.proftext
  llvm/trunk/test/Transforms/PGOProfile/Inputs/misexpect-branch.proftext
  llvm/trunk/test/Transforms/PGOProfile/Inputs/misexpect-switch-correct.proftext
  llvm/trunk/test/Transforms/PGOProfile/Inputs/misexpect-switch.proftext
  llvm/trunk/test/Transforms/PGOProfile/misexpect-branch-correct.ll
  llvm/trunk/test/Transforms/PGOProfile/misexpect-branch-stripped.ll
  llvm/trunk/test/Transforms/PGOProfile/misexpect-branch-unpredictable.ll
  llvm/trunk/test/Transforms/PGOProfile/misexpect-branch.ll
  llvm/trunk/test/Transforms/PGOProfile/misexpect-switch-default.ll
  llvm/trunk/test/Transforms/PGOProfile/misexpect-switch.ll

Index: llvm/trunk/lib/IR/MDBuilder.cpp
===
--- llvm/trunk/lib/IR/MDBuilder.cpp
+++ llvm/trunk/lib/IR/MDBuilder.cpp
@@ -309,3 +309,15 @@
   };
   return MDNode::get(Context, Vals);
 }
+
+MDNode *MDBuilder::createMisExpect(uint64_t Index, uint64_t LikleyWeight,
+   uint64_t UnlikleyWeight) {
+  auto *IntType = Type::getInt64Ty(Context);
+  Metadata *Vals[] = {
+  createString("misexpect"),
+  createConstant(ConstantInt::get(IntType, Index)),
+  createConstant(ConstantInt::get(IntType, LikleyWeight)),
+  createConstant(ConstantInt::get(IntType, UnlikleyWeight)),
+  };
+  return MDNode::get(Context, Vals);
+}
Index: llvm/trunk/lib/IR/DiagnosticInfo.cpp
===
--- llvm/trunk/lib/IR/DiagnosticInfo.cpp
+++ llvm/trunk/lib/IR/DiagnosticInfo.cpp
@@ -370,5 +370,16 @@
   return OS.str();
 }
 
+DiagnosticInfoMisExpect::DiagnosticInfoMisExpect(const Instruction *Inst,
+ Twine )
+: DiagnosticInfoWithLocationBase(DK_MisExpect, DS_Warning,
+ *Inst->getParent()->getParent(),
+ Inst->getDebugLoc()),
+  Msg(Msg) {}
+
+void DiagnosticInfoMisExpect::print(DiagnosticPrinter ) const {
+  DP << getLocationStr() << ": " << getMsg();
+}
+
 void OptimizationRemarkAnalysisFPCommute::anchor() {}
 void OptimizationRemarkAnalysisAliasing::anchor() {}
Index: llvm/trunk/lib/Transforms/Utils/CMakeLists.txt
===
--- llvm/trunk/lib/Transforms/Utils/CMakeLists.txt
+++ llvm/trunk/lib/Transforms/Utils/CMakeLists.txt
@@ -40,6 +40,7 @@
   LowerSwitch.cpp
   Mem2Reg.cpp
   MetaRenamer.cpp
+  MisExpect.cpp
   ModuleUtils.cpp
   NameAnonGlobals.cpp
   PredicateInfo.cpp
Index: llvm/trunk/lib/Transforms/Utils/MisExpect.cpp
===
--- llvm/trunk/lib/Transforms/Utils/MisExpect.cpp
+++ llvm/trunk/lib/Transforms/Utils/MisExpect.cpp
@@ -0,0 +1,177 @@
+//===--- MisExpect.cpp - 

r371635 - Reland "clang-misexpect: Profile Guided Validation of Performance Annotations in LLVM"

2019-09-11 Thread Petr Hosek via cfe-commits
Author: phosek
Date: Wed Sep 11 09:19:50 2019
New Revision: 371635

URL: http://llvm.org/viewvc/llvm-project?rev=371635=rev
Log:
Reland "clang-misexpect: Profile Guided Validation of Performance Annotations 
in LLVM"

This patch contains the basic functionality for reporting potentially
incorrect usage of __builtin_expect() by comparing the developer's
annotation against a collected PGO profile. A more detailed proposal and
discussion appears on the CFE-dev mailing list
(http://lists.llvm.org/pipermail/cfe-dev/2019-July/062971.html) and a
prototype of the initial frontend changes appear here in D65300

We revised the work in D65300 by moving the misexpect check into the
LLVM backend, and adding support for IR and sampling based profiles, in
addition to frontend instrumentation.

We add new misexpect metadata tags to those instructions directly
influenced by the llvm.expect intrinsic (branch, switch, and select)
when lowering the intrinsics. The misexpect metadata contains
information about the expected target of the intrinsic so that we can
check against the correct PGO counter when emitting diagnostics, and the
compiler's values for the LikelyBranchWeight and UnlikelyBranchWeight.
We use these branch weight values to determine when to emit the
diagnostic to the user.

A future patch should address the comment at the top of
LowerExpectIntrisic.cpp to hoist the LikelyBranchWeight and
UnlikelyBranchWeight values into a shared space that can be accessed
outside of the LowerExpectIntrinsic pass. Once that is done, the
misexpect metadata can be updated to be smaller.

In the long term, it is possible to reconstruct portions of the
misexpect metadata from the existing profile data. However, we have
avoided this to keep the code simple, and because some kind of metadata
tag will be required to identify which branch/switch/select instructions
are influenced by the use of llvm.expect

Patch By: paulkirth
Differential Revision: https://reviews.llvm.org/D66324

Added:
cfe/trunk/test/Profile/Inputs/misexpect-branch-nonconst-expect-arg.proftext
cfe/trunk/test/Profile/Inputs/misexpect-branch.proftext
cfe/trunk/test/Profile/Inputs/misexpect-switch-default-only.proftext
cfe/trunk/test/Profile/Inputs/misexpect-switch-default.proftext
cfe/trunk/test/Profile/Inputs/misexpect-switch-nonconst.proftext
cfe/trunk/test/Profile/Inputs/misexpect-switch.proftext
cfe/trunk/test/Profile/misexpect-branch-cold.c
cfe/trunk/test/Profile/misexpect-branch-nonconst-expected-val.c
cfe/trunk/test/Profile/misexpect-branch-unpredictable.c
cfe/trunk/test/Profile/misexpect-branch.c
cfe/trunk/test/Profile/misexpect-switch-default.c
cfe/trunk/test/Profile/misexpect-switch-nonconst.c
cfe/trunk/test/Profile/misexpect-switch-only-default-case.c
cfe/trunk/test/Profile/misexpect-switch.c
Modified:
cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td
cfe/trunk/include/clang/Basic/DiagnosticGroups.td
cfe/trunk/lib/CodeGen/CodeGenAction.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td?rev=371635=371634=371635=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td Wed Sep 11 
09:19:50 2019
@@ -275,7 +275,12 @@ def warn_profile_data_missing : Warning<
 def warn_profile_data_unprofiled : Warning<
   "no profile data available for file \"%0\"">,
   InGroup;
-
+def warn_profile_data_misexpect : Warning<
+  "Potential performance regression from use of __builtin_expect(): "
+  "Annotation was correct on %0 of profiled executions.">,
+  BackendInfo,
+  InGroup,
+  DefaultIgnore;
 } // end of instrumentation issue category
 
 }

Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticGroups.td?rev=371635=371634=371635=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticGroups.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td Wed Sep 11 09:19:50 2019
@@ -1042,6 +1042,7 @@ def BackendOptimizationFailure : DiagGro
 def ProfileInstrMissing : DiagGroup<"profile-instr-missing">;
 def ProfileInstrOutOfDate : DiagGroup<"profile-instr-out-of-date">;
 def ProfileInstrUnprofiled : DiagGroup<"profile-instr-unprofiled">;
+def MisExpect : DiagGroup<"misexpect">;
 
 // AddressSanitizer frontend instrumentation remarks.
 def SanitizeAddressRemarks : DiagGroup<"sanitize-address">;

Modified: cfe/trunk/lib/CodeGen/CodeGenAction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenAction.cpp?rev=371635=371634=371635=diff

[PATCH] D66324: clang-misexpect: Profile Guided Validation of Performance Annotations in LLVM

2019-09-11 Thread Paul Kirth via Phabricator via cfe-commits
paulkirth updated this revision to Diff 219728.
paulkirth added a comment.

Revert mismerge when landing.


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

https://reviews.llvm.org/D66324

Files:
  clang/include/clang/Basic/DiagnosticFrontendKinds.td
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/lib/CodeGen/CodeGenAction.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/Profile/Inputs/misexpect-branch-nonconst-expect-arg.proftext
  clang/test/Profile/Inputs/misexpect-branch.proftext
  clang/test/Profile/Inputs/misexpect-switch-default-only.proftext
  clang/test/Profile/Inputs/misexpect-switch-default.proftext
  clang/test/Profile/Inputs/misexpect-switch-nonconst.proftext
  clang/test/Profile/Inputs/misexpect-switch.proftext
  clang/test/Profile/misexpect-branch-cold.c
  clang/test/Profile/misexpect-branch-nonconst-expected-val.c
  clang/test/Profile/misexpect-branch-unpredictable.c
  clang/test/Profile/misexpect-branch.c
  clang/test/Profile/misexpect-switch-default.c
  clang/test/Profile/misexpect-switch-nonconst.c
  clang/test/Profile/misexpect-switch-only-default-case.c
  clang/test/Profile/misexpect-switch.c
  llvm/include/llvm/IR/DiagnosticInfo.h
  llvm/include/llvm/IR/FixedMetadataKinds.def
  llvm/include/llvm/IR/MDBuilder.h
  llvm/include/llvm/Transforms/Utils/MisExpect.h
  llvm/lib/IR/DiagnosticInfo.cpp
  llvm/lib/IR/MDBuilder.cpp
  llvm/lib/Transforms/IPO/SampleProfile.cpp
  llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp
  llvm/lib/Transforms/Scalar/LowerExpectIntrinsic.cpp
  llvm/lib/Transforms/Utils/CMakeLists.txt
  llvm/lib/Transforms/Utils/MisExpect.cpp
  llvm/test/ThinLTO/X86/lazyload_metadata.ll
  llvm/test/Transforms/LowerExpectIntrinsic/basic.ll
  llvm/test/Transforms/PGOProfile/Inputs/misexpect-branch-correct.proftext
  llvm/test/Transforms/PGOProfile/Inputs/misexpect-branch.proftext
  llvm/test/Transforms/PGOProfile/Inputs/misexpect-switch-correct.proftext
  llvm/test/Transforms/PGOProfile/Inputs/misexpect-switch.proftext
  llvm/test/Transforms/PGOProfile/misexpect-branch-correct.ll
  llvm/test/Transforms/PGOProfile/misexpect-branch-stripped.ll
  llvm/test/Transforms/PGOProfile/misexpect-branch-unpredictable.ll
  llvm/test/Transforms/PGOProfile/misexpect-branch.ll
  llvm/test/Transforms/PGOProfile/misexpect-switch-default.ll
  llvm/test/Transforms/PGOProfile/misexpect-switch.ll

Index: llvm/test/Transforms/PGOProfile/misexpect-switch.ll
===
--- /dev/null
+++ llvm/test/Transforms/PGOProfile/misexpect-switch.ll
@@ -0,0 +1,293 @@
+
+; RUN: llvm-profdata merge %S/Inputs/misexpect-switch.proftext -o %t.profdata
+; RUN: llvm-profdata merge %S/Inputs/misexpect-switch-correct.proftext -o %t.c.profdata
+
+; RUN: opt < %s -lower-expect -pgo-instr-use -pgo-test-profile-file=%t.profdata -S -pgo-warn-misexpect 2>&1 | FileCheck %s --check-prefix=WARNING
+; RUN: opt < %s -lower-expect -pgo-instr-use -pgo-test-profile-file=%t.profdata -S -pass-remarks=misexpect 2>&1 | FileCheck %s --check-prefix=REMARK
+; RUN: opt < %s -lower-expect -pgo-instr-use -pgo-test-profile-file=%t.profdata -S -pgo-warn-misexpect -pass-remarks=misexpect 2>&1 | FileCheck %s --check-prefix=BOTH
+; RUN: opt < %s -lower-expect -pgo-instr-use -pgo-test-profile-file=%t.profdata -S 2>&1 | FileCheck %s --check-prefix=DISABLED
+
+; New PM
+; RUN: opt < %s -passes="function(lower-expect),pgo-instr-use" -pgo-test-profile-file=%t.profdata -pgo-warn-misexpect -S 2>&1 | FileCheck %s --check-prefix=WARNING
+; RUN: opt < %s -passes="function(lower-expect),pgo-instr-use" -pgo-test-profile-file=%t.profdata -pass-remarks=misexpect -S 2>&1 | FileCheck %s --check-prefix=REMARK
+; RUN: opt < %s -passes="function(lower-expect),pgo-instr-use" -pgo-test-profile-file=%t.profdata -pgo-warn-misexpect -pass-remarks=misexpect -S 2>&1 | FileCheck %s --check-prefix=BOTH
+; RUN: opt < %s -passes="function(lower-expect),pgo-instr-use" -pgo-test-profile-file=%t.profdata -S 2>&1 | FileCheck %s --check-prefix=DISABLED
+
+; RUN: opt < %s -lower-expect -pgo-instr-use -pgo-test-profile-file=%t.c.profdata -S -pgo-warn-misexpect -pass-remarks=misexpect 2>&1 | FileCheck %s --check-prefix=CORRECT
+; RUN: opt < %s -passes="function(lower-expect),pgo-instr-use" -pgo-test-profile-file=%t.c.profdata -pgo-warn-misexpect -pass-remarks=misexpect -S 2>&1 | FileCheck %s --check-prefix=CORRECT
+
+; WARNING-DAG: warning: misexpect-switch.c:26:5: 0.00%
+; WARNING-NOT: remark: misexpect-switch.c:26:5: Potential performance regression from use of the llvm.expect intrinsic: Annotation was correct on 0.00% (0 / 8112) of profiled executions.
+
+; REMARK-NOT: warning: misexpect-switch.c:26:5: 0.00%
+; REMARK-DAG: remark: misexpect-switch.c:26:5: Potential performance regression from use of the llvm.expect intrinsic: Annotation was correct on 0.00% (0 / 8112) of profiled executions.
+
+; BOTH-DAG: warning: misexpect-switch.c:26:5: 0.00%
+; BOTH-DAG: remark: 

[PATCH] D66324: clang-misexpect: Profile Guided Validation of Performance Annotations in LLVM

2019-09-11 Thread Paul Kirth via Phabricator via cfe-commits
paulkirth added a comment.

In D66324#1665784 , @lebedev.ri wrote:

> In D66324#1665773 , @gribozavr wrote:
>
> > Reverted in r371598.
> >
> > Another concern that I have is cross-compilation. LLVM's ADT is not set up 
> > to be cross-compiled like the rest of compiler-rt is.
>
>
> Uhm, i have a better question still - why xxhash is even there? it's not used 
> in the diff, and was not reviewed, it just magically appeared in the last 
> update of the patch:
>  https://reviews.llvm.org/D66324?vs=219617=219645


It shouldn't have. My last change only modified a test file to not trigger a 
memory corruption bug. I'm filing a bug for that, but am waiting on a login for 
the bug tracker.

What I suspect happened is that when this landed some local changes got sucked 
in. I'm terribly sorry, it wasn't my intention to add anything significant to 
the patch.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D66324



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


[PATCH] D66324: clang-misexpect: Profile Guided Validation of Performance Annotations in LLVM

2019-09-11 Thread Petr Hosek via Phabricator via cfe-commits
phosek added inline comments.



Comment at: compiler-rt/trunk/lib/profile/xxhash.h:41-42
+
+#include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/StringRef.h"
+

paulkirth wrote:
> chandlerc wrote:
> > Sorry folks, but you can't do this.
> > 
> > You can't depend on ADT from compiler-rt currently.
> > 
> > There are at least two problems here:
> > 
> > First problem is that this pollutes the profile library with symbols from 
> > ADT. That really doesn't seem reasonable without *significant* and invasive 
> > changes to ADT. Otherwise building LLVM and linking it with the profile 
> > library will create an ODR violation (imagine different assert levels or 
> > different versions of LLVM buing built and the host toolchain).
> > 
> > 
> > Second, and much more critically, we haven't gotten to 100% relicensed on 
> > ADT, so it is critical that we not depend on it from runtime libraries.
> > 
> > Third, a lot of this code seems to use old license headers. Please do not 
> > add any code like this to LLVM, and instead use the new LLVM license for 
> > all new code.
> > 
> > For now, this patch (and any related patches) need to be reverted until 
> > these are addressed. Especially the license issues.
> Sorry, this looks like a mismerge somehow. My patch should't have anything 
> from compiler-rt. I think maybe a local change got rolled in when Petr landed 
> my patch.
Sorry about that, this was my mistake, it seems two of my stales files got 
included in when I applied the patch locally. I'll revert the change and reland 
it correctly.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D66324



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


[PATCH] D66324: clang-misexpect: Profile Guided Validation of Performance Annotations in LLVM

2019-09-11 Thread Paul Kirth via Phabricator via cfe-commits
paulkirth marked an inline comment as done.
paulkirth added inline comments.



Comment at: compiler-rt/trunk/lib/profile/xxhash.h:41-42
+
+#include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/StringRef.h"
+

chandlerc wrote:
> Sorry folks, but you can't do this.
> 
> You can't depend on ADT from compiler-rt currently.
> 
> There are at least two problems here:
> 
> First problem is that this pollutes the profile library with symbols from 
> ADT. That really doesn't seem reasonable without *significant* and invasive 
> changes to ADT. Otherwise building LLVM and linking it with the profile 
> library will create an ODR violation (imagine different assert levels or 
> different versions of LLVM buing built and the host toolchain).
> 
> 
> Second, and much more critically, we haven't gotten to 100% relicensed on 
> ADT, so it is critical that we not depend on it from runtime libraries.
> 
> Third, a lot of this code seems to use old license headers. Please do not add 
> any code like this to LLVM, and instead use the new LLVM license for all new 
> code.
> 
> For now, this patch (and any related patches) need to be reverted until these 
> are addressed. Especially the license issues.
Sorry, this looks like a mismerge somehow. My patch should't have anything from 
compiler-rt. I think maybe a local change got rolled in when Petr landed my 
patch.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D66324



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


r371633 - [Clang][Bundler] Fix for a potential memory leak [NFC]

2019-09-11 Thread Sergey Dmitriev via cfe-commits
Author: sdmitriev
Date: Wed Sep 11 09:03:21 2019
New Revision: 371633

URL: http://llvm.org/viewvc/llvm-project?rev=371633=rev
Log:
[Clang][Bundler] Fix for a potential memory leak [NFC]

Bundler leaks memory if it is called with -type=o but given input isn't an 
object file (though it has to have a known binary type like IR, archive, 
etc...). Memory leak is happening when binary object returned by the 
createBinary(...) call cannot be casted to an ObjectFile type. In this case 
returned BinaryOrErr object releases ownership of the binary, but no one is 
taking it (see line 626).

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

Modified:
cfe/trunk/tools/clang-offload-bundler/ClangOffloadBundler.cpp

Modified: cfe/trunk/tools/clang-offload-bundler/ClangOffloadBundler.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-offload-bundler/ClangOffloadBundler.cpp?rev=371633=371632=371633=diff
==
--- cfe/trunk/tools/clang-offload-bundler/ClangOffloadBundler.cpp (original)
+++ cfe/trunk/tools/clang-offload-bundler/ClangOffloadBundler.cpp Wed Sep 11 
09:03:21 2019
@@ -611,24 +611,15 @@ static FileHandler *CreateObjectFileHand
   // Check if the input file format is one that we know how to deal with.
   Expected> BinaryOrErr = createBinary(FirstInput);
 
-  // Failed to open the input as a known binary. Use the default binary 
handler.
-  if (!BinaryOrErr) {
-// We don't really care about the error (we just consume it), if we could
-// not get a valid device binary object we use the default binary handler.
-consumeError(BinaryOrErr.takeError());
+  // We only support regular object files. If failed to open the input as a
+  // known binary or this is not an object file use the default binary handler.
+  if (errorToBool(BinaryOrErr.takeError()) || !isa(*BinaryOrErr))
 return new BinaryFileHandler();
-  }
 
-  // We only support regular object files. If this is not an object file,
-  // default to the binary handler. The handler will be owned by the client of
-  // this function.
-  std::unique_ptr Obj(
-  dyn_cast(BinaryOrErr.get().release()));
-
-  if (!Obj)
-return new BinaryFileHandler();
-
-  return new ObjectFileHandler(std::move(Obj));
+  // Otherwise create an object file handler. The handler will be owned by the
+  // client of this function.
+  return new ObjectFileHandler(
+  std::unique_ptr(cast(BinaryOrErr->release(;
 }
 
 /// Return an appropriate handler given the input files and options.


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


[PATCH] D66018: [ARM] Take into account -mcpu and -mfpu options while handling 'crypto' feature

2019-09-11 Thread Kristina Bessonova via Phabricator via cfe-commits
krisb added a comment.

@dnsampaio, many thanks for committing this!


Repository:
  rL LLVM

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

https://reviews.llvm.org/D66018



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


  1   2   >