[clang] c06e22f - [Driver] Exclude options::LinkerInput for GCC linking

2020-07-31 Thread Fangrui Song via cfe-commits

Author: Fangrui Song
Date: 2020-07-31T00:04:09-07:00
New Revision: c06e22fe07aa5eb8a9f8ce824cbab1bfe5a96581

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

LOG: [Driver] Exclude options::LinkerInput for GCC linking

options::LinkerInput options may get duplicated after 
6a75496836ea14bcfd2f4b59d35a1cad4ac58cee..

Added: 


Modified: 
clang/lib/Driver/ToolChains/Gnu.cpp
clang/test/Driver/gcc_forward.c

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Gnu.cpp 
b/clang/lib/Driver/ToolChains/Gnu.cpp
index 1806c14c395d..9ca674511dab 100644
--- a/clang/lib/Driver/ToolChains/Gnu.cpp
+++ b/clang/lib/Driver/ToolChains/Gnu.cpp
@@ -38,6 +38,9 @@ using tools::addMultilibFlag;
 using tools::addPathIfExists;
 
 static bool forwardToGCC(const Option &O) {
+  // LinkerInput options have been forwarded. Don't duplicate.
+  if (O.hasFlag(options::LinkerInput))
+return false;
   return O.matches(options::OPT_Link_Group) || O.hasFlag(options::LinkOption);
 }
 

diff  --git a/clang/test/Driver/gcc_forward.c b/clang/test/Driver/gcc_forward.c
index 9579d0d60d1c..a99944f8f533 100644
--- a/clang/test/Driver/gcc_forward.c
+++ b/clang/test/Driver/gcc_forward.c
@@ -1,7 +1,7 @@
 // RUN: %clang -### %s -target aarch64-none-elf \
-// RUN:   --coverage -fuse-ld=lld --ld-path=ld -nostdlib -r -rdynamic -static 
-static-pie \
+// RUN:   --coverage -e _start -fuse-ld=lld --ld-path=ld -nostdlib -r 
-rdynamic -static -static-pie \
 // RUN:   2>&1 | FileCheck --check-prefix=FORWARD %s
-// FORWARD: gcc{{[^"]*}}" "--coverage" "-fuse-ld=lld" "--ld-path=ld" 
"-nostdlib" "-r" "-rdynamic" "-static" "-static-pie"
+// FORWARD: gcc{{[^"]*}}" "--coverage" "-fuse-ld=lld" "--ld-path=ld" 
"-nostdlib" "-rdynamic" "-static" "-static-pie" "-o" "a.out" "{{.*}}.o" "-e" 
"_start" "-r"
 
 // Check that we don't try to forward -Xclang or -mlinker-version to GCC.
 // PR12920 -- Check also we may not forward W_Group options to GCC.



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


[PATCH] D84811: [clangd] Add an option to exclude symbols outside of project root from index

2020-07-31 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev updated this revision to Diff 282147.
kbobyrev added a comment.

Switch to `SymbolCollector::Options::FileFilter` that is even more
straightforward.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84811

Files:
  clang-tools-extra/clangd/indexer/IndexerMain.cpp


Index: clang-tools-extra/clangd/indexer/IndexerMain.cpp
===
--- clang-tools-extra/clangd/indexer/IndexerMain.cpp
+++ clang-tools-extra/clangd/indexer/IndexerMain.cpp
@@ -17,11 +17,15 @@
 #include "index/Symbol.h"
 #include "index/SymbolCollector.h"
 #include "support/Logger.h"
+#include "clang/Basic/SourceManager.h"
 #include "clang/Tooling/ArgumentsAdjusters.h"
 #include "clang/Tooling/CommonOptionsParser.h"
 #include "clang/Tooling/Execution.h"
 #include "clang/Tooling/Tooling.h"
+#include "llvm/ADT/SmallString.h"
+#include "llvm/ADT/StringRef.h"
 #include "llvm/Support/CommandLine.h"
+#include "llvm/Support/Path.h"
 #include "llvm/Support/Signals.h"
 
 namespace clang {
@@ -36,12 +40,34 @@
"binary RIFF format")),
llvm::cl::init(IndexFileFormat::RIFF));
 
+static llvm::cl::opt
+ProjectRoot("project-root",
+llvm::cl::desc("Filter out all symbols outside of this "
+   "directory. This is useful for remote index."),
+llvm::cl::Hidden);
+
 class IndexActionFactory : public tooling::FrontendActionFactory {
 public:
-  IndexActionFactory(IndexFileIn &Result) : Result(Result) {}
+  IndexActionFactory(IndexFileIn &Result, llvm::StringRef IndexRoot)
+  : Result(Result) {
+if (!IndexRoot.empty()) {
+  // Returns true if file should be indexed.
+  FileFilter = [&](const SourceManager &SM, FileID ID) {
+const FileEntry *Entry = SM.getFileEntryForID(ID);
+if (!Entry)
+  return false;
+llvm::SmallString<256> FilePath = Entry->tryGetRealPathName();
+// When replacing prefix it checks whether Path starts with OldPrefix.
+// NewPrefix doesn't matter in this case.
+return llvm::sys::path::replace_path_prefix(
+/*Path=*/FilePath, /*OldPrefix=*/IndexRoot, /*NewPrefix=*/"");
+  };
+}
+  }
 
   std::unique_ptr create() override {
 SymbolCollector::Options Opts;
+Opts.FileFilter = FileFilter;
 Opts.CountReferences = true;
 return createStaticIndexingAction(
 Opts,
@@ -57,10 +83,10 @@
 },
 [&](RefSlab S) {
   std::lock_guard Lock(SymbolsMu);
-  for (const auto &Sym : S) {
+  for (const auto &SymbolAndRefs : S) {
 // Deduplication happens during insertion.
-for (const auto &Ref : Sym.second)
-  Refs.insert(Sym.first, Ref);
+for (const auto &Ref : SymbolAndRefs.second)
+  Refs.insert(SymbolAndRefs.first, Ref);
   }
 },
 [&](RelationSlab S) {
@@ -86,6 +112,7 @@
   SymbolSlab::Builder Symbols;
   RefSlab::Builder Refs;
   RelationSlab::Builder Relations;
+  std::function FileFilter = nullptr;
 };
 
 } // namespace
@@ -120,7 +147,9 @@
   // Collect symbols found in each translation unit, merging as we go.
   clang::clangd::IndexFileIn Data;
   auto Err = Executor->get()->execute(
-  std::make_unique(Data),
+  std::make_unique(
+  Data, llvm::sys::path::convert_to_slash(
+clang::clangd::ProjectRoot, 
llvm::sys::path::Style::posix)),
   clang::tooling::getStripPluginsAdjuster());
   if (Err) {
 clang::clangd::elog("{0}", std::move(Err));


Index: clang-tools-extra/clangd/indexer/IndexerMain.cpp
===
--- clang-tools-extra/clangd/indexer/IndexerMain.cpp
+++ clang-tools-extra/clangd/indexer/IndexerMain.cpp
@@ -17,11 +17,15 @@
 #include "index/Symbol.h"
 #include "index/SymbolCollector.h"
 #include "support/Logger.h"
+#include "clang/Basic/SourceManager.h"
 #include "clang/Tooling/ArgumentsAdjusters.h"
 #include "clang/Tooling/CommonOptionsParser.h"
 #include "clang/Tooling/Execution.h"
 #include "clang/Tooling/Tooling.h"
+#include "llvm/ADT/SmallString.h"
+#include "llvm/ADT/StringRef.h"
 #include "llvm/Support/CommandLine.h"
+#include "llvm/Support/Path.h"
 #include "llvm/Support/Signals.h"
 
 namespace clang {
@@ -36,12 +40,34 @@
"binary RIFF format")),
llvm::cl::init(IndexFileFormat::RIFF));
 
+static llvm::cl::opt
+ProjectRoot("project-root",
+llvm::cl::desc("Filter out all symbols outside of this "
+   "directory. This is useful for remote index."),
+llvm::cl::Hidden);
+
 class IndexActionFactory : public tooling::FrontendActionFactory {
 public:
-  IndexActionFactory(IndexFileIn &Result) : Result(Result) {}
+  IndexActionFactory(IndexFileIn &Result, 

[PATCH] D85009: [Sema][BFloat] Forbid arithmetic on vectors of bfloat.

2020-07-31 Thread Simon Tatham via Phabricator via cfe-commits
simon_tatham created this revision.
simon_tatham added reviewers: SjoerdMeijer, rjmccall, rsmith, liutianle, 
RKSimon, craig.topper, jfb, LukeGeeson, fpetrogalli.
Herald added subscribers: cfe-commits, dexonsmith, kristof.beyls.
Herald added a project: clang.
simon_tatham requested review of this revision.

Vectors of bfloat are a storage format only; you're supposed to
explicitly convert them to a wider type to do arithmetic on them.
But currently, if you write something like

  bfloat16x4_t test(bfloat16x4_t a, bfloat16x4_t b) { return a + b; }

then the clang frontend accepts it without error, and (ARM or AArch64)
isel fails to generate code for it.

Added a rule in Sema that forbids the attempt from even being made,
and tests that check it. In particular, we also outlaw arithmetic
between vectors of bfloat and any other vector type.

Patch by Luke Cheeseman.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D85009

Files:
  clang/lib/Sema/SemaExpr.cpp
  clang/test/Sema/arm-bfloat.cpp


Index: clang/test/Sema/arm-bfloat.cpp
===
--- clang/test/Sema/arm-bfloat.cpp
+++ clang/test/Sema/arm-bfloat.cpp
@@ -27,3 +27,21 @@
   fp16 = bf16; // expected-error {{assigning to '__fp16' from incompatible 
type '__bf16'}}
   bf16 + (b ? fp16 : bf16); // expected-error {{incompatible operand types 
('__fp16' and '__bf16')}}
 }
+
+#include 
+
+void test_vector(bfloat16x4_t a, bfloat16x4_t b, float16x4_t c) {
+  a + b; // expected-error {{invalid operands to binary expression 
('bfloat16x4_t' (vector of 4 'bfloat16_t' values) and 'bfloat16x4_t')}}
+  a - b; // expected-error {{invalid operands to binary expression 
('bfloat16x4_t' (vector of 4 'bfloat16_t' values) and 'bfloat16x4_t')}}
+  a * b; // expected-error {{invalid operands to binary expression 
('bfloat16x4_t' (vector of 4 'bfloat16_t' values) and 'bfloat16x4_t')}}
+  a / b; // expected-error {{invalid operands to binary expression 
('bfloat16x4_t' (vector of 4 'bfloat16_t' values) and 'bfloat16x4_t')}}
+
+  a + c; // expected-error {{invalid operands to binary expression 
('bfloat16x4_t' (vector of 4 'bfloat16_t' values) and 'float16x4_t' (vector of 
4 'float16_t' values))}}
+  a - c; // expected-error {{invalid operands to binary expression 
('bfloat16x4_t' (vector of 4 'bfloat16_t' values) and 'float16x4_t' (vector of 
4 'float16_t' values))}}
+  a * c; // expected-error {{invalid operands to binary expression 
('bfloat16x4_t' (vector of 4 'bfloat16_t' values) and 'float16x4_t' (vector of 
4 'float16_t' values))}}
+  a / c; // expected-error {{invalid operands to binary expression 
('bfloat16x4_t' (vector of 4 'bfloat16_t' values) and 'float16x4_t' (vector of 
4 'float16_t' values))}}
+  c + b; // expected-error {{invalid operands to binary expression 
('float16x4_t' (vector of 4 'float16_t' values) and 'bfloat16x4_t' (vector of 4 
'bfloat16_t' values))}}
+  c - b; // expected-error {{invalid operands to binary expression 
('float16x4_t' (vector of 4 'float16_t' values) and 'bfloat16x4_t' (vector of 4 
'bfloat16_t' values))}}
+  c * b; // expected-error {{invalid operands to binary expression 
('float16x4_t' (vector of 4 'float16_t' values) and 'bfloat16x4_t' (vector of 4 
'bfloat16_t' values))}}
+  c / b; // expected-error {{invalid operands to binary expression 
('float16x4_t' (vector of 4 'float16_t' values) and 'bfloat16x4_t' (vector of 4 
'bfloat16_t' values))}}
+}
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -9790,6 +9790,10 @@
   const VectorType *RHSVecType = RHSType->getAs();
   assert(LHSVecType || RHSVecType);
 
+  if ((LHSVecType && LHSVecType->getElementType()->isBFloat16Type()) ||
+  (RHSVecType && RHSVecType->getElementType()->isBFloat16Type()))
+return InvalidOperands(Loc, LHS, RHS);
+
   // AltiVec-style "vector bool op vector bool" combinations are allowed
   // for some operators but not others.
   if (!AllowBothBool &&


Index: clang/test/Sema/arm-bfloat.cpp
===
--- clang/test/Sema/arm-bfloat.cpp
+++ clang/test/Sema/arm-bfloat.cpp
@@ -27,3 +27,21 @@
   fp16 = bf16; // expected-error {{assigning to '__fp16' from incompatible type '__bf16'}}
   bf16 + (b ? fp16 : bf16); // expected-error {{incompatible operand types ('__fp16' and '__bf16')}}
 }
+
+#include 
+
+void test_vector(bfloat16x4_t a, bfloat16x4_t b, float16x4_t c) {
+  a + b; // expected-error {{invalid operands to binary expression ('bfloat16x4_t' (vector of 4 'bfloat16_t' values) and 'bfloat16x4_t')}}
+  a - b; // expected-error {{invalid operands to binary expression ('bfloat16x4_t' (vector of 4 'bfloat16_t' values) and 'bfloat16x4_t')}}
+  a * b; // expected-error {{invalid operands to binary expression ('bfloat16x4_t' (vector of 4 'bfloat16_t' values) and 'bfloat16x4_t')}}
+  a / b; // expected-error {{inva

[clang] 63d3aeb - [analyzer] Fix out-of-tree only clang build by not relaying on private header

2020-07-31 Thread Balazs Benics via cfe-commits

Author: Balazs Benics
Date: 2020-07-31T10:28:14+02:00
New Revision: 63d3aeb529a7b0fb95c2092ca38ad21c1f5cfd74

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

LOG: [analyzer] Fix out-of-tree only clang build by not relaying on private 
header

It turned out that the D78704 included a private LLVM header, which is excluded
from the LLVM install target.
I'm substituting that `#include` with the public one by moving the necessary
`#define` into that. There was a discussion about this at D78704 and on the
cfe-dev mailing list.

I'm also placing a note to remind others of this pitfall.

Reviewed By: mgorny

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

Added: 


Modified: 
clang/unittests/StaticAnalyzer/FalsePositiveRefutationBRVisitorTest.cpp
llvm/include/llvm/Config/config.h.cmake
llvm/include/llvm/Config/llvm-config.h.cmake

Removed: 




diff  --git 
a/clang/unittests/StaticAnalyzer/FalsePositiveRefutationBRVisitorTest.cpp 
b/clang/unittests/StaticAnalyzer/FalsePositiveRefutationBRVisitorTest.cpp
index 7c151c182113..e67dcacca0a9 100644
--- a/clang/unittests/StaticAnalyzer/FalsePositiveRefutationBRVisitorTest.cpp
+++ b/clang/unittests/StaticAnalyzer/FalsePositiveRefutationBRVisitorTest.cpp
@@ -16,7 +16,7 @@
 #include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h"
 #include "clang/StaticAnalyzer/Frontend/AnalysisConsumer.h"
 #include "clang/StaticAnalyzer/Frontend/CheckerRegistry.h"
-#include "llvm/Config/config.h"
+#include "llvm/Config/llvm-config.h"
 #include "gtest/gtest.h"
 
 // FIXME: Use GTEST_SKIP() instead if GTest is updated to version 1.10.0

diff  --git a/llvm/include/llvm/Config/config.h.cmake 
b/llvm/include/llvm/Config/config.h.cmake
index 4d76b27df6b6..b8c7e070eb34 100644
--- a/llvm/include/llvm/Config/config.h.cmake
+++ b/llvm/include/llvm/Config/config.h.cmake
@@ -1,6 +1,9 @@
 #ifndef CONFIG_H
 #define CONFIG_H
 
+// Include this header only under the llvm source tree.
+// This is a private header.
+
 /* Exported configuration */
 #include "llvm/Config/llvm-config.h"
 
@@ -335,9 +338,6 @@
 /* Whether GlobalISel rule coverage is being collected */
 #cmakedefine01 LLVM_GISEL_COV_ENABLED
 
-/* Define if we have z3 and want to build it */
-#cmakedefine LLVM_WITH_Z3 ${LLVM_WITH_Z3}
-
 /* Define to the default GlobalISel coverage file prefix */
 #cmakedefine LLVM_GISEL_COV_PREFIX "${LLVM_GISEL_COV_PREFIX}"
 

diff  --git a/llvm/include/llvm/Config/llvm-config.h.cmake 
b/llvm/include/llvm/Config/llvm-config.h.cmake
index 01892bc5b610..ee299876825e 100644
--- a/llvm/include/llvm/Config/llvm-config.h.cmake
+++ b/llvm/include/llvm/Config/llvm-config.h.cmake
@@ -79,6 +79,9 @@
  */
 #cmakedefine01 LLVM_FORCE_ENABLE_STATS
 
+/* Define if we have z3 and want to build it */
+#cmakedefine LLVM_WITH_Z3 ${LLVM_WITH_Z3}
+
 /* Define if LLVM was built with a dependency to the libtensorflow dynamic 
library */
 #cmakedefine LLVM_HAVE_TF_API
 



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


[PATCH] D84929: [analyzer] Fix out-of-tree only clang build by not relaying on private header

2020-07-31 Thread Balázs Benics via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG63d3aeb529a7: [analyzer] Fix out-of-tree only clang build by 
not relaying on private header (authored by steakhal).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84929

Files:
  clang/unittests/StaticAnalyzer/FalsePositiveRefutationBRVisitorTest.cpp
  llvm/include/llvm/Config/config.h.cmake
  llvm/include/llvm/Config/llvm-config.h.cmake


Index: llvm/include/llvm/Config/llvm-config.h.cmake
===
--- llvm/include/llvm/Config/llvm-config.h.cmake
+++ llvm/include/llvm/Config/llvm-config.h.cmake
@@ -79,6 +79,9 @@
  */
 #cmakedefine01 LLVM_FORCE_ENABLE_STATS
 
+/* Define if we have z3 and want to build it */
+#cmakedefine LLVM_WITH_Z3 ${LLVM_WITH_Z3}
+
 /* Define if LLVM was built with a dependency to the libtensorflow dynamic 
library */
 #cmakedefine LLVM_HAVE_TF_API
 
Index: llvm/include/llvm/Config/config.h.cmake
===
--- llvm/include/llvm/Config/config.h.cmake
+++ llvm/include/llvm/Config/config.h.cmake
@@ -1,6 +1,9 @@
 #ifndef CONFIG_H
 #define CONFIG_H
 
+// Include this header only under the llvm source tree.
+// This is a private header.
+
 /* Exported configuration */
 #include "llvm/Config/llvm-config.h"
 
@@ -335,9 +338,6 @@
 /* Whether GlobalISel rule coverage is being collected */
 #cmakedefine01 LLVM_GISEL_COV_ENABLED
 
-/* Define if we have z3 and want to build it */
-#cmakedefine LLVM_WITH_Z3 ${LLVM_WITH_Z3}
-
 /* Define to the default GlobalISel coverage file prefix */
 #cmakedefine LLVM_GISEL_COV_PREFIX "${LLVM_GISEL_COV_PREFIX}"
 
Index: clang/unittests/StaticAnalyzer/FalsePositiveRefutationBRVisitorTest.cpp
===
--- clang/unittests/StaticAnalyzer/FalsePositiveRefutationBRVisitorTest.cpp
+++ clang/unittests/StaticAnalyzer/FalsePositiveRefutationBRVisitorTest.cpp
@@ -16,7 +16,7 @@
 #include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h"
 #include "clang/StaticAnalyzer/Frontend/AnalysisConsumer.h"
 #include "clang/StaticAnalyzer/Frontend/CheckerRegistry.h"
-#include "llvm/Config/config.h"
+#include "llvm/Config/llvm-config.h"
 #include "gtest/gtest.h"
 
 // FIXME: Use GTEST_SKIP() instead if GTest is updated to version 1.10.0


Index: llvm/include/llvm/Config/llvm-config.h.cmake
===
--- llvm/include/llvm/Config/llvm-config.h.cmake
+++ llvm/include/llvm/Config/llvm-config.h.cmake
@@ -79,6 +79,9 @@
  */
 #cmakedefine01 LLVM_FORCE_ENABLE_STATS
 
+/* Define if we have z3 and want to build it */
+#cmakedefine LLVM_WITH_Z3 ${LLVM_WITH_Z3}
+
 /* Define if LLVM was built with a dependency to the libtensorflow dynamic library */
 #cmakedefine LLVM_HAVE_TF_API
 
Index: llvm/include/llvm/Config/config.h.cmake
===
--- llvm/include/llvm/Config/config.h.cmake
+++ llvm/include/llvm/Config/config.h.cmake
@@ -1,6 +1,9 @@
 #ifndef CONFIG_H
 #define CONFIG_H
 
+// Include this header only under the llvm source tree.
+// This is a private header.
+
 /* Exported configuration */
 #include "llvm/Config/llvm-config.h"
 
@@ -335,9 +338,6 @@
 /* Whether GlobalISel rule coverage is being collected */
 #cmakedefine01 LLVM_GISEL_COV_ENABLED
 
-/* Define if we have z3 and want to build it */
-#cmakedefine LLVM_WITH_Z3 ${LLVM_WITH_Z3}
-
 /* Define to the default GlobalISel coverage file prefix */
 #cmakedefine LLVM_GISEL_COV_PREFIX "${LLVM_GISEL_COV_PREFIX}"
 
Index: clang/unittests/StaticAnalyzer/FalsePositiveRefutationBRVisitorTest.cpp
===
--- clang/unittests/StaticAnalyzer/FalsePositiveRefutationBRVisitorTest.cpp
+++ clang/unittests/StaticAnalyzer/FalsePositiveRefutationBRVisitorTest.cpp
@@ -16,7 +16,7 @@
 #include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h"
 #include "clang/StaticAnalyzer/Frontend/AnalysisConsumer.h"
 #include "clang/StaticAnalyzer/Frontend/CheckerRegistry.h"
-#include "llvm/Config/config.h"
+#include "llvm/Config/llvm-config.h"
 #include "gtest/gtest.h"
 
 // FIXME: Use GTEST_SKIP() instead if GTest is updated to version 1.10.0
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D85010: [clang][ARM] Add name-mangling test for direct __fp16 arguments.

2020-07-31 Thread Simon Tatham via Phabricator via cfe-commits
simon_tatham created this revision.
simon_tatham added reviewers: LukeGeeson, stuij, chill, miyuki, labrinea.
Herald added subscribers: cfe-commits, danielkiss, kristof.beyls.
Herald added a project: clang.
simon_tatham requested review of this revision.

`clang/test/CodeGenCXX/fp16-mangle.cpp` tests pointers to __fp16, but
if you give the `-fallow-half-arguments-and-returns` option, then
clang can also leave an __fp16 unmodified as a function argument or
return type. This regression test checks the name-mangling of that.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D85010

Files:
  clang/test/CodeGenCXX/fp16-mangle-arg-return.cpp


Index: clang/test/CodeGenCXX/fp16-mangle-arg-return.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/fp16-mangle-arg-return.cpp
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -emit-llvm -o - -triple arm-arm-none-eabi 
-fallow-half-arguments-and-returns %s | FileCheck %s
+// RUN: %clang_cc1 -emit-llvm -o - -triple aarch64-arm-none-eabi 
-fallow-half-arguments-and-returns %s | FileCheck %s
+
+// Test name-mangling of __fp16 passed directly as a function argument
+// (when that is permitted).
+
+// CHECK: define {{.*}}void @_Z13fp16_argumentDh(half %{{.*}})
+void fp16_argument(__fp16 arg) {}
+
+// Test name-mangling of __fp16 as a return type. The return type of
+// fp16_return itself isn't mentioned in the mangled name, so to test
+// this, we have to pass it a function pointer and make __fp16 the
+// return type of that.
+
+// CHECK: define {{.*}}void @_Z11fp16_returnPFDhvE(half ()* %{{.*}})
+void fp16_return(__fp16 (*func)(void)) {}


Index: clang/test/CodeGenCXX/fp16-mangle-arg-return.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/fp16-mangle-arg-return.cpp
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -emit-llvm -o - -triple arm-arm-none-eabi -fallow-half-arguments-and-returns %s | FileCheck %s
+// RUN: %clang_cc1 -emit-llvm -o - -triple aarch64-arm-none-eabi -fallow-half-arguments-and-returns %s | FileCheck %s
+
+// Test name-mangling of __fp16 passed directly as a function argument
+// (when that is permitted).
+
+// CHECK: define {{.*}}void @_Z13fp16_argumentDh(half %{{.*}})
+void fp16_argument(__fp16 arg) {}
+
+// Test name-mangling of __fp16 as a return type. The return type of
+// fp16_return itself isn't mentioned in the mangled name, so to test
+// this, we have to pass it a function pointer and make __fp16 the
+// return type of that.
+
+// CHECK: define {{.*}}void @_Z11fp16_returnPFDhvE(half ()* %{{.*}})
+void fp16_return(__fp16 (*func)(void)) {}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D83984: Explicitly use utf-8 in send_string

2020-07-31 Thread serge via Phabricator via cfe-commits
serge-sans-paille added a comment.

According to the doc, `'utf-8'` is already the default encoding, at least on 
py3, but not on py2. i guess that the problem you're trying to fix?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83984

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


[PATCH] D82822: [OpenMP][FIX] Consistently use OpenMPIRBuilder if requested

2020-07-31 Thread David Zarzycki via Phabricator via cfe-commits
davezarzycki added a comment.

Hello, I have a twice-daily auto-bisecting multi-stage cron job running on 
Fedora 32 (x86-64) that has identified this commit as failing my first stage 
test (release + no asserts). Is this expected? Can we get a quick fix or revert 
this?

FAIL: Clang :: OpenMP/irbuilder_nested_parallel_for.c (13233 of 67864)

- TEST 'Clang :: OpenMP/irbuilder_nested_parallel_for.c' FAILED 


Script:
---

: 'RUN: at line 2';   /tmp/_update_lc/r/bin/clang -cc1 -internal-isystem 
/tmp/_update_lc/r/lib/clang/12.0.0/include -nostdsysteminc -verify -fopenmp 
-fopenmp-enable-irbuilder -x c++ -emit-llvm 
/home/dave/ro_s/lp/clang/test/OpenMP/irbuilder_nested_parallel_for.c -triple 
x86_64-unknown-unknown -fexceptions -fcxx-exceptions -o - | 
/tmp/_update_lc/r/bin/FileCheck --check-prefixes=CHECK 
/home/dave/ro_s/lp/clang/test/OpenMP/irbuilder_nested_parallel_for.c

: 'RUN: at line 3';   /tmp/_update_lc/r/bin/clang -cc1 -internal-isystem 
/tmp/_update_lc/r/lib/clang/12.0.0/include -nostdsysteminc -fopenmp 
-fopenmp-enable-irbuilder -x c++ -triple x86_64-unknown-unknown -fexceptions 
-fcxx-exceptions -debug-info-kind=limited -std=c++11 -verify 
/home/dave/ro_s/lp/clang/test/OpenMP/irbuilder_nested_parallel_for.c -emit-llvm 
-o - | /tmp/_update_lc/r/bin/FileCheck --check-prefixes=CHECK-DEBUG 
/home/dave/ro_s/lp/clang/test/OpenMP/irbuilder_nested_parallel_for.c
---

Exit Code: 1

Command Output (stderr):


/home/dave/ro_s/lp/clang/test/OpenMP/irbuilder_nested_parallel_for.c:74:22: 
error: CHECK-DEBUG-NEXT: is not on the line after the previous match
// CHECK-DEBUG-NEXT: [[OMP_GLOBAL_THREAD_NUM:%.*]] = call i32 
@__kmpc_global_thread_num(%struct.ident_t* @12), !dbg !{{[0-9]*}}

  ^

:252:2: note: 'next' match was here
 %omp_global_thread_num1 = call i32 @__kmpc_global_thread_num(%struct.ident_t* 
@12), !dbg !52
 ^
:224:105: note: previous match ended here
 call void @llvm.dbg.declare(metadata double* %b.addr, metadata !45, metadata 
!DIExpression()), !dbg !46

  ^

:225:1: note: non-matching line after previous match is here
 %omp_global_thread_num = call i32 @__kmpc_global_thread_num(%struct.ident_t* 
@10), !dbg !47
^
/home/dave/ro_s/lp/clang/test/OpenMP/irbuilder_nested_parallel_for.c:192:22: 
error: CHECK-DEBUG-NEXT: expected string not found in input
// CHECK-DEBUG-NEXT: [[OMP_GLOBAL_THREAD_NUM:%.*]] = call i32 
@__kmpc_global_thread_num(%struct.ident_t* @25), !dbg !{{[0-9]*}}

  ^

:381:2: note: scanning from here
 %omp_global_thread_num = call i32 @__kmpc_global_thread_num(%struct.ident_t* 
@21), !dbg !83
 ^
:381:19: note: possible intended match here
 %omp_global_thread_num = call i32 @__kmpc_global_thread_num(%struct.ident_t* 
@21), !dbg !83

  ^

Input file: 
Check file: /home/dave/ro_s/lp/clang/test/OpenMP/irbuilder_nested_parallel_for.c

-dump-input=help explains the following input dump.

Input was:
<<

.
.
.
  247:
  248: omp.par.outlined.exit19.exitStub: ; preds = %omp.par.pre_finalize
  249:  ret void
  250:
  251: omp.par.region: ; preds = %omp.par.entry
  252:  %omp_global_thread_num1 = call i32 
@__kmpc_global_thread_num(%struct.ident_t* @12), !dbg !52

next:74 
!~~~
 error: match on wrong line

  253:  br label %omp_parallel
  254:
  255: omp_parallel: ; preds = %omp.par.region
  256:  call void (%struct.ident_t*, i32, void (i32*, i32*, ...)*, ...) 
@__kmpc_fork_call(%struct.ident_t* @12, i32 3, void (i32*, i32*, ...)* bitcast 
(void (i32*, i32*, i32*, double*, float**)* @_Z14parallel_for_1Pfid..omp_par to 
void (i32*, i32*, ...)*), i32* %a.addr, double* %b.addr, float** %r.addr), !dbg 
!53
  257:  br label %omp.par.outlined.exit
.
.
.
  376:  call void @llvm.dbg.declare(metadata float** %r.addr, metadata !77, 
metadata !DIExpression()), !dbg !78
  377:  store i32 %a, i32* %a.addr, align 4
  378:  call void @llvm.dbg.declare(metadata i32* %a.addr, metadata !79, 
metadata !DIExpression()), !dbg !80
  379:  store double %b, double* %b.addr, align 8
  380:  call void @llvm.dbg.declare(metadata double* %b.addr, metadata !81, 
metadata !DIExpression()), !dbg !82
  381:  %omp_global_thread_num = call i32 
@__kmpc_global_thread_num(%struct.ident_t* @21), !dbg !83

next:192'0  
X~~
 error: no match found
next:192'1 

[PATCH] D81083: [Clang] Allow "vector_size" applied to Booleans

2020-07-31 Thread Kazushi Marukawa via Phabricator via cfe-commits
kaz7 added a comment.

Thank you for implementing `EmitFromMemory`.  We are locally trying to use this 
patch to implement vector mask intrinsic instructions on Aurora VE.  It is 
working well with regression tests.  We will try test-suite next.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81083

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


[PATCH] D84939: [clangd] Propagate remote index errors via Expected

2020-07-31 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet accepted this revision.
kadircet added a comment.
This revision is now accepted and ready to land.

thanks, lgtm!




Comment at: 
clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp:313
  RelativePath, llvm::sys::path::Style::posix));
-  if (RelativePath.empty()) {
-return llvm::None;
-  }
-  if (llvm::sys::path::is_absolute(RelativePath)) {
-return llvm::None;
-  }
+  if (RelativePath.empty())
+return make_error("Empty relative path.",

kbobyrev wrote:
> kadircet wrote:
> > is `RelativePath` user provided? can't we just assert on non-emptiness and 
> > non-absoluteness and make this function return a std::string instead?
> Could you elaborate on what you mean by user provided? Relative path is 
> something that comes from the remote index. Ideally, this is non-empty and 
> relative but I think the safer option is to maybe check for errors? Actually, 
> I'm not sure about this but it's not user provided as in "given as a flag 
> passed to CLI invocation by the end user".
> 
> I think the point here is making errors recoverable and not shutting down the 
> client, otherwise everything could be an assertion? Same in other places.
> 
> WDYT?
> Could you elaborate on what you mean by user provided? Relative path is 
> something that comes from the remote index. 

Yes I was asking whether this comes from outside and ideally not processed at 
all before arriving at this logic.

> Ideally, this is non-empty and relative but I think the safer option is to 
> maybe check for errors? Actually, I'm not sure about this but it's not user 
> provided as in "given as a flag passed to CLI invocation by the end user".

Right, the safer is always to check for errors, but if we've already processed 
the RelativePath before it reaches this code path then there wouldn't be much 
value in spending more runtime checks (and also it would be callers 
responsibility generate the errors in such cases). I was asking this because I 
wasn't aware of the whole structure, but looks like this is literally the entry 
point (i.e. the first logic that verifies a user input) for path to uri 
conversions. So no action needed here.



Comment at: clang-tools-extra/clangd/unittests/remote/MarshallingTests.cpp:169
+  ASSERT_TRUE(bool(Serialized));
+  EXPECT_TRUE(bool(ProtobufMarshaller.fromProtobuf(*Serialized)));
 

i would ASSERT_TRUE here, as you'll end up crashing when `fromProtoBuf` returns 
an error (because you are not consuming the error and it is destroyed after 
completion of the statement).



Comment at: clang-tools-extra/clangd/unittests/remote/MarshallingTests.cpp:418
+  auto URIString = ProtobufMarshaller.relativePathToURI("lib/File.cpp");
+  EXPECT_TRUE(bool(URIString));
   // RelativePath can not be absolute.

again should be ASSERT_TRUE for similar concerns stated above.



Comment at: clang-tools-extra/clangd/unittests/remote/MarshallingTests.cpp:436
+  testPathURI("remote/project/lib/File.cpp", Strings));
+  EXPECT_TRUE(bool(RelativePath));
   // RemoteIndexRoot has to be be a prefix of the file path.

again should be ASSERT_TRUE for similar concerns stated above.



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84939

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


[PATCH] D84939: [clangd] Propagate remote index errors via Expected

2020-07-31 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev updated this revision to Diff 282166.
kbobyrev marked 6 inline comments as done.
kbobyrev added a comment.

Good points, thanks!

Addressed post-LGTM comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84939

Files:
  clang-tools-extra/clangd/index/remote/Client.cpp
  clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp
  clang-tools-extra/clangd/index/remote/marshalling/Marshalling.h
  clang-tools-extra/clangd/index/remote/server/Server.cpp
  clang-tools-extra/clangd/unittests/remote/MarshallingTests.cpp

Index: clang-tools-extra/clangd/unittests/remote/MarshallingTests.cpp
===
--- clang-tools-extra/clangd/unittests/remote/MarshallingTests.cpp
+++ clang-tools-extra/clangd/unittests/remote/MarshallingTests.cpp
@@ -7,6 +7,7 @@
 //===--===//
 
 #include "../TestTU.h"
+#include "Index.pb.h"
 #include "TestFS.h"
 #include "index/Index.h"
 #include "index/Ref.h"
@@ -97,11 +98,11 @@
   "clangd/unittests/remote/MarshallingTests.cpp",
   Strings);
   auto Serialized = ProtobufMarshaller.toProtobuf(Original);
-  ASSERT_TRUE(Serialized);
+  ASSERT_TRUE(bool(Serialized));
   EXPECT_EQ(Serialized->location().file_path(),
 "clang-tools-extra/clangd/unittests/remote/MarshallingTests.cpp");
   auto Deserialized = ProtobufMarshaller.fromProtobuf(*Serialized);
-  ASSERT_TRUE(Deserialized);
+  ASSERT_TRUE(bool(Deserialized));
   EXPECT_STREQ(Deserialized->Location.FileURI,
testPathURI("home/my-projects/llvm-project/clang-tools-extra/"
"clangd/unittests/remote/MarshallingTests.cpp",
@@ -109,12 +110,16 @@
 
   // Can't have empty paths.
   *Serialized->mutable_location()->mutable_file_path() = std::string();
-  EXPECT_FALSE(ProtobufMarshaller.fromProtobuf(*Serialized));
+  Deserialized = ProtobufMarshaller.fromProtobuf(*Serialized);
+  EXPECT_FALSE(bool(Deserialized));
+  llvm::consumeError(Deserialized.takeError());
 
   clangd::Ref WithInvalidURI;
   // Invalid URI results in serialization failure.
   WithInvalidURI.Location.FileURI = "This is not a URI";
-  EXPECT_FALSE(ProtobufMarshaller.toProtobuf(WithInvalidURI));
+  auto DeserializedRef = ProtobufMarshaller.toProtobuf(WithInvalidURI);
+  EXPECT_FALSE(bool(DeserializedRef));
+  llvm::consumeError(DeserializedRef.takeError());
 
   // Can not use URIs with scheme different from "file".
   auto UnittestURI =
@@ -122,14 +127,18 @@
   ASSERT_TRUE(bool(UnittestURI));
   WithInvalidURI.Location.FileURI =
   Strings.save(UnittestURI->toString()).begin();
-  EXPECT_FALSE(ProtobufMarshaller.toProtobuf(WithInvalidURI));
+  auto DeserializedSymbol = ProtobufMarshaller.toProtobuf(WithInvalidURI);
+  EXPECT_FALSE(bool(DeserializedSymbol));
+  llvm::consumeError(DeserializedSymbol.takeError());
 
   // Paths transmitted over the wire can not be absolute, they have to be
   // relative.
   Ref WithAbsolutePath;
   *WithAbsolutePath.mutable_location()->mutable_file_path() =
   "/usr/local/user/home/HelloWorld.cpp";
-  EXPECT_FALSE(ProtobufMarshaller.fromProtobuf(WithAbsolutePath));
+  Deserialized = ProtobufMarshaller.fromProtobuf(WithAbsolutePath);
+  EXPECT_FALSE(bool(Deserialized));
+  llvm::consumeError(Deserialized.takeError());
 }
 
 TEST(RemoteMarshallingTest, SymbolSerialization) {
@@ -142,9 +151,9 @@
   // Check that symbols are exactly the same if the path to indexed project is
   // the same on indexing machine and the client.
   auto Serialized = ProtobufMarshaller.toProtobuf(Sym);
-  ASSERT_TRUE(Serialized);
+  ASSERT_TRUE(bool(Serialized));
   auto Deserialized = ProtobufMarshaller.fromProtobuf(*Serialized);
-  ASSERT_TRUE(Deserialized);
+  ASSERT_TRUE(bool(Deserialized));
   EXPECT_EQ(toYAML(Sym), toYAML(*Deserialized));
   // Serialized paths are relative and have UNIX slashes.
   EXPECT_EQ(convert_to_slash(Serialized->definition().file_path(),
@@ -156,36 +165,44 @@
   // Missing definition is OK.
   Sym.Definition = clangd::SymbolLocation();
   Serialized = ProtobufMarshaller.toProtobuf(Sym);
-  ASSERT_TRUE(Serialized);
-  EXPECT_TRUE(ProtobufMarshaller.fromProtobuf(*Serialized));
+  ASSERT_TRUE(bool(Serialized));
+  ASSERT_TRUE(bool(ProtobufMarshaller.fromProtobuf(*Serialized)));
 
   // Relative path is absolute.
   *Serialized->mutable_canonical_declaration()->mutable_file_path() =
   convert_to_slash("/path/to/Declaration.h");
-  EXPECT_FALSE(ProtobufMarshaller.fromProtobuf(*Serialized));
+  Deserialized = ProtobufMarshaller.fromProtobuf(*Serialized);
+  EXPECT_FALSE(bool(Deserialized));
+  llvm::consumeError(Deserialized.takeError());
 
   // Fail with an invalid URI.
   Sym.Definition.FileURI = "Not A URI";
-  EXPECT_FALSE(ProtobufMarshaller.toProtobuf(Sym));
+  Serialized = ProtobufMarshaller.toProtobuf(Sym);
+  EXPECT_FALS

[clang-tools-extra] fb5588b - [clangd] Propagate remote index errors via Expected

2020-07-31 Thread Kirill Bobyrev via cfe-commits

Author: Kirill Bobyrev
Date: 2020-07-31T11:48:32+02:00
New Revision: fb5588b0ad59522031d037b0d1a3fdcf8ada8a79

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

LOG: [clangd] Propagate remote index errors via Expected

This is a refactoring: errors should be logged only on the highest level.
Switch from Optional to Expected in the serialization code.

Reviewed By: kadircet

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

Added: 


Modified: 
clang-tools-extra/clangd/index/remote/Client.cpp
clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp
clang-tools-extra/clangd/index/remote/marshalling/Marshalling.h
clang-tools-extra/clangd/index/remote/server/Server.cpp
clang-tools-extra/clangd/unittests/remote/MarshallingTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/index/remote/Client.cpp 
b/clang-tools-extra/clangd/index/remote/Client.cpp
index af58645d1795..4c1741e715a5 100644
--- a/clang-tools-extra/clangd/index/remote/Client.cpp
+++ b/clang-tools-extra/clangd/index/remote/Client.cpp
@@ -16,6 +16,7 @@
 #include "support/Logger.h"
 #include "support/Trace.h"
 #include "llvm/ADT/StringRef.h"
+#include "llvm/Support/Error.h"
 
 #include 
 
@@ -53,7 +54,9 @@ class IndexClient : public clangd::SymbolIndex {
   }
   auto Response = ProtobufMarshaller->fromProtobuf(Reply.stream_result());
   if (!Response) {
-elog("Received invalid {0}", ReplyT::descriptor()->name());
+elog("Received invalid {0}: {1}. Reason: {2}",
+ ReplyT::descriptor()->name(), Reply.stream_result().DebugString(),
+ Response.takeError());
 ++FailedToParse;
 continue;
   }

diff  --git a/clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp 
b/clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp
index 270e15347ee0..bac5b7e6e958 100644
--- a/clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp
+++ b/clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp
@@ -19,8 +19,6 @@
 #include "support/Logger.h"
 #include "clang/Index/IndexSymbol.h"
 #include "llvm/ADT/DenseSet.h"
-#include "llvm/ADT/None.h"
-#include "llvm/ADT/Optional.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringRef.h"
@@ -46,6 +44,11 @@ llvm::Expected> getIDs(IDRange IDs) 
{
   return Result;
 }
 
+llvm::Error makeStringError(llvm::StringRef Message) {
+  return llvm::make_error(Message,
+ llvm::inconvertibleErrorCode());
+}
+
 } // namespace
 
 Marshaller::Marshaller(llvm::StringRef RemoteIndexRoot,
@@ -124,20 +127,13 @@ Marshaller::fromProtobuf(const RelationsRequest *Message) 
{
   return Req;
 }
 
-llvm::Optional Marshaller::fromProtobuf(const Symbol &Message) 
{
-  if (!Message.has_info() || !Message.has_canonical_declaration()) {
-elog("Cannot convert Symbol from protobuf (missing info, definition or "
- "declaration): {0}",
- Message.DebugString());
-return llvm::None;
-  }
+llvm::Expected Marshaller::fromProtobuf(const Symbol &Message) 
{
+  if (!Message.has_info() || !Message.has_canonical_declaration())
+return makeStringError("Missing info or declaration.");
   clangd::Symbol Result;
   auto ID = SymbolID::fromStr(Message.id());
-  if (!ID) {
-elog("Cannot parse SymbolID {0} given protobuf: {1}", ID.takeError(),
- Message.DebugString());
-return llvm::None;
-  }
+  if (!ID)
+return ID.takeError();
   Result.ID = *ID;
   Result.SymInfo = fromProtobuf(Message.info());
   Result.Name = Message.name();
@@ -148,11 +144,8 @@ llvm::Optional 
Marshaller::fromProtobuf(const Symbol &Message) {
   Result.Definition = *Definition;
   }
   auto Declaration = fromProtobuf(Message.canonical_declaration());
-  if (!Declaration) {
-elog("Cannot convert Symbol from protobuf (invalid declaration): {0}",
- Message.DebugString());
-return llvm::None;
-  }
+  if (!Declaration)
+return Declaration.takeError();
   Result.CanonicalDeclaration = *Declaration;
   Result.References = Message.references();
   Result.Origin = static_cast(Message.origin());
@@ -164,49 +157,36 @@ llvm::Optional 
Marshaller::fromProtobuf(const Symbol &Message) {
   Result.Type = Message.type();
   for (const auto &Header : Message.headers()) {
 auto SerializedHeader = fromProtobuf(Header);
-if (SerializedHeader)
-  Result.IncludeHeaders.push_back(*SerializedHeader);
-else
-  elog("Cannot convert HeaderWithIncludes from protobuf: {0}",
-   Header.DebugString());
+if (!SerializedHeader)
+  return SerializedHeader.takeError();
+Result.IncludeHeaders.push_back(*SerializedHeader);
   }
   Result.Flags = static_cast(Message.flags());

[PATCH] D84939: [clangd] Propagate remote index errors via Expected

2020-07-31 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev added inline comments.



Comment at: 
clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp:313
  RelativePath, llvm::sys::path::Style::posix));
-  if (RelativePath.empty()) {
-return llvm::None;
-  }
-  if (llvm::sys::path::is_absolute(RelativePath)) {
-return llvm::None;
-  }
+  if (RelativePath.empty())
+return make_error("Empty relative path.",

kadircet wrote:
> kbobyrev wrote:
> > kadircet wrote:
> > > is `RelativePath` user provided? can't we just assert on non-emptiness 
> > > and non-absoluteness and make this function return a std::string instead?
> > Could you elaborate on what you mean by user provided? Relative path is 
> > something that comes from the remote index. Ideally, this is non-empty and 
> > relative but I think the safer option is to maybe check for errors? 
> > Actually, I'm not sure about this but it's not user provided as in "given 
> > as a flag passed to CLI invocation by the end user".
> > 
> > I think the point here is making errors recoverable and not shutting down 
> > the client, otherwise everything could be an assertion? Same in other 
> > places.
> > 
> > WDYT?
> > Could you elaborate on what you mean by user provided? Relative path is 
> > something that comes from the remote index. 
> 
> Yes I was asking whether this comes from outside and ideally not processed at 
> all before arriving at this logic.
> 
> > Ideally, this is non-empty and relative but I think the safer option is to 
> > maybe check for errors? Actually, I'm not sure about this but it's not user 
> > provided as in "given as a flag passed to CLI invocation by the end user".
> 
> Right, the safer is always to check for errors, but if we've already 
> processed the RelativePath before it reaches this code path then there 
> wouldn't be much value in spending more runtime checks (and also it would be 
> callers responsibility generate the errors in such cases). I was asking this 
> because I wasn't aware of the whole structure, but looks like this is 
> literally the entry point (i.e. the first logic that verifies a user input) 
> for path to uri conversions. So no action needed here.
Yes, I agree that spending runtime on this is unfortunate but I guess it's the 
cost we'd have to pay :(


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84939

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


[PATCH] D84939: [clangd] Propagate remote index errors via Expected

2020-07-31 Thread Kirill Bobyrev via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGfb5588b0ad59: [clangd] Propagate remote index errors via 
Expected (authored by kbobyrev).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84939

Files:
  clang-tools-extra/clangd/index/remote/Client.cpp
  clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp
  clang-tools-extra/clangd/index/remote/marshalling/Marshalling.h
  clang-tools-extra/clangd/index/remote/server/Server.cpp
  clang-tools-extra/clangd/unittests/remote/MarshallingTests.cpp

Index: clang-tools-extra/clangd/unittests/remote/MarshallingTests.cpp
===
--- clang-tools-extra/clangd/unittests/remote/MarshallingTests.cpp
+++ clang-tools-extra/clangd/unittests/remote/MarshallingTests.cpp
@@ -7,6 +7,7 @@
 //===--===//
 
 #include "../TestTU.h"
+#include "Index.pb.h"
 #include "TestFS.h"
 #include "index/Index.h"
 #include "index/Ref.h"
@@ -97,11 +98,11 @@
   "clangd/unittests/remote/MarshallingTests.cpp",
   Strings);
   auto Serialized = ProtobufMarshaller.toProtobuf(Original);
-  ASSERT_TRUE(Serialized);
+  ASSERT_TRUE(bool(Serialized));
   EXPECT_EQ(Serialized->location().file_path(),
 "clang-tools-extra/clangd/unittests/remote/MarshallingTests.cpp");
   auto Deserialized = ProtobufMarshaller.fromProtobuf(*Serialized);
-  ASSERT_TRUE(Deserialized);
+  ASSERT_TRUE(bool(Deserialized));
   EXPECT_STREQ(Deserialized->Location.FileURI,
testPathURI("home/my-projects/llvm-project/clang-tools-extra/"
"clangd/unittests/remote/MarshallingTests.cpp",
@@ -109,12 +110,16 @@
 
   // Can't have empty paths.
   *Serialized->mutable_location()->mutable_file_path() = std::string();
-  EXPECT_FALSE(ProtobufMarshaller.fromProtobuf(*Serialized));
+  Deserialized = ProtobufMarshaller.fromProtobuf(*Serialized);
+  EXPECT_FALSE(bool(Deserialized));
+  llvm::consumeError(Deserialized.takeError());
 
   clangd::Ref WithInvalidURI;
   // Invalid URI results in serialization failure.
   WithInvalidURI.Location.FileURI = "This is not a URI";
-  EXPECT_FALSE(ProtobufMarshaller.toProtobuf(WithInvalidURI));
+  auto DeserializedRef = ProtobufMarshaller.toProtobuf(WithInvalidURI);
+  EXPECT_FALSE(bool(DeserializedRef));
+  llvm::consumeError(DeserializedRef.takeError());
 
   // Can not use URIs with scheme different from "file".
   auto UnittestURI =
@@ -122,14 +127,18 @@
   ASSERT_TRUE(bool(UnittestURI));
   WithInvalidURI.Location.FileURI =
   Strings.save(UnittestURI->toString()).begin();
-  EXPECT_FALSE(ProtobufMarshaller.toProtobuf(WithInvalidURI));
+  auto DeserializedSymbol = ProtobufMarshaller.toProtobuf(WithInvalidURI);
+  EXPECT_FALSE(bool(DeserializedSymbol));
+  llvm::consumeError(DeserializedSymbol.takeError());
 
   // Paths transmitted over the wire can not be absolute, they have to be
   // relative.
   Ref WithAbsolutePath;
   *WithAbsolutePath.mutable_location()->mutable_file_path() =
   "/usr/local/user/home/HelloWorld.cpp";
-  EXPECT_FALSE(ProtobufMarshaller.fromProtobuf(WithAbsolutePath));
+  Deserialized = ProtobufMarshaller.fromProtobuf(WithAbsolutePath);
+  EXPECT_FALSE(bool(Deserialized));
+  llvm::consumeError(Deserialized.takeError());
 }
 
 TEST(RemoteMarshallingTest, SymbolSerialization) {
@@ -142,9 +151,9 @@
   // Check that symbols are exactly the same if the path to indexed project is
   // the same on indexing machine and the client.
   auto Serialized = ProtobufMarshaller.toProtobuf(Sym);
-  ASSERT_TRUE(Serialized);
+  ASSERT_TRUE(bool(Serialized));
   auto Deserialized = ProtobufMarshaller.fromProtobuf(*Serialized);
-  ASSERT_TRUE(Deserialized);
+  ASSERT_TRUE(bool(Deserialized));
   EXPECT_EQ(toYAML(Sym), toYAML(*Deserialized));
   // Serialized paths are relative and have UNIX slashes.
   EXPECT_EQ(convert_to_slash(Serialized->definition().file_path(),
@@ -156,36 +165,44 @@
   // Missing definition is OK.
   Sym.Definition = clangd::SymbolLocation();
   Serialized = ProtobufMarshaller.toProtobuf(Sym);
-  ASSERT_TRUE(Serialized);
-  EXPECT_TRUE(ProtobufMarshaller.fromProtobuf(*Serialized));
+  ASSERT_TRUE(bool(Serialized));
+  ASSERT_TRUE(bool(ProtobufMarshaller.fromProtobuf(*Serialized)));
 
   // Relative path is absolute.
   *Serialized->mutable_canonical_declaration()->mutable_file_path() =
   convert_to_slash("/path/to/Declaration.h");
-  EXPECT_FALSE(ProtobufMarshaller.fromProtobuf(*Serialized));
+  Deserialized = ProtobufMarshaller.fromProtobuf(*Serialized);
+  EXPECT_FALSE(bool(Deserialized));
+  llvm::consumeError(Deserialized.takeError());
 
   // Fail with an invalid URI.
   Sym.Definition.FileURI = "Not A URI";
-  EXPECT_FALSE(ProtobufMarshaller.toProtobuf(Sym

[clang] 1618828 - [clang][Syntax] syntax::Arena doesnt own TokenBuffer

2020-07-31 Thread Kadir Cetinkaya via cfe-commits

Author: Kadir Cetinkaya
Date: 2020-07-31T11:50:01+02:00
New Revision: 161882816540fc011554e4a820ab896278491b6a

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

LOG: [clang][Syntax] syntax::Arena doesnt own TokenBuffer

Currently an Arena can only be built while consuming a TokenBuffer,
some users (like clangd) might want to share a TokenBuffer with multiple
compenents. This patch changes Arena's TokenBuffer member to be a reference so
that it can be created with read-only token buffers.

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

Added: 


Modified: 
clang/include/clang/Tooling/Syntax/Tree.h
clang/lib/Tooling/Syntax/Tree.cpp
clang/unittests/Tooling/Syntax/TreeTest.cpp

Removed: 




diff  --git a/clang/include/clang/Tooling/Syntax/Tree.h 
b/clang/include/clang/Tooling/Syntax/Tree.h
index bc581004c46e..dd51e0a74070 100644
--- a/clang/include/clang/Tooling/Syntax/Tree.h
+++ b/clang/include/clang/Tooling/Syntax/Tree.h
@@ -39,7 +39,7 @@ namespace syntax {
 class Arena {
 public:
   Arena(SourceManager &SourceMgr, const LangOptions &LangOpts,
-TokenBuffer Tokens);
+const TokenBuffer &Tokens);
 
   const SourceManager &sourceManager() const { return SourceMgr; }
   const LangOptions &langOptions() const { return LangOpts; }
@@ -56,7 +56,7 @@ class Arena {
 private:
   SourceManager &SourceMgr;
   const LangOptions &LangOpts;
-  TokenBuffer Tokens;
+  const TokenBuffer &Tokens;
   /// IDs and storage for additional tokenized files.
   llvm::DenseMap> ExtraTokens;
   /// Keeps all the allocated nodes and their intermediate data structures.

diff  --git a/clang/lib/Tooling/Syntax/Tree.cpp 
b/clang/lib/Tooling/Syntax/Tree.cpp
index 37579e6145b6..2944819afc96 100644
--- a/clang/lib/Tooling/Syntax/Tree.cpp
+++ b/clang/lib/Tooling/Syntax/Tree.cpp
@@ -33,8 +33,8 @@ static void traverse(syntax::Node *N,
 } // namespace
 
 syntax::Arena::Arena(SourceManager &SourceMgr, const LangOptions &LangOpts,
- TokenBuffer Tokens)
-: SourceMgr(SourceMgr), LangOpts(LangOpts), Tokens(std::move(Tokens)) {}
+ const TokenBuffer &Tokens)
+: SourceMgr(SourceMgr), LangOpts(LangOpts), Tokens(Tokens) {}
 
 const clang::syntax::TokenBuffer &syntax::Arena::tokenBuffer() const {
   return Tokens;

diff  --git a/clang/unittests/Tooling/Syntax/TreeTest.cpp 
b/clang/unittests/Tooling/Syntax/TreeTest.cpp
index bd639aa58166..a722ca2b1a45 100644
--- a/clang/unittests/Tooling/Syntax/TreeTest.cpp
+++ b/clang/unittests/Tooling/Syntax/TreeTest.cpp
@@ -35,6 +35,7 @@
 #include "gmock/gmock.h"
 #include "gtest/gtest.h"
 #include 
+#include 
 
 using namespace clang;
 
@@ -59,22 +60,25 @@ class SyntaxTreeTest : public ::testing::Test,
 class BuildSyntaxTree : public ASTConsumer {
 public:
   BuildSyntaxTree(syntax::TranslationUnit *&Root,
+  std::unique_ptr &TB,
   std::unique_ptr &Arena,
   std::unique_ptr Tokens)
-  : Root(Root), Arena(Arena), Tokens(std::move(Tokens)) {
+  : Root(Root), TB(TB), Arena(Arena), Tokens(std::move(Tokens)) {
 assert(this->Tokens);
   }
 
   void HandleTranslationUnit(ASTContext &Ctx) override {
-Arena = std::make_unique(Ctx.getSourceManager(),
-Ctx.getLangOpts(),
-std::move(*Tokens).consume());
+TB =
+
std::make_unique(std::move(*Tokens).consume());
 Tokens = nullptr; // make sure we fail if this gets called twice.
+Arena = std::make_unique(Ctx.getSourceManager(),
+Ctx.getLangOpts(), *TB);
 Root = syntax::buildSyntaxTree(*Arena, *Ctx.getTranslationUnitDecl());
   }
 
 private:
   syntax::TranslationUnit *&Root;
+  std::unique_ptr &TB;
   std::unique_ptr &Arena;
   std::unique_ptr Tokens;
 };
@@ -82,20 +86,22 @@ class SyntaxTreeTest : public ::testing::Test,
 class BuildSyntaxTreeAction : public ASTFrontendAction {
 public:
   BuildSyntaxTreeAction(syntax::TranslationUnit *&Root,
+std::unique_ptr &TB,
 std::unique_ptr &Arena)
-  : Root(Root), Arena(Arena) {}
+  : Root(Root), TB(TB), Arena(Arena) {}
 
   std::unique_ptr
   CreateASTConsumer(CompilerInstance &CI, StringRef InFile) override {
 // We start recording the tokens, ast consumer will take on the result.
 auto Tokens =
 std::make_unique(CI.getPreprocessor());
-return std::make_unique(Root, Arena,
+return std::make_unique(Root, TB, Arena,
  std::move(Tokens));

[PATCH] D84973: [clang][Syntax] syntax::Arena doesnt own TokenBuffer

2020-07-31 Thread Kadir Cetinkaya via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG161882816540: [clang][Syntax] syntax::Arena doesnt own 
TokenBuffer (authored by kadircet).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84973

Files:
  clang/include/clang/Tooling/Syntax/Tree.h
  clang/lib/Tooling/Syntax/Tree.cpp
  clang/unittests/Tooling/Syntax/TreeTest.cpp

Index: clang/unittests/Tooling/Syntax/TreeTest.cpp
===
--- clang/unittests/Tooling/Syntax/TreeTest.cpp
+++ clang/unittests/Tooling/Syntax/TreeTest.cpp
@@ -35,6 +35,7 @@
 #include "gmock/gmock.h"
 #include "gtest/gtest.h"
 #include 
+#include 
 
 using namespace clang;
 
@@ -59,22 +60,25 @@
 class BuildSyntaxTree : public ASTConsumer {
 public:
   BuildSyntaxTree(syntax::TranslationUnit *&Root,
+  std::unique_ptr &TB,
   std::unique_ptr &Arena,
   std::unique_ptr Tokens)
-  : Root(Root), Arena(Arena), Tokens(std::move(Tokens)) {
+  : Root(Root), TB(TB), Arena(Arena), Tokens(std::move(Tokens)) {
 assert(this->Tokens);
   }
 
   void HandleTranslationUnit(ASTContext &Ctx) override {
-Arena = std::make_unique(Ctx.getSourceManager(),
-Ctx.getLangOpts(),
-std::move(*Tokens).consume());
+TB =
+std::make_unique(std::move(*Tokens).consume());
 Tokens = nullptr; // make sure we fail if this gets called twice.
+Arena = std::make_unique(Ctx.getSourceManager(),
+Ctx.getLangOpts(), *TB);
 Root = syntax::buildSyntaxTree(*Arena, *Ctx.getTranslationUnitDecl());
   }
 
 private:
   syntax::TranslationUnit *&Root;
+  std::unique_ptr &TB;
   std::unique_ptr &Arena;
   std::unique_ptr Tokens;
 };
@@ -82,20 +86,22 @@
 class BuildSyntaxTreeAction : public ASTFrontendAction {
 public:
   BuildSyntaxTreeAction(syntax::TranslationUnit *&Root,
+std::unique_ptr &TB,
 std::unique_ptr &Arena)
-  : Root(Root), Arena(Arena) {}
+  : Root(Root), TB(TB), Arena(Arena) {}
 
   std::unique_ptr
   CreateASTConsumer(CompilerInstance &CI, StringRef InFile) override {
 // We start recording the tokens, ast consumer will take on the result.
 auto Tokens =
 std::make_unique(CI.getPreprocessor());
-return std::make_unique(Root, Arena,
+return std::make_unique(Root, TB, Arena,
  std::move(Tokens));
   }
 
 private:
   syntax::TranslationUnit *&Root;
+  std::unique_ptr &TB;
   std::unique_ptr &Arena;
 };
 
@@ -132,7 +138,7 @@
 Compiler.setSourceManager(SourceMgr.get());
 
 syntax::TranslationUnit *Root = nullptr;
-BuildSyntaxTreeAction Recorder(Root, this->Arena);
+BuildSyntaxTreeAction Recorder(Root, this->TB, this->Arena);
 
 // Action could not be executed but the frontend didn't identify any errors
 // in the code ==> problem in setting up the action.
@@ -204,6 +210,7 @@
   new SourceManager(*Diags, *FileMgr);
   std::shared_ptr Invocation;
   // Set after calling buildTree().
+  std::unique_ptr TB;
   std::unique_ptr Arena;
 };
 
Index: clang/lib/Tooling/Syntax/Tree.cpp
===
--- clang/lib/Tooling/Syntax/Tree.cpp
+++ clang/lib/Tooling/Syntax/Tree.cpp
@@ -33,8 +33,8 @@
 } // namespace
 
 syntax::Arena::Arena(SourceManager &SourceMgr, const LangOptions &LangOpts,
- TokenBuffer Tokens)
-: SourceMgr(SourceMgr), LangOpts(LangOpts), Tokens(std::move(Tokens)) {}
+ const TokenBuffer &Tokens)
+: SourceMgr(SourceMgr), LangOpts(LangOpts), Tokens(Tokens) {}
 
 const clang::syntax::TokenBuffer &syntax::Arena::tokenBuffer() const {
   return Tokens;
Index: clang/include/clang/Tooling/Syntax/Tree.h
===
--- clang/include/clang/Tooling/Syntax/Tree.h
+++ clang/include/clang/Tooling/Syntax/Tree.h
@@ -39,7 +39,7 @@
 class Arena {
 public:
   Arena(SourceManager &SourceMgr, const LangOptions &LangOpts,
-TokenBuffer Tokens);
+const TokenBuffer &Tokens);
 
   const SourceManager &sourceManager() const { return SourceMgr; }
   const LangOptions &langOptions() const { return LangOpts; }
@@ -56,7 +56,7 @@
 private:
   SourceManager &SourceMgr;
   const LangOptions &LangOpts;
-  TokenBuffer Tokens;
+  const TokenBuffer &Tokens;
   /// IDs and storage for additional tokenized files.
   llvm::DenseMap> ExtraTokens;
   /// Keeps all the allocated nodes and their intermediate data structures.
__

[PATCH] D84005: Introduce ns_error_domain attribute.

2020-07-31 Thread Michael Forster via Phabricator via cfe-commits
MForster updated this revision to Diff 282168.
MForster added a comment.

Pretty-print VarDecl arguments correctly


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84005

Files:
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/Misc/pragma-attribute-supported-attributes-list.test
  clang/test/Sema/ns_error_enum.m
  clang/utils/TableGen/ClangAttrEmitter.cpp

Index: clang/utils/TableGen/ClangAttrEmitter.cpp
===
--- clang/utils/TableGen/ClangAttrEmitter.cpp
+++ clang/utils/TableGen/ClangAttrEmitter.cpp
@@ -329,6 +329,8 @@
 // empty string but are then recorded as a nullptr.
 OS << "\" << (get" << getUpperName() << "() ? get" << getUpperName()
<< "()->getName() : \"\") << \"";
+  else if (type == "VarDecl *")
+OS << "\" << get" << getUpperName() << "()->getName() << \"";
   else if (type == "TypeSourceInfo *")
 OS << "\" << get" << getUpperName() << "().getAsString() << \"";
   else if (type == "ParamIdx")
Index: clang/test/Sema/ns_error_enum.m
===
--- /dev/null
+++ clang/test/Sema/ns_error_enum.m
@@ -0,0 +1,66 @@
+// RUN: %clang_cc1 -verify %s -x objective-c
+// RUN: %clang_cc1 -verify %s -x objective-c++
+
+
+#define CF_ENUM(_type, _name) enum _name : _type _name; enum _name : _type
+#define NS_ENUM(_type, _name) CF_ENUM(_type, _name)
+
+#define NS_ERROR_ENUM(_type, _name, _domain)  \
+  enum _name : _type _name; enum __attribute__((ns_error_domain(_domain))) _name : _type
+
+typedef NS_ENUM(unsigned, MyEnum) {
+  MyFirst,
+  MySecond,
+};
+
+typedef NS_ENUM(invalidType, MyInvalidEnum) {
+// expected-error@-1{{unknown type name 'invalidType'}}
+// expected-error@-2{{unknown type name 'invalidType'}}
+  MyFirstInvalid,
+  MySecondInvalid,
+};
+
+@interface NSString
+@end
+
+extern NSString *const MyErrorDomain;
+typedef NS_ERROR_ENUM(unsigned char, MyErrorEnum, MyErrorDomain) {
+	MyErrFirst,
+	MyErrSecond,
+};
+
+typedef NSString *const NsErrorDomain;
+extern NsErrorDomain MyTypedefErrorDomain;
+typedef NS_ERROR_ENUM(unsigned char, MyTypedefErrorEnum, MyTypedefErrorDomain) {
+  MyTypedefErrFirst,
+  MyTypedefErrSecond,
+};
+
+extern char *const WrongErrorDomainType;
+enum __attribute__((ns_error_domain(WrongErrorDomainType))) MyWrongErrorDomainType { MyWrongErrorDomain };
+// expected-error@-1{{domain argument 'WrongErrorDomainType' does not point to an NSString constant}}
+
+struct __attribute__((ns_error_domain(MyErrorDomain))) MyStructWithErrorDomain {};
+// expected-error@-1{{'ns_error_domain' attribute only applies to enums}}
+
+int __attribute__((ns_error_domain(MyErrorDomain))) NotTagDecl;
+  // expected-error@-1{{'ns_error_domain' attribute only applies to enums}}
+
+enum __attribute__((ns_error_domain())) NoArg { NoArgError };
+// expected-error@-1{{'ns_error_domain' attribute takes one argument}}
+
+enum __attribute__((ns_error_domain(MyErrorDomain, MyErrorDomain))) TwoArgs { TwoArgsError };
+// expected-error@-1{{'ns_error_domain' attribute takes one argument}}
+
+typedef NS_ERROR_ENUM(unsigned char, MyErrorEnumInvalid, InvalidDomain) {
+	// expected-error@-1{{use of undeclared identifier 'InvalidDomain'}}
+	MyErrFirstInvalid,
+	MyErrSecondInvalid,
+};
+
+typedef NS_ERROR_ENUM(unsigned char, MyErrorEnumInvalid, "domain-string");
+  // expected-error@-1{{domain argument does not refer to global constant}}
+
+void foo() {}
+typedef NS_ERROR_ENUM(unsigned char, MyErrorEnumInvalidFunction, foo);
+  // expected-error@-1{{domain argument 'foo' does not refer to global constant}}
Index: clang/test/Misc/pragma-attribute-supported-attributes-list.test
===
--- clang/test/Misc/pragma-attribute-supported-attributes-list.test
+++ clang/test/Misc/pragma-attribute-supported-attributes-list.test
@@ -80,6 +80,7 @@
 // CHECK-NEXT: MipsShortCall (SubjectMatchRule_function)
 // CHECK-NEXT: NSConsumed (SubjectMatchRule_variable_is_parameter)
 // CHECK-NEXT: NSConsumesSelf (SubjectMatchRule_objc_method)
+// CHECK-NEXT: NSErrorDomain (SubjectMatchRule_enum)
 // CHECK-NEXT: Naked (SubjectMatchRule_function)
 // CHECK-NEXT: NoBuiltin (SubjectMatchRule_function)
 // CHECK-NEXT: NoCommon (SubjectMatchRule_variable)
Index: clang/lib/Sema/SemaDeclAttr.cpp
===
--- clang/lib/Sema/SemaDeclAttr.cpp
+++ clang/lib/Sema/SemaDeclAttr.cpp
@@ -21,6 +21,7 @@
 #include "clang/AST/ExprCXX.h"
 #include "clang/AST/Mangle.h"
 #include "clang/AST/RecursiveASTVisitor.h"
+#include "clang/AST/Type.h"
 #include "clang/Basic/CharInfo.h"
 #include "clang/Basic/SourceManager.h"
 #include "clang/Basic/TargetBuiltins.h"
@@ -30,12 +31,15 @@
 #

[PATCH] D75044: [AArch64] __builtin_return_address for PAuth.

2020-07-31 Thread Momchil Velikov via Phabricator via cfe-commits
chill requested changes to this revision.
chill added a comment.
This revision now requires changes to proceed.

Let's postpone this just for a little bit, to settle on an approach to `depth  
> 0`.


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

https://reviews.llvm.org/D75044

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


[PATCH] D75044: [AArch64] __builtin_return_address for PAuth.

2020-07-31 Thread Momchil Velikov via Phabricator via cfe-commits
chill added a comment.

In D75044#2186973 , @chill wrote:

> Let's postpone this just for a little bit, to settle on an approach to `depth 
>  > 0`.

This is with regard to https://reviews.llvm.org/D84502#inline-779900


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

https://reviews.llvm.org/D75044

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


[PATCH] D84814: [clang-tidy] readability-identifier-naming checks configs for included files

2020-07-31 Thread Nathan James via Phabricator via cfe-commits
njames93 updated this revision to Diff 282172.
njames93 added a comment.

Added Option GetConfigPerFile to control this behaviour.
Ensure the check is enabled in the header files configuration before using any 
configuration found.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84814

Files:
  clang-tools-extra/clang-tidy/ClangTidyCheck.cpp
  clang-tools-extra/clang-tidy/ClangTidyCheck.h
  clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
  clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/readability-identifier-naming.rst
  
clang-tools-extra/test/clang-tidy/checkers/Inputs/readability-identifier-naming/global-style-disabled/.clang-tidy
  
clang-tools-extra/test/clang-tidy/checkers/Inputs/readability-identifier-naming/global-style-disabled/header.h
  
clang-tools-extra/test/clang-tidy/checkers/Inputs/readability-identifier-naming/global-style1/.clang-tidy
  
clang-tools-extra/test/clang-tidy/checkers/Inputs/readability-identifier-naming/global-style1/header.h
  
clang-tools-extra/test/clang-tidy/checkers/Inputs/readability-identifier-naming/global-style2/.clang-tidy
  
clang-tools-extra/test/clang-tidy/checkers/Inputs/readability-identifier-naming/global-style2/header.h
  
clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming-multiple-styles.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming-multiple-styles.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming-multiple-styles.cpp
@@ -0,0 +1,40 @@
+// Setup header directory
+
+// RUN: rm -rf %theaders
+// RUN: mkdir %theaders
+// RUN: cp -R %S/Inputs/readability-identifier-naming/. %theaders
+
+// C++11 isn't explicitly required, but failing to specify a standard means the
+// check will run multiple times for different standards. This will cause the
+// second test to fail as the header file will be changed during the first run.
+
+// RUN: %check_clang_tidy -std=c++11 %s readability-identifier-naming %t -- \
+// RUN:   -config='{ InheritParentConfig: true, CheckOptions: [ \
+// RUN: {key: readability-identifier-naming.FunctionCase, value: camelBack} \
+// RUN:  ]}' -header-filter='.*' -- -I%theaders
+
+#include "global-style-disabled/header.h"
+#include "global-style1/header.h"
+#include "global-style2/header.h"
+// CHECK-MESSAGES-DAG: global-style1/header.h:5:6: warning: invalid case style for global function 'style1Bad'
+// CHECK-MESSAGES-DAG: global-style2/header.h:5:6: warning: invalid case style for global function 'style2Bad'
+
+void goodStyle() {
+  style1_good();
+  STYLE2_GOOD();
+}
+// CHECK-MESSAGES-DAG: :[[@LINE+1]]:6: warning: invalid case style for function 'bad_style'
+void bad_style() {
+  style1Bad();
+  style2Bad();
+}
+//  CHECK-FIXES: void badStyle() {
+// CHECK-FIXES-NEXT:   style1_bad();
+// CHECK-FIXES-NEXT:   STYLE2_BAD();
+// CHECK-FIXES-NEXT: }
+
+void expectNoStyle() {
+  disabled_style();
+  disabledStyle();
+  DISABLED_STYLE();
+}
Index: clang-tools-extra/test/clang-tidy/checkers/Inputs/readability-identifier-naming/global-style2/header.h
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/Inputs/readability-identifier-naming/global-style2/header.h
@@ -0,0 +1,5 @@
+
+
+void STYLE2_GOOD();
+
+void style2Bad();
Index: clang-tools-extra/test/clang-tidy/checkers/Inputs/readability-identifier-naming/global-style2/.clang-tidy
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/Inputs/readability-identifier-naming/global-style2/.clang-tidy
@@ -0,0 +1,5 @@
+Checks: readability-identifier-naming
+CheckOptions:
+  - key: readability-identifier-naming.GlobalFunctionCase
+value:   UPPER_CASE
+
Index: clang-tools-extra/test/clang-tidy/checkers/Inputs/readability-identifier-naming/global-style1/header.h
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/Inputs/readability-identifier-naming/global-style1/header.h
@@ -0,0 +1,5 @@
+
+
+void style1_good();
+
+void style1Bad();
Index: clang-tools-extra/test/clang-tidy/checkers/Inputs/readability-identifier-naming/global-style1/.clang-tidy
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/Inputs/readability-identifier-naming/global-style1/.clang-tidy
@@ -0,0 +1,5 @@
+Checks: readability-identifier-naming
+CheckOptions:
+  - key: readability-identifier-naming.GlobalFunctionCase
+value:   lower_case
+
Index: clang-tools-extra/test/clang-tidy/checkers/Inputs/readability-identifier-

[PATCH] D85016: [clang-format] Add space between method modifier and a tuple return type in C#

2020-07-31 Thread Łukasz Krawczyk via Phabricator via cfe-commits
lbk created this revision.
lbk added reviewers: jbcoe, krasimir.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
lbk requested review of this revision.

"public (string name, int age) methodTuple() {}" is now properly spaced


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D85016

Files:
  clang/lib/Format/TokenAnnotator.cpp
  clang/unittests/Format/FormatTestCSharp.cpp


Index: clang/unittests/Format/FormatTestCSharp.cpp
===
--- clang/unittests/Format/FormatTestCSharp.cpp
+++ clang/unittests/Format/FormatTestCSharp.cpp
@@ -777,6 +777,9 @@
   verifyFormat(R"(private float[ , ] Values;)", Style);
   verifyFormat(R"(string dirPath = args?[ 0 ];)", Style);
   verifyFormat(R"(char[ ,, ] rawCharArray = MakeCharacterGrid();)", Style);
+
+  // Method returning tuple
+  verifyFormat(R"(public (string name, int age) methodTuple() {})", Style);
 }
 
 TEST_F(FormatTestCSharp, CSharpNullableTypes) {
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -3115,6 +3115,16 @@
Keywords.kw_lock))
 return Style.SpaceBeforeParens == FormatStyle::SBPO_ControlStatements 
||
spaceRequiredBeforeParens(Right);
+
+// space between method modifier and opening parenthesis of a tuple return
+// type
+if (Left.isOneOf(tok::kw_public, tok::kw_private, tok::kw_protected,
+ tok::kw_virtual, tok::kw_extern, tok::kw_static,
+ tok::kw_new, Keywords.kw_internal, Keywords.kw_abstract,
+ Keywords.kw_sealed, Keywords.kw_override,
+ Keywords.kw_async, Keywords.kw_unsafe) &&
+Right.is(tok::l_paren))
+  return true;
   } else if (Style.Language == FormatStyle::LK_JavaScript) {
 if (Left.is(TT_JsFatArrow))
   return true;


Index: clang/unittests/Format/FormatTestCSharp.cpp
===
--- clang/unittests/Format/FormatTestCSharp.cpp
+++ clang/unittests/Format/FormatTestCSharp.cpp
@@ -777,6 +777,9 @@
   verifyFormat(R"(private float[ , ] Values;)", Style);
   verifyFormat(R"(string dirPath = args?[ 0 ];)", Style);
   verifyFormat(R"(char[ ,, ] rawCharArray = MakeCharacterGrid();)", Style);
+
+  // Method returning tuple
+  verifyFormat(R"(public (string name, int age) methodTuple() {})", Style);
 }
 
 TEST_F(FormatTestCSharp, CSharpNullableTypes) {
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -3115,6 +3115,16 @@
Keywords.kw_lock))
 return Style.SpaceBeforeParens == FormatStyle::SBPO_ControlStatements ||
spaceRequiredBeforeParens(Right);
+
+// space between method modifier and opening parenthesis of a tuple return
+// type
+if (Left.isOneOf(tok::kw_public, tok::kw_private, tok::kw_protected,
+ tok::kw_virtual, tok::kw_extern, tok::kw_static,
+ tok::kw_new, Keywords.kw_internal, Keywords.kw_abstract,
+ Keywords.kw_sealed, Keywords.kw_override,
+ Keywords.kw_async, Keywords.kw_unsafe) &&
+Right.is(tok::l_paren))
+  return true;
   } else if (Style.Language == FormatStyle::LK_JavaScript) {
 if (Left.is(TT_JsFatArrow))
   return true;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D66035: [WebAssembly] WIP: Add support for reference types

2020-07-31 Thread Paulo Matos via Phabricator via cfe-commits
pmatos added a comment.

In D66035#2181659 , @pmatos wrote:

> I will be splitting the part enabling the target feature through clang into a 
> separate revision as suggested by @tlively

I just noticed that most of this work landed in an earlier commit: 
https://github.com/llvm/llvm-project/commit/764f4089e89e4693b7bb8f1ee18080703ce760dd
I should have seen it but I based my work initially on 10.0.0 so failed to 
notice that.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66035

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


[PATCH] D84979: [analyzer][NFC] Refine CStringLength modeling API

2020-07-31 Thread Balázs Benics via Phabricator via cfe-commits
steakhal added a comment.

It seems the Pre-merge clang-format went crazy.
I think just ignore the lint warnings for the unchanged lines.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84979

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


[PATCH] D84005: Introduce ns_error_domain attribute.

2020-07-31 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/utils/TableGen/ClangAttrEmitter.cpp:332
<< "()->getName() : \"\") << \"";
+  else if (type == "VarDecl *")
+OS << "\" << get" << getUpperName() << "()->getName() << \"";

I think this change is good, but if you wouldn't mind adding an ast dumping 
test (in the AST test directory) that exercises the change, I'd appreciate it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84005

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


[PATCH] D84814: [clang-tidy] readability-identifier-naming checks configs for included files

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

This looks reasonable to me.




Comment at: 
clang-tools-extra/test/clang-tidy/checkers/Inputs/readability-identifier-naming/global-style-disabled/header.h:4
+void DISABLED_STYLE();
\ No newline at end of file


Can you add a newline to the end of this file?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84814

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


[PATCH] D85022: Need to ensure the datalayout differs when using externref

2020-07-31 Thread Paulo Matos via Phabricator via cfe-commits
pmatos created this revision.
Herald added subscribers: cfe-commits, jgravelle-google, sbc100, dschuff.
Herald added a project: clang.
pmatos requested review of this revision.
Herald added a subscriber: aheejin.

externref needs address space 256.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D85022

Files:
  clang/lib/Basic/Targets/WebAssembly.cpp


Index: clang/lib/Basic/Targets/WebAssembly.cpp
===
--- clang/lib/Basic/Targets/WebAssembly.cpp
+++ clang/lib/Basic/Targets/WebAssembly.cpp
@@ -232,6 +232,7 @@
 }
 if (Feature == "+reference-types") {
   HasReferenceTypes = true;
+  resetDataLayout("e-m:e-p:32:32-i64:64-n32:64-S128-ni:256");
   continue;
 }
 if (Feature == "-reference-types") {


Index: clang/lib/Basic/Targets/WebAssembly.cpp
===
--- clang/lib/Basic/Targets/WebAssembly.cpp
+++ clang/lib/Basic/Targets/WebAssembly.cpp
@@ -232,6 +232,7 @@
 }
 if (Feature == "+reference-types") {
   HasReferenceTypes = true;
+  resetDataLayout("e-m:e-p:32:32-i64:64-n32:64-S128-ni:256");
   continue;
 }
 if (Feature == "-reference-types") {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D85022: Need to ensure the datalayout differs when using externref

2020-07-31 Thread Paulo Matos via Phabricator via cfe-commits
pmatos abandoned this revision.
pmatos added a comment.

Mistakingly created - this should have gone to D66035 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85022

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


[PATCH] D84029: [clang][Driver] Default to /usr/bin/ld on Solaris

2020-07-31 Thread Rainer Orth via Phabricator via cfe-commits
ro updated this revision to Diff 282192.
ro added a comment.
Herald added subscribers: llvm-commits, ormris, delcypher.
Herald added a project: LLVM.

Add testcase.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84029

Files:
  clang/lib/Driver/ToolChain.cpp
  clang/lib/Driver/ToolChains/Solaris.h
  clang/test/Driver/solaris-ld-sld.c
  llvm/utils/lit/lit/llvm/config.py


Index: llvm/utils/lit/lit/llvm/config.py
===
--- llvm/utils/lit/lit/llvm/config.py
+++ llvm/utils/lit/lit/llvm/config.py
@@ -59,6 +59,8 @@
 features.add('system-netbsd')
 elif platform.system() == 'AIX':
 features.add('system-aix')
+elif platform.system() == 'SunOS':
+features.add('system-solaris')
 
 # Native compilation: host arch == default triple arch
 # Both of these values should probably be in every site config (e.g. as
Index: clang/test/Driver/solaris-ld-sld.c
===
--- /dev/null
+++ clang/test/Driver/solaris-ld-sld.c
@@ -0,0 +1,9 @@
+// REQUIRES: system-solaris
+
+// Check that clang invokes the native ld.
+
+// FIXME: Test should be UNSUPPORTED if GNU ld isn't installed.
+// RUN: test -f /usr/gnu/bin/ld
+// RUN: env PATH=/usr/gnu/bin %clang -o %t.o %s
+
+int main() { return 0; }
Index: clang/lib/Driver/ToolChains/Solaris.h
===
--- clang/lib/Driver/ToolChains/Solaris.h
+++ clang/lib/Driver/ToolChains/Solaris.h
@@ -65,6 +65,11 @@
   SanitizerMask getSupportedSanitizers() const override;
   unsigned GetDefaultDwarfVersion() const override { return 2; }
 
+  const char *getDefaultLinker() const override {
+// clang currently uses Solaris ld-only options.
+return "/usr/bin/ld";
+  }
+
 protected:
   Tool *buildAssembler() const override;
   Tool *buildLinker() const override;
Index: clang/lib/Driver/ToolChain.cpp
===
--- clang/lib/Driver/ToolChain.cpp
+++ clang/lib/Driver/ToolChain.cpp
@@ -568,8 +568,13 @@
   }
   // If we're passed -fuse-ld= with no argument, or with the argument ld,
   // then use whatever the default system linker is.
-  if (UseLinker.empty() || UseLinker == "ld")
-return GetProgramPath(getDefaultLinker());
+  if (UseLinker.empty() || UseLinker == "ld") {
+const char *DefaultLinker = getDefaultLinker();
+if (!llvm::sys::path::is_absolute(DefaultLinker))
+  return GetProgramPath(DefaultLinker);
+else
+  return std::string(DefaultLinker);
+  }
 
   // Extending -fuse-ld= to an absolute or relative path is unexpected. 
Checking
   // for the linker flavor is brittle. In addition, prepending "ld." or "ld64."


Index: llvm/utils/lit/lit/llvm/config.py
===
--- llvm/utils/lit/lit/llvm/config.py
+++ llvm/utils/lit/lit/llvm/config.py
@@ -59,6 +59,8 @@
 features.add('system-netbsd')
 elif platform.system() == 'AIX':
 features.add('system-aix')
+elif platform.system() == 'SunOS':
+features.add('system-solaris')
 
 # Native compilation: host arch == default triple arch
 # Both of these values should probably be in every site config (e.g. as
Index: clang/test/Driver/solaris-ld-sld.c
===
--- /dev/null
+++ clang/test/Driver/solaris-ld-sld.c
@@ -0,0 +1,9 @@
+// REQUIRES: system-solaris
+
+// Check that clang invokes the native ld.
+
+// FIXME: Test should be UNSUPPORTED if GNU ld isn't installed.
+// RUN: test -f /usr/gnu/bin/ld
+// RUN: env PATH=/usr/gnu/bin %clang -o %t.o %s
+
+int main() { return 0; }
Index: clang/lib/Driver/ToolChains/Solaris.h
===
--- clang/lib/Driver/ToolChains/Solaris.h
+++ clang/lib/Driver/ToolChains/Solaris.h
@@ -65,6 +65,11 @@
   SanitizerMask getSupportedSanitizers() const override;
   unsigned GetDefaultDwarfVersion() const override { return 2; }
 
+  const char *getDefaultLinker() const override {
+// clang currently uses Solaris ld-only options.
+return "/usr/bin/ld";
+  }
+
 protected:
   Tool *buildAssembler() const override;
   Tool *buildLinker() const override;
Index: clang/lib/Driver/ToolChain.cpp
===
--- clang/lib/Driver/ToolChain.cpp
+++ clang/lib/Driver/ToolChain.cpp
@@ -568,8 +568,13 @@
   }
   // If we're passed -fuse-ld= with no argument, or with the argument ld,
   // then use whatever the default system linker is.
-  if (UseLinker.empty() || UseLinker == "ld")
-return GetProgramPath(getDefaultLinker());
+  if (UseLinker.empty() || UseLinker == "ld") {
+const char *DefaultLinker = getDefaultLinker();
+if (!llvm::sys::p

[PATCH] D66035: [WebAssembly] WIP: Add support for reference types

2020-07-31 Thread Paulo Matos via Phabricator via cfe-commits
pmatos updated this revision to Diff 282194.
pmatos added a comment.

Update externref patch


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66035

Files:
  clang/lib/Basic/Targets/WebAssembly.cpp
  lld/wasm/WriterUtils.cpp
  llvm/include/llvm/BinaryFormat/Wasm.h
  llvm/include/llvm/BinaryFormat/WasmRelocs.def
  llvm/include/llvm/CodeGen/TargetLowering.h
  llvm/include/llvm/CodeGen/ValueTypes.td
  llvm/include/llvm/MC/MCExpr.h
  llvm/include/llvm/MC/MCSymbolWasm.h
  llvm/include/llvm/Object/Wasm.h
  llvm/include/llvm/Support/MachineValueType.h
  llvm/lib/BinaryFormat/Wasm.cpp
  llvm/lib/CodeGen/CodeGenPrepare.cpp
  llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
  llvm/lib/CodeGen/ValueTypes.cpp
  llvm/lib/MC/MCExpr.cpp
  llvm/lib/MC/WasmObjectWriter.cpp
  llvm/lib/Object/WasmObjectFile.cpp
  llvm/lib/ObjectYAML/WasmEmitter.cpp
  llvm/lib/ObjectYAML/WasmYAML.cpp
  llvm/lib/Target/WebAssembly/AsmParser/WebAssemblyAsmParser.cpp
  llvm/lib/Target/WebAssembly/Disassembler/WebAssemblyDisassembler.cpp
  llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyInstPrinter.cpp
  llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCCodeEmitter.cpp
  llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCTargetDesc.cpp
  llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCTargetDesc.h
  llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyWasmObjectWriter.cpp
  llvm/lib/Target/WebAssembly/WebAssembly.h
  llvm/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyExplicitLocals.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyFastISel.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.h
  llvm/lib/Target/WebAssembly/WebAssemblyInstrInfo.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyInstrInfo.td
  llvm/lib/Target/WebAssembly/WebAssemblyInstrTable.td
  llvm/lib/Target/WebAssembly/WebAssemblyMCInstLower.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyPeephole.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyRegisterInfo.td
  llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
  llvm/test/CodeGen/WebAssembly/externref.ll
  llvm/test/CodeGen/WebAssembly/reg-argument.mir
  llvm/test/CodeGen/WebAssembly/reg-copy.mir
  llvm/utils/TableGen/CodeGenTarget.cpp

Index: llvm/utils/TableGen/CodeGenTarget.cpp
===
--- llvm/utils/TableGen/CodeGenTarget.cpp
+++ llvm/utils/TableGen/CodeGenTarget.cpp
@@ -219,6 +219,7 @@
   case MVT::iPTRAny:  return "MVT::iPTRAny";
   case MVT::Untyped:  return "MVT::Untyped";
   case MVT::exnref:   return "MVT::exnref";
+  case MVT::externref:   return "MVT::externref";
   default: llvm_unreachable("ILLEGAL VALUE TYPE!");
   }
 }
Index: llvm/test/CodeGen/WebAssembly/reg-copy.mir
===
--- llvm/test/CodeGen/WebAssembly/reg-copy.mir
+++ llvm/test/CodeGen/WebAssembly/reg-copy.mir
@@ -66,3 +66,14 @@
 %0:exnref = COPY %1:exnref
 RETURN implicit-def $arguments
 ...
+---
+name: copy_externref
+# CHECK-LABEL: copy_externref
+body: |
+  ; CHECK-LABEL: bb.0
+  ; CHECK-NEXT: %0:externref = COPY_EXTERNREF %1:externref
+  ; CHECK-NEXT: RETURN
+  bb.0:
+%0:externref = COPY %1:externref
+RETURN implicit-def $arguments
+...
Index: llvm/test/CodeGen/WebAssembly/reg-argument.mir
===
--- llvm/test/CodeGen/WebAssembly/reg-argument.mir
+++ llvm/test/CodeGen/WebAssembly/reg-argument.mir
@@ -57,3 +57,14 @@
 %1:exnref = ARGUMENT_exnref 0, implicit $arguments
 RETURN implicit-def $arguments
 ...
+---
+name: argument_externref
+# CHECK-LABEL: argument_externref
+body: |
+  ; CHECK-LABEL: bb.0:
+  ; CHECK-NEXT: %1:externref = ARGUMENT_externref 0
+  bb.0:
+%0:i32 = CONST_I32 0, implicit-def $arguments
+%1:externref = ARGUMENT_externref 0, implicit $arguments
+RETURN implicit-def $arguments
+...
Index: llvm/test/CodeGen/WebAssembly/externref.ll
===
--- /dev/null
+++ llvm/test/CodeGen/WebAssembly/externref.ll
@@ -0,0 +1,29 @@
+; RUN: llc < %s -asm-verbose=false -disable-wasm-fallthrough-return-opt -wasm-disable-explicit-locals -wasm-keep-registers -mattr=+reference-types | FileCheck %s
+
+target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128-ni:256"
+target triple = "wasm32-unknown-unknown"
+
+declare i8 addrspace(256)* @test(i8 addrspace(256)*) 
+
+
+; CHECK-LABEL: call_test:
+; CHECK: .functype   call_test (externref) -> (externref)
+define i8 addrspace(256)* @call_test(i8 addrspace(256)*) {
+; CHECK: call $push0=, test, $0
+  %a = call i8 addrspace(256)* @test(i8 addrspace(256)* %0) 
+  ret i8 addrspace(256)* %a
+}
+
+; TODO: nullref?
+; define i8 addrspace(256)* @null_test() {
+;   ret i8 addrspace(256)* null
+; }
+
+; TODO: Loading a externref from a pointe

[PATCH] D84029: [clang][Driver] Default to /usr/bin/ld on Solaris

2020-07-31 Thread Rainer Orth via Phabricator via cfe-commits
ro added a comment.

In D84029#2170105 , @MaskRay wrote:

> Can you add a test to `test/Driver/solaris-ld.c`?

No, this needs a separate testcase: the `-C` option unconditionally passed to 
the linker is only understood by the native `ld`.

I've added `solaris-ld-sld.c` instead, and also need a `system-solaris` feature 
to restrict it.  Since `/usr/gnu/bin/ld` isn't necessarily installed, there 
should be a way to mark the test `UNSUPPORTED` if it's missing.  I couldn't 
find how to do so, though.

Tested on `amd64-pc-solaris2.11` (`FAIL`s without the patch, `PASS`es with it) 
and `x86_64-pc-linux-gnu` (comes up `UNSUPPORTED`).

>> However, if someone forgets this, it depends on the user's PATH whether or 
>> not clang finds the correct linker, which doesn't make for a good user 
>> experience.
>
> Not very sure about this. The last resort of GetProgramPath is `PATH`. On 
> FreeBSD and Linux, this is how `/usr/bin/ld` gets selected. PATH can affect 
> `ld` choice.

True, but all possible linkers strive to be GNU `ld` compatible on those 
systems.  OTOH, on proprietary systems (Solaris, HP-UX, AIX, previsously IRIX, 
Tru64 UNIX) there was a native linker years if not decades before GNU `ld` 
started. Sometimes `gld` has added some options for compatibility with the 
native linker, sometimes native linkers (like the Solaris one later in the 
Solaris 11 cycle) added some options for `gld` compatiblity.

However, they usually have different options apart from the very basic ones 
(`-L`, `-l`, `-o`) and one needs to select the right one to avoid mismatches. 
Alternatively, one could  detect the linker flavour at runtime and adapt 
accordingly.  However, the native linkers are usually more featureful/better 
integrated with the system and thus the primary choice.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84029

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


[PATCH] D77776: [Driver] Default to libc++ on FreeBSD

2020-07-31 Thread Greg V via Phabricator via cfe-commits
myfreeweb added a comment.

ping. can we get *some* solution to this included in llvm 11.0 final release?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D6

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


[PATCH] D84839: Add document outline symbols from unnamed contexts, e.g. extern "C".

2020-07-31 Thread Ilya Golovenko via Phabricator via cfe-commits
ilya-golovenko updated this revision to Diff 282197.
ilya-golovenko added a comment.

Changes afte code review, add test for export context


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84839

Files:
  clang-tools-extra/clangd/FindSymbols.cpp
  clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp

Index: clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
===
--- clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
+++ clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
@@ -429,6 +429,40 @@
   EXPECT_THAT(getSymbols(TU.build()), IsEmpty());
 }
 
+TEST(DocumentSymbols, ExternContext) {
+  TestTU TU;
+  TU.Code = R"cpp(
+  extern "C" {
+  void foo();
+  class Foo {};
+  }
+  namespace ns {
+extern "C" {
+void bar();
+class Bar {};
+}
+  })cpp";
+
+  EXPECT_THAT(getSymbols(TU.build()),
+  ElementsAre(WithName("foo"), WithName("Foo"),
+  AllOf(WithName("ns"),
+Children(WithName("bar"), WithName("Bar");
+}
+
+TEST(DocumentSymbols, ExportContext) {
+  TestTU TU;
+  TU.ExtraArgs = {"-std=c++20"};
+  TU.Code = R"cpp(
+  export module test;
+  export {
+  void foo();
+  class Foo {};
+  })cpp";
+
+  EXPECT_THAT(getSymbols(TU.build()),
+  ElementsAre(WithName("foo"), WithName("Foo")));
+}
+
 TEST(DocumentSymbols, NoLocals) {
   TestTU TU;
   TU.Code = R"cpp(
Index: clang-tools-extra/clangd/FindSymbols.cpp
===
--- clang-tools-extra/clangd/FindSymbols.cpp
+++ clang-tools-extra/clangd/FindSymbols.cpp
@@ -188,7 +188,7 @@
   }
 
 private:
-  enum class VisitKind { No, OnlyDecl, DeclAndChildren };
+  enum class VisitKind { No, OnlyDecl, OnlyChildren, DeclAndChildren };
 
   void traverseDecl(Decl *D, std::vector &Results) {
 if (auto *Templ = llvm::dyn_cast(D)) {
@@ -196,18 +196,20 @@
   if (auto *TD = Templ->getTemplatedDecl())
 D = TD;
 }
-auto *ND = llvm::dyn_cast(D);
-if (!ND)
-  return;
-VisitKind Visit = shouldVisit(ND);
+
+VisitKind Visit = shouldVisit(D);
 if (Visit == VisitKind::No)
   return;
-llvm::Optional Sym = declToSym(AST.getASTContext(), *ND);
-if (!Sym)
-  return;
-if (Visit == VisitKind::DeclAndChildren)
-  traverseChildren(D, Sym->children);
-Results.push_back(std::move(*Sym));
+if (Visit == VisitKind::OnlyChildren) {
+  traverseChildren(D, Results);
+} else {
+  auto *ND = llvm::cast(D);
+  if (auto Sym = declToSym(AST.getASTContext(), *ND)) {
+if (Visit == VisitKind::DeclAndChildren)
+  traverseChildren(ND, Sym->children);
+Results.push_back(std::move(*Sym));
+  }
+}
   }
 
   void traverseChildren(Decl *D, std::vector &Results) {
@@ -218,10 +220,16 @@
   traverseDecl(C, Results);
   }
 
-  VisitKind shouldVisit(NamedDecl *D) {
+  VisitKind shouldVisit(Decl *D) {
 if (D->isImplicit())
   return VisitKind::No;
 
+if (llvm::isa(D) || llvm::isa(D))
+  return VisitKind::OnlyChildren;
+
+if (!llvm::isa(D))
+  return VisitKind::No;
+
 if (auto Func = llvm::dyn_cast(D)) {
   // Some functions are implicit template instantiations, those should be
   // ignored.
@@ -260,7 +268,7 @@
   }
 
   ParsedAST &AST;
-};
+}; // namespace
 
 std::vector collectDocSymbols(ParsedAST &AST) {
   return DocumentOutline(AST).build();
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D84839: Add document outline symbols from unnamed contexts, e.g. extern "C".

2020-07-31 Thread Ilya Golovenko via Phabricator via cfe-commits
ilya-golovenko added a comment.

@kadircet I decided to add `OnlyChildren` to `enum VisitKind` instead of making 
a `VisitKindSet` - this helped to minimize the changes in `shouldVisit()`.  
What do you think?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84839

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


[PATCH] D84839: Add document outline symbols from unnamed contexts, e.g. extern "C".

2020-07-31 Thread Ilya Golovenko via Phabricator via cfe-commits
ilya-golovenko updated this revision to Diff 282198.
ilya-golovenko added a comment.

Remove invalid comment


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84839

Files:
  clang-tools-extra/clangd/FindSymbols.cpp
  clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp

Index: clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
===
--- clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
+++ clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
@@ -429,6 +429,40 @@
   EXPECT_THAT(getSymbols(TU.build()), IsEmpty());
 }
 
+TEST(DocumentSymbols, ExternContext) {
+  TestTU TU;
+  TU.Code = R"cpp(
+  extern "C" {
+  void foo();
+  class Foo {};
+  }
+  namespace ns {
+extern "C" {
+void bar();
+class Bar {};
+}
+  })cpp";
+
+  EXPECT_THAT(getSymbols(TU.build()),
+  ElementsAre(WithName("foo"), WithName("Foo"),
+  AllOf(WithName("ns"),
+Children(WithName("bar"), WithName("Bar");
+}
+
+TEST(DocumentSymbols, ExportContext) {
+  TestTU TU;
+  TU.ExtraArgs = {"-std=c++20"};
+  TU.Code = R"cpp(
+  export module test;
+  export {
+  void foo();
+  class Foo {};
+  })cpp";
+
+  EXPECT_THAT(getSymbols(TU.build()),
+  ElementsAre(WithName("foo"), WithName("Foo")));
+}
+
 TEST(DocumentSymbols, NoLocals) {
   TestTU TU;
   TU.Code = R"cpp(
Index: clang-tools-extra/clangd/FindSymbols.cpp
===
--- clang-tools-extra/clangd/FindSymbols.cpp
+++ clang-tools-extra/clangd/FindSymbols.cpp
@@ -188,7 +188,7 @@
   }
 
 private:
-  enum class VisitKind { No, OnlyDecl, DeclAndChildren };
+  enum class VisitKind { No, OnlyDecl, OnlyChildren, DeclAndChildren };
 
   void traverseDecl(Decl *D, std::vector &Results) {
 if (auto *Templ = llvm::dyn_cast(D)) {
@@ -196,18 +196,20 @@
   if (auto *TD = Templ->getTemplatedDecl())
 D = TD;
 }
-auto *ND = llvm::dyn_cast(D);
-if (!ND)
-  return;
-VisitKind Visit = shouldVisit(ND);
+
+VisitKind Visit = shouldVisit(D);
 if (Visit == VisitKind::No)
   return;
-llvm::Optional Sym = declToSym(AST.getASTContext(), *ND);
-if (!Sym)
-  return;
-if (Visit == VisitKind::DeclAndChildren)
-  traverseChildren(D, Sym->children);
-Results.push_back(std::move(*Sym));
+if (Visit == VisitKind::OnlyChildren) {
+  traverseChildren(D, Results);
+} else {
+  auto *ND = llvm::cast(D);
+  if (auto Sym = declToSym(AST.getASTContext(), *ND)) {
+if (Visit == VisitKind::DeclAndChildren)
+  traverseChildren(ND, Sym->children);
+Results.push_back(std::move(*Sym));
+  }
+}
   }
 
   void traverseChildren(Decl *D, std::vector &Results) {
@@ -218,10 +220,16 @@
   traverseDecl(C, Results);
   }
 
-  VisitKind shouldVisit(NamedDecl *D) {
+  VisitKind shouldVisit(Decl *D) {
 if (D->isImplicit())
   return VisitKind::No;
 
+if (llvm::isa(D) || llvm::isa(D))
+  return VisitKind::OnlyChildren;
+
+if (!llvm::isa(D))
+  return VisitKind::No;
+
 if (auto Func = llvm::dyn_cast(D)) {
   // Some functions are implicit template instantiations, those should be
   // ignored.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] 0d25d3b - [clang-tidy] Fix build problem after commit 45a720a864320bbbeb596a

2020-07-31 Thread Bjorn Pettersson via cfe-commits

Author: Bjorn Pettersson
Date: 2020-07-31T14:29:03+02:00
New Revision: 0d25d3b7e3e3acb86d93acb2291c1d26e056746b

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

LOG: [clang-tidy] Fix build problem after commit 45a720a864320bbbeb596a

When building with LLVM8.0 on RHEL7.8 I got failures like this
after commit 45a720a864320bbbe:

/app/llvm/8.0/bin/../lib/gcc/x86_64-unknown-linux-gnu/
5.4.0/../../../../include/c++/5.4.0/ext/new_allocator.h:120:23:
error: no matching constructor for initialization of
'std::pair,
std::__cxx11::basic_string >'
{ ::new((void *)__p) _Up(std::forward<_Args>(__args)...); }

...

../../clang-tools-extra/clang-tidy/ClangTidyOptions.cpp:73:15:
note: in instantiation of function template specialization
'std::vector,
std::__cxx11::basic_string >,
std::allocator,
std::__cxx11::basic_string > > >::emplace_back &>' requested here
Options.emplace_back(KeyValue.getKey(), KeyValue.getValue().Value);

This is an attempt to avoid such build problems.

Added: 


Modified: 
clang-tools-extra/clang-tidy/ClangTidyOptions.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/ClangTidyOptions.cpp 
b/clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
index 19ba47f005dc..6b28cb2bdd13 100644
--- a/clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
+++ b/clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
@@ -70,7 +70,7 @@ struct NOptionMap {
   NOptionMap(IO &, const ClangTidyOptions::OptionMap &OptionMap) {
 Options.reserve(OptionMap.size());
 for (const auto &KeyValue : OptionMap)
-  Options.emplace_back(KeyValue.getKey(), KeyValue.getValue().Value);
+  Options.emplace_back(std::string(KeyValue.getKey()), 
KeyValue.getValue().Value);
   }
   ClangTidyOptions::OptionMap denormalize(IO &) {
 ClangTidyOptions::OptionMap Map;



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


[clang-tools-extra] 638f0cf - [clangd] Be more explicit on testing the optional DefLoc in LocatedSymbol.

2020-07-31 Thread Haojian Wu via cfe-commits

Author: Haojian Wu
Date: 2020-07-31T14:34:56+02:00
New Revision: 638f0cf565f2121151c32d7eb52a1de0e333d5f6

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

LOG: [clangd] Be more explicit on testing the optional DefLoc in LocatedSymbol.

And also fix a bug where we may return a meaningless location.

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

Added: 


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

Removed: 




diff  --git a/clang-tools-extra/clangd/XRefs.cpp 
b/clang-tools-extra/clangd/XRefs.cpp
index cf747b607f4a..1fc89f3e0847 100644
--- a/clang-tools-extra/clangd/XRefs.cpp
+++ b/clang-tools-extra/clangd/XRefs.cpp
@@ -405,15 +405,17 @@ locateSymbolTextually(const SpelledWord &Word, ParsedAST 
&AST,
   log("locateSymbolNamedTextuallyAt: {0}", MaybeDeclLoc.takeError());
   return;
 }
-Location DeclLoc = *MaybeDeclLoc;
-Location DefLoc;
+LocatedSymbol Located;
+Located.PreferredDeclaration = *MaybeDeclLoc;
+Located.Name = (Sym.Name + Sym.TemplateSpecializationArgs).str();
 if (Sym.Definition) {
   auto MaybeDefLoc = indexToLSPLocation(Sym.Definition, MainFilePath);
   if (!MaybeDefLoc) {
 log("locateSymbolNamedTextuallyAt: {0}", MaybeDefLoc.takeError());
 return;
   }
-  DefLoc = *MaybeDefLoc;
+  Located.PreferredDeclaration = *MaybeDefLoc;
+  Located.Definition = *MaybeDefLoc;
 }
 
 if (ScoredResults.size() >= 3) {
@@ -424,11 +426,6 @@ locateSymbolTextually(const SpelledWord &Word, ParsedAST 
&AST,
   return;
 }
 
-LocatedSymbol Located;
-Located.Name = (Sym.Name + Sym.TemplateSpecializationArgs).str();
-Located.PreferredDeclaration = bool(Sym.Definition) ? DefLoc : DeclLoc;
-Located.Definition = DefLoc;
-
 SymbolQualitySignals Quality;
 Quality.merge(Sym);
 SymbolRelevanceSignals Relevance;

diff  --git a/clang-tools-extra/clangd/unittests/XRefsTests.cpp 
b/clang-tools-extra/clangd/unittests/XRefsTests.cpp
index 0a8f85ed5317..c9c115fd19d8 100644
--- a/clang-tools-extra/clangd/unittests/XRefsTests.cpp
+++ b/clang-tools-extra/clangd/unittests/XRefsTests.cpp
@@ -41,6 +41,7 @@ using ::testing::ElementsAre;
 using ::testing::Eq;
 using ::testing::IsEmpty;
 using ::testing::Matcher;
+using ::testing::UnorderedElementsAre;
 using ::testing::UnorderedElementsAreArray;
 
 MATCHER_P2(FileRange, File, Range, "") {
@@ -264,19 +265,23 @@ MATCHER_P3(Sym, Name, Decl, DefOrNone, "") {
  << llvm::to_string(arg.PreferredDeclaration);
 return false;
   }
+  if (!Def && !arg.Definition)
+return true;
   if (Def && !arg.Definition) {
 *result_listener << "Has no definition";
 return false;
   }
-  if (Def && arg.Definition->range != *Def) {
+  if (!Def && arg.Definition) {
+*result_listener << "Definition is " << llvm::to_string(arg.Definition);
+return false;
+  }
+  if (arg.Definition->range != *Def) {
 *result_listener << "Definition is " << llvm::to_string(arg.Definition);
 return false;
   }
   return true;
 }
-::testing::Matcher Sym(std::string Name, Range Decl) {
-  return Sym(Name, Decl, llvm::None);
-}
+
 MATCHER_P(Sym, Name, "") { return arg.Name == Name; }
 
 MATCHER_P(RangeIs, R, "") { return arg.range == R; }
@@ -771,7 +776,7 @@ TEST(LocateSymbol, TextualSmoke) {
   auto AST = TU.build();
   auto Index = TU.index();
   EXPECT_THAT(locateSymbolAt(AST, T.point(), Index.get()),
-  ElementsAre(Sym("MyClass", T.range(;
+  ElementsAre(Sym("MyClass", T.range(), T.range(;
 }
 
 TEST(LocateSymbol, Textual) {
@@ -891,18 +896,20 @@ TEST(LocateSymbol, Ambiguous) {
   // FIXME: Target the constructor as well.
   EXPECT_THAT(locateSymbolAt(AST, T.point("9")), ElementsAre(Sym("Foo")));
   EXPECT_THAT(locateSymbolAt(AST, T.point("10")),
-  ElementsAre(Sym("Foo", T.range("ConstructorLoc";
+  ElementsAre(Sym("Foo", T.range("ConstructorLoc"), llvm::None)));
   EXPECT_THAT(locateSymbolAt(AST, T.point("11")),
-  ElementsAre(Sym("Foo", T.range("ConstructorLoc";
+  ElementsAre(Sym("Foo", T.range("ConstructorLoc"), llvm::None)));
   // These assertions are unordered because the order comes from
   // CXXRecordDecl::lookupDependentName() which doesn't appear to provide
   // an order guarantee.
   EXPECT_THAT(locateSymbolAt(AST, T.point("12")),
-  UnorderedElementsAre(Sym("bar", T.range("NonstaticOverload1")),
-   Sym("bar", T.range("NonstaticOverload2";
-  EXPECT_THAT(locateSymbolAt(AST, T.point("13")),
-  UnorderedElementsAre(Sym("baz", T.range("StaticOverload1")),
-   Sym("baz", T.range("StaticO

[PATCH] D84919: [clangd] Be more explicit on testing the optional DefLoc in LocatedSymbol.

2020-07-31 Thread Haojian Wu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
hokein marked an inline comment as done.
Closed by commit rG638f0cf565f2: [clangd] Be more explicit on testing the 
optional DefLoc in LocatedSymbol. (authored by hokein).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84919

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

Index: clang-tools-extra/clangd/unittests/XRefsTests.cpp
===
--- clang-tools-extra/clangd/unittests/XRefsTests.cpp
+++ clang-tools-extra/clangd/unittests/XRefsTests.cpp
@@ -41,6 +41,7 @@
 using ::testing::Eq;
 using ::testing::IsEmpty;
 using ::testing::Matcher;
+using ::testing::UnorderedElementsAre;
 using ::testing::UnorderedElementsAreArray;
 
 MATCHER_P2(FileRange, File, Range, "") {
@@ -264,19 +265,23 @@
  << llvm::to_string(arg.PreferredDeclaration);
 return false;
   }
+  if (!Def && !arg.Definition)
+return true;
   if (Def && !arg.Definition) {
 *result_listener << "Has no definition";
 return false;
   }
-  if (Def && arg.Definition->range != *Def) {
+  if (!Def && arg.Definition) {
+*result_listener << "Definition is " << llvm::to_string(arg.Definition);
+return false;
+  }
+  if (arg.Definition->range != *Def) {
 *result_listener << "Definition is " << llvm::to_string(arg.Definition);
 return false;
   }
   return true;
 }
-::testing::Matcher Sym(std::string Name, Range Decl) {
-  return Sym(Name, Decl, llvm::None);
-}
+
 MATCHER_P(Sym, Name, "") { return arg.Name == Name; }
 
 MATCHER_P(RangeIs, R, "") { return arg.range == R; }
@@ -771,7 +776,7 @@
   auto AST = TU.build();
   auto Index = TU.index();
   EXPECT_THAT(locateSymbolAt(AST, T.point(), Index.get()),
-  ElementsAre(Sym("MyClass", T.range(;
+  ElementsAre(Sym("MyClass", T.range(), T.range(;
 }
 
 TEST(LocateSymbol, Textual) {
@@ -891,18 +896,20 @@
   // FIXME: Target the constructor as well.
   EXPECT_THAT(locateSymbolAt(AST, T.point("9")), ElementsAre(Sym("Foo")));
   EXPECT_THAT(locateSymbolAt(AST, T.point("10")),
-  ElementsAre(Sym("Foo", T.range("ConstructorLoc";
+  ElementsAre(Sym("Foo", T.range("ConstructorLoc"), llvm::None)));
   EXPECT_THAT(locateSymbolAt(AST, T.point("11")),
-  ElementsAre(Sym("Foo", T.range("ConstructorLoc";
+  ElementsAre(Sym("Foo", T.range("ConstructorLoc"), llvm::None)));
   // These assertions are unordered because the order comes from
   // CXXRecordDecl::lookupDependentName() which doesn't appear to provide
   // an order guarantee.
   EXPECT_THAT(locateSymbolAt(AST, T.point("12")),
-  UnorderedElementsAre(Sym("bar", T.range("NonstaticOverload1")),
-   Sym("bar", T.range("NonstaticOverload2";
-  EXPECT_THAT(locateSymbolAt(AST, T.point("13")),
-  UnorderedElementsAre(Sym("baz", T.range("StaticOverload1")),
-   Sym("baz", T.range("StaticOverload2";
+  UnorderedElementsAre(
+  Sym("bar", T.range("NonstaticOverload1"), llvm::None),
+  Sym("bar", T.range("NonstaticOverload2"), llvm::None)));
+  EXPECT_THAT(
+  locateSymbolAt(AST, T.point("13")),
+  UnorderedElementsAre(Sym("baz", T.range("StaticOverload1"), llvm::None),
+   Sym("baz", T.range("StaticOverload2"), llvm::None)));
 }
 
 TEST(LocateSymbol, TextualDependent) {
@@ -932,9 +939,10 @@
   // interaction between locateASTReferent() and
   // locateSymbolNamedTextuallyAt().
   auto Results = locateSymbolAt(AST, Source.point(), Index.get());
-  EXPECT_THAT(Results, UnorderedElementsAre(
-   Sym("uniqueMethodName", Header.range("FooLoc")),
-   Sym("uniqueMethodName", Header.range("BarLoc";
+  EXPECT_THAT(Results,
+  UnorderedElementsAre(
+  Sym("uniqueMethodName", Header.range("FooLoc"), llvm::None),
+  Sym("uniqueMethodName", Header.range("BarLoc"), llvm::None)));
 }
 
 TEST(LocateSymbol, TemplateTypedefs) {
@@ -992,20 +1000,23 @@
   auto Locations =
   runLocateSymbolAt(Server, FooCpp, SourceAnnotations.point("p1"));
   EXPECT_TRUE(bool(Locations)) << "findDefinitions returned an error";
-  EXPECT_THAT(*Locations, ElementsAre(Sym("foo", SourceAnnotations.range(;
+  EXPECT_THAT(*Locations, ElementsAre(Sym("foo", SourceAnnotations.range(),
+  SourceAnnotations.range(;
 
   // Go to a definition in header_in_preamble.h.
   Locations = runLocateSymbolAt(Server, FooCpp, SourceAnnotations.point("p2"));
   EXPECT_TRUE(bool(Locations)) << "findDefinitions returned an error";
   EXPECT_THAT(
   *Locations,
-  ElementsAre(Sym("bar_preamble", HeaderInPreambleAnnotation

[clang] e704aa4 - DR2303: Prefer 'nearer' base classes during template deduction.

2020-07-31 Thread Erich Keane via cfe-commits

Author: Erich Keane
Date: 2020-07-31T05:39:55-07:00
New Revision: e704aa4f254a26505d4bb9dc38bdee0ff4efa4ba

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

LOG: DR2303: Prefer 'nearer' base classes during template deduction.

DR2303 fixes the case where the derived-base match for template
deduction is ambiguous if a base-of-base ALSO matches. The canonical
example (as shown in the test) is just like the MSVC implementation of
std::tuple.

This fixes a fairly sizable issue, where if a user inherits from
std::tuple on Windows (with the MS STL), they cannot use that type to
call a function that takes std::tuple.

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

Added: 


Modified: 
clang/lib/Sema/SemaTemplateDeduction.cpp
clang/test/CXX/drs/dr23xx.cpp
clang/www/cxx_dr_status.html

Removed: 




diff  --git a/clang/lib/Sema/SemaTemplateDeduction.cpp 
b/clang/lib/Sema/SemaTemplateDeduction.cpp
index 1f7d0f0e8d97..7aa94502fa84 100644
--- a/clang/lib/Sema/SemaTemplateDeduction.cpp
+++ b/clang/lib/Sema/SemaTemplateDeduction.cpp
@@ -1201,6 +1201,120 @@ static bool isForwardingReference(QualType Param, 
unsigned FirstInnerIndex) {
   return false;
 }
 
+///  Attempt to deduce the template arguments by checking the base types
+///  according to (C++20 [temp.deduct.call] p4b3.
+///
+/// \param S the semantic analysis object within which we are deducing.
+///
+/// \param RecordT the top level record object we are deducing against.
+///
+/// \param TemplateParams the template parameters that we are deducing.
+///
+/// \param SpecParam the template specialization parameter type.
+///
+/// \param Info information about the template argument deduction itself.
+///
+/// \param Deduced the deduced template arguments.
+///
+/// \returns the result of template argument deduction with the bases. 
"invalid"
+/// means no matches, "success" found a single item, and the
+/// "MiscellaneousDeductionFailure" result happens when the match is ambiguous.
+static Sema::TemplateDeductionResult DeduceTemplateBases(
+Sema &S, const RecordType *RecordT, TemplateParameterList *TemplateParams,
+const TemplateSpecializationType *SpecParam, TemplateDeductionInfo &Info,
+SmallVectorImpl &Deduced) {
+  // C++14 [temp.deduct.call] p4b3:
+  //   If P is a class and P has the form simple-template-id, then the
+  //   transformed A can be a derived class of the deduced A. Likewise if
+  //   P is a pointer to a class of the form simple-template-id, the
+  //   transformed A can be a pointer to a derived class pointed to by the
+  //   deduced A. However, if there is a class C that is a (direct or
+  //   indirect) base class of D and derived (directly or indirectly) from a
+  //   class B and that would be a valid deduced A, the deduced A cannot be
+  //   B or pointer to B, respectively.
+  //
+  //   These alternatives are considered only if type deduction would
+  //   otherwise fail. If they yield more than one possible deduced A, the
+  //   type deduction fails.
+
+  // Use a breadth-first search through the bases to collect the set of
+  // successful matches. Visited contains the set of nodes we have already
+  // visited, while ToVisit is our stack of records that we still need to
+  // visit.  Matches contains a list of matches that have yet to be
+  // disqualified.
+  llvm::SmallPtrSet Visited;
+  SmallVector ToVisit;
+  // We iterate over this later, so we have to use MapVector to ensure
+  // determinism.
+  llvm::MapVector>
+  Matches;
+
+  auto AddBases = [&Visited, &ToVisit](const RecordType *RT) {
+CXXRecordDecl *RD = cast(RT->getDecl());
+for (const auto &Base : RD->bases()) {
+  assert(Base.getType()->isRecordType() &&
+ "Base class that isn't a record?");
+  const RecordType *RT = Base.getType()->getAs();
+  if (Visited.insert(RT).second)
+ToVisit.push_back(Base.getType()->getAs());
+}
+  };
+
+  // Set up the loop by adding all the bases.
+  AddBases(RecordT);
+
+  // Search each path of bases until we either run into a successful match
+  // (where all bases of it are invalid), or we run out of bases.
+  while (!ToVisit.empty()) {
+const RecordType *NextT = ToVisit.pop_back_val();
+
+SmallVector DeducedCopy(Deduced.begin(),
+Deduced.end());
+TemplateDeductionInfo BaseInfo(TemplateDeductionInfo::ForBase, Info);
+Sema::TemplateDeductionResult BaseResult =
+DeduceTemplateArguments(S, TemplateParams, SpecParam,
+QualType(NextT, 0), BaseInfo, DeducedCopy);
+
+// If this was a successful deduction, add it to the list of matches,
+// otherwise we need to continue searching its bases.
+if (BaseResult == Sema::T

[PATCH] D84048: DR2303: Prefer 'nearer' base classes during template deduction.

2020-07-31 Thread Erich Keane via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGe704aa4f254a: DR2303: Prefer 'nearer' base classes 
during template deduction. (authored by erichkeane).
Herald added a project: clang.

Changed prior to commit:
  https://reviews.llvm.org/D84048?vs=280101&id=282204#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84048

Files:
  clang/lib/Sema/SemaTemplateDeduction.cpp
  clang/test/CXX/drs/dr23xx.cpp
  clang/www/cxx_dr_status.html

Index: clang/www/cxx_dr_status.html
===
--- clang/www/cxx_dr_status.html
+++ clang/www/cxx_dr_status.html
@@ -13633,7 +13633,7 @@
 https://wg21.link/cwg2303";>2303
 DRWP
 Partial ordering and recursive variadic inheritance
-Unknown
+Clang 12
   
   
 https://wg21.link/cwg2304";>2304
Index: clang/test/CXX/drs/dr23xx.cpp
===
--- clang/test/CXX/drs/dr23xx.cpp
+++ clang/test/CXX/drs/dr23xx.cpp
@@ -113,3 +113,35 @@
   extern template const int d;
 #endif
 }
+
+#if __cplusplus >= 201103L
+namespace dr2303 { // dr2303: 12
+template 
+struct A;
+template <>
+struct A<> {};
+template 
+struct A : A {};
+struct B : A {};
+struct C : A, A {}; // expected-warning {{direct base 'A' is inaccessible}}
+struct D : A, A {}; // expected-warning {{direct base 'A' is inaccessible}}
+struct E : A {};
+struct F : B, E {};
+
+template 
+void f(const A &) {
+  static_assert(sizeof...(T) == 2, "Should only match A");
+}
+template 
+void f2(const A *);
+
+void g() {
+  f(B{}); // This is no longer ambiguous.
+  B b;
+  f2(&b);
+  f(C{});
+  f(D{});
+  f(F{}); // expected-error {{ambiguous conversion from derived class}}
+}
+} //namespace dr2303
+#endif
Index: clang/lib/Sema/SemaTemplateDeduction.cpp
===
--- clang/lib/Sema/SemaTemplateDeduction.cpp
+++ clang/lib/Sema/SemaTemplateDeduction.cpp
@@ -1201,6 +1201,120 @@
   return false;
 }
 
+///  Attempt to deduce the template arguments by checking the base types
+///  according to (C++20 [temp.deduct.call] p4b3.
+///
+/// \param S the semantic analysis object within which we are deducing.
+///
+/// \param RecordT the top level record object we are deducing against.
+///
+/// \param TemplateParams the template parameters that we are deducing.
+///
+/// \param SpecParam the template specialization parameter type.
+///
+/// \param Info information about the template argument deduction itself.
+///
+/// \param Deduced the deduced template arguments.
+///
+/// \returns the result of template argument deduction with the bases. "invalid"
+/// means no matches, "success" found a single item, and the
+/// "MiscellaneousDeductionFailure" result happens when the match is ambiguous.
+static Sema::TemplateDeductionResult DeduceTemplateBases(
+Sema &S, const RecordType *RecordT, TemplateParameterList *TemplateParams,
+const TemplateSpecializationType *SpecParam, TemplateDeductionInfo &Info,
+SmallVectorImpl &Deduced) {
+  // C++14 [temp.deduct.call] p4b3:
+  //   If P is a class and P has the form simple-template-id, then the
+  //   transformed A can be a derived class of the deduced A. Likewise if
+  //   P is a pointer to a class of the form simple-template-id, the
+  //   transformed A can be a pointer to a derived class pointed to by the
+  //   deduced A. However, if there is a class C that is a (direct or
+  //   indirect) base class of D and derived (directly or indirectly) from a
+  //   class B and that would be a valid deduced A, the deduced A cannot be
+  //   B or pointer to B, respectively.
+  //
+  //   These alternatives are considered only if type deduction would
+  //   otherwise fail. If they yield more than one possible deduced A, the
+  //   type deduction fails.
+
+  // Use a breadth-first search through the bases to collect the set of
+  // successful matches. Visited contains the set of nodes we have already
+  // visited, while ToVisit is our stack of records that we still need to
+  // visit.  Matches contains a list of matches that have yet to be
+  // disqualified.
+  llvm::SmallPtrSet Visited;
+  SmallVector ToVisit;
+  // We iterate over this later, so we have to use MapVector to ensure
+  // determinism.
+  llvm::MapVector>
+  Matches;
+
+  auto AddBases = [&Visited, &ToVisit](const RecordType *RT) {
+CXXRecordDecl *RD = cast(RT->getDecl());
+for (const auto &Base : RD->bases()) {
+  assert(Base.getType()->isRecordType() &&
+ "Base class that isn't a record?");
+  const RecordType *RT = Base.getType()->getAs();
+  if (Visited.insert(RT).second)
+ToVisit.push_back(Base.getType()->getAs());
+}
+  };
+
+  // Set up the loop by adding all the bases.
+  AddBases(RecordT);
+
+  // Search each path of bases until we either run into a successful matc

[PATCH] D77776: [Driver] Default to libc++ on FreeBSD

2020-07-31 Thread Dimitry Andric via Phabricator via cfe-commits
dim added a comment.

In D6#1993211 , @arichardson wrote:

> I don't like the fact that this only changes one of the users of 
> `getTriple().getOSMajorVersion()`.

Why not, if this is a one-off case, it's perfectly OK to put it in here. Maybe 
add a comment as to why it is needed?

Could you add a new member function such as

>   void FreeBSD::getMajorVersion() const {
> unsigned Major = getTriple().getOSMajorVersion();
> if (Major == 0)
>return 10; 
> return Major
>   }
>
> and replace all uses of `getTriple().getOSMajorVersion()` with 
> `getMajorVersion()`.

Maybe other OSes would also have this same issue, but then you'd have to 
replace this kind of logic for *all* of them, not only FreeBSD. That said, 
maybe there aren't so many places where the major version is checked, and where 
features are enabled or disabled depending on this version?

> We could also use the host version instead of 10?
>
>   +#ifdef __FreeBSD__
>   + return __FreeBSD_version / 10;
>   +#else
>   + return 10;
>   +#endif

No, that would hardcode something at build time. We need to respect whatever 
triple the user is passing in.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D6

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


[PATCH] D85025: [RecoveryExpr]WIP: Support dependence in C-only codepath

2020-07-31 Thread Haojian Wu via Phabricator via cfe-commits
hokein created this revision.
Herald added subscribers: cfe-commits, dang, arphaman, kbarton, nemanjai.
Herald added a project: clang.
hokein requested review of this revision.
Herald added a subscriber: wuzish.

This is a large patch containing all required changes, want early
feedback.

what does this patch do?

- support dependent mechanisam (only for error-recovery) in C-only codepath;
- allows building RecoveryExpr for C;
- remove all early TypoCorrection technical debet in clang;

This will be split into different patches:

- build dependent binary operator for C: https://reviews.llvm.org/D84226
- build dependent callexpr in C for error-recovery: 
https://reviews.llvm.org/D84304
- suppress spurious "typecheck_cond_expect_scalar" diagnostic: 
https://reviews.llvm.org/D84322
- suppress spurious "err_typecheck_expect_scalar_operand" diagnostic : 
https://reviews.llvm.org/D84387
- adjust all existing tests when enabled recovery-expr for C: 
https://reviews.llvm.org/D84970

TESTED: ninja check-clang


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D85025

Files:
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Driver/Options.td
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/Expr.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Parse/ParseExpr.cpp
  clang/lib/Sema/SemaCast.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/test/AST/ast-dump-recovery.c
  clang/test/CodeGen/builtins-ppc-error.c
  clang/test/CodeGen/builtins-systemz-zvector-error.c
  clang/test/CodeGen/builtins-systemz-zvector2-error.c
  clang/test/CodeGen/builtins-systemz-zvector3-error.c
  clang/test/Index/complete-switch.c
  clang/test/OpenMP/begin_declare_variant_messages.c
  clang/test/OpenMP/declare_variant_messages.c
  clang/test/Parser/objc-foreach-syntax.m
  clang/test/Sema/__try.c
  clang/test/Sema/enum.c
  clang/test/Sema/error-dependence.c
  clang/test/Sema/typo-correction.c

Index: clang/test/Sema/typo-correction.c
===
--- clang/test/Sema/typo-correction.c
+++ clang/test/Sema/typo-correction.c
@@ -14,7 +14,7 @@
   // expected-error {{use of undeclared identifier 'b'}}
 
 int foobar;  // expected-note {{'foobar' declared here}}
-a = goobar ?: 4;  // expected-warning {{type specifier missing, defaults to 'int'}} \
+new_a = goobar ?: 4;  // expected-warning {{type specifier missing, defaults to 'int'}} \
   // expected-error {{use of undeclared identifier 'goobar'; did you mean 'foobar'?}} \
   // expected-error {{initializer element is not a compile-time constant}}
 
@@ -50,10 +50,10 @@
   cabs(errij);  // expected-error {{use of undeclared identifier 'errij'}}
 }
 
-extern long afunction(int); // expected-note {{'afunction' declared here}}
+extern long afunction(int);
 void fn2() {
   f(THIS_IS_AN_ERROR, // expected-error {{use of undeclared identifier 'THIS_IS_AN_ERROR'}}
-afunction(afunction_));  // expected-error {{use of undeclared identifier 'afunction_'; did you mean 'afunction'?}}
+afunction(afunction_));  // expected-error {{use of undeclared identifier 'afunction_'}}
 }
 
 int d = X ? d : L; // expected-error 2 {{use of undeclared identifier}}
Index: clang/test/Sema/error-dependence.c
===
--- /dev/null
+++ clang/test/Sema/error-dependence.c
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -frecovery-ast -fno-recovery-ast-type -fc-dependence %s
+
+int call(int); // expected-note 2{{'call' declared here}}
+
+void test1(int s) {
+  // verify "assigning to 'int' from incompatible type ''" is
+  // not emitted.
+  s = call(); // expected-error {{too few arguments to function call}}
+
+  // verify disgnostic "called object type '' is not a function
+  // or function pointer" is not emitted.
+  (*__builtin_classify_type)(1); // expected-error {{builtin functions must be directly called}}
+}
+
+void test2(int *ptr, float f) {
+  // verify diagnostic "used type '' where arithmetic or pointer
+  // type is required" is not emitted.
+  ptr > f ? ptr : f; // expected-error {{invalid operands to binary expression}}
+}
+
+void test3(float f) {
+  // verify diagnostic "operand of type '' where arithmetic or
+  // pointer type is required" is not emitted.
+  f = (float)call(); // expected-error {{too few arguments to function call}}
+}
Index: clang/test/Sema/enum.c
===
--- clang/test/Sema/enum.c
+++ clang/test/Sema/enum.c
@@ -100,7 +100,8 @@
 // PR7911
 extern enum PR7911T PR7911V; // expected-warning{{ISO C forbids forward references to 'enum' types}}
 void PR7911F() {
-  switch (PR7911V); // expected-error {{statement requires expression of integer type}}
+  switch (PR7911V); // expected-error {{statement requires expression of integer type}} \
+// expected-warning {{switch statement has empty b

[PATCH] D85026: [analyzer] Minor refactoring of SVal::getSubKind function

2020-07-31 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov created this revision.
ASDenysPetrov added reviewers: NoQ, vsavchenko, Eugene.Zelenko, krememek, 
steakhal.
ASDenysPetrov added a project: clang.
Herald added subscribers: cfe-commits, Charusso, dkrupp, donat.nagy, Szelethus, 
dexonsmith, mikhail.ramalho, a.sidorin, szepet, baloghadamsoftware, xazax.hun.
ASDenysPetrov requested review of this revision.

`BaseMask` occupies the lowest bits. Effect of applying the mask is neutralized 
by right shift operation, thus making it useless.
Also change mask init value from //hex// to //bin// since it's more natural for 
mask.

Fix: Remove a redundant bitwise operation.

P.S. It hurts my eyes everytime I see it. I gave up.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D85026

Files:
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h


Index: clang/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h
===
--- clang/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h
+++ clang/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h
@@ -80,7 +80,7 @@
 #define ABSTRACT_SVAL_WITH_KIND(Id, Parent) Id ## Kind,
 #include "clang/StaticAnalyzer/Core/PathSensitive/SVals.def"
   };
-  enum { BaseBits = 2, BaseMask = 0x3 };
+  enum { BaseBits = 2, BaseMask = 0b11 };
 
 protected:
   const void *Data = nullptr;
@@ -116,7 +116,7 @@
 
   unsigned getRawKind() const { return Kind; }
   BaseKind getBaseKind() const { return (BaseKind) (Kind & BaseMask); }
-  unsigned getSubKind() const { return (Kind & ~BaseMask) >> BaseBits; }
+  unsigned getSubKind() const { return Kind >> BaseBits; }
 
   // This method is required for using SVal in a FoldingSetNode.  It
   // extracts a unique signature for this SVal object.


Index: clang/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h
===
--- clang/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h
+++ clang/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h
@@ -80,7 +80,7 @@
 #define ABSTRACT_SVAL_WITH_KIND(Id, Parent) Id ## Kind,
 #include "clang/StaticAnalyzer/Core/PathSensitive/SVals.def"
   };
-  enum { BaseBits = 2, BaseMask = 0x3 };
+  enum { BaseBits = 2, BaseMask = 0b11 };
 
 protected:
   const void *Data = nullptr;
@@ -116,7 +116,7 @@
 
   unsigned getRawKind() const { return Kind; }
   BaseKind getBaseKind() const { return (BaseKind) (Kind & BaseMask); }
-  unsigned getSubKind() const { return (Kind & ~BaseMask) >> BaseBits; }
+  unsigned getSubKind() const { return Kind >> BaseBits; }
 
   // This method is required for using SVal in a FoldingSetNode.  It
   // extracts a unique signature for this SVal object.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D77776: [Driver] Default to libc++ on FreeBSD

2020-07-31 Thread Greg V via Phabricator via cfe-commits
myfreeweb added a comment.

In D6#2187273 , @dim wrote:

>>   +#ifdef __FreeBSD__
>>   +return __FreeBSD_version / 10;
>>   +#else
>>   +return 10;
>>   +#endif
>
> No, that would hardcode something at build time. We need to respect whatever 
> triple the user is passing in.

Nobody has proposed not respecting that, this is all in the context of the `if 
(Major == 0)` fallback


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D6

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


[PATCH] D84811: [clangd] Add an option to exclude symbols outside of project root from index

2020-07-31 Thread Haojian Wu via Phabricator via cfe-commits
hokein added inline comments.



Comment at: clang-tools-extra/clangd/indexer/IndexerMain.cpp:70
 SymbolCollector::Options Opts;
+Opts.FileFilter = FileFilter;
 Opts.CountReferences = true;

`FileFilter` seems more promising, but there are some FIXMEs ("use the result 
to filter out symbols.") in the SymbolCollector.cpp` -- looks like the 
SymbolCollector doesn't support this yet, sigh...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84811

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


[PATCH] D77776: [Driver] Default to libc++ on FreeBSD

2020-07-31 Thread Dimitry Andric via Phabricator via cfe-commits
dim added a comment.

In D6#2187334 , @myfreeweb wrote:

> In D6#2187273 , @dim wrote:
>
>>>   +#ifdef __FreeBSD__
>>>   +   return __FreeBSD_version / 10;
>>>   +#else
>>>   +   return 10;
>>>   +#endif
>>
>> No, that would hardcode something at build time. We need to respect whatever 
>> triple the user is passing in.
>
> Nobody has proposed not respecting that, this is all in the context of the 
> `if (Major == 0)` fallback

Aha, then there is no need to do arithmetic with `__FreeBSD_version`, as 
`__FreeBSD__` already contains just the major version.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D6

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


[PATCH] D85016: [clang-format] Add space between method modifier and a tuple return type in C#

2020-07-31 Thread Łukasz Krawczyk via Phabricator via cfe-commits
lbk updated this revision to Diff 282210.
lbk added a comment.

Extend test set by additional values of method_modifier

Updating D85016 : [clang-format] Add space 
between method modifier and a tuple return type in C#


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85016

Files:
  clang/lib/Format/TokenAnnotator.cpp
  clang/unittests/Format/FormatTestCSharp.cpp


Index: clang/unittests/Format/FormatTestCSharp.cpp
===
--- clang/unittests/Format/FormatTestCSharp.cpp
+++ clang/unittests/Format/FormatTestCSharp.cpp
@@ -777,6 +777,20 @@
   verifyFormat(R"(private float[ , ] Values;)", Style);
   verifyFormat(R"(string dirPath = args?[ 0 ];)", Style);
   verifyFormat(R"(char[ ,, ] rawCharArray = MakeCharacterGrid();)", Style);
+
+  // Method returning tuple
+  verifyFormat(R"(public (string name, int age) methodTuple() {})", Style);
+  verifyFormat(R"(private (string name, int age) methodTuple() {})", Style);
+  verifyFormat(R"(protected (string name, int age) methodTuple() {})", Style);
+  verifyFormat(R"(virtual (string name, int age) methodTuple() {})", Style);
+  verifyFormat(R"(extern (string name, int age) methodTuple() {})", Style);
+  verifyFormat(R"(static (string name, int age) methodTuple() {})", Style);
+  verifyFormat(R"(internal (string name, int age) methodTuple() {})", Style);
+  verifyFormat(R"(abstract (string name, int age) methodTuple() {})", Style);
+  verifyFormat(R"(sealed (string name, int age) methodTuple() {})", Style);
+  verifyFormat(R"(override (string name, int age) methodTuple() {})", Style);
+  verifyFormat(R"(async (string name, int age) methodTuple() {})", Style);
+  verifyFormat(R"(unsafe (string name, int age) methodTuple() {})", Style);
 }
 
 TEST_F(FormatTestCSharp, CSharpNullableTypes) {
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -3115,6 +3115,16 @@
Keywords.kw_lock))
 return Style.SpaceBeforeParens == FormatStyle::SBPO_ControlStatements 
||
spaceRequiredBeforeParens(Right);
+
+// space between method modifier and opening parenthesis of a tuple return
+// type
+if (Left.isOneOf(tok::kw_public, tok::kw_private, tok::kw_protected,
+ tok::kw_virtual, tok::kw_extern, tok::kw_static,
+ Keywords.kw_internal, Keywords.kw_abstract,
+ Keywords.kw_sealed, Keywords.kw_override,
+ Keywords.kw_async, Keywords.kw_unsafe) &&
+Right.is(tok::l_paren))
+  return true;
   } else if (Style.Language == FormatStyle::LK_JavaScript) {
 if (Left.is(TT_JsFatArrow))
   return true;


Index: clang/unittests/Format/FormatTestCSharp.cpp
===
--- clang/unittests/Format/FormatTestCSharp.cpp
+++ clang/unittests/Format/FormatTestCSharp.cpp
@@ -777,6 +777,20 @@
   verifyFormat(R"(private float[ , ] Values;)", Style);
   verifyFormat(R"(string dirPath = args?[ 0 ];)", Style);
   verifyFormat(R"(char[ ,, ] rawCharArray = MakeCharacterGrid();)", Style);
+
+  // Method returning tuple
+  verifyFormat(R"(public (string name, int age) methodTuple() {})", Style);
+  verifyFormat(R"(private (string name, int age) methodTuple() {})", Style);
+  verifyFormat(R"(protected (string name, int age) methodTuple() {})", Style);
+  verifyFormat(R"(virtual (string name, int age) methodTuple() {})", Style);
+  verifyFormat(R"(extern (string name, int age) methodTuple() {})", Style);
+  verifyFormat(R"(static (string name, int age) methodTuple() {})", Style);
+  verifyFormat(R"(internal (string name, int age) methodTuple() {})", Style);
+  verifyFormat(R"(abstract (string name, int age) methodTuple() {})", Style);
+  verifyFormat(R"(sealed (string name, int age) methodTuple() {})", Style);
+  verifyFormat(R"(override (string name, int age) methodTuple() {})", Style);
+  verifyFormat(R"(async (string name, int age) methodTuple() {})", Style);
+  verifyFormat(R"(unsafe (string name, int age) methodTuple() {})", Style);
 }
 
 TEST_F(FormatTestCSharp, CSharpNullableTypes) {
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -3115,6 +3115,16 @@
Keywords.kw_lock))
 return Style.SpaceBeforeParens == FormatStyle::SBPO_ControlStatements ||
spaceRequiredBeforeParens(Right);
+
+// space between method modifier and opening parenthesis of a tuple return
+// type
+if (Left.isOneOf(tok::kw_public, tok::kw_private, tok::kw_protected,
+ tok::kw_virtual, tok::kw_extern, tok::kw_sta

[PATCH] D84814: [clang-tidy] readability-identifier-naming checks configs for included files

2020-07-31 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added inline comments.



Comment at: clang-tools-extra/docs/ReleaseNotes.rst:76
+
+  Added an option GetConfigPerFile to support including files which use
+  different naming styles.

Please enclose GetConfigPerFile in single back-quotes.



Comment at: 
clang-tools-extra/docs/clang-tidy/checks/readability-identifier-naming.rst:719
+
+When ``true`` the check will look for the configuration for where an
+identifier is declared. Useful for when you include header files that use

Please use single back-quotes for option values. Same below.



Comment at: 
clang-tools-extra/docs/clang-tidy/checks/readability-identifier-naming.rst:720
+When ``true`` the check will look for the configuration for where an
+identifier is declared. Useful for when you include header files that use
+a different style. 

I think will be good idea to reformulate without //you//, like //header file 
included//.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84814

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


[PATCH] D84316: [analyzer][NFC] Split CStringChecker to modeling and reporting

2020-07-31 Thread 19n07u5 via Phabricator via cfe-commits
19n07u5 added a comment.

The title is a little bit confusing because only the C-string size model is 
going to be separated and be accessible. Other than that as @NoQ pointed out we 
need lot more of these common-API-separation patches. It is a great starting 
point for the `CStringChecker`.




Comment at: clang/lib/StaticAnalyzer/Checkers/CMakeLists.txt:146
+  CStringChecker
+  )

Other common checker functionality folders and headers do not require extra 
CMake support long ago. I think when we need such support, we could define it 
later, so that you could revert this.



Comment at: clang/lib/StaticAnalyzer/Checkers/CStringChecker/CStringLength.h:43
+ ProgramStateRef &State, const Expr *Ex,
+ SVal Buf, bool Hypothetical = false);
+

steakhal wrote:
> steakhal wrote:
> > steakhal wrote:
> > > balazske wrote:
> > > > I do not like that the //get// and //set// (CStringLength) functions 
> > > > are not symmetrical. I (and other developers) would think that the get 
> > > > function returns a stored value and the set function sets it. The 
> > > > `getCStringLength` is more a `computeCStringLength` and additionally 
> > > > may manipulate the `State` too. In this form it is usable mostly only 
> > > > for CStringChecker. (A separate function to get the value stored in the 
> > > > length map should exist instead of this `Hypothetical` thing.)
> > > > [...] get function returns a stored value and the set function sets it.
> > > Certainly a burden to understand. It would be more appealing, but more 
> > > useful?
> > > The user would have to check and create if necessary regardless. So 
> > > fusing these two functions is more like a feature.
> > > What use case do you think of using only the query function? In other 
> > > words, how can you guarantee that you will find a length for a symbol?
> > > 
> > > > In this form it is usable mostly only for CStringChecker. (A separate 
> > > > function to get the value stored in the length map should exist instead 
> > > > of this Hypothetical thing.)
> > > You are right. However, I want to focus on splitting parts without 
> > > modifying the already existing API reducing the risk of breaking things.
> > > You should expect such a change in an upcoming patch.
> > On second thought, It probably worth having a cleaner API to a slight 
> > inconvenience. If he feels like, still can wrap them.
> > I will investigate it tomorrow.
> I made a separate patch for cleansing this API.
> In the D84979 now these API functions will behave as expected.
> I (and other developers) would think that the get function returns a stored 
> value and the set function sets it.
Developers should not believe the getters are pure getters. As a checker-writer 
point of view, you do not care whether the C-string already exist or the 
checker creates it during symbolic execution, you only want to get the C-string.

Think about all the Static Analyzer getters as factory functions, that is the 
de facto standard now. For example, when you are trying to get a symbolic value 
with `getSVal()`, for the first occurrence of an expression no `SVal` exist, so 
it also creates it.

With that in mind, @steakhal, could you partially revert the renaming related 
refactors of D84979, please?


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

https://reviews.llvm.org/D84316

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


[PATCH] D85028: [clangd] Support new/deleta operator in TargetFinder.

2020-07-31 Thread Haojian Wu via Phabricator via cfe-commits
hokein created this revision.
hokein added a reviewer: kadircet.
Herald added subscribers: usaxena95, arphaman, jkorous.
Herald added a project: clang.
hokein requested review of this revision.
Herald added subscribers: MaskRay, ilya-biryukov.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D85028

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


Index: clang-tools-extra/clangd/unittests/FindTargetTests.cpp
===
--- clang-tools-extra/clangd/unittests/FindTargetTests.cpp
+++ clang-tools-extra/clangd/unittests/FindTargetTests.cpp
@@ -559,6 +559,28 @@
 };
   )cpp";
   EXPECT_DECLS("UnresolvedMemberExpr", "void func(int *)", "void func(char 
*)");
+
+  Code = R"cpp(
+struct X {
+  static void *operator new(unsigned long s);
+};
+
+void k() {
+  [[new]] X();
+}
+  )cpp";
+  EXPECT_DECLS("CXXNewExpr", "static void *operator new(unsigned long s)");
+
+  Code = R"cpp(
+struct X {
+  static void operator delete(void *) noexcept;
+};
+
+void k(X* x) {
+  [[delete]] x;
+}
+  )cpp";
+  EXPECT_DECLS("CXXDeleteExpr", "static void operator delete(void *) 
noexcept");
 }
 
 TEST_F(TargetDeclTest, DependentExprs) {
Index: clang-tools-extra/clangd/FindTarget.cpp
===
--- clang-tools-extra/clangd/FindTarget.cpp
+++ clang-tools-extra/clangd/FindTarget.cpp
@@ -460,6 +460,12 @@
   void VisitPseudoObjectExpr(const PseudoObjectExpr *POE) {
 Outer.add(POE->getSyntacticForm(), Flags);
   }
+  void VisitCXXNewExpr(const CXXNewExpr *CNE) {
+Outer.add(CNE->getOperatorNew(), Flags);
+  }
+  void VisitCXXDeleteExpr(const CXXDeleteExpr *CNE) {
+Outer.add(CNE->getOperatorDelete(), Flags);
+  }
 };
 Visitor(*this, Flags).Visit(S);
   }


Index: clang-tools-extra/clangd/unittests/FindTargetTests.cpp
===
--- clang-tools-extra/clangd/unittests/FindTargetTests.cpp
+++ clang-tools-extra/clangd/unittests/FindTargetTests.cpp
@@ -559,6 +559,28 @@
 };
   )cpp";
   EXPECT_DECLS("UnresolvedMemberExpr", "void func(int *)", "void func(char *)");
+
+  Code = R"cpp(
+struct X {
+  static void *operator new(unsigned long s);
+};
+
+void k() {
+  [[new]] X();
+}
+  )cpp";
+  EXPECT_DECLS("CXXNewExpr", "static void *operator new(unsigned long s)");
+
+  Code = R"cpp(
+struct X {
+  static void operator delete(void *) noexcept;
+};
+
+void k(X* x) {
+  [[delete]] x;
+}
+  )cpp";
+  EXPECT_DECLS("CXXDeleteExpr", "static void operator delete(void *) noexcept");
 }
 
 TEST_F(TargetDeclTest, DependentExprs) {
Index: clang-tools-extra/clangd/FindTarget.cpp
===
--- clang-tools-extra/clangd/FindTarget.cpp
+++ clang-tools-extra/clangd/FindTarget.cpp
@@ -460,6 +460,12 @@
   void VisitPseudoObjectExpr(const PseudoObjectExpr *POE) {
 Outer.add(POE->getSyntacticForm(), Flags);
   }
+  void VisitCXXNewExpr(const CXXNewExpr *CNE) {
+Outer.add(CNE->getOperatorNew(), Flags);
+  }
+  void VisitCXXDeleteExpr(const CXXDeleteExpr *CNE) {
+Outer.add(CNE->getOperatorDelete(), Flags);
+  }
 };
 Visitor(*this, Flags).Visit(S);
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D85009: [Sema][BFloat] Forbid arithmetic on vectors of bfloat.

2020-07-31 Thread Luke Geeson via Phabricator via cfe-commits
LukeGeeson accepted this revision.
LukeGeeson added a comment.
This revision is now accepted and ready to land.

This seems sensible and benign, LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85009

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


[PATCH] D84839: Add document outline symbols from unnamed contexts, e.g. extern "C".

2020-07-31 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added a comment.

In D84839#2187222 , @ilya-golovenko 
wrote:

> @kadircet I decided to add `OnlyChildren` to `enum VisitKind` instead of 
> making a `VisitKindSet` - this helped to minimize the changes in 
> `shouldVisit()`.  What do you think?

SGTM.




Comment at: clang-tools-extra/clangd/FindSymbols.cpp:203
   return;
-llvm::Optional Sym = declToSym(AST.getASTContext(), *ND);
-if (!Sym)
-  return;
-if (Visit == VisitKind::DeclAndChildren)
-  traverseChildren(D, Sym->children);
-Results.push_back(std::move(*Sym));
+if (Visit == VisitKind::OnlyChildren) {
+  traverseChildren(D, Results);

ah this is complicated now, but at least for the sake of nestedness:
```
if (Visit == OnlyChildren)
  return traverseChildren;

// We must have the Decl in the result set.
auto *ND = llvm::cast(D);
auto Sym = declToSym(AST.getASTContext(), *ND);
if (!Sym) return;
Results.push_back(std::move(*Sym));

if(Visit == OnlyDecl) return;

assert(Visit == DeclAndChildren && "Unexpected VisitKind");
traverseChildren(Result.back()->children);
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84839

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


[PATCH] D85031: [builtins] Unify the softfloat division implementation

2020-07-31 Thread Anatoly Trosinenko via Phabricator via cfe-commits
atrosinenko created this revision.
atrosinenko added reviewers: koviankevin, joerg, efriedma, compnerd, scanon.
Herald added a project: Sanitizers.
Herald added a subscriber: Sanitizers.
atrosinenko requested review of this revision.
atrosinenko updated this revision to Diff 282225.
atrosinenko added a comment.

Revert auto-linting


atrosinenko added a comment.

Here are the benchmark and fuzzing harness used to test this patch.

F12453076: fuzz_divXf3.sh 

F12453075: divXf3_fuzzer.c 

F12453074: bench_divXf3.sh 

F12453073: divXf3_bench.c 




Comment at: compiler-rt/lib/builtins/fp_div_impl.inc:248-249
+  if (quotient_UQ1 < (implicitBit << 1)) {
+residualLo = (aSignificand << (significandBits + 1)) - quotient_UQ1 * 
bSignificand;
+writtenExponent -= 1;
+

Interesting fact: swapping these two seemingly commuting lines makes code 
slower by 15-25%. This applies to current Clang as well as to `clang-8` from 
Ubuntu 20.04 repository.


This patch replaces three different pre-existing implementations of 
`div[sdt]f3` LibCalls with a generic one - like it is already done for many 
other LibCalls.

The patch was written with intent of the proof being as self-contained as 
possible, so future contributors do not have to re-prove it again. On the other 
hand, this makes it look clumsy, so feedback on **both** correctness and 
readability is highly appreciated.

When fuzzing with AFL++ (25M iterations each type width), just one error was 
found: for single precision, `0x1.fep-126F` divided by `2.F` was not 
correctly rounded to exactly `1.0`. On the other hand, this patch is just an 
intentionally simplified version of the full patch introducing a proper support 
for subnormal results - the full version fixes this issue as well.

This particular diff pretends to be an NFC refactoring and //technically// the 
above issue is not a regression because the original implementation yields the 
same result. :)


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D85031

Files:
  compiler-rt/lib/builtins/divdf3.c
  compiler-rt/lib/builtins/divsf3.c
  compiler-rt/lib/builtins/divtf3.c
  compiler-rt/lib/builtins/fp_div_impl.inc
  compiler-rt/lib/builtins/fp_lib.h
  compiler-rt/lib/builtins/int_util.h
  compiler-rt/test/builtins/Unit/divdf3_test.c

Index: compiler-rt/test/builtins/Unit/divdf3_test.c
===
--- compiler-rt/test/builtins/Unit/divdf3_test.c
+++ compiler-rt/test/builtins/Unit/divdf3_test.c
@@ -80,5 +80,13 @@
 if (test__divdf3(0x1.0p+0, 0x1.0001p+0, UINT64_C(0x3fefffe0)))
   return 1;
 
+// some misc test cases obtained by fuzzing against h/w implementation
+if (test__divdf3(0x1.fdc239dd64735p-658, -0x1.fff9364c0843fp-948, UINT64_C(0xd20fdc8fc0ceffb1)))
+  return 1;
+if (test__divdf3(-0x1.78abb261d47c8p+794, 0x1.fb01d537cc5aep+266, UINT64_C(0xe0e7c6148ffc23e3)))
+  return 1;
+if (test__divdf3(-0x1.da7dfe6048b8bp-875, 0x1.ffc7ea3ff60a4p-610, UINT64_C(0xaf5dab1fe0269e2a)))
+  return 1;
+
 return 0;
 }
Index: compiler-rt/lib/builtins/int_util.h
===
--- compiler-rt/lib/builtins/int_util.h
+++ compiler-rt/lib/builtins/int_util.h
@@ -28,4 +28,21 @@
 #define COMPILE_TIME_ASSERT2(expr, cnt)\
   typedef char ct_assert_##cnt[(expr) ? 1 : -1] UNUSED
 
+// Force unrolling the code specified to be repeated N times.
+#define REPEAT_0_TIMES(code_to_repeat) /* do nothing */
+#define REPEAT_1_TIMES(code_to_repeat) \
+  code_to_repeat
+#define REPEAT_2_TIMES(code_to_repeat) \
+  code_to_repeat \
+  code_to_repeat
+#define REPEAT_3_TIMES(code_to_repeat) \
+  REPEAT_2_TIMES(code_to_repeat) \
+  code_to_repeat
+#define REPEAT_4_TIMES(code_to_repeat) \
+  REPEAT_3_TIMES(code_to_repeat) \
+  code_to_repeat
+
+#define REPEAT_N_TIMES_(N, code_to_repeat) REPEAT_##N##_TIMES(code_to_repeat)
+#define REPEAT_N_TIMES(N, code_to_repeat) REPEAT_N_TIMES_(N, code_to_repeat)
+
 #endif // INT_UTIL_H
Index: compiler-rt/lib/builtins/fp_lib.h
===
--- compiler-rt/lib/builtins/fp_lib.h
+++ compiler-rt/lib/builtins/fp_lib.h
@@ -40,9 +40,12 @@
 
 #if defined SINGLE_PRECISION
 
+typedef uint16_t half_rep_t;
 typedef uint32_t rep_t;
+typedef uint64_t twice_rep_t;
 typedef int32_t srep_t;
 typedef float fp_t;
+#define HALF_REP_C UINT16_C
 #define REP_C UINT32_C
 #define significandBits 23
 
@@ -58,9 +61,11 @@
 
 #elif defined DOUBLE_PRECISION
 
+typedef uint32_t half_rep_t;
 typedef uint64_t rep_t;
 typedef int64_t srep_t;
 typedef double fp_t;
+#define HALF_REP_C UINT32_C
 #define REP_C UINT64_C
 #define significandBits 52
 
@@ -102,9 +107,11 @@
 #elif defined QUAD_PRECISION
 #if __LDB

[PATCH] D85010: [clang][ARM] Add name-mangling test for direct __fp16 arguments.

2020-07-31 Thread Mikhail Maltsev via Phabricator via cfe-commits
miyuki accepted this revision.
miyuki added a comment.
This revision is now accepted and ready to land.

The mangling agrees with 
https://itanium-cxx-abi.github.io/cxx-abi/abi.html#mangling-builtin
LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85010

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


[PATCH] D85032: [builtins] Make divXf3 handle denormal results

2020-07-31 Thread Anatoly Trosinenko via Phabricator via cfe-commits
atrosinenko created this revision.
atrosinenko added reviewers: koviankevin, joerg, efriedma, compnerd, scanon.
Herald added a project: Sanitizers.
Herald added a subscriber: Sanitizers.
atrosinenko requested review of this revision.

This is the last patch from the patchset introducing proper support for 
subnormal results to `div[sdt]f3`.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D85032

Files:
  compiler-rt/lib/builtins/fp_div_impl.inc
  compiler-rt/test/builtins/Unit/divdf3_test.c
  compiler-rt/test/builtins/Unit/divsf3_test.c
  compiler-rt/test/builtins/Unit/divtf3_test.c

Index: compiler-rt/test/builtins/Unit/divtf3_test.c
===
--- compiler-rt/test/builtins/Unit/divtf3_test.c
+++ compiler-rt/test/builtins/Unit/divtf3_test.c
@@ -124,6 +124,13 @@
  UINT64_C(0xfffe)))
 return 1;
 
+// smallest normal value divided by 2.0
+if (test__divtf3(0x1.0p-16382L, 2.L, UINT64_C(0x8000), UINT64_C(0x0)))
+  return 1;
+// smallest subnormal result
+if (test__divtf3(0x1.0p-1022L, 0x1p+52L, UINT64_C(0x0), UINT64_C(0x1)))
+  return 1;
+
 // any / any
 if (test__divtf3(0x1.a23b45362464523375893ab4cdefp+5L,
  0x1.eedcbaba3a94546558237654321fp-1L,
Index: compiler-rt/test/builtins/Unit/divsf3_test.c
===
--- compiler-rt/test/builtins/Unit/divsf3_test.c
+++ compiler-rt/test/builtins/Unit/divsf3_test.c
@@ -80,5 +80,20 @@
 if (test__divsf3(0x1.0p+0F, 0x1.0001p+0F, UINT32_C(0x3f7fff00)))
   return 1;
 
+// smallest normal value divided by 2.0
+if (test__divsf3(0x1.0p-126F, 2.0F, UINT32_C(0x0040)))
+  return 1;
+// smallest subnormal result
+if (test__divsf3(0x1.0p-126F, 0x1p+23F, UINT32_C(0x0001)))
+  return 1;
+
+// some misc test cases obtained by fuzzing against h/w implementation
+if (test__divsf3(-0x1.3e75e6p-108F, -0x1.cf372p+38F, UINT32_C(0x0006)))
+  return 1;
+if (test__divsf3(0x1.e77c54p+81F, -0x1.e77c52p-47F, UINT32_C(0xff80)))
+  return 1;
+if (test__divsf3(0x1.fep-126F, 2.F, UINT32_C(0x0080)))
+  return 1;
+
 return 0;
 }
Index: compiler-rt/test/builtins/Unit/divdf3_test.c
===
--- compiler-rt/test/builtins/Unit/divdf3_test.c
+++ compiler-rt/test/builtins/Unit/divdf3_test.c
@@ -80,6 +80,13 @@
 if (test__divdf3(0x1.0p+0, 0x1.0001p+0, UINT64_C(0x3fefffe0)))
   return 1;
 
+// smallest normal value divided by 2.0
+if (test__divdf3(0x1.0p-1022, 2., UINT64_C(0x0008)))
+  return 1;
+// smallest subnormal result
+if (test__divdf3(0x1.0p-1022, 0x1.0p+52, UINT64_C(0x0001)))
+  return 1;
+
 // some misc test cases obtained by fuzzing against h/w implementation
 if (test__divdf3(0x1.fdc239dd64735p-658, -0x1.fff9364c0843fp-948, UINT64_C(0xd20fdc8fc0ceffb1)))
   return 1;
@@ -87,6 +94,12 @@
   return 1;
 if (test__divdf3(-0x1.da7dfe6048b8bp-875, 0x1.ffc7ea3ff60a4p-610, UINT64_C(0xaf5dab1fe0269e2a)))
   return 1;
+if (test__divdf3(0x1.0p-1022, 0x1.9p+5, UINT64_C(0x51eb851eb852)))
+  return 1;
+if (test__divdf3(0x1.0p-1022, 0x1.0028p+41, UINT64_C(0x07ff)))
+  return 1;
+if (test__divdf3(0x1.0p-1022, 0x1.0028p+52, UINT64_C(0x1)))
+  return 1;
 
 return 0;
 }
Index: compiler-rt/lib/builtins/fp_div_impl.inc
===
--- compiler-rt/lib/builtins/fp_div_impl.inc
+++ compiler-rt/lib/builtins/fp_div_impl.inc
@@ -247,6 +247,7 @@
   if (quotient_UQ1 < (implicitBit << 1)) {
 residualLo = (aSignificand << (significandBits + 1)) - quotient_UQ1 * bSignificand;
 writtenExponent -= 1;
+aSignificand <<= 1;
 
 // the error is doubled
   } else {
@@ -276,19 +277,25 @@
   // Now, quotient_UQ1_SB <= the correctly-rounded result
   // and may need taking NextAfter() up to 3 times (see error estimates above)
   // r = a - b * q
+  rep_t absResult;
+  if (writtenExponent > 0) {
+// Clear the implicit bit
+absResult = quotient_UQ1 & significandMask;
+// Insert the exponent
+absResult |= (rep_t)writtenExponent << significandBits;
+residualLo <<= 1;
+  } else {
+// Prevent shift amount from being negative
+if (significandBits + writtenExponent < 0)
+  return fromRep(quotientSign);
 
-  if (writtenExponent < 0) {
-// Result is definitely subnormal, flushing to zero
-return fromRep(quotientSign);
-  }
+absResult = quotient_UQ1 >> (-writtenExponent + 1);
 
-  // Clear the implicit bit
-  rep_t absResult = quotient_UQ1 & significandMask;
-  // Insert the exponent
-  absResult |= (rep_t)writtenExponent << significandBits;
+// multiplied by two to prevent shift amount to be negative
+residualLo = (aSignifi

[PATCH] D85009: [Sema][BFloat] Forbid arithmetic on vectors of bfloat.

2020-07-31 Thread JF Bastien via Phabricator via cfe-commits
jfb added a comment.

Is that true of all vector bfloat implementations? It seems like arithmetic on 
these types is something implementations would likely support.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85009

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


[PATCH] D85031: [builtins] Unify the softfloat division implementation

2020-07-31 Thread Anatoly Trosinenko via Phabricator via cfe-commits
atrosinenko added a comment.

Here are the benchmark and fuzzing harness used to test this patch.

F12453076: fuzz_divXf3.sh 

F12453075: divXf3_fuzzer.c 

F12453074: bench_divXf3.sh 

F12453073: divXf3_bench.c 




Comment at: compiler-rt/lib/builtins/fp_div_impl.inc:248-249
+  if (quotient_UQ1 < (implicitBit << 1)) {
+residualLo = (aSignificand << (significandBits + 1)) - quotient_UQ1 * 
bSignificand;
+writtenExponent -= 1;
+

Interesting fact: swapping these two seemingly commuting lines makes code 
slower by 15-25%. This applies to current Clang as well as to `clang-8` from 
Ubuntu 20.04 repository.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85031

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


[PATCH] D85031: [builtins] Unify the softfloat division implementation

2020-07-31 Thread Anatoly Trosinenko via Phabricator via cfe-commits
atrosinenko updated this revision to Diff 282225.
atrosinenko added a comment.

Revert auto-linting


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85031

Files:
  compiler-rt/lib/builtins/divdf3.c
  compiler-rt/lib/builtins/divsf3.c
  compiler-rt/lib/builtins/divtf3.c
  compiler-rt/lib/builtins/fp_div_impl.inc
  compiler-rt/lib/builtins/fp_lib.h
  compiler-rt/lib/builtins/int_util.h
  compiler-rt/test/builtins/Unit/divdf3_test.c

Index: compiler-rt/test/builtins/Unit/divdf3_test.c
===
--- compiler-rt/test/builtins/Unit/divdf3_test.c
+++ compiler-rt/test/builtins/Unit/divdf3_test.c
@@ -80,5 +80,13 @@
 if (test__divdf3(0x1.0p+0, 0x1.0001p+0, UINT64_C(0x3fefffe0)))
   return 1;
 
+// some misc test cases obtained by fuzzing against h/w implementation
+if (test__divdf3(0x1.fdc239dd64735p-658, -0x1.fff9364c0843fp-948, UINT64_C(0xd20fdc8fc0ceffb1)))
+  return 1;
+if (test__divdf3(-0x1.78abb261d47c8p+794, 0x1.fb01d537cc5aep+266, UINT64_C(0xe0e7c6148ffc23e3)))
+  return 1;
+if (test__divdf3(-0x1.da7dfe6048b8bp-875, 0x1.ffc7ea3ff60a4p-610, UINT64_C(0xaf5dab1fe0269e2a)))
+  return 1;
+
 return 0;
 }
Index: compiler-rt/lib/builtins/int_util.h
===
--- compiler-rt/lib/builtins/int_util.h
+++ compiler-rt/lib/builtins/int_util.h
@@ -28,4 +28,21 @@
 #define COMPILE_TIME_ASSERT2(expr, cnt)\
   typedef char ct_assert_##cnt[(expr) ? 1 : -1] UNUSED
 
+// Force unrolling the code specified to be repeated N times.
+#define REPEAT_0_TIMES(code_to_repeat) /* do nothing */
+#define REPEAT_1_TIMES(code_to_repeat) \
+  code_to_repeat
+#define REPEAT_2_TIMES(code_to_repeat) \
+  code_to_repeat \
+  code_to_repeat
+#define REPEAT_3_TIMES(code_to_repeat) \
+  REPEAT_2_TIMES(code_to_repeat) \
+  code_to_repeat
+#define REPEAT_4_TIMES(code_to_repeat) \
+  REPEAT_3_TIMES(code_to_repeat) \
+  code_to_repeat
+
+#define REPEAT_N_TIMES_(N, code_to_repeat) REPEAT_##N##_TIMES(code_to_repeat)
+#define REPEAT_N_TIMES(N, code_to_repeat) REPEAT_N_TIMES_(N, code_to_repeat)
+
 #endif // INT_UTIL_H
Index: compiler-rt/lib/builtins/fp_lib.h
===
--- compiler-rt/lib/builtins/fp_lib.h
+++ compiler-rt/lib/builtins/fp_lib.h
@@ -40,9 +40,12 @@
 
 #if defined SINGLE_PRECISION
 
+typedef uint16_t half_rep_t;
 typedef uint32_t rep_t;
+typedef uint64_t twice_rep_t;
 typedef int32_t srep_t;
 typedef float fp_t;
+#define HALF_REP_C UINT16_C
 #define REP_C UINT32_C
 #define significandBits 23
 
@@ -58,9 +61,11 @@
 
 #elif defined DOUBLE_PRECISION
 
+typedef uint32_t half_rep_t;
 typedef uint64_t rep_t;
 typedef int64_t srep_t;
 typedef double fp_t;
+#define HALF_REP_C UINT32_C
 #define REP_C UINT64_C
 #define significandBits 52
 
@@ -102,9 +107,11 @@
 #elif defined QUAD_PRECISION
 #if __LDBL_MANT_DIG__ == 113 && defined(__SIZEOF_INT128__)
 #define CRT_LDBL_128BIT
+typedef uint64_t half_rep_t;
 typedef __uint128_t rep_t;
 typedef __int128_t srep_t;
 typedef long double fp_t;
+#define HALF_REP_C UINT64_C
 #define REP_C (__uint128_t)
 // Note: Since there is no explicit way to tell compiler the constant is a
 // 128-bit integer, we let the constant be casted to 128-bit integer
Index: compiler-rt/lib/builtins/fp_div_impl.inc
===
--- /dev/null
+++ compiler-rt/lib/builtins/fp_div_impl.inc
@@ -0,0 +1,308 @@
+//===-- lib/fp_div_impl.inc - Floating point division -*- 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 file implements soft-float division with the IEEE-754 default
+// rounding (to nearest, ties to even).
+//
+//===--===//
+
+#define HW (typeWidth / 2)
+#define loMask (REP_C(-1) >> HW)
+
+#define NUMBER_OF_ITERATIONS \
+  (NUMBER_OF_HALF_ITERATIONS + NUMBER_OF_FULL_ITERATIONS)
+
+#if NUMBER_OF_FULL_ITERATIONS < 1
+#   error At least one full iteration is required
+#endif
+
+static __inline fp_t __divXf3(fp_t a, fp_t b) {
+
+  const unsigned int aExponent = toRep(a) >> significandBits & maxExponent;
+  const unsigned int bExponent = toRep(b) >> significandBits & maxExponent;
+  const rep_t quotientSign = (toRep(a) ^ toRep(b)) & signBit;
+
+  rep_t aSignificand = toRep(a) & significandMask;
+  rep_t bSignificand = toRep(b) & significandMask;
+  int scale = 0;
+
+  // Detect if a or b is zero, denormal, infinity, or NaN.
+  if (aExponent - 1U >= maxExponent - 1U ||
+  bExponent - 1U >= maxExpone

[PATCH] D84839: Add document outline symbols from unnamed contexts, e.g. extern "C".

2020-07-31 Thread Ilya Golovenko via Phabricator via cfe-commits
ilya-golovenko updated this revision to Diff 282236.
ilya-golovenko added a comment.

Simplify logic in traverseDecl method


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84839

Files:
  clang-tools-extra/clangd/FindSymbols.cpp
  clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp

Index: clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
===
--- clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
+++ clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
@@ -429,6 +429,40 @@
   EXPECT_THAT(getSymbols(TU.build()), IsEmpty());
 }
 
+TEST(DocumentSymbols, ExternContext) {
+  TestTU TU;
+  TU.Code = R"cpp(
+  extern "C" {
+  void foo();
+  class Foo {};
+  }
+  namespace ns {
+extern "C" {
+void bar();
+class Bar {};
+}
+  })cpp";
+
+  EXPECT_THAT(getSymbols(TU.build()),
+  ElementsAre(WithName("foo"), WithName("Foo"),
+  AllOf(WithName("ns"),
+Children(WithName("bar"), WithName("Bar");
+}
+
+TEST(DocumentSymbols, ExportContext) {
+  TestTU TU;
+  TU.ExtraArgs = {"-std=c++20"};
+  TU.Code = R"cpp(
+  export module test;
+  export {
+  void foo();
+  class Foo {};
+  })cpp";
+
+  EXPECT_THAT(getSymbols(TU.build()),
+  ElementsAre(WithName("foo"), WithName("Foo")));
+}
+
 TEST(DocumentSymbols, NoLocals) {
   TestTU TU;
   TU.Code = R"cpp(
Index: clang-tools-extra/clangd/FindSymbols.cpp
===
--- clang-tools-extra/clangd/FindSymbols.cpp
+++ clang-tools-extra/clangd/FindSymbols.cpp
@@ -188,7 +188,7 @@
   }
 
 private:
-  enum class VisitKind { No, OnlyDecl, DeclAndChildren };
+  enum class VisitKind { No, OnlyDecl, OnlyChildren, DeclAndChildren };
 
   void traverseDecl(Decl *D, std::vector &Results) {
 if (auto *Templ = llvm::dyn_cast(D)) {
@@ -196,18 +196,25 @@
   if (auto *TD = Templ->getTemplatedDecl())
 D = TD;
 }
-auto *ND = llvm::dyn_cast(D);
-if (!ND)
-  return;
-VisitKind Visit = shouldVisit(ND);
+
+VisitKind Visit = shouldVisit(D);
 if (Visit == VisitKind::No)
   return;
-llvm::Optional Sym = declToSym(AST.getASTContext(), *ND);
+
+if (Visit == VisitKind::OnlyChildren)
+  return traverseChildren(D, Results);
+
+auto *ND = llvm::cast(D);
+auto Sym = declToSym(AST.getASTContext(), *ND);
 if (!Sym)
   return;
-if (Visit == VisitKind::DeclAndChildren)
-  traverseChildren(D, Sym->children);
 Results.push_back(std::move(*Sym));
+
+if (Visit == VisitKind::OnlyDecl)
+  return;
+
+assert(Visit == VisitKind::DeclAndChildren && "Unexpected VisitKind");
+traverseChildren(ND, Results.back().children);
   }
 
   void traverseChildren(Decl *D, std::vector &Results) {
@@ -218,10 +225,16 @@
   traverseDecl(C, Results);
   }
 
-  VisitKind shouldVisit(NamedDecl *D) {
+  VisitKind shouldVisit(Decl *D) {
 if (D->isImplicit())
   return VisitKind::No;
 
+if (llvm::isa(D) || llvm::isa(D))
+  return VisitKind::OnlyChildren;
+
+if (!llvm::isa(D))
+  return VisitKind::No;
+
 if (auto Func = llvm::dyn_cast(D)) {
   // Some functions are implicit template instantiations, those should be
   // ignored.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D82822: [OpenMP][FIX] Consistently use OpenMPIRBuilder if requested

2020-07-31 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added a comment.

@davezarzycki The bots reported this as well, didn't build MLIR locally, this 
should have been fixed by 4d83aa4771d84940626d86c883193af390812281 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82822

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


[PATCH] D72705: [analyzer] Added new checker 'alpha.unix.ErrorReturn'.

2020-07-31 Thread Balázs Kéri via Phabricator via cfe-commits
balazske added a comment.

Some results with an improved version of this checker:
tmux: 6 results
duckdb: 23 results (1-2 false positive)
vim: 1 result
emacs: 25 results (more false positives mostly because ? operator that is easy 
to fix)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72705

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


[PATCH] D85033: [clang] Provide a better name for unnamed parameters, lambda classes and lambda captures.

2020-07-31 Thread Bruno Ricci via Phabricator via cfe-commits
riccibruno created this revision.
riccibruno added reviewers: erichkeane, rsmith.
riccibruno added a project: clang.
Herald added subscribers: cfe-commits, arphaman.
riccibruno requested review of this revision.

As a follow up to D84658 :

For an unnamed parameter: `(unnamed variable at {{.*}}:: of type 
)` -> `(unnamed parameter at {{.*}}:: of type )`.

For a lambda object: `(unnamed class at {{.*}}::)` -> `(lambda at 
{{.*}}::)`.

For a variable captured in a lambda-capture: `(unnamed field at 
{{.*}}:: of type )` -> pretty-printed name of the captured 
variable (except for now in the uncommon case of a captured VLA; see the 
comment).

I have also added unit tests for the changes in D84658 
.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D85033

Files:
  clang/lib/AST/Decl.cpp
  clang/test/AST/ast-dump-record-definition-data-json.cpp
  clang/test/Analysis/explain-svals.cpp
  clang/test/Index/annotate-tokens.cpp
  clang/test/Index/linkage.c
  clang/test/Index/load-decls.c
  clang/test/Index/load-namespaces.cpp
  clang/test/Index/preamble.c
  clang/test/Index/print-type.c
  clang/test/Index/print-type.cpp
  clang/test/Index/recursive-cxx-member-calls.cpp
  clang/test/Index/usrs.m
  clang/test/Modules/module-private.cpp
  clang/test/SemaCXX/lambda-expressions.cpp
  clang/test/SemaCXX/warn-large-by-value-copy.cpp
  clang/test/Tooling/clang-diff-ast.cpp
  clang/unittests/AST/ASTTraverserTest.cpp
  clang/unittests/AST/NamedDeclPrinterTest.cpp

Index: clang/unittests/AST/NamedDeclPrinterTest.cpp
===
--- clang/unittests/AST/NamedDeclPrinterTest.cpp
+++ clang/unittests/AST/NamedDeclPrinterTest.cpp
@@ -6,7 +6,8 @@
 //
 //===--===//
 //
-// This file contains tests for NamedDecl::printQualifiedName().
+// This file contains tests for NamedDecl::printName()
+// and NamedDecl::printQualifiedName().
 //
 // These tests have a coding convention:
 // * declaration to be printed is named 'A' unless it should have some special
@@ -93,11 +94,10 @@
   return ::testing::AssertionSuccess();
 }
 
-::testing::AssertionResult
-PrintedNamedDeclMatches(StringRef Code, const std::vector &Args,
-bool SuppressUnwrittenScope,
-const DeclarationMatcher &NodeMatch,
-StringRef ExpectedPrinted, StringRef FileName) {
+::testing::AssertionResult PrintedQualifiedNamedDeclMatches(
+StringRef Code, const std::vector &Args,
+bool SuppressUnwrittenScope, const DeclarationMatcher &NodeMatch,
+StringRef ExpectedPrinted, StringRef FileName) {
   return PrintedDeclMatches(Code, Args, NodeMatch, ExpectedPrinted, FileName,
 [=](llvm::raw_ostream &Out, const NamedDecl *ND) {
   auto Policy =
@@ -108,34 +108,43 @@
 });
 }
 
+::testing::AssertionResult PrintedUnqualifiedNamedDeclMatches(
+StringRef Code, const std::vector &Args,
+const DeclarationMatcher &NodeMatch, StringRef ExpectedPrinted,
+StringRef FileName) {
+  return PrintedDeclMatches(
+  Code, Args, NodeMatch, ExpectedPrinted, FileName,
+  [=](llvm::raw_ostream &Out, const NamedDecl *ND) { ND->printName(Out); });
+}
+
 ::testing::AssertionResult
-PrintedNamedDeclCXX98Matches(StringRef Code, StringRef DeclName,
- StringRef ExpectedPrinted) {
+PrintedQualifiedNamedDeclCXX98Matches(StringRef Code, StringRef DeclName,
+  StringRef ExpectedPrinted) {
   std::vector Args(1, "-std=c++98");
-  return PrintedNamedDeclMatches(Code, Args,
- /*SuppressUnwrittenScope*/ false,
- namedDecl(hasName(DeclName)).bind("id"),
- ExpectedPrinted, "input.cc");
+  return PrintedQualifiedNamedDeclMatches(
+  Code, Args,
+  /*SuppressUnwrittenScope*/ false, namedDecl(hasName(DeclName)).bind("id"),
+  ExpectedPrinted, "input.cc");
 }
 
 ::testing::AssertionResult
-PrintedWrittenNamedDeclCXX11Matches(StringRef Code, StringRef DeclName,
-StringRef ExpectedPrinted) {
+PrintedWrittenQualifiedNamedDeclCXX11Matches(StringRef Code, StringRef DeclName,
+ StringRef ExpectedPrinted) {
   std::vector Args(1, "-std=c++11");
-  return PrintedNamedDeclMatches(Code, Args,
- /*SuppressUnwrittenScope*/ true,
- namedDecl(hasName(DeclName)).bind("id"),
- ExpectedPrinted, "input.cc");
+  return PrintedQualifiedNamedDeclMatches(
+  Code, Args,
+  /*SuppressUnwrittenScope*/ true, namedDecl(hasName(DeclName)).bind("id"),
+  ExpectedPrinted, "input.cc");
 }
 
-::testing::AssertionResult
-Prin

[PATCH] D81346: [KernelAddressSanitizer] Ensure global array size remains multiple of type-size

2020-07-31 Thread Marco Elver via Phabricator via cfe-commits
melver added a comment.

Note: We landed globals support for KASAN with 
https://reviews.llvm.org/rGd3f89314ff20ce1612bd5e09f9f90ff5dd5205a7


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81346

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


[PATCH] D85009: [Sema][BFloat] Forbid arithmetic on vectors of bfloat.

2020-07-31 Thread Simon Tatham via Phabricator via cfe-commits
simon_tatham added a comment.

In D85009#2187549 , @jfb wrote:

> Is that true of all vector bfloat implementations? It seems like arithmetic 
> on these types is something implementations would likely support.

As I understand it, Arm currently has the only implementation in clang so far. 
But if other targets disagree, we can make this conditional on 
`getVectorKind()`, so that `VectorType::NeonVector` gets this restriction and 
other vector types get whatever they need.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85009

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


[PATCH] D85034: [analyzer] Simplified functions SVal::getAsSymbolicExpression and similar ones

2020-07-31 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov created this revision.
ASDenysPetrov added reviewers: vsavchenko, NoQ, steakhal, dcoughlin.
ASDenysPetrov added a project: clang.
Herald added subscribers: cfe-commits, martong, Charusso, dkrupp, donat.nagy, 
Szelethus, mikhail.ramalho, a.sidorin, szepet, baloghadamsoftware, xazax.hun.
ASDenysPetrov requested review of this revision.

Simplified functions `SVal::getAsSymbolicExpression`, `SVal::getAsSymExpr` and 
`SVal::getAsSymbol`. After revision I concluded that `getAsSymbolicExpression` 
and `getAsSymExpr` repeat functionality of `getAsSymbol`, thus they can be 
removed.

Fix: Removed functions SVal::getAsSymbolicExpression and SVal::getAsSymExpr.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D85034

Files:
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h
  clang/lib/StaticAnalyzer/Checkers/CheckObjCDealloc.cpp
  clang/lib/StaticAnalyzer/Checkers/MacOSKeychainAPIChecker.cpp
  
clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.cpp
  clang/lib/StaticAnalyzer/Checkers/Taint.cpp
  clang/lib/StaticAnalyzer/Core/ProgramState.cpp
  clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
  clang/lib/StaticAnalyzer/Core/SVals.cpp
  clang/lib/StaticAnalyzer/Core/SimpleConstraintManager.cpp
  clang/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp

Index: clang/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
===
--- clang/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
+++ clang/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
@@ -86,7 +86,7 @@
 return makeLocAsInteger(LI->getLoc(), castSize);
   }
 
-  if (const SymExpr *se = val.getAsSymbolicExpression()) {
+  if (SymbolRef se = val.getAsSymbol()) {
 QualType T = Context.getCanonicalType(se->getType());
 // If types are the same or both are integers, ignore the cast.
 // FIXME: Remove this hack when we support symbolic truncation/extension.
Index: clang/lib/StaticAnalyzer/Core/SimpleConstraintManager.cpp
===
--- clang/lib/StaticAnalyzer/Core/SimpleConstraintManager.cpp
+++ clang/lib/StaticAnalyzer/Core/SimpleConstraintManager.cpp
@@ -57,7 +57,7 @@
   // SymIntExprs.
   if (!canReasonAbout(Cond)) {
 // Just add the constraint to the expression without trying to simplify.
-SymbolRef Sym = Cond.getAsSymExpr();
+SymbolRef Sym = Cond.getAsSymbol();
 assert(Sym);
 return assumeSymUnsupported(State, Sym, Assumption);
   }
@@ -101,7 +101,7 @@
 
   if (!canReasonAbout(Value)) {
 // Just add the constraint to the expression without trying to simplify.
-SymbolRef Sym = Value.getAsSymExpr();
+SymbolRef Sym = Value.getAsSymbol();
 assert(Sym);
 return assumeSymInclusiveRange(State, Sym, From, To, InRange);
   }
Index: clang/lib/StaticAnalyzer/Core/SVals.cpp
===
--- clang/lib/StaticAnalyzer/Core/SVals.cpp
+++ clang/lib/StaticAnalyzer/Core/SVals.cpp
@@ -116,8 +116,6 @@
   return nullptr;
 }
 
-// TODO: The next 3 functions have to be simplified.
-
 /// If this SVal wraps a symbol return that SymbolRef.
 /// Otherwise, return 0.
 ///
@@ -132,22 +130,6 @@
   return getAsLocSymbol(IncludeBaseRegions);
 }
 
-/// getAsSymbolicExpression - If this Sval wraps a symbolic expression then
-///  return that expression.  Otherwise return NULL.
-const SymExpr *SVal::getAsSymbolicExpression() const {
-  if (Optional X = getAs())
-return X->getSymbol();
-
-  return getAsSymbol();
-}
-
-const SymExpr* SVal::getAsSymExpr() const {
-  const SymExpr* Sym = getAsSymbol();
-  if (!Sym)
-Sym = getAsSymbolicExpression();
-  return Sym;
-}
-
 const MemRegion *SVal::getAsRegion() const {
   if (Optional X = getAs())
 return X->getRegion();
Index: clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
===
--- clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
+++ clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
@@ -377,8 +377,8 @@
 SVal SValBuilder::makeSymExprValNN(BinaryOperator::Opcode Op,
NonLoc LHS, NonLoc RHS,
QualType ResultTy) {
-  const SymExpr *symLHS = LHS.getAsSymExpr();
-  const SymExpr *symRHS = RHS.getAsSymExpr();
+  SymbolRef symLHS = LHS.getAsSymbol();
+  SymbolRef symRHS = RHS.getAsSymbol();
 
   // TODO: When the Max Complexity is reached, we should conjure a symbol
   // instead of generating an Unknown value and propagate the taint info to it.
@@ -492,7 +492,7 @@
   if (getContext().getTypeSize(castTy) >= getContext().getTypeSize(originalTy))
 return evalCast(val, castTy, originalTy);
 
-  const SymExpr *se = val.getAsSymbolicExpression();
+  SymbolRef se = val.getAsSymbol();
   if (!se) // Let evalCast handle non symbolic expressions.
 return evalCast(val, castTy, originalTy);
 
Index: clang/lib/StaticAnalyzer/Core/ProgramState.cpp
===

[PATCH] D85009: [Sema][BFloat] Forbid arithmetic on vectors of bfloat.

2020-07-31 Thread JF Bastien via Phabricator via cfe-commits
jfb added a comment.

In D85009#2187603 , @simon_tatham 
wrote:

> In D85009#2187549 , @jfb wrote:
>
>> Is that true of all vector bfloat implementations? It seems like arithmetic 
>> on these types is something implementations would likely support.
>
> As I understand it, Arm currently has the only implementation in clang so 
> far. But if other targets disagree, we can make this conditional on 
> `getVectorKind()`, so that `VectorType::NeonVector` gets this restriction and 
> other vector types get whatever they need.

You mean: only aarch64 backend supports lowering bfloat16 vectors at the 
moment? Because the clang support isn't "ARM bfloat", it's just bfloat. The 
tests are ARM bfloat and I think that's fine (i.e. Sema should be able to check 
ISA-specific problems), but in general this property your checking for seems 
like a target property.

If I write C or C++ code using bfloat, I'd like to know what that type actually 
means and what I can do with it. As a developer, it'll be super frustrating 
once other targets support bfloat... should those target have their own bfloat 
(because it won't be compatible with ARM's), or should bfloat work differently 
on different targets?

I actually don't know what the intended approach is here, which is why I'm 
asking :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85009

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


[PATCH] D82576: [PowerPC][Power10] Implement low-order Vector Modulus Builtins, and add Vector Multiply/Divide/Modulus Builtins Tests

2020-07-31 Thread Amy Kwan via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc4e574323210: [PowerPC] Implement low-order Vector Modulus 
Builtins, and add Vector… (authored by amyk).

Changed prior to commit:
  https://reviews.llvm.org/D82576?vs=274679&id=282244#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82576

Files:
  clang/lib/Headers/altivec.h
  clang/test/CodeGen/builtins-ppc-p10vector.c

Index: clang/test/CodeGen/builtins-ppc-p10vector.c
===
--- clang/test/CodeGen/builtins-ppc-p10vector.c
+++ clang/test/CodeGen/builtins-ppc-p10vector.c
@@ -25,6 +25,66 @@
 unsigned short usa;
 unsigned long long ulla;
 
+vector signed long long test_vec_mul_sll(void) {
+  // CHECK: mul <2 x i64>
+  // CHECK-NEXT: ret <2 x i64>
+  return vec_mul(vslla, vsllb);
+}
+
+vector unsigned long long test_vec_mul_ull(void) {
+  // CHECK: mul <2 x i64>
+  // CHECK-NEXT: ret <2 x i64>
+  return vec_mul(vulla, vullb);
+}
+
+vector signed int test_vec_div_si(void) {
+  // CHECK: sdiv <4 x i32>
+  // CHECK-NEXT: ret <4 x i32>
+  return vec_div(vsia, vsib);
+}
+
+vector unsigned int test_vec_div_ui(void) {
+  // CHECK: udiv <4 x i32>
+  // CHECK-NEXT: ret <4 x i32>
+  return vec_div(vuia, vuib);
+}
+
+vector signed long long test_vec_div_sll(void) {
+  // CHECK: sdiv <2 x i64>
+  // CHECK-NEXT: ret <2 x i64>
+  return vec_div(vslla, vsllb);
+}
+
+vector unsigned long long test_vec_div_ull(void) {
+  // CHECK: udiv <2 x i64>
+  // CHECK-NEXT: ret <2 x i64>
+  return vec_div(vulla, vullb);
+}
+
+vector signed int test_vec_mod_si(void) {
+  // CHECK: srem <4 x i32>
+  // CHECK-NEXT: ret <4 x i32>
+  return vec_mod(vsia, vsib);
+}
+
+vector unsigned int test_vec_mod_ui(void) {
+  // CHECK: urem <4 x i32>
+  // CHECK-NEXT: ret <4 x i32>
+  return vec_mod(vuia, vuib);
+}
+
+vector signed long long test_vec_mod_sll(void) {
+  // CHECK: srem <2 x i64>
+  // CHECK-NEXT: ret <2 x i64>
+  return vec_mod(vslla, vsllb);
+}
+
+vector unsigned long long test_vec_mod_ull(void) {
+  // CHECK: urem <2 x i64>
+  // CHECK-NEXT: ret <2 x i64>
+  return vec_mod(vulla, vullb);
+}
+
 vector unsigned long long test_vpdepd(void) {
   // CHECK: @llvm.ppc.altivec.vpdepd(<2 x i64>
   // CHECK-NEXT: ret <2 x i64>
Index: clang/lib/Headers/altivec.h
===
--- clang/lib/Headers/altivec.h
+++ clang/lib/Headers/altivec.h
@@ -16933,6 +16933,28 @@
   return __builtin_altivec_vctzdm(__a, __b);
 }
 
+/* vec_mod */
+
+static __inline__ vector signed int __ATTRS_o_ai
+vec_mod(vector signed int __a, vector signed int __b) {
+  return __a % __b;
+}
+
+static __inline__ vector unsigned int __ATTRS_o_ai
+vec_mod(vector unsigned int __a, vector unsigned int __b) {
+  return __a % __b;
+}
+
+static __inline__ vector signed long long __ATTRS_o_ai
+vec_mod(vector signed long long __a, vector signed long long __b) {
+  return __a % __b;
+}
+
+static __inline__ vector unsigned long long __ATTRS_o_ai
+vec_mod(vector unsigned long long __a, vector unsigned long long __b) {
+  return __a % __b;
+}
+
 /* vec_sldbi */
 
 #define vec_sldb(__a, __b, __c) __builtin_altivec_vsldbi(__a, __b, (__c & 0x7))
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] c4e5743 - [PowerPC] Implement low-order Vector Modulus Builtins, and add Vector Multiply/Divide/Modulus Builtins Tests

2020-07-31 Thread Amy Kwan via cfe-commits

Author: Amy Kwan
Date: 2020-07-31T10:58:07-05:00
New Revision: c4e574323210feda1a3988e85fdd93b90a63d1b1

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

LOG: [PowerPC] Implement low-order Vector Modulus Builtins, and add Vector 
Multiply/Divide/Modulus Builtins Tests

Power10 introduces new instructions for vector multiply, divide and modulus.
These instructions can be exploited by the builtin functions: vec_mul, vec_div,
and vec_mod, respectively.

This patch aims adds the function prototype, vec_mod, as vec_mul and vec_div
been previously implemented in altivec.h.

This patch also adds the following front end tests:
vec_mul for v2i64
vec_div for v4i32 and v2i64
vec_mod for v4i32 and v2i64

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

Added: 


Modified: 
clang/lib/Headers/altivec.h
clang/test/CodeGen/builtins-ppc-p10vector.c

Removed: 




diff  --git a/clang/lib/Headers/altivec.h b/clang/lib/Headers/altivec.h
index 4e25ec118072..f42200f5bd4e 100644
--- a/clang/lib/Headers/altivec.h
+++ b/clang/lib/Headers/altivec.h
@@ -16933,6 +16933,28 @@ vec_cnttzm(vector unsigned long long __a, vector 
unsigned long long __b) {
   return __builtin_altivec_vctzdm(__a, __b);
 }
 
+/* vec_mod */
+
+static __inline__ vector signed int __ATTRS_o_ai
+vec_mod(vector signed int __a, vector signed int __b) {
+  return __a % __b;
+}
+
+static __inline__ vector unsigned int __ATTRS_o_ai
+vec_mod(vector unsigned int __a, vector unsigned int __b) {
+  return __a % __b;
+}
+
+static __inline__ vector signed long long __ATTRS_o_ai
+vec_mod(vector signed long long __a, vector signed long long __b) {
+  return __a % __b;
+}
+
+static __inline__ vector unsigned long long __ATTRS_o_ai
+vec_mod(vector unsigned long long __a, vector unsigned long long __b) {
+  return __a % __b;
+}
+
 /* vec_sldbi */
 
 #define vec_sldb(__a, __b, __c) __builtin_altivec_vsldbi(__a, __b, (__c & 0x7))

diff  --git a/clang/test/CodeGen/builtins-ppc-p10vector.c 
b/clang/test/CodeGen/builtins-ppc-p10vector.c
index e67018b06214..571d33d34a22 100644
--- a/clang/test/CodeGen/builtins-ppc-p10vector.c
+++ b/clang/test/CodeGen/builtins-ppc-p10vector.c
@@ -25,6 +25,66 @@ unsigned char uca;
 unsigned short usa;
 unsigned long long ulla;
 
+vector signed long long test_vec_mul_sll(void) {
+  // CHECK: mul <2 x i64>
+  // CHECK-NEXT: ret <2 x i64>
+  return vec_mul(vslla, vsllb);
+}
+
+vector unsigned long long test_vec_mul_ull(void) {
+  // CHECK: mul <2 x i64>
+  // CHECK-NEXT: ret <2 x i64>
+  return vec_mul(vulla, vullb);
+}
+
+vector signed int test_vec_div_si(void) {
+  // CHECK: sdiv <4 x i32>
+  // CHECK-NEXT: ret <4 x i32>
+  return vec_div(vsia, vsib);
+}
+
+vector unsigned int test_vec_div_ui(void) {
+  // CHECK: udiv <4 x i32>
+  // CHECK-NEXT: ret <4 x i32>
+  return vec_div(vuia, vuib);
+}
+
+vector signed long long test_vec_div_sll(void) {
+  // CHECK: sdiv <2 x i64>
+  // CHECK-NEXT: ret <2 x i64>
+  return vec_div(vslla, vsllb);
+}
+
+vector unsigned long long test_vec_div_ull(void) {
+  // CHECK: udiv <2 x i64>
+  // CHECK-NEXT: ret <2 x i64>
+  return vec_div(vulla, vullb);
+}
+
+vector signed int test_vec_mod_si(void) {
+  // CHECK: srem <4 x i32>
+  // CHECK-NEXT: ret <4 x i32>
+  return vec_mod(vsia, vsib);
+}
+
+vector unsigned int test_vec_mod_ui(void) {
+  // CHECK: urem <4 x i32>
+  // CHECK-NEXT: ret <4 x i32>
+  return vec_mod(vuia, vuib);
+}
+
+vector signed long long test_vec_mod_sll(void) {
+  // CHECK: srem <2 x i64>
+  // CHECK-NEXT: ret <2 x i64>
+  return vec_mod(vslla, vsllb);
+}
+
+vector unsigned long long test_vec_mod_ull(void) {
+  // CHECK: urem <2 x i64>
+  // CHECK-NEXT: ret <2 x i64>
+  return vec_mod(vulla, vullb);
+}
+
 vector unsigned long long test_vpdepd(void) {
   // CHECK: @llvm.ppc.altivec.vpdepd(<2 x i64>
   // CHECK-NEXT: ret <2 x i64>



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


[PATCH] D85009: [Sema][BFloat] Forbid arithmetic on vectors of bfloat.

2020-07-31 Thread Luke Geeson via Phabricator via cfe-commits
LukeGeeson added a comment.

In D85009#2187621 , @jfb wrote:

> In D85009#2187603 , @simon_tatham 
> wrote:
>
>> In D85009#2187549 , @jfb wrote:
>>
>>> Is that true of all vector bfloat implementations? It seems like arithmetic 
>>> on these types is something implementations would likely support.
>>
>> As I understand it, Arm currently has the only implementation in clang so 
>> far. But if other targets disagree, we can make this conditional on 
>> `getVectorKind()`, so that `VectorType::NeonVector` gets this restriction 
>> and other vector types get whatever they need.
>
> You mean: only aarch64 backend supports lowering bfloat16 vectors at the 
> moment? Because the clang support isn't "ARM bfloat", it's just bfloat. The 
> tests are ARM bfloat and I think that's fine (i.e. Sema should be able to 
> check ISA-specific problems), but in general this property your checking for 
> seems like a target property.
>
> If I write C or C++ code using bfloat, I'd like to know what that type 
> actually means and what I can do with it. As a developer, it'll be super 
> frustrating once other targets support bfloat... should those target have 
> their own bfloat (because it won't be compatible with ARM's), or should 
> bfloat work differently on different targets?
>
> I actually don't know what the intended approach is here, which is why I'm 
> asking :)

Yes there is an Intel bfloat type too, however we are the only target for the 
bfloat c/ir type so far. The jury is also out as far as the standards are 
concerned too, the best we can do now is prevent behavior we know is not 
compatible, and like Simon says, add some predication later


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85009

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


[PATCH] D85009: [Sema][BFloat] Forbid arithmetic on vectors of bfloat.

2020-07-31 Thread Simon Tatham via Phabricator via cfe-commits
simon_tatham added a comment.

In D85009#2187621 , @jfb wrote:

> You mean: only aarch64 backend supports lowering bfloat16 vectors at the 
> moment?

Yes, sorry – I should have said that Arm has the only implementation //in an 
LLVM target//. I meant the only one "in clang" in the sense of "compiled into 
the overall clang binary", which was unclear of me.

I agree that from a front end / language specification perspective this is 
tricky. That's why I mentioned the vector kind. The //scalar// bfloat type may 
have to have the same source-language semantics across all targets, but when it 
comes to vectors, each target will define a different set of vector types. The 
Arm header files will be defining something along the lines of

  typedef __attribute__((neon_vector_type(8))) bfloat16_t bfloat16x8_t;

and the next target that wants to use a vector of bfloat will presumably do 
something similar with a different `foo_vector_type` attribute (and quite 
likely a different set of vector lengths too).

Vector architectures are more or less //certain// to vary in the range of 
operations they permit, so it seems reasonable to me that clang will end up 
wanting to treat a `neon_vector_type` vector of bfloats differently from 
whatever other `foo_vector_type` is declared. They'll be different types, and 
conditioning behavior on which one you've got is essentially a way to make it 
target-specific.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85009

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


[PATCH] D85009: [Sema][BFloat] Forbid arithmetic on vectors of bfloat.

2020-07-31 Thread JF Bastien via Phabricator via cfe-commits
jfb added a comment.

In D85009#2187631 , @LukeGeeson wrote:

> In D85009#2187621 , @jfb wrote:
>
>> In D85009#2187603 , @simon_tatham 
>> wrote:
>>
>>> In D85009#2187549 , @jfb wrote:
>>>
 Is that true of all vector bfloat implementations? It seems like 
 arithmetic on these types is something implementations would likely 
 support.
>>>
>>> As I understand it, Arm currently has the only implementation in clang so 
>>> far. But if other targets disagree, we can make this conditional on 
>>> `getVectorKind()`, so that `VectorType::NeonVector` gets this restriction 
>>> and other vector types get whatever they need.
>>
>> You mean: only aarch64 backend supports lowering bfloat16 vectors at the 
>> moment? Because the clang support isn't "ARM bfloat", it's just bfloat. The 
>> tests are ARM bfloat and I think that's fine (i.e. Sema should be able to 
>> check ISA-specific problems), but in general this property your checking for 
>> seems like a target property.
>>
>> If I write C or C++ code using bfloat, I'd like to know what that type 
>> actually means and what I can do with it. As a developer, it'll be super 
>> frustrating once other targets support bfloat... should those target have 
>> their own bfloat (because it won't be compatible with ARM's), or should 
>> bfloat work differently on different targets?
>>
>> I actually don't know what the intended approach is here, which is why I'm 
>> asking :)
>
> Yes there is an Intel bfloat type too, however we are the only target for the 
> bfloat c/ir type so far. The jury is also out as far as the standards are 
> concerned too, the best we can do now is prevent behavior we know is not 
> compatible, and like Simon says, add some predication later

Language-wise I think https://wg21.link/p1467 is where C++ is going, and C is 
taking a similar approach.

I'd like to make sure this is well thought out. Not just "the ISA does this, 
let's do the same". We know other ISAs act differently, and I'm not clear on 
what the intended behavior will be for people writing C and C++ code.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85009

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


[PATCH] D85034: [analyzer] Simplified functions SVal::getAsSymbolicExpression and similar ones

2020-07-31 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko added a comment.

Thanks for working on improving the quality of the codebase!
I again have to nitpick about the commit message, can you please change it to 
"Simplify ..."?




Comment at: clang/lib/StaticAnalyzer/Core/SVals.cpp:135-149
-/// getAsSymbolicExpression - If this Sval wraps a symbolic expression then
-///  return that expression.  Otherwise return NULL.
-const SymExpr *SVal::getAsSymbolicExpression() const {
-  if (Optional X = getAs())
-return X->getSymbol();
-
-  return getAsSymbol();

Oof, it's a mess!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85034

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


[PATCH] D68997: Allow searching for prebuilt implicit modules.

2020-07-31 Thread Alexandre Rames via Phabricator via cfe-commits
arames marked 2 inline comments as done.
arames added inline comments.



Comment at: clang/docs/Modules.rst:295
+
+A trick to prebuilt required modules in one command is to generate implicit 
modules using the ``-fdisable-module-hash`` option.
+

Bigcheese wrote:
> I also think it's important to point out here that disabling the module hash 
> means you are responsible for making sure the modules are compatible. How to 
> do this is mentioned below, but it's never stated why you would want to do 
> this.
Fixed the typo.

Good point.
I am refactoring the examples to make everything clearer.



Comment at: clang/docs/Modules.rst:303
+  # prebuilt/A.pcm  prebuilt/B.pcm
+  clang -cc1 -x c use.c -fmodules -fprebuilt-module-path=prebuilt -o /use.o
+

Fixed a few other typos in the examples as well.



Comment at: clang/test/Modules/prebuilt-implicit-modules.m:9
+// RUN: %clang_cc1 -x objective-c %s -I%S/Inputs/prebuilt-implicit-module 
-fmodules -fmodule-map-file=%S/Inputs/prebuilt-implicit-module/module.modulemap 
-fprebuilt-implicit-modules -fprebuilt-module-path=%t -fmodules-cache-path=%t1
+// RUN: find %t1 -name "module_a*.pcm" | not grep module_e
+//

Bigcheese wrote:
> Is this actually supposed to be `module_e`? I would expect this to be 
> verifying that it didn't add `module_a` to `%t1`.
That was a typo. Fixed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68997

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


[PATCH] D81083: [Clang] Allow "vector_size" applied to Booleans

2020-07-31 Thread Richard Sandiford via Phabricator via cfe-commits
rsandifo-arm added a subscriber: lenary.
rsandifo-arm added inline comments.



Comment at: clang/docs/LanguageExtensions.rst:473
+architectures.  The size parameter of a boolean vector type is the number of
+bits in the vector (for all non-bool vectors, the number refers to the number
+of bytes in the vector).

simoll wrote:
> lenary wrote:
> > It would be nice if this aside about non-bool vectors was more prominently 
> > displayed - it's something I hadn't realised before.
> Yep. that caught me by surprise too. I'll move that sentence to the paragraph 
> about GCC vectors above.
Sorry for the extremely late comment.  Like @lenary I hadn't thought about 
this.  I'd assumed that the vector woiuld still be a multiple of 8 bits in 
size, but I agree that's probably too restrictive to be the only option 
available.

In that case, would it make sense to add a separate attribute instead?  I think 
it's too surprising to change the units of the existing attribute based on the 
element type.  Perhaps we should even make it take two parameters: the total 
number of elements, and the number of bits per element.  That might be more 
natural for some AVX and SVE combinations.  We wouldn't need to supporrt all 
combinations from the outset, it's just a question whether we should make the 
syntax general enough to support it in future.

Perhaps we could do both: support `vector_size` for `bool` using byte sizes 
(and not allowing subbyte vector lengths), and add a new, more general 
attribute that allows subbyte lengths and explicit subbyte element sizes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81083

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


[PATCH] D66035: [WebAssembly] WIP: Add support for reference types

2020-07-31 Thread Thomas Lively via Phabricator via cfe-commits
tlively added a comment.

In D66035#2187021 , @pmatos wrote:

> In D66035#2181659 , @pmatos wrote:
>
>> I will be splitting the part enabling the target feature through clang into 
>> a separate revision as suggested by @tlively
>
> I just noticed that most of this work landed in an earlier commit

Sorry, I forgot about that!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66035

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


[PATCH] D84678: [clang] False line number in a function definition with "void" parameter

2020-07-31 Thread Bruno Ricci via Phabricator via cfe-commits
riccibruno added a comment.

In D84678#2184687 , @Jac1494 wrote:

> Hi @aaron.ballman ,
> Address your review comments. 
> Thank you for accepting this. I don't have commit access please commit this.
> Thanks.

As discussed with Aaron on IRC I can commit it for you. To do that I need a 
name and an email for the attribution.
But first move the test to the already existing `test/Sema/void_arg.c` which 
already test this diagnostic.


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

https://reviews.llvm.org/D84678

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


[PATCH] D84811: [clangd] Add an option to exclude symbols outside of project root from index

2020-07-31 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev added inline comments.



Comment at: clang-tools-extra/clangd/indexer/IndexerMain.cpp:70
 SymbolCollector::Options Opts;
+Opts.FileFilter = FileFilter;
 Opts.CountReferences = true;

hokein wrote:
> `FileFilter` seems more promising, but there are some FIXMEs ("use the result 
> to filter out symbols.") in the SymbolCollector.cpp` -- looks like the 
> SymbolCollector doesn't support this yet, sigh...
Hmm, you are right. However, I tried running the indxer with and without new 
option and the number of symbols & references was different. Hmm, this is 
interesting, I wonder why this happened.

Yeah, I think I should update the code to make sure everything works. Thanks 
for noticing it!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84811

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


[PATCH] D84811: [clangd] Add an option to exclude symbols outside of project root from index

2020-07-31 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev planned changes to this revision.
kbobyrev added a comment.

Need tot resolve `FIXME`s around `shouldIndexFile()`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84811

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


[PATCH] D84197: [PowerPC][Power10] Vector String Isolate instruction definitions and MC Tests

2020-07-31 Thread Amy Kwan via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG93fd8dbdc250: [PowerPC] Add Vector String Isolate 
instruction definitions and MC Tests (authored by Conanap, committed by amyk).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84197

Files:
  llvm/lib/Target/PowerPC/PPCInstrPrefix.td
  llvm/test/MC/Disassembler/PowerPC/ppc64-encoding-ISA31.txt
  llvm/test/MC/PowerPC/ppc64-encoding-ISA31.s

Index: llvm/test/MC/PowerPC/ppc64-encoding-ISA31.s
===
--- llvm/test/MC/PowerPC/ppc64-encoding-ISA31.s
+++ llvm/test/MC/PowerPC/ppc64-encoding-ISA31.s
@@ -585,3 +585,24 @@
 # CHECK-BE: xscvsqqp 8, 28# encoding: [0xfd,0x0b,0xe6,0x88]
 # CHECK-LE: xscvsqqp 8, 28# encoding: [0x88,0xe6,0x0b,0xfd]
 xscvsqqp 8, 28
+# CHECK-BE: vstribr 2, 2  # encoding: [0x10,0x41,0x10,0x0d]
+# CHECK-LE: vstribr 2, 2  # encoding: [0x0d,0x10,0x41,0x10]
+vstribr 2, 2
+# CHECK-BE: vstribl 2, 2  # encoding: [0x10,0x40,0x10,0x0d]
+# CHECK-LE: vstribl 2, 2  # encoding: [0x0d,0x10,0x40,0x10]
+vstribl 2, 2
+# CHECK-BE: vstrihr 2, 2  # encoding: [0x10,0x43,0x10,0x0d]
+# CHECK-LE: vstrihr 2, 2  # encoding: [0x0d,0x10,0x43,0x10]
+vstrihr 2, 2
+# CHECK-BE: vstribr. 2, 2 # encoding: [0x10,0x41,0x14,0x0d]
+# CHECK-LE: vstribr. 2, 2 # encoding: [0x0d,0x14,0x41,0x10]
+vstribr. 2, 2
+# CHECK-BE: vstribl. 2, 2 # encoding: [0x10,0x40,0x14,0x0d]
+# CHECK-LE: vstribl. 2, 2 # encoding: [0x0d,0x14,0x40,0x10]
+vstribl. 2, 2
+# CHECK-BE: vstrihr. 2, 2 # encoding: [0x10,0x43,0x14,0x0d]
+# CHECK-LE: vstrihr. 2, 2 # encoding: [0x0d,0x14,0x43,0x10]
+vstrihr. 2, 2
+# CHECK-BE: vstrihl. 2, 2 # encoding: [0x10,0x42,0x14,0x0d]
+# CHECK-LE: vstrihl. 2, 2 # encoding: [0x0d,0x14,0x42,0x10]
+vstrihl. 2, 2
Index: llvm/test/MC/Disassembler/PowerPC/ppc64-encoding-ISA31.txt
===
--- llvm/test/MC/Disassembler/PowerPC/ppc64-encoding-ISA31.txt
+++ llvm/test/MC/Disassembler/PowerPC/ppc64-encoding-ISA31.txt
@@ -459,3 +459,26 @@
 # CHECK: xscvsqqp 8, 28
 0xfd 0xb 0xe6 0x88
 
+# CHECK: vstribr 2, 2
+0x10 0x41 0x10 0x0d
+
+# CHECK: vstribl 2, 2
+0x10 0x40 0x10 0x0d
+
+# CHECK: vstrihr 2, 2
+0x10 0x43 0x10 0x0d
+
+# CHECK: vstrihl 2, 2
+0x10 0x42 0x10 0x0d
+
+# CHECK: vstribr. 2, 2
+0x10 0x41 0x14 0x0d
+
+# CHECK: vstribl. 2, 2
+0x10 0x40 0x14 0x0d
+
+# CHECK: vstrihr. 2, 2
+0x10 0x43 0x14 0x0d
+
+# CHECK: vstrihl. 2, 2
+0x10 0x42 0x14 0x0d
Index: llvm/lib/Target/PowerPC/PPCInstrPrefix.td
===
--- llvm/lib/Target/PowerPC/PPCInstrPrefix.td
+++ llvm/lib/Target/PowerPC/PPCInstrPrefix.td
@@ -59,6 +59,39 @@
   string BaseName = "";
 }
 
+// VX-Form: [ PO VT R VB RC XO ]
+class VXForm_VTB5_RC xo, bits<5> R, dag OOL, dag IOL, string asmstr,
+  InstrItinClass itin, list pattern>
+  : I<4, OOL, IOL, asmstr, itin> {
+  bits<5> VT;
+  bits<5> VB;
+  bit RC = 0;
+
+  let Pattern = pattern;
+
+  let Inst{6-10} = VT;
+  let Inst{11-15} = R;
+  let Inst{16-20} = VB;
+  let Inst{21} = RC;
+  let Inst{22-31} = xo;
+}
+
+// Multiclass definition to account for record and non-record form
+// instructions of VXRForm.
+multiclass VXForm_VTB5_RCr xo, bits<5> R, dag OOL, dag IOL,
+string asmbase, string asmstr,
+InstrItinClass itin, list pattern> {
+  let BaseName = asmbase in {
+def NAME : VXForm_VTB5_RC, RecFormRel;
+let Defs = [CR6] in
+def _rec : VXForm_VTB5_RC, isRecordForm, RecFormRel;
+  }
+}
+
 class MLS_DForm_R_SI34_RTA5_MEM opcode, dag OOL, dag IOL, string asmstr,
 InstrItinClass itin, list pattern>
   : PI<1, opcode, OOL, IOL, asmstr, itin> {
@@ -822,6 +855,14 @@
   (int_ppc_altivec_vsrdbi v16i8:$VRA,
   v16i8:$VRB, 
   i32:$SH))]>;
+  defm VSTRIBR : VXForm_VTB5_RCr<13, 1, (outs vrrc:$vT), (ins vrrc:$vB),
+ "vstribr", "$vT, $vB", IIC_VecGeneral, []>;
+  defm VSTRIBL : VXForm_VTB5_RCr<13, 0, (outs vrrc:$vT), (ins vrrc:$vB),
+ "vstribl", "$vT, $vB", IIC_VecGeneral, []>;
+  defm VSTRIHR : VXForm_VTB5_RCr<13, 3, (outs vrrc:$vT), (ins vrrc

[PATCH] D76323: [AST] Fix handling of long double and bool in __builtin_bit_cast

2020-07-31 Thread Louis Dionne via Phabricator via cfe-commits
ldionne added a comment.

Gentle ping. This is blocking the implementation of `std::bit_cast` in libc++.


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

https://reviews.llvm.org/D76323

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


[PATCH] D84678: [clang] False line number in a function definition with "void" parameter

2020-07-31 Thread Bruno Ricci via Phabricator via cfe-commits
riccibruno added a comment.

In D84678#2187747 , @riccibruno wrote:

> In D84678#2184687 , @Jac1494 wrote:
>
>> Hi @aaron.ballman ,
>> Address your review comments. 
>> Thank you for accepting this. I don't have commit access please commit this.
>> Thanks.
>
> As discussed with Aaron on IRC I can commit it for you. To do that I need a 
> name and an email for the attribution.
> But first move the test to the already existing `test/Sema/void_arg.c` which 
> already test this diagnostic.

Ah, it's a C++ test. Then put it into `test/SemaCXX/`


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

https://reviews.llvm.org/D84678

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


[PATCH] D85026: [analyzer] Minor refactoring of SVal::getSubKind function

2020-07-31 Thread Balázs Benics via Phabricator via cfe-commits
steakhal accepted this revision.
steakhal added a comment.
This revision is now accepted and ready to land.

I like the change.
I also proved the equivalence, just for fun really :D

  from z3 import *
  
  def proof_equality(F, G):
s = Solver()
s.add(Not(F == G))
r = s.check()
if r == unsat:
  print("proved")
else:
  print("counterexample")
  print(s.model())
  
  
  Kind = BitVec('Kind', 32)
  BaseMask = BitVecVal(0b11, 32)
  BaseBits = BitVecVal(2, 32)
  
  Before = (Kind & ~BaseMask) >> BaseBits
  After = Kind >> BaseBits
  
  proof_equality(Before, After)
  # prints: proved 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85026

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


[PATCH] D84678: [clang] False line number in a function definition with "void" parameter

2020-07-31 Thread Jaydeep Chauhan via Phabricator via cfe-commits
Jac1494 updated this revision to Diff 282263.
Jac1494 added a comment.

Hi @riccibruno,
Address your review comment.Add please use
Name :- Jaydeep Chauhan
Mail id:- jaydeepchauhan1...@gmail.com
Thanks


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

https://reviews.llvm.org/D84678

Files:
  clang/lib/Sema/SemaType.cpp
  clang/test/SemaCXX/void-argument.cpp


Index: clang/test/SemaCXX/void-argument.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/void-argument.cpp
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+void fun(
+void a, // expected-error{{'void' must be the first and only parameter if 
specified}}
+double b,
+int c,
+void d, // expected-error{{'void' must be the first and only parameter if 
specified}}
+int e,
+void f) // expected-error{{'void' must be the first and only parameter if 
specified}}
+{}
+
+void foo(
+int a,
+void, // expected-error{{'void' must be the first and only parameter if 
specified}}
+int b);
+
+void bar(
+void, // expected-error{{'void' must be the first and only parameter if 
specified}}
+...);
+
+struct S {
+  S(
+  void,  // expected-error{{'void' must be the first and only parameter if 
specified}}
+  void); // expected-error{{'void' must be the first and only parameter if 
specified}}
+};
Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -5109,7 +5109,7 @@
 // is an incomplete type (C99 6.2.5p19) and function decls cannot
 // have parameters of incomplete type.
 if (FTI.NumParams != 1 || FTI.isVariadic) {
-  S.Diag(DeclType.Loc, diag::err_void_only_param);
+  S.Diag(FTI.Params[i].IdentLoc, diag::err_void_only_param);
   ParamTy = Context.IntTy;
   Param->setType(ParamTy);
 } else if (FTI.Params[i].Ident) {


Index: clang/test/SemaCXX/void-argument.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/void-argument.cpp
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+void fun(
+void a, // expected-error{{'void' must be the first and only parameter if specified}}
+double b,
+int c,
+void d, // expected-error{{'void' must be the first and only parameter if specified}}
+int e,
+void f) // expected-error{{'void' must be the first and only parameter if specified}}
+{}
+
+void foo(
+int a,
+void, // expected-error{{'void' must be the first and only parameter if specified}}
+int b);
+
+void bar(
+void, // expected-error{{'void' must be the first and only parameter if specified}}
+...);
+
+struct S {
+  S(
+  void,  // expected-error{{'void' must be the first and only parameter if specified}}
+  void); // expected-error{{'void' must be the first and only parameter if specified}}
+};
Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -5109,7 +5109,7 @@
 // is an incomplete type (C99 6.2.5p19) and function decls cannot
 // have parameters of incomplete type.
 if (FTI.NumParams != 1 || FTI.isVariadic) {
-  S.Diag(DeclType.Loc, diag::err_void_only_param);
+  S.Diag(FTI.Params[i].IdentLoc, diag::err_void_only_param);
   ParamTy = Context.IntTy;
   Param->setType(ParamTy);
 } else if (FTI.Params[i].Ident) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D81242: [StackSafety] Run ThinLTO

2020-07-31 Thread Teresa Johnson via Phabricator via cfe-commits
tejohnson added a comment.

In D81242#2183383 , @tejohnson wrote:

> I just noticed that generateParamAccessSummary is taking a bit over 5% of the 
> ThinLTO thin link step in an internal build (and will soon be more than 5% as 
> I found another analysis that is hogging compile time that I'm going to work 
> on fixing).

FYI with D84985  now committed, this goes up 
to >7% of the runtime.

> This is currently the second hottest analysis in the thin link. Is the stack 
> safety analysis meant to be always on with ThinLTO?
>
> I have a theory on what is causing it to incur so much overhead, see below.




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81242

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


[PATCH] D85034: [analyzer] Simplified functions SVal::getAsSymbolicExpression and similar ones

2020-07-31 Thread Balázs Benics via Phabricator via cfe-commits
steakhal resigned from this revision.
steakhal added a comment.
Herald added a subscriber: steakhal.

It would be great to simplify these. I have also wondered once why those 
different functions exist.
Does anyone know what was the original intention of these functions?
Since I'm not confident in this area, I resign.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85034

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


[clang] 18eba16 - [OpenMP][docs] Update loop tiling status.

2020-07-31 Thread Michael Kruse via cfe-commits

Author: Michael Kruse
Date: 2020-07-31T13:01:55-05:00
New Revision: 18eba165e7ba80328a910cad3407599d8ff60f4f

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

LOG: [OpenMP][docs] Update loop tiling status.

Added: 


Modified: 
clang/docs/OpenMPSupport.rst

Removed: 




diff  --git a/clang/docs/OpenMPSupport.rst b/clang/docs/OpenMPSupport.rst
index 28fbd7baebb2..af5e538b1435 100644
--- a/clang/docs/OpenMPSupport.rst
+++ b/clang/docs/OpenMPSupport.rst
@@ -266,7 +266,7 @@ want to help with the implementation.
 
+--+--+--+---+
 | misc extension   | default(firstprivate) & default(private)  
   | :part:`partial`  | firstprivate done: D75591   
  |
 
+--+--+--+---+
-| loop extension   | Loop tiling transformation
   | :part:`claimed`  | 
  |
+| loop extension   | Loop tiling transformation
   | :part:`worked on`| D76342  
  |
 
+--+--+--+---+
 | device extension | 'present' map type modifier   
   | :part:`mostly done`  | D83061, D83062, D84422  
  |
 
+--+--+--+---+



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


[libunwind] 46591b9 - [libunwind] Add -Wno-suggest-override to CMakeLists.txt.

2020-07-31 Thread via cfe-commits

Author: kristina
Date: 2020-07-31T19:04:13+01:00
New Revision: 46591b95362325d262ca29ce13e7b5ddda624bc8

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

LOG: [libunwind] Add -Wno-suggest-override to CMakeLists.txt.

Set -Wno-suggest-override where such warning is provided
by the compiler when building libunwind, alongside libcxx
and libcxxabi, using recent Clang. This extends behavior
introduced in 77e0e9e17daf0865620abcd41f692ab0642367c4
to libunwind, avoiding a large amount of warnings during
builds. See D84126 for the original patch.

Added: 


Modified: 
libunwind/CMakeLists.txt

Removed: 




diff  --git a/libunwind/CMakeLists.txt b/libunwind/CMakeLists.txt
index 4606360f07ab7..8419d851ab7f4 100644
--- a/libunwind/CMakeLists.txt
+++ b/libunwind/CMakeLists.txt
@@ -271,6 +271,8 @@ add_compile_flags_if_supported(-Wunused-variable)
 add_compile_flags_if_supported(-Wwrite-strings)
 add_compile_flags_if_supported(-Wundef)
 
+add_compile_flags_if_supported(-Wno-suggest-override)
+
 if (LIBUNWIND_ENABLE_WERROR)
   add_compile_flags_if_supported(-Werror)
   add_compile_flags_if_supported(-WX)



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


[PATCH] D85026: [analyzer] Minor refactoring of SVal::getSubKind function

2020-07-31 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko added a comment.

Hey, nice catch!
However, I'm going to complain about commit messages again 😅 I would prefer 
having imperative mood in the message, something like "Refactor ..." or 
"Introduce minor refactoring..."


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85026

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


[PATCH] D79279: Add overloaded versions of builtin mem* functions

2020-07-31 Thread JF Bastien via Phabricator via cfe-commits
jfb updated this revision to Diff 282281.
jfb marked 9 inline comments as done.
jfb added a comment.

Address Richard's comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79279

Files:
  clang/docs/LanguageExtensions.rst
  clang/include/clang/Basic/Builtins.def
  clang/include/clang/Basic/DiagnosticASTKinds.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/ExprConstant.cpp
  clang/lib/CodeGen/CGBuilder.h
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/CodeGen/CGExpr.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/test/CodeGen/builtin-overloaded-memfns.c
  clang/test/CodeGenObjC/builtin-memfns.m
  clang/test/Sema/builtin-overloaded-memfns.cpp
  clang/test/SemaCXX/constexpr-string.cpp

Index: clang/test/SemaCXX/constexpr-string.cpp
===
--- clang/test/SemaCXX/constexpr-string.cpp
+++ clang/test/SemaCXX/constexpr-string.cpp
@@ -675,4 +675,25 @@
 return true;
   }
   static_assert(test_address_of_incomplete_struct_type()); // expected-error {{constant}} expected-note {{in call}}
+
+  template 
+  constexpr auto test_memcpy_overloaded(int dst_off, int src_off, int num) {
+T dst[4] = {0, 0, 0, 0};
+const T src[4] = {1, 2, 3, 4};
+// expected-note@+2 {{size parameter is 12, expected a size that is evenly divisible by element size 8}}
+// expected-note@+1 {{size parameter is 4, expected a size that is evenly divisible by element size 8}}
+__builtin_memcpy_overloaded(dst + dst_off, src + src_off, num * sizeof(T), ElNum * sizeof(T));
+return result(dst);
+  }
+
+  static_assert(test_memcpy_overloaded(0, 0, 1) == 1000);
+  static_assert(test_memcpy_overloaded(0, 0, 2) == 1200);
+  static_assert(test_memcpy_overloaded(0, 0, 3) == 1230);
+  static_assert(test_memcpy_overloaded(0, 0, 4) == 1234);
+  static_assert(test_memcpy_overloaded(0, 0, 4) == 1234);
+
+  // expected-error@+1 {{static_assert expression is not an integral constant expression}}
+  static_assert(test_memcpy_overloaded(0, 0, 3) == 1234); // expected-note {{in call to 'test_memcpy_overloaded(0, 0, 3)'}}
+  // expected-error@+1 {{static_assert expression is not an integral constant expression}}
+  static_assert(test_memcpy_overloaded(0, 0, 1) == 1234); // expected-note {{in call to 'test_memcpy_overloaded(0, 0, 1)'}}
 }
Index: clang/test/Sema/builtin-overloaded-memfns.cpp
===
--- /dev/null
+++ clang/test/Sema/builtin-overloaded-memfns.cpp
@@ -0,0 +1,252 @@
+// RUN: %clang_cc1 %s -verify -fsyntax-only -triple=arm64-unknown-unknown -fms-extensions -DCPY=1
+// RUN: %clang_cc1 %s -verify -fsyntax-only -triple=arm64-unknown-unknown -fms-extensions -DCPY=0
+
+// Test memcpy and memmove with the same code, since they're basically the same constraints.
+#if CPY
+#define MEM(...) __builtin_memcpy_overloaded(__VA_ARGS__)
+#else
+#define MEM(...) __builtin_memmove_overloaded(__VA_ARGS__)
+#endif
+
+#define NULL (void *)0
+#define nullptr __nullptr
+using size_t = __SIZE_TYPE__;
+using sizeless_t = __SVInt8_t;
+using float4 = float __attribute__((ext_vector_type(4)));
+struct Intish {
+  int i;
+};
+struct NotLockFree {
+  char buf[512];
+};
+struct TrivialCpy {
+  char buf[8];
+  TrivialCpy();
+  TrivialCpy(const TrivialCpy &) = default;
+};
+struct NotTrivialCpy {
+  char buf[8];
+  NotTrivialCpy();
+  NotTrivialCpy(const NotTrivialCpy &);
+};
+
+constexpr int CONSTEXPR_ONE = 1;
+
+void arg_count() {
+  MEM();  // expected-error {{too few arguments to function call, expected 3, have 0}}
+  MEM(0); // expected-error {{too few arguments to function call, expected 3, have 1}}
+  MEM(0, 0);  // expected-error {{too few arguments to function call, expected 3, have 2}}
+  MEM(0, 0, 0, 0, 0); // expected-error {{too many arguments to function call, expected 4, have 5}}
+  __builtin_memset_overloaded();  // expected-error {{too few arguments to function call, expected 3, have 0}}
+  __builtin_memset_overloaded(0); // expected-error {{too few arguments to function call, expected 3, have 1}}
+  __builtin_memset_overloaded(0, 0);  // expected-error {{too few arguments to function call, expected 3, have 2}}
+  __builtin_memset_overloaded(0, 0, 0, 0, 0); // expected-error {{too many arguments to function call, expected 4, have 5}}
+}
+
+void null(char *dst, const char *src, size_t size) {
+  MEM(0, src, 0);  // expected-error{{cannot initialize a parameter of type 'void *' with an rvalue of type 'int'}}
+  MEM(0, src, size);   // expected-error{{cannot initialize a parameter of type 'void *' with an rvalue of type 'int'}}
+  MEM(dst, 0, 0);  // expect

[PATCH] D79279: Add overloaded versions of builtin mem* functions

2020-07-31 Thread JF Bastien via Phabricator via cfe-commits
jfb added a comment.

This is almost ready I think!
There are a few things still open, I'd love feedback on them.




Comment at: clang/docs/LanguageExtensions.rst:2435-2437
+* ``__builtin_memcpy_overloaded(QUAL void *dst, QUAL const void *src, size_t 
byte_size, size_t byte_element_size = )``
+* ``__builtin_memmove_overloaded(QUAL void *dst, QUAL const void *src, size_t 
byte_size, size_t byte_element_size = )``
+* ``__builtin_memset_overloaded(QUAL void *dst, unsigned char val, size_t 
byte_size, size_t byte_element_size = )``

rsmith wrote:
> rsmith wrote:
> > What happens if `byte_element_size` does not divide `byte_size`?
> Did you really mean `void*` here? I've been pretty confused by some of the 
> stuff happening below that seems to depend on the actual type of the passed 
> pointer, which would make more sense if you meant `QUAL T *` here rather than 
> `QUAL void*`. Do the builtins do different things for different argument 
> pointee types or not?
Runtime constraint violation. constexpr needs to catch this too, added. Though 
IIUC we can't actually check alignment in constexpr, which makes sense since 
there's no actual address.

Similarly, I think we ought to add UBSan builtin check for this. I think it 
makes sense to add as an option to `CreateElementUnorderedAtomicMemCpy`: either 
assert-check at compile-time (the current default, which triggers assertions as 
I've annotated in the tests' FIXME), or at runtime if the sanitizer is enabled. 
WDYT?

I've added these two to the documentation.



Comment at: clang/docs/LanguageExtensions.rst:2435-2437
+* ``__builtin_memcpy_overloaded(QUAL void *dst, QUAL const void *src, size_t 
byte_size, size_t byte_element_size = )``
+* ``__builtin_memmove_overloaded(QUAL void *dst, QUAL const void *src, size_t 
byte_size, size_t byte_element_size = )``
+* ``__builtin_memset_overloaded(QUAL void *dst, unsigned char val, size_t 
byte_size, size_t byte_element_size = )``

jfb wrote:
> rsmith wrote:
> > rsmith wrote:
> > > What happens if `byte_element_size` does not divide `byte_size`?
> > Did you really mean `void*` here? I've been pretty confused by some of the 
> > stuff happening below that seems to depend on the actual type of the passed 
> > pointer, which would make more sense if you meant `QUAL T *` here rather 
> > than `QUAL void*`. Do the builtins do different things for different 
> > argument pointee types or not?
> Runtime constraint violation. constexpr needs to catch this too, added. 
> Though IIUC we can't actually check alignment in constexpr, which makes sense 
> since there's no actual address.
> 
> Similarly, I think we ought to add UBSan builtin check for this. I think it 
> makes sense to add as an option to `CreateElementUnorderedAtomicMemCpy`: 
> either assert-check at compile-time (the current default, which triggers 
> assertions as I've annotated in the tests' FIXME), or at runtime if the 
> sanitizer is enabled. WDYT?
> 
> I've added these two to the documentation.
Oh yeah, this should be `T*` and `U*`. Fixed.

They used to key atomicity off of element size, but now that we have the extra 
parameter we only look at `T` and `U` for correctness (not behavior).



Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:8941-8943
+def err_atomic_builtin_ext_size_mismatches_el : Error<
+  "number of bytes to copy must be a multiple of pointer element size, "
+  "got %0 bytes to copy with element size %1 for %2">;

rsmith wrote:
> Presumably the number of bytes need not be a compile-time constant? It's a 
> bit weird to produce an error rather than a warning on a case that would be 
> valid but (perhaps?) UB if the argument were non-constant.
I commented below, indeed it seems like some of this ought to be relaxed.



Comment at: clang/lib/Sema/SemaChecking.cpp:5567
+  << (int)ElSz->getLimitedValue() << DstElSz << DstValTy
+  << DstOp->getSourceRange() << Arg->getSourceRange());
+

I'm re-thinking these checks:
```
if (ElSz->urem(DstElSz))
  return ExprError(
  Diag(TheCall->getBeginLoc(),
   PDiag(diag::err_atomic_builtin_ext_size_mismatches_el))
  << (int)ElSz->getLimitedValue() << DstElSz << DstValTy
  << DstOp->getSourceRange() << Arg->getSourceRange());
```
I'm not sure we ought to have them anymore. We know that the types are 
trivially copyable, it therefore doesn't really matter if you're copying with 
operations smaller than the type itself. For example:
```
struct Data {
  int a, b, c, d;
};
```
It ought to be fine to do 4-byte copies of `Data`, if whatever your algorithm 
is is happy with that. I therefore think I'll remove these checks based on the 
dst / src element types. The only thing that seems to make sense is making sure 
that you don't straddle object boundaries with element size.

I removed sizeless types: we'll codegen whatever 

[PATCH] D85039: [DO NOT SUBMIT][WIP] prototype

2020-07-31 Thread Zola Bridges via Phabricator via cfe-commits
zbrid created this revision.
Herald added subscribers: llvm-commits, Sanitizers, cfe-commits, hiraditya.
Herald added projects: clang, Sanitizers, LLVM.
zbrid requested review of this revision.

Not intended to be reviewed. I only uploaded this patch to have a
link to share.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D85039

Files:
  clang/lib/CodeGen/BackendUtil.cpp
  compiler-rt/lib/asan/asan_globals.cpp
  llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp
  load.c

Index: load.c
===
--- /dev/null
+++ load.c
@@ -0,0 +1,6 @@
+int load(int *p) { return *p; }
+
+int main() {
+  int i = 10;
+  load(&i);
+}
Index: llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp
===
--- llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp
+++ llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp
@@ -1058,6 +1058,12 @@
 getArgTLSPtr(), 0, Idx);
 }
 
+static void SetNoSanitizeMetadata(Instruction *I) {
+  I->setMetadata(
+  I->getParent()->getParent()->getParent()->getMDKindID("nosanitize"),
+  MDNode::get(I->getContext(), None));
+}
+
 Value *DFSanFunction::getShadow(Value *V) {
   if (!isa(V) && !isa(V))
 return DFS.ZeroShadow;
@@ -1073,8 +1079,10 @@
 DFS.ArgTLS ? &*F->getEntryBlock().begin()
: cast(ArgTLSPtr)->getNextNode();
 IRBuilder<> IRB(ArgTLSPos);
-Shadow =
+LoadInst *LI =
 IRB.CreateLoad(DFS.ShadowTy, getArgTLS(A->getArgNo(), ArgTLSPos));
+SetNoSanitizeMetadata(LI);
+Shadow = LI;
 break;
   }
   case DataFlowSanitizer::IA_Args: {
@@ -1105,9 +1113,11 @@
   assert(Addr != RetvalTLS && "Reinstrumenting?");
   IRBuilder<> IRB(Pos);
   Value *ShadowPtrMaskValue;
-  if (DFSanRuntimeShadowMask)
-ShadowPtrMaskValue = IRB.CreateLoad(IntptrTy, ExternalShadowMask);
-  else
+  if (DFSanRuntimeShadowMask) {
+LoadInst *LI = IRB.CreateLoad(IntptrTy, ExternalShadowMask);
+SetNoSanitizeMetadata(LI);
+ShadowPtrMaskValue = LI;
+  } else
 ShadowPtrMaskValue = ShadowPtrMask;
   return IRB.CreateIntToPtr(
   IRB.CreateMul(
@@ -1225,7 +1235,9 @@
 const auto i = AllocaShadowMap.find(AI);
 if (i != AllocaShadowMap.end()) {
   IRBuilder<> IRB(Pos);
-  return IRB.CreateLoad(DFS.ShadowTy, i->second);
+  LoadInst *LI = IRB.CreateLoad(DFS.ShadowTy, i->second);
+  SetNoSanitizeMetadata(LI);
+  return LI;
 }
   }
 
@@ -1366,7 +1378,8 @@
 const auto i = AllocaShadowMap.find(AI);
 if (i != AllocaShadowMap.end()) {
   IRBuilder<> IRB(Pos);
-  IRB.CreateStore(Shadow, i->second);
+  StoreInst *SI = IRB.CreateStore(Shadow, i->second);
+  SetNoSanitizeMetadata(SI);
   return;
 }
   }
@@ -1559,7 +1572,8 @@
 case DataFlowSanitizer::IA_TLS: {
   Value *S = DFSF.getShadow(RI.getReturnValue());
   IRBuilder<> IRB(&RI);
-  IRB.CreateStore(S, DFSF.getRetvalTLS());
+  StoreInst *SI = IRB.CreateStore(S, DFSF.getRetvalTLS());
+  SetNoSanitizeMetadata(SI);
   break;
 }
 case DataFlowSanitizer::IA_Args: {
@@ -1666,7 +1680,8 @@
 
   for (unsigned n = 0; i != CB.arg_end(); ++i, ++n) {
 auto LabelVAPtr = IRB.CreateStructGEP(LabelVATy, LabelVAAlloca, n);
-IRB.CreateStore(DFSF.getShadow(*i), LabelVAPtr);
+StoreInst *SI = IRB.CreateStore(DFSF.getShadow(*i), LabelVAPtr);
+SetNoSanitizeMetadata(SI);
   }
 
   Args.push_back(IRB.CreateStructGEP(LabelVATy, LabelVAAlloca, 0));
@@ -1702,6 +1717,7 @@
 if (!FT->getReturnType()->isVoidTy()) {
   LoadInst *LabelLoad =
   IRB.CreateLoad(DFSF.DFS.ShadowTy, DFSF.LabelReturnAlloca);
+  SetNoSanitizeMetadata(LabelLoad);
   DFSF.setShadow(CustomCI, LabelLoad);
 }
 
@@ -1716,8 +1732,9 @@
   FunctionType *FT = CB.getFunctionType();
   if (DFSF.DFS.getInstrumentedABI() == DataFlowSanitizer::IA_TLS) {
 for (unsigned i = 0, n = FT->getNumParams(); i != n; ++i) {
-  IRB.CreateStore(DFSF.getShadow(CB.getArgOperand(i)),
-  DFSF.getArgTLS(i, &CB));
+  StoreInst *SI = IRB.CreateStore(DFSF.getShadow(CB.getArgOperand(i)),
+  DFSF.getArgTLS(i, &CB));
+  SetNoSanitizeMetadata(SI);
 }
   }
 
@@ -1739,6 +1756,7 @@
 if (DFSF.DFS.getInstrumentedABI() == DataFlowSanitizer::IA_TLS) {
   IRBuilder<> NextIRB(Next);
   LoadInst *LI = NextIRB.CreateLoad(DFSF.DFS.ShadowTy, DFSF.getRetvalTLS());
+  SetNoSanitizeMetadata(LI);
   DFSF.SkipInsts.insert(LI);
   DFSF.setShadow(&CB, LI);
   DFSF.NonZeroChecks.push_back(LI);
@@ -1769,9 +1787,10 @@
"", &DFSF.F->getEntryBlock().front());
   Args.push_back(IRB.CreateConstGEP2_32(VarArgArrayTy, VarArgShadow, 0, 0));
   for (unsigne

[PATCH] D84316: [analyzer][NFC] Split CStringChecker to modeling and reporting

2020-07-31 Thread Balázs Benics via Phabricator via cfe-commits
steakhal added a comment.

In D84316#2187372 , @19n07u5 wrote:

> The title is a little bit confusing because only the C-string size model is 
> going to be separated and be accessible.

Could you elaborate on why is the title not precise?
It seems that the modeling logic and the reporting logic will be separated:

- modeling will be implemented in `CStringLengthModeling.cpp`
- reporting will be implemented in `CStringChecker.cpp` (just as like it was 
before)

I just wanted a short (at most 80 char long) title, if you offer any better I 
would be pleased.

---

> Other than that as @NoQ pointed out we need lot more of these 
> common-API-separation patches. It is a great starting point for the 
> `CStringChecker`.

Thanks. I'm thinking about making the checker cleaner - we will see.




Comment at: clang/lib/StaticAnalyzer/Checkers/CMakeLists.txt:146
+  CStringChecker
+  )

19n07u5 wrote:
> Other common checker functionality folders and headers do not require extra 
> CMake support long ago. I think when we need such support, we could define it 
> later, so that you could revert this.
It would be easier to use the `CStringLength.h` header without specifying the 
complete path to it.
IMO `#include "CStringChecker/CStringLength.h"` is kindof verbose compared to 
simply using `#include "CStringLength.h"`.
As of now, I'm sticking to this.



Comment at: clang/lib/StaticAnalyzer/Checkers/CStringChecker/CStringLength.h:43
+ ProgramStateRef &State, const Expr *Ex,
+ SVal Buf, bool Hypothetical = false);
+

19n07u5 wrote:
> steakhal wrote:
> > steakhal wrote:
> > > steakhal wrote:
> > > > balazske wrote:
> > > > > I do not like that the //get// and //set// (CStringLength) functions 
> > > > > are not symmetrical. I (and other developers) would think that the 
> > > > > get function returns a stored value and the set function sets it. The 
> > > > > `getCStringLength` is more a `computeCStringLength` and additionally 
> > > > > may manipulate the `State` too. In this form it is usable mostly only 
> > > > > for CStringChecker. (A separate function to get the value stored in 
> > > > > the length map should exist instead of this `Hypothetical` thing.)
> > > > > [...] get function returns a stored value and the set function sets 
> > > > > it.
> > > > Certainly a burden to understand. It would be more appealing, but more 
> > > > useful?
> > > > The user would have to check and create if necessary regardless. So 
> > > > fusing these two functions is more like a feature.
> > > > What use case do you think of using only the query function? In other 
> > > > words, how can you guarantee that you will find a length for a symbol?
> > > > 
> > > > > In this form it is usable mostly only for CStringChecker. (A separate 
> > > > > function to get the value stored in the length map should exist 
> > > > > instead of this Hypothetical thing.)
> > > > You are right. However, I want to focus on splitting parts without 
> > > > modifying the already existing API reducing the risk of breaking things.
> > > > You should expect such a change in an upcoming patch.
> > > On second thought, It probably worth having a cleaner API to a slight 
> > > inconvenience. If he feels like, still can wrap them.
> > > I will investigate it tomorrow.
> > I made a separate patch for cleansing this API.
> > In the D84979 now these API functions will behave as expected.
> > I (and other developers) would think that the get function returns a stored 
> > value and the set function sets it.
> Developers should not believe the getters are pure getters. As a 
> checker-writer point of view, you do not care whether the C-string already 
> exist or the checker creates it during symbolic execution, you only want to 
> get the C-string.
> 
> Think about all the Static Analyzer getters as factory functions, that is the 
> de facto standard now. For example, when you are trying to get a symbolic 
> value with `getSVal()`, for the first occurrence of an expression no `SVal` 
> exist, so it also creates it.
> 
> With that in mind, @steakhal, could you partially revert the renaming related 
> refactors of D84979, please?
> [...] As a checker-writer point of view, you do not care whether the C-string 
> already exist or the checker creates it during symbolic execution, you only 
> want to get the C-string.
I would have agreed with you - before I made the D84979 patch.
Now I believe if the interface can be implemented //purely// then it should be 
done so.

> Think about all the Static Analyzer getters as factory functions, that is the 
> de facto standard now.
We can always change them.

> For example, when you are trying to get a symbolic value with `getSVal()`, 
> for the first occurrence of an expression no `SVal` exist, so it also creates 
> it.
I'm not really familiar with the interna

[PATCH] D85033: [clang] Provide a better pretty-printed name for unnamed parameters, lambda classes and lambda captures.

2020-07-31 Thread Bruno Ricci via Phabricator via cfe-commits
riccibruno updated this revision to Diff 282296.
riccibruno added a comment.

Make the unit tests in `NamedDeclPrinterTest.cpp` more robust.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85033

Files:
  clang/lib/AST/Decl.cpp
  clang/test/AST/ast-dump-record-definition-data-json.cpp
  clang/test/Analysis/explain-svals.cpp
  clang/test/Index/annotate-tokens.cpp
  clang/test/Index/linkage.c
  clang/test/Index/load-decls.c
  clang/test/Index/load-namespaces.cpp
  clang/test/Index/preamble.c
  clang/test/Index/print-type.c
  clang/test/Index/print-type.cpp
  clang/test/Index/recursive-cxx-member-calls.cpp
  clang/test/Index/usrs.m
  clang/test/Modules/module-private.cpp
  clang/test/SemaCXX/lambda-expressions.cpp
  clang/test/SemaCXX/warn-large-by-value-copy.cpp
  clang/test/Tooling/clang-diff-ast.cpp
  clang/unittests/AST/ASTTraverserTest.cpp
  clang/unittests/AST/NamedDeclPrinterTest.cpp

Index: clang/unittests/AST/NamedDeclPrinterTest.cpp
===
--- clang/unittests/AST/NamedDeclPrinterTest.cpp
+++ clang/unittests/AST/NamedDeclPrinterTest.cpp
@@ -6,7 +6,8 @@
 //
 //===--===//
 //
-// This file contains tests for NamedDecl::printQualifiedName().
+// This file contains tests for NamedDecl::printName()
+// and NamedDecl::printQualifiedName().
 //
 // These tests have a coding convention:
 // * declaration to be printed is named 'A' unless it should have some special
@@ -93,11 +94,10 @@
   return ::testing::AssertionSuccess();
 }
 
-::testing::AssertionResult
-PrintedNamedDeclMatches(StringRef Code, const std::vector &Args,
-bool SuppressUnwrittenScope,
-const DeclarationMatcher &NodeMatch,
-StringRef ExpectedPrinted, StringRef FileName) {
+::testing::AssertionResult PrintedQualifiedNamedDeclMatches(
+StringRef Code, const std::vector &Args,
+bool SuppressUnwrittenScope, const DeclarationMatcher &NodeMatch,
+StringRef ExpectedPrinted, StringRef FileName) {
   return PrintedDeclMatches(Code, Args, NodeMatch, ExpectedPrinted, FileName,
 [=](llvm::raw_ostream &Out, const NamedDecl *ND) {
   auto Policy =
@@ -108,34 +108,43 @@
 });
 }
 
+::testing::AssertionResult PrintedUnqualifiedNamedDeclMatches(
+StringRef Code, const std::vector &Args,
+const DeclarationMatcher &NodeMatch, StringRef ExpectedPrinted,
+StringRef FileName) {
+  return PrintedDeclMatches(
+  Code, Args, NodeMatch, ExpectedPrinted, FileName,
+  [=](llvm::raw_ostream &Out, const NamedDecl *ND) { ND->printName(Out); });
+}
+
 ::testing::AssertionResult
-PrintedNamedDeclCXX98Matches(StringRef Code, StringRef DeclName,
- StringRef ExpectedPrinted) {
+PrintedQualifiedNamedDeclCXX98Matches(StringRef Code, StringRef DeclName,
+  StringRef ExpectedPrinted) {
   std::vector Args(1, "-std=c++98");
-  return PrintedNamedDeclMatches(Code, Args,
- /*SuppressUnwrittenScope*/ false,
- namedDecl(hasName(DeclName)).bind("id"),
- ExpectedPrinted, "input.cc");
+  return PrintedQualifiedNamedDeclMatches(
+  Code, Args,
+  /*SuppressUnwrittenScope*/ false, namedDecl(hasName(DeclName)).bind("id"),
+  ExpectedPrinted, "input.cc");
 }
 
 ::testing::AssertionResult
-PrintedWrittenNamedDeclCXX11Matches(StringRef Code, StringRef DeclName,
-StringRef ExpectedPrinted) {
+PrintedWrittenQualifiedNamedDeclCXX11Matches(StringRef Code, StringRef DeclName,
+ StringRef ExpectedPrinted) {
   std::vector Args(1, "-std=c++11");
-  return PrintedNamedDeclMatches(Code, Args,
- /*SuppressUnwrittenScope*/ true,
- namedDecl(hasName(DeclName)).bind("id"),
- ExpectedPrinted, "input.cc");
+  return PrintedQualifiedNamedDeclMatches(
+  Code, Args,
+  /*SuppressUnwrittenScope*/ true, namedDecl(hasName(DeclName)).bind("id"),
+  ExpectedPrinted, "input.cc");
 }
 
-::testing::AssertionResult
-PrintedWrittenPropertyDeclObjCMatches(StringRef Code, StringRef DeclName,
-   StringRef ExpectedPrinted) {
+::testing::AssertionResult PrintedWrittenQualifiedPropertyDeclObjCMatches(
+StringRef Code, StringRef DeclName, StringRef ExpectedPrinted) {
   std::vector Args{"-std=c++11", "-xobjective-c++"};
-  return PrintedNamedDeclMatches(Code, Args,
- /*SuppressUnwrittenScope*/ true,
- objcPropertyDecl(hasName(DeclName)).bind("id"),
- E

[PATCH] D84678: [clang] False line number in a function definition with "void" parameter

2020-07-31 Thread Bruno Ricci via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG38d3e7533279: [clang] Use the location of the void 
parameters when complaining that only a… (authored by Jac1494, committed by 
riccibruno).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84678

Files:
  clang/lib/Sema/SemaType.cpp
  clang/test/SemaCXX/void-argument.cpp


Index: clang/test/SemaCXX/void-argument.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/void-argument.cpp
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+void fun(
+void a, // expected-error{{'void' must be the first and only parameter if 
specified}}
+double b,
+int c,
+void d, // expected-error{{'void' must be the first and only parameter if 
specified}}
+int e,
+void f) // expected-error{{'void' must be the first and only parameter if 
specified}}
+{}
+
+void foo(
+int a,
+void, // expected-error{{'void' must be the first and only parameter if 
specified}}
+int b);
+
+void bar(
+void, // expected-error{{'void' must be the first and only parameter if 
specified}}
+...);
+
+struct S {
+  S(
+  void,  // expected-error{{'void' must be the first and only parameter if 
specified}}
+  void); // expected-error{{'void' must be the first and only parameter if 
specified}}
+};
Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -5114,7 +5114,7 @@
 // is an incomplete type (C99 6.2.5p19) and function decls cannot
 // have parameters of incomplete type.
 if (FTI.NumParams != 1 || FTI.isVariadic) {
-  S.Diag(DeclType.Loc, diag::err_void_only_param);
+  S.Diag(FTI.Params[i].IdentLoc, diag::err_void_only_param);
   ParamTy = Context.IntTy;
   Param->setType(ParamTy);
 } else if (FTI.Params[i].Ident) {


Index: clang/test/SemaCXX/void-argument.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/void-argument.cpp
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+void fun(
+void a, // expected-error{{'void' must be the first and only parameter if specified}}
+double b,
+int c,
+void d, // expected-error{{'void' must be the first and only parameter if specified}}
+int e,
+void f) // expected-error{{'void' must be the first and only parameter if specified}}
+{}
+
+void foo(
+int a,
+void, // expected-error{{'void' must be the first and only parameter if specified}}
+int b);
+
+void bar(
+void, // expected-error{{'void' must be the first and only parameter if specified}}
+...);
+
+struct S {
+  S(
+  void,  // expected-error{{'void' must be the first and only parameter if specified}}
+  void); // expected-error{{'void' must be the first and only parameter if specified}}
+};
Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -5114,7 +5114,7 @@
 // is an incomplete type (C99 6.2.5p19) and function decls cannot
 // have parameters of incomplete type.
 if (FTI.NumParams != 1 || FTI.isVariadic) {
-  S.Diag(DeclType.Loc, diag::err_void_only_param);
+  S.Diag(FTI.Params[i].IdentLoc, diag::err_void_only_param);
   ParamTy = Context.IntTy;
   Param->setType(ParamTy);
 } else if (FTI.Params[i].Ident) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 38d3e75 - [clang] Use the location of the void parameters when complaining that only a single void parameter should be present.

2020-07-31 Thread Bruno Ricci via cfe-commits

Author: Jaydeep Chauhan
Date: 2020-07-31T20:36:58+01:00
New Revision: 38d3e7533279fd4bfefcd88eac7d3b64f804c53a

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

LOG: [clang] Use the location of the void parameters when complaining that only 
a single void parameter should be present.

Fixes PR46417.

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

Reviewed By: aaron.ballman

Added: 
clang/test/SemaCXX/void-argument.cpp

Modified: 
clang/lib/Sema/SemaType.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp
index abf1d6450036..ff5223c0795e 100644
--- a/clang/lib/Sema/SemaType.cpp
+++ b/clang/lib/Sema/SemaType.cpp
@@ -5114,7 +5114,7 @@ static TypeSourceInfo 
*GetFullTypeForDeclarator(TypeProcessingState &state,
 // is an incomplete type (C99 6.2.5p19) and function decls cannot
 // have parameters of incomplete type.
 if (FTI.NumParams != 1 || FTI.isVariadic) {
-  S.Diag(DeclType.Loc, diag::err_void_only_param);
+  S.Diag(FTI.Params[i].IdentLoc, diag::err_void_only_param);
   ParamTy = Context.IntTy;
   Param->setType(ParamTy);
 } else if (FTI.Params[i].Ident) {

diff  --git a/clang/test/SemaCXX/void-argument.cpp 
b/clang/test/SemaCXX/void-argument.cpp
new file mode 100644
index ..8354347f5559
--- /dev/null
+++ b/clang/test/SemaCXX/void-argument.cpp
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+void fun(
+void a, // expected-error{{'void' must be the first and only parameter if 
specified}}
+double b,
+int c,
+void d, // expected-error{{'void' must be the first and only parameter if 
specified}}
+int e,
+void f) // expected-error{{'void' must be the first and only parameter if 
specified}}
+{}
+
+void foo(
+int a,
+void, // expected-error{{'void' must be the first and only parameter if 
specified}}
+int b);
+
+void bar(
+void, // expected-error{{'void' must be the first and only parameter if 
specified}}
+...);
+
+struct S {
+  S(
+  void,  // expected-error{{'void' must be the first and only parameter if 
specified}}
+  void); // expected-error{{'void' must be the first and only parameter if 
specified}}
+};



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


[PATCH] D80242: [Clang] implement -fno-eliminate-unused-debug-types

2020-07-31 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers updated this revision to Diff 282307.
nickdesaulniers marked 4 inline comments as done.
nickdesaulniers added a comment.

- rebase, add captures to tests, simplify NODBG-NOT cases


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80242

Files:
  clang/docs/ClangCommandLineReference.rst
  clang/docs/CommandGuide/clang.rst
  clang/docs/UsersManual.rst
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Basic/CodeGenOptions.h
  clang/include/clang/Basic/DebugInfoOptions.h
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/CodeGen/CGDebugInfo.h
  clang/lib/CodeGen/CGDecl.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGen/debug-info-unused-types.c
  clang/test/CodeGen/debug-info-unused-types.cpp
  clang/test/Driver/debug-options.c

Index: clang/test/Driver/debug-options.c
===
--- clang/test/Driver/debug-options.c
+++ clang/test/Driver/debug-options.c
@@ -361,3 +361,12 @@
 // GEMBED_2:  error: invalid argument '-gembed-source' only allowed with '-gdwarf-5'
 // NOGEMBED_5-NOT:  "-gembed-source"
 // NOGEMBED_2-NOT:  error: invalid argument '-gembed-source' only allowed with '-gdwarf-5'
+//
+// RUN: %clang -### -g -fno-eliminate-unused-debug-types -c %s 2>&1 \
+// RUN:| FileCheck -check-prefix=DEBUG_UNUSED_TYPES %s
+// DEBUG_UNUSED_TYPES: "-debug-info-kind=unused-types"
+// DEBUG_UNUSED_TYPES-NOT: "-debug-info-kind=limited"
+// RUN: %clang -### -g -feliminate-unused-debug-types -c %s 2>&1 \
+// RUN:| FileCheck -check-prefix=NO_DEBUG_UNUSED_TYPES %s
+// NO_DEBUG_UNUSED_TYPES: "-debug-info-kind=limited"
+// NO_DEBUG_UNUSED_TYPES-NOT: "-debug-info-kind=unused-types"
Index: clang/test/CodeGen/debug-info-unused-types.cpp
===
--- /dev/null
+++ clang/test/CodeGen/debug-info-unused-types.cpp
@@ -0,0 +1,31 @@
+// RUN: %clang++ -fno-eliminate-unused-debug-types -g -emit-llvm -S -o - %s | FileCheck %s
+// RUN: %clang++ -fno-eliminate-unused-debug-types -g1 -emit-llvm -S -o - %s | FileCheck --check-prefix=NODBG %s
+// RUN: %clang++ -feliminate-unused-debug-types -g -emit-llvm -S -o - %s | FileCheck --check-prefix=NODBG %s
+// RUN: %clang++ -g -emit-llvm -S -o - %s | FileCheck --check-prefix=NODBG %s
+// RUN: %clang++ -emit-llvm -S -o - %s | FileCheck --check-prefix=NODBG %s
+using foo = int;
+class bar {};
+enum class baz { BAZ };
+
+void quux() {
+  using x = int;
+  class y {};
+  enum class z { Z };
+}
+
+// CHECK: !DICompileUnit{{.+}}retainedTypes: [[RETTYPES:![0-9]+]]
+// CHECK: [[TYPE0:![0-9]+]] = !DICompositeType(tag: DW_TAG_enumeration_type, name: "baz"
+// CHECK: [[TYPE1:![0-9]+]] = !DIEnumerator(name: "BAZ"
+// CHECK: [[TYPE2:![0-9]+]] = !DICompositeType(tag: DW_TAG_enumeration_type, name: "z"
+// CHECK: [[TYPE3:![0-9]+]] = !DIEnumerator(name: "Z"
+// CHECK: [[RETTYPES]] = !{[[TYPE4:![0-9]+]], [[TYPE5:![0-9]+]], [[TYPE0]], !5, [[TYPE6:![0-9]+]], [[TYPE2]]}
+// CHECK: [[TYPE4]] = !DIDerivedType(tag: DW_TAG_typedef, name: "foo"
+// CHECK: [[TYPE5]] = distinct !DICompositeType(tag: DW_TAG_class_type, name: "bar"
+// CHECK: [[TYPE6]] = distinct !DICompositeType(tag: DW_TAG_class_type, name: "y"
+
+// NODBG-NOT: !DI{{CompositeType|Enumerator|DerivedType}}
+
+class unused_class;
+enum class unused_enum_class;
+
+// NODBG-NOT: name: "unused_
Index: clang/test/CodeGen/debug-info-unused-types.c
===
--- /dev/null
+++ clang/test/CodeGen/debug-info-unused-types.c
@@ -0,0 +1,50 @@
+// RUN: %clang -fno-eliminate-unused-debug-types -g -emit-llvm -S -o - %s | FileCheck %s
+// RUN: %clang -fno-eliminate-unused-debug-types -g1 -emit-llvm -S -o - %s | FileCheck --check-prefix=NODBG %s
+// RUN: %clang -feliminate-unused-debug-types -g -emit-llvm -S -o - %s | FileCheck --check-prefix=NODBG %s
+// RUN: %clang -g -emit-llvm -S -o - %s | FileCheck --check-prefix=NODBG %s
+// RUN: %clang -emit-llvm -S -o - %s | FileCheck --check-prefix=NODBG %s
+typedef int my_int;
+struct foo {};
+enum bar { BAR };
+union baz {};
+
+void quux(void) {
+  typedef int x;
+  struct y {};
+  enum z { Z };
+  union w {};
+}
+
+// Check that debug info is emitted for the typedef, struct, enum, and union
+// when -fno-eliminate-unused-debug-types and -g are set.
+
+// CHECK: !DICompileUnit{{.+}}retainedTypes: [[RETTYPES:![0-9]+]]
+// CHECK: [[TYPE0:![0-9]+]] = !DICompositeType(tag: DW_TAG_enumeration_type, name: "bar"
+// CHECK: [[TYPE1:![0-9]+]] = !DIEnumerator(name: "BAR"
+// CHECK: [[TYPE2:![0-9]+]] = !DICompositeType(tag: DW_TAG_enumeration_type, name: "z"
+// CHECK: [[TYPE3:![0-9]+]] = !DIEnumerator(name: "Z"
+// CHECK: [[RETTYPES]] = !{[[TYPE4:![0-9]+]], [[TYPE5:![0-9]+]], [[TYPE0]], [[TYPE6:![0-9]+]], !17, [[T

[PATCH] D80242: [Clang] implement -fno-eliminate-unused-debug-types

2020-07-31 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers marked an inline comment as not done.
nickdesaulniers added inline comments.



Comment at: clang/lib/Driver/ToolChains/Clang.cpp:3842-3846
+  if (EmitDwarf &&
+  Args.hasFlag(options::OPT_fno_eliminate_unused_debug_types,
+   options::OPT_feliminate_unused_debug_types, false) &&
+  DebugInfoKind >= codegenoptions::DebugInfoConstructor)
+DebugInfoKind = codegenoptions::UnusedTypeInfo;

dblaikie wrote:
> Would this be tidier if it were rolled into the if/checking around 380 since 
> it's a very similar option?
Sorry, I recently rebased, is 380 still where you were thinking...or...? (Maybe 
you can add some code context in case it moves again)?  Maybe 490 
(`DebugLevelToInfoKind`)?  Otherwise I don't really see other patterns that 
check `EmitDwarf`.



Comment at: clang/test/CodeGen/debug-info-unused-types.cpp:24-30
+// NODBG-NOT: !DICompositeType(tag: DW_TAG_enumeration_type, name: "baz"
+// NODBG-NOT: !DIEnumerator(name: "BAZ"
+// NODBG-NOT: !DICompositeType(tag: DW_TAG_enumeration_type, name: "z"
+// NODBG-NOT: !DIEnumerator(name: "Z"
+// NODBG-NOT: !DIDerivedType(tag: DW_TAG_typedef, name: "foo"
+// NODBG-NOT: !DICompositeType(tag: DW_TAG_class_type, name: "bar"
+// NODBG-NOT: !DICompositeType(tag: DW_TAG_class_type, name: "y"

dblaikie wrote:
> Maybe simpler to test the NODBG by `NODBG-NOT: DI{{[a-zA-Z]*}}Type` ? Not 
> sure if that'd quite work, but might be adequate.
`DISubroutineType` unfortunately would match. 
`!DI{{CompositeType|Enumerator|DerivedType}} ` does work though!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80242

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


[PATCH] D85033: [clang] Provide a better pretty-printed name for unnamed parameters, lambda classes and lambda captures.

2020-07-31 Thread Bruno Ricci via Phabricator via cfe-commits
riccibruno updated this revision to Diff 282312.
riccibruno added a comment.

Add `-fno-delayed-template-parsing` to the new unit tests to also pass on 
Windows.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85033

Files:
  clang/lib/AST/Decl.cpp
  clang/test/AST/ast-dump-record-definition-data-json.cpp
  clang/test/Analysis/explain-svals.cpp
  clang/test/Index/annotate-tokens.cpp
  clang/test/Index/linkage.c
  clang/test/Index/load-decls.c
  clang/test/Index/load-namespaces.cpp
  clang/test/Index/preamble.c
  clang/test/Index/print-type.c
  clang/test/Index/print-type.cpp
  clang/test/Index/recursive-cxx-member-calls.cpp
  clang/test/Index/usrs.m
  clang/test/Modules/module-private.cpp
  clang/test/SemaCXX/lambda-expressions.cpp
  clang/test/SemaCXX/warn-large-by-value-copy.cpp
  clang/test/Tooling/clang-diff-ast.cpp
  clang/unittests/AST/ASTTraverserTest.cpp
  clang/unittests/AST/NamedDeclPrinterTest.cpp

Index: clang/unittests/AST/NamedDeclPrinterTest.cpp
===
--- clang/unittests/AST/NamedDeclPrinterTest.cpp
+++ clang/unittests/AST/NamedDeclPrinterTest.cpp
@@ -6,7 +6,8 @@
 //
 //===--===//
 //
-// This file contains tests for NamedDecl::printQualifiedName().
+// This file contains tests for NamedDecl::printName()
+// and NamedDecl::printQualifiedName().
 //
 // These tests have a coding convention:
 // * declaration to be printed is named 'A' unless it should have some special
@@ -93,11 +94,10 @@
   return ::testing::AssertionSuccess();
 }
 
-::testing::AssertionResult
-PrintedNamedDeclMatches(StringRef Code, const std::vector &Args,
-bool SuppressUnwrittenScope,
-const DeclarationMatcher &NodeMatch,
-StringRef ExpectedPrinted, StringRef FileName) {
+::testing::AssertionResult PrintedQualifiedNamedDeclMatches(
+StringRef Code, const std::vector &Args,
+bool SuppressUnwrittenScope, const DeclarationMatcher &NodeMatch,
+StringRef ExpectedPrinted, StringRef FileName) {
   return PrintedDeclMatches(Code, Args, NodeMatch, ExpectedPrinted, FileName,
 [=](llvm::raw_ostream &Out, const NamedDecl *ND) {
   auto Policy =
@@ -108,34 +108,43 @@
 });
 }
 
+::testing::AssertionResult PrintedUnqualifiedNamedDeclMatches(
+StringRef Code, const std::vector &Args,
+const DeclarationMatcher &NodeMatch, StringRef ExpectedPrinted,
+StringRef FileName) {
+  return PrintedDeclMatches(
+  Code, Args, NodeMatch, ExpectedPrinted, FileName,
+  [=](llvm::raw_ostream &Out, const NamedDecl *ND) { ND->printName(Out); });
+}
+
 ::testing::AssertionResult
-PrintedNamedDeclCXX98Matches(StringRef Code, StringRef DeclName,
- StringRef ExpectedPrinted) {
+PrintedQualifiedNamedDeclCXX98Matches(StringRef Code, StringRef DeclName,
+  StringRef ExpectedPrinted) {
   std::vector Args(1, "-std=c++98");
-  return PrintedNamedDeclMatches(Code, Args,
- /*SuppressUnwrittenScope*/ false,
- namedDecl(hasName(DeclName)).bind("id"),
- ExpectedPrinted, "input.cc");
+  return PrintedQualifiedNamedDeclMatches(
+  Code, Args,
+  /*SuppressUnwrittenScope*/ false, namedDecl(hasName(DeclName)).bind("id"),
+  ExpectedPrinted, "input.cc");
 }
 
 ::testing::AssertionResult
-PrintedWrittenNamedDeclCXX11Matches(StringRef Code, StringRef DeclName,
-StringRef ExpectedPrinted) {
+PrintedWrittenQualifiedNamedDeclCXX11Matches(StringRef Code, StringRef DeclName,
+ StringRef ExpectedPrinted) {
   std::vector Args(1, "-std=c++11");
-  return PrintedNamedDeclMatches(Code, Args,
- /*SuppressUnwrittenScope*/ true,
- namedDecl(hasName(DeclName)).bind("id"),
- ExpectedPrinted, "input.cc");
+  return PrintedQualifiedNamedDeclMatches(
+  Code, Args,
+  /*SuppressUnwrittenScope*/ true, namedDecl(hasName(DeclName)).bind("id"),
+  ExpectedPrinted, "input.cc");
 }
 
-::testing::AssertionResult
-PrintedWrittenPropertyDeclObjCMatches(StringRef Code, StringRef DeclName,
-   StringRef ExpectedPrinted) {
+::testing::AssertionResult PrintedWrittenQualifiedPropertyDeclObjCMatches(
+StringRef Code, StringRef DeclName, StringRef ExpectedPrinted) {
   std::vector Args{"-std=c++11", "-xobjective-c++"};
-  return PrintedNamedDeclMatches(Code, Args,
- /*SuppressUnwrittenScope*/ true,
- objcPropertyDecl(hasName(DeclName)).bind("id"),
- 

[PATCH] D83242: [clang][BPF] support type exist/size and enum exist/value relocations

2020-07-31 Thread Yonghong Song via Phabricator via cfe-commits
yonghong-song updated this revision to Diff 282325.
yonghong-song edited the summary of this revision.
yonghong-song added a comment.

enum value relocation change: use ld_imm64 so we support 64bit enum value from 
day one. put enumerator name as the AccessString.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83242

Files:
  clang/include/clang/Basic/BuiltinsBPF.def
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/test/CodeGen/builtins-bpf-preserve-field-info-3.c
  clang/test/CodeGen/builtins-bpf-preserve-field-info-4.c
  clang/test/Sema/builtins-bpf.c
  llvm/include/llvm/IR/IntrinsicsBPF.td

Index: llvm/include/llvm/IR/IntrinsicsBPF.td
===
--- llvm/include/llvm/IR/IntrinsicsBPF.td
+++ llvm/include/llvm/IR/IntrinsicsBPF.td
@@ -26,4 +26,10 @@
   def int_bpf_btf_type_id : GCCBuiltin<"__builtin_bpf_btf_type_id">,
   Intrinsic<[llvm_i32_ty], [llvm_any_ty, llvm_any_ty, llvm_i64_ty],
   [IntrNoMem]>;
+  def int_bpf_preserve_type_info : GCCBuiltin<"__builtin_bpf_preserve_type_info">,
+  Intrinsic<[llvm_i32_ty], [llvm_i32_ty, llvm_i64_ty],
+  [IntrNoMem]>;
+  def int_bpf_preserve_enum_value : GCCBuiltin<"__builtin_bpf_preserve_enum_value">,
+  Intrinsic<[llvm_i64_ty], [llvm_i32_ty, llvm_ptr_ty, llvm_i64_ty],
+  [IntrNoMem]>;
 }
Index: clang/test/Sema/builtins-bpf.c
===
--- clang/test/Sema/builtins-bpf.c
+++ clang/test/Sema/builtins-bpf.c
@@ -1,7 +1,28 @@
 // RUN: %clang_cc1 -x c -triple bpf-pc-linux-gnu -dwarf-version=4 -fsyntax-only -verify %s
 
-struct s { int a; int b[4]; int c:1; };
-union u { int a; int b[4]; int c:1; };
+struct s {
+  int a;
+  int b[4];
+  int c:1;
+};
+union u {
+  int a;
+  int b[4];
+  int c:1;
+};
+typedef struct {
+  int a;
+  int b;
+} __t;
+typedef int (*__f)(void);
+enum AA {
+  VAL1 = 10,
+  VAL2 = 0x8000UL,
+};
+typedef enum {
+  VAL10 = 10,
+  VAL11 = 11,
+} __BB;
 
 unsigned invalid1(const int *arg) {
   return __builtin_preserve_field_info(arg, 1); // expected-error {{__builtin_preserve_field_info argument 1 not a field access}}
@@ -46,3 +67,38 @@
 unsigned invalid11(struct s *arg, int info_kind) {
   return __builtin_preserve_field_info(arg->a, info_kind); // expected-error {{__builtin_preserve_field_info argument 2 not a constant}}
 }
+
+unsigned valid12() {
+  const struct s t;
+  return __builtin_preserve_type_info(t, 0) +
+ __builtin_preserve_type_info(*(struct s *)0, 1);
+}
+
+unsigned valid13() {
+  __t t;
+  return __builtin_preserve_type_info(t, 1) +
+ __builtin_preserve_type_info(*(__t *)0, 0);
+}
+
+unsigned valid14() {
+  enum AA t;
+  return __builtin_preserve_type_info(t, 0) +
+ __builtin_preserve_type_info(*(enum AA *)0, 1);
+}
+
+unsigned valid15() {
+  return __builtin_preserve_enum_value(*(enum AA *)VAL1, 1) +
+ __builtin_preserve_enum_value(*(enum AA *)VAL2, 1);
+}
+
+unsigned invalid16() {
+  return __builtin_preserve_enum_value(*(enum AA *)0, 1); // expected-error {{__builtin_preserve_enum_value argument 1 invalid}}
+}
+
+unsigned invalid17() {
+  return __builtin_preserve_enum_value(*(enum AA *)VAL10, 1); // expected-error {{__builtin_preserve_enum_value argument 1 invalid}}
+}
+
+unsigned invalid18(struct s *arg) {
+  return __builtin_preserve_type_info(arg->a + 2, 0); // expected-error {{__builtin_preserve_type_info argument 1 invalid}}
+}
Index: clang/test/CodeGen/builtins-bpf-preserve-field-info-4.c
===
--- /dev/null
+++ clang/test/CodeGen/builtins-bpf-preserve-field-info-4.c
@@ -0,0 +1,32 @@
+// REQUIRES: bpf-registered-target
+// RUN: %clang -target bpf -emit-llvm -S -g %s -o - | FileCheck %s
+
+#define _(x, y) (__builtin_preserve_enum_value((x), (y)))
+
+enum AA {
+  VAL1 = 2,
+  VAL2 = 0x8000UL,
+};
+typedef enum { VAL10 = -2, VAL11 = 0x8000, }  __BB;
+
+unsigned unit1() {
+  return _(*(enum AA *)VAL1, 0) + _(*(__BB *)VAL10, 1);
+}
+
+unsigned unit2() {
+  return _(*(enum AA *)VAL2, 0) + _(*(__BB *)VAL11, 1);
+}
+
+// CHECK: @0 = private unnamed_addr constant [7 x i8] c"VAL1:2\00", align 1
+// CHECK: @1 = private unnamed_addr constant [9 x i8] c"VAL10:-2\00", align 1
+// CHECK: @2 = private unnamed_addr constant [17 x i8] c"VAL2:-2147483648\00", align 1
+// CHECK: @3 = private unnamed_addr constant [17 x i8] c"VAL11:4294934528\00", align 1
+
+// CHECK: call i64 @llvm.bpf.preserve.enum.value(i32 0, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @0, i32 0, i32 0), i64 0), !dbg !{{[0-9]+}}, !llvm.preserve.access.index ![[ENUM_AA:[0-9]+]]
+// CHECK: call i64 @llvm.bpf.preserve.enum.value(i32 1, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @1, i32 0, i32 0), i64 1), !db

[PATCH] D68997: Allow searching for prebuilt implicit modules.

2020-07-31 Thread Alexandre Rames via Phabricator via cfe-commits
arames updated this revision to Diff 282335.
arames marked an inline comment as done.
arames added a comment.

Addressed review comments.

- Fixed typos in the doc.
- Added doc about module compatibility.
- Cleaned and tested commands in the doc.
- Reworked module hash code to not require `-fmodules-cache-path` when using 
`-fprebuilt-implicit-modules`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68997

Files:
  clang/docs/Modules.rst
  clang/include/clang/Driver/Options.td
  clang/include/clang/Frontend/CompilerInstance.h
  clang/include/clang/Lex/HeaderSearch.h
  clang/include/clang/Lex/HeaderSearchOptions.h
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInstance.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Lex/HeaderSearch.cpp
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/test/Modules/Inputs/prebuilt-implicit-module/a.h
  clang/test/Modules/Inputs/prebuilt-implicit-module/module.modulemap
  clang/test/Modules/prebuilt-implicit-modules.m

Index: clang/test/Modules/prebuilt-implicit-modules.m
===
--- /dev/null
+++ clang/test/Modules/prebuilt-implicit-modules.m
@@ -0,0 +1,35 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -x objective-c -fmodules %S/Inputs/prebuilt-implicit-module/module.modulemap -emit-module -fmodule-name=module_a -fmodules-cache-path=%t
+// RUN: find %t -name "module_a*.pcm" | grep module_a
+
+// Check we use a prebuilt module when available, and do not build an implicit module.
+// RUN: rm -rf %t1
+// RUN: mkdir -p %t1
+// RUN: %clang_cc1 -x objective-c %s -I%S/Inputs/prebuilt-implicit-module -fmodules -fmodule-map-file=%S/Inputs/prebuilt-implicit-module/module.modulemap -fprebuilt-implicit-modules -fprebuilt-module-path=%t -fmodules-cache-path=%t1
+// RUN: find %t1 -name "module_a*.pcm" | not grep module_a
+
+// Check a module cache path is not required when all modules resolve to a
+// prebuilt implicit modules.
+// RUN: rm -rf %t1
+// RUN: mkdir -p %t1
+// RUN: %clang_cc1 -x objective-c %s -I%S/Inputs/prebuilt-implicit-module -fmodules -fmodule-map-file=%S/Inputs/prebuilt-implicit-module/module.modulemap -fprebuilt-implicit-modules -fprebuilt-module-path=%t
+
+// Check that we correctly fall back to implicit modules if the prebuilt implicit module is not found.
+// RUN: rm -rf %t1
+// RUN: mkdir -p %t1
+// RUN: %clang_cc1 -x objective-c %s -I%S/Inputs/prebuilt-implicit-module -fmodules -fmodule-map-file=%S/Inputs/prebuilt-implicit-module/module.modulemap -fprebuilt-implicit-modules -fprebuilt-module-path=%t -fmodules-cache-path=%t1 -fno-signed-char
+// RUN: find %t1 -name "module_a*.pcm" | grep module_a
+
+// Check that non-implicit prebuilt modules are always preferred to prebuilt implicit modules.
+// RUN: rm -rf %t2
+// RUN: mkdir -p %t2
+// RUN: %clang_cc1 -x objective-c -fmodules %S/Inputs/prebuilt-implicit-module/module.modulemap -emit-module -fmodule-name=module_a -fmodules-cache-path=%t
+// RUN: %clang_cc1 -x objective-c -fmodules %S/Inputs/prebuilt-implicit-module/module.modulemap -emit-module -fmodule-name=module_a -o %t/module_a.pcm -fno-signed-char
+// RUN: not %clang_cc1 -x objective-c %s -I%S/Inputs/prebuilt-implicit-module -fmodules -fmodule-map-file=%S/Inputs/prebuilt-implicit-module/module.modulemap -fprebuilt-implicit-modules -fprebuilt-module-path=%t -fmodules-cache-path=%t2
+// RUN: find %t2 -name "module_a*.pcm" | not grep module_a
+
+// expected-no-diagnostics
+@import module_a;
+int test() {
+  return a;
+}
Index: clang/test/Modules/Inputs/prebuilt-implicit-module/module.modulemap
===
--- /dev/null
+++ clang/test/Modules/Inputs/prebuilt-implicit-module/module.modulemap
@@ -0,0 +1 @@
+module module_a { header "a.h" }
Index: clang/test/Modules/Inputs/prebuilt-implicit-module/a.h
===
--- /dev/null
+++ clang/test/Modules/Inputs/prebuilt-implicit-module/a.h
@@ -0,0 +1 @@
+const int a = 1;
Index: clang/lib/Serialization/ASTWriter.cpp
===
--- clang/lib/Serialization/ASTWriter.cpp
+++ clang/lib/Serialization/ASTWriter.cpp
@@ -1319,6 +1319,7 @@
   Record.push_back(HSOpts.DisableModuleHash);
   Record.push_back(HSOpts.ImplicitModuleMaps);
   Record.push_back(HSOpts.ModuleMapFileHomeIsCwd);
+  Record.push_back(HSOpts.EnablePrebuiltImplicitModules);
   Record.push_back(HSOpts.UseBuiltinIncludes);
   Record.push_back(HSOpts.UseStandardSystemIncludes);
   Record.push_back(HSOpts.UseStandardCXXIncludes);
Index: clang/lib/Serialization/ASTReader.cpp
===
--- clang/lib/Serialization/ASTReader.cpp
+++ clang/lib/Serialization/ASTReader.cpp
@@ -5847,6 +5847,7 @@
   HSOpts.DisableModuleHash = Record[Idx++];
 

[PATCH] D68997: Allow searching for prebuilt implicit modules.

2020-07-31 Thread Alexandre Rames via Phabricator via cfe-commits
arames updated this revision to Diff 282336.
arames added a comment.

Fix a typo.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68997

Files:
  clang/docs/Modules.rst
  clang/include/clang/Driver/Options.td
  clang/include/clang/Frontend/CompilerInstance.h
  clang/include/clang/Lex/HeaderSearch.h
  clang/include/clang/Lex/HeaderSearchOptions.h
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInstance.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Lex/HeaderSearch.cpp
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/test/Modules/Inputs/prebuilt-implicit-module/a.h
  clang/test/Modules/Inputs/prebuilt-implicit-module/module.modulemap
  clang/test/Modules/prebuilt-implicit-modules.m

Index: clang/test/Modules/prebuilt-implicit-modules.m
===
--- /dev/null
+++ clang/test/Modules/prebuilt-implicit-modules.m
@@ -0,0 +1,35 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -x objective-c -fmodules %S/Inputs/prebuilt-implicit-module/module.modulemap -emit-module -fmodule-name=module_a -fmodules-cache-path=%t
+// RUN: find %t -name "module_a*.pcm" | grep module_a
+
+// Check we use a prebuilt module when available, and do not build an implicit module.
+// RUN: rm -rf %t1
+// RUN: mkdir -p %t1
+// RUN: %clang_cc1 -x objective-c %s -I%S/Inputs/prebuilt-implicit-module -fmodules -fmodule-map-file=%S/Inputs/prebuilt-implicit-module/module.modulemap -fprebuilt-implicit-modules -fprebuilt-module-path=%t -fmodules-cache-path=%t1
+// RUN: find %t1 -name "module_a*.pcm" | not grep module_a
+
+// Check a module cache path is not required when all modules resolve to
+// prebuilt implicit modules.
+// RUN: rm -rf %t1
+// RUN: mkdir -p %t1
+// RUN: %clang_cc1 -x objective-c %s -I%S/Inputs/prebuilt-implicit-module -fmodules -fmodule-map-file=%S/Inputs/prebuilt-implicit-module/module.modulemap -fprebuilt-implicit-modules -fprebuilt-module-path=%t
+
+// Check that we correctly fall back to implicit modules if the prebuilt implicit module is not found.
+// RUN: rm -rf %t1
+// RUN: mkdir -p %t1
+// RUN: %clang_cc1 -x objective-c %s -I%S/Inputs/prebuilt-implicit-module -fmodules -fmodule-map-file=%S/Inputs/prebuilt-implicit-module/module.modulemap -fprebuilt-implicit-modules -fprebuilt-module-path=%t -fmodules-cache-path=%t1 -fno-signed-char
+// RUN: find %t1 -name "module_a*.pcm" | grep module_a
+
+// Check that non-implicit prebuilt modules are always preferred to prebuilt implicit modules.
+// RUN: rm -rf %t2
+// RUN: mkdir -p %t2
+// RUN: %clang_cc1 -x objective-c -fmodules %S/Inputs/prebuilt-implicit-module/module.modulemap -emit-module -fmodule-name=module_a -fmodules-cache-path=%t
+// RUN: %clang_cc1 -x objective-c -fmodules %S/Inputs/prebuilt-implicit-module/module.modulemap -emit-module -fmodule-name=module_a -o %t/module_a.pcm -fno-signed-char
+// RUN: not %clang_cc1 -x objective-c %s -I%S/Inputs/prebuilt-implicit-module -fmodules -fmodule-map-file=%S/Inputs/prebuilt-implicit-module/module.modulemap -fprebuilt-implicit-modules -fprebuilt-module-path=%t -fmodules-cache-path=%t2
+// RUN: find %t2 -name "module_a*.pcm" | not grep module_a
+
+// expected-no-diagnostics
+@import module_a;
+int test() {
+  return a;
+}
Index: clang/test/Modules/Inputs/prebuilt-implicit-module/module.modulemap
===
--- /dev/null
+++ clang/test/Modules/Inputs/prebuilt-implicit-module/module.modulemap
@@ -0,0 +1 @@
+module module_a { header "a.h" }
Index: clang/test/Modules/Inputs/prebuilt-implicit-module/a.h
===
--- /dev/null
+++ clang/test/Modules/Inputs/prebuilt-implicit-module/a.h
@@ -0,0 +1 @@
+const int a = 1;
Index: clang/lib/Serialization/ASTWriter.cpp
===
--- clang/lib/Serialization/ASTWriter.cpp
+++ clang/lib/Serialization/ASTWriter.cpp
@@ -1319,6 +1319,7 @@
   Record.push_back(HSOpts.DisableModuleHash);
   Record.push_back(HSOpts.ImplicitModuleMaps);
   Record.push_back(HSOpts.ModuleMapFileHomeIsCwd);
+  Record.push_back(HSOpts.EnablePrebuiltImplicitModules);
   Record.push_back(HSOpts.UseBuiltinIncludes);
   Record.push_back(HSOpts.UseStandardSystemIncludes);
   Record.push_back(HSOpts.UseStandardCXXIncludes);
Index: clang/lib/Serialization/ASTReader.cpp
===
--- clang/lib/Serialization/ASTReader.cpp
+++ clang/lib/Serialization/ASTReader.cpp
@@ -5847,6 +5847,7 @@
   HSOpts.DisableModuleHash = Record[Idx++];
   HSOpts.ImplicitModuleMaps = Record[Idx++];
   HSOpts.ModuleMapFileHomeIsCwd = Record[Idx++];
+  HSOpts.EnablePrebuiltImplicitModules = Record[Idx++];
   HSOpts.UseBuiltinIncludes = Record[Idx++];
   HSOpts.UseStandardSystemIncludes = Record[Idx++];
   HSOpts.UseStandardCXXI

  1   2   >