[PATCH] D70500: [WebAssembly] Enable use of wasm-opt and LTO-enabled system libraries

2019-11-22 Thread sunfishcode via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG812828984c10: [WebAssembly] Use wasm-opt and LTO libraries 
when available. (authored by sunfishcode).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70500

Files:
  clang/lib/Driver/ToolChains/WebAssembly.cpp
  clang/test/Driver/wasm-toolchain-lto.c


Index: clang/test/Driver/wasm-toolchain-lto.c
===
--- /dev/null
+++ clang/test/Driver/wasm-toolchain-lto.c
@@ -0,0 +1,6 @@
+// A basic C link command-line with optimization with known OS and LTO enabled.
+
+// RUN: %clang -### -O2 -flto -no-canonical-prefixes -target wasm32-wasi 
--sysroot=/foo %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=LINK_OPT_KNOWN %s
+// LINK_OPT_KNOWN: clang{{.*}}" "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
+// LINK_OPT_KNOWN: wasm-ld{{.*}}" "-L/foo/lib/wasm32-wasi/llvm-lto/
Index: clang/lib/Driver/ToolChains/WebAssembly.cpp
===
--- clang/lib/Driver/ToolChains/WebAssembly.cpp
+++ clang/lib/Driver/ToolChains/WebAssembly.cpp
@@ -8,6 +8,7 @@
 
 #include "WebAssembly.h"
 #include "CommonArgs.h"
+#include "clang/Basic/Version.h"
 #include "clang/Config/config.h"
 #include "clang/Driver/Compilation.h"
 #include "clang/Driver/Driver.h"
@@ -90,6 +91,31 @@
   CmdArgs.push_back(Output.getFilename());
 
   C.addCommand(std::make_unique(JA, *this, Linker, CmdArgs, Inputs));
+
+  // When optimizing, if wasm-opt is in the PATH, run wasm-opt.
+  if (Arg *A = Args.getLastArg(options::OPT_O_Group)) {
+if (llvm::ErrorOr WasmOptPath =
+   llvm::sys::findProgramByName("wasm-opt")) {
+  StringRef OOpt = "s";
+  if (A->getOption().matches(options::OPT_O4) ||
+  A->getOption().matches(options::OPT_Ofast))
+OOpt = "4";
+  else if (A->getOption().matches(options::OPT_O0))
+OOpt = "0";
+  else if (A->getOption().matches(options::OPT_O))
+OOpt = A->getValue();
+
+  if (OOpt != "0") {
+const char *WasmOpt = Args.MakeArgString(*WasmOptPath);
+ArgStringList CmdArgs;
+CmdArgs.push_back(Output.getFilename());
+CmdArgs.push_back(Args.MakeArgString(llvm::Twine("-O") + OOpt));
+CmdArgs.push_back("-o");
+CmdArgs.push_back(Output.getFilename());
+C.addCommand(std::make_unique(JA, *this, WasmOpt, CmdArgs, 
Inputs));
+  }
+}
+  }
 }
 
 WebAssembly::WebAssembly(const Driver , const llvm::Triple ,
@@ -109,6 +135,16 @@
   } else {
 const std::string MultiarchTriple =
 getMultiarchTriple(getDriver(), Triple, getDriver().SysRoot);
+if (D.isUsingLTO()) {
+  auto LLVMRevision = getLLVMRevision();
+  if (!LLVMRevision.empty()) {
+// For LTO, enable use of lto-enabled sysroot libraries too, if 
available.
+// Note that the directory is keyed to the LLVM revision, as LLVM's
+// bitcode format is not stable.
+getFilePaths().push_back(getDriver().SysRoot + "/lib/" + 
MultiarchTriple +
+ "/llvm-lto/" + LLVMRevision);
+  }
+}
 getFilePaths().push_back(getDriver().SysRoot + "/lib/" + MultiarchTriple);
   }
 }


Index: clang/test/Driver/wasm-toolchain-lto.c
===
--- /dev/null
+++ clang/test/Driver/wasm-toolchain-lto.c
@@ -0,0 +1,6 @@
+// A basic C link command-line with optimization with known OS and LTO enabled.
+
+// RUN: %clang -### -O2 -flto -no-canonical-prefixes -target wasm32-wasi --sysroot=/foo %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=LINK_OPT_KNOWN %s
+// LINK_OPT_KNOWN: clang{{.*}}" "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
+// LINK_OPT_KNOWN: wasm-ld{{.*}}" "-L/foo/lib/wasm32-wasi/llvm-lto/
Index: clang/lib/Driver/ToolChains/WebAssembly.cpp
===
--- clang/lib/Driver/ToolChains/WebAssembly.cpp
+++ clang/lib/Driver/ToolChains/WebAssembly.cpp
@@ -8,6 +8,7 @@
 
 #include "WebAssembly.h"
 #include "CommonArgs.h"
+#include "clang/Basic/Version.h"
 #include "clang/Config/config.h"
 #include "clang/Driver/Compilation.h"
 #include "clang/Driver/Driver.h"
@@ -90,6 +91,31 @@
   CmdArgs.push_back(Output.getFilename());
 
   C.addCommand(std::make_unique(JA, *this, Linker, CmdArgs, Inputs));
+
+  // When optimizing, if wasm-opt is in the PATH, run wasm-opt.
+  if (Arg *A = Args.getLastArg(options::OPT_O_Group)) {
+if (llvm::ErrorOr WasmOptPath =
+   llvm::sys::findProgramByName("wasm-opt")) {
+  StringRef OOpt = "s";
+  if (A->getOption().matches(options::OPT_O4) ||
+  A->getOption().matches(options::OPT_Ofast))
+OOpt = "4";
+  else if (A->getOption().matches(options::OPT_O0))
+OOpt = "0";
+  else if (A->getOption().matches(options::OPT_O))
+OOpt = A->getValue();
+
+  if (OOpt != "0") 

[PATCH] D69420: [clang][clang-scan-deps] Add support for extracting full module dependencies.

2019-11-22 Thread Doug Gregor via Phabricator via cfe-commits
doug.gregor added a comment.

In D69420#1757664 , @Bigcheese wrote:

> It was already there from a previous commit. I see it in tree currently.


Oh, sorry. I missed it in my cherry-picking and GitHub search failed to find it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69420



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


[clang] 8128289 - [WebAssembly] Use wasm-opt and LTO libraries when available.

2019-11-22 Thread Dan Gohman via cfe-commits

Author: Dan Gohman
Date: 2019-11-22T22:16:28-08:00
New Revision: 812828984c10857a4cd260eb638c52a4411f9143

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

LOG: [WebAssembly] Use wasm-opt and LTO libraries when available.

When there's a wasm-opt in the PATH, run the it to optimize LLVM's
output. This fixes PR43796.

And, add an "llvm-lto" directory to the sysroot library search paths,
so that sysroots can provide LTO-enabled system libraries.

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

Added: 
clang/test/Driver/wasm-toolchain-lto.c

Modified: 
clang/lib/Driver/ToolChains/WebAssembly.cpp

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/WebAssembly.cpp 
b/clang/lib/Driver/ToolChains/WebAssembly.cpp
index ab648025f222..a2a9dff79e52 100644
--- a/clang/lib/Driver/ToolChains/WebAssembly.cpp
+++ b/clang/lib/Driver/ToolChains/WebAssembly.cpp
@@ -8,6 +8,7 @@
 
 #include "WebAssembly.h"
 #include "CommonArgs.h"
+#include "clang/Basic/Version.h"
 #include "clang/Config/config.h"
 #include "clang/Driver/Compilation.h"
 #include "clang/Driver/Driver.h"
@@ -90,6 +91,31 @@ void wasm::Linker::ConstructJob(Compilation , const 
JobAction ,
   CmdArgs.push_back(Output.getFilename());
 
   C.addCommand(std::make_unique(JA, *this, Linker, CmdArgs, Inputs));
+
+  // When optimizing, if wasm-opt is in the PATH, run wasm-opt.
+  if (Arg *A = Args.getLastArg(options::OPT_O_Group)) {
+if (llvm::ErrorOr WasmOptPath =
+   llvm::sys::findProgramByName("wasm-opt")) {
+  StringRef OOpt = "s";
+  if (A->getOption().matches(options::OPT_O4) ||
+  A->getOption().matches(options::OPT_Ofast))
+OOpt = "4";
+  else if (A->getOption().matches(options::OPT_O0))
+OOpt = "0";
+  else if (A->getOption().matches(options::OPT_O))
+OOpt = A->getValue();
+
+  if (OOpt != "0") {
+const char *WasmOpt = Args.MakeArgString(*WasmOptPath);
+ArgStringList CmdArgs;
+CmdArgs.push_back(Output.getFilename());
+CmdArgs.push_back(Args.MakeArgString(llvm::Twine("-O") + OOpt));
+CmdArgs.push_back("-o");
+CmdArgs.push_back(Output.getFilename());
+C.addCommand(std::make_unique(JA, *this, WasmOpt, CmdArgs, 
Inputs));
+  }
+}
+  }
 }
 
 WebAssembly::WebAssembly(const Driver , const llvm::Triple ,
@@ -109,6 +135,16 @@ WebAssembly::WebAssembly(const Driver , const 
llvm::Triple ,
   } else {
 const std::string MultiarchTriple =
 getMultiarchTriple(getDriver(), Triple, getDriver().SysRoot);
+if (D.isUsingLTO()) {
+  auto LLVMRevision = getLLVMRevision();
+  if (!LLVMRevision.empty()) {
+// For LTO, enable use of lto-enabled sysroot libraries too, if 
available.
+// Note that the directory is keyed to the LLVM revision, as LLVM's
+// bitcode format is not stable.
+getFilePaths().push_back(getDriver().SysRoot + "/lib/" + 
MultiarchTriple +
+ "/llvm-lto/" + LLVMRevision);
+  }
+}
 getFilePaths().push_back(getDriver().SysRoot + "/lib/" + MultiarchTriple);
   }
 }

diff  --git a/clang/test/Driver/wasm-toolchain-lto.c 
b/clang/test/Driver/wasm-toolchain-lto.c
new file mode 100644
index ..216207316f3d
--- /dev/null
+++ b/clang/test/Driver/wasm-toolchain-lto.c
@@ -0,0 +1,6 @@
+// A basic C link command-line with optimization with known OS and LTO enabled.
+
+// RUN: %clang -### -O2 -flto -no-canonical-prefixes -target wasm32-wasi 
--sysroot=/foo %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=LINK_OPT_KNOWN %s
+// LINK_OPT_KNOWN: clang{{.*}}" "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
+// LINK_OPT_KNOWN: wasm-ld{{.*}}" "-L/foo/lib/wasm32-wasi/llvm-lto/



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


[PATCH] D69420: [clang][clang-scan-deps] Add support for extracting full module dependencies.

2019-11-22 Thread Michael Spencer via Phabricator via cfe-commits
Bigcheese added a comment.

It was already there from a previous commit. I see it in tree currently.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69420



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


[PATCH] D70632: clang-format-vs : Fix typo NUGET_EXE_DIR on README

2019-11-22 Thread empty2fill via Phabricator via cfe-commits
empty2fill created this revision.
empty2fill added a reviewer: hans.
empty2fill added a project: clang-format.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Match with the CMake variable.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D70632

Files:
  clang/tools/clang-format-vs/README.txt


Index: clang/tools/clang-format-vs/README.txt
===
--- clang/tools/clang-format-vs/README.txt
+++ clang/tools/clang-format-vs/README.txt
@@ -10,12 +10,12 @@
 
 - BUILD_CLANG_FORMAT_VS_PLUGIN=ON
 
-- NUGET_EXE_PATH=path/to/nuget_dir (unless nuget.exe is already available in 
PATH)
+- NUGET_EXE_DIR=path/to/nuget_dir (unless nuget.exe is already available in 
PATH)
 
 example:
   cd /d C:\code\llvm
   mkdir build & cd build
-  cmake -DBUILD_CLANG_FORMAT_VS_PLUGIN=ON -DNUGET_EXE_PATH=C:\nuget ..
+  cmake -DBUILD_CLANG_FORMAT_VS_PLUGIN=ON -DNUGET_EXE_DIR=C:\nuget ..
 
 Once LLVM.sln is generated, build the clang_format_vsix target, which will 
build
 ClangFormat.sln, the C# extension application.


Index: clang/tools/clang-format-vs/README.txt
===
--- clang/tools/clang-format-vs/README.txt
+++ clang/tools/clang-format-vs/README.txt
@@ -10,12 +10,12 @@
 
 - BUILD_CLANG_FORMAT_VS_PLUGIN=ON
 
-- NUGET_EXE_PATH=path/to/nuget_dir (unless nuget.exe is already available in PATH)
+- NUGET_EXE_DIR=path/to/nuget_dir (unless nuget.exe is already available in PATH)
 
 example:
   cd /d C:\code\llvm
   mkdir build & cd build
-  cmake -DBUILD_CLANG_FORMAT_VS_PLUGIN=ON -DNUGET_EXE_PATH=C:\nuget ..
+  cmake -DBUILD_CLANG_FORMAT_VS_PLUGIN=ON -DNUGET_EXE_DIR=C:\nuget ..
 
 Once LLVM.sln is generated, build the clang_format_vsix target, which will build
 ClangFormat.sln, the C# extension application.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D69420: [clang][clang-scan-deps] Add support for extracting full module dependencies.

2019-11-22 Thread Doug Gregor via Phabricator via cfe-commits
doug.gregor added a comment.

It looks like Inputs/modules_cdb.json missing from this patch?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69420



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


[PATCH] D70537: [clang] CGDebugInfo asserts `!DT.isNull()` when compiling with debug symbols

2019-11-22 Thread kamlesh kumar via Phabricator via cfe-commits
kamleshbhalui updated this revision to Diff 230747.
kamleshbhalui added a comment.

Thanks, @vsk for reviewing.
I have incorporated your suggestions.


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

https://reviews.llvm.org/D70537

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/test/CodeGenCXX/pr42710.cpp


Index: clang/test/CodeGenCXX/pr42710.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/pr42710.cpp
@@ -0,0 +1,20 @@
+// RUN: %clang %s -DTYPE=auto -emit-llvm -S -g -o - -std=c++17
+// expected-no-diagnostics
+// RUN: %clang %s -DTYPE=int -emit-llvm -S -g -o - -std=c++17
+// expected-no-diagnostics
+
+struct TypeId
+{
+inline static int counter{};
+
+template
+inline static const TYPE identifier = counter++;
+
+template
+inline static const TYPE value = identifier;
+};
+
+int main()
+{
+return TypeId::value;
+}
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -1433,6 +1433,10 @@
 if (isa(V))
   continue;
 
+if (isa(V) &&
+V->getType()->isUndeducedType())
+  continue;
+
 // Reuse the existing static member declaration if one exists
 auto MI = StaticDataMemberCache.find(V->getCanonicalDecl());
 if (MI != StaticDataMemberCache.end()) {


Index: clang/test/CodeGenCXX/pr42710.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/pr42710.cpp
@@ -0,0 +1,20 @@
+// RUN: %clang %s -DTYPE=auto -emit-llvm -S -g -o - -std=c++17
+// expected-no-diagnostics
+// RUN: %clang %s -DTYPE=int -emit-llvm -S -g -o - -std=c++17
+// expected-no-diagnostics
+
+struct TypeId
+{
+inline static int counter{};
+
+template
+inline static const TYPE identifier = counter++;
+
+template
+inline static const TYPE value = identifier;
+};
+
+int main()
+{
+return TypeId::value;
+}
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -1433,6 +1433,10 @@
 if (isa(V))
   continue;
 
+if (isa(V) &&
+V->getType()->isUndeducedType())
+  continue;
+
 // Reuse the existing static member declaration if one exists
 auto MI = StaticDataMemberCache.find(V->getCanonicalDecl());
 if (MI != StaticDataMemberCache.end()) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 380a645 - [ASTMatchers] work around a miscompile; "NFC"

2019-11-22 Thread George Burgess IV via cfe-commits

Author: George Burgess IV
Date: 2019-11-22T20:11:16-08:00
New Revision: 380a6452b2e98d9c34828503edf8032f6b4c82d3

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

LOG: [ASTMatchers] work around a miscompile; "NFC"

I chatted with Reid offline, and we agreed that having a workaround here
would be appropriate until PR43879 is resolved.

The given transformation Works On My Machine(TM), and should hopefully
hold more broadly, but my fingers are crossed nonetheless. :)

Added: 


Modified: 
clang/lib/ASTMatchers/ASTMatchFinder.cpp

Removed: 




diff  --git a/clang/lib/ASTMatchers/ASTMatchFinder.cpp 
b/clang/lib/ASTMatchers/ASTMatchFinder.cpp
index c51fd630e64b..8a103f3d89a3 100644
--- a/clang/lib/ASTMatchers/ASTMatchFinder.cpp
+++ b/clang/lib/ASTMatchers/ASTMatchFinder.cpp
@@ -904,8 +904,9 @@ bool MatchASTVisitor::objcClassIsDerivedFrom(
 if (Base.matches(*ClassDecl, this, Builder))
   return true;
 
+// Not `return false` as a temporary workaround for PR43879.
 if (Directly)
-  return false;
+  break;
   }
 
   return false;



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


Buildbot numbers for the week of 11/10/2019 - 11/16/2019

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

Below are some buildbot numbers for the last week of 11/10/2019 -
11/16/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
--+-
 reverse-iteration| 67:01:47
 llvm-clang-win-x-armv7l  | 23:59:35
 llvm-sphinx-docs | 23:27:00
 llvm-clang-x86_64-expensive-checks-win   | 16:24:32
 clang-cmake-x86_64-avx2-linux| 15:40:52
 clang-cmake-x86_64-sde-avx512-linux  | 14:04:07
 clang-lld-x86_64-2stage  | 12:27:54
 clang-cmake-armv7-full   | 10:11:36
 sanitizer-x86_64-linux-bootstrap | 09:15:18
 llvm-clang-win-x-aarch64 | 09:03:43
 sanitizer-x86_64-linux-bootstrap-ubsan   | 08:23:49
 clang-cmake-armv7-selfhost-neon  | 07:44:38
 clang-with-lto-ubuntu| 07:18:30
 clang-with-thin-lto-ubuntu   | 06:20:57
 clang-cmake-aarch64-lld  | 05:54:52
 clang-cmake-armv7-selfhost   | 05:40:40
 clang-s390x-linux-multistage | 05:36:09
 clang-ppc64le-linux-multistage   | 05:31:12
 clang-cmake-aarch64-full | 05:30:14
 llvm-clang-x86_64-expensive-checks-ubuntu| 05:16:29
 clang-ppc64be-linux-multistage   | 04:31:16
 clang-s390x-linux-lnt| 04:24:03
 clang-s390x-linux| 04:22:31
 clang-ppc64be-linux-lnt  | 04:20:30
 clang-ppc64be-linux  | 04:19:07
 clang-ppc64le-linux  | 04:01:37
 clang-cmake-aarch64-quick| 03:42:42
 clang-cmake-aarch64-global-isel  | 03:41:56
 clang-ppc64le-linux-lnt  | 03:37:04
 ppc64le-lld-multistage-test  | 03:30:09
 clang-cmake-armv7-lnt| 03:26:38
 clang-cuda-build | 03:19:36
 lld-x86_64-ubuntu-fast   | 03:16:58
 lld-x86_64-darwin13  | 03:14:00
 clang-cmake-armv8-lld| 03:12:37
 clang-x86_64-linux-abi-test  | 03:09:14
 llvm-clang-x86_64-win-fast   | 03:06:37
 lld-x86_64-win7  | 03:04:48
 clang-x64-windows-msvc   | 03:02:17
 clang-cmake-armv7-quick  | 03:00:04
 llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast   | 02:59:07
 clang-cmake-armv7-global-isel| 02:53:02
 sanitizer-x86_64-linux-bootstrap-msan| 02:49:11
 clang-hexagon-elf| 02:44:17
 sanitizer-x86_64-linux-fuzzer| 02:43:15
 sanitizer-x86_64-linux-fast  | 02:38:17
 sanitizer-x86_64-linux   | 02:35:57
 sanitizer-ppc64be-linux  | 02:34:32
 sanitizer-x86_64-linux-android   | 02:18:29
 llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast | 02:15:30
 clang-cmake-thumbv7-full-sh  | 01:32:23
 lldb-x86_64-debian   | 01:03:46
 clang-tools-sphinx-docs  | 00:36:07
 lldb-x64-windows-ninja   | 00:36:04
 clang-armv7-linux-build-cache| 00:32:49
 sanitizer-windows| 00:19:35
 sanitizer-x86_64-linux-autoconf  | 00:13:37
(57 rows)


"Status change ratio" by active builder (percent of builds that changed the
builder status from greed to red or from red to green):
   buildername   | builds | changes
| status_change_ratio
-++-+
 clang-lld-x86_64-2stage | 16 |   6
|37.5
 clang-s390x-linux-multistage| 48 |  15
|31.3
 sanitizer-x86_64-linux  |122 |  32
|26.2
 clang-ppc64le-linux-multistage  | 39 |  10
|25.6
 clang-with-lto-ubuntu  

Buildbot numbers for the week of 11/03/2019 - 11/09/2019

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

Below are some buildbot numbers for the week of 11/03/2019 - 11/09/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
-+-
 llvm-clang-x86_64-expensive-checks-ubuntu   | 78:32:53
 lld-perf-testsuite  | 64:54:42
 clang-cuda-build| 24:50:28
 llvm-clang-x86_64-expensive-checks-win  | 24:37:07
 libcxx-libcxxabi-libunwind-x86_64-linux-ubuntu  | 24:31:12
 libcxx-libcxxabi-x86_64-linux-ubuntu-msan   | 24:30:41
 libcxx-libcxxabi-x86_64-linux-ubuntu-ubsan  | 24:30:40
 libcxx-libcxxabi-x86_64-linux-ubuntu-asan   | 24:29:57
 libcxx-libcxxabi-x86_64-linux-ubuntu-gcc-tot-latest-std | 24:29:10
 libcxx-libcxxabi-x86_64-linux-ubuntu-tsan   | 24:28:47
 libcxx-libcxxabi-x86_64-linux-ubuntu-cxx2a  | 24:08:39
 libcxx-libcxxabi-x86_64-linux-ubuntu-32bit  | 24:08:18
 libcxx-libcxxabi-libunwind-armv7-linux-noexceptions | 23:52:51
 libcxx-libcxxabi-libunwind-armv8-linux-noexceptions | 23:30:57
 libcxx-libcxxabi-libunwind-aarch64-linux-noexceptions   | 23:21:33
 libcxx-libcxxabi-libunwind-armv7-linux  | 23:18:37
 libcxx-libcxxabi-libunwind-aarch64-linux| 23:13:23
 libcxx-libcxxabi-libunwind-armv8-linux  | 22:48:04
 clang-lld-x86_64-2stage | 22:26:51
 sanitizer-x86_64-linux  | 20:11:45
 sanitizer-ppc64be-linux | 16:12:02
 clang-cmake-aarch64-full| 14:53:05
 sanitizer-x86_64-linux-fuzzer   | 13:45:15
 clang-with-lto-ubuntu   | 12:52:40
 sanitizer-ppc64le-linux | 12:38:02
 clang-cmake-aarch64-lld | 12:26:11
 clang-cmake-thumbv7-full-sh | 11:59:14
 aosp-O3-polly-before-vectorizer-unprofitable| 09:40:45
 clang-s390x-linux-multistage| 09:01:34
 sanitizer-x86_64-linux-bootstrap| 07:15:07
 sanitizer-x86_64-linux-bootstrap-ubsan  | 05:31:01
 clang-native-arm-lnt-perf   | 05:19:06
 sanitizer-x86_64-linux-bootstrap-msan   | 05:11:01
 clang-ppc64le-linux-multistage  | 04:53:20
 lld-x86_64-darwin13 | 04:45:31
 clang-cmake-armv8-lld   | 04:41:39
 clang-x64-windows-msvc  | 04:37:59
 ppc64le-lld-multistage-test | 04:26:13
 clang-cmake-aarch64-quick   | 04:12:37
 sanitizer-x86_64-linux-fast | 03:59:03
 clang-ppc64le-linux-lnt | 03:24:25
 clang-ppc64be-linux-multistage  | 03:13:01
 clang-with-thin-lto-ubuntu  | 03:03:05
 lldb-x86_64-debian  | 02:50:31
 clang-ppc64be-linux | 02:48:42
 clang-ppc64le-linux | 02:46:37
 llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast| 02:45:23
 reverse-iteration   | 02:43:44
 clang-ppc64be-linux-lnt | 02:30:27
 clang-cmake-armv7-full  | 02:17:39
 clang-s390x-linux-lnt   | 02:06:30
 clang-s390x-linux   | 02:04:19
 clang-cmake-aarch64-global-isel | 02:03:00
 clang-cmake-x86_64-avx2-linux   | 01:45:47
 sanitizer-x86_64-linux-android  | 01:42:11
 clang-hexagon-elf   | 01:21:58
 polly-arm-linux | 01:21:41
 clang-x86_64-linux-abi-test | 01:17:30
 clang-cmake-armv7-quick | 01:15:35
 lld-x86_64-ubuntu-fast  | 01:09:19
 clang-cmake-x86_64-sde-avx512-linux | 00:53:31
 lldb-x64-windows-ninja  | 00:52:15
 

LLVM buildmaster will be updated and restarted tonight

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

LLVM buildmaster will be updated and restarted after 8PM 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] D70583: clang/Modules: Rename CompilerInstance::ModuleManager, NFC

2019-11-22 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith closed this revision.
dexonsmith added a comment.

Pushed as 20d51b2f14ac4488f684f8fc57cb0ba718a6b91d 
.


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

https://reviews.llvm.org/D70583



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


[clang-tools-extra] 20d51b2 - clang/Modules: Rename CompilerInstance::ModuleManager, NFC

2019-11-22 Thread Duncan P. N. Exon Smith via cfe-commits

Author: Duncan P. N. Exon Smith
Date: 2019-11-22T18:24:11-08:00
New Revision: 20d51b2f14ac4488f684f8fc57cb0ba718a6b91d

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

LOG: clang/Modules: Rename CompilerInstance::ModuleManager, NFC

Fix the confusing naming of `CompilerInstance::ModuleManager`.  This is
actually an instance of `ASTReader`, which contains an instance of
`ModuleManager`.  I have to assume there was a point in the past where
they were just one class, but it's been pretty confusing for a while.  I
think it's time to fix it.

The new name is `TheASTReader`; the annoying `The` prefix is so that we
don't shadow the `ASTReader` class.  I tried out `ASTRdr` but that
seemed less clear, and this choice matches `ThePCHContainerOperations`
just a couple of declarations below.

Also rename `CompilerInstance::getModuleManager` and
`CompilerInstance::createModuleManager` to `*ASTReader`, making some
cases of `getModuleManager().getModuleManager()` a little more clear.

https://reviews.llvm.org/D70583

Added: 


Modified: 
clang-tools-extra/clang-tidy/ExpandModularHeadersPPCallbacks.cpp
clang/include/clang/Frontend/CompilerInstance.h
clang/lib/Frontend/ASTUnit.cpp
clang/lib/Frontend/CompilerInstance.cpp
clang/lib/Frontend/FrontendAction.cpp
clang/lib/Frontend/Rewrite/FrontendActions.cpp
clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/ExpandModularHeadersPPCallbacks.cpp 
b/clang-tools-extra/clang-tidy/ExpandModularHeadersPPCallbacks.cpp
index d200718c6af6..483177454527 100644
--- a/clang-tools-extra/clang-tidy/ExpandModularHeadersPPCallbacks.cpp
+++ b/clang-tools-extra/clang-tidy/ExpandModularHeadersPPCallbacks.cpp
@@ -106,7 +106,7 @@ void ExpandModularHeadersPPCallbacks::handleModuleFile(
 
   // Visit all the input files of this module and mark them to record their
   // contents later.
-  Compiler.getModuleManager()->visitInputFiles(
+  Compiler.getASTReader()->visitInputFiles(
   *MF, true, false,
   [this](const serialization::InputFile , bool /*IsSystem*/) {
 Recorder->addNecessaryFile(IF.getFile());
@@ -153,7 +153,7 @@ void ExpandModularHeadersPPCallbacks::InclusionDirective(
 const Module *Imported, SrcMgr::CharacteristicKind FileType) {
   if (Imported) {
 serialization::ModuleFile *MF =
-Compiler.getModuleManager()->getModuleManager().lookup(
+Compiler.getASTReader()->getModuleManager().lookup(
 Imported->getASTFile());
 handleModuleFile(MF);
   }

diff  --git a/clang/include/clang/Frontend/CompilerInstance.h 
b/clang/include/clang/Frontend/CompilerInstance.h
index cb3c39807ed7..e501dde465cc 100644
--- a/clang/include/clang/Frontend/CompilerInstance.h
+++ b/clang/include/clang/Frontend/CompilerInstance.h
@@ -116,7 +116,7 @@ class CompilerInstance : public ModuleLoader {
   std::unique_ptr FrontendTimer;
 
   /// The ASTReader, if one exists.
-  IntrusiveRefCntPtr ModuleManager;
+  IntrusiveRefCntPtr TheASTReader;
 
   /// The module dependency collector for crashdumps
   std::shared_ptr ModuleDepCollector;
@@ -514,7 +514,7 @@ class CompilerInstance : public ModuleLoader {
   /// @name Module Management
   /// {
 
-  IntrusiveRefCntPtr getModuleManager() const;
+  IntrusiveRefCntPtr getASTReader() const;
   void setModuleManager(IntrusiveRefCntPtr Reader);
 
   std::shared_ptr getModuleDepCollector() const;
@@ -782,7 +782,7 @@ class CompilerInstance : public ModuleLoader {
   }
 
   // Create module manager.
-  void createModuleManager();
+  void createASTReader();
 
   bool loadModuleFile(StringRef FileName);
 

diff  --git a/clang/lib/Frontend/ASTUnit.cpp b/clang/lib/Frontend/ASTUnit.cpp
index 20f71ed1c411..b3264952ff47 100644
--- a/clang/lib/Frontend/ASTUnit.cpp
+++ b/clang/lib/Frontend/ASTUnit.cpp
@@ -1457,7 +1457,7 @@ void 
ASTUnit::transferASTDataFromCompilerInstance(CompilerInstance ) {
   CI.setFileManager(nullptr);
   if (CI.hasTarget())
 Target = ();
-  Reader = CI.getModuleManager();
+  Reader = CI.getASTReader();
   HadModuleLoaderFatalFailure = CI.hadModuleLoaderFatalFailure();
 }
 

diff  --git a/clang/lib/Frontend/CompilerInstance.cpp 
b/clang/lib/Frontend/CompilerInstance.cpp
index 682aa54ac64e..b69dc4f854ff 100644
--- a/clang/lib/Frontend/CompilerInstance.cpp
+++ b/clang/lib/Frontend/CompilerInstance.cpp
@@ -75,7 +75,7 @@ void CompilerInstance::setInvocation(
 
 bool CompilerInstance::shouldBuildGlobalModuleIndex() const {
   return (BuildGlobalModuleIndex ||
-  (ModuleManager && ModuleManager->isGlobalIndexUnavailable() &&
+  (TheASTReader && TheASTReader->isGlobalIndexUnavailable() &&
getFrontendOpts().GenerateGlobalModuleIndex)) &&
  !ModuleBuildFailed;
 }
@@ 

[PATCH] D70556: clang/Modules: Refactor CompilerInstance::loadModule, NFC

2019-11-22 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith closed this revision.
dexonsmith marked an inline comment as done.
dexonsmith added a comment.

Pushed as 20d51b2f14ac4488f684f8fc57cb0ba718a6b91d.


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

https://reviews.llvm.org/D70556



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


[clang] 5cca622 - clang/Modules: Refactor CompilerInstance::loadModule, NFC

2019-11-22 Thread Duncan P. N. Exon Smith via cfe-commits

Author: Duncan P. N. Exon Smith
Date: 2019-11-22T18:23:47-08:00
New Revision: 5cca622310c10fdf6f921b6cce26f91d9f14c762

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

LOG: clang/Modules: Refactor CompilerInstance::loadModule, NFC

Refactor the logic on CompilerInstance::loadModule and a couple of
surrounding methods in order to clarify what's going on.

- Rename ModuleLoader::loadModuleFromSource to compileModuleFromSource
  and fix its documentation, since it never loads a module.  It just
  creates/compiles one.
- Rename one of the overloads of compileModuleImpl to compileModule,
  making it more obvious which one calls the other.
- Rename compileAndLoadModule to compileModuleAndReadAST.  This
  clarifies the relationship between this helper and its caller,
  CompilerInstance::loadModule (the old name implied the opposite
  relationship).  It also (correctly) indicates that more needs to be
  done to load the module than this function is responsible for.
- Split findOrCompileModuleAndReadAST out of loadModule.  Besides
  reducing nesting for this code thanks to early returns and the like,
  this refactor clarifies the logic in loadModule, particularly around
  calls to ModuleMap::cacheModuleLoad and
  ModuleMap::getCachedModuleLoad.  findOrCompileModuleAndReadAST also
  breaks early if the initial ReadAST call returns Missing or OutOfDate,
  allowing the last ditch call to compileModuleAndReadAST to come at the
  end of the function body.
- Additionally split out selectModuleSource, clarifying the logic
  due to early returns.
- Add ModuleLoadResult::isNormal and OtherUncachedFailure, so that
  loadModule knows whether to cache the result.
  OtherUncachedFailure was added to keep this patch NFC, but there's
  a chance that these cases were uncached by accident, through
  copy/paste/modify failures.  These should be audited as a
  follow-up (maybe we can eliminate this case).
- Do *not* lift the setting of `ModuleLoadFailed = true` to
  loadModule because there isn't a clear pattern for when it's set.
  This should be reconsidered in a follow-up, in case it would be
  correct to set `ModuleLoadFailed` whenever no module is returned
  and the result is either Normal or OtherUncachedFailure.
- Add some header documentation where it was missing, and fix it where
  it was wrong.

This should have no functionality change.

https://reviews.llvm.org/D70556

Added: 


Modified: 
clang/include/clang/Frontend/CompilerInstance.h
clang/include/clang/Lex/ModuleLoader.h
clang/lib/Frontend/CompilerInstance.cpp
clang/lib/Lex/Pragma.cpp

Removed: 




diff  --git a/clang/include/clang/Frontend/CompilerInstance.h 
b/clang/include/clang/Frontend/CompilerInstance.h
index 0ed5c9beac27..cb3c39807ed7 100644
--- a/clang/include/clang/Frontend/CompilerInstance.h
+++ b/clang/include/clang/Frontend/CompilerInstance.h
@@ -786,12 +786,30 @@ class CompilerInstance : public ModuleLoader {
 
   bool loadModuleFile(StringRef FileName);
 
+private:
+  /// Find a module, potentially compiling it, before reading its AST.  This is
+  /// the guts of loadModule.
+  ///
+  /// For prebuilt modules, the Module is not expected to exist in
+  /// HeaderSearch's ModuleMap.  If a ModuleFile by that name is in the
+  /// ModuleManager, then it will be loaded and looked up.
+  ///
+  /// For implicit modules, the Module is expected to already be in the
+  /// ModuleMap.  First attempt to load it from the given path on disk.  If 
that
+  /// fails, defer to compileModuleAndReadAST, which will first build and then
+  /// load it.
+  ModuleLoadResult findOrCompileModuleAndReadAST(StringRef ModuleName,
+ SourceLocation ImportLoc,
+ SourceLocation ModuleNameLoc,
+ bool IsInclusionDirective);
+
+public:
   ModuleLoadResult loadModule(SourceLocation ImportLoc, ModuleIdPath Path,
   Module::NameVisibilityKind Visibility,
   bool IsInclusionDirective) override;
 
-  void loadModuleFromSource(SourceLocation ImportLoc, StringRef ModuleName,
-StringRef Source) override;
+  void createModuleFromSource(SourceLocation ImportLoc, StringRef ModuleName,
+  StringRef Source) override;
 
   void makeModuleVisible(Module *Mod, Module::NameVisibilityKind Visibility,
  SourceLocation ImportLoc) override;

diff  --git a/clang/include/clang/Lex/ModuleLoader.h 
b/clang/include/clang/Lex/ModuleLoader.h
index c93501acb9c2..c1f7f068c0f1 100644
--- a/clang/include/clang/Lex/ModuleLoader.h
+++ 

[clang-tools-extra] 9f13a03 - clang-tidy: don't use an absolute path in a test

2019-11-22 Thread George Burgess IV via cfe-commits

Author: George Burgess IV
Date: 2019-11-22T18:13:18-08:00
New Revision: 9f13a032b6d7f720caf6511d0c9b1b6b7d2bbc67

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

LOG: clang-tidy: don't use an absolute path in a test

`run_clang_tidy` takes a regular expression to match against
compile_commands.json entries. If we pass "%t/test.cpp" and "%t" expands
to anything that includes chars that a regex treats specially, like '+',
this test starts failing.

Added: 


Modified: 
clang-tools-extra/test/clang-tidy/infrastructure/run-clang-tidy.cpp

Removed: 




diff  --git 
a/clang-tools-extra/test/clang-tidy/infrastructure/run-clang-tidy.cpp 
b/clang-tools-extra/test/clang-tidy/infrastructure/run-clang-tidy.cpp
index 31c4d681ebc9..0d0e41e022ae 100644
--- a/clang-tools-extra/test/clang-tidy/infrastructure/run-clang-tidy.cpp
+++ b/clang-tools-extra/test/clang-tidy/infrastructure/run-clang-tidy.cpp
@@ -9,7 +9,7 @@
 // RUN: echo "value:   '0'" >> %t/.clang-tidy
 // RUN: cp "%s" "%t/test.cpp"
 // RUN: cd "%t"
-// RUN: not %run_clang_tidy "%t/test.cpp"
+// RUN: not %run_clang_tidy "test.cpp"
 
 int main()
 {



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


[PATCH] D70625: [DebugInfo][BPF] Support to emit debugInfo for extern variables

2019-11-22 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

Seems to have a few things going on

- the title talks about global variables
- the description talks about extern types (guessing that's just a typo?)
- the patch itself seems to have code that's visiting more functions? ( 
processFuncPrototypes )
- & also I'd generally still prefer to see two patches for each piece of new 
debug info - first adding the functionality to LLVM, then second using that 
functionality in Clang (even though we're in the monorepo - these are still 
divisible patches that makes code review, revert, root cause analysis, etc, 
easier)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70625



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


[PATCH] D70583: clang/Modules: Rename CompilerInstance::ModuleManager, NFC

2019-11-22 Thread Bruno Cardoso Lopes via Phabricator via cfe-commits
bruno accepted this revision.
bruno added a comment.
This revision is now accepted and ready to land.

> I have to assume there was a point in the past where they were just one 
> class, but it's been pretty confusing for a while. I think it's time to fix 
> it.

Thanks!

LGTM


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

https://reviews.llvm.org/D70583



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


[PATCH] D70556: clang/Modules: Refactor CompilerInstance::loadModule, NFC

2019-11-22 Thread Bruno Cardoso Lopes via Phabricator via cfe-commits
bruno accepted this revision.
bruno added a comment.

Nice! LGTM


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

https://reviews.llvm.org/D70556



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


[PATCH] D70556: clang/Modules: Refactor CompilerInstance::loadModule, NFC

2019-11-22 Thread Michael Spencer via Phabricator via cfe-commits
Bigcheese accepted this revision.
Bigcheese added a comment.
This revision is now accepted and ready to land.

lgtm. Nice cleanup.


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

https://reviews.llvm.org/D70556



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


[clang] e956952 - DebugInfo: Flag Dwarf Version metadata for merging during LTO

2019-11-22 Thread David Blaikie via cfe-commits

Author: David Blaikie
Date: 2019-11-22T17:16:35-08:00
New Revision: e956952edec140d2475aa7c8cbe20fbdd3320634

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

LOG: DebugInfo: Flag Dwarf Version metadata for merging during LTO

When the Dwarf Version metadata was initially added (r184276) there was
no support for Module::Max - though the comment suggested that was the
desired behavior. The original behavior was Module::Warn which would
warn and then pick whichever version came first - which is pretty
arbitrary/luck-based if the consumer has some need for one version or
the other.

Now that the functionality's been added (r303590) this change updates
the implementation to match the desired goal.

The general logic here is - if you compile /some/ of your program with a
more recent DWARF version, you must have a consumer that can handle it,
so might as well use it for /everything/.

The only place where this might fall down is if you have a need to use
an old tool (supporting only the older DWARF version) for some subset of
your program. In which case now it'll all be the higher version. That
seems pretty narrow (& the inverse could happen too - you specifically
/need/ the higher DWARF version for some extra expressivity, etc, in
some part of the program)

Added: 


Modified: 
clang/lib/CodeGen/CodeGenModule.cpp
clang/test/CodeGen/dwarf-version.c

Removed: 




diff  --git a/clang/lib/CodeGen/CodeGenModule.cpp 
b/clang/lib/CodeGen/CodeGenModule.cpp
index 0e561693f20c..25268efff61b 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -470,9 +470,7 @@ void CodeGenModule::Release() {
   CodeGenOpts.NumRegisterParameters);
 
   if (CodeGenOpts.DwarfVersion) {
-// We actually want the latest version when there are conflicts.
-// We can change from Warning to Latest if such mode is supported.
-getModule().addModuleFlag(llvm::Module::Warning, "Dwarf Version",
+getModule().addModuleFlag(llvm::Module::Max, "Dwarf Version",
   CodeGenOpts.DwarfVersion);
   }
   if (CodeGenOpts.EmitCodeView) {

diff  --git a/clang/test/CodeGen/dwarf-version.c 
b/clang/test/CodeGen/dwarf-version.c
index 10add21d88dd..87143ee13118 100644
--- a/clang/test/CodeGen/dwarf-version.c
+++ b/clang/test/CodeGen/dwarf-version.c
@@ -38,10 +38,10 @@ int main (void) {
 
 // NOCODEVIEW-NOT: !"CodeView"
 
-// VER2: !{i32 2, !"Dwarf Version", i32 2}
-// VER3: !{i32 2, !"Dwarf Version", i32 3}
-// VER4: !{i32 2, !"Dwarf Version", i32 4}
-// VER5: !{i32 2, !"Dwarf Version", i32 5}
+// VER2: !{i32 7, !"Dwarf Version", i32 2}
+// VER3: !{i32 7, !"Dwarf Version", i32 3}
+// VER4: !{i32 7, !"Dwarf Version", i32 4}
+// VER5: !{i32 7, !"Dwarf Version", i32 5}
 
 // NODWARF-NOT: !"Dwarf Version"
 // CODEVIEW: !{i32 2, !"CodeView", i32 1}



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


Re: [PATCH] D69897: Add #pragma clang loop vectorize_assume_alignment(n)

2019-11-22 Thread HAPPY Mahto via cfe-commits
Hello Michael, A very good Morning to you.

On Wed, Nov 20, 2019 at 10:58 PM Michael Kruse  wrote:

> Am Mi., 20. Nov. 2019 um 10:21 Uhr schrieb HAPPY Mahto
> :
> >> #pragma clang loop vectorize_assume_alignment(32)
> >> for(int i = 0;i < n; i++){
> >> a[i] = b[i] + i*i;
> >> }
> >
> >  for this all-access inside the loop will be aligned to 32bit,
> > ex  IR
> >>
> >> for.cond: ; preds = %for.inc,
> %entry
> >>   %5 = load i32, i32* %i, align 32, !llvm.access.group !2
> >>   %6 = load i32, i32* %n, align 32, !llvm.access.group !2
> >>   %cmp = icmp slt i32 %5, %6
> >>   br i1 %cmp, label %for.body, label %for.end
> >>
> >> for.body: ; preds = %for.cond
> >>   %7 = load i32, i32* %i, align 32, !llvm.access.group !2
> >>   %8 = load i32, i32* %i, align 32, !llvm.access.group !2
> >>   %idxprom = sext i32 %8 to i64
> >>   %arrayidx = getelementptr inbounds i32, i32* %vla1, i64 %idxprom
> >>   store i32 %7, i32* %arrayidx, align 32, !llvm.access.group !2
> >>   br label %for.inc
> >>
> >> for.inc:  ; preds = %for.body
> >>   %9 = load i32, i32* %i, align 32, !llvm.access.group !2
> >>   %inc = add nsw i32 %9, 1
> >>   store i32 %inc, i32* %i, align 32, !llvm.access.group !2
> >>   br label %for.cond, !llvm.loop !3
> >
> > You will not need to create pointers for every array(or operand you want
> to perform the operation on).
>
> IMHO it is better if the programmer has to. It is not always obvious
> which arrays are used in the loop. Also, the information can be used
> by other optimzations that the vectorizer.
>
>  We wrote this pragma in by keeping in mind that arrays inside the
important loops are used for vectorization and it'll be good for them to be
in aligned manner.
for( int i = 0; i < n; i++){
  a[i] = b[i] + c[i];
  d[i] = e[i] + i*i;
}
If there are more than 4-5 arrays inside loop being used then it'll be
extra effort to define all of them as _builtin_assume_aligned, we're
thinking of letting that thing handled by pragma itself. It'll be very
helpful for us if other people from community can give their views on this.


> >>
> >> void mult(float* x, int size, float factor){
> >>   float* ax = (float*)__builtin_assume_aligned(x, 64);
> >>   for (int i = 0; i < size; ++i)
> >>  ax[i] *= factor;
> >> }
>
> https://godbolt.org/z/Fd6HMe
>
> > the alignment is assumed whereas in #pragma it is set to the number
> specified.
>
> Semantically, it is the same.
>
> I wonder how you expect the assembly output to change? The
> __builtin_assume_aligned, will be picked up by the backend and result
> in movaps to be used instead of movups.
>
>

> > it'll be easier, and having a pragma for doing this will help as it's
> provided in OMP and intel compilers.
>
> This is a compiler-specific extension. It does not have an influence
> on what other compilers do. Even with clang, if you try to do
>
> #pragma clang loop vectorize_assume_alignment(32)
> #pragma omp simd
> for (int i = 0; i < size; ++i)
>
> clang will silently swallow the vectorize_assume_alignment.
>
>
> Michael
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D70627: [AST] Split out Attrs.h for table generated *Attr classes

2019-11-22 Thread Reid Kleckner via Phabricator via cfe-commits
rnk created this revision.
rnk added a reviewer: aaron.ballman.
Herald added subscribers: arphaman, mgrang, kosarev, jholewinski.
Herald added a reviewer: jdoerfert.
Herald added a project: clang.

Many AST headers require Attr to be complete, but do not need the
complete table generated list of attributes. Separate that into Attrs.h
from Attr.h, and include it where necessary.

-ftime-trace shows that including Attrs.h by itself takes 370ms to
parse, so separating it out is valuable.

After this change, 1706 files depend on Attr.h, but only 600 object
files depend on Attrs.h. This represents a potential savings of 409s CPU
time per build, but on my workstation, a local build only got faster by
2-3s overall (4m45s -> 4m42s).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D70627

Files:
  clang-tools-extra/clang-tidy/bugprone/VirtualNearMissCheck.cpp
  clang-tools-extra/clang-tidy/hicpp/NoAssemblerCheck.cpp
  clang-tools-extra/clang-tidy/modernize/UseOverrideCheck.cpp
  clang/include/clang/AST/Attr.h
  clang/include/clang/AST/AttrVisitor.h
  clang/include/clang/AST/Attrs.h
  clang/include/clang/AST/RecursiveASTVisitor.h
  clang/include/clang/ASTMatchers/ASTMatchers.h
  clang/include/clang/Sema/Initialization.h
  clang/include/clang/Sema/Sema.h
  clang/include/clang/StaticAnalyzer/Checkers/SValExplainer.h
  clang/lib/AST/AttrImpl.cpp
  clang/lib/AST/CommentSema.cpp
  clang/lib/AST/Decl.cpp
  clang/lib/AST/DeclBase.cpp
  clang/lib/AST/DeclCXX.cpp
  clang/lib/AST/DeclObjC.cpp
  clang/lib/AST/DeclPrinter.cpp
  clang/lib/AST/Expr.cpp
  clang/lib/AST/ExprCXX.cpp
  clang/lib/AST/ExprConstant.cpp
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/AST/Mangle.cpp
  clang/lib/AST/MicrosoftCXXABI.cpp
  clang/lib/AST/MicrosoftMangle.cpp
  clang/lib/AST/RecordLayoutBuilder.cpp
  clang/lib/AST/Type.cpp
  clang/lib/AST/TypeLoc.cpp
  clang/lib/Analysis/CFG.cpp
  clang/lib/Analysis/Consumed.cpp
  clang/lib/Analysis/RetainSummaryManager.cpp
  clang/lib/Analysis/ThreadSafety.cpp
  clang/lib/Analysis/ThreadSafetyCommon.cpp
  clang/lib/Analysis/UninitializedValues.cpp
  clang/lib/CodeGen/CGBlocks.cpp
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/CodeGen/CGCXX.cpp
  clang/lib/CodeGen/CGCXXABI.cpp
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/CodeGen/CGClass.cpp
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/CodeGen/CGDecl.cpp
  clang/lib/CodeGen/CGDeclCXX.cpp
  clang/lib/CodeGen/CGExpr.cpp
  clang/lib/CodeGen/CGExprAgg.cpp
  clang/lib/CodeGen/CGExprConstant.cpp
  clang/lib/CodeGen/CGExprScalar.cpp
  clang/lib/CodeGen/CGLoopInfo.cpp
  clang/lib/CodeGen/CGObjC.cpp
  clang/lib/CodeGen/CGObjCGNU.cpp
  clang/lib/CodeGen/CGObjCMac.cpp
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
  clang/lib/CodeGen/CGRecordLayoutBuilder.cpp
  clang/lib/CodeGen/CGStmt.cpp
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/lib/CodeGen/CGVTables.cpp
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/CodeGen/CodeGenModule.h
  clang/lib/CodeGen/CodeGenTBAA.cpp
  clang/lib/CodeGen/ItaniumCXXABI.cpp
  clang/lib/CodeGen/MicrosoftCXXABI.cpp
  clang/lib/CodeGen/SanitizerMetadata.cpp
  clang/lib/CodeGen/TargetInfo.cpp
  clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp
  clang/lib/Frontend/Rewrite/RewriteObjC.cpp
  clang/lib/Index/CommentToXML.cpp
  clang/lib/Index/IndexDecl.cpp
  clang/lib/Index/IndexSymbol.cpp
  clang/lib/Index/IndexingContext.cpp
  clang/lib/Index/USRGeneration.cpp
  clang/lib/Serialization/ASTReaderDecl.cpp
  clang/lib/Serialization/ASTWriterDecl.cpp
  clang/lib/StaticAnalyzer/Checkers/CheckObjCDealloc.cpp
  clang/lib/StaticAnalyzer/Checkers/DirectIvarAssignment.cpp
  clang/lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/InterCheckerAPI.h
  clang/lib/StaticAnalyzer/Checkers/IvarInvalidationChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/MIGChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/MacOSXAPIChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/MoveChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/NoReturnFunctionChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/NonNullParamChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/ObjCUnusedIVarsChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp
  
clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.cpp
  clang/lib/StaticAnalyzer/Checkers/UndefCapturedBlockVarChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/VirtualCallChecker.cpp
  clang/lib/StaticAnalyzer/Core/CallEvent.cpp
  clang/lib/StaticAnalyzer/Core/MemRegion.cpp
  clang/lib/StaticAnalyzer/Core/RegionStore.cpp
  clang/tools/libclang/CIndex.cpp
  clang/tools/libclang/CXIndexDataConsumer.cpp

Index: clang/tools/libclang/CXIndexDataConsumer.cpp
===
--- clang/tools/libclang/CXIndexDataConsumer.cpp
+++ 

[clang] 019779d - Remove needless Attr.h include from DeclCXX.h, NFC

2019-11-22 Thread Reid Kleckner via cfe-commits

Author: Reid Kleckner
Date: 2019-11-22T16:16:10-08:00
New Revision: 019779dadfd7c98aedf0072d604ace295be6fa62

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

LOG: Remove needless Attr.h include from DeclCXX.h, NFC

This actually has no impact on the build, because TypeLoc.h includes
Attr.h. However, DeclCXX.h has no need of it, so go ahead and remove it.
The final step in this patch series is to split Attr.h and Attrs.h.

Added: 


Modified: 
clang/include/clang/AST/DeclCXX.h

Removed: 




diff  --git a/clang/include/clang/AST/DeclCXX.h 
b/clang/include/clang/AST/DeclCXX.h
index 4960eccbd520..63d67bd3f55b 100644
--- a/clang/include/clang/AST/DeclCXX.h
+++ b/clang/include/clang/AST/DeclCXX.h
@@ -17,7 +17,6 @@
 
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/ASTUnresolvedSet.h"
-#include "clang/AST/Attr.h"
 #include "clang/AST/Decl.h"
 #include "clang/AST/DeclBase.h"
 #include "clang/AST/DeclarationName.h"



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


[clang] a9cc64e - Separate the MS inheritance model enum from the attribute, NFC

2019-11-22 Thread Reid Kleckner via cfe-commits

Author: Reid Kleckner
Date: 2019-11-22T16:06:30-08:00
New Revision: a9cc64e50e64e76151679780f0ace11b48eadd44

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

LOG: Separate the MS inheritance model enum from the attribute, NFC

This avoids the need to include Attr.h in DeclCXX.h for a four-value
enum. Removing the include will be done separately, since it is large
and risky change.

Added: 


Modified: 
clang/include/clang/AST/CXXInheritance.h
clang/include/clang/AST/DeclCXX.h
clang/include/clang/Basic/Attr.td
clang/include/clang/Basic/Specifiers.h
clang/include/clang/Sema/Sema.h
clang/lib/AST/MicrosoftCXXABI.cpp
clang/lib/AST/MicrosoftMangle.cpp
clang/lib/CodeGen/CGDebugInfo.cpp
clang/lib/CodeGen/MicrosoftCXXABI.cpp
clang/lib/Sema/SemaDecl.cpp
clang/lib/Sema/SemaDeclAttr.cpp
clang/lib/Sema/SemaType.cpp

Removed: 




diff  --git a/clang/include/clang/AST/CXXInheritance.h 
b/clang/include/clang/AST/CXXInheritance.h
index bb2ad9c64d3b..f223c1f2f4f0 100644
--- a/clang/include/clang/AST/CXXInheritance.h
+++ b/clang/include/clang/AST/CXXInheritance.h
@@ -372,6 +372,30 @@ class CXXFinalOverriderMap
 class CXXIndirectPrimaryBaseSet
   : public llvm::SmallSet {};
 
+inline bool
+inheritanceModelHasVBPtrOffsetField(MSInheritanceModel Inheritance) {
+  return Inheritance == MSInheritanceModel::Unspecified;
+}
+
+// Only member pointers to functions need a this adjustment, since it can be
+// combined with the field offset for data pointers.
+inline bool inheritanceModelHasNVOffsetField(bool IsMemberFunction,
+ MSInheritanceModel Inheritance) {
+  return IsMemberFunction && Inheritance >= MSInheritanceModel::Multiple;
+}
+
+inline bool
+inheritanceModelHasVBTableOffsetField(MSInheritanceModel Inheritance) {
+  return Inheritance >= MSInheritanceModel::Virtual;
+}
+
+inline bool inheritanceModelHasOnlyOneField(bool IsMemberFunction,
+MSInheritanceModel Inheritance) {
+  if (IsMemberFunction)
+return Inheritance <= MSInheritanceModel::Single;
+  return Inheritance <= MSInheritanceModel::Multiple;
+}
+
 } // namespace clang
 
 #endif // LLVM_CLANG_AST_CXXINHERITANCE_H

diff  --git a/clang/include/clang/AST/DeclCXX.h 
b/clang/include/clang/AST/DeclCXX.h
index e7845adc9613..4960eccbd520 100644
--- a/clang/include/clang/AST/DeclCXX.h
+++ b/clang/include/clang/AST/DeclCXX.h
@@ -1736,10 +1736,10 @@ class CXXRecordDecl : public RecordDecl {
   }
 
   /// Returns the inheritance model used for this record.
-  MSInheritanceAttr::Spelling getMSInheritanceModel() const;
+  MSInheritanceModel getMSInheritanceModel() const;
 
   /// Calculate what the inheritance model would be for this class.
-  MSInheritanceAttr::Spelling calculateInheritanceModel() const;
+  MSInheritanceModel calculateInheritanceModel() const;
 
   /// In the Microsoft C++ ABI, use zero for the field offset of a null data
   /// member pointer if we can guarantee that zero is not a valid field offset,
@@ -1747,11 +1747,7 @@ class CXXRecordDecl : public RecordDecl {
   /// vfptr at offset zero, so we can use zero for null.  If there are multiple
   /// fields, we can use zero even if it is a valid field offset because
   /// null-ness testing will check the other fields.
-  bool nullFieldOffsetIsZero() const {
-return !MSInheritanceAttr::hasOnlyOneField(/*IsMemberFunction=*/false,
-   getMSInheritanceModel()) ||
-   (hasDefinition() && isPolymorphic());
-  }
+  bool nullFieldOffsetIsZero() const;
 
   /// Controls when vtordisps will be emitted if this record is used as a
   /// virtual base.

diff  --git a/clang/include/clang/Basic/Attr.td 
b/clang/include/clang/Basic/Attr.td
index 70df86126a11..5d9e5dd59596 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -2990,25 +2990,9 @@ def MSInheritance : InheritableAttr {
Keyword<"__virtual_inheritance">,
Keyword<"__unspecified_inheritance">];
   let AdditionalMembers = [{
-  static bool hasVBPtrOffsetField(Spelling Inheritance) {
-return Inheritance == Keyword_unspecified_inheritance;
-  }
-
-  // Only member pointers to functions need a this adjustment, since it can be
-  // combined with the field offset for data pointers.
-  static bool hasNVOffsetField(bool IsMemberFunction, Spelling Inheritance) {
-return IsMemberFunction && Inheritance >= Keyword_multiple_inheritance;
-  }
-
-  static bool hasVBTableOffsetField(Spelling Inheritance) {
-return Inheritance >= Keyword_virtual_inheritance;
-  }
-
-  static bool hasOnlyOneField(bool IsMemberFunction,
-  Spelling Inheritance) {
-   

[PATCH] D70625: [DebugInfo][BPF] Support to emit debugInfo for extern variables

2019-11-22 Thread Yonghong Song via Phabricator via cfe-commits
yonghong-song created this revision.
yonghong-song added reviewers: aprantl, dblaikie, RKSimon, ast.
yonghong-song added a project: debug-info.
Herald added subscribers: llvm-commits, cfe-commits, ormris, hiraditya.
Herald added projects: clang, LLVM.

extern variable usage in BPF is different from traditional
pure user space application. Recent discussion in linux bpf 
mailing list has two use cases where debug info types are 
required to use extern variables:

- extern types are required to have a suitable interface in libbpf (bpf loader) 
to provide kernel config parameters to bpf programs. 
https://lore.kernel.org/bpf/CAEf4BzYCNo5GeVGMhp3fhysQ=_axAf=23ptwazs-yayafmx...@mail.gmail.com/T/#t
- extern types are required so kernel bpf verifier can verify program which 
uses external functions more precisely. This will make later link with actual 
external function no need to reverify. 
https://lore.kernel.org/bpf/87eez4odqp@toke.dk/T/#m8d5c3e87ffe7f2764e02d722cb0d8cbc136880ed

This patch added clang support to emit debuginfo for extern variables,
and bpf support to consume such info into BTF, which can then be used
by bpf loader.

A few more things need to do:

- currently, I added clang EmitGlobalDeclVariable() to emit debuginfo for 
extern variables. It might be possible to reuse existing EmitGlobalVariable(). 
Need double check.
- BPF is C only, so I only tested C. I am not sure whether adding other 
language support is necessary at this point.
- add clang test cases and a few more bpf backend tests.

But some early feedback will be great!


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D70625

Files:
  clang/include/clang/AST/ASTConsumer.h
  clang/include/clang/Basic/TargetInfo.h
  clang/include/clang/Sema/Sema.h
  clang/lib/Basic/Targets/BPF.h
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/CodeGen/CGDebugInfo.h
  clang/lib/CodeGen/CodeGenAction.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/CodeGen/CodeGenModule.h
  clang/lib/CodeGen/ModuleBuilder.cpp
  clang/lib/Sema/Sema.cpp
  clang/lib/Sema/SemaDecl.cpp
  llvm/include/llvm/IR/DIBuilder.h
  llvm/lib/IR/DIBuilder.cpp
  llvm/lib/IR/DebugInfo.cpp
  llvm/lib/Target/BPF/BTF.h
  llvm/lib/Target/BPF/BTFDebug.cpp
  llvm/lib/Target/BPF/BTFDebug.h
  llvm/test/CodeGen/BPF/BTF/extern-var-func.ll
  llvm/test/CodeGen/BPF/BTF/extern-var-section.ll
  llvm/test/CodeGen/BPF/BTF/extern-var-struct.ll
  llvm/unittests/Transforms/Utils/CloningTest.cpp

Index: llvm/unittests/Transforms/Utils/CloningTest.cpp
===
--- llvm/unittests/Transforms/Utils/CloningTest.cpp
+++ llvm/unittests/Transforms/Utils/CloningTest.cpp
@@ -764,7 +764,7 @@
 
 DBuilder.createGlobalVariableExpression(
 Subprogram, "unattached", "unattached", File, 1,
-DBuilder.createNullPtrType(), false, Expr);
+DBuilder.createNullPtrType(), false, true, Expr);
 
 auto *Entry = BasicBlock::Create(C, "", F);
 IBuilder.SetInsertPoint(Entry);
Index: llvm/test/CodeGen/BPF/BTF/extern-var-struct.ll
===
--- /dev/null
+++ llvm/test/CodeGen/BPF/BTF/extern-var-struct.ll
@@ -0,0 +1,101 @@
+; RUN: llc -march=bpfel -filetype=asm -o - %s | FileCheck -check-prefixes=CHECK %s
+; RUN: llc -march=bpfeb -filetype=asm -o - %s | FileCheck -check-prefixes=CHECK %s
+;
+; Source code:
+;   typedef struct t1 { int f1; } __t1;
+;   int test() { return global.f1; }
+; Compilation flag:
+;   clang -target bpf -O2 -g -S -emit-llvm test.c
+
+%struct.t1 = type { i32 }
+
+@global = external dso_local local_unnamed_addr global %struct.t1, align 4, !dbg !0
+
+; Function Attrs: norecurse nounwind readonly
+define dso_local i32 @test() local_unnamed_addr #0 !dbg !15 {
+entry:
+  %0 = load i32, i32* getelementptr inbounds (%struct.t1, %struct.t1* @global, i64 0, i32 0), align 4, !dbg !18, !tbaa !19
+  ret i32 %0, !dbg !24
+}
+
+; CHECK: .section.BTF,"",@progbits
+; CHECK-NEXT:.short  60319   # 0xeb9f
+; CHECK-NEXT:.byte   1
+; CHECK-NEXT:.byte   0
+; CHECK-NEXT:.long   24
+; CHECK-NEXT:.long   0
+; CHECK-NEXT:.long   92
+; CHECK-NEXT:.long   92
+; CHECK-NEXT:.long   73
+; CHECK-NEXT:.long   0   # BTF_KIND_FUNC_PROTO(id = 1)
+; CHECK-NEXT:.long   218103808   # 0xd00
+; CHECK-NEXT:.long   2
+; CHECK-NEXT:.long   1   # BTF_KIND_INT(id = 2)
+; CHECK-NEXT:.long   16777216# 0x100
+; CHECK-NEXT:.long   4
+; CHECK-NEXT:.long   16777248# 0x120
+; CHECK-NEXT:.long   5   # BTF_KIND_FUNC(id = 3)
+; CHECK-NEXT:.long   201326592   # 0xc00
+; CHECK-NEXT:.long   1
+; CHECK-NEXT:.long   55  # BTF_KIND_TYPEDEF(id = 4)
+; CHECK-NEXT:

[clang] 2692eb0 - Move vtordisp mode from Attr class to LangOptions.h, NFC

2019-11-22 Thread Reid Kleckner via cfe-commits

Author: Reid Kleckner
Date: 2019-11-22T15:47:46-08:00
New Revision: 2692eb0b86c8f7ae1299d2e032f2778bb6e0a224

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

LOG: Move vtordisp mode from Attr class to LangOptions.h, NFC

This removes one of the two uses of Attr.h in DeclCXX.h, reducing the
need to include Attr.h as widely. LangOptions is already very popular.

Added: 


Modified: 
clang/include/clang/AST/DeclCXX.h
clang/include/clang/Basic/Attr.td
clang/include/clang/Basic/LangOptions.def
clang/include/clang/Basic/LangOptions.h
clang/include/clang/Sema/Sema.h
clang/lib/AST/MicrosoftCXXABI.cpp
clang/lib/AST/RecordLayoutBuilder.cpp
clang/lib/Frontend/CompilerInvocation.cpp
clang/lib/Parse/ParsePragma.cpp
clang/lib/Sema/Sema.cpp
clang/lib/Sema/SemaAttr.cpp

Removed: 




diff  --git a/clang/include/clang/AST/DeclCXX.h 
b/clang/include/clang/AST/DeclCXX.h
index ce9f0467735d..e7845adc9613 100644
--- a/clang/include/clang/AST/DeclCXX.h
+++ b/clang/include/clang/AST/DeclCXX.h
@@ -1755,7 +1755,7 @@ class CXXRecordDecl : public RecordDecl {
 
   /// Controls when vtordisps will be emitted if this record is used as a
   /// virtual base.
-  MSVtorDispAttr::Mode getMSVtorDispMode() const;
+  MSVtorDispMode getMSVtorDispMode() const;
 
   /// Determine whether this lambda expression was known to be dependent
   /// at the time it was created, even if its context does not appear to be

diff  --git a/clang/include/clang/Basic/Attr.td 
b/clang/include/clang/Basic/Attr.td
index e155593760ff..70df86126a11 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -3021,13 +3021,7 @@ def MSVtorDisp : InheritableAttr {
   let SemaHandler = 0;
 
   let AdditionalMembers = [{
-  enum Mode {
-Never,
-ForVBaseOverride,
-ForVFTable
-  };
-
-  Mode getVtorDispMode() const { return Mode(vdm); }
+  MSVtorDispMode getVtorDispMode() const { return MSVtorDispMode(vdm); }
   }];
   let Documentation = [Undocumented];
 }

diff  --git a/clang/include/clang/Basic/LangOptions.def 
b/clang/include/clang/Basic/LangOptions.def
index 6ec55ded3c84..82bf379af909 100644
--- a/clang/include/clang/Basic/LangOptions.def
+++ b/clang/include/clang/Basic/LangOptions.def
@@ -304,7 +304,8 @@ BENIGN_LANGOPT(BracketDepth, 32, 256,
 BENIGN_LANGOPT(NumLargeByValueCopy, 32, 0,
 "if non-zero, warn about parameter or return Warn if parameter/return 
value is larger in bytes than this setting. 0 is no check.")
 VALUE_LANGOPT(MSCompatibilityVersion, 32, 0, "Microsoft Visual C/C++ Version")
-VALUE_LANGOPT(VtorDispMode, 2, 1, "How many vtordisps to insert")
+ENUM_LANGOPT(VtorDispMode, MSVtorDispMode, 2, MSVtorDispMode::ForVBaseOverride,
+ "How many vtordisps to insert")
 
 LANGOPT(ApplePragmaPack, 1, 0, "Apple gcc-compatible #pragma pack handling")
 

diff  --git a/clang/include/clang/Basic/LangOptions.h 
b/clang/include/clang/Basic/LangOptions.h
index befe2f19792c..95628280a4a0 100644
--- a/clang/include/clang/Basic/LangOptions.h
+++ b/clang/include/clang/Basic/LangOptions.h
@@ -44,6 +44,10 @@ class LangOptionsBase {
 #include "clang/Basic/LangOptions.def"
 };
 
+/// In the Microsoft ABI, this controls the placement of virtual displacement
+/// members used to implement virtual inheritance.
+enum class MSVtorDispMode { Never, ForVBaseOverride, ForVFTable };
+
 /// Keeps track of the various options that can be
 /// enabled, which controls the dialect of C or C++ that is accepted.
 class LangOptions : public LangOptionsBase {
@@ -91,6 +95,8 @@ class LangOptions : public LangOptionsBase {
 PPTMK_FullGeneralityVirtualInheritance
   };
 
+  using MSVtorDispMode = clang::MSVtorDispMode;
+
   enum DefaultCallingConvention {
 DCC_None,
 DCC_CDecl,

diff  --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 55e39a27e6c6..111c91088acc 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -518,7 +518,7 @@ class Sema final {
   ///structors
   /// 2: Always insert vtordisps to support RTTI on partially constructed
   ///objects
-  PragmaStack VtorDispStack;
+  PragmaStack VtorDispStack;
   // #pragma pack.
   // Sentinel to represent when the stack is set to mac68k alignment.
   static const unsigned kMac68kAlignmentSentinel = ~0U;
@@ -8960,7 +8960,7 @@ class Sema final {
   /// Called on well formed \#pragma vtordisp().
   void ActOnPragmaMSVtorDisp(PragmaMsStackAction Action,
  SourceLocation PragmaLoc,
- MSVtorDispAttr::Mode Value);
+ MSVtorDispMode Value);
 
   enum PragmaSectionKind {
 PSK_DataSeg,

diff  --git a/clang/lib/AST/MicrosoftCXXABI.cpp 

[clang] 6551ac7 - [Driver] Make -static-libgcc imply static libunwind

2019-11-22 Thread Josh Kunz via cfe-commits

Author: Josh Kunz
Date: 2019-11-22T15:33:13-08:00
New Revision: 6551ac7489fe070a2edcfac88f68c93321cba9a9

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

LOG: [Driver] Make -static-libgcc imply static libunwind

In the GNU toolchain, `-static-libgcc` implies that the unwindlib will
be linked statically. However, when `--unwindlib=libunwind`, this flag is
ignored, and a bare `-lunwind` is added to the linker args.  Unfortunately,
this means that if both `libunwind.so`, and `libunwind.a` are present
in the library path, `libunwind.so` will be chosen in all cases where
`-static` is not set.

This change makes `-static-libgcc` affect the `-l` flag produced by
`--unwindlib=libunwind`. After this patch, providing
`-static-libgcc --unwindlib=libunwind` will cause the driver to explicitly
emit `-l:libunwind.a` to statically link libunwind. For all other cases
it will emit `-l:libunwind.so` matching current behavior with a more
explicit link line.

https://reviews.llvm.org/D70416

Added: 


Modified: 
clang/lib/Driver/ToolChains/CommonArgs.cpp
clang/test/Driver/compiler-rt-unwind.c

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp 
b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index 58705a2aa933..37ec73468570 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -1209,7 +1209,10 @@ static void AddUnwindLibrary(const ToolChain , const 
Driver ,
 break;
   }
   case ToolChain::UNW_CompilerRT:
-CmdArgs.push_back("-lunwind");
+if (LGT == LibGccType::StaticLibGcc)
+  CmdArgs.push_back("-l:libunwind.a");
+else
+  CmdArgs.push_back("-l:libunwind.so");
 break;
   }
 

diff  --git a/clang/test/Driver/compiler-rt-unwind.c 
b/clang/test/Driver/compiler-rt-unwind.c
index 0ec067cbfc6d..652a48c6ad78 100644
--- a/clang/test/Driver/compiler-rt-unwind.c
+++ b/clang/test/Driver/compiler-rt-unwind.c
@@ -13,7 +13,15 @@
 // RUN: --gcc-toolchain="" \
 // RUN:   | FileCheck --check-prefix=RTLIB-GCC-UNWINDLIB-COMPILER-RT %s
 // RTLIB-GCC-UNWINDLIB-COMPILER-RT: "{{.*}}lgcc"
-// RTLIB-GCC-UNWINDLIB-COMPILER-RT: "{{.*}}lunwind"
+// RTLIB-GCC-UNWINDLIB-COMPILER-RT: "{{.*}}l:libunwind.so"
+//
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: --target=x86_64-unknown-linux -rtlib=libgcc --unwindlib=libunwind \
+// RUN: -static-libgcc \
+// RUN: --gcc-toolchain="" \
+// RUN:   | FileCheck --check-prefix=RTLIB-GCC-STATIC-UNWINDLIB-COMPILER-RT %s
+// RTLIB-GCC-STATIC-UNWINDLIB-COMPILER-RT: "{{.*}}lgcc"
+// RTLIB-GCC-STATIC-UNWINDLIB-COMPILER-RT: "{{.*}}l:libunwind.a"
 //
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1   \
 // RUN: --target=x86_64-unknown-linux -rtlib=compiler-rt \



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


[PATCH] D70624: [Diagnostics] Warn for comparison with string literals expanded from macro (PR44064)

2019-11-22 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 marked an inline comment as done.
xbolva00 added inline comments.



Comment at: clang/test/Sema/warn-stringcompare.c:4-6
+#define DELIM "/"
+#define NULL (void *)0
+

Current behaviour: https://godbolt.org/z/7nYH6N


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70624



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


[PATCH] D70624: [Diagnostics] Warn for comparison with string literals expanded from macro (PR44064)

2019-11-22 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 created this revision.
xbolva00 added a reviewer: aaron.ballman.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
xbolva00 marked an inline comment as done.
xbolva00 added inline comments.



Comment at: clang/test/Sema/warn-stringcompare.c:4-6
+#define DELIM "/"
+#define NULL (void *)0
+

Current behaviour: https://godbolt.org/z/7nYH6N


As noted in PR, we have a poor test coverage for this warning. I think macro 
support was just overlooked. GCC warns in these cases.
Clang missed a real bug in the code I am working with, GCC caught it.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D70624

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaExpr.cpp
  clang/test/Sema/exprs.c
  clang/test/Sema/warn-stringcompare.c

Index: clang/test/Sema/warn-stringcompare.c
===
--- /dev/null
+++ clang/test/Sema/warn-stringcompare.c
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -x c -fsyntax-only -verify %s
+// RUN: %clang_cc1 -x c++ -fsyntax-only -verify %s
+
+#define DELIM "/"
+#define NULL (void *)0
+
+void test(const char *d) {
+  if ("/" != d) // expected-warning {{result of comparison against a string literal is unspecified}}
+return;
+  if (d == "/") // expected-warning {{result of comparison against a string literal is unspecified}}
+return;
+  if ("/" != NULL)
+return;
+  if (NULL == "/")
+return;
+  if ("/" != DELIM) // expected-warning {{result of comparison against a string literal is unspecified}}
+return;
+  if (DELIM == "/") // expected-warning {{result of comparison against a string literal is unspecified}}
+return;
+}
Index: clang/test/Sema/exprs.c
===
--- clang/test/Sema/exprs.c
+++ clang/test/Sema/exprs.c
@@ -119,7 +119,7 @@
 
 // PR3753
 int test12(const char *X) {
-  return X == "foo";  // expected-warning {{comparison against a string literal is unspecified (use strncmp instead)}}
+  return X == "foo";  // expected-warning {{comparison against a string literal is unspecified}}
 }
 
 int test12b(const char *X) {
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -10338,7 +10338,6 @@
   QualType RHSType = RHS->getType();
   if (LHSType->hasFloatingRepresentation() ||
   (LHSType->isBlockPointerType() && !BinaryOperator::isEqualityOp(Opc)) ||
-  LHS->getBeginLoc().isMacroID() || RHS->getBeginLoc().isMacroID() ||
   S.inTemplateInstantiation())
 return;
 
@@ -10366,45 +10365,51 @@
 AlwaysEqual, // std::strong_ordering::equal from operator<=>
   };
 
-  if (Expr::isSameComparisonOperand(LHS, RHS)) {
-unsigned Result;
-switch (Opc) {
-case BO_EQ: case BO_LE: case BO_GE:
-  Result = AlwaysTrue;
-  break;
-case BO_NE: case BO_LT: case BO_GT:
-  Result = AlwaysFalse;
-  break;
-case BO_Cmp:
-  Result = AlwaysEqual;
-  break;
-default:
-  Result = AlwaysConstant;
-  break;
-}
-S.DiagRuntimeBehavior(Loc, nullptr,
-  S.PDiag(diag::warn_comparison_always)
-  << 0 /*self-comparison*/
-  << Result);
-  } else if (checkForArray(LHSStripped) && checkForArray(RHSStripped)) {
-// What is it always going to evaluate to?
-unsigned Result;
-switch(Opc) {
-case BO_EQ: // e.g. array1 == array2
-  Result = AlwaysFalse;
-  break;
-case BO_NE: // e.g. array1 != array2
-  Result = AlwaysTrue;
-  break;
-default: // e.g. array1 <= array2
-  // The best we can say is 'a constant'
-  Result = AlwaysConstant;
-  break;
+  if (!LHS->getBeginLoc().isMacroID() && !RHS->getBeginLoc().isMacroID()) {
+if (Expr::isSameComparisonOperand(LHS, RHS)) {
+  unsigned Result;
+  switch (Opc) {
+  case BO_EQ:
+  case BO_LE:
+  case BO_GE:
+Result = AlwaysTrue;
+break;
+  case BO_NE:
+  case BO_LT:
+  case BO_GT:
+Result = AlwaysFalse;
+break;
+  case BO_Cmp:
+Result = AlwaysEqual;
+break;
+  default:
+Result = AlwaysConstant;
+break;
+  }
+  S.DiagRuntimeBehavior(Loc, nullptr,
+S.PDiag(diag::warn_comparison_always)
+<< 0 /*self-comparison*/
+<< Result);
+} else if (checkForArray(LHSStripped) && checkForArray(RHSStripped)) {
+  // What is it always going to evaluate to?
+  unsigned Result;
+  switch (Opc) {
+  case BO_EQ: // e.g. array1 == array2
+Result = AlwaysFalse;
+break;
+  case BO_NE: // e.g. array1 != array2
+Result = AlwaysTrue;
+break;
+  default: // e.g. array1 <= array2
+// The best we can 

[PATCH] D69740: [profile] Support counter relocation at runtime

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

In D69740#1752348 , @vsk wrote:

> I think this looks good overall. The only high-level item that seems to be 
> missing is Fuchsia testing -- are there any bots for this?


Not yet unfortunately, it's something I'm slowly working on but it'll take more 
time. I've been only testing this manually for now.

> I've left inline comments about fixing up some tests. Please also leave a 
> comment about Fuchsia/-runtime-counter-relocation in 
> clang/docs/SourceBasedCodeCoverage.rst.

Done.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69740



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


[PATCH] D69740: [profile] Support counter relocation at runtime

2019-11-22 Thread Petr Hosek via Phabricator via cfe-commits
phosek updated this revision to Diff 230733.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69740

Files:
  clang/docs/SourceBasedCodeCoverage.rst
  clang/lib/Driver/ToolChains/Darwin.cpp
  compiler-rt/lib/profile/CMakeLists.txt
  compiler-rt/lib/profile/InstrProfiling.h
  compiler-rt/lib/profile/InstrProfilingBiasVar.c
  compiler-rt/lib/profile/InstrProfilingBuffer.c
  compiler-rt/lib/profile/InstrProfilingFile.c
  compiler-rt/lib/profile/InstrProfilingInternal.h
  compiler-rt/lib/profile/InstrProfilingPlatformFuchsia.c
  llvm/include/llvm/ProfileData/InstrProf.h
  llvm/include/llvm/Transforms/Instrumentation/InstrProfiling.h
  llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp
  llvm/test/Instrumentation/InstrProfiling/runtime-counter-relocation.ll

Index: llvm/test/Instrumentation/InstrProfiling/runtime-counter-relocation.ll
===
--- /dev/null
+++ llvm/test/Instrumentation/InstrProfiling/runtime-counter-relocation.ll
@@ -0,0 +1,25 @@
+; RUN: opt < %s -S -instrprof | FileCheck %s
+; RUN: opt < %s -S -instrprof -runtime-counter-relocation | FileCheck -check-prefixes=RELOC %s
+
+target triple = "x86_64-unknown-linux-gnu"
+
+@__profn_foo = hidden constant [3 x i8] c"foo"
+; RELOC: @__llvm_profile_counter_bias = linkonce_odr global i64 0
+
+; CHECK-LABEL: define void @foo
+; CHECK-NEXT: %pgocount = load i64, i64* getelementptr inbounds ([1 x i64], [1 x i64]* @__profc_foo, i64 0, i64 0)
+; CHECK-NEXT: %1 = add i64 %pgocount, 1
+; CHECK-NEXT: store i64 %1, i64* getelementptr inbounds ([1 x i64], [1 x i64]* @__profc_foo, i64 0, i64 0)
+; RELOC-LABEL: define void @foo
+; RELOC-NEXT: %1 = load i64, i64* @__llvm_profile_counter_bias
+; RELOC-NEXT: %2 = add i64 ptrtoint ([1 x i64]* @__profc_foo to i64), %1
+; RELOC-NEXT: %3 = inttoptr i64 %2 to i64*
+; RELOC-NEXT: %pgocount = load i64, i64* %3
+; RELOC-NEXT: %4 = add i64 %pgocount, 1
+; RELOC-NEXT: store i64 %4, i64* %3
+define void @foo() {
+  call void @llvm.instrprof.increment(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @__profn_foo, i32 0, i32 0), i64 0, i32 1, i32 0)
+  ret void
+}
+
+declare void @llvm.instrprof.increment(i8*, i64, i32, i32)
Index: llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp
===
--- llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp
+++ llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp
@@ -83,6 +83,11 @@
 cl::desc("Rename counter variable of a comdat function based on cfg hash"),
 cl::init(true));
 
+cl::opt RuntimeCounterRelocation(
+"runtime-counter-relocation",
+cl::desc("Enable relocating counters at runtime."),
+cl::init(false));
+
 cl::opt ValueProfileStaticAlloc(
 "vp-static-alloc",
 cl::desc("Do static counter allocation for value profiler"),
@@ -408,6 +413,20 @@
 }
 
 bool InstrProfiling::lowerIntrinsics(Function *F) {
+  Value *Load = nullptr;
+  if (isRuntimeCounterRelocationEnabled()) {
+if (!F->empty()) {
+  IRBuilder<> Builder(>getEntryBlock().front());
+  Type *Int64Ty = Type::getInt64Ty(M->getContext());
+  GlobalVariable *Bias = M->getGlobalVariable(getInstrProfCounterBiasVarName());
+  if (!Bias)
+Bias = new GlobalVariable(*M, Int64Ty, false, GlobalValue::LinkOnceODRLinkage,
+  Constant::getNullValue(Int64Ty),
+  getInstrProfCounterBiasVarName());
+  Load = Builder.CreateLoad(Int64Ty, Bias);
+}
+  }
+
   bool MadeChange = false;
   PromotionCandidates.clear();
   for (BasicBlock  : *F) {
@@ -424,13 +443,23 @@
 }
   }
 
-  if (!MadeChange)
+  if (!MadeChange) {
+if (RuntimeCounterRelocation && Load)
+  Load->deleteValue();
 return false;
+  }
 
   promoteCounterLoadStores(F);
   return true;
 }
 
+bool InstrProfiling::isRuntimeCounterRelocationEnabled() const {
+  if (RuntimeCounterRelocation.getNumOccurrences() > 0)
+return RuntimeCounterRelocation;
+
+  return TT.isOSFuchsia();
+}
+
 bool InstrProfiling::isCounterPromotionEnabled() const {
   if (DoCounterPromotion.getNumOccurrences() > 0)
 return DoCounterPromotion;
@@ -641,6 +670,17 @@
   Value *Addr = Builder.CreateConstInBoundsGEP2_64(Counters->getValueType(),
Counters, 0, Index);
 
+  if (isRuntimeCounterRelocationEnabled()) {
+Type *Int64Ty = Type::getInt64Ty(M->getContext());
+Type *Int64PtrTy = Type::getInt64PtrTy(M->getContext());
+Function *Fn = Inc->getParent()->getParent();
+Instruction  = Fn->getEntryBlock().front();
+if (LoadInst *LI = dyn_cast()) {
+  auto *Add = Builder.CreateAdd(Builder.CreatePtrToInt(Addr, Int64Ty), LI);
+  Addr = Builder.CreateIntToPtr(Add, Int64PtrTy);
+}
+  }
+
   if (Options.Atomic || AtomicCounterUpdateAll) {
 Builder.CreateAtomicRMW(AtomicRMWInst::Add, Addr, 

[Diffusion] rG825235c140e7: Revert "[Sema] Use the canonical type in function isVector"

2019-11-22 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak added a subscriber: cfe-commits.

BRANCHES
  master

Users:
  ahatanak (Author)

https://reviews.llvm.org/rG825235c140e7



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


[PATCH] D69740: [profile] Support counter relocation at runtime

2019-11-22 Thread Petr Hosek via Phabricator via cfe-commits
phosek updated this revision to Diff 230727.
phosek marked 2 inline comments as done.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69740

Files:
  clang/lib/Driver/ToolChains/Darwin.cpp
  compiler-rt/lib/profile/CMakeLists.txt
  compiler-rt/lib/profile/InstrProfiling.h
  compiler-rt/lib/profile/InstrProfilingBiasVar.c
  compiler-rt/lib/profile/InstrProfilingBuffer.c
  compiler-rt/lib/profile/InstrProfilingFile.c
  compiler-rt/lib/profile/InstrProfilingInternal.h
  compiler-rt/lib/profile/InstrProfilingPlatformFuchsia.c
  llvm/include/llvm/ProfileData/InstrProf.h
  llvm/include/llvm/Transforms/Instrumentation/InstrProfiling.h
  llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp
  llvm/test/Instrumentation/InstrProfiling/runtime-counter-relocation.ll

Index: llvm/test/Instrumentation/InstrProfiling/runtime-counter-relocation.ll
===
--- /dev/null
+++ llvm/test/Instrumentation/InstrProfiling/runtime-counter-relocation.ll
@@ -0,0 +1,25 @@
+; RUN: opt < %s -S -instrprof | FileCheck %s
+; RUN: opt < %s -S -instrprof -runtime-counter-relocation | FileCheck -check-prefixes=RELOC %s
+
+target triple = "x86_64-unknown-linux-gnu"
+
+@__profn_foo = hidden constant [3 x i8] c"foo"
+; RELOC: @__llvm_profile_counter_bias = linkonce_odr global i64 0
+
+; CHECK-LABEL: define void @foo
+; CHECK-NEXT: %pgocount = load i64, i64* getelementptr inbounds ([1 x i64], [1 x i64]* @__profc_foo, i64 0, i64 0)
+; CHECK-NEXT: %1 = add i64 %pgocount, 1
+; CHECK-NEXT: store i64 %1, i64* getelementptr inbounds ([1 x i64], [1 x i64]* @__profc_foo, i64 0, i64 0)
+; RELOC-LABEL: define void @foo
+; RELOC-NEXT: %1 = load i64, i64* @__llvm_profile_counter_bias
+; RELOC-NEXT: %2 = add i64 ptrtoint ([1 x i64]* @__profc_foo to i64), %1
+; RELOC-NEXT: %3 = inttoptr i64 %2 to i64*
+; RELOC-NEXT: %pgocount = load i64, i64* %3
+; RELOC-NEXT: %4 = add i64 %pgocount, 1
+; RELOC-NEXT: store i64 %4, i64* %3
+define void @foo() {
+  call void @llvm.instrprof.increment(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @__profn_foo, i32 0, i32 0), i64 0, i32 1, i32 0)
+  ret void
+}
+
+declare void @llvm.instrprof.increment(i8*, i64, i32, i32)
Index: llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp
===
--- llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp
+++ llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp
@@ -83,6 +83,11 @@
 cl::desc("Rename counter variable of a comdat function based on cfg hash"),
 cl::init(true));
 
+cl::opt RuntimeCounterRelocation(
+"runtime-counter-relocation",
+cl::desc("Enable relocating counters at runtime."),
+cl::init(false));
+
 cl::opt ValueProfileStaticAlloc(
 "vp-static-alloc",
 cl::desc("Do static counter allocation for value profiler"),
@@ -408,6 +413,20 @@
 }
 
 bool InstrProfiling::lowerIntrinsics(Function *F) {
+  Value *Load = nullptr;
+  if (isRuntimeCounterRelocationEnabled()) {
+if (!F->empty()) {
+  IRBuilder<> Builder(>getEntryBlock().front());
+  Type *Int64Ty = Type::getInt64Ty(M->getContext());
+  GlobalVariable *Bias = M->getGlobalVariable(getInstrProfCounterBiasVarName());
+  if (!Bias)
+Bias = new GlobalVariable(*M, Int64Ty, false, GlobalValue::LinkOnceODRLinkage,
+  Constant::getNullValue(Int64Ty),
+  getInstrProfCounterBiasVarName());
+  Load = Builder.CreateLoad(Int64Ty, Bias);
+}
+  }
+
   bool MadeChange = false;
   PromotionCandidates.clear();
   for (BasicBlock  : *F) {
@@ -424,13 +443,23 @@
 }
   }
 
-  if (!MadeChange)
+  if (!MadeChange) {
+if (RuntimeCounterRelocation && Load)
+  Load->deleteValue();
 return false;
+  }
 
   promoteCounterLoadStores(F);
   return true;
 }
 
+bool InstrProfiling::isRuntimeCounterRelocationEnabled() const {
+  if (RuntimeCounterRelocation.getNumOccurrences() > 0)
+return RuntimeCounterRelocation;
+
+  return TT.isOSFuchsia();
+}
+
 bool InstrProfiling::isCounterPromotionEnabled() const {
   if (DoCounterPromotion.getNumOccurrences() > 0)
 return DoCounterPromotion;
@@ -641,6 +670,17 @@
   Value *Addr = Builder.CreateConstInBoundsGEP2_64(Counters->getValueType(),
Counters, 0, Index);
 
+  if (isRuntimeCounterRelocationEnabled()) {
+Type *Int64Ty = Type::getInt64Ty(M->getContext());
+Type *Int64PtrTy = Type::getInt64PtrTy(M->getContext());
+Function *Fn = Inc->getParent()->getParent();
+Instruction  = Fn->getEntryBlock().front();
+if (LoadInst *LI = dyn_cast()) {
+  auto *Add = Builder.CreateAdd(Builder.CreatePtrToInt(Addr, Int64Ty), LI);
+  Addr = Builder.CreateIntToPtr(Add, Int64PtrTy);
+}
+  }
+
   if (Options.Atomic || 

[PATCH] D70596: [analyzer][docs] NFC: Extend documentation for MallocOverflow checker

2019-11-22 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.

Fair enough!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70596



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


[clang] 825235c - Revert "[Sema] Use the canonical type in function isVector"

2019-11-22 Thread Akira Hatanaka via cfe-commits

Author: Akira Hatanaka
Date: 2019-11-22T13:48:39-08:00
New Revision: 825235c140e7747f686bd7902cb0f9af77590841

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

LOG: Revert "[Sema] Use the canonical type in function isVector"

This reverts commit a6150b48cea00ab31e9335cc73770327acc4cb3a.
The commit broke a few neon CodeGen tests.

Added: 


Modified: 
clang/lib/Sema/SemaExpr.cpp
clang/test/Sema/fp16vec-sema.c

Removed: 




diff  --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 63a189a102fc..3be8af1dd9e7 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -8155,7 +8155,7 @@ Sema::CheckAssignmentConstraints(SourceLocation Loc,
 /// type ElementType.
 static bool isVector(QualType QT, QualType ElementType) {
   if (const VectorType *VT = QT->getAs())
-return VT->getElementType().getCanonicalType() == ElementType;
+return VT->getElementType() == ElementType;
   return false;
 }
 

diff  --git a/clang/test/Sema/fp16vec-sema.c b/clang/test/Sema/fp16vec-sema.c
index 3d028224d22d..aefb5f86a14b 100644
--- a/clang/test/Sema/fp16vec-sema.c
+++ b/clang/test/Sema/fp16vec-sema.c
@@ -4,7 +4,6 @@ typedef __fp16 half4 __attribute__ ((vector_size (8)));
 typedef float float4 __attribute__ ((vector_size (16)));
 typedef short short4 __attribute__ ((vector_size (8)));
 typedef int int4 __attribute__ ((vector_size (16)));
-typedef __fp16 float16_t;
 
 half4 hv0, hv1;
 float4 fv0, fv1;
@@ -50,9 +49,3 @@ void testFP16Vec(int c) {
   hv0++; // expected-error{{cannot increment value of type}}
   ++hv0; // expected-error{{cannot increment value of type}}
 }
-
-void testTypeDef() {
-  __fp16 t0 __attribute__((vector_size (8)));
-  float16_t t1 __attribute__((vector_size (8)));
-  t1 = t0;
-}



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


[PATCH] D70342: [Diagnostics] Put "deprecated copy" warnings into -Wdeprecated-copy

2019-11-22 Thread Dávid Bolvanský via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG9353c5dd0664: [Diagnostics] Put deprecated copy 
warnings into -Wdeprecated-copy (authored by xbolva00).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70342

Files:
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/test/SemaCXX/deprecated-copy.cpp


Index: clang/test/SemaCXX/deprecated-copy.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/deprecated-copy.cpp
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -std=c++11 %s -Wdeprecated-copy -verify
+// RUN: %clang_cc1 -std=c++11 %s -Wdeprecated-copy-dtor -DDEPRECATED_COPY_DTOR 
-verify
+// RUN: %clang_cc1 -std=c++11 %s -Wextra -verify
+
+#ifdef DEPRECATED_COPY_DTOR
+struct A {
+  int *ptr;
+  ~A() { delete ptr; } // expected-warning {{definition of implicit copy 
constructor for 'A' is deprecated because it has a user-declared destructor}}
+};
+
+void foo() {
+  A a{};
+  A b = a; // expected-note {{implicit copy constructor for 'A' first required 
here}}
+}
+#else
+struct B {
+  B =(const B &); // expected-warning {{definition of implicit copy 
constructor for 'B' is deprecated because it has a user-declared copy 
assignment operator}}
+};
+
+void bar() {
+  B b1, b2(b1); // expected-note {{implicit copy constructor for 'B' first 
required here}}
+}
+#endif
Index: clang/lib/Sema/SemaDeclCXX.cpp
===
--- clang/lib/Sema/SemaDeclCXX.cpp
+++ clang/lib/Sema/SemaDeclCXX.cpp
@@ -12434,9 +12434,10 @@
 
   if (UserDeclaredOperation) {
 S.Diag(UserDeclaredOperation->getLocation(),
- diag::warn_deprecated_copy_operation)
-  << RD << /*copy assignment*/!isa(CopyOp)
-  << /*destructor*/isa(UserDeclaredOperation);
+   isa(UserDeclaredOperation)
+   ? diag::warn_deprecated_copy_dtor_operation
+   : diag::warn_deprecated_copy_operation)
+<< RD << /*copy assignment*/ !isa(CopyOp);
   }
 }
 
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -551,9 +551,13 @@
   "use using declarations instead">;
 def warn_deprecated_copy_operation : Warning<
   "definition of implicit copy %select{constructor|assignment operator}1 "
-  "for %0 is deprecated because it has a user-declared "
-  "%select{copy %select{assignment operator|constructor}1|destructor}2">,
-  InGroup, DefaultIgnore;
+  "for %0 is deprecated because it has a user-declared copy "
+  "%select{assignment operator|constructor}1">,
+  InGroup, DefaultIgnore;
+def warn_deprecated_copy_dtor_operation : Warning<
+  "definition of implicit copy %select{constructor|assignment operator}1 "
+  "for %0 is deprecated because it has a user-declared destructor">,
+  InGroup, DefaultIgnore;
 def warn_cxx17_compat_exception_spec_in_signature : Warning<
   "mangled name of %0 will change in C++17 due to non-throwing exception "
   "specification in function signature">, InGroup;
Index: clang/include/clang/Basic/DiagnosticGroups.td
===
--- clang/include/clang/Basic/DiagnosticGroups.td
+++ clang/include/clang/Basic/DiagnosticGroups.td
@@ -128,6 +128,8 @@
 
 def DeprecatedAttributes : DiagGroup<"deprecated-attributes">;
 def DeprecatedCommaSubscript : DiagGroup<"deprecated-comma-subscript">;
+def DeprecatedCopy : DiagGroup<"deprecated-copy">;
+def DeprecatedCopyDtor : DiagGroup<"deprecated-copy-dtor">;
 def DeprecatedDeclarations : DiagGroup<"deprecated-declarations">;
 def UnavailableDeclarations : DiagGroup<"unavailable-declarations">;
 def UnguardedAvailabilityNew : DiagGroup<"unguarded-availability-new">;
@@ -147,6 +149,8 @@
 // FIXME: Why is DeprecatedImplementations not in this group?
 def Deprecated : DiagGroup<"deprecated", [DeprecatedAttributes,
   DeprecatedCommaSubscript,
+  DeprecatedCopy,
+  DeprecatedCopyDtor,
   DeprecatedDeclarations,
   DeprecatedDynamicExceptionSpec,
   DeprecatedIncrementBool,
@@ -812,6 +816,7 @@
   ]>;
 
 def Extra : DiagGroup<"extra", [
+DeprecatedCopy,
 MissingFieldInitializers,
 IgnoredQualifiers,
 InitializerOverrides,


Index: clang/test/SemaCXX/deprecated-copy.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/deprecated-copy.cpp
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -std=c++11 %s -Wdeprecated-copy -verify
+// RUN: 

[PATCH] D70351: [clang][WIP][clang-scan-deps] Add an experimental C API.

2019-11-22 Thread Michael Spencer via Phabricator via cfe-commits
Bigcheese marked an inline comment as done.
Bigcheese added inline comments.



Comment at: clang/include/clang-c/Dependencies.h:146
+ */
+typedef struct CXOpaqueDependencyScannerWorker *CXDependencyScannerWorker;
+

kousikk wrote:
> It would be simpler if the clients didn't have to worry about the worker?
> As far as a user of this lib is concerned, they need to create a shared 
> cache, then call scanDeps() in some form with the shared cache and other 
> inputs.
> 
> Can we hide the worker inside the implementation? So essentially we create a 
> new worker for every invocation (that's assuming worker setup is cheap).
A lot of caching is per-worker. It would be pretty bad to spawn a new worker 
for every scan.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70351



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


[PATCH] D70615: Add an -fno-temp-file flag for compilation

2019-11-22 Thread Zachary Henkel via Phabricator via cfe-commits
zahen created this revision.
zahen added reviewers: rsmith, rnk, zturner.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Our build system does not handle randomly named files created during the build 
well.  We'd prefer to write compilation output directly without creating a 
temporary file.  Function parameters already existed to control this behavior 
but were not exposed all the way out to the command line.

I'm open to suggestions what kinds of tests could be added alongside the 
change.  Anecdotally, this code been running in internal production builds for 
months.

I do not have commit access so I will need someone else to submit the patch 
once it's accepted.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D70615

Files:
  clang/include/clang/Driver/Options.td
  clang/include/clang/Frontend/FrontendOptions.h
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInstance.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Frontend/FrontendActions.cpp


Index: clang/lib/Frontend/FrontendActions.cpp
===
--- clang/lib/Frontend/FrontendActions.cpp
+++ clang/lib/Frontend/FrontendActions.cpp
@@ -140,7 +140,7 @@
   std::unique_ptr OS =
   CI.createOutputFile(CI.getFrontendOpts().OutputFile, /*Binary=*/true,
   /*RemoveFileOnSignal=*/false, InFile,
-  /*Extension=*/"", /*UseTemporary=*/true);
+  /*Extension=*/"", CI.getFrontendOpts().UseTemporary);
   if (!OS)
 return nullptr;
 
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -1886,6 +1886,7 @@
   Opts.ModulesEmbedFiles = Args.getAllArgValues(OPT_fmodules_embed_file_EQ);
   Opts.ModulesEmbedAllFiles = Args.hasArg(OPT_fmodules_embed_all_files);
   Opts.IncludeTimestamps = !Args.hasArg(OPT_fno_pch_timestamp);
+  Opts.UseTemporary = !Args.hasArg(OPT_fno_temp_file); 
 
   Opts.CodeCompleteOpts.IncludeMacros
 = Args.hasArg(OPT_code_completion_macros);
Index: clang/lib/Frontend/CompilerInstance.cpp
===
--- clang/lib/Frontend/CompilerInstance.cpp
+++ clang/lib/Frontend/CompilerInstance.cpp
@@ -672,7 +672,7 @@
   StringRef Extension) {
   return createOutputFile(getFrontendOpts().OutputFile, Binary,
   /*RemoveFileOnSignal=*/true, InFile, Extension,
-  /*UseTemporary=*/true);
+  getFrontendOpts().UseTemporary );
 }
 
 std::unique_ptr CompilerInstance::createNullOutputFile() {
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -4688,6 +4688,7 @@
   Args.AddLastArg(CmdArgs, options::OPT_ftime_trace_granularity_EQ);
   Args.AddLastArg(CmdArgs, options::OPT_ftrapv);
   Args.AddLastArg(CmdArgs, options::OPT_malign_double);
+  Args.AddLastArg(CmdArgs, options::OPT_fno_temp_file);
 
   if (Arg *A = Args.getLastArg(options::OPT_ftrapv_handler_EQ)) {
 CmdArgs.push_back("-ftrapv-handler");
Index: clang/include/clang/Frontend/FrontendOptions.h
===
--- clang/include/clang/Frontend/FrontendOptions.h
+++ clang/include/clang/Frontend/FrontendOptions.h
@@ -294,6 +294,9 @@
   /// Whether timestamps should be written to the produced PCH file.
   unsigned IncludeTimestamps : 1;
 
+  /// Should a temporary file be used during compilation.
+  unsigned UseTemporary : 1;
+
   CodeCompleteOptions CodeCompleteOpts;
 
   /// Specifies the output format of the AST.
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -1559,6 +1559,8 @@
 def fno_strict_vtable_pointers: Flag<["-"], "fno-strict-vtable-pointers">,
   Group;
 def fno_strict_overflow : Flag<["-"], "fno-strict-overflow">, Group;
+def fno_temp_file : Flag<["-"], "fno-temp-file">, Group,
+  Flags<[CC1Option, CoreOption]>, HelpText<"Do not create a temp file during 
compilation">;
 def fno_threadsafe_statics : Flag<["-"], "fno-threadsafe-statics">, 
Group,
   Flags<[CC1Option]>, HelpText<"Do not emit code to make initialization of 
local statics thread safe">;
 def fno_use_cxa_atexit : Flag<["-"], "fno-use-cxa-atexit">, Group, 
Flags<[CC1Option]>,


Index: clang/lib/Frontend/FrontendActions.cpp
===
--- clang/lib/Frontend/FrontendActions.cpp
+++ clang/lib/Frontend/FrontendActions.cpp
@@ -140,7 +140,7 @@
   std::unique_ptr OS =
   

[PATCH] D70571: [Coverage] Emit a gap region to cover switch bodies

2019-11-22 Thread Vedant Kumar via Phabricator via cfe-commits
vsk updated this revision to Diff 230714.
vsk added a comment.

- Add some documentation about clang internals.


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

https://reviews.llvm.org/D70571

Files:
  clang/docs/SourceBasedCodeCoverage.rst
  clang/lib/CodeGen/CoverageMappingGen.cpp
  clang/test/CoverageMapping/switch.cpp
  clang/test/CoverageMapping/switchmacro.c

Index: clang/test/CoverageMapping/switchmacro.c
===
--- clang/test/CoverageMapping/switchmacro.c
+++ clang/test/CoverageMapping/switchmacro.c
@@ -4,7 +4,7 @@
 
 // CHECK: foo
 int foo(int i) { // CHECK-NEXT: File 0, [[@LINE]]:16 -> {{[0-9]+}}:2 = #0
-  switch (i) {
+  switch (i) {   // CHECK-NEXT: Gap,File 0, [[@LINE]]:14 -> {{[0-9]+}}:11 = 0
   default:   // CHECK-NEXT: File 0, [[@LINE]]:3 -> {{[0-9]+}}:11 = #2
 if (i == 1)  // CHECK-NEXT: File 0, [[@LINE]]:9 -> [[@LINE]]:15 = #2
   return 0;  // CHECK: File 0, [[@LINE]]:7 -> [[@LINE]]:15 = #3
Index: clang/test/CoverageMapping/switch.cpp
===
--- clang/test/CoverageMapping/switch.cpp
+++ clang/test/CoverageMapping/switch.cpp
@@ -2,11 +2,11 @@
 
 // CHECK: foo
 void foo(int i) {   // CHECK-NEXT: File 0, [[@LINE]]:17 -> [[@LINE+8]]:2 = #0
-  switch(i) {
+  switch(i) {   // CHECK-NEXT: Gap,File 0, [[@LINE]]:13 -> [[@LINE+4]]:10 = 0
   case 1:   // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+1]]:11 = #2
 return;
   case 2:   // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+1]]:10 = #3
-break;  // CHECK-NEXT: File 0, [[@LINE]]:10 -> [[@LINE+2]]:3 = #1
+break;  // CHECK-NEXT: Gap,File 0, [[@LINE]]:10 -> [[@LINE+2]]:3 = #1
   }
   int x = 0;// CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+1]]:2 = #1
 }
@@ -29,7 +29,7 @@
 nop();
 
   switch (i) {  // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+6]]:2 = #4
-nop();  // CHECK-NEXT: File 0, [[@LINE]]:5 -> [[@LINE+2]]:10 = 0
+nop();  // CHECK-NEXT: Gap,File 0, [[@LINE-1]]:14 -> [[@LINE+2]]:10 = 0
   case 1:   // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+1]]:10 = #7
 nop();
   }
@@ -47,7 +47,7 @@
 // CHECK-NEXT: main
 int main() {// CHECK-NEXT: File 0, [[@LINE]]:12 -> [[@LINE+35]]:2 = #0
   int i = 0;
-  switch(i) {
+  switch(i) {   // CHECK-NEXT: Gap,File 0, [[@LINE]]:13 -> [[@LINE+8]]:10 = 0
   case 0:   // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+2]]:10 = #2
 i = 1;
 break;
@@ -58,16 +58,16 @@
 break;  // CHECK-NEXT: File 0, [[@LINE]]:10 -> [[@LINE+2]]:3 = #1
   }
   switch(i) {   // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+23]]:2 = #1
-  case 0:   // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+2]]:10 = #6
-i = 1;
+  case 0:   // CHECK-NEXT: Gap,File 0, [[@LINE-1]]:13 -> [[@LINE+6]]:10 = 0
+i = 1;  // CHECK-NEXT: File 0, [[@LINE-1]]:3 -> [[@LINE+1]]:10 = #6
 break;
   case 1:   // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+3]]:10 = #7
 i = 2;
   default:  // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+1]]:10 = (#7 + #8)
 break;  // CHECK-NEXT: File 0, [[@LINE]]:10 -> [[@LINE+3]]:3 = #5
   }
-
-  switch(i) {   // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+13]]:2 = #5
+// CHECK-NEXT: File 0, [[@LINE+1]]:3 -> [[@LINE+14]]:2 = #5
+  switch(i) {   // CHECK-NEXT: Gap,File 0, [[@LINE]]:13 -> [[@LINE+6]]:11 = 0
   case 1:   // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+5]]:11 = #10
   case 2:   // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+4]]:11 = (#10 + #11)
 i = 11;
@@ -85,7 +85,7 @@
 // FIXME: End location for "case 1" shouldn't point at the end of the switch.
  // CHECK: fallthrough
 int fallthrough(int i) { // CHECK-NEXT: File 0, [[@LINE]]:24 -> [[@LINE+12]]:2 = #0
-  switch(i) {
+  switch(i) {   // CHECK-NEXT: Gap,File 0, [[@LINE]]:13 -> [[@LINE+9]]:10 = 0
   case 1:   // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+8]]:10 = #2
 i = 23;
   case 2:   // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+2]]:10 = (#2 + #3)
@@ -101,7 +101,7 @@
 void abort(void) __attribute((noreturn));
// CHECK: noret
 int noret(int x) { // CHECK-NEXT: File 0, [[@LINE]]:18 -> [[@LINE+9]]:2
-  switch (x) {
+  switch (x) { // CHECK-NEXT: Gap,File 0, [[@LINE]]:14 -> [[@LINE+6]]:14 = 0
   default: // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+1]]:12
 abort();
   case 1: // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+1]]:13
Index: clang/lib/CodeGen/CoverageMappingGen.cpp
===
--- clang/lib/CodeGen/CoverageMappingGen.cpp
+++ clang/lib/CodeGen/CoverageMappingGen.cpp
@@ -1114,8 +1114,8 @@
 // Make a region for the body of the switch.  If the body starts with
 // a case, that case 

[clang] a6150b4 - [Sema] Use the canonical type in function isVector

2019-11-22 Thread Akira Hatanaka via cfe-commits

Author: Akira Hatanaka
Date: 2019-11-22T12:57:24-08:00
New Revision: a6150b48cea00ab31e9335cc73770327acc4cb3a

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

LOG: [Sema] Use the canonical type in function isVector

This fixes an assertion in Sema::CreateBuiltinBinOp that fails when one
of the vector operand's element type is a typedef of __fp16.

rdar://problem/55983556

Added: 


Modified: 
clang/lib/Sema/SemaExpr.cpp
clang/test/Sema/fp16vec-sema.c

Removed: 




diff  --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 3be8af1dd9e7..63a189a102fc 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -8155,7 +8155,7 @@ Sema::CheckAssignmentConstraints(SourceLocation Loc,
 /// type ElementType.
 static bool isVector(QualType QT, QualType ElementType) {
   if (const VectorType *VT = QT->getAs())
-return VT->getElementType() == ElementType;
+return VT->getElementType().getCanonicalType() == ElementType;
   return false;
 }
 

diff  --git a/clang/test/Sema/fp16vec-sema.c b/clang/test/Sema/fp16vec-sema.c
index aefb5f86a14b..3d028224d22d 100644
--- a/clang/test/Sema/fp16vec-sema.c
+++ b/clang/test/Sema/fp16vec-sema.c
@@ -4,6 +4,7 @@ typedef __fp16 half4 __attribute__ ((vector_size (8)));
 typedef float float4 __attribute__ ((vector_size (16)));
 typedef short short4 __attribute__ ((vector_size (8)));
 typedef int int4 __attribute__ ((vector_size (16)));
+typedef __fp16 float16_t;
 
 half4 hv0, hv1;
 float4 fv0, fv1;
@@ -49,3 +50,9 @@ void testFP16Vec(int c) {
   hv0++; // expected-error{{cannot increment value of type}}
   ++hv0; // expected-error{{cannot increment value of type}}
 }
+
+void testTypeDef() {
+  __fp16 t0 __attribute__((vector_size (8)));
+  float16_t t1 __attribute__((vector_size (8)));
+  t1 = t0;
+}



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


[clang] 2b79563 - Fix typo to separate "-x" from warning flag.

2019-11-22 Thread Bill Wendling via cfe-commits

Author: Bill Wendling
Date: 2019-11-22T12:51:41-08:00
New Revision: 2b795637b9024d76e53cd303ad74ac02ba22da5b

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

LOG: Fix typo to separate "-x" from warning flag.

Added: 


Modified: 
clang/test/Sema/no-warn-missing-prototype.c

Removed: 




diff  --git a/clang/test/Sema/no-warn-missing-prototype.c 
b/clang/test/Sema/no-warn-missing-prototype.c
index 2361677a5f73..4dbc25755922 100644
--- a/clang/test/Sema/no-warn-missing-prototype.c
+++ b/clang/test/Sema/no-warn-missing-prototype.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -Wmissing-prototypes-x c -ffreestanding 
-verify %s
+// RUN: %clang_cc1 -fsyntax-only -Wmissing-prototypes -x c -ffreestanding 
-verify %s
 // RUN: %clang_cc1 -fsyntax-only -Wmissing-prototypes -x c++ -ffreestanding 
-verify %s
 // expected-no-diagnostics
 int main() {



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


[PATCH] D70588: Don't report "main" as missing a prototype in freestanding mode

2019-11-22 Thread Bill Wendling via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG9180f8a57436: Dont report main as missing 
a prototype in freestanding mode (authored by void).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70588

Files:
  clang/lib/Sema/SemaDecl.cpp
  clang/test/Sema/no-warn-missing-prototype.c


Index: clang/test/Sema/no-warn-missing-prototype.c
===
--- /dev/null
+++ clang/test/Sema/no-warn-missing-prototype.c
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -fsyntax-only -Wmissing-prototypes-x c -ffreestanding 
-verify %s
+// RUN: %clang_cc1 -fsyntax-only -Wmissing-prototypes -x c++ -ffreestanding 
-verify %s
+// expected-no-diagnostics
+int main() {
+  return 0;
+}
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -13319,8 +13319,10 @@
 return false;
 
   // Don't warn about 'main'.
-  if (FD->isMain())
-return false;
+  if (isa(FD->getDeclContext()->getRedeclContext()))
+if (IdentifierInfo *II = FD->getIdentifier())
+  if (II->isStr("main"))
+return false;
 
   // Don't warn about inline functions.
   if (FD->isInlined())


Index: clang/test/Sema/no-warn-missing-prototype.c
===
--- /dev/null
+++ clang/test/Sema/no-warn-missing-prototype.c
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -fsyntax-only -Wmissing-prototypes-x c -ffreestanding -verify %s
+// RUN: %clang_cc1 -fsyntax-only -Wmissing-prototypes -x c++ -ffreestanding -verify %s
+// expected-no-diagnostics
+int main() {
+  return 0;
+}
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -13319,8 +13319,10 @@
 return false;
 
   // Don't warn about 'main'.
-  if (FD->isMain())
-return false;
+  if (isa(FD->getDeclContext()->getRedeclContext()))
+if (IdentifierInfo *II = FD->getIdentifier())
+  if (II->isStr("main"))
+return false;
 
   // Don't warn about inline functions.
   if (FD->isInlined())
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 9180f8a - Don't report "main" as missing a prototype in freestanding mode

2019-11-22 Thread Bill Wendling via cfe-commits

Author: Bill Wendling
Date: 2019-11-22T12:35:43-08:00
New Revision: 9180f8a57436da0ce91d9d4885702a10f89571bc

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

LOG: Don't report "main" as missing a prototype in freestanding mode

Summary:
A user may want to use freestanding mode with the standard "main" entry
point. It's not useful to warn about a missing prototype as it's not
typical to have a prototype for "main".

Reviewers: efriedma, aaron.ballman

Reviewed By: aaron.ballman

Subscribers: aaron.ballman, cfe-commits

Tags: #clang

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

Added: 
clang/test/Sema/no-warn-missing-prototype.c

Modified: 
clang/lib/Sema/SemaDecl.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 6d857e832c4b..47c05d5d2eaa 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -13319,8 +13319,10 @@ ShouldWarnAboutMissingPrototype(const FunctionDecl *FD,
 return false;
 
   // Don't warn about 'main'.
-  if (FD->isMain())
-return false;
+  if (isa(FD->getDeclContext()->getRedeclContext()))
+if (IdentifierInfo *II = FD->getIdentifier())
+  if (II->isStr("main"))
+return false;
 
   // Don't warn about inline functions.
   if (FD->isInlined())

diff  --git a/clang/test/Sema/no-warn-missing-prototype.c 
b/clang/test/Sema/no-warn-missing-prototype.c
new file mode 100644
index ..2361677a5f73
--- /dev/null
+++ b/clang/test/Sema/no-warn-missing-prototype.c
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -fsyntax-only -Wmissing-prototypes-x c -ffreestanding 
-verify %s
+// RUN: %clang_cc1 -fsyntax-only -Wmissing-prototypes -x c++ -ffreestanding 
-verify %s
+// expected-no-diagnostics
+int main() {
+  return 0;
+}



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


[PATCH] D70071: [ConstExprPreter] Removed the flag forcing the use of the interpreter

2019-11-22 Thread Michael Spencer via Phabricator via cfe-commits
Bigcheese accepted this revision.
Bigcheese 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/D70071/new/

https://reviews.llvm.org/D70071



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


[PATCH] D70608: [OPENMP] [DOCS] correct status for use_device_addr clause

2019-11-22 Thread Kelvin Li via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG0c7a1c0cfc2a: [OPENMP] [DOCS] correct status for 
use_device_addr clause (authored by kkwli0).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70608

Files:
  clang/docs/OpenMPSupport.rst


Index: clang/docs/OpenMPSupport.rst
===
--- clang/docs/OpenMPSupport.rst
+++ clang/docs/OpenMPSupport.rst
@@ -205,7 +205,7 @@
 
+--+--+--+---+
 | device extension | mapping lambda expression 
   | :good:`done` | D51107  
  |
 
+--+--+--+---+
-| device extension | clause: use_device_addr for target data   
   | :good:`done` | 
  |
+| device extension | clause: use_device_addr for target data   
   | :part:`worked on`| 
  |
 
+--+--+--+---+
 | device extension | map(replicate) or map(local) when requires 
unified_shared_me | :part:`worked on`| D55719,D55892
 |
 
+--+--+--+---+


Index: clang/docs/OpenMPSupport.rst
===
--- clang/docs/OpenMPSupport.rst
+++ clang/docs/OpenMPSupport.rst
@@ -205,7 +205,7 @@
 +--+--+--+---+
 | device extension | mapping lambda expression| :good:`done` | D51107|
 +--+--+--+---+
-| device extension | clause: use_device_addr for target data  | :good:`done` |   |
+| device extension | clause: use_device_addr for target data  | :part:`worked on`|   |
 +--+--+--+---+
 | device extension | map(replicate) or map(local) when requires unified_shared_me | :part:`worked on`| D55719,D55892 |
 +--+--+--+---+
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D68407: [RISCV] Use compiler-rt if no GCC installation detected

2019-11-22 Thread Edward Jones via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGe0f22fe04a5c: [RISCV] Use compiler-rt if no GCC installation 
detected (authored by edward-jones).

Changed prior to commit:
  https://reviews.llvm.org/D68407?vs=229284=230708#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68407

Files:
  clang/lib/Driver/ToolChains/RISCVToolchain.cpp
  clang/lib/Driver/ToolChains/RISCVToolchain.h
  clang/test/Driver/riscv32-toolchain-extra.c
  clang/test/Driver/riscv32-toolchain.c
  clang/test/Driver/riscv64-toolchain-extra.c
  clang/test/Driver/riscv64-toolchain.c

Index: clang/test/Driver/riscv64-toolchain.c
===
--- clang/test/Driver/riscv64-toolchain.c
+++ clang/test/Driver/riscv64-toolchain.c
@@ -3,8 +3,11 @@
 // RUN: %clang %s -### -no-canonical-prefixes -target riscv64 2>&1 | FileCheck -check-prefix=CC1 %s
 // CC1: clang{{.*}} "-cc1" "-triple" "riscv64"
 
+// In the below tests, --rtlib=platform is used so that the driver ignores
+// the configure-time CLANG_DEFAULT_RTLIB option when choosing the runtime lib
+
 // RUN: %clang %s -### -no-canonical-prefixes \
-// RUN:   -target riscv64-unknown-elf \
+// RUN:   -target riscv64-unknown-elf --rtlib=platform \
 // RUN:   --gcc-toolchain=%S/Inputs/basic_riscv64_tree \
 // RUN:   --sysroot=%S/Inputs/basic_riscv64_tree/riscv64-unknown-elf 2>&1 \
 // RUN:   | FileCheck -check-prefix=C-RV64-BAREMETAL-LP64 %s
@@ -20,7 +23,7 @@
 // C-RV64-BAREMETAL-LP64: "{{.*}}/Inputs/basic_riscv64_tree/lib/gcc/riscv64-unknown-elf/8.0.1{{/|}}crtend.o"
 
 // RUN: %clang %s -### -no-canonical-prefixes \
-// RUN:   -target riscv64-unknown-elf \
+// RUN:   -target riscv64-unknown-elf --rtlib=platform \
 // RUN:   --sysroot= \
 // RUN:   --gcc-toolchain=%S/Inputs/basic_riscv64_tree 2>&1 \
 // RUN:   | FileCheck -check-prefix=C-RV64-BAREMETAL-NOSYSROOT-LP64 %s
@@ -35,7 +38,7 @@
 // C-RV64-BAREMETAL-NOSYSROOT-LP64: "{{.*}}/Inputs/basic_riscv64_tree/lib/gcc/riscv64-unknown-elf/8.0.1{{/|}}crtend.o"
 
 // RUN: %clangxx %s -### -no-canonical-prefixes \
-// RUN:   -target riscv64-unknown-elf -stdlib=libstdc++ \
+// RUN:   -target riscv64-unknown-elf -stdlib=libstdc++ --rtlib=platform \
 // RUN:   --gcc-toolchain=%S/Inputs/basic_riscv64_tree \
 // RUN:   --sysroot=%S/Inputs/basic_riscv64_tree/riscv64-unknown-elf 2>&1 \
 // RUN:   | FileCheck -check-prefix=CXX-RV64-BAREMETAL-LP64 %s
@@ -52,7 +55,7 @@
 // CXX-RV64-BAREMETAL-LP64: "{{.*}}/Inputs/basic_riscv64_tree/lib/gcc/riscv64-unknown-elf/8.0.1{{/|}}crtend.o"
 
 // RUN: %clangxx %s -### -no-canonical-prefixes \
-// RUN:   -target riscv64-unknown-elf -stdlib=libstdc++ \
+// RUN:   -target riscv64-unknown-elf -stdlib=libstdc++ --rtlib=platform \
 // RUN:   --sysroot= \
 // RUN:   --gcc-toolchain=%S/Inputs/basic_riscv64_tree 2>&1 \
 // RUN:   | FileCheck -check-prefix=CXX-RV64-BAREMETAL-NOSYSROOT-LP64 %s
@@ -68,7 +71,7 @@
 // CXX-RV64-BAREMETAL-NOSYSROOT-LP64: "{{.*}}/Inputs/basic_riscv64_tree/lib/gcc/riscv64-unknown-elf/8.0.1{{/|}}crtend.o"
 
 // RUN: %clang %s -### -no-canonical-prefixes -fuse-ld=ld \
-// RUN:   -target riscv64-unknown-linux-gnu -mabi=lp64 \
+// RUN:   -target riscv64-unknown-linux-gnu --rtlib=platform -mabi=lp64 \
 // RUN:   --gcc-toolchain=%S/Inputs/multilib_riscv_linux_sdk \
 // RUN:   --sysroot=%S/Inputs/multilib_riscv_linux_sdk/sysroot 2>&1 \
 // RUN:   | FileCheck -check-prefix=C-RV64-LINUX-MULTI-LP64 %s
@@ -84,7 +87,7 @@
 // C-RV64-LINUX-MULTI-LP64: "-L{{.*}}/Inputs/multilib_riscv_linux_sdk/sysroot/usr/lib64/lp64"
 
 // RUN: %clang %s -### -no-canonical-prefixes -fuse-ld=ld \
-// RUN:   -target riscv64-unknown-linux-gnu -march=rv64imafd \
+// RUN:   -target riscv64-unknown-linux-gnu --rtlib=platform -march=rv64imafd \
 // RUN:   --gcc-toolchain=%S/Inputs/multilib_riscv_linux_sdk \
 // RUN:   --sysroot=%S/Inputs/multilib_riscv_linux_sdk/sysroot 2>&1 \
 // RUN:   | FileCheck -check-prefix=C-RV64-LINUX-MULTI-LP64D %s
@@ -100,7 +103,8 @@
 // C-RV64-LINUX-MULTI-LP64D: "-L{{.*}}/Inputs/multilib_riscv_linux_sdk/sysroot/usr/lib64/lp64d"
 
 // RUN: %clang %s -### -no-canonical-prefixes -fuse-ld=ld \
-// RUN:   -target riscv64-unknown-elf --sysroot= -march=rv64imac -mabi=lp64\
+// RUN:   -target riscv64-unknown-elf --rtlib=platform --sysroot= \
+// RUN:   -march=rv64imac -mabi=lp64\
 // RUN:   --gcc-toolchain=%S/Inputs/multilib_riscv_elf_sdk 2>&1 \
 // RUN:   | FileCheck -check-prefix=C-RV64IMAC-BAREMETAL-MULTI-LP64 %s
 
@@ -115,7 +119,8 @@
 // C-RV64IMAC-BAREMETAL-MULTI-LP64: "{{.*}}/Inputs/multilib_riscv_elf_sdk/lib/gcc/riscv64-unknown-elf/8.2.0/rv64imac/lp64{{/|}}crtend.o"
 
 // RUN: %clang %s -### -no-canonical-prefixes -fuse-ld=ld \
-// RUN:   -target riscv64-unknown-elf --sysroot= -march=rv64imafdc -mabi=lp64d \
+// RUN:   -target riscv64-unknown-elf --rtlib=platform --sysroot= \
+// RUN:   -march=rv64imafdc -mabi=lp64d \
 // 

[clang] 0c7a1c0 - [OPENMP] [DOCS] correct status for use_device_addr clause

2019-11-22 Thread Kelvin Li via cfe-commits

Author: Kelvin Li
Date: 2019-11-22T15:32:40-05:00
New Revision: 0c7a1c0cfc2a4e5b8b7f3920b2797c12963b8384

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

LOG: [OPENMP] [DOCS] correct status for use_device_addr clause

The status of the use_device_addr clause feature is changed from 'done' to 
'worked on`.

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

Added: 


Modified: 
clang/docs/OpenMPSupport.rst

Removed: 




diff  --git a/clang/docs/OpenMPSupport.rst b/clang/docs/OpenMPSupport.rst
index aafadcfa0058..ee80f1afb9e6 100644
--- a/clang/docs/OpenMPSupport.rst
+++ b/clang/docs/OpenMPSupport.rst
@@ -205,7 +205,7 @@ implementation.
 
+--+--+--+---+
 | device extension | mapping lambda expression 
   | :good:`done` | D51107  
  |
 
+--+--+--+---+
-| device extension | clause: use_device_addr for target data   
   | :good:`done` | 
  |
+| device extension | clause: use_device_addr for target data   
   | :part:`worked on`| 
  |
 
+--+--+--+---+
 | device extension | map(replicate) or map(local) when requires 
unified_shared_me | :part:`worked on`| D55719,D55892
 |
 
+--+--+--+---+



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


[clang] e0f22fe - [RISCV] Use compiler-rt if no GCC installation detected

2019-11-22 Thread Edward Jones via cfe-commits

Author: Edward Jones
Date: 2019-11-22T20:05:29Z
New Revision: e0f22fe04a5c9eb244ff0533549743b7deb03b99

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

LOG: [RISCV] Use compiler-rt if no GCC installation detected

If a GCC installation is not detected, then this attempts to
use compiler-rt and the compiler-rt crtbegin/crtend
implementations as a fallback.

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

Added: 


Modified: 
clang/lib/Driver/ToolChains/RISCVToolchain.cpp
clang/lib/Driver/ToolChains/RISCVToolchain.h
clang/test/Driver/riscv32-toolchain-extra.c
clang/test/Driver/riscv32-toolchain.c
clang/test/Driver/riscv64-toolchain-extra.c
clang/test/Driver/riscv64-toolchain.c

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/RISCVToolchain.cpp 
b/clang/lib/Driver/ToolChains/RISCVToolchain.cpp
index bd63873e3c6c..25d912428b5f 100644
--- a/clang/lib/Driver/ToolChains/RISCVToolchain.cpp
+++ b/clang/lib/Driver/ToolChains/RISCVToolchain.cpp
@@ -61,6 +61,16 @@ Tool *RISCVToolChain::buildLinker() const {
   return new tools::RISCV::Linker(*this);
 }
 
+ToolChain::RuntimeLibType RISCVToolChain::GetDefaultRuntimeLibType() const {
+  return GCCInstallation.isValid() ?
+ToolChain::RLT_Libgcc : ToolChain::RLT_CompilerRT;
+}
+
+ToolChain::UnwindLibType
+RISCVToolChain::GetUnwindLibType(const llvm::opt::ArgList ) const {
+  return ToolChain::UNW_None;
+}
+
 void RISCVToolChain::addClangTargetOptions(
 const llvm::opt::ArgList ,
 llvm::opt::ArgStringList ,
@@ -138,9 +148,22 @@ void RISCV::Linker::ConstructJob(Compilation , const 
JobAction ,
   bool WantCRTs =
   !Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles);
 
+  const char *crtbegin, *crtend;
+  auto RuntimeLib = ToolChain.GetRuntimeLibType(Args);
+  if (RuntimeLib == ToolChain::RLT_Libgcc) {
+crtbegin = "crtbegin.o";
+crtend = "crtend.o";
+  } else {
+assert (RuntimeLib == ToolChain::RLT_CompilerRT);
+crtbegin = ToolChain.getCompilerRTArgString(Args, "crtbegin",
+ToolChain::FT_Object);
+crtend = ToolChain.getCompilerRTArgString(Args, "crtend",
+  ToolChain::FT_Object);
+  }
+
   if (WantCRTs) {
 CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath("crt0.o")));
-CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath("crtbegin.o")));
+CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath(crtbegin)));
   }
 
   Args.AddAllArgs(CmdArgs, options::OPT_L);
@@ -161,11 +184,11 @@ void RISCV::Linker::ConstructJob(Compilation , const 
JobAction ,
 CmdArgs.push_back("-lc");
 CmdArgs.push_back("-lgloss");
 CmdArgs.push_back("--end-group");
-CmdArgs.push_back("-lgcc");
+AddRunTimeLibs(ToolChain, ToolChain.getDriver(), CmdArgs, Args);
   }
 
   if (WantCRTs)
-CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath("crtend.o")));
+CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath(crtend)));
 
   CmdArgs.push_back("-o");
   CmdArgs.push_back(Output.getFilename());

diff  --git a/clang/lib/Driver/ToolChains/RISCVToolchain.h 
b/clang/lib/Driver/ToolChains/RISCVToolchain.h
index b2b56b066efd..bb7f64849bcb 100644
--- a/clang/lib/Driver/ToolChains/RISCVToolchain.h
+++ b/clang/lib/Driver/ToolChains/RISCVToolchain.h
@@ -25,6 +25,9 @@ class LLVM_LIBRARY_VISIBILITY RISCVToolChain : public 
Generic_ELF {
   void addClangTargetOptions(const llvm::opt::ArgList ,
  llvm::opt::ArgStringList ,
  Action::OffloadKind) const override;
+  RuntimeLibType GetDefaultRuntimeLibType() const override;
+  UnwindLibType
+  GetUnwindLibType(const llvm::opt::ArgList ) const override;
   void
   AddClangSystemIncludeArgs(const llvm::opt::ArgList ,
 llvm::opt::ArgStringList ) const override;

diff  --git a/clang/test/Driver/riscv32-toolchain-extra.c 
b/clang/test/Driver/riscv32-toolchain-extra.c
index 613667213ac8..d07d0f199ae2 100644
--- a/clang/test/Driver/riscv32-toolchain-extra.c
+++ b/clang/test/Driver/riscv32-toolchain-extra.c
@@ -19,15 +19,15 @@
 // RUN: ln -s %S/Inputs/basic_riscv32_nogcc_tree/bin/riscv32-unknown-elf-ld 
%T/testroot-riscv32-baremetal-nogcc/bin/riscv32-unknown-elf-ld
 // RUN: ln -s %S/Inputs/basic_riscv32_nogcc_tree/riscv32-unknown-elf 
%T/testroot-riscv32-baremetal-nogcc/riscv32-unknown-elf
 // RUN: %T/testroot-riscv32-baremetal-nogcc/bin/clang %s -### 
-no-canonical-prefixes \
-// RUN:-target riscv32-unknown-elf 2>&1 \
+// RUN:-target riscv32-unknown-elf --rtlib=platform 2>&1 \
 // RUN:| FileCheck -check-prefix=C-RV32-BAREMETAL-ILP32-NOGCC %s
 
-// C-RV32-BAREMETAL-ILP32-NOGCC: InstalledDir: [[DRIVERDIR:.*]]
 // 

[PATCH] D70467: [Distro] Bypass distro detection on non-Linux hosts

2019-11-22 Thread Reid Kleckner via Phabricator via cfe-commits
rnk accepted this revision.
rnk added a comment.
This revision is now accepted and ready to land.

In D70467#1755364 , @aganea wrote:

> Actually, I'm not sure the `DetectDistro()` does what it intends to do when 
> cross-compiling: if I compile on Ubuntu and I forcibly specify `-target 
> x86_64-linux` on the cmd-line, should it detect which Linux distro I'm on? In 
> the case of `CudaInstallationDetector()` it seems it should use the host 
> triple, whereas in the case `clang/lib/Driver/ToolChains/Linux.cpp:Linux()` 
> it adds flags for building the target, so it should take the target triple 
> maybe. Should we pass a triple to `DetectDistro`?


It does seem wrong to use DetectDistro when the user passes a target triple. 
DetectDistro inherently detects something about that host, and it seems we 
don't have a way to pass that information explicitly on the command line. So, 
cross-compiling from one distro to another might somehow do the wrong thing 
depending on what distro detection does.

In D70467#1755337 , @aganea wrote:

> In D70467#1752611 , @rnk wrote:
>
> > Hm, I guess it does happen. I think that condition should be restructured 
> > to only do all that BSD, PS4, Android, Gentoo etc logic if the format is 
> > ELF, if COFF, then always default to -faddrsig.
>
>
> We're cross-compiling all our target platforms on Windows. It seems this 
> patch would be still valid in that case:
>
>   > clang -target x86_64-linux a.cpp
>   
>
> Would still call `DetectDistro()`, and unless I'm missing something, we 
> wouldn't want it to lookup `C:\etc\lsb-release` even if it's there? Or people 
> are really doing that to target a specific distro when compiling from 
> Windows? It doesn't make sense from my POV.
>  The same argument applies to CUDA: the code in 
> `clang/lib/Driver/ToolChains/Cuda.cpp:CudaInstallationDetector()` says 
> "HostTriple" but it's actually the Target triple -- you can try my cmd-line 
> above, it hits the Distro detect.
>  Unless you specify a non-real FS, I wouldn't want `DetectDistro` to return 
> anything else than `Distro::UnknownDistro` when running on a non-Linux OS.
>  Would you have a different opinion or something I don't see?


True, that makes sense to me.

lgtm




Comment at: clang/lib/Driver/Distro.cpp:29
+  // If the host is not running Linux, and we're backed by a real file system,
+  // no need to check the distro.
+  IntrusiveRefCntPtr RealFS =

I think it's worth adding more to this comment. This is the case where someone 
is cross-compiling from BSD or Windows to Linux, and it would be meaningless to 
try to figure out the "distro" of the non-Linux host.



Comment at: clang/lib/Driver/ToolChains/Linux.cpp:514
 
-  const Distro Distro(getDriver().getVFS());
+  const Distro Distro(getDriver().getVFS(), Triple);
 

So many duplicate detections. =/


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

https://reviews.llvm.org/D70467



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


[PATCH] D69746: [analyzer] FixItHint: Apply and test hints with the Clang Tidy's script

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

In D69746#1756448 , @gribozavr2 wrote:

> > This patch introduces a way to apply the fix-its by the Analyzer:
>
> I'm not sure this option is very useful... I don't know of anyone who uses 
> the same option in Clang or ClangTidy. The only way I know people apply 
> fixits is with the help of IDEs. I am also skeptical that people want to 
> apply *all* fixits. Usually people want to pick a few specific ones, or all 
> fixits of a certain kind; but not everything.
>
> What workflow are you thinking of for this option?


For now this is definitely for testing purposes only. This patch doesn't expose 
the option in any of the interfaces that are intended for actual users to use 
(`-analyzer-config` is not one of them).

I don't have any immediate plans on exposing this option to users. That said, 
the user can always apply fixits of a specific checker by only running that 
checker (or by only enabling fixits of this checker).


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

https://reviews.llvm.org/D69746



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


[PATCH] D67149: Fix argument order for BugType instation for

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

Ah, the good old "stringly typed" APIs.

Would you like to write a LIT test for the fix, say by `FileCheck`ing the Plist 
output? (i could write one for you if it's not your cup of tea)


Repository:
  rC Clang

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

https://reviews.llvm.org/D67149



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


[PATCH] D70613: Add method to ignore invisible AST nodes

2019-11-22 Thread Stephen Kelly via Phabricator via cfe-commits
steveire created this revision.
steveire added a reviewer: aaron.ballman.
Herald added subscribers: cfe-commits, mgorny.
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D70613

Files:
  clang/include/clang/AST/ASTNodeTraverser.h
  clang/include/clang/AST/ASTTypeTraits.h
  clang/include/clang/AST/Expr.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/Expr.cpp
  clang/unittests/AST/ASTTraverserTest.cpp
  clang/unittests/AST/CMakeLists.txt
  clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp

Index: clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
===
--- clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
+++ clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
@@ -1680,6 +1680,149 @@
  functionDecl(hasDescendant(Matcher)));
 }
 
+TEST(Traversal, traverseInvisible) {
+
+  StringRef Code = R"cpp(
+
+struct A
+{
+};
+
+struct B
+{
+  B(int);
+  B(A const& a);
+  B();
+};
+
+struct C
+{
+  operator B();
+};
+
+B func1() {
+  return 42;
+}
+
+B func2() {
+  return B{42};
+}
+
+B func3() {
+  return B(42);
+}
+
+B func4() {
+  return B();
+}
+
+B func5() {
+  return B{};
+}
+
+B func6() {
+  return C();
+}
+
+B func7() {
+  return A();
+}
+
+B func8() {
+  return C{};
+}
+
+B func9() {
+  return A{};
+}
+
+B func10() {
+  A a;
+  return a;
+}
+
+B func11() {
+  B b;
+  return b;
+}
+
+B func12() {
+  C c;
+  return c;
+}
+
+)cpp";
+
+  EXPECT_TRUE(matches(
+  Code, traverse(ast_type_traits::TK_IgnoreInvisible,
+ returnStmt(forFunction(functionDecl(hasName("func1"))),
+hasReturnValue(integerLiteral(equals(42)));
+
+  EXPECT_TRUE(matches(
+  Code,
+  traverse(ast_type_traits::TK_IgnoreInvisible,
+   returnStmt(forFunction(functionDecl(hasName("func2"))),
+  hasReturnValue(cxxTemporaryObjectExpr(
+  hasArgument(0, integerLiteral(equals(42);
+
+  EXPECT_TRUE(matches(
+  Code, traverse(ast_type_traits::TK_IgnoreInvisible,
+ returnStmt(forFunction(functionDecl(hasName("func3"))),
+hasReturnValue(
+cxxFunctionalCastExpr(hasSourceExpression(
+integerLiteral(equals(42);
+
+  EXPECT_TRUE(matches(
+  Code, traverse(ast_type_traits::TK_IgnoreInvisible,
+ returnStmt(forFunction(functionDecl(hasName("func4"))),
+hasReturnValue(cxxTemporaryObjectExpr());
+
+  EXPECT_TRUE(matches(
+  Code, traverse(ast_type_traits::TK_IgnoreInvisible,
+ returnStmt(forFunction(functionDecl(hasName("func5"))),
+hasReturnValue(cxxTemporaryObjectExpr());
+
+  EXPECT_TRUE(matches(
+  Code, traverse(ast_type_traits::TK_IgnoreInvisible,
+ returnStmt(forFunction(functionDecl(hasName("func6"))),
+hasReturnValue(cxxTemporaryObjectExpr());
+
+  EXPECT_TRUE(matches(
+  Code, traverse(ast_type_traits::TK_IgnoreInvisible,
+ returnStmt(forFunction(functionDecl(hasName("func7"))),
+hasReturnValue(cxxTemporaryObjectExpr());
+
+  EXPECT_TRUE(matches(
+  Code, traverse(ast_type_traits::TK_IgnoreInvisible,
+ returnStmt(forFunction(functionDecl(hasName("func8"))),
+hasReturnValue(cxxFunctionalCastExpr(
+hasSourceExpression(initListExpr(;
+
+  EXPECT_TRUE(matches(
+  Code, traverse(ast_type_traits::TK_IgnoreInvisible,
+ returnStmt(forFunction(functionDecl(hasName("func9"))),
+hasReturnValue(cxxFunctionalCastExpr(
+hasSourceExpression(initListExpr(;
+
+  EXPECT_TRUE(matches(
+  Code, traverse(ast_type_traits::TK_IgnoreInvisible,
+ returnStmt(forFunction(functionDecl(hasName("func10"))),
+hasReturnValue(
+declRefExpr(to(varDecl(hasName("a");
+
+  EXPECT_TRUE(matches(
+  Code, traverse(ast_type_traits::TK_IgnoreInvisible,
+ returnStmt(forFunction(functionDecl(hasName("func11"))),
+hasReturnValue(
+declRefExpr(to(varDecl(hasName("b");
+
+  EXPECT_TRUE(matches(
+  Code, traverse(ast_type_traits::TK_IgnoreInvisible,
+ returnStmt(forFunction(functionDecl(hasName("func12"))),
+hasReturnValue(
+declRefExpr(to(varDecl(hasName("c");
+}
+
 TEST(IgnoringImpCasts, MatchesImpCasts) {
   // This test checks that 

[PATCH] D70524: Support DebugInfo generation for auto return type for C++ functions.

2019-11-22 Thread Adrian Prantl via Phabricator via cfe-commits
aprantl added a comment.

In D70524#1757237 , @dblaikie wrote:

> Generally if you're not touching LLVM code, I would suggest not adding an 
> LLVM test - unless this is new or surprising usage of existing LLVM 
> functionality (or the functionality was otherwise undertested in LLVM 
> previously). But I'm guessing that's not the case here?


The rephrase the question David is asking: Do we already have an LLVM test for 
a named unspecified type?


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

https://reviews.llvm.org/D70524



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


[PATCH] D70342: [Diagnostics] Put "deprecated copy" warnings into -Wdeprecated-copy

2019-11-22 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 added a comment.

Thank you!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70342



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


[PATCH] D70342: [Diagnostics] Put "deprecated copy" warnings into -Wdeprecated-copy

2019-11-22 Thread David Blaikie via Phabricator via cfe-commits
dblaikie accepted this revision.
dblaikie added a comment.
This revision is now accepted and ready to land.

Looks good to me - can handle anything else from @rsmith in post-commit review.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70342



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


[PATCH] D70411: [analyzer] CERT: StrChecker: 31.c

2019-11-22 Thread Csaba Dabis via Phabricator via cfe-commits
Charusso updated this revision to Diff 230702.
Charusso marked an inline comment as done.
Charusso retitled this revision from "[analyzer][WIP] CERT: StrChecker: 31.c" 
to "[analyzer] CERT: StrChecker: 31.c".
Charusso added a comment.

- Remove the report storing map so we do not traverse backwards on the bug-path.
- Use `NoteTags` instead of reports on problematic function calls.
- Emit a report only if a not null-terminated string is read.
- Store whether the string is null-terminated.


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

https://reviews.llvm.org/D70411

Files:
  clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
  clang/include/clang/StaticAnalyzer/Core/BugReporter/CommonBugCategories.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/DynamicSizeInfo.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/SymExpr.h
  clang/lib/StaticAnalyzer/Checkers/AllocationState.h
  clang/lib/StaticAnalyzer/Checkers/CMakeLists.txt
  clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/cert/StrChecker.cpp
  clang/lib/StaticAnalyzer/Core/CommonBugCategories.cpp
  clang/test/Analysis/Inputs/system-header-simulator.h
  clang/test/Analysis/cert/str31-c-fp-suppression.cpp
  clang/test/Analysis/cert/str31-c-notes.cpp
  clang/test/Analysis/cert/str31-c.cpp

Index: clang/test/Analysis/cert/str31-c.cpp
===
--- /dev/null
+++ clang/test/Analysis/cert/str31-c.cpp
@@ -0,0 +1,205 @@
+// RUN: %clang_analyze_cc1 \
+// RUN:  -analyzer-checker=core,unix,security.cert.str.31.c \
+// RUN:  -verify %s
+
+// See the examples on the page of STR31:
+// https://wiki.sei.cmu.edu/confluence/display/c/STR31-C.+Guarantee+that+storage+for+strings+has+sufficient+space+for+character+data+and+the+null+terminator
+
+#include "../Inputs/system-header-simulator.h"
+
+#define EOF -1
+typedef __SIZE_TYPE__ size_t;
+
+void free(void *memblock);
+void *malloc(size_t size);
+
+void do_something(char *buffer);
+
+namespace test_gets_bad {
+#define BUFFER_SIZE 1024
+
+void func(void) {
+  char buf[BUFFER_SIZE];
+  if (gets(buf)) {
+do_something(buf);
+// expected-warning@-1 {{'buf' is not null-terminated}}
+  }
+}
+} // namespace test_gets_bad
+
+namespace test_gets_good {
+enum { BUFFERSIZE = 32 };
+
+void func(void) {
+  char buff[BUFFERSIZE];
+
+  if (fgets(buff, sizeof(buff), stdin)) {
+do_something(buff);
+  }
+}
+} // namespace test_gets_good
+
+namespace test_sprintf_bad {
+void func(const char *name) {
+  char buf[128];
+  sprintf(buf, "%s.txt", name);
+
+  do_something(buf);
+  // expected-warning@-1 {{'buf' is not null-terminated}}
+}
+} // namespace test_sprintf_bad
+
+namespace test_sprintf_good {
+void func(const char *name) {
+  char buff[128];
+  snprintf(buff, sizeof(buff), "%s.txt", name);
+
+  do_something(buff);
+}
+} // namespace test_sprintf_good
+
+namespace test_fscanf_bad {
+enum { BUF_LENGTH = 1024 };
+
+void get_data(void) {
+  char buf[BUF_LENGTH];
+  if (fscanf(stdin, "%s", buf)) {
+do_something(buf);
+// expected-warning@-1 {{'buf' is not null-terminated}}
+  }
+}
+} // namespace test_fscanf_bad
+
+namespace test_fscanf_good {
+enum { BUF_LENGTH = 1024 };
+
+void get_data(void) {
+  char buff[BUF_LENGTH];
+  if (fscanf(stdin, "%1023s", buff)) {
+do_something(buff);
+  }
+}
+} // namespace test_fscanf_good
+
+namespace test_strcpy_bad {
+int main(int argc, char *argv[]) {
+  const char *const name = (argc && argv[0]) ? argv[0] : "";
+  char prog_name[128];
+  strcpy(prog_name, name);
+
+  do_something(prog_name);
+  // expected-warning@-1 {{'prog_name' is not null-terminated}}
+
+  return 0;
+}
+
+void func(void) {
+  char buff[256];
+  char *editor = getenv("EDITOR");
+  if (editor != NULL) {
+strcpy(buff, editor);
+
+do_something(buff);
+// expected-warning@-1 {{'buff' is not null-terminated}}
+  }
+}
+} // namespace test_strcpy_bad
+
+namespace test_strcpy_good {
+int main(int argc, char *argv[]) {
+  const char *const name = (argc && argv[0]) ? argv[0] : "";
+  char *prog_name2 = (char *)malloc(strlen(name) + 1);
+  if (prog_name2 != NULL) {
+strcpy(prog_name2, name);
+  }
+
+  do_something(prog_name2);
+
+  free(prog_name2);
+  return 0;
+}
+
+void func(void) {
+  char *buff2;
+  char *editor = getenv("EDITOR");
+  if (editor != NULL) {
+size_t len = strlen(editor) + 1;
+buff2 = (char *)malloc(len);
+if (buff2 != NULL) {
+  strcpy(buff2, editor);
+}
+
+do_something(buff2);
+free(buff2);
+  }
+}
+} // namespace test_strcpy_good
+
+//===--===//
+// The following is from the rule's page which we do not handle yet.
+//===--===//
+
+namespace test_loop_index_bad {
+void copy(size_t n, char src[n], char dest[n]) {
+  size_t i;
+
+  for (i = 0; src[i] && (i < n); ++i) {
+dest[i] = 

[PATCH] D70411: [analyzer] CERT: StrChecker: 31.c

2019-11-22 Thread Csaba Dabis via Phabricator via cfe-commits
Charusso added a comment.

Now I have simplified the checker so we do not need any ASCII-art, I believe. 
Do we have any better logic than the current implementation to catch when the 
string is read?


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

https://reviews.llvm.org/D70411



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


[PATCH] D69620: Add AIX assembler support

2019-11-22 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast added inline comments.



Comment at: clang/lib/Driver/ToolChains/AIX.cpp:37
+
+  // Specify the mode in which the as command operates.
+  if (IsArch32Bit) {

Refer to the other comment regarding confusion of "as" with the English word.



Comment at: clang/lib/Driver/ToolChains/AIX.cpp:47
+  // displayed. Otherwise, undefined symbols are flagged with error messages.
+  CmdArgs.push_back("-u");
+

There is no FIXME here indicating the plan to remove this in the future when 
the assembly generation from the compiler no longer needs this.



Comment at: clang/lib/Driver/ToolChains/AIX.cpp:49
+
+  // Acccept any mixture of instructions.
+  CmdArgs.push_back("-many");

Minor nit: Typo: s/Acccept/Accept/;



Comment at: clang/lib/Driver/ToolChains/AIX.cpp:50
+  // Acccept any mixture of instructions.
+  CmdArgs.push_back("-many");
+

A comment should indicate that this behaviour matches that of GCC on Power for 
AIX and Linux for both the user-provided assembler source case and the 
compiler-produced assembler source case. The behaviour for XL with 
user-provided assemble source is different.



Comment at: clang/lib/Driver/ToolChains/AIX.cpp:61
+
+  // Specify assembler input file(s).
+  for (const auto  : Inputs)

The AIX assembler does not accept more than one input file. If the intent is to 
let the assembler produce the error message, then I think we should at least 
have a comment to acknowledge the situation.



Comment at: clang/test/Driver/aix-as.c:1
+// General tests that as invocations on AIX targets are sane. Note that we
+// only test assembler functionalities in this suite.

Minor nit: To avoid confusion with the English word, use
```
`as`
```
or
```
as(1)
```



Comment at: clang/test/Driver/aix-as.c:31
+// RUN: -target powerpc-ibm-aix7.1.0.0 \
+// RUN:   | FileCheck --check-prefix=CHECK-AS32-PTHREAD %s
+// CHECK-AS32-PTHREAD-NOT: warning:

I am not getting how this block is related to "pthread".



Comment at: clang/test/Driver/aix-as.c:40
+
+// Check powerpc-ibm-aix7.1.0.0, 64-bit. -Wa,, option.
+// RUN: %clang -no-canonical-prefixes %s -### -c -o %t.o 2>&1 \

s/powerpc/powerpc64/;



Comment at: clang/test/Driver/aix-as.c:44
+// RUN: -target powerpc64-ibm-aix7.1.0.0 \
+// RUN:   | FileCheck --check-prefix=CHECK-AS64-PTHREAD %s
+// CHECK-AS64-PTHREAD-NOT: warning:

Same comment re: "pthread".


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69620



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


[PATCH] D70111: [DWARF5]Addition of alignment field in the typedef for dwarf5

2019-11-22 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

In D70111#1754702 , @awpandey wrote:

> I am considering this
>
> - Will commit this without C bindings
> - will give separate patch for C bindings and release notes (if necessary).
> - will give another patch for Go bindings and release notes (if necessary).


I'm not sure I follow - are you asking a question? Proposing a path forward 
you're planning to take (or this patch already represents)?

I'd reiterate my previous request:

Please update the go bindings and include a release note that this API is 
changing & why. (include that in this patch review & then it can be reviewed & 
all committed together to keep the whole source tree in a working state, 
because committing the change while either removing the C API or updating it 
without updating the Go bindings would break the Go bindings, which isn't good)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70111



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


[PATCH] D70524: Support DebugInfo generation for auto return type for C++ functions.

2019-11-22 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

Generally if you're not touching LLVM code, I would suggest not adding an LLVM 
test - unless this is new or surprising usage of existing LLVM functionality 
(or the functionality was otherwise undertested in LLVM previously). But I'm 
guessing that's not the case here?


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

https://reviews.llvm.org/D70524



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


[PATCH] D70518: [clang-include-fixer] Suppress cmd prompt from Vim on Windows

2019-11-22 Thread Reid Kleckner via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGe1e7b6f381a9: [clang-include-fixer] Suppress cmd prompt from 
Vim on Windows (authored by rnk).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70518

Files:
  clang-tools-extra/clang-include-fixer/tool/clang-include-fixer.py


Index: clang-tools-extra/clang-include-fixer/tool/clang-include-fixer.py
===
--- clang-tools-extra/clang-include-fixer/tool/clang-include-fixer.py
+++ clang-tools-extra/clang-include-fixer/tool/clang-include-fixer.py
@@ -85,9 +85,16 @@
 
 
 def execute(command, text):
+  # Avoid flashing a cmd prompt on Windows.
+  startupinfo = None
+  if sys.platform.startswith('win32'):
+startupinfo = subprocess.STARTUPINFO()
+startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
+startupinfo.wShowWindow = subprocess.SW_HIDE
+
   p = subprocess.Popen(command,
stdout=subprocess.PIPE, stderr=subprocess.PIPE,
-   stdin=subprocess.PIPE)
+   stdin=subprocess.PIPE, startupinfo=startupinfo)
   return p.communicate(input=text)
 
 


Index: clang-tools-extra/clang-include-fixer/tool/clang-include-fixer.py
===
--- clang-tools-extra/clang-include-fixer/tool/clang-include-fixer.py
+++ clang-tools-extra/clang-include-fixer/tool/clang-include-fixer.py
@@ -85,9 +85,16 @@
 
 
 def execute(command, text):
+  # Avoid flashing a cmd prompt on Windows.
+  startupinfo = None
+  if sys.platform.startswith('win32'):
+startupinfo = subprocess.STARTUPINFO()
+startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
+startupinfo.wShowWindow = subprocess.SW_HIDE
+
   p = subprocess.Popen(command,
stdout=subprocess.PIPE, stderr=subprocess.PIPE,
-   stdin=subprocess.PIPE)
+   stdin=subprocess.PIPE, startupinfo=startupinfo)
   return p.communicate(input=text)
 
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D70368: [clang-tidy] Rewrite modernize-avoid-bind check

2019-11-22 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added a comment.

Please mark addressed comments as done.


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

https://reviews.llvm.org/D70368



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


[PATCH] D70524: Support DebugInfo generation for auto return type for C++ functions.

2019-11-22 Thread Adrian Prantl via Phabricator via cfe-commits
aprantl added inline comments.



Comment at: llvm/test/DebugInfo/X86/debug-info-auto-return.ll:1
+;RUN: %llc_dwarf %s -filetype=obj -o - | llvm-dwarfdump -v - | FileCheck %s
+

I don't think the FORMs are relevant for this test, so we can do without the 
`-v`


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

https://reviews.llvm.org/D70524



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


[clang-tools-extra] e1e7b6f - [clang-include-fixer] Suppress cmd prompt from Vim on Windows

2019-11-22 Thread Reid Kleckner via cfe-commits

Author: Reid Kleckner
Date: 2019-11-22T11:28:42-08:00
New Revision: e1e7b6f381a9a5640605fdc4a3e78eb01f8fc8b9

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

LOG: [clang-include-fixer] Suppress cmd prompt from Vim on Windows

Copied from the clang-format.py editor integration.

Reviewers: bkramer

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

Added: 


Modified: 
clang-tools-extra/clang-include-fixer/tool/clang-include-fixer.py

Removed: 




diff  --git a/clang-tools-extra/clang-include-fixer/tool/clang-include-fixer.py 
b/clang-tools-extra/clang-include-fixer/tool/clang-include-fixer.py
index 4c38f71ef76a..df05101e4fd8 100644
--- a/clang-tools-extra/clang-include-fixer/tool/clang-include-fixer.py
+++ b/clang-tools-extra/clang-include-fixer/tool/clang-include-fixer.py
@@ -85,9 +85,16 @@ def GetUserSelection(message, headers, 
maximum_suggested_headers):
 
 
 def execute(command, text):
+  # Avoid flashing a cmd prompt on Windows.
+  startupinfo = None
+  if sys.platform.startswith('win32'):
+startupinfo = subprocess.STARTUPINFO()
+startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
+startupinfo.wShowWindow = subprocess.SW_HIDE
+
   p = subprocess.Popen(command,
stdout=subprocess.PIPE, stderr=subprocess.PIPE,
-   stdin=subprocess.PIPE)
+   stdin=subprocess.PIPE, startupinfo=startupinfo)
   return p.communicate(input=text)
 
 



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


[PATCH] D70537: [clang] CGDebugInfo asserts `!DT.isNull()` when compiling with debug symbols

2019-11-22 Thread Vedant Kumar via Phabricator via cfe-commits
vsk requested changes to this revision.
vsk added inline comments.
This revision now requires changes to proceed.



Comment at: clang/lib/CodeGen/CGDebugInfo.cpp:1437
+if (isa(V))
+  continue;
+

I see that we don't attempt to handle `VarTemplateSpecializationDecl` when 
emitting CodeView. But it looks like we generally do handle these when emitting 
DWARF. I think the problem you're trying to address has more to do with clang 
not being able to describe globals with undeduced types in debug info.

E.g. if I replace `auto` with `int` in your test case, I get 
(https://godbolt.org/z/gRpRws):

```
!17 = distinct !DIGlobalVariable(name: "value", linkageName: 
"_ZN6TypeId5valueIJiEEE", scope: !2, file: !8, line: 7, type: !14, isLocal: 
false, isDefinition: true, declaration: !13, templateParams: !18)
!18 = !{!19}
!19 = !DITemplateValueParameter(tag: DW_TAG_GNU_template_parameter_pack, name: 
"Args", value: !20)
```

Could you limit the scope of this patch to just ignore 
VarTemplateSpecializationDecl's with undeduced types? I think there's an 
example of how to do this in `CGDebugInfo::EmitUsingDecl`, you could factor 
that out and reuse it here.

Please also add a test case for the `s/auto/int/` example, to make sure that 
doesn't regress.


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

https://reviews.llvm.org/D70537



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


[PATCH] D70551: [clang-offload-wrapper] Add data layout to the wrapper bitcode

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

Wrapper tool is invoked at link phase, therefore there just could be no .bc 
files available to read data layout from. Ok, looks like there is no good 
solution for the data layout problem, so I will drop the idea of passing 
wrapper .bc directly to the linker when LTO is enabled (at least for now:). I 
will abandon this patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70551



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


[PATCH] D70603: Change while to do-while

2019-11-22 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 added a comment.

This is fine as NFC/NFCI patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70603



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


[PATCH] D70603: Change while to do-while

2019-11-22 Thread Seija Kijin via Phabricator via cfe-commits
pi1024e added a comment.

What do you mean? I test compiled this and there are no errors after running 
the test benchmark. Was I supposed to do something else?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70603



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


[PATCH] D70605: [OpenCL] Fix address space for implicit conversion (PR43145)

2019-11-22 Thread Sven van Haastregt via Phabricator via cfe-commits
svenvh created this revision.
svenvh added reviewers: Anastasia, rjmccall.
Herald added a subscriber: yaxunl.

Clang was creating a `DerivedToBase` `ImplicitCastExpr` that was also
casting between address spaces as part of the second step in the
standard conversion sequence.  Defer the address space conversion to
the third step in the sequence instead, such that we get a separate
`ImplicitCastExpr` for the address space conversion.


https://reviews.llvm.org/D70605

Files:
  clang/lib/Sema/SemaExprCXX.cpp
  clang/test/CodeGenOpenCLCXX/addrspace-derived-base.cl


Index: clang/test/CodeGenOpenCLCXX/addrspace-derived-base.cl
===
--- clang/test/CodeGenOpenCLCXX/addrspace-derived-base.cl
+++ clang/test/CodeGenOpenCLCXX/addrspace-derived-base.cl
@@ -69,3 +69,12 @@
   // CHECK: bitcast i8 addrspace(4)* %add.ptr1 to %class.B2 addrspace(4)*
   // CHECK: call {{.*}} @_ZNU3AS42B26getRefEv
 }
+
+// Implicit conversion of derived to base.
+
+void functionWithBaseArg(class B2 *b) {}
+
+void pr43145_4() {
+  Derived d;
+  functionWithBaseArg();
+}
Index: clang/lib/Sema/SemaExprCXX.cpp
===
--- clang/lib/Sema/SemaExprCXX.cpp
+++ clang/lib/Sema/SemaExprCXX.cpp
@@ -4095,9 +4095,21 @@
 << From->getSourceRange();
 }
 
+// Defer address space conversion to the third conversion.
+QualType FromPteeType = From->getType()->getPointeeType();
+QualType ToPteeType = ToType->getPointeeType();
+QualType NewToType = ToType;
+if (!FromPteeType.isNull() && !ToPteeType.isNull() &&
+FromPteeType.getAddressSpace() != ToPteeType.getAddressSpace()) {
+  NewToType = Context.removeAddrSpaceQualType(ToPteeType);
+  NewToType = Context.getAddrSpaceQualType(NewToType,
+   FromPteeType.getAddressSpace());
+  NewToType = Context.getPointerType(NewToType);
+}
+
 CastKind Kind;
 CXXCastPath BasePath;
-if (CheckPointerConversion(From, ToType, Kind, BasePath, CStyle))
+if (CheckPointerConversion(From, NewToType, Kind, BasePath, CStyle))
   return ExprError();
 
 // Make sure we extend blocks if necessary.
@@ -4108,8 +4120,8 @@
   From = E.get();
 }
 if (getLangOpts().allowsNonTrivialObjCLifetimeQualifiers())
-  CheckObjCConversion(SourceRange(), ToType, From, CCK);
-From = ImpCastExprToType(From, ToType, Kind, VK_RValue, , CCK)
+  CheckObjCConversion(SourceRange(), NewToType, From, CCK);
+From = ImpCastExprToType(From, NewToType, Kind, VK_RValue, , CCK)
  .get();
 break;
   }


Index: clang/test/CodeGenOpenCLCXX/addrspace-derived-base.cl
===
--- clang/test/CodeGenOpenCLCXX/addrspace-derived-base.cl
+++ clang/test/CodeGenOpenCLCXX/addrspace-derived-base.cl
@@ -69,3 +69,12 @@
   // CHECK: bitcast i8 addrspace(4)* %add.ptr1 to %class.B2 addrspace(4)*
   // CHECK: call {{.*}} @_ZNU3AS42B26getRefEv
 }
+
+// Implicit conversion of derived to base.
+
+void functionWithBaseArg(class B2 *b) {}
+
+void pr43145_4() {
+  Derived d;
+  functionWithBaseArg();
+}
Index: clang/lib/Sema/SemaExprCXX.cpp
===
--- clang/lib/Sema/SemaExprCXX.cpp
+++ clang/lib/Sema/SemaExprCXX.cpp
@@ -4095,9 +4095,21 @@
 << From->getSourceRange();
 }
 
+// Defer address space conversion to the third conversion.
+QualType FromPteeType = From->getType()->getPointeeType();
+QualType ToPteeType = ToType->getPointeeType();
+QualType NewToType = ToType;
+if (!FromPteeType.isNull() && !ToPteeType.isNull() &&
+FromPteeType.getAddressSpace() != ToPteeType.getAddressSpace()) {
+  NewToType = Context.removeAddrSpaceQualType(ToPteeType);
+  NewToType = Context.getAddrSpaceQualType(NewToType,
+   FromPteeType.getAddressSpace());
+  NewToType = Context.getPointerType(NewToType);
+}
+
 CastKind Kind;
 CXXCastPath BasePath;
-if (CheckPointerConversion(From, ToType, Kind, BasePath, CStyle))
+if (CheckPointerConversion(From, NewToType, Kind, BasePath, CStyle))
   return ExprError();
 
 // Make sure we extend blocks if necessary.
@@ -4108,8 +4120,8 @@
   From = E.get();
 }
 if (getLangOpts().allowsNonTrivialObjCLifetimeQualifiers())
-  CheckObjCConversion(SourceRange(), ToType, From, CCK);
-From = ImpCastExprToType(From, ToType, Kind, VK_RValue, , CCK)
+  CheckObjCConversion(SourceRange(), NewToType, From, CCK);
+From = ImpCastExprToType(From, NewToType, Kind, VK_RValue, , CCK)
  .get();
 break;
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D70603: Change while to do-while

2019-11-22 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

Missing a test; please upload all patches with full context (`-U9`)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70603



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


[PATCH] D70551: [clang-offload-wrapper] Add data layout to the wrapper bitcode

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

In D70551#1757065 , @sdmitriev wrote:

> I would agree with you if data layout was indeed available in the driver, but 
> unfortunately driver does not have access to any existing TargetInfo instance 
> (or maybe I just have not found it). So, I have to create TargetInfo and 
> build data layout even for the case when driver passes it to the wrapper 
> tool. I guess that would also be a default data layout, so it would not 
> differ much from what I have already done in this patch. BTW, I will probably 
> upload an alternative patch where I have implemented your suggestion, just to 
> compare))


Of course, this is not a good solution. I was hoping that TargetInfo is 
available in driver. Otherwise, it would be good somehow to read the target 
data from the .bc file.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70551



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


[PATCH] D70551: [clang-offload-wrapper] Add data layout to the wrapper bitcode

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

I would agree with you if data layout was indeed available in the driver, but 
unfortunately driver does not have access to any existing TargetInfo instance 
(or maybe I just have not found it). So, I have to create TargetInfo and build 
data layout even for the case when driver passes it to the wrapper tool. I 
guess that would also be a default data layout, so it would not differ much 
from what I have already done in this patch. BTW, I will probably upload an 
alternative patch where I have implemented your suggestion, just to compare))


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70551



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


[PATCH] D61837: Make it possible control matcher traversal kind with ASTContext

2019-11-22 Thread Stephen Kelly via Phabricator via cfe-commits
steveire updated this revision to Diff 230678.
steveire added a comment.

Rebase and update


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61837

Files:
  clang/include/clang/AST/ASTContext.h
  clang/include/clang/AST/ASTNodeTraverser.h
  clang/include/clang/ASTMatchers/ASTMatchers.h
  clang/include/clang/ASTMatchers/ASTMatchersInternal.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/ASTMatchers/ASTMatchFinder.cpp
  clang/lib/ASTMatchers/ASTMatchersInternal.cpp
  clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp

Index: clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
===
--- clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
+++ clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
@@ -1595,6 +1595,91 @@
   notMatches("class C {}; C a = C();", varDecl(has(cxxConstructExpr();
 }
 
+TEST(Traversal, traverseMatcher) {
+
+  StringRef VarDeclCode = R"cpp(
+void foo()
+{
+  int i = 3.0;
+}
+)cpp";
+
+  auto Matcher = varDecl(hasInitializer(floatLiteral()));
+
+  EXPECT_TRUE(
+  notMatches(VarDeclCode, traverse(ast_type_traits::TK_AsIs, Matcher)));
+  EXPECT_TRUE(
+  matches(VarDeclCode,
+  traverse(ast_type_traits::TK_IgnoreImplicitCastsAndParentheses,
+   Matcher)));
+}
+
+TEST(Traversal, traverseMatcherNesting) {
+
+  StringRef Code = R"cpp(
+float bar(int i)
+{
+  return i;
+}
+
+void foo()
+{
+  bar(bar(3.0));
+}
+)cpp";
+
+  EXPECT_TRUE(matches(
+  Code,
+  traverse(ast_type_traits::TK_IgnoreImplicitCastsAndParentheses,
+   callExpr(has(callExpr(traverse(
+   ast_type_traits::TK_AsIs,
+   callExpr(has(implicitCastExpr(has(floatLiteral(;
+}
+
+TEST(Traversal, traverseMatcherThroughImplicit) {
+  StringRef Code = R"cpp(
+struct S {
+  S(int x);
+};
+
+void constructImplicit() {
+  int a = 8;
+  S s(a);
+}
+  )cpp";
+
+  auto Matcher = traverse(ast_type_traits::TK_IgnoreImplicitCastsAndParentheses,
+  implicitCastExpr());
+
+  // Verfiy that it does not segfault
+  EXPECT_FALSE(matches(Code, Matcher));
+}
+
+TEST(Traversal, traverseMatcherThroughMemoization) {
+
+  StringRef Code = R"cpp(
+void foo()
+{
+  int i = 3.0;
+}
+  )cpp";
+
+  auto Matcher = varDecl(hasInitializer(floatLiteral()));
+
+  // Matchers such as hasDescendant memoize their result regarding AST
+  // nodes. In the matcher below, the first use of hasDescendant(Matcher)
+  // fails, and the use of it inside the traverse() matcher should pass
+  // causing the overall matcher to be a true match.
+  // This test verifies that the first false result is not re-used, which
+  // would cause the overall matcher to be incorrectly false.
+
+  EXPECT_TRUE(matches(
+  Code, functionDecl(anyOf(
+hasDescendant(Matcher),
+traverse(ast_type_traits::TK_IgnoreImplicitCastsAndParentheses,
+ functionDecl(hasDescendant(Matcher)));
+}
+
 TEST(IgnoringImpCasts, MatchesImpCasts) {
   // This test checks that ignoringImpCasts matches when implicit casts are
   // present and its inner matcher alone does not match.
Index: clang/lib/ASTMatchers/ASTMatchersInternal.cpp
===
--- clang/lib/ASTMatchers/ASTMatchersInternal.cpp
+++ clang/lib/ASTMatchers/ASTMatchersInternal.cpp
@@ -189,6 +189,14 @@
   llvm_unreachable("Invalid Op value.");
 }
 
+DynTypedMatcher DynTypedMatcher::constructRestrictedWrapper(
+const DynTypedMatcher ,
+ast_type_traits::ASTNodeKind RestrictKind) {
+  DynTypedMatcher Copy = InnerMatcher;
+  Copy.RestrictKind = RestrictKind;
+  return Copy;
+}
+
 DynTypedMatcher DynTypedMatcher::trueMatcher(
 ast_type_traits::ASTNodeKind NodeKind) {
   return DynTypedMatcher(NodeKind, NodeKind, &*TrueMatcherInstance);
@@ -211,8 +219,13 @@
 bool DynTypedMatcher::matches(const ast_type_traits::DynTypedNode ,
   ASTMatchFinder *Finder,
   BoundNodesTreeBuilder *Builder) const {
-  if (RestrictKind.isBaseOf(DynNode.getNodeKind()) &&
-  Implementation->dynMatches(DynNode, Finder, Builder)) {
+  TraversalKindScope raii(Finder->getASTContext(),
+  Implementation->TraversalKind());
+
+  auto N = Finder->getASTContext().traverseIgnored(DynNode);
+
+  if (RestrictKind.isBaseOf(N.getNodeKind()) &&
+  Implementation->dynMatches(N, Finder, Builder)) {
 return true;
   }
   // Delete all bindings when a matcher does not match.
@@ -225,8 +238,13 @@
 bool DynTypedMatcher::matchesNoKindCheck(
 const ast_type_traits::DynTypedNode , ASTMatchFinder *Finder,
 BoundNodesTreeBuilder *Builder) const {
-  assert(RestrictKind.isBaseOf(DynNode.getNodeKind()));
-  if (Implementation->dynMatches(DynNode, Finder, Builder)) {
+  TraversalKindScope 

[PATCH] D70603: Change while to do-while

2019-11-22 Thread Seija Kijin via Phabricator via cfe-commits
pi1024e created this revision.
pi1024e added a project: LLVM.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
pi1024e added a reviewer: llvm.org.
pi1024e edited reviewers, added: modocache, sammccall, Quuxplusone; removed: 
llvm.org.

The assert statement says that the location must be a macroID, which is true. 
However, the while statements checks for that again, which is unnecessary, and 
gives warnings for returning a potentially non-initialized variable. For this 
reason, I suggest changing the while to a do-while loop while keeping the 
assert where it is.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D70603

Files:
  clang/lib/Analysis/ReachableCode.cpp


Index: clang/lib/Analysis/ReachableCode.cpp
===
--- clang/lib/Analysis/ReachableCode.cpp
+++ clang/lib/Analysis/ReachableCode.cpp
@@ -138,10 +138,10 @@
 static SourceLocation getTopMostMacro(SourceLocation Loc, SourceManager ) {
   assert(Loc.isMacroID());
   SourceLocation Last;
-  while (Loc.isMacroID()) {
+  do {
 Last = Loc;
 Loc = SM.getImmediateMacroCallerLoc(Loc);
-  }
+  } while (Loc.isMacroID());
   return Last;
 }
 


Index: clang/lib/Analysis/ReachableCode.cpp
===
--- clang/lib/Analysis/ReachableCode.cpp
+++ clang/lib/Analysis/ReachableCode.cpp
@@ -138,10 +138,10 @@
 static SourceLocation getTopMostMacro(SourceLocation Loc, SourceManager ) {
   assert(Loc.isMacroID());
   SourceLocation Last;
-  while (Loc.isMacroID()) {
+  do {
 Last = Loc;
 Loc = SM.getImmediateMacroCallerLoc(Loc);
-  }
+  } while (Loc.isMacroID());
   return Last;
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D70554: [libTooling] Add stencil combinators for nodes that may be pointers or values.

2019-11-22 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
ymandel marked an inline comment as done.
Closed by commit rG01e8dd2e7a85: [libTooling] Add stencil combinators for nodes 
that may be pointers or values. (authored by ymandel).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70554

Files:
  clang/include/clang/Tooling/Transformer/Stencil.h
  clang/lib/Tooling/Transformer/Stencil.cpp
  clang/unittests/Tooling/StencilTest.cpp

Index: clang/unittests/Tooling/StencilTest.cpp
===
--- clang/unittests/Tooling/StencilTest.cpp
+++ clang/unittests/Tooling/StencilTest.cpp
@@ -233,6 +233,46 @@
   testExpr(Id, "int *x; *x;", addressOf(Id), "x");
 }
 
+TEST_F(StencilTest, MaybeDerefValue) {
+  StringRef Id = "id";
+  testExpr(Id, "int x; x;", maybeDeref(Id), "x");
+}
+
+TEST_F(StencilTest, MaybeDerefPointer) {
+  StringRef Id = "id";
+  testExpr(Id, "int *x; x;", maybeDeref(Id), "*x");
+}
+
+TEST_F(StencilTest, MaybeDerefBinOp) {
+  StringRef Id = "id";
+  testExpr(Id, "int *x; x + 1;", maybeDeref(Id), "*(x + 1)");
+}
+
+TEST_F(StencilTest, MaybeDerefAddressExpr) {
+  StringRef Id = "id";
+  testExpr(Id, "int x; ", maybeDeref(Id), "x");
+}
+
+TEST_F(StencilTest, MaybeAddressOfPointer) {
+  StringRef Id = "id";
+  testExpr(Id, "int *x; x;", maybeAddressOf(Id), "x");
+}
+
+TEST_F(StencilTest, MaybeAddressOfValue) {
+  StringRef Id = "id";
+  testExpr(Id, "int x; x;", addressOf(Id), "");
+}
+
+TEST_F(StencilTest, MaybeAddressOfBinOp) {
+  StringRef Id = "id";
+  testExpr(Id, "int x; x + 1;", maybeAddressOf(Id), "&(x + 1)");
+}
+
+TEST_F(StencilTest, MaybeAddressOfDerefExpr) {
+  StringRef Id = "id";
+  testExpr(Id, "int *x; *x;", addressOf(Id), "x");
+}
+
 TEST_F(StencilTest, AccessOpValue) {
   StringRef Snippet = R"cc(
 S x;
Index: clang/lib/Tooling/Transformer/Stencil.cpp
===
--- clang/lib/Tooling/Transformer/Stencil.cpp
+++ clang/lib/Tooling/Transformer/Stencil.cpp
@@ -59,7 +59,9 @@
 enum class UnaryNodeOperator {
   Parens,
   Deref,
-  Address,
+  MaybeDeref,
+  AddressOf,
+  MaybeAddressOf,
 };
 
 // Generic container for stencil operations with a (single) node-id argument.
@@ -121,9 +123,15 @@
   case UnaryNodeOperator::Deref:
 OpName = "deref";
 break;
-  case UnaryNodeOperator::Address:
+  case UnaryNodeOperator::MaybeDeref:
+OpName = "maybeDeref";
+break;
+  case UnaryNodeOperator::AddressOf:
 OpName = "addressOf";
 break;
+  case UnaryNodeOperator::MaybeAddressOf:
+OpName = "maybeAddressOf";
+break;
   }
   return (OpName + "(\"" + Data.Id + "\")").str();
 }
@@ -191,7 +199,21 @@
   case UnaryNodeOperator::Deref:
 Source = tooling::buildDereference(*E, *Match.Context);
 break;
-  case UnaryNodeOperator::Address:
+  case UnaryNodeOperator::MaybeDeref:
+if (!E->getType()->isAnyPointerType()) {
+  *Result += tooling::getText(*E, *Match.Context);
+  return Error::success();
+}
+Source = tooling::buildDereference(*E, *Match.Context);
+break;
+  case UnaryNodeOperator::AddressOf:
+Source = tooling::buildAddressOf(*E, *Match.Context);
+break;
+  case UnaryNodeOperator::MaybeAddressOf:
+if (E->getType()->isAnyPointerType()) {
+  *Result += tooling::getText(*E, *Match.Context);
+  return Error::success();
+}
 Source = tooling::buildAddressOf(*E, *Match.Context);
 break;
   }
@@ -300,9 +322,19 @@
   UnaryNodeOperator::Deref, ExprId);
 }
 
+Stencil transformer::maybeDeref(llvm::StringRef ExprId) {
+  return std::make_shared>(
+  UnaryNodeOperator::MaybeDeref, ExprId);
+}
+
 Stencil transformer::addressOf(llvm::StringRef ExprId) {
   return std::make_shared>(
-  UnaryNodeOperator::Address, ExprId);
+  UnaryNodeOperator::AddressOf, ExprId);
+}
+
+Stencil transformer::maybeAddressOf(llvm::StringRef ExprId) {
+  return std::make_shared>(
+  UnaryNodeOperator::MaybeAddressOf, ExprId);
 }
 
 Stencil transformer::access(StringRef BaseId, Stencil Member) {
Index: clang/include/clang/Tooling/Transformer/Stencil.h
===
--- clang/include/clang/Tooling/Transformer/Stencil.h
+++ clang/include/clang/Tooling/Transformer/Stencil.h
@@ -87,11 +87,24 @@
 /// \p ExprId is wrapped in parentheses, if needed.
 Stencil deref(llvm::StringRef ExprId);
 
+/// If \p ExprId is of pointer type, constructs an idiomatic dereferencing of
+/// the expression bound to \p ExprId, including wrapping it in parentheses, if
+/// needed. Otherwise, generates the original expression source.
+/// FIXME: Identify smart-pointers as pointer types.
+Stencil maybeDeref(llvm::StringRef ExprId);
+
 /// Constructs an expression that idiomatically takes the address of the
 /// expression bound to \p ExprId. \p ExprId is wrapped in parentheses, if
 /// needed.
 

[clang] 01e8dd2 - [libTooling] Add stencil combinators for nodes that may be pointers or values.

2019-11-22 Thread Yitzhak Mandelbaum via cfe-commits

Author: Yitzhak Mandelbaum
Date: 2019-11-22T12:36:40-05:00
New Revision: 01e8dd2e7a852794a60e50f356f171f893503598

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

LOG: [libTooling] Add stencil combinators for nodes that may be pointers or 
values.

Summary:
Adds combinators `maybeDeref` and `maybeAddressOf` to provide a uniform way to 
handle
nodes which may be bound to either a pointer or a value (most often in the
context of member expressions). Such polymorphism is already supported by
`access`; these combinators extend it to more general uses.

Reviewers: gribozavr

Subscribers: cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang/include/clang/Tooling/Transformer/Stencil.h
clang/lib/Tooling/Transformer/Stencil.cpp
clang/unittests/Tooling/StencilTest.cpp

Removed: 




diff  --git a/clang/include/clang/Tooling/Transformer/Stencil.h 
b/clang/include/clang/Tooling/Transformer/Stencil.h
index dd65e68b7e8a..0363b689dc5b 100644
--- a/clang/include/clang/Tooling/Transformer/Stencil.h
+++ b/clang/include/clang/Tooling/Transformer/Stencil.h
@@ -87,11 +87,24 @@ Stencil expression(llvm::StringRef Id);
 /// \p ExprId is wrapped in parentheses, if needed.
 Stencil deref(llvm::StringRef ExprId);
 
+/// If \p ExprId is of pointer type, constructs an idiomatic dereferencing of
+/// the expression bound to \p ExprId, including wrapping it in parentheses, if
+/// needed. Otherwise, generates the original expression source.
+/// FIXME: Identify smart-pointers as pointer types.
+Stencil maybeDeref(llvm::StringRef ExprId);
+
 /// Constructs an expression that idiomatically takes the address of the
 /// expression bound to \p ExprId. \p ExprId is wrapped in parentheses, if
 /// needed.
 Stencil addressOf(llvm::StringRef ExprId);
 
+/// If \p ExprId is not a pointer type, constructs an expression that
+/// idiomatically takes the address of the expression bound to \p ExprId,
+/// including wrapping \p ExprId in parentheses, if needed. Otherwise, 
generates
+/// the original expression source.
+/// FIXME: Identify smart-pointers as pointer types.
+Stencil maybeAddressOf(llvm::StringRef ExprId);
+
 /// Constructs a `MemberExpr` that accesses the named member (\p Member) of the
 /// object bound to \p BaseId. The access is constructed idiomatically: if \p
 /// BaseId is bound to `e` and \p Member identifies member `m`, then returns

diff  --git a/clang/lib/Tooling/Transformer/Stencil.cpp 
b/clang/lib/Tooling/Transformer/Stencil.cpp
index 486e18b341f7..8710e3cdf60f 100644
--- a/clang/lib/Tooling/Transformer/Stencil.cpp
+++ b/clang/lib/Tooling/Transformer/Stencil.cpp
@@ -59,7 +59,9 @@ struct DebugPrintNodeData {
 enum class UnaryNodeOperator {
   Parens,
   Deref,
-  Address,
+  MaybeDeref,
+  AddressOf,
+  MaybeAddressOf,
 };
 
 // Generic container for stencil operations with a (single) node-id argument.
@@ -121,9 +123,15 @@ std::string toStringData(const UnaryOperationData ) {
   case UnaryNodeOperator::Deref:
 OpName = "deref";
 break;
-  case UnaryNodeOperator::Address:
+  case UnaryNodeOperator::MaybeDeref:
+OpName = "maybeDeref";
+break;
+  case UnaryNodeOperator::AddressOf:
 OpName = "addressOf";
 break;
+  case UnaryNodeOperator::MaybeAddressOf:
+OpName = "maybeAddressOf";
+break;
   }
   return (OpName + "(\"" + Data.Id + "\")").str();
 }
@@ -191,7 +199,21 @@ Error evalData(const UnaryOperationData ,
   case UnaryNodeOperator::Deref:
 Source = tooling::buildDereference(*E, *Match.Context);
 break;
-  case UnaryNodeOperator::Address:
+  case UnaryNodeOperator::MaybeDeref:
+if (!E->getType()->isAnyPointerType()) {
+  *Result += tooling::getText(*E, *Match.Context);
+  return Error::success();
+}
+Source = tooling::buildDereference(*E, *Match.Context);
+break;
+  case UnaryNodeOperator::AddressOf:
+Source = tooling::buildAddressOf(*E, *Match.Context);
+break;
+  case UnaryNodeOperator::MaybeAddressOf:
+if (E->getType()->isAnyPointerType()) {
+  *Result += tooling::getText(*E, *Match.Context);
+  return Error::success();
+}
 Source = tooling::buildAddressOf(*E, *Match.Context);
 break;
   }
@@ -300,9 +322,19 @@ Stencil transformer::deref(llvm::StringRef ExprId) {
   UnaryNodeOperator::Deref, ExprId);
 }
 
+Stencil transformer::maybeDeref(llvm::StringRef ExprId) {
+  return std::make_shared>(
+  UnaryNodeOperator::MaybeDeref, ExprId);
+}
+
 Stencil transformer::addressOf(llvm::StringRef ExprId) {
   return std::make_shared>(
-  UnaryNodeOperator::Address, ExprId);
+  UnaryNodeOperator::AddressOf, ExprId);
+}
+
+Stencil transformer::maybeAddressOf(llvm::StringRef ExprId) {
+  return std::make_shared>(
+  

[PATCH] D70551: [clang-offload-wrapper] Add data layout to the wrapper bitcode

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

In D70551#1756997 , @sdmitriev wrote:

> Ok, it is possible to do it like you suggested, but I think that teaching 
> wrapper tool to set data layout without external help is more preferable. 
> There is a certain difference between opt and wrapper tool – opt works on the 
> existing .bc that is provided in command line and data-layout option just 
> gives user an optional way to override input’s data layout while wrapper tool 
> creates output .bc from scratch. With your proposal, data-layout would become 
> sort of mandatory option for the wrapper tool which is not very convenient. I 
> believe wrapper tool should be able to set it without external help, and we 
> can always add an option to override data layout (similar to opt) if there 
> would be a need for that.


Why it is not convenient? Plus, when you're trying to build the data layout 
yourself, you end up with the default one for the given target rather than rely 
on the one specified by the user when the driver was invoked. So, I think, it 
would be better to get the data layout from the driver rather than use the 
default one.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70551



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


[PATCH] D70551: [clang-offload-wrapper] Add data layout to the wrapper bitcode

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

Ok, it is possible to do it like you suggested, but I think that teaching 
wrapper tool to set data layout without external help is more preferable. There 
is a certain difference between opt and wrapper tool – opt works on the 
existing .bc that is provided in command line and data-layout option just gives 
user an optional way to override input’s data layout while wrapper tool creates 
output .bc from scratch. With your proposal, data-layout would become sort of 
mandatory option for the wrapper tool which is not very convenient. I believe 
wrapper tool should be able to set it without external help, and we can always 
add an option to override data layout (similar to opt) if there would be a need 
for that.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70551



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


[PATCH] D69180: [Format] Add format check for coroutine keywords with negative numbers

2019-11-22 Thread Jonathan Thomas via Phabricator via cfe-commits
jonathoma added a comment.

@modocache Feel free to commit from my end! Thanks again :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69180



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


[PATCH] D70470: [analyzer] Add FuchsiaHandleCheck to catch handle leaks, use after frees and double frees

2019-11-22 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun updated this revision to Diff 230668.
xazax.hun added a comment.

- Fix member operator modeling.
- Added new lines to the end of files.
- Added documentation.
- Minor typo fixes in tests.


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

https://reviews.llvm.org/D70470

Files:
  clang/docs/analyzer/checkers.rst
  clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/StaticAnalyzer/Checkers/CMakeLists.txt
  clang/lib/StaticAnalyzer/Checkers/FuchsiaHandleChecker.cpp
  clang/test/Analysis/fuchsia_handle.cpp

Index: clang/test/Analysis/fuchsia_handle.cpp
===
--- /dev/null
+++ clang/test/Analysis/fuchsia_handle.cpp
@@ -0,0 +1,127 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,fuchsia.HandleChecker -verify %s
+
+typedef __typeof__(sizeof(int)) size_t;
+typedef int zx_status_t;
+typedef __typeof__(sizeof(int)) zx_handle_t;
+typedef unsigned int uint32_t;
+#define NULL ((void *)0)
+
+#if defined(__clang__)
+#define ZX_HANDLE_ACQUIRE  __attribute__((acquire_handle))
+#define ZX_HANDLE_RELEASE  __attribute__((release_handle))
+#define ZX_HANDLE_USE  __attribute__((use_handle))
+#else
+#define ZX_HANDLE_ACQUIRE
+#define ZX_HANDLE_RELEASE
+#define ZX_HANDLE_USE
+#endif
+
+zx_status_t zx_channel_create(
+uint32_t options,
+ZX_HANDLE_ACQUIRE zx_handle_t* out0,
+zx_handle_t* out1 ZX_HANDLE_ACQUIRE);
+
+zx_status_t zx_handle_close(
+zx_handle_t handle ZX_HANDLE_RELEASE);
+
+void escape1(zx_handle_t *in);
+void escape2(zx_handle_t in);
+
+void use1(const zx_handle_t *in ZX_HANDLE_USE);
+void use2(zx_handle_t in ZX_HANDLE_USE);
+
+// To test if argument indexes are OK for operator calls.
+struct MyType {
+  ZX_HANDLE_ACQUIRE
+  zx_handle_t operator+(zx_handle_t replace ZX_HANDLE_RELEASE);
+};
+
+void checkNoLeak01() {
+  zx_handle_t sa, sb;
+  zx_channel_create(0, , );
+  zx_handle_close(sa);
+  zx_handle_close(sb);
+}
+
+void checkNoLeak02() {
+  zx_handle_t ay[2];
+  zx_channel_create(0, [0], [1]);
+  zx_handle_close(ay[0]);
+  zx_handle_close(ay[1]);
+}
+
+void checkNoLeak03() {
+  zx_handle_t ay[2];
+  zx_channel_create(0, [0], [1]);
+  for (int i = 0; i < 2; i++)
+zx_handle_close(ay[i]);
+}
+
+zx_handle_t checkNoLeak04() {
+  zx_handle_t sa, sb;
+  zx_channel_create(0, , );
+  zx_handle_close(sa);
+  return sb; // no warning
+}
+
+zx_handle_t checkNoLeak05(zx_handle_t *out1) {
+  zx_handle_t sa, sb;
+  zx_channel_create(0, , );
+  *out1 = sa;
+  return sb; // no warning
+}
+
+void checkNoLeak06() {
+  zx_handle_t sa, sb;
+  if (zx_channel_create(0, , ))
+return;
+  zx_handle_close(sa);
+  zx_handle_close(sb);
+} 
+
+void checkNoLeak07(int tag) {
+  zx_handle_t sa, sb;
+  if (zx_channel_create(0, , ))
+return;
+  escape1();
+  escape2(sb);
+}
+
+void checkLeak01(int tag) {
+  zx_handle_t sa, sb;
+  zx_channel_create(0, , );
+  use1();
+  if (tag)
+zx_handle_close(sa);
+  use2(sb); // expected-warning {{Potential leak of handle}}
+  zx_handle_close(sb);
+}
+
+void checkDoubleRelease01(int tag) {
+  zx_handle_t sa, sb;
+  zx_channel_create(0, , );
+  if (tag)
+zx_handle_close(sa);
+  zx_handle_close(sa); // expected-warning {{Releasing a previously released handle}}
+  zx_handle_close(sb);
+}
+
+void checkUseAfterFree01(int tag) {
+  zx_handle_t sa, sb;
+  zx_channel_create(0, , );
+  if (tag) {
+zx_handle_close(sa);
+use1(); // expected-warning {{Using a previously released handle}}
+  }
+  zx_handle_close(sb);
+  use2(sb); // expected-warning {{Using a previously released handle}}
+}
+
+void checkMemberOperatorIndices() {
+  zx_handle_t sa, sb, sc;
+  zx_channel_create(0, , );
+  zx_handle_close(sb);
+  MyType t;
+  sc = t + sa;
+  zx_handle_close(sc);
+}
Index: clang/lib/StaticAnalyzer/Checkers/FuchsiaHandleChecker.cpp
===
--- /dev/null
+++ clang/lib/StaticAnalyzer/Checkers/FuchsiaHandleChecker.cpp
@@ -0,0 +1,457 @@
+//=== FuchsiaHandleChecker.cpp - Find handle leaks/double closes -*- 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
+//
+//===--===//
+//
+// This checker checks if the handle of Fuchsia is properly used according to
+// following rules.
+//   - If a handle is acquired, it should be released before execution
+//ends.
+//   - If a handle is released, it should not be released again.
+//   - If a handle is released, it should not be used for other purposes
+//such as I/O.
+//
+// In this checker, each tracked handle is associated with a state. When the
+// handle variable is passed to different function calls or syscalls, its 

[PATCH] D70572: [Serialization] #pragma clang transform

2019-11-22 Thread Michael Kruse via Phabricator via cfe-commits
Meinersbur updated this revision to Diff 230670.
Meinersbur added a comment.

- Remove some leftovers


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70572

Files:
  clang/include/clang/Serialization/ASTBitCodes.h
  clang/include/clang/Serialization/ASTReader.h
  clang/include/clang/Serialization/ASTWriter.h
  clang/lib/AST/StmtProfile.cpp
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTReaderStmt.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/lib/Serialization/ASTWriterStmt.cpp
  clang/test/PCH/transform-interleave.cpp
  clang/test/PCH/transform-unroll.cpp
  clang/test/PCH/transform-unrollandjam.cpp
  clang/test/PCH/transform-vectorize.cpp

Index: clang/test/PCH/transform-vectorize.cpp
===
--- /dev/null
+++ clang/test/PCH/transform-vectorize.cpp
@@ -0,0 +1,28 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fexperimental-transform-pragma -emit-pch -o %t.pch %s
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fexperimental-transform-pragma -include-pch %t.pch %s -ast-dump-all -o - | FileCheck %s
+
+#ifndef HEADER
+#define HEADER
+
+void vectorize_heuristic(int n) {
+#pragma clang transform vectorize
+  for (int i = 0; i < n; i+=1)
+;
+}
+// CHECK-LABEL: FunctionDecl {{.*}} imported vectorize_heuristic
+// CHECK: TransformExecutableDirective
+// CHECK-NEXT: ForStmt
+
+
+void vectorize_width(int n) {
+#pragma clang transform vectorize width(4)
+  for (int i = 0; i < n; i+=1)
+;
+}
+// CHECK-LABEL: FunctionDecl {{.*}} imported vectorize_width
+// CHECK: TransformExecutableDirective
+// CHECK-NEXT: WidthClause
+// CHECK-NEXT:   IntegerLiteral {{.*}} 'int' 4
+// CHECK-NEXT: ForStmt
+
+#endif /* HEADER */
Index: clang/test/PCH/transform-unrollandjam.cpp
===
--- /dev/null
+++ clang/test/PCH/transform-unrollandjam.cpp
@@ -0,0 +1,30 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fexperimental-transform-pragma -emit-pch -o %t.pch %s
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fexperimental-transform-pragma -include-pch %t.pch %s -ast-dump-all -o - | FileCheck %s
+
+#ifndef HEADER
+#define HEADER
+
+void  unrollandjam_heuristic(int n) {
+#pragma clang transform unrollandjam
+  for (int i = 0; i < n; i+=1)
+for (int j = 0; j < n; j+=1)
+  ;
+}
+// CHECK-LABEL: FunctionDecl {{.*}} imported unrollandjam_heuristic
+// CHECK: TransformExecutableDirective
+// CHECK-NEXT: ForStmt
+
+
+void unrollandjam_partial(int n) {
+#pragma clang transform unrollandjam partial(4)
+  for (int i = 0; i < n; i+=1)
+for (int j = 0; j < n; j+=1)
+  ;
+}
+// CHECK-LABEL: FunctionDecl {{.*}} imported unrollandjam_partial
+// CHECK: TransformExecutableDirective
+// CHECK-NEXT: PartialClause
+// CHECK-NEXT:   IntegerLiteral {{.*}} 'int' 4
+// CHECK-NEXT: ForStmt
+
+#endif /* HEADER */
Index: clang/test/PCH/transform-unroll.cpp
===
--- /dev/null
+++ clang/test/PCH/transform-unroll.cpp
@@ -0,0 +1,85 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fexperimental-transform-pragma -emit-pch -o %t.pch %s
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fexperimental-transform-pragma -include-pch %t.pch %s -ast-dump-all -o - | FileCheck %s
+
+#ifndef HEADER
+#define HEADER
+
+void  unroll_heuristic(int n) {
+#pragma clang transform unroll
+  for (int i = 0; i < 4; i+=1)
+;
+}
+// CHECK-LABEL: FunctionDecl {{.*}} imported unroll_heuristic
+// CHECK: TransformExecutableDirective
+// CHECK-NEXT: ForStmt
+
+
+void unroll_full(int n) {
+#pragma clang transform unroll full
+  for (int i = 0; i < 4; i+=1)
+;
+}
+// CHECK-LABEL: FunctionDecl {{.*}} imported unroll_full
+// CHECK: TransformExecutableDirective
+// CHECK-NEXT: FullClause
+// CHECK-NEXT: ForStmt
+
+
+void unroll_partial(int n) {
+#pragma clang transform unroll partial(4)
+  for (int i = 0; i < n; i+=1)
+;
+}
+// CHECK-LABEL: FunctionDecl {{.*}} imported unroll_partial
+// CHECK: TransformExecutableDirective
+// CHECK-NEXT: PartialClause
+// CHECK-NEXT:   IntegerLiteral {{.*}} 'int' 4
+// CHECK-NEXT: ForStmt
+
+
+template
+void unroll_template_function(int n) {
+#pragma clang transform unroll partial(FACTOR)
+  for (int i = 0; i < n; i+=1)
+;
+}
+// CHECK-LABEL: FunctionDecl {{.*}} imported unroll_template_function
+// CHECK: TransformExecutableDirective
+// CHECK-NEXT: PartialClause
+// CHECK-NEXT:   DeclRefExpr {{.*}} 'FACTOR' 'int'
+// CHECK-NEXT: ForStmt
+
+
+template void unroll_template_function<5>(int);
+// CHECK-LABEL: FunctionDecl {{.*}} imported unroll_template_function
+// CHECK: TransformExecutableDirective
+// CHECK-NEXT: PartialClause
+// CHECK-NEXT:   SubstNonTypeTemplateParmExpr
+// CHECK-NEXT:   IntegerLiteral {{.*}} 'int' 5
+// CHECK-NEXT: ForStmt
+
+
+template
+struct Unroll {
+  void 

[PATCH] D70368: [clang-tidy] Rewrite modernize-avoid-bind check

2019-11-22 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added inline comments.



Comment at: clang-tools-extra/docs/ReleaseNotes.rst:194
+  The check now supports supports diagnosing and fixing arbitrary callables 
instead of
+  only simple free functions. The ``PermissiveParameterList`` option has also 
been
+  added to address situations where the existing fix-it logic would sometimes 
generate

Please use single back-tics for options.



Comment at: clang-tools-extra/docs/clang-tidy/checks/modernize-avoid-bind.rst:50
+  If the option is set to non-zero, the check will append ``auto&&...`` to the 
end
+  of every placeholder parameter list.  Without this, it is possible for a 
fixit
+  to perform an incorrect transformation in the case where the result of the 
``bind``

Double space here and in other places are still not fixed. Same for fixit.


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

https://reviews.llvm.org/D70368



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


[clang] 5459a90 - [OPENMP]Simplify processing of context selectors, NFC.

2019-11-22 Thread Alexey Bataev via cfe-commits

Author: Alexey Bataev
Date: 2019-11-22T11:53:06-05:00
New Revision: 5459a905c23c03fad68e80b2dff23ca1ca3b7c7c

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

LOG: [OPENMP]Simplify processing of context selectors, NFC.

Added: 


Modified: 
clang/lib/CodeGen/CGOpenMPRuntime.cpp
clang/lib/Sema/SemaOpenMP.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp 
b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
index c2d895b4ea4a..f80249483c7a 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -11138,33 +11138,22 @@ bool checkContext(
 bool matchesContext(CodeGenModule ,
 const CompleteOMPContextSelectorData ) {
   for (const OMPContextSelectorData  : ContextData) {
-switch (Data.CtxSet) {
-case OMP_CTX_SET_implementation:
-  switch (Data.Ctx) {
-  case OMP_CTX_vendor:
-if (!checkContext(Data))
-  return false;
-break;
-  case OMP_CTX_kind:
-  case OMP_CTX_unknown:
-llvm_unreachable(
-"Unexpected context selector kind in implementation set.");
-  }
+switch (Data.Ctx) {
+case OMP_CTX_vendor:
+  assert(Data.CtxSet == OMP_CTX_SET_implementation &&
+ "Expected implementation context selector set.");
+  if (!checkContext(Data))
+return false;
   break;
-case OMP_CTX_SET_device:
-  switch (Data.Ctx) {
-  case OMP_CTX_kind:
-if (!checkContext(
-Data, CGM))
-  return false;
-break;
-  case OMP_CTX_vendor:
-  case OMP_CTX_unknown:
-llvm_unreachable("Unexpected context selector kind in device set.");
-  }
+case OMP_CTX_kind:
+  assert(Data.CtxSet == OMP_CTX_SET_device &&
+ "Expected device context selector set.");
+  if (!checkContext(Data,
+   
CGM))
+return false;
   break;
-case OMP_CTX_SET_unknown:
-  llvm_unreachable("Unexpected context selector set kind.");
+case OMP_CTX_unknown:
+  llvm_unreachable("Unknown context selector kind.");
 }
   }
   return true;
@@ -11184,32 +11173,21 @@ translateAttrToContextSelectorData(ASTContext ,
 Data.back().Ctx = Ctx;
 const Expr *Score = *std::next(A->scores_begin(), I);
 Data.back().Score = Score->EvaluateKnownConstInt(C);
-switch (CtxSet) {
-case OMP_CTX_SET_implementation:
-  switch (Ctx) {
-  case OMP_CTX_vendor:
-Data.back().Names =
-llvm::makeArrayRef(A->implVendors_begin(), A->implVendors_end());
-break;
-  case OMP_CTX_kind:
-  case OMP_CTX_unknown:
-llvm_unreachable(
-"Unexpected context selector kind in implementation set.");
-  }
+switch (Ctx) {
+case OMP_CTX_vendor:
+  assert(CtxSet == OMP_CTX_SET_implementation &&
+ "Expected implementation context selector set.");
+  Data.back().Names =
+  llvm::makeArrayRef(A->implVendors_begin(), A->implVendors_end());
   break;
-case OMP_CTX_SET_device:
-  switch (Ctx) {
-  case OMP_CTX_kind:
-Data.back().Names =
-llvm::makeArrayRef(A->deviceKinds_begin(), A->deviceKinds_end());
-break;
-  case OMP_CTX_vendor:
-  case OMP_CTX_unknown:
-llvm_unreachable("Unexpected context selector kind in device set.");
-  }
+case OMP_CTX_kind:
+  assert(CtxSet == OMP_CTX_SET_device &&
+ "Expected device context selector set.");
+  Data.back().Names =
+  llvm::makeArrayRef(A->deviceKinds_begin(), A->deviceKinds_end());
   break;
-case OMP_CTX_SET_unknown:
-  llvm_unreachable("Unexpected context selector set kind.");
+case OMP_CTX_unknown:
+  llvm_unreachable("Unknown context selector kind.");
 }
   }
   return Data;

diff  --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp
index 53840d400164..59178fb671fb 100644
--- a/clang/lib/Sema/SemaOpenMP.cpp
+++ b/clang/lib/Sema/SemaOpenMP.cpp
@@ -5404,29 +5404,19 @@ void Sema::ActOnOpenMPDeclareVariantDirective(
   else
 Score = ActOnIntegerConstant(SourceLocation(), 0).get();
 }
-switch (CtxSet) {
-case OMP_CTX_SET_implementation:
-  switch (Ctx) {
-  case OMP_CTX_vendor:
-ImplVendors.append(D.Names.begin(), D.Names.end());
-break;
-  case OMP_CTX_kind:
-  case OMP_CTX_unknown:
-llvm_unreachable("Unexpected context selector kind.");
-  }
+switch (Ctx) {
+case OMP_CTX_vendor:
+  assert(CtxSet == OMP_CTX_SET_implementation &&
+ "Expected implementation context selector set.");
+  ImplVendors.append(D.Names.begin(), D.Names.end());
   

[PATCH] D70368: [clang-tidy] Rewrite modernize-avoid-bind check

2019-11-22 Thread Zachary Turner via Phabricator via cfe-commits
zturner updated this revision to Diff 230661.
zturner added a comment.

Addressed suggestions from @Eugene.Zelenko


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

https://reviews.llvm.org/D70368

Files:
  clang-tools-extra/clang-tidy/modernize/AvoidBindCheck.cpp
  clang-tools-extra/clang-tidy/modernize/AvoidBindCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/modernize-avoid-bind.rst
  
clang-tools-extra/test/clang-tidy/checkers/modernize-avoid-bind-permissive-parameter-list.cpp
  clang-tools-extra/test/clang-tidy/checkers/modernize-avoid-bind.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/modernize-avoid-bind.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/modernize-avoid-bind.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/modernize-avoid-bind.cpp
@@ -8,75 +8,62 @@
 template 
 bind_rt bind(Fp &&, Arguments &&...);
 }
+
+template 
+T ref(T );
 }
 
-int add(int x, int y) { return x + y; }
+namespace boost {
+template 
+class bind_rt {};
 
-void f() {
-  auto clj = std::bind(add, 2, 2);
-  // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: prefer a lambda to std::bind [modernize-avoid-bind]
-  // CHECK-FIXES: auto clj = [] { return add(2, 2); };
-}
+template 
+bind_rt bind(const Fp &, Arguments...);
 
-void g() {
-  int x = 2;
-  int y = 2;
-  auto clj = std::bind(add, x, y);
-  // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: prefer a lambda to std::bind
-  // CHECK-FIXES: auto clj = [=] { return add(x, y); };
+template 
+struct reference_wrapper {
+  explicit reference_wrapper(T ) {}
+};
+
+template 
+reference_wrapper const ref(T ) {
+  return reference_wrapper(t);
 }
 
-struct placeholder {};
-placeholder _1;
-placeholder _2;
+} // namespace boost
 
-void h() {
-  int x = 2;
-  auto clj = std::bind(add, x, _1);
-  // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: prefer a lambda to std::bind
-  // CHECK-FIXES: auto clj = [=](auto && arg1) { return add(x, arg1); };
-}
+namespace C {
+int add(int x, int y) { return x + y; }
+} // namespace C
 
-struct A;
-struct B;
-bool ABTest(const A &, const B &);
+struct Foo {
+  static int add(int x, int y) { return x + y; }
+};
 
-void i() {
-  auto BATest = std::bind(ABTest, _2, _1);
-  // CHECK-MESSAGES: :[[@LINE-1]]:17: warning: prefer a lambda to std::bind
-  // CHECK-FIXES: auto BATest = [](auto && arg1, auto && arg2) { return ABTest(arg2, arg1); };
-}
+struct D {
+  D() = default;
+  void operator()(int x, int y) const {}
 
-void j() {
-  auto clj = std::bind(add, 2, 2, 2);
-  // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: prefer a lambda to std::bind
-  // No fix is applied for argument mismatches.
-  // CHECK-FIXES: auto clj = std::bind(add, 2, 2, 2);
-}
+  void MemberFunction(int x) {}
 
-void k() {
-  auto clj = std::bind(add, _1, _1);
-  // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: prefer a lambda to std::bind
-  // No fix is applied for reused placeholders.
-  // CHECK-FIXES: auto clj = std::bind(add, _1, _1);
-}
+  static D *create();
+};
 
-void m() {
-  auto clj = std::bind(add, 1, add(2, 5));
-  // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: prefer a lambda to std::bind
-  // No fix is applied for nested calls.
-  // CHECK-FIXES: auto clj = std::bind(add, 1, add(2, 5));
-}
+struct F {
+  F(int x) {}
+  ~F() {}
 
-namespace C {
-  int add(int x, int y){ return x + y; }
-}
+  int get() { return 42; }
+};
 
-void n() {
-  auto clj = std::bind(C::add, 1, 1);
-  // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: prefer a lambda to std::bind
-  // CHECK-FIXES: auto clj = [] { return C::add(1, 1); };
-}
+void UseF(F);
+
+struct placeholder {};
+placeholder _1;
+placeholder _2;
+
+int add(int x, int y) { return x + y; }
+int addThree(int x, int y, int z) { return x + y + z; }
 
 // Let's fake a minimal std::function-like facility.
 namespace std {
@@ -114,10 +101,213 @@
   void Reset(std::function);
 };
 
-void test(Thing *t) {
+int GlobalVariable = 42;
+
+struct TestCaptureByValueStruct {
+  int MemberVariable;
+  static int StaticMemberVariable;
+  F MemberStruct;
+
+  void testCaptureByValue(int Param, F f) {
+int x = 3;
+int y = 4;
+auto AAA = std::bind(add, x, y);
+// CHECK-MESSAGES: :[[@LINE-1]]:16: warning: prefer a lambda to std::bind [modernize-avoid-bind]
+// CHECK-FIXES: auto AAA = [x, y] { return add(x, y); };
+
+// When the captured variable is repeated, it should only appear in the capture list once.
+auto BBB = std::bind(add, x, x);
+// CHECK-MESSAGES: :[[@LINE-1]]:16: warning: prefer a lambda to std::bind [modernize-avoid-bind]
+// CHECK-FIXES: auto BBB = [x] { return add(x, x); };
+
+int LocalVariable;
+// Global variables shouldn't be captured at all, and members should be captured through this.
+auto CCC = std::bind(add, MemberVariable, GlobalVariable);
+// CHECK-MESSAGES: :[[@LINE-1]]:16: warning: prefer a lambda to std::bind [modernize-avoid-bind]
+// 

[PATCH] D70524: Support DebugInfo generation for auto return type for C++ functions.

2019-11-22 Thread Paul Robinson via Phabricator via cfe-commits
probinson added inline comments.



Comment at: llvm/test/DebugInfo/X86/debug-info-auto-return.ll:30
+; CHECK:  DW_TAG_subprogram [7] *
+; CHECK-NEXT: DW_AT_linkage_name [DW_FORM_strx1](indexed (0007) string 
= "_ZN7myClass7findMaxEv")
+; CHECK: DW_AT_type [DW_FORM_ref4] {{.*}} "auto"

No need to over-specify this (form/index etc) as those details can change over 
time and aren't relevant to the test.  Sufficient to check
`DW_AT_linkage_name {{.*}} "_ZN7myClass7findMaxEv"`



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

https://reviews.llvm.org/D70524



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


[PATCH] D69022: [coroutines] Remove assert on CoroutineParameterMoves in Sema::buildCoroutineParameterMoves

2019-11-22 Thread Brian Gesiak via Phabricator via cfe-commits
modocache added a comment.

Thanks again for the patch @junparser! And sorry the review took so long!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69022



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


[PATCH] D69022: [coroutines] Remove assert on CoroutineParameterMoves in Sema::buildCoroutineParameterMoves

2019-11-22 Thread Brian Gesiak via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG0b3d1d1348da: [coroutines] Remove assert on 
CoroutineParameterMoves in Sema… (authored by modocache).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69022

Files:
  clang/lib/Sema/SemaCoroutine.cpp
  clang/test/SemaCXX/coroutines.cpp


Index: clang/test/SemaCXX/coroutines.cpp
===
--- clang/test/SemaCXX/coroutines.cpp
+++ clang/test/SemaCXX/coroutines.cpp
@@ -87,6 +87,11 @@
   co_await a;
 }
 
+int no_promise_type_multiple_awaits(int) { // expected-error {{this function 
cannot be a coroutine: 'std::experimental::coroutine_traits' has no 
member named 'promise_type'}}
+  co_await a;
+  co_await a;
+}
+
 template <>
 struct std::experimental::coroutine_traits { typedef int 
promise_type; };
 double bad_promise_type(double) { // expected-error {{this function cannot be 
a coroutine: 'experimental::coroutine_traits::promise_type' 
(aka 'int') is not a class}}
Index: clang/lib/Sema/SemaCoroutine.cpp
===
--- clang/lib/Sema/SemaCoroutine.cpp
+++ clang/lib/Sema/SemaCoroutine.cpp
@@ -1527,8 +1527,8 @@
   auto *FD = cast(CurContext);
 
   auto *ScopeInfo = getCurFunction();
-  assert(ScopeInfo->CoroutineParameterMoves.empty() &&
- "Should not build parameter moves twice");
+  if (!ScopeInfo->CoroutineParameterMoves.empty())
+return false;
 
   for (auto *PD : FD->parameters()) {
 if (PD->getType()->isDependentType())


Index: clang/test/SemaCXX/coroutines.cpp
===
--- clang/test/SemaCXX/coroutines.cpp
+++ clang/test/SemaCXX/coroutines.cpp
@@ -87,6 +87,11 @@
   co_await a;
 }
 
+int no_promise_type_multiple_awaits(int) { // expected-error {{this function cannot be a coroutine: 'std::experimental::coroutine_traits' has no member named 'promise_type'}}
+  co_await a;
+  co_await a;
+}
+
 template <>
 struct std::experimental::coroutine_traits { typedef int promise_type; };
 double bad_promise_type(double) { // expected-error {{this function cannot be a coroutine: 'experimental::coroutine_traits::promise_type' (aka 'int') is not a class}}
Index: clang/lib/Sema/SemaCoroutine.cpp
===
--- clang/lib/Sema/SemaCoroutine.cpp
+++ clang/lib/Sema/SemaCoroutine.cpp
@@ -1527,8 +1527,8 @@
   auto *FD = cast(CurContext);
 
   auto *ScopeInfo = getCurFunction();
-  assert(ScopeInfo->CoroutineParameterMoves.empty() &&
- "Should not build parameter moves twice");
+  if (!ScopeInfo->CoroutineParameterMoves.empty())
+return false;
 
   for (auto *PD : FD->parameters()) {
 if (PD->getType()->isDependentType())
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 0b3d1d1 - [coroutines] Remove assert on CoroutineParameterMoves in Sema::buildCoroutineParameterMoves

2019-11-22 Thread Brian Gesiak via cfe-commits

Author: Brian Gesiak
Date: 2019-11-22T11:39:13-05:00
New Revision: 0b3d1d1348da78c8b12e89f138577b0a8ffd4b2f

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

LOG: [coroutines] Remove assert on CoroutineParameterMoves in 
Sema::buildCoroutineParameterMoves

Summary:
The assertion of CoroutineParameterMoves happens when build coroutine function 
with arguments  multiple time while fails to build promise type.

Fix: use return false instead.

Test Plan: check-clang

Reviewers: modocache, GorNishanov, rjmccall

Reviewed By: modocache

Subscribers: rjmccall, EricWF, cfe-commits

Tags: #clang

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

Patch by junparser (JunMa)!

Added: 


Modified: 
clang/lib/Sema/SemaCoroutine.cpp
clang/test/SemaCXX/coroutines.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaCoroutine.cpp 
b/clang/lib/Sema/SemaCoroutine.cpp
index 7c125e999d00..271c4a10f3e4 100644
--- a/clang/lib/Sema/SemaCoroutine.cpp
+++ b/clang/lib/Sema/SemaCoroutine.cpp
@@ -1527,8 +1527,8 @@ bool Sema::buildCoroutineParameterMoves(SourceLocation 
Loc) {
   auto *FD = cast(CurContext);
 
   auto *ScopeInfo = getCurFunction();
-  assert(ScopeInfo->CoroutineParameterMoves.empty() &&
- "Should not build parameter moves twice");
+  if (!ScopeInfo->CoroutineParameterMoves.empty())
+return false;
 
   for (auto *PD : FD->parameters()) {
 if (PD->getType()->isDependentType())

diff  --git a/clang/test/SemaCXX/coroutines.cpp 
b/clang/test/SemaCXX/coroutines.cpp
index c8de7b017859..677c6e6ff8d2 100644
--- a/clang/test/SemaCXX/coroutines.cpp
+++ b/clang/test/SemaCXX/coroutines.cpp
@@ -87,6 +87,11 @@ int no_promise_type() { // expected-error {{this function 
cannot be a coroutine:
   co_await a;
 }
 
+int no_promise_type_multiple_awaits(int) { // expected-error {{this function 
cannot be a coroutine: 'std::experimental::coroutine_traits' has no 
member named 'promise_type'}}
+  co_await a;
+  co_await a;
+}
+
 template <>
 struct std::experimental::coroutine_traits { typedef int 
promise_type; };
 double bad_promise_type(double) { // expected-error {{this function cannot be 
a coroutine: 'experimental::coroutine_traits::promise_type' 
(aka 'int') is not a class}}



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


[PATCH] D70524: Support DebugInfo generation for auto return type for C++ functions.

2019-11-22 Thread Adrian Prantl via Phabricator via cfe-commits
aprantl added inline comments.



Comment at: clang/lib/CodeGen/CGDebugInfo.cpp:2925
+return C.getQualifiedType(T.getTypePtr(), Quals);
+  }
 case Type::DeducedTemplateSpecialization: {

You need to mark this `LLVM_FALLTHROUGH` now or you'll get a warning.



Comment at: clang/lib/CodeGen/CGDebugInfo.cpp:3104
   case Type::Auto:
+if (CGM.getCodeGenOpts().DwarfVersion >= 5) {
+  return CreateType(cast(Ty));

LLVM coding style doesn't put single statements into `{}`



Comment at: clang/lib/CodeGen/CGDebugInfo.cpp:3106
+  return CreateType(cast(Ty));
+}
   case Type::Attributed:

same here



Comment at: clang/test/CodeGenCXX/debug-info-auto-return.cpp:7
+
+// CHECK: !DISubprogram(name: "findMax",{{.*}}, type: !18
+// CHECK: !18 =  !DISubroutineType(types: !19)

Please don't hardcode the MDNode numbers, they will inevitably change over 
time. Instead use variables:
```
type: ![[SUBROUTINE_TYPE:[0-9]+]]`
// CHECK: ![[SUBROUTINE_TYPE]] =  !DISubroutineType(types: ![[ARGS:[0-9]+)
```
etc


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

https://reviews.llvm.org/D70524



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


[clang] 6f7c876 - [OPENMP]Fix behaviour of defaultmap for OpenMP 4.5.

2019-11-22 Thread Alexey Bataev via cfe-commits

Author: Alexey Bataev
Date: 2019-11-22T11:26:09-05:00
New Revision: 6f7c8760a5c01edaa8e9c8e48940e1b8a7aa4128

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

LOG: [OPENMP]Fix behaviour of defaultmap for OpenMP 4.5.

In OpenMP 4.5 pointers also must be considered as scalar types and
defaultmap(tofrom:scalar) clause must affect mapping of the pointers
too.

Added: 


Modified: 
clang/lib/Sema/SemaOpenMP.cpp
clang/test/OpenMP/target_map_codegen.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp
index 45cac595004f..53840d400164 100644
--- a/clang/lib/Sema/SemaOpenMP.cpp
+++ b/clang/lib/Sema/SemaOpenMP.cpp
@@ -1763,7 +1763,12 @@ void Sema::checkOpenMPDeviceExpr(const Expr *E) {
 }
 
 static OpenMPDefaultmapClauseKind
-getVariableCategoryFromDecl(const ValueDecl *VD) {
+getVariableCategoryFromDecl(const LangOptions , const ValueDecl *VD) {
+  if (LO.OpenMP <= 45) {
+if (VD->getType().getNonReferenceType()->isScalarType())
+  return OMPC_DEFAULTMAP_scalar;
+return OMPC_DEFAULTMAP_aggregate;
+  }
   if (VD->getType().getNonReferenceType()->isAnyPointerType())
 return OMPC_DEFAULTMAP_pointer;
   if (VD->getType().getNonReferenceType()->isScalarType())
@@ -1894,8 +1899,8 @@ bool Sema::isOpenMPCapturedByRef(const ValueDecl *D, 
unsigned Level,
   (DSAStack->isForceCaptureByReferenceInTargetExecutable() &&
!Ty->isAnyPointerType()) ||
   !Ty->isScalarType() ||
-  DSAStack->isDefaultmapCapturedByRef(Level,
-  getVariableCategoryFromDecl(D)) 
||
+  DSAStack->isDefaultmapCapturedByRef(
+  Level, getVariableCategoryFromDecl(LangOpts, D)) ||
   DSAStack->hasExplicitDSA(
   D, [](OpenMPClauseKind K) { return K == OMPC_reduction; }, 
Level);
 }
@@ -2112,8 +2117,8 @@ void Sema::setOpenMPCaptureKind(FieldDecl *FD, const 
ValueDecl *D,
 if (DSAStack->hasExplicitDirective(isOpenMPTargetExecutionDirective,
NewLevel)) {
   OMPC = OMPC_map;
-  if (DSAStack->mustBeFirstprivateAtLevel(NewLevel,
-  getVariableCategoryFromDecl(D)))
+  if (DSAStack->mustBeFirstprivateAtLevel(
+  NewLevel, getVariableCategoryFromDecl(LangOpts, D)))
 OMPC = OMPC_firstprivate;
   break;
 }
@@ -2944,7 +2949,8 @@ class DSAAttrChecker final : public 
StmtVisitor {
   // data-haring attribute clause (including a data-sharing attribute
   // clause on a combined construct where target. is one of the
   // constituent constructs), or an is_device_ptr clause.
-  OpenMPDefaultmapClauseKind ClauseKind = getVariableCategoryFromDecl(VD);
+  OpenMPDefaultmapClauseKind ClauseKind =
+  getVariableCategoryFromDecl(SemaRef.getLangOpts(), VD);
   if (SemaRef.getLangOpts().OpenMP >= 50) {
 bool IsModifierNone = Stack->getDefaultmapModifier(ClauseKind) ==
   OMPC_DEFAULTMAP_MODIFIER_none;

diff  --git a/clang/test/OpenMP/target_map_codegen.cpp 
b/clang/test/OpenMP/target_map_codegen.cpp
index 0a8198a90417..cd1b5e49174e 100644
--- a/clang/test/OpenMP/target_map_codegen.cpp
+++ b/clang/test/OpenMP/target_map_codegen.cpp
@@ -656,15 +656,15 @@ void implicit_maps_pointer (){
 
 // CK11-LABEL: 
@.__omp_offloading_{{.*}}implicit_maps_double_complex{{.*}}_l678.region_id = 
weak constant i8 0
 
-// CK11-DAG: [[SIZES:@.+]] = {{.+}}constant [1 x i64] [i64 16]
+// CK11-DAG: [[SIZES:@.+]] = {{.+}}constant [2 x i64] [i64 16, i64 {{8|4}}]
 // Map types: OMP_MAP_TO  | OMP_MAP_FROM | OMP_MAP_TARGET_PARAM | 
OMP_MAP_IMPLICIT = 547
-// CK11-DAG: [[TYPES:@.+]] = {{.+}}constant [1 x i64] [i64 547]
+// CK11-DAG: [[TYPES:@.+]] = {{.+}}constant [2 x i64] [i64 547, i64 547]
 
 // CK11-LABEL: implicit_maps_double_complex{{.*}}(
-void implicit_maps_double_complex (int a){
+void implicit_maps_double_complex (int a, int *b){
   double _Complex dc = (double)a;
 
-  // CK11-DAG: call i32 @__tgt_target(i64 {{.+}}, i8* {{.+}}, i32 1, i8** 
[[BPGEP:%[0-9]+]], i8** [[PGEP:%[0-9]+]], {{.+}}[[SIZES]]{{.+}}, 
{{.+}}[[TYPES]]{{.+}})
+  // CK11-DAG: call i32 @__tgt_target(i64 {{.+}}, i8* {{.+}}, i32 2, i8** 
[[BPGEP:%[0-9]+]], i8** [[PGEP:%[0-9]+]], {{.+}}[[SIZES]]{{.+}}, 
{{.+}}[[TYPES]]{{.+}})
   // CK11-DAG: [[BPGEP]] = getelementptr inbounds {{.+}}[[BPS:%[^,]+]], i32 0, 
i32 0
   // CK11-DAG: [[PGEP]] = getelementptr inbounds {{.+}}[[PS:%[^,]+]], i32 0, 
i32 0
   // CK11-DAG: [[BP1:%.+]] = getelementptr inbounds {{.+}}[[BPS]], i32 0, i32 0
@@ -674,14 +674,14 @@ void implicit_maps_double_complex (int a){
   // CK11-DAG: store { double, double }* [[PTR:%[^,]+]], { double, double }** 
[[CBP1]]
   // 

[PATCH] D62574: Initial draft of target-configurable address spaces.

2019-11-22 Thread Bevin Hansson via Phabricator via cfe-commits
ebevhan marked 2 inline comments as done.
ebevhan added a comment.

Sorry for the very late response on this. Hope it's not completely off your 
radar.




Comment at: include/clang/AST/ASTContext.h:2598
+  /// Returns true if address space A overlaps with B.
+  bool isAddressSpaceOverlapping(LangAS A, LangAS B) const {
+// A overlaps with B if either is a superset of the other.

Anastasia wrote:
> ebevhan wrote:
> > Anastasia wrote:
> > > ebevhan wrote:
> > > > Anastasia wrote:
> > > > > Is there any advantage of keeping superset concept? Amd if 
> > > > > yes, how do we position the new functionality with explicit cast?
> > > > > 
> > > > > I think I am missing a bit conceptual view... because I think we 
> > > > > originally discussed to switch to implicit/explicit conversion model. 
> > > > > Perhaps there is no reason to do it but I would just like to 
> > > > > understand why? 
> > > > Yes, I know the original discussion was regarding the implicit/explicit 
> > > > model, but I came to realize during the implementation that all that 
> > > > was needed to get the superspace model to work generically with the 
> > > > current behavior was an override on the explicit conversion.
> > > > 
> > > > The implicit/explicit model also has the drawback that it's a bit too 
> > > > expressive. You can express semantics that just don't really make 
> > > > sense, like permitting implicit conversion but not explicit conversion. 
> > > > The superspace model doesn't let you do that, and the additions I've 
> > > > made here still don't: If implicit conversion is allowed, explicit 
> > > > conversion must also be allowed. It just becomes possible to allow 
> > > > explicit conversion for ASes that don't overlap.
> > > > 
> > > > Since the superspace model is what OpenCL and Embedded-C use in their 
> > > > specification, it's probably better to use that anyway.
> > > > The implicit/explicit model also has the drawback that it's a bit too 
> > > > expressive. You can express semantics that just don't really make 
> > > > sense, like permitting implicit conversion but not explicit conversion. 
> > > > The superspace model doesn't let you do that, and the additions I've 
> > > > made here still don't: If implicit conversion is allowed, explicit 
> > > > conversion must also be allowed. It just becomes possible to allow 
> > > > explicit conversion for ASes that don't overlap.
> > > 
> > > Ok, I think we could define the new model something like - explicit 
> > > conversions are automatically allowed for all implicit conversions... 
> > > targets won't have to specify those but only extra comversions that are 
> > > not allowed implicitly. 
> > > 
> > > Just to understand in the current patch when are we supposed to use 
> > > `isAddressSpaceOverlapping` and when 
> > > `isExplicitAddrSpaceConversionLegal`. Can't we just always use 
> > > `isExplicitAddrSpaceConversionLegal`?
> > > 
> > > > 
> > > > Since the superspace model is what OpenCL and Embedded-C use in their 
> > > > specification, it's probably better to use that anyway.
> > > 
> > > I agree the advantage of following spec is really huge. However, Clang is 
> > > already broken for Emdedded C isn't it? Because it allows any explicit 
> > > conversions?
> > > 
> > > As for OpenCL it might be reasonable to provide new documentation if 
> > > needed as soon as the new rules don't invalidate all behavior.
> > > 
> > > 
> > > Ok, I think we could define the new model something like - explicit 
> > > conversions are automatically allowed for all implicit conversions... 
> > > targets won't have to specify those but only extra comversions that are 
> > > not allowed implicitly.
> > 
> > Yes, this is how it's defined. Converting explicitly between two ASes where 
> > either one is a superset of the other is always legal.
> > 
> > > Just to understand in the current patch when are we supposed to use 
> > > isAddressSpaceOverlapping and when isExplicitAddrSpaceConversionLegal. 
> > > Can't we just always use isExplicitAddrSpaceConversionLegal?
> > 
> > I guess the distinction between `isAddressSpaceOverlapping` and 
> > `isExplicitAddrSpaceConversionLegal` is pretty subtle. You would want the 
> > former when you need to know if **implicit conversion A->B or B->A** is 
> > permitted, and the latter when you need to know if **explicit conversion 
> > A->B** is permitted.
> > 
> > Though in most cases, I think the latter is probably the most common.
> > 
> > > I agree the advantage of following spec is really huge. However, Clang is 
> > > already broken for Emdedded C isn't it? Because it allows any explicit 
> > > conversions?
> > 
> > No, the current behavior of permitting all explicit conversions is 
> > according to spec: "A non-null pointer into an address space A can be cast 
> > to a pointer into another address space B, but such a cast is undefined if 
> > the source pointer does not point to a location in B." The addition 

[clang] 26fa9e3 - Add support to find out resource dir and add it as compilation args

2019-11-22 Thread Kousik Kumar via cfe-commits

Author: Kousik Kumar
Date: 2019-11-22T07:43:54-08:00
New Revision: 26fa9e31f58a7ff693f3a5d8c2eb1b6a5a13b133

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

LOG: Add support to find out resource dir and add it as compilation args

Summary:
If -resource-dir is not specified as part of the compilation command, then by 
default
clang-scan-deps picks up a directory relative to its own path as 
resource-directory.
This is probably not the right behavior - since resource directory should be 
picked relative
to the path of the clang-compiler in the compilation command.
This patch adds support for it along with a cache to store the resource-dir 
paths based on
compiler paths.

Notes:
1. "-resource-dir" is a behavior that's specific to clang, gcc does not have 
that flag. That's why if I'm not able to find a resource-dir, I quietly ignore 
it.
2. Should I also use the mtime of the compiler in the cache? I think its not 
strictly necessary since we assume the filesystem is immutable.
3. From my testing, this does not regress performance.
4. Will try to get this tested on Windows.

But basically the problem that this patch is trying to solve is, clients might 
not always want to specify
"-resource-dir" in their compile commands, so scan-deps must auto-infer it 
correctly.

Reviewers: arphaman, Bigcheese, jkorous, dexonsmith, klimek

Reviewed By: Bigcheese

Subscribers: MaskRay, cfe-commits

Tags: #clang

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

Added: 


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

Removed: 




diff  --git a/clang/tools/clang-scan-deps/ClangScanDeps.cpp 
b/clang/tools/clang-scan-deps/ClangScanDeps.cpp
index bd463cbdeee9..1294e6682841 100644
--- a/clang/tools/clang-scan-deps/ClangScanDeps.cpp
+++ b/clang/tools/clang-scan-deps/ClangScanDeps.cpp
@@ -13,6 +13,7 @@
 #include "clang/Tooling/DependencyScanning/DependencyScanningWorker.h"
 #include "clang/Tooling/JSONCompilationDatabase.h"
 #include "llvm/Support/CommandLine.h"
+#include "llvm/Support/FileUtilities.h"
 #include "llvm/Support/InitLLVM.h"
 #include "llvm/Support/Program.h"
 #include "llvm/Support/Signals.h"
@@ -39,6 +40,64 @@ class SharedStream {
   raw_ostream 
 };
 
+class ResourceDirectoryCache {
+public:
+  /// findResourceDir finds the resource directory relative to the clang
+  /// compiler being used in Args, by running it with "-print-resource-dir"
+  /// option and cache the results for reuse. \returns resource directory path
+  /// associated with the given invocation command or empty string if the
+  /// compiler path is NOT an absolute path.
+  StringRef findResourceDir(const tooling::CommandLineArguments ) {
+if (Args.size() < 1)
+  return "";
+
+const std::string  = Args[0];
+if (!llvm::sys::path::is_absolute(ClangBinaryPath))
+  return "";
+
+const std::string  =
+llvm::sys::path::filename(ClangBinaryPath);
+
+std::unique_lock LockGuard(CacheLock);
+const auto  = Cache.find(ClangBinaryPath);
+if (CachedResourceDir != Cache.end())
+  return CachedResourceDir->second;
+
+std::vector PrintResourceDirArgs{ClangBinaryName,
+"-print-resource-dir"};
+llvm::SmallString<64> OutputFile, ErrorFile;
+llvm::sys::fs::createTemporaryFile("print-resource-dir-output",
+   "" /*no-suffix*/, OutputFile);
+llvm::sys::fs::createTemporaryFile("print-resource-dir-error",
+   "" /*no-suffix*/, ErrorFile);
+llvm::FileRemover OutputRemover(OutputFile.c_str());
+llvm::FileRemover ErrorRemover(ErrorFile.c_str());
+llvm::Optional Redirects[] = {
+{""}, // Stdin
+StringRef(OutputFile),
+StringRef(ErrorFile),
+};
+if (const int RC = llvm::sys::ExecuteAndWait(
+ClangBinaryPath, PrintResourceDirArgs, {}, Redirects)) {
+  auto ErrorBuf = llvm::MemoryBuffer::getFile(ErrorFile.c_str());
+  llvm::errs() << ErrorBuf.get()->getBuffer();
+  return "";
+}
+
+auto OutputBuf = llvm::MemoryBuffer::getFile(OutputFile.c_str());
+if (!OutputBuf)
+  return "";
+StringRef Output = OutputBuf.get()->getBuffer().rtrim('\n');
+
+Cache[ClangBinaryPath] = Output.str();
+return Cache[ClangBinaryPath];
+  }
+
+private:
+  std::map Cache;
+  std::mutex CacheLock;
+};
+
 llvm::cl::opt Help("h", llvm::cl::desc("Alias for -help"),
  llvm::cl::Hidden);
 
@@ -169,12 +228,15 @@ int main(int argc, const char **argv) {
   auto AdjustingCompilations =
   std::make_unique(
   std::move(Compilations));
+  ResourceDirectoryCache ResourceDirCache;
   AdjustingCompilations->appendArgumentsAdjuster(
-  [](const 

[PATCH] D69122: Add support to find out resource dir and add it as compilation args

2019-11-22 Thread Kousik Kumar via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG26fa9e31f58a: Add support to find out resource dir and add 
it as compilation args (authored by kousikk).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69122

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

Index: clang/tools/clang-scan-deps/ClangScanDeps.cpp
===
--- clang/tools/clang-scan-deps/ClangScanDeps.cpp
+++ clang/tools/clang-scan-deps/ClangScanDeps.cpp
@@ -13,6 +13,7 @@
 #include "clang/Tooling/DependencyScanning/DependencyScanningWorker.h"
 #include "clang/Tooling/JSONCompilationDatabase.h"
 #include "llvm/Support/CommandLine.h"
+#include "llvm/Support/FileUtilities.h"
 #include "llvm/Support/InitLLVM.h"
 #include "llvm/Support/Program.h"
 #include "llvm/Support/Signals.h"
@@ -39,6 +40,64 @@
   raw_ostream 
 };
 
+class ResourceDirectoryCache {
+public:
+  /// findResourceDir finds the resource directory relative to the clang
+  /// compiler being used in Args, by running it with "-print-resource-dir"
+  /// option and cache the results for reuse. \returns resource directory path
+  /// associated with the given invocation command or empty string if the
+  /// compiler path is NOT an absolute path.
+  StringRef findResourceDir(const tooling::CommandLineArguments ) {
+if (Args.size() < 1)
+  return "";
+
+const std::string  = Args[0];
+if (!llvm::sys::path::is_absolute(ClangBinaryPath))
+  return "";
+
+const std::string  =
+llvm::sys::path::filename(ClangBinaryPath);
+
+std::unique_lock LockGuard(CacheLock);
+const auto  = Cache.find(ClangBinaryPath);
+if (CachedResourceDir != Cache.end())
+  return CachedResourceDir->second;
+
+std::vector PrintResourceDirArgs{ClangBinaryName,
+"-print-resource-dir"};
+llvm::SmallString<64> OutputFile, ErrorFile;
+llvm::sys::fs::createTemporaryFile("print-resource-dir-output",
+   "" /*no-suffix*/, OutputFile);
+llvm::sys::fs::createTemporaryFile("print-resource-dir-error",
+   "" /*no-suffix*/, ErrorFile);
+llvm::FileRemover OutputRemover(OutputFile.c_str());
+llvm::FileRemover ErrorRemover(ErrorFile.c_str());
+llvm::Optional Redirects[] = {
+{""}, // Stdin
+StringRef(OutputFile),
+StringRef(ErrorFile),
+};
+if (const int RC = llvm::sys::ExecuteAndWait(
+ClangBinaryPath, PrintResourceDirArgs, {}, Redirects)) {
+  auto ErrorBuf = llvm::MemoryBuffer::getFile(ErrorFile.c_str());
+  llvm::errs() << ErrorBuf.get()->getBuffer();
+  return "";
+}
+
+auto OutputBuf = llvm::MemoryBuffer::getFile(OutputFile.c_str());
+if (!OutputBuf)
+  return "";
+StringRef Output = OutputBuf.get()->getBuffer().rtrim('\n');
+
+Cache[ClangBinaryPath] = Output.str();
+return Cache[ClangBinaryPath];
+  }
+
+private:
+  std::map Cache;
+  std::mutex CacheLock;
+};
+
 llvm::cl::opt Help("h", llvm::cl::desc("Alias for -help"),
  llvm::cl::Hidden);
 
@@ -169,12 +228,15 @@
   auto AdjustingCompilations =
   std::make_unique(
   std::move(Compilations));
+  ResourceDirectoryCache ResourceDirCache;
   AdjustingCompilations->appendArgumentsAdjuster(
-  [](const tooling::CommandLineArguments , StringRef FileName) {
+  [](const tooling::CommandLineArguments ,
+  StringRef FileName) {
 std::string LastO = "";
 bool HasMT = false;
 bool HasMQ = false;
 bool HasMD = false;
+bool HasResourceDir = false;
 // We need to find the last -o value.
 if (!Args.empty()) {
   std::size_t Idx = Args.size() - 1;
@@ -188,6 +250,8 @@
 HasMQ = true;
   if (Args[Idx] == "-MD")
 HasMD = true;
+  if (Args[Idx] == "-resource-dir")
+HasResourceDir = true;
 }
 --Idx;
   }
@@ -215,6 +279,15 @@
 AdjustedArgs.push_back("-Xclang");
 AdjustedArgs.push_back("-sys-header-deps");
 AdjustedArgs.push_back("-Wno-error");
+
+if (!HasResourceDir) {
+  StringRef ResourceDir =
+  ResourceDirCache.findResourceDir(Args);
+  if (!ResourceDir.empty()) {
+AdjustedArgs.push_back("-resource-dir");
+AdjustedArgs.push_back(ResourceDir);
+  }
+}
 return AdjustedArgs;
   });
   AdjustingCompilations->appendArgumentsAdjuster(
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D70485: [ARM,MVE] Add intrinsics to deal with predicates.

2019-11-22 Thread Dave Green via Phabricator via cfe-commits
dmgreen accepted this revision.
dmgreen added a comment.

Thanks. I'm still happy.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70485



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


[PATCH] D69475: [clang] Provide better fix-it on exception spec error

2019-11-22 Thread Jeremy Demeule via Phabricator via cfe-commits
jdemeule added a comment.

Kindly ping reviewer.


Repository:
  rC Clang

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

https://reviews.llvm.org/D69475



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


[PATCH] D69282: [RFC] Add a VCS conflict marker format printing on tooling::ReplacementError

2019-11-22 Thread Jeremy Demeule via Phabricator via cfe-commits
jdemeule added a reviewer: ioeric.
jdemeule added a comment.

Kindly ping reviewers and adding Eric as you were interested last year about 
that.


Repository:
  rC Clang

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

https://reviews.llvm.org/D69282



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


[PATCH] D70554: [libTooling] Add stencil combinators for nodes that may be pointers or values.

2019-11-22 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr2 marked an inline comment as done.
gribozavr2 added inline comments.



Comment at: clang/include/clang/Tooling/Transformer/Stencil.h:96
+// Constructs an expression that idiomatically represents a value, taking into
+// account whether `ExprId` is a pointer or already a value.
+Stencil asValue(llvm::StringRef ExprId);

ymandel wrote:
> gribozavr2 wrote:
> > Need more explanation to cover the cases when the expression is a pointer 
> > to a pointer (do we deref once or twice?), or a smart pointer (do we take 
> > care of that at all?)
> > 
> > WDYT about calling it `maybeDeref()` or `derefIfPointer()`?
> I went with maybe... Given that, I didn't elaborate on pointer-to-pointer 
> case because it never claims to result in a value. WDYT?
> 
> also, I kind of like derefIfPointer better, but addressOfIfValue just seemed 
> to clunky. So, went w/ maybe...
> Given that, I didn't elaborate on pointer-to-pointer case because it never 
> claims to result in a value. WDYT?

I think it is clear what happens with pointers to pointers given the current 
doc comment.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70554



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


[PATCH] D70554: [libTooling] Add stencil combinators for nodes that may be pointers or values.

2019-11-22 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr2 accepted this revision.
gribozavr2 added inline comments.



Comment at: clang/include/clang/Tooling/Transformer/Stencil.h:90
 
+/// If \p ExprId is of pointer type, constructs an idiomatic dereferencing of
+/// the expression bound to \p ExprId, including wrapping it in parentheses, if

"If the expression \p ExprId has pointer type ..."



Comment at: clang/include/clang/Tooling/Transformer/Stencil.h:101
 
+/// If \p ExprId is not a pointer type, constructs an expression that
+/// idiomatically takes the address of the expression bound to \p ExprId,

"If the expression \p ExprId is not a pointer, ..."


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70554



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


[PATCH] D70554: [libTooling] Add stencil combinators for nodes that may be pointers or values.

2019-11-22 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel updated this revision to Diff 230646.
ymandel added a comment.

renamed combinators; reordered cases to pair x and maybeX.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70554

Files:
  clang/include/clang/Tooling/Transformer/Stencil.h
  clang/lib/Tooling/Transformer/Stencil.cpp
  clang/unittests/Tooling/StencilTest.cpp

Index: clang/unittests/Tooling/StencilTest.cpp
===
--- clang/unittests/Tooling/StencilTest.cpp
+++ clang/unittests/Tooling/StencilTest.cpp
@@ -233,6 +233,46 @@
   testExpr(Id, "int *x; *x;", addressOf(Id), "x");
 }
 
+TEST_F(StencilTest, MaybeDerefValue) {
+  StringRef Id = "id";
+  testExpr(Id, "int x; x;", maybeDeref(Id), "x");
+}
+
+TEST_F(StencilTest, MaybeDerefPointer) {
+  StringRef Id = "id";
+  testExpr(Id, "int *x; x;", maybeDeref(Id), "*x");
+}
+
+TEST_F(StencilTest, MaybeDerefBinOp) {
+  StringRef Id = "id";
+  testExpr(Id, "int *x; x + 1;", maybeDeref(Id), "*(x + 1)");
+}
+
+TEST_F(StencilTest, MaybeDerefAddressExpr) {
+  StringRef Id = "id";
+  testExpr(Id, "int x; ", maybeDeref(Id), "x");
+}
+
+TEST_F(StencilTest, MaybeAddressOfPointer) {
+  StringRef Id = "id";
+  testExpr(Id, "int *x; x;", maybeAddressOf(Id), "x");
+}
+
+TEST_F(StencilTest, MaybeAddressOfValue) {
+  StringRef Id = "id";
+  testExpr(Id, "int x; x;", addressOf(Id), "");
+}
+
+TEST_F(StencilTest, MaybeAddressOfBinOp) {
+  StringRef Id = "id";
+  testExpr(Id, "int x; x + 1;", maybeAddressOf(Id), "&(x + 1)");
+}
+
+TEST_F(StencilTest, MaybeAddressOfDerefExpr) {
+  StringRef Id = "id";
+  testExpr(Id, "int *x; *x;", addressOf(Id), "x");
+}
+
 TEST_F(StencilTest, AccessOpValue) {
   StringRef Snippet = R"cc(
 S x;
Index: clang/lib/Tooling/Transformer/Stencil.cpp
===
--- clang/lib/Tooling/Transformer/Stencil.cpp
+++ clang/lib/Tooling/Transformer/Stencil.cpp
@@ -59,7 +59,9 @@
 enum class UnaryNodeOperator {
   Parens,
   Deref,
-  Address,
+  MaybeDeref,
+  AddressOf,
+  MaybeAddressOf,
 };
 
 // Generic container for stencil operations with a (single) node-id argument.
@@ -121,9 +123,15 @@
   case UnaryNodeOperator::Deref:
 OpName = "deref";
 break;
-  case UnaryNodeOperator::Address:
+  case UnaryNodeOperator::MaybeDeref:
+OpName = "maybeDeref";
+break;
+  case UnaryNodeOperator::AddressOf:
 OpName = "addressOf";
 break;
+  case UnaryNodeOperator::MaybeAddressOf:
+OpName = "maybeAddressOf";
+break;
   }
   return (OpName + "(\"" + Data.Id + "\")").str();
 }
@@ -191,7 +199,21 @@
   case UnaryNodeOperator::Deref:
 Source = tooling::buildDereference(*E, *Match.Context);
 break;
-  case UnaryNodeOperator::Address:
+  case UnaryNodeOperator::MaybeDeref:
+if (!E->getType()->isAnyPointerType()) {
+  *Result += tooling::getText(*E, *Match.Context);
+  return Error::success();
+}
+Source = tooling::buildDereference(*E, *Match.Context);
+break;
+  case UnaryNodeOperator::AddressOf:
+Source = tooling::buildAddressOf(*E, *Match.Context);
+break;
+  case UnaryNodeOperator::MaybeAddressOf:
+if (E->getType()->isAnyPointerType()) {
+  *Result += tooling::getText(*E, *Match.Context);
+  return Error::success();
+}
 Source = tooling::buildAddressOf(*E, *Match.Context);
 break;
   }
@@ -300,9 +322,19 @@
   UnaryNodeOperator::Deref, ExprId);
 }
 
+Stencil transformer::maybeDeref(llvm::StringRef ExprId) {
+  return std::make_shared>(
+  UnaryNodeOperator::MaybeDeref, ExprId);
+}
+
 Stencil transformer::addressOf(llvm::StringRef ExprId) {
   return std::make_shared>(
-  UnaryNodeOperator::Address, ExprId);
+  UnaryNodeOperator::AddressOf, ExprId);
+}
+
+Stencil transformer::maybeAddressOf(llvm::StringRef ExprId) {
+  return std::make_shared>(
+  UnaryNodeOperator::MaybeAddressOf, ExprId);
 }
 
 Stencil transformer::access(StringRef BaseId, Stencil Member) {
Index: clang/include/clang/Tooling/Transformer/Stencil.h
===
--- clang/include/clang/Tooling/Transformer/Stencil.h
+++ clang/include/clang/Tooling/Transformer/Stencil.h
@@ -87,11 +87,24 @@
 /// \p ExprId is wrapped in parentheses, if needed.
 Stencil deref(llvm::StringRef ExprId);
 
+/// If \p ExprId is of pointer type, constructs an idiomatic dereferencing of
+/// the expression bound to \p ExprId, including wrapping it in parentheses, if
+/// needed. Otherwise, generates the original expression source.
+/// FIXME: Identify smart points as pointer types.
+Stencil maybeDeref(llvm::StringRef ExprId);
+
 /// Constructs an expression that idiomatically takes the address of the
 /// expression bound to \p ExprId. \p ExprId is wrapped in parentheses, if
 /// needed.
 Stencil addressOf(llvm::StringRef ExprId);
 
+/// If \p ExprId is not a pointer type, constructs an expression that
+/// 

  1   2   >