[PATCH] D68845: Don't emit unwanted constructor calls in co_return statements

2019-10-10 Thread Arthur O'Dwyer via Phabricator via cfe-commits
Quuxplusone added a comment.

Oh, and can you please make sure there are test cases for all the various cases 
covered in P1155 
? 
Specifically, I would expect all three of the following test cases to compile 
successfully. It looks like they compile successfully in trunk right now 
(Godbolt ), so we're just testing that they 
don't get broken in the future.

  struct Widget { Widget(); Widget(const Widget&) = delete; Widget(Widget&&); };
  struct To { operator Widget() &&; };
  task nine() { To t; co_return t; }
  
  struct Fowl { Fowl(Widget); };
  task eleven() { Widget w; co_return w; }
  
  struct Base { Base(); Base(const Base&) = delete; Base(Base&&); };
  struct Derived : Base {};
  task thirteen() { Derived result; co_return result; }


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68845



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


[PATCH] D68845: Don't emit unwanted constructor calls in co_return statements

2019-10-10 Thread Arthur O'Dwyer via Phabricator via cfe-commits
Quuxplusone added inline comments.



Comment at: clang/lib/Sema/SemaCoroutine.cpp:869
   if (E) {
-auto NRVOCandidate = this->getCopyElisionCandidate(E->getType(), E, 
CES_AsIfByStdMove);
-if (NRVOCandidate) {
-  InitializedEntity Entity =
-  InitializedEntity::InitializeResult(Loc, E->getType(), 
NRVOCandidate);
-  ExprResult MoveResult = this->PerformMoveOrCopyInitialization(
-  Entity, NRVOCandidate, E->getType(), E);
-  if (MoveResult.get())
-E = MoveResult.get();
-}
+VarDecl *NRVOCandidate =
+getCopyElisionCandidate(E->getType(), E, CES_Default);

aaronpuchert wrote:
> Should be renamed to `RVOCandidate`, I don't think NRVO can happen here.
(Btw, I have no comment on the actual code change in this patch. I'm here in my 
capacity as 
[RVO-explainer](https://www.youtube.com/watch?v=hA1WNtNyNbo)-and-[P1155](http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p1155r2.html)-author,
 not code-understander. ;))

What's happening here is never technically "RVO" at all, because there is no 
"RV". However, the "N" is accurate. (See [my acronym 
glossary](https://quuxplusone.github.io/blog/2019/08/02/the-tough-guide-to-cpp-acronyms/#rvo-nrvo-urvo)
 for details.)
The important thing here is that when you say `co_return x;` the `x` is 
//named//, and it //would be// a candidate for NRVO if we were in a situation 
where NRVO was possible at all.

The actual optimization that is happening here is "implicit move."

I would strongly prefer to keep the name `NRVOCandidate` here, because that is 
the name that is used for the exact same purpose — computing "implicit move" 
candidates — in `BuildReturnStmt`. Ideally this code would be factored out so 
that it appeared in only one place; but until then, gratuitous differences 
between the two sites should be minimized IMO.



Comment at: clang/test/SemaCXX/coroutine-rvo.cpp:71
+task param2val(MoveOnly value) {
+  co_return value;
 }

This should work equally well with `NoCopyNoMove`, right? It should just call 
`task::return_value(NCNM&&)`. I don't think you need `MoveOnly` in this 
test file anymore.



Comment at: clang/test/SemaCXX/coroutine-rvo.cpp:74
 
-// expected-no-diagnostics
+task lvalue2val(Default& value) {
+  co_return value; // expected-error{{rvalue reference to type 'Default' 
cannot bind to lvalue of type 'Default'}}

Ditto here, could you use `NoCopyNoMove` instead of `Default`?



Comment at: clang/test/SemaCXX/coroutine-rvo.cpp:86
+
+task rvalue2ref(Default&& value) {
+  co_return value; // expected-error{{non-const lvalue reference to type 
'Default' cannot bind to a temporary of type 'Default'}}

And ditto here: `NoCopyNoMove` instead of `Default`?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68845



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


LLVM buildmaster will be restarted soon

2019-10-10 Thread Galina Kistanova via cfe-commits
 Hello everyone,

LLVM buildmaster will be updated and restarted in few minutes.

Thanks

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


[PATCH] D66046: Add new tautological compare warning for bitwise-or with a non-zero constant

2019-10-10 Thread Richard Trieu via Phabricator via cfe-commits
rtrieu added a comment.

In D66046#1696785 , @xbolva00 wrote:

> Could this patch solve https://bugs.llvm.org/show_bug.cgi?id=43573?


No, but I left some notes on the bug on why negative values are hard and where 
to fix it.


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

https://reviews.llvm.org/D66046



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


[PATCH] D68825: [libTooling] Change Stencil equality to use `toString()`

2019-10-10 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel updated this revision to Diff 224536.
ymandel added a comment.

removed `operator==` and updated tests accordingly.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68825

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

Index: clang/unittests/Tooling/StencilTest.cpp
===
--- clang/unittests/Tooling/StencilTest.cpp
+++ clang/unittests/Tooling/StencilTest.cpp
@@ -357,39 +357,6 @@
   testExpr(Id, "3;", cat(run(SimpleFn)), "Bound");
 }
 
-TEST(StencilEqualityTest, Equality) {
-  auto Lhs = cat("foo", dPrint("dprint_id"));
-  auto Rhs = cat("foo", dPrint("dprint_id"));
-  EXPECT_EQ(Lhs, Rhs);
-}
-
-TEST(StencilEqualityTest, InEqualityDifferentOrdering) {
-  auto Lhs = cat("foo", dPrint("node"));
-  auto Rhs = cat(dPrint("node"), "foo");
-  EXPECT_NE(Lhs, Rhs);
-}
-
-TEST(StencilEqualityTest, InEqualityDifferentSizes) {
-  auto Lhs = cat("foo", dPrint("node"), "bar", "baz");
-  auto Rhs = cat("foo", dPrint("node"), "bar");
-  EXPECT_NE(Lhs, Rhs);
-}
-
-// node is opaque and therefore cannot be examined for equality.
-TEST(StencilEqualityTest, InEqualitySelection) {
-  auto S1 = cat(node("node"));
-  auto S2 = cat(node("node"));
-  EXPECT_NE(S1, S2);
-}
-
-// `run` is opaque.
-TEST(StencilEqualityTest, InEqualityRun) {
-  auto F = [](const MatchResult ) { return "foo"; };
-  auto S1 = cat(run(F));
-  auto S2 = cat(run(F));
-  EXPECT_NE(S1, S2);
-}
-
 TEST(StencilToStringTest, RawTextOp) {
   auto S = cat("foo bar baz");
   StringRef Expected = R"("foo bar baz")";
@@ -426,6 +393,11 @@
   EXPECT_EQ(S.toString(), Expected);
 }
 
+TEST(StencilToStringTest, SelectionOp) {
+  auto S1 = cat(node("node1"));
+  EXPECT_EQ(S1.toString(), "selection(...)");
+}
+
 TEST(StencilToStringTest, AccessOp) {
   auto S = cat(access("Id", text("memberData")));
   StringRef Expected = R"repr(access("Id", "memberData"))repr";
@@ -445,6 +417,12 @@
   EXPECT_EQ(S.toString(), Expected);
 }
 
+TEST(StencilToStringTest, RunOp) {
+  auto F1 = [](const MatchResult ) { return "foo"; };
+  auto S1 = cat(run(F1));
+  EXPECT_EQ(S1.toString(), "run(...)");
+}
+
 TEST(StencilToStringTest, MultipleOp) {
   auto S = cat("foo", access("x", "m()"), "bar",
ifBound("x", text("t"), access("e", "f")));
Index: clang/lib/Tooling/Transformer/Stencil.cpp
===
--- clang/lib/Tooling/Transformer/Stencil.cpp
+++ clang/lib/Tooling/Transformer/Stencil.cpp
@@ -31,14 +31,6 @@
 using llvm::Expected;
 using llvm::StringError;
 
-// A down_cast function to safely down cast a StencilPartInterface to a subclass
-// D. Returns nullptr if P is not an instance of D.
-template  const D *down_cast(const StencilPartInterface *P) {
-  if (P == nullptr || D::typeId() != P->typeId())
-return nullptr;
-  return static_cast(P);
-}
-
 static llvm::Expected
 getNode(const ast_matchers::BoundNodes , StringRef Id) {
   auto  = Nodes.getMap();
@@ -100,35 +92,6 @@
   StencilPart FalsePart;
 };
 
-bool isEqualData(const RawTextData , const RawTextData ) {
-  return A.Text == B.Text;
-}
-
-bool isEqualData(const DebugPrintNodeData , const DebugPrintNodeData ) {
-  return A.Id == B.Id;
-}
-
-bool isEqualData(const UnaryOperationData , const UnaryOperationData ) {
-  return A.Op == B.Op && A.Id == B.Id;
-}
-
-// Equality is not (yet) defined for \c RangeSelector.
-bool isEqualData(const SelectorData &, const SelectorData &) { return false; }
-
-bool isEqualData(const AccessData , const AccessData ) {
-  return A.BaseId == B.BaseId && A.Member == B.Member;
-}
-
-bool isEqualData(const IfBoundData , const IfBoundData ) {
-  return A.Id == B.Id && A.TruePart == B.TruePart && A.FalsePart == B.FalsePart;
-}
-
-// Equality is not defined over MatchConsumers, which are opaque.
-bool isEqualData(const MatchConsumer ,
- const MatchConsumer ) {
-  return false;
-}
-
 std::string toStringData(const RawTextData ) {
   std::string Result;
   llvm::raw_string_ostream OS(Result);
@@ -159,7 +122,7 @@
   return (OpName + "(\"" + Data.Id + "\")").str();
 }
 
-std::string toStringData(const SelectorData &) { return "SelectorData()"; }
+std::string toStringData(const SelectorData &) { return "selection(...)"; }
 
 std::string toStringData(const AccessData ) {
   return (llvm::Twine("access(\"") + Data.BaseId + "\", " +
@@ -174,7 +137,7 @@
 }
 
 std::string toStringData(const MatchConsumer &) {
-  return "MatchConsumer()";
+  return "run(...)";
 }
 
 // The `evalData()` overloads evaluate the given stencil data to a string, given
@@ -275,28 +238,13 @@
 
 public:
   template 
-  explicit StencilPartImpl(Ps &&... Args)
-  : StencilPartInterface(StencilPartImpl::typeId()),
-Data(std::forward(Args)...) {}
-
-  // Generates a unique identifier for this class 

[PATCH] D68753: [CUDA][HIP} Add a test for constexpr default ctor

2019-10-10 Thread Yaxun Liu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc1f8e04eeefe: [CUDA][HIP} Add a test for constexpr default 
ctor (authored by yaxunl).
Herald added a project: clang.

Changed prior to commit:
  https://reviews.llvm.org/D68753?vs=224492=224529#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68753

Files:
  clang/test/SemaCUDA/constexpr-ctor.cu


Index: clang/test/SemaCUDA/constexpr-ctor.cu
===
--- /dev/null
+++ clang/test/SemaCUDA/constexpr-ctor.cu
@@ -0,0 +1,33 @@
+// RUN: %clang_cc1 -std=c++11 -triple nvptx64-nvidia-cuda -fsyntax-only \
+// RUN:-fcuda-is-device -verify=dev %s
+// RUN: %clang_cc1 -std=c++11 -triple x86_64-unknown-linux-gnu -fsyntax-only \
+// RUN:-verify=host %s
+
+// host-no-diagnostics
+
+#include "Inputs/cuda.h"
+
+struct A {
+  A(); // dev-note 2{{'A' declared here}}
+};
+
+template  struct B {
+  T a;
+  constexpr B() = default; // dev-error 2{{reference to __host__ function 'A' 
in __host__ __device__ function}}
+};
+
+__host__ void f() { B x; }
+__device__ void f() { B x; } // dev-note{{called by 'f'}}
+
+struct foo {
+  __host__ foo() { B x; }
+  __device__ foo() { B x; } // dev-note{{called by 'foo'}}
+};
+
+__host__ void g() { foo x; }
+__device__ void g() { foo x; } // dev-note{{called by 'g'}}
+
+struct bar {
+  __host__ bar() { B x; }
+  __device__ bar() { B x; } // no error since no instantiation of bar
+};


Index: clang/test/SemaCUDA/constexpr-ctor.cu
===
--- /dev/null
+++ clang/test/SemaCUDA/constexpr-ctor.cu
@@ -0,0 +1,33 @@
+// RUN: %clang_cc1 -std=c++11 -triple nvptx64-nvidia-cuda -fsyntax-only \
+// RUN:-fcuda-is-device -verify=dev %s
+// RUN: %clang_cc1 -std=c++11 -triple x86_64-unknown-linux-gnu -fsyntax-only \
+// RUN:-verify=host %s
+
+// host-no-diagnostics
+
+#include "Inputs/cuda.h"
+
+struct A {
+  A(); // dev-note 2{{'A' declared here}}
+};
+
+template  struct B {
+  T a;
+  constexpr B() = default; // dev-error 2{{reference to __host__ function 'A' in __host__ __device__ function}}
+};
+
+__host__ void f() { B x; }
+__device__ void f() { B x; } // dev-note{{called by 'f'}}
+
+struct foo {
+  __host__ foo() { B x; }
+  __device__ foo() { B x; } // dev-note{{called by 'foo'}}
+};
+
+__host__ void g() { foo x; }
+__device__ void g() { foo x; } // dev-note{{called by 'g'}}
+
+struct bar {
+  __host__ bar() { B x; }
+  __device__ bar() { B x; } // no error since no instantiation of bar
+};
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D68832: [tsan,msan] Insert module constructors in a module pass

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

Reverted in r374503.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68832



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


r374503 - Revert 374481 "[tsan, msan] Insert module constructors in a module pass"

2019-10-10 Thread Nico Weber via cfe-commits
Author: nico
Date: Thu Oct 10 19:44:20 2019
New Revision: 374503

URL: http://llvm.org/viewvc/llvm-project?rev=374503=rev
Log:
Revert 374481 "[tsan,msan] Insert module constructors in a module pass"

CodeGen/sanitizer-module-constructor.c fails on mac and windows, see e.g.
http://lab.llvm.org:8011/builders/clang-x64-windows-msvc/builds/11424

Removed:
cfe/trunk/test/CodeGen/sanitizer-module-constructor.c
Modified:
cfe/trunk/lib/CodeGen/BackendUtil.cpp

Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=374503=374502=374503=diff
==
--- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original)
+++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Thu Oct 10 19:44:20 2019
@@ -974,7 +974,6 @@ static void addSanitizersAtO0(ModulePass
   }
 
   if (LangOpts.Sanitize.has(SanitizerKind::Memory)) {
-MPM.addPass(MemorySanitizerPass({}));
 MPM.addPass(createModuleToFunctionPassAdaptor(MemorySanitizerPass({})));
   }
 
@@ -984,7 +983,6 @@ static void addSanitizersAtO0(ModulePass
   }
 
   if (LangOpts.Sanitize.has(SanitizerKind::Thread)) {
-MPM.addPass(ThreadSanitizerPass());
 MPM.addPass(createModuleToFunctionPassAdaptor(ThreadSanitizerPass()));
   }
 }
@@ -1164,23 +1162,16 @@ void EmitAssemblyHelper::EmitAssemblyWit
 [](FunctionPassManager , PassBuilder::OptimizationLevel Level) 
{
   FPM.addPass(BoundsCheckingPass());
 });
-  if (LangOpts.Sanitize.has(SanitizerKind::Memory)) {
-PB.registerPipelineStartEPCallback([](ModulePassManager ) {
-  MPM.addPass(MemorySanitizerPass({}));
-});
+  if (LangOpts.Sanitize.has(SanitizerKind::Memory))
 PB.registerOptimizerLastEPCallback(
 [](FunctionPassManager , PassBuilder::OptimizationLevel Level) 
{
   FPM.addPass(MemorySanitizerPass({}));
 });
-  }
-  if (LangOpts.Sanitize.has(SanitizerKind::Thread)) {
-PB.registerPipelineStartEPCallback(
-[](ModulePassManager ) { MPM.addPass(ThreadSanitizerPass()); 
});
+  if (LangOpts.Sanitize.has(SanitizerKind::Thread))
 PB.registerOptimizerLastEPCallback(
 [](FunctionPassManager , PassBuilder::OptimizationLevel Level) 
{
   FPM.addPass(ThreadSanitizerPass());
 });
-  }
   if (LangOpts.Sanitize.has(SanitizerKind::Address)) {
 PB.registerPipelineStartEPCallback([&](ModulePassManager ) {
   MPM.addPass(

Removed: cfe/trunk/test/CodeGen/sanitizer-module-constructor.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/sanitizer-module-constructor.c?rev=374502=auto
==
--- cfe/trunk/test/CodeGen/sanitizer-module-constructor.c (original)
+++ cfe/trunk/test/CodeGen/sanitizer-module-constructor.c (removed)
@@ -1,22 +0,0 @@
-// RUN: %clang_cc1 -fsanitize=address -emit-llvm -O3 -fdebug-pass-manager 
-fexperimental-new-pass-manager -o - %s 2>&1 | FileCheck %s
-// RUN: %clang_cc1 -fsanitize=thread -emit-llvm -O3 -fdebug-pass-manager 
-fexperimental-new-pass-manager -o - %s 2>&1 | FileCheck %s
-// RUN: %clang_cc1 -fsanitize=memory -emit-llvm -O3 -fdebug-pass-manager 
-fexperimental-new-pass-manager -o - %s 2>&1 | FileCheck %s
-
-// This is regression test for PR42877
-
-typedef struct a *b;
-struct a {
-  int c;
-};
-int d;
-b e;
-static void f(b g) {
-  for (d = g->c;;)
-;
-}
-void h() { f(e); }
-
-// CHECK: Running pass: {{.*}}SanitizerPass on 
{{.*}}sanitizer-module-constructor.c
-// CHECK-NOT: Running pass: LoopSimplifyPass on {{.*}}san.module_ctor
-// CHECK: Running analysis: DominatorTreeAnalysis on {{.*}}san.module_ctor
-// CHECK: Running pass: LoopSimplifyPass on {{.*}}san.module_ctor


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


r374502 - [CUDA][HIP} Add a test for constexpr default ctor

2019-10-10 Thread Yaxun Liu via cfe-commits
Author: yaxunl
Date: Thu Oct 10 19:43:28 2019
New Revision: 374502

URL: http://llvm.org/viewvc/llvm-project?rev=374502=rev
Log:
[CUDA][HIP} Add a test for constexpr default ctor

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

Added:
cfe/trunk/test/SemaCUDA/constexpr-ctor.cu

Added: cfe/trunk/test/SemaCUDA/constexpr-ctor.cu
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCUDA/constexpr-ctor.cu?rev=374502=auto
==
--- cfe/trunk/test/SemaCUDA/constexpr-ctor.cu (added)
+++ cfe/trunk/test/SemaCUDA/constexpr-ctor.cu Thu Oct 10 19:43:28 2019
@@ -0,0 +1,33 @@
+// RUN: %clang_cc1 -std=c++11 -triple nvptx64-nvidia-cuda -fsyntax-only \
+// RUN:-fcuda-is-device -verify=dev %s
+// RUN: %clang_cc1 -std=c++11 -triple x86_64-unknown-linux-gnu -fsyntax-only \
+// RUN:-verify=host %s
+
+// host-no-diagnostics
+
+#include "Inputs/cuda.h"
+
+struct A {
+  A(); // dev-note 2{{'A' declared here}}
+};
+
+template  struct B {
+  T a;
+  constexpr B() = default; // dev-error 2{{reference to __host__ function 'A' 
in __host__ __device__ function}}
+};
+
+__host__ void f() { B x; }
+__device__ void f() { B x; } // dev-note{{called by 'f'}}
+
+struct foo {
+  __host__ foo() { B x; }
+  __device__ foo() { B x; } // dev-note{{called by 'foo'}}
+};
+
+__host__ void g() { foo x; }
+__device__ void g() { foo x; } // dev-note{{called by 'g'}}
+
+struct bar {
+  __host__ bar() { B x; }
+  __device__ bar() { B x; } // no error since no instantiation of bar
+};


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


[PATCH] D68835: [clang-scan-deps] Add basic support for Clang modules.

2019-10-10 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith added inline comments.



Comment at: lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp:135
+  return llvm::StringSwitch(Ext)
+.CasesLower(".c", ".cc", ".cpp", ".c++", ".cxx", true)
+.CasesLower(".h", ".hh", ".hpp", ".h++", ".hxx", true)

arphaman wrote:
> Let me do some experiments to find files in our codebase that have some weird 
> extensions we should minimize as well, to check what else could be there.
I think we should get the standard preprocessed source extensions for 
completeness, even though it would be rare for someone to send those in. IIRC, 
`.i`, `.ii`, `.mi`, and `.mmi` (not sure about that last one).


Repository:
  rC Clang

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

https://reviews.llvm.org/D68835



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


Re: r374484 - Move most CXXRecordDecl::DefinitionData bit-fields out into a separate

2019-10-10 Thread Adrian Prantl via cfe-commits
Hi Richard,

it's possible that this broke the module build

http://lab.llvm.org:8080/green/view/LLDB/job/lldb-cmake/2482/consoleFull#-432653710a1ca8a51-895e-46c6-af87-ce24fa4cd561
 


/Users/buildslave/jenkins/workspace/lldb-cmake/host-compiler/bin/clang++  
-DGTEST_HAS_RTTI=0 -D_DEBUG -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS 
-D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -Itools/clang/lib/Parse 
-I/Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/clang/lib/Parse 
-I/Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/clang/include 
-Itools/clang/include 
-I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include/libxml2
 -Iinclude 
-I/Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/llvm/include 
-Wdocumentation -fPIC -fvisibility-inlines-hidden -Werror=date-time 
-Werror=unguarded-availability-new -std=c++14 -fmodules 
-fmodules-cache-path=/Users/buildslave/jenkins/workspace/lldb-cmake/lldb-build/module.cache
 -fcxx-modules -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual 
-Wmissing-field-initializers -pedantic -Wno-long-long -Wimplicit-fallthrough 
-Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor 
-Wdelete-non-virtual-dtor -Wstring-conversion -fdiagnostics-color -fno-common 
-Woverloaded-virtual -Wno-nested-anon-types -O3  -isysroot 
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk
   -UNDEBUG  -fno-exceptions -fno-rtti -MD -MT 
tools/clang/lib/Parse/CMakeFiles/obj.clangParse.dir/ParseAST.cpp.o -MF 
tools/clang/lib/Parse/CMakeFiles/obj.clangParse.dir/ParseAST.cpp.o.d -o 
tools/clang/lib/Parse/CMakeFiles/obj.clangParse.dir/ParseAST.cpp.o -c 
/Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/clang/lib/Parse/ParseAST.cpp
While building module 'Clang_Parse' imported from 
/Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/clang/lib/Parse/ParseAST.cpp:13:
While building module 'Clang_AST' imported from 
/Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/clang/include/clang/Parse/Parser.h:16:
In file included from :1:
In file included from 
/Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/clang/include/clang/AST/ASTNodeTraverser.h:20:
In file included from 
/Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/clang/include/clang/AST/DeclVisitor.h:18:
 
<>/Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/clang/include/clang/AST/DeclCXX.h:282:5:
 fatal error: import of module 'Clang_AST.CXXRecordDeclDefinitionBits' appears 
within 'clang::CXXRecordDecl::DefinitionData'
#include "CXXRecordDeclDefinitionBits.def"
^
/Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/clang/include/clang/AST/DeclCXX.h:279:3:
 note: 'clang::CXXRecordDecl::DefinitionData' begins here
  struct DefinitionData {
  ^
While building module 'Clang_Parse' imported from 
/Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/clang/lib/Parse/ParseAST.cpp:13:
In file included from :1:
In file included from 
/Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/clang/include/clang/Parse/RAIIObjectsForParser.h:18:
/Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/clang/include/clang/Parse/Parser.h:16:10:
 fatal error: could not build module 'Clang_AST'
#include "clang/AST/OpenMPClause.h"
 ^~
While building module 'Clang_Parse' imported from 
/Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/clang/lib/Parse/ParseAST.cpp:13:
While building module 'Clang_Sema' imported from 
/Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/clang/include/clang/Parse/Parser.h:24:
In file included from :1:
In file included from 
/Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/clang/include/clang/Sema/MultiplexExternalSemaSource.h:15:
/Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/clang/include/clang/Sema/ExternalSemaSource.h:15:10:
 fatal error: could not build module 'Clang_AST'
#include "clang/AST/ExternalASTSource.h"
 ^~~
/Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/clang/lib/Parse/ParseAST.cpp:13:10:
 fatal error: could not build module 'Clang_Parse'
#include "clang/Parse/ParseAST.h"
 ^~~~
4 errors generated.

> On Oct 10, 2019, at 5:29 PM, Richard Smith via cfe-commits 
>  wrote:
> 
> Author: rsmith
> Date: Thu Oct 10 17:29:04 2019
> New Revision: 374484
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=374484=rev
> Log:
> Move most CXXRecordDecl::DefinitionData bit-fields out into a separate
> file.
> 
> Reduces duplication and thereby reduces the risk that someone will
> forget to update one of these places, as I did when adding
> DefaultedDestructorIsConstexpr (though I've been unable to produce
> a testcase for which that matters so 

r374496 - Fix assertion failure for a cv-qualified array as a non-type template

2019-10-10 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Thu Oct 10 18:29:53 2019
New Revision: 374496

URL: http://llvm.org/viewvc/llvm-project?rev=374496=rev
Log:
Fix assertion failure for a cv-qualified array as a non-type template
parameter type.

We were both failing to decay the array type to a pointer and failing to
remove the top-level cv-qualifications. Fix this by decaying array
parameters even if the parameter type is dependent.

Modified:
cfe/trunk/lib/Sema/SemaTemplate.cpp
cfe/trunk/test/SemaTemplate/temp_arg_nontype.cpp

Modified: cfe/trunk/lib/Sema/SemaTemplate.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplate.cpp?rev=374496=374495=374496=diff
==
--- cfe/trunk/lib/Sema/SemaTemplate.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplate.cpp Thu Oct 10 18:29:53 2019
@@ -1099,9 +1099,6 @@ QualType Sema::CheckNonTypeTemplateParam
   T->isMemberPointerType() ||
   //   -- std::nullptr_t.
   T->isNullPtrType() ||
-  // If T is a dependent type, we can't do the check now, so we
-  // assume that it is well-formed.
-  T->isDependentType() ||
   // Allow use of auto in template parameter declarations.
   T->isUndeducedType()) {
 // C++ [temp.param]p5: The top-level cv-qualifiers on the 
template-parameter
@@ -1114,9 +,18 @@ QualType Sema::CheckNonTypeTemplateParam
   //   A non-type template-parameter of type "array of T" or
   //   "function returning T" is adjusted to be of type "pointer to
   //   T" or "pointer to function returning T", respectively.
-  else if (T->isArrayType() || T->isFunctionType())
+  if (T->isArrayType() || T->isFunctionType())
 return Context.getDecayedType(T);
 
+  // If T is a dependent type, we can't do the check now, so we
+  // assume that it is well-formed. Note that stripping off the
+  // qualifiers here is not really correct if T turns out to be
+  // an array type, but we'll recompute the type everywhere it's
+  // used during instantiation, so that should be OK. (Using the
+  // qualified type is equally wrong.)
+  if (T->isDependentType())
+return T.getUnqualifiedType();
+
   Diag(Loc, diag::err_template_nontype_parm_bad_type)
 << T;
 

Modified: cfe/trunk/test/SemaTemplate/temp_arg_nontype.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/temp_arg_nontype.cpp?rev=374496=374495=374496=diff
==
--- cfe/trunk/test/SemaTemplate/temp_arg_nontype.cpp (original)
+++ cfe/trunk/test/SemaTemplate/temp_arg_nontype.cpp Thu Oct 10 18:29:53 2019
@@ -493,3 +493,16 @@ namespace instantiation_dependent {
   template int (...);
   int  = g(0);
 }
+
+namespace complete_array_from_incomplete {
+  template (T::kNum)]>
+  class Base {};
+  template 
+  class Derived : public Base {};
+
+  struct T {
+static const int kNum = 3;
+  };
+  extern const char *const kStrs[3] = {};
+  Derived d;
+}


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


[PATCH] D68846: Do the bare minimum to get ClangdXPC.framework building with CMake's Xcode generator

2019-10-10 Thread Jordan Rose via Phabricator via cfe-commits
jordan_rose closed this revision.
jordan_rose added a comment.

Committed in rCTE374494 .


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D68846



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


[PATCH] D68849: [Parse] Don't speculatively parse an identifier in the wrong context.

2019-10-10 Thread Eli Friedman via Phabricator via cfe-commits
efriedma created this revision.
efriedma added a reviewer: rsmith.
Herald added a project: clang.

When we see something like `ihttps://bugs.llvm.org/show_bug.cgi?id=43080 (but not the issues currently 
marked as "duplicate"; I haven't dug deeply into the causes of those issues).


Repository:
  rC Clang

https://reviews.llvm.org/D68849

Files:
  lib/Parse/ParseTemplate.cpp
  test/CXX/basic/basic.lookup/basic.lookup.unqual/p3.cpp
  test/CodeGenCXX/odr-use.cpp
  test/SemaCXX/cxx1y-variable-templates_top_level.cpp
  test/SemaTemplate/typo-template-name.cpp

Index: test/SemaTemplate/typo-template-name.cpp
===
--- test/SemaTemplate/typo-template-name.cpp
+++ test/SemaTemplate/typo-template-name.cpp
@@ -5,14 +5,14 @@
 void typo_first_a(); // expected-note {{found}}
 template void typo_first_b(); // expected-note 2{{declared here}}
   }
-  void testA() { A::typo_first_a(); } // expected-error {{'typo_first_a' does not name a template but is followed by template arguments; did you mean 'typo_first_b'?}}
+  void testA() { A::typo_first_a(); } // expected-error {{expected '(' for function-style cast or type construction}} expected-error {{'typo_first_a' does not name a template but is followed by template arguments; did you mean 'typo_first_b'?}}
 
   namespace B {
 void typo_first_b(); // expected-note {{found}}
   }
-  void testB() { B::typo_first_b(); } // expected-error {{'typo_first_b' does not name a template but is followed by template arguments; did you mean 'A::typo_first_b'?}}
+  void testB() { B::typo_first_b(); } // expected-error {{expected '(' for function-style cast or type construction}} expected-error {{'typo_first_b' does not name a template but is followed by template arguments; did you mean 'A::typo_first_b'?}}
 
-  struct Base {
+  struct Base { // expected-note {{declared here}}
 template static void foo(); // expected-note 4{{declared here}}
 int n;
   };
@@ -20,19 +20,19 @@
 void foo(); // expected-note {{found}}
   };
   // We probably don't want to suggest correcting to .Base::foo
-  void testMember() { Derived().foo(); } // expected-error-re {{does not name a template but is followed by template arguments{{$
+  void testMember() { Derived().foo(); } // expected-error {{expected '(' for function-style cast or type construction}} expected-error-re {{does not name a template but is followed by template arguments{{$
 
   struct Derived2 : Base {
 void goo(); // expected-note {{found}}
   };
-  void testMember2() { Derived2().goo(); } // expected-error {{member 'goo' of 'InExpr::Derived2' is not a template; did you mean 'foo'?}}
+  void testMember2() { Derived2().goo(); } // expected-error {{expected '(' for function-style cast or type construction}} expected-error {{member 'goo' of 'InExpr::Derived2' is not a template; did you mean 'foo'?}}
 
   void no_correction() {
 int foo; // expected-note 3{{found}}
 
-foo(); // expected-error {{'foo' does not name a template but is followed by template arguments; did you mean 'Base::foo'?}}
+foo(); // expected-error {{expected '(' for function-style cast or type construction}} expected-error {{'foo' does not name a template but is followed by template arguments; did you mean 'Base::foo'?}}
 foo<>(); // expected-error {{'foo' does not name a template but is followed by template arguments; did you mean 'Base::foo'?}}
-foo(); // expected-error {{'foo' does not name a template but is followed by template arguments; did you mean 'Base::foo'?}}
+foo(); //  expected-error {{'Base' does not refer to a value}} expected-error {{expected expression}} expected-error {{'foo' does not name a template but is followed by template arguments; did you mean 'Base::foo'?}}
 
 // These are valid expressions.
 foo 
-T pi = T(3.1415926535897932385); // expected-note 2{{declared here}}
+T pi = T(3.1415926535897932385); // expected-note {{declared here}}
 
 template 
 CONST T cpi = T(3.1415926535897932385); // expected-note {{template is declared here}}
@@ -58,9 +58,9 @@
 namespace shadow {
   void foo() {
 int ipi0 = pi;
-int pi; // expected-note {{found}}
+int pi;
 int a = pi;
-int ipi = pi;  // expected-error {{'pi' does not name a template but is followed by template arguments; did you mean '::pi'?}}
+int ipi = pi;  // expected-error {{expected '(' for function-style cast or type construction}} expected-error {{expected expression}}
   }
 }
 
Index: test/CodeGenCXX/odr-use.cpp
===
--- /dev/null
+++ test/CodeGenCXX/odr-use.cpp
@@ -0,0 +1,5 @@
+// RUN: %clang_cc1 -std=c++11 -emit-llvm -o - -triple x86_64-linux-gnu %s | FileCheck %s --check-prefixes=CHECK
+
+// Make sure this doesn't crash, and produces reasonable output
+// CHECK: icmp ult i64 4,
+int f(int i) { return sizeof i int f(T);
 template int g(T);
-#if __cplusplus <= 201703L
-// 

[clang-tools-extra] r374494 - Get ClangdXPC.framework building (barely) with CMake's Xcode generator

2019-10-10 Thread Jordan Rose via cfe-commits
Author: jrose
Date: Thu Oct 10 18:23:56 2019
New Revision: 374494

URL: http://llvm.org/viewvc/llvm-project?rev=374494=rev
Log:
Get ClangdXPC.framework building (barely) with CMake's Xcode generator

The output directories for CMake's Xcode project generator are
specific to the configuration, and so looking in
CMAKE_LIBRARY_OUTPUT_DIRECTORY isn't going to work. Fortunately, CMake
already provides generator expressions to find the output of a given
target.

I call this "barely" building because the built framework isn't going
to respect the configuration; that is, I can't have both Debug and
RelWithDebInfo variants of ClangdXPC.framework at the same time like I
can with normal library or executable targets. To do that we'd have to
put the framework in a configuration-specific output directory or use
CMake's native support for frameworks instead.

https://reviews.llvm.org/D68846

Modified:

clang-tools-extra/trunk/clangd/xpc/cmake/modules/CreateClangdXPCFramework.cmake

Modified: 
clang-tools-extra/trunk/clangd/xpc/cmake/modules/CreateClangdXPCFramework.cmake
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/xpc/cmake/modules/CreateClangdXPCFramework.cmake?rev=374494=374493=374494=diff
==
--- 
clang-tools-extra/trunk/clangd/xpc/cmake/modules/CreateClangdXPCFramework.cmake 
(original)
+++ 
clang-tools-extra/trunk/clangd/xpc/cmake/modules/CreateClangdXPCFramework.cmake 
Thu Oct 10 18:23:56 2019
@@ -28,7 +28,7 @@ macro(create_clangd_xpc_framework target
 
 # Copy the framework binary.
 COMMAND ${CMAKE_COMMAND} -E copy
-   "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/lib${target}.dylib"
+   "$"
"${CLANGD_FRAMEWORK_OUT_LOCATION}/${name}"
 
 # Copy the XPC Service PLIST.
@@ -38,7 +38,7 @@ macro(create_clangd_xpc_framework target
 
 # Copy the Clangd binary.
 COMMAND ${CMAKE_COMMAND} -E copy
-  "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/clangd"
+  "$"
   "${CLANGD_XPC_SERVICE_OUT_LOCATION}/MacOS/clangd"
 
  COMMAND ${CMAKE_COMMAND} -E create_symlink "A"


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


[PATCH] D68845: Don't emit unwanted constructor calls in co_return statements

2019-10-10 Thread Aaron Puchert via Phabricator via cfe-commits
aaronpuchert added inline comments.



Comment at: clang/lib/Sema/SemaCoroutine.cpp:869
   if (E) {
-auto NRVOCandidate = this->getCopyElisionCandidate(E->getType(), E, 
CES_AsIfByStdMove);
-if (NRVOCandidate) {
-  InitializedEntity Entity =
-  InitializedEntity::InitializeResult(Loc, E->getType(), 
NRVOCandidate);
-  ExprResult MoveResult = this->PerformMoveOrCopyInitialization(
-  Entity, NRVOCandidate, E->getType(), E);
-  if (MoveResult.get())
-E = MoveResult.get();
-}
+VarDecl *NRVOCandidate =
+getCopyElisionCandidate(E->getType(), E, CES_Default);

Should be renamed to `RVOCandidate`, I don't think NRVO can happen here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68845



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


[PATCH] D68252: [Stats] Add ALWAYS_ENABLED_STATISTIC enabled regardless of LLVM_ENABLE_STATS.

2019-10-10 Thread Volodymyr Sapsai via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
vsapsai marked an inline comment as done.
Closed by commit rGadb203feda90: [Stats] Add ALWAYS_ENABLED_STATISTIC enabled 
regardless of LLVM_ENABLE_STATS. (authored by vsapsai).

Changed prior to commit:
  https://reviews.llvm.org/D68252?vs=224235=224514#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68252

Files:
  llvm/include/llvm/ADT/Statistic.h
  llvm/lib/Support/Statistic.cpp
  llvm/unittests/ADT/StatisticTest.cpp

Index: llvm/unittests/ADT/StatisticTest.cpp
===
--- llvm/unittests/ADT/StatisticTest.cpp
+++ llvm/unittests/ADT/StatisticTest.cpp
@@ -17,6 +17,7 @@
 #define DEBUG_TYPE "unittest"
 STATISTIC(Counter, "Counts things");
 STATISTIC(Counter2, "Counts other things");
+ALWAYS_ENABLED_STATISTIC(AlwaysCounter, "Counts things always");
 
 #if LLVM_ENABLE_STATS
 static void
@@ -43,6 +44,12 @@
 #else
   EXPECT_EQ(Counter, 0u);
 #endif
+
+  AlwaysCounter = 0;
+  EXPECT_EQ(AlwaysCounter, 0u);
+  AlwaysCounter++;
+  ++AlwaysCounter;
+  EXPECT_EQ(AlwaysCounter, 2u);
 }
 
 TEST(StatisticTest, Assign) {
@@ -54,6 +61,9 @@
 #else
   EXPECT_EQ(Counter, 0u);
 #endif
+
+  AlwaysCounter = 2;
+  EXPECT_EQ(AlwaysCounter, 2u);
 }
 
 TEST(StatisticTest, API) {
Index: llvm/lib/Support/Statistic.cpp
===
--- llvm/lib/Support/Statistic.cpp
+++ llvm/lib/Support/Statistic.cpp
@@ -57,7 +57,7 @@
 /// This class is also used to look up statistic values from applications that
 /// use LLVM.
 class StatisticInfo {
-  std::vector Stats;
+  std::vector Stats;
 
   friend void llvm::PrintStatistics();
   friend void llvm::PrintStatistics(raw_ostream );
@@ -66,14 +66,12 @@
   /// Sort statistics by debugtype,name,description.
   void sort();
 public:
-  using const_iterator = std::vector::const_iterator;
+  using const_iterator = std::vector::const_iterator;
 
   StatisticInfo();
   ~StatisticInfo();
 
-  void addStatistic(Statistic *S) {
-Stats.push_back(S);
-  }
+  void addStatistic(TrackingStatistic *S) { Stats.push_back(S); }
 
   const_iterator begin() const { return Stats.begin(); }
   const_iterator end() const { return Stats.end(); }
@@ -90,7 +88,7 @@
 
 /// RegisterStatistic - The first time a statistic is bumped, this method is
 /// called.
-void Statistic::RegisterStatistic() {
+void TrackingStatistic::RegisterStatistic() {
   // If stats are enabled, inform StatInfo that this statistic should be
   // printed.
   // llvm_shutdown calls destructors while holding the ManagedStatic mutex.
@@ -135,15 +133,16 @@
 }
 
 void StatisticInfo::sort() {
-  llvm::stable_sort(Stats, [](const Statistic *LHS, const Statistic *RHS) {
-if (int Cmp = std::strcmp(LHS->getDebugType(), RHS->getDebugType()))
-  return Cmp < 0;
+  llvm::stable_sort(
+  Stats, [](const TrackingStatistic *LHS, const TrackingStatistic *RHS) {
+if (int Cmp = std::strcmp(LHS->getDebugType(), RHS->getDebugType()))
+  return Cmp < 0;
 
-if (int Cmp = std::strcmp(LHS->getName(), RHS->getName()))
-  return Cmp < 0;
+if (int Cmp = std::strcmp(LHS->getName(), RHS->getName()))
+  return Cmp < 0;
 
-return std::strcmp(LHS->getDesc(), RHS->getDesc()) < 0;
-  });
+return std::strcmp(LHS->getDesc(), RHS->getDesc()) < 0;
+  });
 }
 
 void StatisticInfo::reset() {
@@ -207,7 +206,7 @@
   // Print all of the statistics.
   OS << "{\n";
   const char *delim = "";
-  for (const Statistic *Stat : Stats.Stats) {
+  for (const TrackingStatistic *Stat : Stats.Stats) {
 OS << delim;
 assert(yaml::needsQuotes(Stat->getDebugType()) == yaml::QuotingType::None &&
"Statistic group/type name is simple.");
Index: llvm/include/llvm/ADT/Statistic.h
===
--- llvm/include/llvm/ADT/Statistic.h
+++ llvm/include/llvm/ADT/Statistic.h
@@ -44,38 +44,39 @@
 class raw_fd_ostream;
 class StringRef;
 
-class Statistic {
+class StatisticBase {
 public:
   const char *DebugType;
   const char *Name;
   const char *Desc;
-  std::atomic Value;
-  std::atomic Initialized;
 
-  unsigned getValue() const { return Value.load(std::memory_order_relaxed); }
+  StatisticBase(const char *DebugType, const char *Name, const char *Desc)
+  : DebugType(DebugType), Name(Name), Desc(Desc) {}
+
   const char *getDebugType() const { return DebugType; }
   const char *getName() const { return Name; }
   const char *getDesc() const { return Desc; }
+};
 
-  /// construct - This should only be called for non-global statistics.
-  void construct(const char *debugtype, const char *name, const char *desc) {
-DebugType = debugtype;
-Name = name;
-Desc = desc;
-Value = 0;
-Initialized = false;
-  }
+class TrackingStatistic : public StatisticBase {
+public:
+  std::atomic 

[PATCH] D68832: [tsan,msan] Insert module constructors in a module pass

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

This fails on Mac and windows http://45.33.8.238/win/247/step_6.txt


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68832



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


[PATCH] D51741: [coro]Pass rvalue reference for named local variable to return_value

2019-10-10 Thread Aaron Puchert via Phabricator via cfe-commits
aaronpuchert added a comment.

Please have a look at D68845 . This should 
address the issues that we discussed.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D51741



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


[PATCH] D68846: Do the bare minimum to get ClangdXPC.framework building with CMake's Xcode generator

2019-10-10 Thread Jordan Rose via Phabricator via cfe-commits
jordan_rose created this revision.
jordan_rose added reviewers: beanz, jkorous.
Herald added subscribers: cfe-commits, usaxena95, kadircet, arphaman, 
dexonsmith, MaskRay, ilya-biryukov, mgorny.
Herald added a project: clang.

The output directories for CMake's Xcode project generator are specific to the 
configuration, and so looking in `CMAKE_LIBRARY_OUTPUT_DIRECTORY` isn't going 
to work. Fortunately, CMake already provides generator expressions to find the 
output of a given target.

I call this the bare minimum because the //built// framework isn't going to 
respect the configuration; that is, I can't have both Debug and RelWithDebInfo 
variants of ClangdXPC.framework at the same time like I can with normal library 
or executable targets. To do that we'd have to put the framework in a 
configuration-specific output directory too…or use CMake's native support for 
frameworks instead.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D68846

Files:
  clang-tools-extra/clangd/xpc/cmake/modules/CreateClangdXPCFramework.cmake


Index: clang-tools-extra/clangd/xpc/cmake/modules/CreateClangdXPCFramework.cmake
===
--- clang-tools-extra/clangd/xpc/cmake/modules/CreateClangdXPCFramework.cmake
+++ clang-tools-extra/clangd/xpc/cmake/modules/CreateClangdXPCFramework.cmake
@@ -28,7 +28,7 @@
 
 # Copy the framework binary.
 COMMAND ${CMAKE_COMMAND} -E copy
-   "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/lib${target}.dylib"
+   "$"
"${CLANGD_FRAMEWORK_OUT_LOCATION}/${name}"
 
 # Copy the XPC Service PLIST.
@@ -38,7 +38,7 @@
 
 # Copy the Clangd binary.
 COMMAND ${CMAKE_COMMAND} -E copy
-  "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/clangd"
+  "$"
   "${CLANGD_XPC_SERVICE_OUT_LOCATION}/MacOS/clangd"
 
  COMMAND ${CMAKE_COMMAND} -E create_symlink "A"


Index: clang-tools-extra/clangd/xpc/cmake/modules/CreateClangdXPCFramework.cmake
===
--- clang-tools-extra/clangd/xpc/cmake/modules/CreateClangdXPCFramework.cmake
+++ clang-tools-extra/clangd/xpc/cmake/modules/CreateClangdXPCFramework.cmake
@@ -28,7 +28,7 @@
 
 # Copy the framework binary.
 COMMAND ${CMAKE_COMMAND} -E copy
-   "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/lib${target}.dylib"
+   "$"
"${CLANGD_FRAMEWORK_OUT_LOCATION}/${name}"
 
 # Copy the XPC Service PLIST.
@@ -38,7 +38,7 @@
 
 # Copy the Clangd binary.
 COMMAND ${CMAKE_COMMAND} -E copy
-  "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/clangd"
+  "$"
   "${CLANGD_XPC_SERVICE_OUT_LOCATION}/MacOS/clangd"
 
  COMMAND ${CMAKE_COMMAND} -E create_symlink "A"
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D68845: Don't emit unwanted constructor calls in co_return statements

2019-10-10 Thread Aaron Puchert via Phabricator via cfe-commits
aaronpuchert created this revision.
aaronpuchert added reviewers: GorNishanov, modocache, Quuxplusone.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
aaronpuchert updated this revision to Diff 224513.
aaronpuchert added a comment.

Also remove FIXME comment.


The implementation of return value optimization in D51741 
 turns

  co_return value;

which is essentially

  __promise.return_value(value);

into

  __promise.return_value(decltype(std::move(value)));

instead of

  __promise.return_value(std::move(value));

Instead of doing a copy/move initialization, which is only required for
regular return statements, we just cast to an xvalue reference when we
can consume an object.

Also simplifies the test: some flags aren't needed, neither is main.
Instead we now check that no move constructor is emitted in certain
cases. (That is, we actually delete the move constructor.)


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D68845

Files:
  clang/lib/Sema/SemaCoroutine.cpp
  clang/test/SemaCXX/coroutine-rvo.cpp


Index: clang/test/SemaCXX/coroutine-rvo.cpp
===
--- clang/test/SemaCXX/coroutine-rvo.cpp
+++ clang/test/SemaCXX/coroutine-rvo.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple x86_64-apple-darwin9 %s -stdlib=libc++ -std=c++1z 
-fcoroutines-ts -fsyntax-only
+// RUN: %clang_cc1 -verify -std=c++17 -fcoroutines-ts -fsyntax-only %s
 
 namespace std::experimental {
 template  struct coroutine_handle {
@@ -38,11 +38,17 @@
   void await_resume() noexcept;
 };
 
+struct Default {};
+
 struct MoveOnly {
-  MoveOnly() {};
+  MoveOnly() = default;
   MoveOnly(const MoveOnly&) = delete;
-  MoveOnly(MoveOnly&&) noexcept {};
-  ~MoveOnly() {};
+  MoveOnly(MoveOnly&&) = default;
+};
+
+struct NoCopyNoMove {
+  NoCopyNoMove() = default;
+  NoCopyNoMove(const NoCopyNoMove&) = delete;
 };
 
 template 
@@ -52,18 +58,31 @@
 auto final_suspend() { return suspend_never{}; }
 auto get_return_object() { return task{}; }
 static void unhandled_exception() {}
-void return_value(T&& value) {}
+void return_value(T&& value) {} // expected-note 2{{passing argument}}
   };
 };
 
-task f() {
-  MoveOnly value;
+task local2val() {
+  NoCopyNoMove value;
   co_return value;
 }
 
-int main() {
-  f();
-  return 0;
+task param2val(MoveOnly value) {
+  co_return value;
 }
 
-// expected-no-diagnostics
+task lvalue2val(Default& value) {
+  co_return value; // expected-error{{rvalue reference to type 'Default' 
cannot bind to lvalue of type 'Default'}}
+}
+
+task rvalue2val(NoCopyNoMove&& value) {
+  co_return value;
+}
+
+task lvalue2ref(NoCopyNoMove& value) {
+  co_return value;
+}
+
+task rvalue2ref(Default&& value) {
+  co_return value; // expected-error{{non-const lvalue reference to type 
'Default' cannot bind to a temporary of type 'Default'}}
+}
Index: clang/lib/Sema/SemaCoroutine.cpp
===
--- clang/lib/Sema/SemaCoroutine.cpp
+++ clang/lib/Sema/SemaCoroutine.cpp
@@ -866,20 +866,13 @@
 
   // Move the return value if we can
   if (E) {
-auto NRVOCandidate = this->getCopyElisionCandidate(E->getType(), E, 
CES_AsIfByStdMove);
-if (NRVOCandidate) {
-  InitializedEntity Entity =
-  InitializedEntity::InitializeResult(Loc, E->getType(), 
NRVOCandidate);
-  ExprResult MoveResult = this->PerformMoveOrCopyInitialization(
-  Entity, NRVOCandidate, E->getType(), E);
-  if (MoveResult.get())
-E = MoveResult.get();
-}
+VarDecl *NRVOCandidate =
+getCopyElisionCandidate(E->getType(), E, CES_Default);
+if (NRVOCandidate && !NRVOCandidate->getType()->isLValueReferenceType())
+  E = ImplicitCastExpr::Create(Context, E->getType(), CK_NoOp, E, {},
+   VK_XValue);
   }
 
-  // FIXME: If the operand is a reference to a variable that's about to go out
-  // of scope, we should treat the operand as an xvalue for this overload
-  // resolution.
   VarDecl *Promise = FSI->CoroutinePromise;
   ExprResult PC;
   if (E && (isa(E) || !E->getType()->isVoidType())) {


Index: clang/test/SemaCXX/coroutine-rvo.cpp
===
--- clang/test/SemaCXX/coroutine-rvo.cpp
+++ clang/test/SemaCXX/coroutine-rvo.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple x86_64-apple-darwin9 %s -stdlib=libc++ -std=c++1z -fcoroutines-ts -fsyntax-only
+// RUN: %clang_cc1 -verify -std=c++17 -fcoroutines-ts -fsyntax-only %s
 
 namespace std::experimental {
 template  struct coroutine_handle {
@@ -38,11 +38,17 @@
   void await_resume() noexcept;
 };
 
+struct Default {};
+
 struct MoveOnly {
-  MoveOnly() {};
+  MoveOnly() = default;
   MoveOnly(const MoveOnly&) = delete;
-  MoveOnly(MoveOnly&&) noexcept {};
-  ~MoveOnly() {};
+  MoveOnly(MoveOnly&&) = default;
+};
+
+struct NoCopyNoMove {
+  NoCopyNoMove() = default;
+  

[PATCH] D68845: Don't emit unwanted constructor calls in co_return statements

2019-10-10 Thread Aaron Puchert via Phabricator via cfe-commits
aaronpuchert updated this revision to Diff 224513.
aaronpuchert added a comment.

Also remove FIXME comment.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68845

Files:
  clang/lib/Sema/SemaCoroutine.cpp
  clang/test/SemaCXX/coroutine-rvo.cpp


Index: clang/test/SemaCXX/coroutine-rvo.cpp
===
--- clang/test/SemaCXX/coroutine-rvo.cpp
+++ clang/test/SemaCXX/coroutine-rvo.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple x86_64-apple-darwin9 %s -stdlib=libc++ -std=c++1z 
-fcoroutines-ts -fsyntax-only
+// RUN: %clang_cc1 -verify -std=c++17 -fcoroutines-ts -fsyntax-only %s
 
 namespace std::experimental {
 template  struct coroutine_handle {
@@ -38,11 +38,17 @@
   void await_resume() noexcept;
 };
 
+struct Default {};
+
 struct MoveOnly {
-  MoveOnly() {};
+  MoveOnly() = default;
   MoveOnly(const MoveOnly&) = delete;
-  MoveOnly(MoveOnly&&) noexcept {};
-  ~MoveOnly() {};
+  MoveOnly(MoveOnly&&) = default;
+};
+
+struct NoCopyNoMove {
+  NoCopyNoMove() = default;
+  NoCopyNoMove(const NoCopyNoMove&) = delete;
 };
 
 template 
@@ -52,18 +58,31 @@
 auto final_suspend() { return suspend_never{}; }
 auto get_return_object() { return task{}; }
 static void unhandled_exception() {}
-void return_value(T&& value) {}
+void return_value(T&& value) {} // expected-note 2{{passing argument}}
   };
 };
 
-task f() {
-  MoveOnly value;
+task local2val() {
+  NoCopyNoMove value;
   co_return value;
 }
 
-int main() {
-  f();
-  return 0;
+task param2val(MoveOnly value) {
+  co_return value;
 }
 
-// expected-no-diagnostics
+task lvalue2val(Default& value) {
+  co_return value; // expected-error{{rvalue reference to type 'Default' 
cannot bind to lvalue of type 'Default'}}
+}
+
+task rvalue2val(NoCopyNoMove&& value) {
+  co_return value;
+}
+
+task lvalue2ref(NoCopyNoMove& value) {
+  co_return value;
+}
+
+task rvalue2ref(Default&& value) {
+  co_return value; // expected-error{{non-const lvalue reference to type 
'Default' cannot bind to a temporary of type 'Default'}}
+}
Index: clang/lib/Sema/SemaCoroutine.cpp
===
--- clang/lib/Sema/SemaCoroutine.cpp
+++ clang/lib/Sema/SemaCoroutine.cpp
@@ -866,20 +866,13 @@
 
   // Move the return value if we can
   if (E) {
-auto NRVOCandidate = this->getCopyElisionCandidate(E->getType(), E, 
CES_AsIfByStdMove);
-if (NRVOCandidate) {
-  InitializedEntity Entity =
-  InitializedEntity::InitializeResult(Loc, E->getType(), 
NRVOCandidate);
-  ExprResult MoveResult = this->PerformMoveOrCopyInitialization(
-  Entity, NRVOCandidate, E->getType(), E);
-  if (MoveResult.get())
-E = MoveResult.get();
-}
+VarDecl *NRVOCandidate =
+getCopyElisionCandidate(E->getType(), E, CES_Default);
+if (NRVOCandidate && !NRVOCandidate->getType()->isLValueReferenceType())
+  E = ImplicitCastExpr::Create(Context, E->getType(), CK_NoOp, E, {},
+   VK_XValue);
   }
 
-  // FIXME: If the operand is a reference to a variable that's about to go out
-  // of scope, we should treat the operand as an xvalue for this overload
-  // resolution.
   VarDecl *Promise = FSI->CoroutinePromise;
   ExprResult PC;
   if (E && (isa(E) || !E->getType()->isVoidType())) {


Index: clang/test/SemaCXX/coroutine-rvo.cpp
===
--- clang/test/SemaCXX/coroutine-rvo.cpp
+++ clang/test/SemaCXX/coroutine-rvo.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple x86_64-apple-darwin9 %s -stdlib=libc++ -std=c++1z -fcoroutines-ts -fsyntax-only
+// RUN: %clang_cc1 -verify -std=c++17 -fcoroutines-ts -fsyntax-only %s
 
 namespace std::experimental {
 template  struct coroutine_handle {
@@ -38,11 +38,17 @@
   void await_resume() noexcept;
 };
 
+struct Default {};
+
 struct MoveOnly {
-  MoveOnly() {};
+  MoveOnly() = default;
   MoveOnly(const MoveOnly&) = delete;
-  MoveOnly(MoveOnly&&) noexcept {};
-  ~MoveOnly() {};
+  MoveOnly(MoveOnly&&) = default;
+};
+
+struct NoCopyNoMove {
+  NoCopyNoMove() = default;
+  NoCopyNoMove(const NoCopyNoMove&) = delete;
 };
 
 template 
@@ -52,18 +58,31 @@
 auto final_suspend() { return suspend_never{}; }
 auto get_return_object() { return task{}; }
 static void unhandled_exception() {}
-void return_value(T&& value) {}
+void return_value(T&& value) {} // expected-note 2{{passing argument}}
   };
 };
 
-task f() {
-  MoveOnly value;
+task local2val() {
+  NoCopyNoMove value;
   co_return value;
 }
 
-int main() {
-  f();
-  return 0;
+task param2val(MoveOnly value) {
+  co_return value;
 }
 
-// expected-no-diagnostics
+task lvalue2val(Default& value) {
+  co_return value; // expected-error{{rvalue reference to type 'Default' cannot bind to lvalue of type 'Default'}}
+}
+
+task rvalue2val(NoCopyNoMove&& value) {

r374488 - Include whether the destructor is constexpr in -ast-dump output for a

2019-10-10 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Thu Oct 10 17:40:08 2019
New Revision: 374488

URL: http://llvm.org/viewvc/llvm-project?rev=374488=rev
Log:
Include whether the destructor is constexpr in -ast-dump output for a
clss.

Modified:
cfe/trunk/lib/AST/TextNodeDumper.cpp

Modified: cfe/trunk/lib/AST/TextNodeDumper.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/TextNodeDumper.cpp?rev=374488=374487=374488=diff
==
--- cfe/trunk/lib/AST/TextNodeDumper.cpp (original)
+++ cfe/trunk/lib/AST/TextNodeDumper.cpp Thu Oct 10 17:40:08 2019
@@ -1643,6 +1643,7 @@ void TextNodeDumper::VisitCXXRecordDecl(
   FLAG(hasTrivialDestructor, trivial);
   FLAG(hasNonTrivialDestructor, non_trivial);
   FLAG(hasUserDeclaredDestructor, user_declared);
+  FLAG(hasConstexprDestructor, constexpr);
   FLAG(needsImplicitDestructor, needs_implicit);
   FLAG(needsOverloadResolutionForDestructor, needs_overload_resolution);
   if (!D->needsOverloadResolutionForDestructor())


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


[PATCH] D68835: [clang-scan-deps] Add basic support for Clang modules.

2019-10-10 Thread Michael Spencer via Phabricator via cfe-commits
Bigcheese updated this revision to Diff 224507.
Bigcheese marked 2 inline comments as done.
Bigcheese added a comment.

Addressed review comments.


Repository:
  rC Clang

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

https://reviews.llvm.org/D68835

Files:
  lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp
  test/ClangScanDeps/Inputs/module.modulemap
  test/ClangScanDeps/Inputs/modules_cdb.json
  test/ClangScanDeps/modules.cpp

Index: test/ClangScanDeps/modules.cpp
===
--- /dev/null
+++ test/ClangScanDeps/modules.cpp
@@ -0,0 +1,41 @@
+// RUN: rm -rf %t.dir
+// RUN: rm -rf %t.cdb
+// RUN: rm -rf %t.module-cache
+// RUN: mkdir -p %t.dir
+// RUN: cp %s %t.dir/modules_cdb_input.cpp
+// RUN: cp %s %t.dir/modules_cdb_input2.cpp
+// RUN: mkdir %t.dir/Inputs
+// RUN: cp %S/Inputs/header.h %t.dir/Inputs/header.h
+// RUN: cp %S/Inputs/header2.h %t.dir/Inputs/header2.h
+// RUN: cp %S/Inputs/module.modulemap %t.dir/Inputs/module.modulemap
+// RUN: sed -e "s|DIR|%/t.dir|g" %S/Inputs/modules_cdb.json > %t.cdb
+//
+// RUN: clang-scan-deps -compilation-database %t.cdb -j 1 -mode preprocess-minimized-sources | \
+// RUN:   FileCheck --check-prefixes=CHECK1,CHECK2,CHECK2NO %s
+//
+// The output order is non-deterministic when using more than one thread,
+// so check the output using two runs. Note that the 'NOT' check is not used
+// as it might fail if the results for `modules_cdb_input.cpp` are reported before
+// `modules_cdb_input2.cpp`.
+//
+// RUN: clang-scan-deps -compilation-database %t.cdb -j 2 -mode preprocess-minimized-sources | \
+// RUN:   FileCheck --check-prefix=CHECK1 %s
+// RUN: clang-scan-deps -compilation-database %t.cdb -j 2 -mode preprocess | \
+// RUN:   FileCheck --check-prefix=CHECK1 %s
+// RUN: clang-scan-deps -compilation-database %t.cdb -j 2 -mode preprocess-minimized-sources | \
+// RUN:   FileCheck --check-prefix=CHECK2 %s
+// RUN: clang-scan-deps -compilation-database %t.cdb -j 2 -mode preprocess | \
+// RUN:   FileCheck --check-prefix=CHECK2 %s
+
+#include "header.h"
+
+// CHECK1: modules_cdb_input2.cpp
+// CHECK1-NEXT: modules_cdb_input2.cpp
+// CHECK1-NEXT: Inputs{{/|\\}}module.modulemap
+// CHECK1-NEXT: Inputs{{/|\\}}header2.h
+// CHECK1: Inputs{{/|\\}}header.h
+
+// CHECK2: modules_cdb_input.cpp
+// CHECK2-NEXT: Inputs{{/|\\}}module.modulemap
+// CHECK2-NEXT: Inputs{{/|\\}}header.h
+// CHECK2NO-NOT: header2
Index: test/ClangScanDeps/Inputs/modules_cdb.json
===
--- /dev/null
+++ test/ClangScanDeps/Inputs/modules_cdb.json
@@ -0,0 +1,13 @@
+[
+{
+  "directory": "DIR",
+  "command": "clang -E -fsyntax-only DIR/modules_cdb_input2.cpp -IInputs -D INCLUDE_HEADER2 -MD -MF DIR/modules_cdb2.d -fmodules -fmodules-cache-path=DIR/module-cache -fimplicit-modules -fimplicit-module-maps",
+  "file": "DIR/modules_cdb_input2.cpp"
+},
+{
+  "directory": "DIR",
+  "command": "clang -E DIR/modules_cdb_input.cpp -IInputs -fmodules -fmodules-cache-path=DIR/module-cache -fimplicit-modules -fimplicit-module-maps",
+  "file": "DIR/modules_cdb_input.cpp"
+}
+]
+
Index: test/ClangScanDeps/Inputs/module.modulemap
===
--- /dev/null
+++ test/ClangScanDeps/Inputs/module.modulemap
@@ -0,0 +1,7 @@
+module header1 {
+  header "header.h"
+}
+
+module header2 {
+header "header2.h"
+}
Index: lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp
===
--- lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp
+++ lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp
@@ -122,6 +122,31 @@
   return It.first->getValue();
 }
 
+/// Whitelist file extensions that should be minimized, treating no extension as
+/// a source file that should be minimized.
+///
+/// This is kinda hacky, it would be better if we knew what kind of file Clang
+/// was expecting instead.
+static bool shouldMinimize(StringRef Filename) {
+  StringRef Ext = llvm::sys::path::extension(Filename);
+  if (Ext.empty())
+return true; // C++ standard library
+  return llvm::StringSwitch(Ext)
+.CasesLower(".c", ".cc", ".cpp", ".c++", ".cxx", true)
+.CasesLower(".h", ".hh", ".hpp", ".h++", ".hxx", true)
+.CasesLower(".m", ".mm", true)
+.CasesLower(".def", ".inc", true)
+.Default(false);
+}
+
+
+static bool shouldCacheStatFailures(StringRef Filename) {
+  StringRef Ext = llvm::sys::path::extension(Filename);
+  if (Ext.empty())
+return false; // This may be the module cache directory.
+  return shouldMinimize(Filename); // Only cache stat failures on source files.
+}
+
 llvm::ErrorOr
 DependencyScanningWorkerFilesystem::getOrCreateFileSystemEntry(
 const StringRef Filename) {
@@ -132,7 +157,8 @@
   // FIXME: Handle PCM/PCH files.
   // FIXME: Handle module map files.
 
-  bool KeepOriginalSource = 

r374484 - Move most CXXRecordDecl::DefinitionData bit-fields out into a separate

2019-10-10 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Thu Oct 10 17:29:04 2019
New Revision: 374484

URL: http://llvm.org/viewvc/llvm-project?rev=374484=rev
Log:
Move most CXXRecordDecl::DefinitionData bit-fields out into a separate
file.

Reduces duplication and thereby reduces the risk that someone will
forget to update one of these places, as I did when adding
DefaultedDestructorIsConstexpr (though I've been unable to produce
a testcase for which that matters so far).

Added:
cfe/trunk/include/clang/AST/CXXRecordDeclDefinitionBits.def
Modified:
cfe/trunk/include/clang/AST/DeclCXX.h
cfe/trunk/lib/AST/ASTImporter.cpp
cfe/trunk/lib/AST/DeclCXX.cpp
cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
cfe/trunk/lib/Serialization/ASTWriter.cpp

Added: cfe/trunk/include/clang/AST/CXXRecordDeclDefinitionBits.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/CXXRecordDeclDefinitionBits.def?rev=374484=auto
==
--- cfe/trunk/include/clang/AST/CXXRecordDeclDefinitionBits.def (added)
+++ cfe/trunk/include/clang/AST/CXXRecordDeclDefinitionBits.def Thu Oct 10 
17:29:04 2019
@@ -0,0 +1,236 @@
+//===-- CXXRecordDeclDefinitionBits.def - Class definition bits -*- 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 enumerates the various bitfields that we want to store on C++ 
class
+// definitions.
+//
+//===--===//
+//
+/// @file CXXRecordDeclDefinitionBits.def
+///
+/// In this file, each of the bitfields representing data about a C++ class
+/// results in an expansion of the FIELD macro, which should be defined before
+/// including this file.
+///
+/// The macro have three operands:
+///
+/// Name: The name of the field, as a member of CXXRecordDecl::DefinitionData.
+///
+/// BitWidth: The width of the field in bits.
+///
+/// MergePolicy: How to behave when the value of the field is different in
+/// multiple translation units, one of:
+///   NO_MERGE: It is an ODR violation if the fields do not match.
+///   MERGE_OR: Merge the fields by ORing them together.
+
+#ifndef FIELD
+#error define FIELD before including this file
+#endif
+
+/// True if this class has any user-declared constructors.
+FIELD(UserDeclaredConstructor, 1, NO_MERGE)
+
+/// The user-declared special members which this class has.
+FIELD(UserDeclaredSpecialMembers, 6, NO_MERGE)
+
+/// True when this class is an aggregate.
+FIELD(Aggregate, 1, NO_MERGE)
+
+/// True when this class is a POD-type.
+FIELD(PlainOldData, 1, NO_MERGE)
+
+/// True when this class is empty for traits purposes, that is:
+///  * has no data members other than 0-width bit-fields and empty fields
+///marked [[no_unique_address]]
+///  * has no virtual function/base, and
+///  * doesn't inherit from a non-empty class.
+/// Doesn't take union-ness into account.
+FIELD(Empty, 1, NO_MERGE)
+
+/// True when this class is polymorphic, i.e., has at
+/// least one virtual member or derives from a polymorphic class.
+FIELD(Polymorphic, 1, NO_MERGE)
+
+/// True when this class is abstract, i.e., has at least
+/// one pure virtual function, (that can come from a base class).
+FIELD(Abstract, 1, NO_MERGE)
+
+/// True when this class is standard-layout, per the applicable
+/// language rules (including DRs).
+FIELD(IsStandardLayout, 1, NO_MERGE)
+
+/// True when this class was standard-layout under the C++11
+/// definition.
+///
+/// C++11 [class]p7.  A standard-layout class is a class that:
+/// * has no non-static data members of type non-standard-layout class (or
+///   array of such types) or reference,
+/// * has no virtual functions (10.3) and no virtual base classes (10.1),
+/// * has the same access control (Clause 11) for all non-static data
+///   members
+/// * has no non-standard-layout base classes,
+/// * either has no non-static data members in the most derived class and at
+///   most one base class with non-static data members, or has no base
+///   classes with non-static data members, and
+/// * has no base classes of the same type as the first non-static data
+///   member.
+FIELD(IsCXX11StandardLayout, 1, NO_MERGE)
+
+/// True when any base class has any declared non-static data
+/// members or bit-fields.
+/// This is a helper bit of state used to implement IsStandardLayout more
+/// efficiently.
+FIELD(HasBasesWithFields, 1, NO_MERGE)
+
+/// True when any base class has any declared non-static data
+/// members.
+/// This is a helper bit of state used to implement IsCXX11StandardLayout
+/// more efficiently.
+FIELD(HasBasesWithNonStaticDataMembers, 1, NO_MERGE)
+
+/// True when there are private non-static data members.
+FIELD(HasPrivateFields, 

[PATCH] D68746: [Clang][OpenMP Offload] Move offload registration code to the wrapper

2019-10-10 Thread George Rokos via Phabricator via cfe-commits
grokos added inline comments.



Comment at: clang/tools/clang-offload-wrapper/ClangOffloadWrapper.cpp:74
+  IntegerType *getSizeTTy() {
+switch (M.getDataLayout().getPointerTypeSize(Type::getInt8PtrTy(C))) {
+case 4u:

sdmitriev wrote:
> ABataev wrote:
> > sdmitriev wrote:
> > > ABataev wrote:
> > > > Same question as before: maybe better to make the size of size_t type a 
> > > > parameter of a tool?
> > > As I remember you also had another suggestion - change size_t to 
> > > intptr_t. That will eliminate the need to an additional parameter for 
> > > size type. Will it be better?
> > In thi case we'll need to change the type in the libomptarget.
> Right. @grokos , do you see any potential problems in changing 
> __tgt_offload_entry::size type from size_t to intptr_t?
As long as `intptr_t` has the same size as `size_t` it should be fine. Of 
course, if this is not the case, then if libomptarget tries to load an older 
image where `sizeof(__tgt_offload_entry::size) != sizeof(intptr_t)` then 
backwards compatibility will have been broken. Fortunately, on all platforms 
supported by released versions of libomptarget so far (x86_64, ppc64, aarch64) 
if I'm not mistaken `sizeof(size_t) == sizeof(initptr_t)`, so I don't think 
we'll break anything.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68746



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


[PATCH] D68660: [tooling] Teach Tooling to understand compilation with offloading.

2019-10-10 Thread Michael Liao via Phabricator via cfe-commits
hliao added a comment.

In D68660#1705087 , @thakis wrote:

> This makes tests assert on Mac: http://45.33.8.238/mac/1415/step_6.txt


please let me know whether that works for you. thanks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68660



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


[PATCH] D68832: [tsan,msan] Insert module constructors in a module pass

2019-10-10 Thread Vitaly Buka via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG5c72aa232e74: [tsan,msan] Insert module constructors in a 
module pass (authored by vitalybuka).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68832

Files:
  clang/lib/CodeGen/BackendUtil.cpp
  clang/test/CodeGen/sanitizer-module-constructor.c
  llvm/include/llvm/Transforms/Instrumentation/MemorySanitizer.h
  llvm/include/llvm/Transforms/Instrumentation/ThreadSanitizer.h
  llvm/lib/Passes/PassRegistry.def
  llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
  llvm/lib/Transforms/Instrumentation/ThreadSanitizer.cpp
  llvm/test/Instrumentation/MemorySanitizer/msan_basic.ll
  llvm/test/Instrumentation/ThreadSanitizer/tsan_basic.ll

Index: llvm/test/Instrumentation/ThreadSanitizer/tsan_basic.ll
===
--- llvm/test/Instrumentation/ThreadSanitizer/tsan_basic.ll
+++ llvm/test/Instrumentation/ThreadSanitizer/tsan_basic.ll
@@ -1,5 +1,5 @@
 ; RUN: opt < %s -tsan -S | FileCheck %s
-; RUN: opt < %s -passes=tsan -S | FileCheck %s
+; RUN: opt < %s -passes='function(tsan),module(tsan-module)' -S | FileCheck %s
 
 target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64"
 target triple = "x86_64-unknown-linux-gnu"
Index: llvm/test/Instrumentation/MemorySanitizer/msan_basic.ll
===
--- llvm/test/Instrumentation/MemorySanitizer/msan_basic.ll
+++ llvm/test/Instrumentation/MemorySanitizer/msan_basic.ll
@@ -1,10 +1,9 @@
-; RUN: opt < %s -msan-check-access-address=0 -S -passes=msan 2>&1 | FileCheck  \
-; RUN: -allow-deprecated-dag-overlap %s
-; RUN: opt < %s -msan -msan-check-access-address=0 -S | FileCheck -allow-deprecated-dag-overlap %s
-; RUN: opt < %s -msan-check-access-address=0 -msan-track-origins=1 -S  \
-; RUN: -passes=msan 2>&1 | FileCheck -allow-deprecated-dag-overlap \
-; RUN: -check-prefix=CHECK -check-prefix=CHECK-ORIGINS %s
-; RUN: opt < %s -msan -msan-check-access-address=0 -msan-track-origins=1 -S | FileCheck -allow-deprecated-dag-overlap -check-prefix=CHECK -check-prefix=CHECK-ORIGINS %s
+; RUN: opt < %s -msan-check-access-address=0 -S -passes='module(msan-module),function(msan)' 2>&1 | FileCheck -allow-deprecated-dag-overlap %s
+; RUN: opt < %s --passes='module(msan-module),function(msan)' -msan-check-access-address=0 -S | FileCheck -allow-deprecated-dag-overlap %s
+; RUN: opt < %s -msan-check-access-address=0 -msan-track-origins=1 -S -passes='module(msan-module),function(msan)' 2>&1 | \
+; RUN:   FileCheck -allow-deprecated-dag-overlap -check-prefixes=CHECK,CHECK-ORIGINS %s
+; RUN: opt < %s -passes='module(msan-module),function(msan)' -msan-check-access-address=0 -msan-track-origins=1 -S | \
+; RUN:   FileCheck -allow-deprecated-dag-overlap -check-prefixes=CHECK,CHECK-ORIGINS %s
 
 target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
 target triple = "x86_64-unknown-linux-gnu"
Index: llvm/lib/Transforms/Instrumentation/ThreadSanitizer.cpp
===
--- llvm/lib/Transforms/Instrumentation/ThreadSanitizer.cpp
+++ llvm/lib/Transforms/Instrumentation/ThreadSanitizer.cpp
@@ -92,11 +92,10 @@
 /// ensures the __tsan_init function is in the list of global constructors for
 /// the module.
 struct ThreadSanitizer {
-  ThreadSanitizer(Module );
   bool sanitizeFunction(Function , const TargetLibraryInfo );
 
 private:
-  void initializeCallbacks(Module );
+  void initialize(Module );
   bool instrumentLoadOrStore(Instruction *I, const DataLayout );
   bool instrumentAtomic(Instruction *I, const DataLayout );
   bool instrumentMemIntrinsic(Instruction *I);
@@ -108,8 +107,6 @@
   void InsertRuntimeIgnores(Function );
 
   Type *IntptrTy;
-  IntegerType *OrdTy;
-  // Callbacks to run-time library are computed in doInitialization.
   FunctionCallee TsanFuncEntry;
   FunctionCallee TsanFuncExit;
   FunctionCallee TsanIgnoreBegin;
@@ -130,7 +127,6 @@
   FunctionCallee TsanVptrUpdate;
   FunctionCallee TsanVptrLoad;
   FunctionCallee MemmoveFn, MemcpyFn, MemsetFn;
-  Function *TsanCtorFunction;
 };
 
 struct ThreadSanitizerLegacyPass : FunctionPass {
@@ -143,16 +139,32 @@
 private:
   Optional TSan;
 };
+
+void insertModuleCtor(Module ) {
+  getOrCreateSanitizerCtorAndInitFunctions(
+  M, kTsanModuleCtorName, kTsanInitName, /*InitArgTypes=*/{},
+  /*InitArgs=*/{},
+  // This callback is invoked when the functions are created the first
+  // time. Hook them into the global ctors list in that case:
+  [&](Function *Ctor, FunctionCallee) { appendToGlobalCtors(M, Ctor, 0); });
+}
+
 }  // namespace
 
 

r374481 - [tsan,msan] Insert module constructors in a module pass

2019-10-10 Thread Vitaly Buka via cfe-commits
Author: vitalybuka
Date: Thu Oct 10 16:49:10 2019
New Revision: 374481

URL: http://llvm.org/viewvc/llvm-project?rev=374481=rev
Log:
[tsan,msan] Insert module constructors in a module pass

Summary:
If we insert them from function pass some analysis may be missing or invalid.
Fixes PR42877.

Reviewers: eugenis, leonardchan

Reviewed By: leonardchan

Subscribers: hiraditya, cfe-commits, llvm-commits

Tags: #clang, #llvm

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

Added:
cfe/trunk/test/CodeGen/sanitizer-module-constructor.c
Modified:
cfe/trunk/lib/CodeGen/BackendUtil.cpp

Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=374481=374480=374481=diff
==
--- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original)
+++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Thu Oct 10 16:49:10 2019
@@ -974,6 +974,7 @@ static void addSanitizersAtO0(ModulePass
   }
 
   if (LangOpts.Sanitize.has(SanitizerKind::Memory)) {
+MPM.addPass(MemorySanitizerPass({}));
 MPM.addPass(createModuleToFunctionPassAdaptor(MemorySanitizerPass({})));
   }
 
@@ -983,6 +984,7 @@ static void addSanitizersAtO0(ModulePass
   }
 
   if (LangOpts.Sanitize.has(SanitizerKind::Thread)) {
+MPM.addPass(ThreadSanitizerPass());
 MPM.addPass(createModuleToFunctionPassAdaptor(ThreadSanitizerPass()));
   }
 }
@@ -1162,16 +1164,23 @@ void EmitAssemblyHelper::EmitAssemblyWit
 [](FunctionPassManager , PassBuilder::OptimizationLevel Level) 
{
   FPM.addPass(BoundsCheckingPass());
 });
-  if (LangOpts.Sanitize.has(SanitizerKind::Memory))
+  if (LangOpts.Sanitize.has(SanitizerKind::Memory)) {
+PB.registerPipelineStartEPCallback([](ModulePassManager ) {
+  MPM.addPass(MemorySanitizerPass({}));
+});
 PB.registerOptimizerLastEPCallback(
 [](FunctionPassManager , PassBuilder::OptimizationLevel Level) 
{
   FPM.addPass(MemorySanitizerPass({}));
 });
-  if (LangOpts.Sanitize.has(SanitizerKind::Thread))
+  }
+  if (LangOpts.Sanitize.has(SanitizerKind::Thread)) {
+PB.registerPipelineStartEPCallback(
+[](ModulePassManager ) { MPM.addPass(ThreadSanitizerPass()); 
});
 PB.registerOptimizerLastEPCallback(
 [](FunctionPassManager , PassBuilder::OptimizationLevel Level) 
{
   FPM.addPass(ThreadSanitizerPass());
 });
+  }
   if (LangOpts.Sanitize.has(SanitizerKind::Address)) {
 PB.registerPipelineStartEPCallback([&](ModulePassManager ) {
   MPM.addPass(

Added: cfe/trunk/test/CodeGen/sanitizer-module-constructor.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/sanitizer-module-constructor.c?rev=374481=auto
==
--- cfe/trunk/test/CodeGen/sanitizer-module-constructor.c (added)
+++ cfe/trunk/test/CodeGen/sanitizer-module-constructor.c Thu Oct 10 16:49:10 
2019
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 -fsanitize=address -emit-llvm -O3 -fdebug-pass-manager 
-fexperimental-new-pass-manager -o - %s 2>&1 | FileCheck %s
+// RUN: %clang_cc1 -fsanitize=thread -emit-llvm -O3 -fdebug-pass-manager 
-fexperimental-new-pass-manager -o - %s 2>&1 | FileCheck %s
+// RUN: %clang_cc1 -fsanitize=memory -emit-llvm -O3 -fdebug-pass-manager 
-fexperimental-new-pass-manager -o - %s 2>&1 | FileCheck %s
+
+// This is regression test for PR42877
+
+typedef struct a *b;
+struct a {
+  int c;
+};
+int d;
+b e;
+static void f(b g) {
+  for (d = g->c;;)
+;
+}
+void h() { f(e); }
+
+// CHECK: Running pass: {{.*}}SanitizerPass on 
{{.*}}sanitizer-module-constructor.c
+// CHECK-NOT: Running pass: LoopSimplifyPass on {{.*}}san.module_ctor
+// CHECK: Running analysis: DominatorTreeAnalysis on {{.*}}san.module_ctor
+// CHECK: Running pass: LoopSimplifyPass on {{.*}}san.module_ctor


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


[PATCH] D68660: [tooling] Teach Tooling to understand compilation with offloading.

2019-10-10 Thread Michael Liao via Phabricator via cfe-commits
hliao added a comment.

In D68660#1705087 , @thakis wrote:

> This makes tests assert on Mac: http://45.33.8.238/mac/1415/step_6.txt


I have no access to MacOS but try to fix that in r374478. Maybe that's a good 
excuse for a MacBook, ;)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68660



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


[PATCH] D68832: [tsan,msan] Insert module constructors in a module pass

2019-10-10 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka updated this revision to Diff 224501.
vitalybuka marked 2 inline comments as done.
vitalybuka added a comment.

nfc


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68832

Files:
  clang/lib/CodeGen/BackendUtil.cpp
  clang/test/CodeGen/sanitizer-module-constructor.c
  llvm/include/llvm/Transforms/Instrumentation/MemorySanitizer.h
  llvm/include/llvm/Transforms/Instrumentation/ThreadSanitizer.h
  llvm/lib/Passes/PassRegistry.def
  llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
  llvm/lib/Transforms/Instrumentation/ThreadSanitizer.cpp
  llvm/test/Instrumentation/MemorySanitizer/msan_basic.ll
  llvm/test/Instrumentation/ThreadSanitizer/tsan_basic.ll

Index: llvm/test/Instrumentation/ThreadSanitizer/tsan_basic.ll
===
--- llvm/test/Instrumentation/ThreadSanitizer/tsan_basic.ll
+++ llvm/test/Instrumentation/ThreadSanitizer/tsan_basic.ll
@@ -1,5 +1,5 @@
 ; RUN: opt < %s -tsan -S | FileCheck %s
-; RUN: opt < %s -passes=tsan -S | FileCheck %s
+; RUN: opt < %s -passes='function(tsan),module(tsan-module)' -S | FileCheck %s
 
 target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64"
 target triple = "x86_64-unknown-linux-gnu"
Index: llvm/test/Instrumentation/MemorySanitizer/msan_basic.ll
===
--- llvm/test/Instrumentation/MemorySanitizer/msan_basic.ll
+++ llvm/test/Instrumentation/MemorySanitizer/msan_basic.ll
@@ -1,10 +1,9 @@
-; RUN: opt < %s -msan-check-access-address=0 -S -passes=msan 2>&1 | FileCheck  \
-; RUN: -allow-deprecated-dag-overlap %s
-; RUN: opt < %s -msan -msan-check-access-address=0 -S | FileCheck -allow-deprecated-dag-overlap %s
-; RUN: opt < %s -msan-check-access-address=0 -msan-track-origins=1 -S  \
-; RUN: -passes=msan 2>&1 | FileCheck -allow-deprecated-dag-overlap \
-; RUN: -check-prefix=CHECK -check-prefix=CHECK-ORIGINS %s
-; RUN: opt < %s -msan -msan-check-access-address=0 -msan-track-origins=1 -S | FileCheck -allow-deprecated-dag-overlap -check-prefix=CHECK -check-prefix=CHECK-ORIGINS %s
+; RUN: opt < %s -msan-check-access-address=0 -S -passes='module(msan-module),function(msan)' 2>&1 | FileCheck -allow-deprecated-dag-overlap %s
+; RUN: opt < %s --passes='module(msan-module),function(msan)' -msan-check-access-address=0 -S | FileCheck -allow-deprecated-dag-overlap %s
+; RUN: opt < %s -msan-check-access-address=0 -msan-track-origins=1 -S -passes='module(msan-module),function(msan)' 2>&1 | \
+; RUN:   FileCheck -allow-deprecated-dag-overlap -check-prefixes=CHECK,CHECK-ORIGINS %s
+; RUN: opt < %s -passes='module(msan-module),function(msan)' -msan-check-access-address=0 -msan-track-origins=1 -S | \
+; RUN:   FileCheck -allow-deprecated-dag-overlap -check-prefixes=CHECK,CHECK-ORIGINS %s
 
 target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
 target triple = "x86_64-unknown-linux-gnu"
Index: llvm/lib/Transforms/Instrumentation/ThreadSanitizer.cpp
===
--- llvm/lib/Transforms/Instrumentation/ThreadSanitizer.cpp
+++ llvm/lib/Transforms/Instrumentation/ThreadSanitizer.cpp
@@ -92,11 +92,10 @@
 /// ensures the __tsan_init function is in the list of global constructors for
 /// the module.
 struct ThreadSanitizer {
-  ThreadSanitizer(Module );
   bool sanitizeFunction(Function , const TargetLibraryInfo );
 
 private:
-  void initializeCallbacks(Module );
+  void initialize(Module );
   bool instrumentLoadOrStore(Instruction *I, const DataLayout );
   bool instrumentAtomic(Instruction *I, const DataLayout );
   bool instrumentMemIntrinsic(Instruction *I);
@@ -108,8 +107,6 @@
   void InsertRuntimeIgnores(Function );
 
   Type *IntptrTy;
-  IntegerType *OrdTy;
-  // Callbacks to run-time library are computed in doInitialization.
   FunctionCallee TsanFuncEntry;
   FunctionCallee TsanFuncExit;
   FunctionCallee TsanIgnoreBegin;
@@ -130,7 +127,6 @@
   FunctionCallee TsanVptrUpdate;
   FunctionCallee TsanVptrLoad;
   FunctionCallee MemmoveFn, MemcpyFn, MemsetFn;
-  Function *TsanCtorFunction;
 };
 
 struct ThreadSanitizerLegacyPass : FunctionPass {
@@ -143,16 +139,32 @@
 private:
   Optional TSan;
 };
+
+void insertModuleCtor(Module ) {
+  getOrCreateSanitizerCtorAndInitFunctions(
+  M, kTsanModuleCtorName, kTsanInitName, /*InitArgTypes=*/{},
+  /*InitArgs=*/{},
+  // This callback is invoked when the functions are created the first
+  // time. Hook them into the global ctors list in that case:
+  [&](Function *Ctor, FunctionCallee) { appendToGlobalCtors(M, Ctor, 0); });
+}
+
 }  // namespace
 
 PreservedAnalyses ThreadSanitizerPass::run(Function ,
   

[PATCH] D68753: [CUDA][HIP} Add a test for constexpr default ctor

2019-10-10 Thread Artem Belevich via Phabricator via cfe-commits
tra accepted this revision.
tra added a comment.
This revision is now accepted and ready to land.

LGTM.
Sometimes I wish it would be possible to specify some of the -verify 
diagnostics in temporal order, as opposed to tying them to locations. I.e. in 
this case it would be way more useful to see the call stack leading to the 
error at B::B. Oh, well.


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

https://reviews.llvm.org/D68753



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


r374478 - [tooling] Fix assertion on MacOSX.

2019-10-10 Thread Michael Liao via cfe-commits
Author: hliao
Date: Thu Oct 10 16:45:20 2019
New Revision: 374478

URL: http://llvm.org/viewvc/llvm-project?rev=374478=rev
Log:
[tooling] Fix assertion on MacOSX.

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

Modified: cfe/trunk/lib/Tooling/Tooling.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/Tooling.cpp?rev=374478=374477=374478=diff
==
--- cfe/trunk/lib/Tooling/Tooling.cpp (original)
+++ cfe/trunk/lib/Tooling/Tooling.cpp Thu Oct 10 16:45:20 2019
@@ -106,7 +106,12 @@ static const llvm::opt::ArgStringList *g
 // compilation, device compilation only option, such as
 // `--cuda-device-only`, needs specifying.
 assert(Actions.size() == 2);
-assert(isa(Actions.front()));
+assert(
+isa(Actions.front()) ||
+// On MacOSX real actions may end up being wrapped in
+// BindArchAction.
+(isa(Actions.front()) &&
+ isa(*Actions.front()->input_begin(;
 OffloadCompilation = true;
 break;
   }


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


[PATCH] D68660: [tooling] Teach Tooling to understand compilation with offloading.

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

This makes tests assert on Mac: http://45.33.8.238/mac/1415/step_6.txt


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68660



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


[PATCH] D68660: [tooling] Teach Tooling to understand compilation with offloading.

2019-10-10 Thread Michael Liao via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG1ccb39bbd87c: [tooling] Teach Tooling to understand 
compilation with offloading. (authored by hliao).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68660

Files:
  clang/lib/Tooling/Tooling.cpp
  clang/test/Tooling/clang-check-offload.cpp


Index: clang/test/Tooling/clang-check-offload.cpp
===
--- /dev/null
+++ clang/test/Tooling/clang-check-offload.cpp
@@ -0,0 +1,4 @@
+// RUN: not clang-check "%s" -- -c -x hip -nogpulib 2>&1 | FileCheck %s
+
+// CHECK: C++ requires
+invalid;
Index: clang/lib/Tooling/Tooling.cpp
===
--- clang/lib/Tooling/Tooling.cpp
+++ clang/lib/Tooling/Tooling.cpp
@@ -91,7 +91,29 @@
   // We expect to get back exactly one Command job, if we didn't something
   // failed. Extract that job from the Compilation.
   const driver::JobList  = Compilation->getJobs();
-  if (Jobs.size() != 1 || !isa(*Jobs.begin())) {
+  const driver::ActionList  = Compilation->getActions();
+  bool OffloadCompilation = false;
+  if (Jobs.size() > 1) {
+for (auto A : Actions){
+  // On MacOSX real actions may end up being wrapped in BindArchAction
+  if (isa(A))
+A = *A->input_begin();
+  if (isa(A)) {
+// Offload compilation has 2 top-level actions, one (at the front) is
+// the original host compilation and the other is offload action
+// composed of at least one device compilation. For such case, general
+// tooling will consider host-compilation only. For tooling on device
+// compilation, device compilation only option, such as
+// `--cuda-device-only`, needs specifying.
+assert(Actions.size() == 2);
+assert(isa(Actions.front()));
+OffloadCompilation = true;
+break;
+  }
+}
+  }
+  if (Jobs.size() == 0 || !isa(*Jobs.begin()) ||
+  (Jobs.size() > 1 && !OffloadCompilation)) {
 SmallString<256> error_msg;
 llvm::raw_svector_ostream error_stream(error_msg);
 Jobs.Print(error_stream, "; ", true);


Index: clang/test/Tooling/clang-check-offload.cpp
===
--- /dev/null
+++ clang/test/Tooling/clang-check-offload.cpp
@@ -0,0 +1,4 @@
+// RUN: not clang-check "%s" -- -c -x hip -nogpulib 2>&1 | FileCheck %s
+
+// CHECK: C++ requires
+invalid;
Index: clang/lib/Tooling/Tooling.cpp
===
--- clang/lib/Tooling/Tooling.cpp
+++ clang/lib/Tooling/Tooling.cpp
@@ -91,7 +91,29 @@
   // We expect to get back exactly one Command job, if we didn't something
   // failed. Extract that job from the Compilation.
   const driver::JobList  = Compilation->getJobs();
-  if (Jobs.size() != 1 || !isa(*Jobs.begin())) {
+  const driver::ActionList  = Compilation->getActions();
+  bool OffloadCompilation = false;
+  if (Jobs.size() > 1) {
+for (auto A : Actions){
+  // On MacOSX real actions may end up being wrapped in BindArchAction
+  if (isa(A))
+A = *A->input_begin();
+  if (isa(A)) {
+// Offload compilation has 2 top-level actions, one (at the front) is
+// the original host compilation and the other is offload action
+// composed of at least one device compilation. For such case, general
+// tooling will consider host-compilation only. For tooling on device
+// compilation, device compilation only option, such as
+// `--cuda-device-only`, needs specifying.
+assert(Actions.size() == 2);
+assert(isa(Actions.front()));
+OffloadCompilation = true;
+break;
+  }
+}
+  }
+  if (Jobs.size() == 0 || !isa(*Jobs.begin()) ||
+  (Jobs.size() > 1 && !OffloadCompilation)) {
 SmallString<256> error_msg;
 llvm::raw_svector_ostream error_stream(error_msg);
 Jobs.Print(error_stream, "; ", true);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D68720: Support -fstack-clash-protection for x86

2019-10-10 Thread Tom Stellard via Phabricator via cfe-commits
tstellar added inline comments.



Comment at: clang/test/CodeGen/stack-clash-protection.c:3
+// RUN: %clang -target x86_64 -o %t.out %s -fstack-clash-protection && %t.out
+
+#include 

There were concerns[1] raised recently about adding clang tests that were 
codegen dependent.  Is something being tested here that can't be tested with an 
IR test?  If you only need to test that the frontend option work, I think 
checking the IR for the necessary function attributes might be enough.



[1] http://lists.llvm.org/pipermail/cfe-dev/2019-September/063309.html


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68720



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


[PATCH] D63932: [GlobalDCE] Dead Virtual Function Elimination

2019-10-10 Thread Peter Collingbourne via Phabricator via cfe-commits
pcc accepted this revision.
pcc added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D63932



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


r374470 - [tooling] Teach Tooling to understand compilation with offloading.

2019-10-10 Thread Michael Liao via cfe-commits
Author: hliao
Date: Thu Oct 10 16:05:55 2019
New Revision: 374470

URL: http://llvm.org/viewvc/llvm-project?rev=374470=rev
Log:
[tooling] Teach Tooling to understand compilation with offloading.

Summary:
- So far, we only recognize the host compilation with offloading and
  skip the offloading part.

Reviewers: tra, yaxunl

Subscribers: cfe-commits

Tags: #clang

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

Added:
cfe/trunk/test/Tooling/clang-check-offload.cpp
Modified:
cfe/trunk/lib/Tooling/Tooling.cpp

Modified: cfe/trunk/lib/Tooling/Tooling.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/Tooling.cpp?rev=374470=374469=374470=diff
==
--- cfe/trunk/lib/Tooling/Tooling.cpp (original)
+++ cfe/trunk/lib/Tooling/Tooling.cpp Thu Oct 10 16:05:55 2019
@@ -91,7 +91,29 @@ static const llvm::opt::ArgStringList *g
   // We expect to get back exactly one Command job, if we didn't something
   // failed. Extract that job from the Compilation.
   const driver::JobList  = Compilation->getJobs();
-  if (Jobs.size() != 1 || !isa(*Jobs.begin())) {
+  const driver::ActionList  = Compilation->getActions();
+  bool OffloadCompilation = false;
+  if (Jobs.size() > 1) {
+for (auto A : Actions){
+  // On MacOSX real actions may end up being wrapped in BindArchAction
+  if (isa(A))
+A = *A->input_begin();
+  if (isa(A)) {
+// Offload compilation has 2 top-level actions, one (at the front) is
+// the original host compilation and the other is offload action
+// composed of at least one device compilation. For such case, general
+// tooling will consider host-compilation only. For tooling on device
+// compilation, device compilation only option, such as
+// `--cuda-device-only`, needs specifying.
+assert(Actions.size() == 2);
+assert(isa(Actions.front()));
+OffloadCompilation = true;
+break;
+  }
+}
+  }
+  if (Jobs.size() == 0 || !isa(*Jobs.begin()) ||
+  (Jobs.size() > 1 && !OffloadCompilation)) {
 SmallString<256> error_msg;
 llvm::raw_svector_ostream error_stream(error_msg);
 Jobs.Print(error_stream, "; ", true);

Added: cfe/trunk/test/Tooling/clang-check-offload.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Tooling/clang-check-offload.cpp?rev=374470=auto
==
--- cfe/trunk/test/Tooling/clang-check-offload.cpp (added)
+++ cfe/trunk/test/Tooling/clang-check-offload.cpp Thu Oct 10 16:05:55 2019
@@ -0,0 +1,4 @@
+// RUN: not clang-check "%s" -- -c -x hip -nogpulib 2>&1 | FileCheck %s
+
+// CHECK: C++ requires
+invalid;


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


[PATCH] D68838: [ARM] Fix arm_neon.h with -flax-vector-conversions=none, part 3

2019-10-10 Thread Eli Friedman via Phabricator via cfe-commits
efriedma updated this revision to Diff 224496.

Repository:
  rC Clang

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

https://reviews.llvm.org/D68838

Files:
  test/CodeGen/aarch64-v8.2a-neon-intrinsics.c
  utils/TableGen/NeonEmitter.cpp


Index: utils/TableGen/NeonEmitter.cpp
===
--- utils/TableGen/NeonEmitter.cpp
+++ utils/TableGen/NeonEmitter.cpp
@@ -1442,7 +1442,8 @@
 }
 
 // Check if an explicit cast is needed.
-if (CastToType.isVector() && LocalCK == ClassB) {
+if (CastToType.isVector() &&
+(LocalCK == ClassB || (T.isHalf() && !T.isScalarForMangling( {
   CastToType.makeInteger(8, true);
   Arg = "(" + CastToType.str() + ")" + Arg;
 } else if (CastToType.isVector() && LocalCK == ClassI) {
Index: test/CodeGen/aarch64-v8.2a-neon-intrinsics.c
===
--- test/CodeGen/aarch64-v8.2a-neon-intrinsics.c
+++ test/CodeGen/aarch64-v8.2a-neon-intrinsics.c
@@ -1,5 +1,5 @@
 // RUN: %clang_cc1 -triple arm64-none-linux-gnu -target-feature +neon 
-target-feature +fullfp16 -target-feature +v8.2a\
-// RUN: -fallow-half-arguments-and-returns -S -disable-O0-optnone -emit-llvm 
-o - %s \
+// RUN: -fallow-half-arguments-and-returns -flax-vector-conversions=none -S 
-disable-O0-optnone -emit-llvm -o - %s \
 // RUN: | opt -S -mem2reg \
 // RUN: | FileCheck %s
 


Index: utils/TableGen/NeonEmitter.cpp
===
--- utils/TableGen/NeonEmitter.cpp
+++ utils/TableGen/NeonEmitter.cpp
@@ -1442,7 +1442,8 @@
 }
 
 // Check if an explicit cast is needed.
-if (CastToType.isVector() && LocalCK == ClassB) {
+if (CastToType.isVector() &&
+(LocalCK == ClassB || (T.isHalf() && !T.isScalarForMangling( {
   CastToType.makeInteger(8, true);
   Arg = "(" + CastToType.str() + ")" + Arg;
 } else if (CastToType.isVector() && LocalCK == ClassI) {
Index: test/CodeGen/aarch64-v8.2a-neon-intrinsics.c
===
--- test/CodeGen/aarch64-v8.2a-neon-intrinsics.c
+++ test/CodeGen/aarch64-v8.2a-neon-intrinsics.c
@@ -1,5 +1,5 @@
 // RUN: %clang_cc1 -triple arm64-none-linux-gnu -target-feature +neon -target-feature +fullfp16 -target-feature +v8.2a\
-// RUN: -fallow-half-arguments-and-returns -S -disable-O0-optnone -emit-llvm -o - %s \
+// RUN: -fallow-half-arguments-and-returns -flax-vector-conversions=none -S -disable-O0-optnone -emit-llvm -o - %s \
 // RUN: | opt -S -mem2reg \
 // RUN: | FileCheck %s
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D68823: Fix help message for -ffp-contract

2019-10-10 Thread Yaxun Liu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc10a64718ed2: Fix help message for -ffp-contract (authored 
by yaxunl).
Herald added a project: clang.

Changed prior to commit:
  https://reviews.llvm.org/D68823?vs=224436=224497#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68823

Files:
  clang/include/clang/Driver/Options.td


Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -1147,7 +1147,8 @@
 def fno_trapping_math : Flag<["-"], "fno-trapping-math">, Group, 
Flags<[CC1Option]>;
 def ffp_contract : Joined<["-"], "ffp-contract=">, Group,
   Flags<[CC1Option]>, HelpText<"Form fused FP ops (e.g. FMAs): fast 
(everywhere)"
-  " | on (according to FP_CONTRACT pragma, default) | off (never fuse)">, 
Values<"fast,on,off">;
+  " | on (according to FP_CONTRACT pragma) | off (never fuse). Default"
+  " is 'fast' for CUDA/HIP and 'on' otherwise.">, Values<"fast,on,off">;
 
 def fstrict_float_cast_overflow : Flag<["-"],
   "fstrict-float-cast-overflow">, Group, Flags<[CC1Option]>,


Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -1147,7 +1147,8 @@
 def fno_trapping_math : Flag<["-"], "fno-trapping-math">, Group, Flags<[CC1Option]>;
 def ffp_contract : Joined<["-"], "ffp-contract=">, Group,
   Flags<[CC1Option]>, HelpText<"Form fused FP ops (e.g. FMAs): fast (everywhere)"
-  " | on (according to FP_CONTRACT pragma, default) | off (never fuse)">, Values<"fast,on,off">;
+  " | on (according to FP_CONTRACT pragma) | off (never fuse). Default"
+  " is 'fast' for CUDA/HIP and 'on' otherwise.">, Values<"fast,on,off">;
 
 def fstrict_float_cast_overflow : Flag<["-"],
   "fstrict-float-cast-overflow">, Group, Flags<[CC1Option]>,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r374467 - Fix help message for -ffp-contract

2019-10-10 Thread Yaxun Liu via cfe-commits
Author: yaxunl
Date: Thu Oct 10 15:43:00 2019
New Revision: 374467

URL: http://llvm.org/viewvc/llvm-project?rev=374467=rev
Log:
Fix help message for -ffp-contract

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

Modified:
cfe/trunk/include/clang/Driver/Options.td

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=374467=374466=374467=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Thu Oct 10 15:43:00 2019
@@ -1147,7 +1147,8 @@ def ftrapping_math : Flag<["-"], "ftrapp
 def fno_trapping_math : Flag<["-"], "fno-trapping-math">, Group, 
Flags<[CC1Option]>;
 def ffp_contract : Joined<["-"], "ffp-contract=">, Group,
   Flags<[CC1Option]>, HelpText<"Form fused FP ops (e.g. FMAs): fast 
(everywhere)"
-  " | on (according to FP_CONTRACT pragma, default) | off (never fuse)">, 
Values<"fast,on,off">;
+  " | on (according to FP_CONTRACT pragma) | off (never fuse). Default"
+  " is 'fast' for CUDA/HIP and 'on' otherwise.">, Values<"fast,on,off">;
 
 def fstrict_float_cast_overflow : Flag<["-"],
   "fstrict-float-cast-overflow">, Group, Flags<[CC1Option]>,


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


[PATCH] D68720: Support -fstack-clash-protection for x86

2019-10-10 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added inline comments.



Comment at: llvm/lib/Target/X86/X86FrameLowering.cpp:423
+   AbsOffset - CurrentAbsOffset + PageSize);
+if (FreeProbeIterator != MBB.end()) {
+  NumFrameFreeProbe++;

Each probe has to have an offset of at most PageSize bytes from the previous 
probe.  If each probe is exactly PageSize bytes away from the previous probe, 
that's fine.  But it looks like you don't enforce the distance between free 
probes correctly?



Comment at: llvm/lib/Target/X86/X86FrameLowering.cpp:481
+[](MachineOperand ) { return MO.isFI(); })) {
+  break; // effect on stack pointer not modelled, stopping
+}

There are instructions that don't refer to any FI, but are still relevant.  For 
example, calls.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68720



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


[PATCH] D68753: [CUDA][HIP} Add a test for constexpr default ctor

2019-10-10 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 224492.
yaxunl marked an inline comment as done.
yaxunl added a comment.

revised by Artem's comments


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

https://reviews.llvm.org/D68753

Files:
  test/SemaCUDA/constexpr-ctor.cu


Index: test/SemaCUDA/constexpr-ctor.cu
===
--- /dev/null
+++ test/SemaCUDA/constexpr-ctor.cu
@@ -0,0 +1,33 @@
+// RUN: %clang_cc1 -std=c++11 -triple nvptx64-nvidia-cuda -fsyntax-only \
+// RUN:-fcuda-is-device -verify=dev %s
+// RUN: %clang_cc1 -std=c++11 -triple x86_64-unknown-linux-gnu -fsyntax-only \
+// RUN:-verify=host %s
+
+// host-no-diagnostics
+
+#include "Inputs/cuda.h"
+
+struct A {
+  A(); // dev-note 2{{'A' declared here}}
+};
+
+template  struct B {
+  T a;
+  constexpr B() = default; // dev-error 2{{reference to __host__ function 'A' 
in __host__ __device__ function}}
+};
+
+__host__ void f() { B x; }
+__device__ void f() { B x; } // dev-note{{called by 'f'}}
+
+struct foo {
+  __host__ foo() { B x; }
+  __device__ foo() { B x; } // dev-note{{called by 'foo'}}
+};
+
+__host__ void g() { foo x; }
+__device__ void g() { foo x; } // dev-note{{called by 'g'}}
+
+struct bar {
+  __host__ bar() { B x; }
+  __device__ bar() { B x; } // no error since no instantiation of bar
+};


Index: test/SemaCUDA/constexpr-ctor.cu
===
--- /dev/null
+++ test/SemaCUDA/constexpr-ctor.cu
@@ -0,0 +1,33 @@
+// RUN: %clang_cc1 -std=c++11 -triple nvptx64-nvidia-cuda -fsyntax-only \
+// RUN:-fcuda-is-device -verify=dev %s
+// RUN: %clang_cc1 -std=c++11 -triple x86_64-unknown-linux-gnu -fsyntax-only \
+// RUN:-verify=host %s
+
+// host-no-diagnostics
+
+#include "Inputs/cuda.h"
+
+struct A {
+  A(); // dev-note 2{{'A' declared here}}
+};
+
+template  struct B {
+  T a;
+  constexpr B() = default; // dev-error 2{{reference to __host__ function 'A' in __host__ __device__ function}}
+};
+
+__host__ void f() { B x; }
+__device__ void f() { B x; } // dev-note{{called by 'f'}}
+
+struct foo {
+  __host__ foo() { B x; }
+  __device__ foo() { B x; } // dev-note{{called by 'foo'}}
+};
+
+__host__ void g() { foo x; }
+__device__ void g() { foo x; } // dev-note{{called by 'g'}}
+
+struct bar {
+  __host__ bar() { B x; }
+  __device__ bar() { B x; } // no error since no instantiation of bar
+};
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D68753: [CUDA][HIP} Add a test for constexpr default ctor

2019-10-10 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl marked 2 inline comments as done.
yaxunl added inline comments.



Comment at: test/SemaCUDA/constexpr-ctor.cu:14-27
+template  struct B {
+  T a;
+  constexpr B() = default;
+};
+
+template  struct C {
+  T a;

tra wrote:
> yaxunl wrote:
> > tra wrote:
> > > Do we really need three identical templates? If they are needed to let 
> > > compiler emit multiple diagnostics, perhaps we could just add another 
> > > template parameter so we can get different instantiations.
> > the error is emitted on the default ctor of the template. If we do not use 
> > different templates, all errors are emitted on the same line, we cannot 
> > make sure some instantiations do not cause error and some instantiations 
> > should cause error.
> > 
> > Adding template parameter will not help, because the error will still be 
> > emitted to the same line.
> Having multiple errors attributed to the same source is OK. You can specify 
> expected count. E.g.
> `dev-error 2 {{something}}`. Single template appears to be sufficient 
> (https://godbolt.org/z/G3WvYD).
> 
> You'll have different note diags emitted for individual errors, so checking 
> them would both provide more info about that exactly the problem is and will 
> verify that they are reported in the correct locations. Right now you are 
> describing what/where triggers an error that as a comment. Letting compiler 
> verify that instead would be better, IMO.
> 
> 
Yes I can use note. will do.


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

https://reviews.llvm.org/D68753



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


r374465 - PR43629: Fix crash evaluating constexpr placement new on a subobject of

2019-10-10 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Thu Oct 10 15:31:17 2019
New Revision: 374465

URL: http://llvm.org/viewvc/llvm-project?rev=374465=rev
Log:
PR43629: Fix crash evaluating constexpr placement new on a subobject of
an out-of-lifetime object.

Modified:
cfe/trunk/include/clang/Basic/DiagnosticASTKinds.td
cfe/trunk/lib/AST/ExprConstant.cpp
cfe/trunk/test/SemaCXX/cxx2a-constexpr-dynalloc.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticASTKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticASTKinds.td?rev=374465=374464=374465=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticASTKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticASTKinds.td Thu Oct 10 15:31:17 2019
@@ -126,7 +126,8 @@ def note_constexpr_lifetime_ended : Note
   "%plural{8:storage duration|:lifetime}0 has ended">;
 def note_constexpr_access_uninit : Note<
   "%select{read of|read of|assignment to|increment of|decrement of|"
-  "member call on|dynamic_cast of|typeid applied to||destruction of}0 "
+  "member call on|dynamic_cast of|typeid applied to|"
+  "construction of subobject of|destruction of}0 "
   "%select{object outside its lifetime|uninitialized object}1 "
   "is not allowed in a constant expression">;
 def note_constexpr_use_uninit_reference : Note<

Modified: cfe/trunk/lib/AST/ExprConstant.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=374465=374464=374465=diff
==
--- cfe/trunk/lib/AST/ExprConstant.cpp (original)
+++ cfe/trunk/lib/AST/ExprConstant.cpp Thu Oct 10 15:31:17 2019
@@ -3178,7 +3178,7 @@ findSubobject(EvalInfo , const Expr
   // Walk the designator's path to find the subobject.
   for (unsigned I = 0, N = Sub.Entries.size(); /**/; ++I) {
 // Reading an indeterminate value is undefined, but assigning over one is 
OK.
-if ((O->isAbsent() && handler.AccessKind != AK_Construct) ||
+if ((O->isAbsent() && !(handler.AccessKind == AK_Construct && I == N)) ||
 (O->isIndeterminate() && handler.AccessKind != AK_Construct &&
  handler.AccessKind != AK_Assign &&
  handler.AccessKind != AK_ReadObjectRepresentation)) {

Modified: cfe/trunk/test/SemaCXX/cxx2a-constexpr-dynalloc.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/cxx2a-constexpr-dynalloc.cpp?rev=374465=374464=374465=diff
==
--- cfe/trunk/test/SemaCXX/cxx2a-constexpr-dynalloc.cpp (original)
+++ cfe/trunk/test/SemaCXX/cxx2a-constexpr-dynalloc.cpp Thu Oct 10 15:31:17 2019
@@ -166,3 +166,13 @@ constexpr bool construct_after_lifetime(
   return true;
 }
 static_assert(construct_after_lifetime()); // expected-error {{}} 
expected-note {{in call}}
+
+constexpr bool construct_after_lifetime_2() {
+  struct A { struct B {} b; };
+  A a;
+  a.~A();
+  std::construct_at(); // expected-note {{in call}}
+  // expected-note@#new {{construction of subobject of object outside its 
lifetime is not allowed in a constant expression}}
+  return true;
+}
+static_assert(construct_after_lifetime_2()); // expected-error {{}} 
expected-note {{in call}}


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


[PATCH] D68838: [ARM] Fix arm_neon.h with -flax-vector-conversions=none, part 3

2019-10-10 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

Thanks again! In my testing, this is enough to get the clang testsuite to pass 
with the default changed to `-flax-vector-conversions=integer`.




Comment at: test/CodeGen/aarch64-v8.2a-neon-intrinsics.c:149-170
+uint16x4_t test_vcvt_u16_f16 (float16x4_t a) {
   return vcvt_u16_f16(a);
 }
 
 // CHECK-LABEL: test_vcvtq_u16_f16
 // CHECK:  [[VCVT:%.*]] = fptoui <8 x half> %a to <8 x i16>
 // CHECK:  ret <8 x i16> [[VCVT]]

I already committed these three fixes in r374457.


Repository:
  rC Clang

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

https://reviews.llvm.org/D68838



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


[PATCH] D68807: [ClangTidy] Separate tests for infrastructure and checkers

2019-10-10 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr added a comment.

It would look weird if we have a ton of tests for checkers in a directory, and 
then a subdirectory for infra tests.

Why are we trying to optimize the number of renamed files? I already did the 
renaming, so we are not saving any work. I think we should optimize for 
long-term readability of the codebase.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68807



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


[PATCH] D68746: [Clang][OpenMP Offload] Move offload registration code to the wrapper

2019-10-10 Thread Sergey Dmitriev via Phabricator via cfe-commits
sdmitriev added a subscriber: grokos.
sdmitriev added inline comments.



Comment at: clang/tools/clang-offload-wrapper/ClangOffloadWrapper.cpp:74
+  IntegerType *getSizeTTy() {
+switch (M.getDataLayout().getPointerTypeSize(Type::getInt8PtrTy(C))) {
+case 4u:

ABataev wrote:
> sdmitriev wrote:
> > ABataev wrote:
> > > Same question as before: maybe better to make the size of size_t type a 
> > > parameter of a tool?
> > As I remember you also had another suggestion - change size_t to intptr_t. 
> > That will eliminate the need to an additional parameter for size type. Will 
> > it be better?
> In thi case we'll need to change the type in the libomptarget.
Right. @grokos , do you see any potential problems in changing 
__tgt_offload_entry::size type from size_t to intptr_t?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68746



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


[PATCH] D68823: Fix help message for -ffp-contract

2019-10-10 Thread Artem Belevich via Phabricator via cfe-commits
tra accepted this revision.
tra added inline comments.
This revision is now accepted and ready to land.



Comment at: include/clang/Driver/Options.td:1148
+  " | on (according to FP_CONTRACT pragma) | off (never fuse). Default"
+  " is 'fast' for CUDA/HIP and 'on' otherwise.">, Values<"fast,on,off">;
 

yaxunl wrote:
> tra wrote:
> > Could you point me where we set it? I'm having trouble finding the code 
> > that controls it for CUDA.
> https://github.com/llvm-mirror/clang/blob/dea3d1b9fed4a2c2ede2976abc2baba61bd85ac2/lib/Frontend/CompilerInvocation.cpp#L2295
Thank you. LGTM.


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

https://reviews.llvm.org/D68823



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


[PATCH] D68838: [ARM] Fix arm_neon.h with -flax-vector-conversions=none, part 3

2019-10-10 Thread Eli Friedman via Phabricator via cfe-commits
efriedma created this revision.
efriedma added reviewers: rsmith, SjoerdMeijer.
Herald added a subscriber: kristof.beyls.
Herald added a project: clang.

It's completely impossible to check that I've actually found all the issues, 
due to the use of macros in arm_neon.h, but hopefully this time it'll take more 
than a few hours for someone to find another issue.

I have no idea why, but apparently there's a rule that some, but not all, 
builtins which should take an fp16 vector actually take an int8 vector as an 
argument.  Fix this, and add test coverage.


Repository:
  rC Clang

https://reviews.llvm.org/D68838

Files:
  test/CodeGen/aarch64-v8.2a-neon-intrinsics.c
  utils/TableGen/NeonEmitter.cpp


Index: utils/TableGen/NeonEmitter.cpp
===
--- utils/TableGen/NeonEmitter.cpp
+++ utils/TableGen/NeonEmitter.cpp
@@ -1442,7 +1442,8 @@
 }
 
 // Check if an explicit cast is needed.
-if (CastToType.isVector() && LocalCK == ClassB) {
+if (CastToType.isVector() &&
+(LocalCK == ClassB || (T.isHalf() && !T.isScalarForMangling( {
   CastToType.makeInteger(8, true);
   Arg = "(" + CastToType.str() + ")" + Arg;
 } else if (CastToType.isVector() && LocalCK == ClassI) {
Index: test/CodeGen/aarch64-v8.2a-neon-intrinsics.c
===
--- test/CodeGen/aarch64-v8.2a-neon-intrinsics.c
+++ test/CodeGen/aarch64-v8.2a-neon-intrinsics.c
@@ -1,5 +1,5 @@
 // RUN: %clang_cc1 -triple arm64-none-linux-gnu -target-feature +neon 
-target-feature +fullfp16 -target-feature +v8.2a\
-// RUN: -fallow-half-arguments-and-returns -S -disable-O0-optnone -emit-llvm 
-o - %s \
+// RUN: -fallow-half-arguments-and-returns -flax-vector-conversions=none -S 
-disable-O0-optnone -emit-llvm -o - %s \
 // RUN: | opt -S -mem2reg \
 // RUN: | FileCheck %s
 
@@ -146,14 +146,14 @@
 // CHECK-LABEL: test_vcvt_u16_f16
 // CHECK:  [[VCVT:%.*]] = fptoui <4 x half> %a to <4 x i16>
 // CHECK:  ret <4 x i16> [[VCVT]]
-int16x4_t test_vcvt_u16_f16 (float16x4_t a) {
+uint16x4_t test_vcvt_u16_f16 (float16x4_t a) {
   return vcvt_u16_f16(a);
 }
 
 // CHECK-LABEL: test_vcvtq_u16_f16
 // CHECK:  [[VCVT:%.*]] = fptoui <8 x half> %a to <8 x i16>
 // CHECK:  ret <8 x i16> [[VCVT]]
-int16x8_t test_vcvtq_u16_f16 (float16x8_t a) {
+uint16x8_t test_vcvtq_u16_f16 (float16x8_t a) {
   return vcvtq_u16_f16(a);
 }
 
@@ -167,7 +167,7 @@
 // CHECK-LABEL: test_vcvta_u16_f16
 // CHECK:  [[VCVT:%.*]] = call <4 x i16> 
@llvm.aarch64.neon.fcvtau.v4i16.v4f16(<4 x half> %a)
 // CHECK:  ret <4 x i16> [[VCVT]]
-int16x4_t test_vcvta_u16_f16 (float16x4_t a) {
+uint16x4_t test_vcvta_u16_f16 (float16x4_t a) {
   return vcvta_u16_f16(a);
 }
 


Index: utils/TableGen/NeonEmitter.cpp
===
--- utils/TableGen/NeonEmitter.cpp
+++ utils/TableGen/NeonEmitter.cpp
@@ -1442,7 +1442,8 @@
 }
 
 // Check if an explicit cast is needed.
-if (CastToType.isVector() && LocalCK == ClassB) {
+if (CastToType.isVector() &&
+(LocalCK == ClassB || (T.isHalf() && !T.isScalarForMangling( {
   CastToType.makeInteger(8, true);
   Arg = "(" + CastToType.str() + ")" + Arg;
 } else if (CastToType.isVector() && LocalCK == ClassI) {
Index: test/CodeGen/aarch64-v8.2a-neon-intrinsics.c
===
--- test/CodeGen/aarch64-v8.2a-neon-intrinsics.c
+++ test/CodeGen/aarch64-v8.2a-neon-intrinsics.c
@@ -1,5 +1,5 @@
 // RUN: %clang_cc1 -triple arm64-none-linux-gnu -target-feature +neon -target-feature +fullfp16 -target-feature +v8.2a\
-// RUN: -fallow-half-arguments-and-returns -S -disable-O0-optnone -emit-llvm -o - %s \
+// RUN: -fallow-half-arguments-and-returns -flax-vector-conversions=none -S -disable-O0-optnone -emit-llvm -o - %s \
 // RUN: | opt -S -mem2reg \
 // RUN: | FileCheck %s
 
@@ -146,14 +146,14 @@
 // CHECK-LABEL: test_vcvt_u16_f16
 // CHECK:  [[VCVT:%.*]] = fptoui <4 x half> %a to <4 x i16>
 // CHECK:  ret <4 x i16> [[VCVT]]
-int16x4_t test_vcvt_u16_f16 (float16x4_t a) {
+uint16x4_t test_vcvt_u16_f16 (float16x4_t a) {
   return vcvt_u16_f16(a);
 }
 
 // CHECK-LABEL: test_vcvtq_u16_f16
 // CHECK:  [[VCVT:%.*]] = fptoui <8 x half> %a to <8 x i16>
 // CHECK:  ret <8 x i16> [[VCVT]]
-int16x8_t test_vcvtq_u16_f16 (float16x8_t a) {
+uint16x8_t test_vcvtq_u16_f16 (float16x8_t a) {
   return vcvtq_u16_f16(a);
 }
 
@@ -167,7 +167,7 @@
 // CHECK-LABEL: test_vcvta_u16_f16
 // CHECK:  [[VCVT:%.*]] = call <4 x i16> @llvm.aarch64.neon.fcvtau.v4i16.v4f16(<4 x half> %a)
 // CHECK:  ret <4 x i16> [[VCVT]]
-int16x4_t test_vcvta_u16_f16 (float16x4_t a) {
+uint16x4_t test_vcvta_u16_f16 (float16x4_t a) {
   return vcvta_u16_f16(a);
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D68746: [Clang][OpenMP Offload] Move offload registration code to the wrapper

2019-10-10 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: clang/tools/clang-offload-wrapper/ClangOffloadWrapper.cpp:74
+  IntegerType *getSizeTTy() {
+switch (M.getDataLayout().getPointerTypeSize(Type::getInt8PtrTy(C))) {
+case 4u:

sdmitriev wrote:
> ABataev wrote:
> > Same question as before: maybe better to make the size of size_t type a 
> > parameter of a tool?
> As I remember you also had another suggestion - change size_t to intptr_t. 
> That will eliminate the need to an additional parameter for size type. Will 
> it be better?
In thi case we'll need to change the type in the libomptarget.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68746



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


[PATCH] D68807: [ClangTidy] Separate tests for infrastructure and checkers

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

Description says:

> making it easier to find infrastructure tests
>  Tests for infrastructure were difficult to find because they were 
> outnumbered by tests for checkers.

So presumably there far fewer infra tests as compared to checker tests,
and the issue is specifically with infra tests.
Why not improve that *specifically*?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68807



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


[PATCH] D68746: [Clang][OpenMP Offload] Move offload registration code to the wrapper

2019-10-10 Thread Sergey Dmitriev via Phabricator via cfe-commits
sdmitriev added inline comments.



Comment at: clang/tools/clang-offload-wrapper/ClangOffloadWrapper.cpp:174
+  /// Global variable that represents BinDesc is returned.
+  GlobalVariable *createBinDesc(ArrayRef> Bufs) {
+// Create external begin/end symbols for the offload entries table.

ABataev wrote:
> Why `ArrayRef`, not `StringRef`? It has a constructor for 
> pointer/length pair.
Well, in this context StringRef type would be similar to ArrayRef, but 
with extra operations for string manipulations. Since we know that device 
images are not strings, we do not really need any string operations for image 
buffers and therefore I think ArrayRef is a better choice here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68746



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


[PATCH] D68832: [tsan,msan] Insert module constructors in a module pass

2019-10-10 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan accepted this revision.
leonardchan added a comment.
This revision is now accepted and ready to land.

Thanks for finding the root cause of this!




Comment at: llvm/lib/Transforms/Instrumentation/ThreadSanitizer.cpp:143
+
+static void insertModuleCtor(Module ) {
+  getOrCreateSanitizerCtorAndInitFunctions(

nit: static unneeded here



Comment at: llvm/lib/Transforms/Instrumentation/ThreadSanitizer.cpp:163
+PreservedAnalyses ThreadSanitizerPass::run(Module ,
+   AnalysisManager ) {
+  insertModuleCtor(M);

nit: `ModuleAnalysisManager `


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68832



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


[PATCH] D68401: [Hexagon] Fix clang driver to parse -mcpu/-mvXX and -march properly.

2019-10-10 Thread Brian Cain via Phabricator via cfe-commits
bcain accepted this revision.
bcain added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rC Clang

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

https://reviews.llvm.org/D68401



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


[PATCH] D68835: [clang-scan-deps] Add basic support for Clang modules.

2019-10-10 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added inline comments.



Comment at: lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp:135
+  return llvm::StringSwitch(Ext)
+.CasesLower(".c", ".cc", ".cpp", ".c++", ".cxx", true)
+.CasesLower(".h", ".hh", ".hpp", ".h++", ".hxx", true)

Let me do some experiments to find files in our codebase that have some weird 
extensions we should minimize as well, to check what else could be there.



Comment at: test/ClangScanDeps/Inputs/modules_cdb.json:4
+  "directory": "DIR",
+  "command": "clang -E -fsyntax-only DIR/modules_cdb_input2.cpp -IInputs -D 
INCLUDE_HEADER2 -MD -MF DIR/modules_cdb2.d -fmodules 
-fmodules-cache-path=DIR/module-cache",
+  "file": "DIR/modules_cdb_input2.cpp"

You probably want to put in -fimplicit-modules explicitly as the driver might 
not infer it outside of Darwin.


Repository:
  rC Clang

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

https://reviews.llvm.org/D68835



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


[PATCH] D68823: Fix help message for -ffp-contract

2019-10-10 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl marked an inline comment as done.
yaxunl added inline comments.



Comment at: include/clang/Driver/Options.td:1148
+  " | on (according to FP_CONTRACT pragma) | off (never fuse). Default"
+  " is 'fast' for CUDA/HIP and 'on' otherwise.">, Values<"fast,on,off">;
 

tra wrote:
> Could you point me where we set it? I'm having trouble finding the code that 
> controls it for CUDA.
https://github.com/llvm-mirror/clang/blob/dea3d1b9fed4a2c2ede2976abc2baba61bd85ac2/lib/Frontend/CompilerInvocation.cpp#L2295


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

https://reviews.llvm.org/D68823



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


[PATCH] D68807: [ClangTidy] Separate tests for infrastructure and checkers

2019-10-10 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr added a comment.

Why does the number of moves matter? Git preserves history across moves.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68807



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


[PATCH] D68835: [clang-scan-deps] Add basic support for Clang modules.

2019-10-10 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added inline comments.



Comment at: test/ClangScanDeps/modules.cpp:39
+// CHECK2: modules_cdb_input.cpp
+// CHECK2-NEXT: Inputs/module.modulemap
+// CHECK2-NEXT: Inputs{{/|\\}}header.h

Missing windows path slash thing.


Repository:
  rC Clang

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

https://reviews.llvm.org/D68835



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


[PATCH] D68824: Fix __builtin_assume_aligned with too large values.

2019-10-10 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

This seems to be missing a CodeGen test for what IR we generate on an 
overly-large alignment. (The warning says the alignment is ignored, but I don't 
see where you're actually doing anything different in that case when generating 
IR.)




Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:2857-2859
+: Warning<"requested alignment must be %0 bytes or smaller; assumption "
+  "ignored">,
+  InGroup>;

Ignoring the assumption in this case seems unnecessarily user-hostile (and 
would require hard-coding an arbitrary LLVM limit in the source code to work 
around). Couldn't we just assume the highest alignment that we do support 
instead?



Comment at: clang/lib/CodeGen/CGStmtOpenMP.cpp:1522
   for (const auto *Clause : D.getClausesOfKind()) {
-unsigned ClauseAlignment = 0;
+size_t ClauseAlignment = 0;
 if (const Expr *AlignmentExpr = Clause->getAlignment()) {

It's not appropriate to assume that `size_t` is any bigger than `unsigned` or 
generally that it's meaningful on the target. If you want 64 bits here, use 
`uint64_t`, but the right choice is probably `llvm::APInt`.



Comment at: clang/lib/Sema/SemaChecking.cpp:6067-6070
+// Alignment calculations can wrap around if it's greater than 2**28.
+unsigned MaximumAlignment =
+Context.getTargetInfo().getTriple().isOSBinFormatCOFF() ? 8192
+: 268435456;

Why is there a different limit depending on bin format? We can support this at 
the IR level regardless, can't we? (I don't see how the binary format is 
relevant.)


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

https://reviews.llvm.org/D68824



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


[PATCH] D68835: [clang-scan-deps] Add basic support for Clang modules.

2019-10-10 Thread Michael Spencer via Phabricator via cfe-commits
Bigcheese created this revision.
Bigcheese added a reviewer: arphaman.
Herald added subscribers: tschuett, dexonsmith.
Herald added a project: clang.

This fixes two issues that prevent simple uses of Clang modules from working.

- We would previously minimize _every_ file opened by clang, even module maps 
and module pcm files. Now we only minimize files with known extensions. It 
would be better if we knew which files clang intended to open as a source file, 
but this works for now.

- We previously cached every lookup, even failed lookups. This is a problem 
because clang stats the module cache directory before building a module and 
creating that directory. If we cache that failure then the subsequent pcm load 
doesn't see the module cache and fails.

Overall this still leaves us building minmized modules on disk during scanning.
This will need to be improved eventually for performance, but this is correct,
and works for now.


Repository:
  rC Clang

https://reviews.llvm.org/D68835

Files:
  lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp
  test/ClangScanDeps/Inputs/module.modulemap
  test/ClangScanDeps/Inputs/modules_cdb.json
  test/ClangScanDeps/modules.cpp

Index: test/ClangScanDeps/modules.cpp
===
--- /dev/null
+++ test/ClangScanDeps/modules.cpp
@@ -0,0 +1,41 @@
+// RUN: rm -rf %t.dir
+// RUN: rm -rf %t.cdb
+// RUN: rm -rf %t.module-cache
+// RUN: mkdir -p %t.dir
+// RUN: cp %s %t.dir/modules_cdb_input.cpp
+// RUN: cp %s %t.dir/modules_cdb_input2.cpp
+// RUN: mkdir %t.dir/Inputs
+// RUN: cp %S/Inputs/header.h %t.dir/Inputs/header.h
+// RUN: cp %S/Inputs/header2.h %t.dir/Inputs/header2.h
+// RUN: cp %S/Inputs/module.modulemap %t.dir/Inputs/module.modulemap
+// RUN: sed -e "s|DIR|%/t.dir|g" %S/Inputs/modules_cdb.json > %t.cdb
+//
+// RUN: clang-scan-deps -compilation-database %t.cdb -j 1 -mode preprocess-minimized-sources | \
+// RUN:   FileCheck --check-prefixes=CHECK1,CHECK2,CHECK2NO %s
+//
+// The output order is non-deterministic when using more than one thread,
+// so check the output using two runs. Note that the 'NOT' check is not used
+// as it might fail if the results for `modules_cdb_input.cpp` are reported before
+// `modules_cdb_input2.cpp`.
+//
+// RUN: clang-scan-deps -compilation-database %t.cdb -j 2 -mode preprocess-minimized-sources | \
+// RUN:   FileCheck --check-prefix=CHECK1 %s
+// RUN: clang-scan-deps -compilation-database %t.cdb -j 2 -mode preprocess | \
+// RUN:   FileCheck --check-prefix=CHECK1 %s
+// RUN: clang-scan-deps -compilation-database %t.cdb -j 2 -mode preprocess-minimized-sources | \
+// RUN:   FileCheck --check-prefix=CHECK2 %s
+// RUN: clang-scan-deps -compilation-database %t.cdb -j 2 -mode preprocess | \
+// RUN:   FileCheck --check-prefix=CHECK2 %s
+
+#include "header.h"
+
+// CHECK1: modules_cdb_input2.cpp
+// CHECK1-NEXT: modules_cdb_input2.cpp
+// CHECK1-NEXT: Inputs{{/|\\}}module.modulemap
+// CHECK1-NEXT: Inputs{{/|\\}}header2.h
+// CHECK1: Inputs{{/|\\}}header.h
+
+// CHECK2: modules_cdb_input.cpp
+// CHECK2-NEXT: Inputs/module.modulemap
+// CHECK2-NEXT: Inputs{{/|\\}}header.h
+// CHECK2NO-NOT: header2
Index: test/ClangScanDeps/Inputs/modules_cdb.json
===
--- /dev/null
+++ test/ClangScanDeps/Inputs/modules_cdb.json
@@ -0,0 +1,13 @@
+[
+{
+  "directory": "DIR",
+  "command": "clang -E -fsyntax-only DIR/modules_cdb_input2.cpp -IInputs -D INCLUDE_HEADER2 -MD -MF DIR/modules_cdb2.d -fmodules -fmodules-cache-path=DIR/module-cache",
+  "file": "DIR/modules_cdb_input2.cpp"
+},
+{
+  "directory": "DIR",
+  "command": "clang -E DIR/modules_cdb_input.cpp -IInputs -fmodules -fmodules-cache-path=DIR/module-cache",
+  "file": "DIR/modules_cdb_input.cpp"
+}
+]
+
Index: test/ClangScanDeps/Inputs/module.modulemap
===
--- /dev/null
+++ test/ClangScanDeps/Inputs/module.modulemap
@@ -0,0 +1,7 @@
+module header1 {
+  header "header.h"
+}
+
+module header2 {
+header "header2.h"
+}
Index: lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp
===
--- lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp
+++ lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp
@@ -122,6 +122,31 @@
   return It.first->getValue();
 }
 
+/// Whitelist file extensions that should be minimized, treating no extension as
+/// a source file that should be minimized.
+///
+/// This is kinda hacky, it would be better if we knew what kind of file Clang
+/// was expecting instead.
+static bool shouldMinimize(StringRef Filename) {
+  StringRef Ext = llvm::sys::path::extension(Filename);
+  if (Ext.empty())
+return true; // C++ standard library
+  return llvm::StringSwitch(Ext)
+.CasesLower(".c", ".cc", ".cpp", ".c++", ".cxx", true)
+.CasesLower(".h", ".hh", ".hpp", ".h++", ".hxx", true)
+

[PATCH] D67537: [WIP] [clangd] Client-side support for inactive regions

2019-10-10 Thread Nathan Ridge via Phabricator via cfe-commits
nridge updated this revision to Diff 224483.
nridge added a comment.

Updated to reflect changes to server side in D67536 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67537

Files:
  clang-tools-extra/clangd/clients/clangd-vscode/src/semantic-highlighting.ts
  
clang-tools-extra/clangd/clients/clangd-vscode/test/semantic-highlighting.test.ts

Index: clang-tools-extra/clangd/clients/clangd-vscode/test/semantic-highlighting.test.ts
===
--- clang-tools-extra/clangd/clients/clangd-vscode/test/semantic-highlighting.test.ts
+++ clang-tools-extra/clangd/clients/clangd-vscode/test/semantic-highlighting.test.ts
@@ -116,7 +116,8 @@
 tokens : [
   {character : 1, length : 2, scopeIndex : 1},
   {character : 10, length : 2, scopeIndex : 2},
-]
+],
+isInactive: false
   },
   {
 line : 2,
@@ -124,7 +125,8 @@
   {character : 3, length : 2, scopeIndex : 1},
   {character : 6, length : 2, scopeIndex : 1},
   {character : 8, length : 2, scopeIndex : 2},
-]
+],
+isInactive: false
   },
 ];
 
@@ -139,7 +141,8 @@
   line : 1,
   tokens : [
 {character : 2, length : 1, scopeIndex : 0},
-  ]
+  ],
+  isInactive: false
 };
 highlighter.highlight('file2', [ highlightingsInLine1 ]);
 assert.deepEqual(highlighter.applicationUriHistory,
Index: clang-tools-extra/clangd/clients/clangd-vscode/src/semantic-highlighting.ts
===
--- clang-tools-extra/clangd/clients/clangd-vscode/src/semantic-highlighting.ts
+++ clang-tools-extra/clangd/clients/clangd-vscode/src/semantic-highlighting.ts
@@ -23,6 +23,8 @@
   // with its start position, length and the "lookup table" index of of the
   // semantic highlighting Text Mate scopes.
   tokens?: string;
+  // Whether the line is part of an inactive preprocessor branch.
+  isInactive?: boolean;
 }
 
 // A SemanticHighlightingToken decoded from the base64 data sent by clangd.
@@ -40,6 +42,8 @@
   line: number;
   // All SemanticHighlightingTokens on the line.
   tokens: SemanticHighlightingToken[];
+  // Whether the line is part of an inactive preprocessor branch.
+  isInactive: boolean;
 }
 
 // Language server push notification providing the semantic highlighting
@@ -123,7 +127,7 @@
 
   handleNotification(params: SemanticHighlightingParams) {
 const lines: SemanticHighlightingLine[] = params.lines.map(
-(line) => ({line : line.line, tokens : decodeTokens(line.tokens)}));
+(line) => ({line : line.line, tokens : decodeTokens(line.tokens), isInactive: line.isInactive || false}));
 this.highlighter.highlight(params.textDocument.uri, lines);
   }
   // Disposes of all disposable resources used by this object.
@@ -161,6 +165,7 @@
   // SemanticHighlightingToken with scopeIndex i should have the decoration at
   // index i in this list.
   private decorationTypes: vscode.TextEditorDecorationType[] = [];
+  private inactiveCodeDecorationType: vscode.TextEditorDecorationType;
   // The clangd TextMate scope lookup table.
   private scopeLookupTable: string[][];
   constructor(scopeLookupTable: string[][]) {
@@ -192,6 +197,18 @@
   };
   return vscode.window.createTextEditorDecorationType(options);
 });
+this.inactiveCodeDecorationType = vscode.window.createTextEditorDecorationType({
+  isWholeLine: true,
+  // TODO: Avoid hardcoding these colors.
+  light: {
+color: "rgb(100, 100, 100)",
+backgroundColor: "rgba(220, 220, 220, 0.3)"
+  },
+  dark: {
+color: "rgb(100, 100, 100)",
+backgroundColor: "rgba(18, 18, 18, 0.3)"
+  }
+});
 this.getVisibleTextEditorUris().forEach((fileUri) =>
 this.applyHighlights(fileUri));
   }
@@ -222,11 +239,12 @@
 // TextEditorDecorationType are very expensive to create (which makes
 // incremental updates infeasible). For this reason one
 // TextEditorDecorationType is used per scope.
-const ranges = this.getDecorationRanges(fileUri);
+const [ranges, inactiveRanges] = this.getDecorationRanges(fileUri);
 vscode.window.visibleTextEditors.forEach((e) => {
   if (e.document.uri.toString() !== fileUri)
 return;
   this.decorationTypes.forEach((d, i) => e.setDecorations(d, ranges[i]));
+  e.setDecorations(this.inactiveCodeDecorationType, inactiveRanges);
 });
   }
 
@@ -245,23 +263,29 @@
 
   // Returns the ranges that should be used when decorating. Index i in the
   // range array has the decoration type at index i of this.decorationTypes.
-  protected getDecorationRanges(fileUri: string): vscode.Range[][] {
+  protected getDecorationRanges(fileUri: string): [vscode.Range[][], 

[PATCH] D67536: [WIP] [clangd] Add support for an inactive regions notification

2019-10-10 Thread Nathan Ridge via Phabricator via cfe-commits
nridge added a comment.

Ok, I updated the patch to convey the line highlight separately from the token 
highlights.

I did use the simplified approach I mentioned, where I use a single 
`isInactive` flag. If you'd prefer the more general approach where we send an 
array of line styles, I can do that, though my personal preference would be to 
wait until we have an actual use case before generalizing.

There are still no tests yet, as I'm still not sure whether we have agreement 
on the approach. If you like the approach, please let me know, and I'll follow 
up with tests.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67536



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


Re: [PATCH] D68824: Fix __builtin_assume_aligned with too large values.

2019-10-10 Thread Keane, Erich via cfe-commits
Thanks! On the way home for the evening, so I'll fix it up tomorrow.

On Oct 10, 2019 2:34 PM, Nico Weber via Phabricator  
wrote:
thakis added a comment.

Since you just left IRC, I reverted this in 374456 for now.


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

https://reviews.llvm.org/D68824



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


r374457 - Fix some errors in tests that cause them to fail with lax

2019-10-10 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Thu Oct 10 14:40:56 2019
New Revision: 374457

URL: http://llvm.org/viewvc/llvm-project?rev=374457=rev
Log:
Fix some errors in  tests that cause them to fail with lax
vector conversions disabled.

Modified:
cfe/trunk/test/CodeGen/aarch64-v8.2a-neon-intrinsics.c
cfe/trunk/test/CodeGen/arm64-vrnd.c

Modified: cfe/trunk/test/CodeGen/aarch64-v8.2a-neon-intrinsics.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/aarch64-v8.2a-neon-intrinsics.c?rev=374457=374456=374457=diff
==
--- cfe/trunk/test/CodeGen/aarch64-v8.2a-neon-intrinsics.c (original)
+++ cfe/trunk/test/CodeGen/aarch64-v8.2a-neon-intrinsics.c Thu Oct 10 14:40:56 
2019
@@ -146,14 +146,14 @@ int16x8_t test_vcvtq_s16_f16 (float16x8_
 // CHECK-LABEL: test_vcvt_u16_f16
 // CHECK:  [[VCVT:%.*]] = fptoui <4 x half> %a to <4 x i16>
 // CHECK:  ret <4 x i16> [[VCVT]]
-int16x4_t test_vcvt_u16_f16 (float16x4_t a) {
+uint16x4_t test_vcvt_u16_f16 (float16x4_t a) {
   return vcvt_u16_f16(a);
 }
 
 // CHECK-LABEL: test_vcvtq_u16_f16
 // CHECK:  [[VCVT:%.*]] = fptoui <8 x half> %a to <8 x i16>
 // CHECK:  ret <8 x i16> [[VCVT]]
-int16x8_t test_vcvtq_u16_f16 (float16x8_t a) {
+uint16x8_t test_vcvtq_u16_f16 (float16x8_t a) {
   return vcvtq_u16_f16(a);
 }
 
@@ -167,7 +167,7 @@ int16x4_t test_vcvta_s16_f16 (float16x4_
 // CHECK-LABEL: test_vcvta_u16_f16
 // CHECK:  [[VCVT:%.*]] = call <4 x i16> 
@llvm.aarch64.neon.fcvtau.v4i16.v4f16(<4 x half> %a)
 // CHECK:  ret <4 x i16> [[VCVT]]
-int16x4_t test_vcvta_u16_f16 (float16x4_t a) {
+uint16x4_t test_vcvta_u16_f16 (float16x4_t a) {
   return vcvta_u16_f16(a);
 }
 

Modified: cfe/trunk/test/CodeGen/arm64-vrnd.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/arm64-vrnd.c?rev=374457=374456=374457=diff
==
--- cfe/trunk/test/CodeGen/arm64-vrnd.c (original)
+++ cfe/trunk/test/CodeGen/arm64-vrnd.c Thu Oct 10 14:40:56 2019
@@ -1,22 +1,22 @@
-// RUN: %clang_cc1 -triple arm64-apple-ios7 -target-feature +neon 
-ffreestanding -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple arm64-apple-ios7 -target-feature +neon 
-ffreestanding -flax-vector-conversions=none -emit-llvm -o - %s | FileCheck %s
 
 #include 
 
-int64x2_t rnd5(float64x2_t a) { return vrndq_f64(a); }
+float64x2_t rnd5(float64x2_t a) { return vrndq_f64(a); }
 // CHECK: call <2 x double> @llvm.trunc.v2f64(<2 x double>
 
-int64x2_t rnd9(float64x2_t a) { return vrndnq_f64(a); }
+float64x2_t rnd9(float64x2_t a) { return vrndnq_f64(a); }
 // CHECK: call <2 x double> @llvm.aarch64.neon.frintn.v2f64(<2 x double>
 
-int64x2_t rnd13(float64x2_t a) { return vrndmq_f64(a); }
+float64x2_t rnd13(float64x2_t a) { return vrndmq_f64(a); }
 // CHECK: call <2 x double> @llvm.floor.v2f64(<2 x double>
 
-int64x2_t rnd18(float64x2_t a) { return vrndpq_f64(a); }
+float64x2_t rnd18(float64x2_t a) { return vrndpq_f64(a); }
 // CHECK: call <2 x double> @llvm.ceil.v2f64(<2 x double>
 
-int64x2_t rnd22(float64x2_t a) { return vrndaq_f64(a); }
+float64x2_t rnd22(float64x2_t a) { return vrndaq_f64(a); }
 // CHECK: call <2 x double> @llvm.round.v2f64(<2 x double>
 
-int64x2_t rnd25(float64x2_t a) { return vrndxq_f64(a); }
+float64x2_t rnd25(float64x2_t a) { return vrndxq_f64(a); }
 // CHECK: call <2 x double> @llvm.rint.v2f64(<2 x double>
 


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


[PATCH] D68746: [Clang][OpenMP Offload] Move offload registration code to the wrapper

2019-10-10 Thread Sergey Dmitriev via Phabricator via cfe-commits
sdmitriev added inline comments.



Comment at: clang/tools/clang-offload-wrapper/ClangOffloadWrapper.cpp:74
+  IntegerType *getSizeTTy() {
+switch (M.getDataLayout().getPointerTypeSize(Type::getInt8PtrTy(C))) {
+case 4u:

ABataev wrote:
> Same question as before: maybe better to make the size of size_t type a 
> parameter of a tool?
As I remember you also had another suggestion - change size_t to intptr_t. That 
will eliminate the need to an additional parameter for size type. Will it be 
better?



Comment at: clang/tools/clang-offload-wrapper/ClangOffloadWrapper.cpp:204
+ImagesInits.reserve(Bufs.size());
+for (const ArrayRef  : Bufs) {
+  auto *Data = ConstantDataArray::get(C, Buf);

ABataev wrote:
> No need for `const` and `&` here.
Right.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68746



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


[PATCH] D68824: Fix __builtin_assume_aligned with too large values.

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

Since you just left IRC, I reverted this in 374456 for now.


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

https://reviews.llvm.org/D68824



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


[PATCH] D67536: [WIP] [clangd] Add support for an inactive regions notification

2019-10-10 Thread Nathan Ridge via Phabricator via cfe-commits
nridge updated this revision to Diff 224480.
nridge added a comment.

Updated to use as isInactive flag on SemanticHighlightingInformation


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67536

Files:
  clang-tools-extra/clangd/ParsedAST.cpp
  clang-tools-extra/clangd/ParsedAST.h
  clang-tools-extra/clangd/Protocol.cpp
  clang-tools-extra/clangd/Protocol.h
  clang-tools-extra/clangd/SemanticHighlighting.cpp
  clang-tools-extra/clangd/SemanticHighlighting.h
  clang-tools-extra/clangd/test/semantic-highlighting.test

Index: clang-tools-extra/clangd/test/semantic-highlighting.test
===
--- clang-tools-extra/clangd/test/semantic-highlighting.test
+++ clang-tools-extra/clangd/test/semantic-highlighting.test
@@ -50,6 +50,9 @@
 # CHECK-NEXT:"storage.type.primitive.cpp"
 # CHECK-NEXT:  ],
 # CHECK-NEXT:  [
+# CHECK-NEXT:"meta.disabled"
+# CHECK-NEXT:  ],
+# CHECK-NEXT:  [
 # CHECK-NEXT:"entity.name.function.preprocessor.cpp"
 # CHECK-NEXT:  ]
 # CHECK-NEXT:]
Index: clang-tools-extra/clangd/SemanticHighlighting.h
===
--- clang-tools-extra/clangd/SemanticHighlighting.h
+++ clang-tools-extra/clangd/SemanticHighlighting.h
@@ -41,8 +41,9 @@
   TemplateParameter,
   Primitive,
   Macro,
+  InactiveCode,
 
-  LastKind = Macro
+  LastKind = InactiveCode
 };
 llvm::raw_ostream <<(llvm::raw_ostream , HighlightingKind K);
 
@@ -59,6 +60,7 @@
 struct LineHighlightings {
   int Line;
   std::vector Tokens;
+  bool IsInactive;
 };
 
 bool operator==(const LineHighlightings , const LineHighlightings );
Index: clang-tools-extra/clangd/SemanticHighlighting.cpp
===
--- clang-tools-extra/clangd/SemanticHighlighting.cpp
+++ clang-tools-extra/clangd/SemanticHighlighting.cpp
@@ -137,6 +137,27 @@
   // the end of the Tokens).
   TokRef = TokRef.drop_front(Conflicting.size());
 }
+// Add inactive highlighting tokens.
+const SourceManager  = AST.getSourceManager();
+for (const SourceRange  : AST.getSkippedRanges()) {
+  if (isInsideMainFile(R.getBegin(), SM)) {
+// Create one token for each line in the skipped range, so it works
+// with line-based diffing.
+Position Begin = sourceLocToPosition(SM, R.getBegin());
+Position End = sourceLocToPosition(SM, R.getEnd());
+assert(Begin.line <= End.line);
+for (int Line = Begin.line; Line < End.line; ++Line) {
+  // Don't bother computing the offset for the end of the line, just use
+  // zero. The client will treat this highlighting kind specially, and
+  // highlight the entire line visually (i.e. not just to where the text
+  // on the line ends, but to the end of the screen).
+  NonConflicting.push_back({HighlightingKind::InactiveCode,
+{Position{Line, 0}, Position{Line, 0}}});
+}
+  }
+}
+// Re-sort the tokens because that's what the diffing expects.
+llvm::sort(NonConflicting);
 return NonConflicting;
   }
 
@@ -347,6 +368,8 @@
 return OS << "Primitive";
   case HighlightingKind::Macro:
 return OS << "Macro";
+  case HighlightingKind::InactiveCode:
+return OS << "InactiveCode";
   }
   llvm_unreachable("invalid HighlightingKind");
 }
@@ -391,8 +414,21 @@
LineNumber = NextLineNumber()) {
 NewLine = takeLine(New, NewLine.end(), LineNumber);
 OldLine = takeLine(Old, OldLine.end(), LineNumber);
-if (NewLine != OldLine)
-  DiffedLines.push_back({LineNumber, NewLine});
+if (NewLine != OldLine) {
+  DiffedLines.push_back({LineNumber, NewLine, /*IsInactive=*/false});
+
+  // Turn a HighlightingKind::InactiveCode token into the IsInactive flag.
+  auto  = DiffedLines.back();
+  for (auto Iter = AddedLine.Tokens.begin();
+   Iter != AddedLine.Tokens.end();) {
+if (Iter->Kind == HighlightingKind::InactiveCode) {
+  Iter = AddedLine.Tokens.erase(Iter);
+  AddedLine.IsInactive = true;
+} else {
+  ++Iter;
+}
+  }
+}
   }
 
   return DiffedLines;
@@ -435,7 +471,7 @@
   write16be(static_cast(Token.Kind), OS);
 }
 
-Lines.push_back({Line.Line, encodeBase64(LineByteTokens)});
+Lines.push_back({Line.Line, encodeBase64(LineByteTokens), Line.IsInactive});
   }
 
   return Lines;
@@ -476,6 +512,8 @@
 return "storage.type.primitive.cpp";
   case HighlightingKind::Macro:
 return "entity.name.function.preprocessor.cpp";
+  case HighlightingKind::InactiveCode:
+return "meta.disabled";
   }
   llvm_unreachable("unhandled HighlightingKind");
 }
Index: clang-tools-extra/clangd/Protocol.h

[PATCH] D68824: Fix __builtin_assume_aligned with too large values.

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

The new test fails on Windows:

  -- Testing: 16032 tests, 32 workers --
  Testing:  0.. 10.. 20.. 30.. 40.. 50
  FAIL: Clang :: Sema/builtin-assume-aligned.c (8862 of 16032)
   TEST 'Clang :: Sema/builtin-assume-aligned.c' FAILED 

  Script:
  --
  : 'RUN: at line 1';   c:\src\llvm-project\out\gn\bin\clang.exe -cc1 
-internal-isystem c:\src\llvm-project\out\gn\lib\clang\10.0.0\include 
-nostdsysteminc -fsyntax-only -verify 
C:\src\llvm-project\clang\test\Sema\builtin-assume-aligned.c
  --
  Exit Code: 1
  
  Command Output (stdout):
  --
  $ ":" "RUN: at line 1"
  $ "c:\src\llvm-project\out\gn\bin\clang.exe" "-cc1" "-internal-isystem" 
"c:\src\llvm-project\out\gn\lib\clang\10.0.0\include" "-nostdsysteminc" 
"-fsyntax-only" "-verify" 
"C:\src\llvm-project\clang\test\Sema\builtin-assume-aligned.c"
  # command stderr:
  error: 'warning' diagnostics expected but not seen: 
File C:\src\llvm-project\clang\test\Sema\builtin-assume-aligned.c Line 62: 
requested alignment must be 268435456 bytes or smaller; assumption ignored
  error: 'warning' diagnostics seen but not expected: 
File C:\src\llvm-project\clang\test\Sema\builtin-assume-aligned.c Line 62: 
requested alignment must be 8192 bytes or smaller; assumption ignored
  2 errors generated.
  
  error: command failed with exit status: 1
  
  --
  
  
  Testing:  0.. 10.. 20.. 30.. 40.. 50.. 60.. 70.. 80.. 90.. 
  Testing Time: 152.23s
  
  Failing Tests (1):
  Clang :: Sema/builtin-assume-aligned.c


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

https://reviews.llvm.org/D68824



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


[PATCH] D51741: [coro]Pass rvalue reference for named local variable to return_value

2019-10-10 Thread Aaron Puchert via Phabricator via cfe-commits
aaronpuchert added a comment.

@Quuxplusone Thanks for your very helpful comments!

> In which case, this patch (D51741 ) itself 
> fixed this FIXME at least partly, and maybe completely. Maybe this patch 
> should have removed or amended the FIXME, rather than just adding code above 
> it.

It seems you're right, depending on the `CopyElisionSemanticsKind` it might 
even be fixed completely.

> However, now that P1825  has been accepted 
> into C++2a, `CES_AsIfByStdMove` is the actual (draft-)standard behavior, and 
> should rightly be named something like `CES_FutureDefault`!

Ok, since coroutines are actually a C++20 feature, using `CES_AsIfByStdMove` is 
not really wrong. But it would be inconsistent with our current treatment of 
`return` statements, and maybe we should switch both at the same time. (And 
perhaps depending on the value of `-std=`, since enabling coroutines manually 
is also possible in older standards. Maybe we can have a function that returns 
that correct value for a given standard?)

So changing the `CopyElisionSemanticsKind` is not the right fix for my example. 
Which is not surprising, because the problem isn't that we're eliding a copy 
that we shouldn't elide, it's that we introduce a local copy which shouldn't be 
there. (Which might actually turn this code into UB, if the copy constructor 
was available.) We avoid this with `CES_Strict` more or less accidentally:

- Without `CES_AllowParameters` we don't get a candidate because the VarDecl is 
a parameter.
- Without `CES_AllowDifferentTypes`, 
`Context.hasSameUnqualifiedType(ReturnType, VDType)` returns false and so we 
return false from `Sema::isCopyElisionCandidate`, bceause `E->getType()` (the 
type of the DeclRefExpr) is `MoveOnly`, but the VarDecl is a `MoveOnly&`.

The actual problem is the call to `PerformMoveOrCopyInitialization`. For normal 
return statements, the caller provides us with storage for the return value 
when that is a struct/class. We then copy (or move) the return value there 
(RVO) or directly construct it there (NRVO). Returning from a coroutine however 
just calls some `return_value` member function. If we look at the existing 
test, we produce

  CoreturnStmt 0x2462f28 
  |-CXXConstructExpr 0x2462e50  'MoveOnly' 'void (MoveOnly &&) 
noexcept' elidable
  | `-ImplicitCastExpr 0x2462e38  'MoveOnly' xvalue 
  |   `-DeclRefExpr 0x245e390  'MoveOnly' lvalue Var 0x245e2e8 'value' 
'MoveOnly'
  `-ExprWithCleanups 0x2462f10  'void'
`-CXXMemberCallExpr 0x2462ed0  'void'
  |-MemberExpr 0x2462ea0  '' 
.return_value 0x245fde8
  | `-DeclRefExpr 0x2462e80  
'std::experimental::traits_sfinae_base, 
void>::promise_type':'task::promise_type' lvalue Var 0x245fec8 
'__promise' 'std::experimental::traits_sfinae_base, 
void>::promise_type':'task::promise_type'
  `-MaterializeTemporaryExpr 0x2462ef8  'MoveOnly' xvalue
`-CXXConstructExpr 0x2462e50  'MoveOnly' 'void (MoveOnly &&) 
noexcept' elidable
  `-ImplicitCastExpr 0x2462e38  'MoveOnly' xvalue 
`-DeclRefExpr 0x245e390  'MoveOnly' lvalue Var 0x245e2e8 
'value' 'MoveOnly'

There is an actual move constructor call. So instead of transforming 
`__promise.return_value(value)` into 
`__promise.return_value(std::move(value))`, we have transformed it into 
`__promise.return_value(decltype(std::move(value)))`. This constructor 
is marked elidable, but since it's not an actual return value, there is nothing 
we can elide. Indeed, the unoptimized IR (where I've demangled the function 
names) is:

  %ref.tmp9.reload.addr39 = getelementptr inbounds %_Z1fv.Frame, %_Z1fv.Frame* 
%FramePtr, i32 0, i32 7
  %ref.tmp9.reload.addr = getelementptr inbounds %_Z1fv.Frame, %_Z1fv.Frame* 
%FramePtr, i32 0, i32 7
  %value.reload.addr37 = getelementptr inbounds %_Z1fv.Frame, %_Z1fv.Frame* 
%FramePtr, i32 0, i32 6
  call void @"MoveOnly::MoveOnly(MoveOnly&&)"(%struct.MoveOnly* 
%ref.tmp9.reload.addr39, %struct.MoveOnly* dereferenceable(1) 
%value.reload.addr37) #2
  call void 
@"task::promise_type::return_value(MoveOnly&&)"(%"struct.task::promise_type"*
 %__promise, %struct.MoveOnly* dereferenceable(1) %ref.tmp9.reload.addr)

That move constructor call shouldn't be there. We shouldn't construct anything, 
if constructor calls are needed, building the call statement will do that. 
Instead of doing a move or copy initialization, we should do an rvalue 
reference initialization or implicit cast if we're returning a DeclRefExpr 
referencing a variable that we can consume.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D51741



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


r374456 - Revert 374450 "Fix __builtin_assume_aligned with too large values."

2019-10-10 Thread Nico Weber via cfe-commits
Author: nico
Date: Thu Oct 10 14:34:32 2019
New Revision: 374456

URL: http://llvm.org/viewvc/llvm-project?rev=374456=rev
Log:
Revert 374450 "Fix __builtin_assume_aligned with too large values."

The test fails on Windows, with

  error: 'warning' diagnostics expected but not seen:
File builtin-assume-aligned.c Line 62: requested alignment
must be 268435456 bytes or smaller; assumption ignored
  error: 'warning' diagnostics seen but not expected:
File builtin-assume-aligned.c Line 62: requested alignment
must be 8192 bytes or smaller; assumption ignored

Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
cfe/trunk/lib/CodeGen/CGCall.cpp
cfe/trunk/lib/CodeGen/CGExprScalar.cpp
cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.h
cfe/trunk/lib/Sema/SemaChecking.cpp
cfe/trunk/test/Sema/builtin-assume-aligned.c

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=374456=374455=374456=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Thu Oct 10 14:34:32 
2019
@@ -2853,10 +2853,6 @@ def err_alignment_dependent_typedef_name
 
 def err_attribute_aligned_too_great : Error<
   "requested alignment must be %0 bytes or smaller">;
-def warn_assume_aligned_too_great
-: Warning<"requested alignment must be %0 bytes or smaller; assumption "
-  "ignored">,
-  InGroup>;
 def warn_redeclaration_without_attribute_prev_attribute_ignored : Warning<
   "%q0 redeclared without %1 attribute: previous %1 ignored">,
   InGroup;

Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=374456=374455=374456=diff
==
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Thu Oct 10 14:34:32 2019
@@ -2048,10 +2048,11 @@ RValue CodeGenFunction::EmitBuiltinExpr(
 
 Value *AlignmentValue = EmitScalarExpr(E->getArg(1));
 ConstantInt *AlignmentCI = cast(AlignmentValue);
+unsigned Alignment = (unsigned)AlignmentCI->getZExtValue();
 
 EmitAlignmentAssumption(PtrValue, Ptr,
 /*The expr loc is sufficient.*/ SourceLocation(),
-AlignmentCI, OffsetValue);
+Alignment, OffsetValue);
 return RValue::get(PtrValue);
   }
   case Builtin::BI__assume:

Modified: cfe/trunk/lib/CodeGen/CGCall.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCall.cpp?rev=374456=374455=374456=diff
==
--- cfe/trunk/lib/CodeGen/CGCall.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCall.cpp Thu Oct 10 14:34:32 2019
@@ -4569,7 +4569,7 @@ RValue CodeGenFunction::EmitCall(const C
   llvm::Value *Alignment = EmitScalarExpr(AA->getAlignment());
   llvm::ConstantInt *AlignmentCI = cast(Alignment);
   EmitAlignmentAssumption(Ret.getScalarVal(), RetTy, Loc, 
AA->getLocation(),
-  AlignmentCI, OffsetValue);
+  AlignmentCI->getZExtValue(), OffsetValue);
 } else if (const auto *AA = TargetDecl->getAttr()) {
   llvm::Value *AlignmentVal = CallArgs[AA->getParamIndex().getLLVMIndex()]
   .getRValue(*this)

Modified: cfe/trunk/lib/CodeGen/CGExprScalar.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprScalar.cpp?rev=374456=374455=374456=diff
==
--- cfe/trunk/lib/CodeGen/CGExprScalar.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprScalar.cpp Thu Oct 10 14:34:32 2019
@@ -294,7 +294,8 @@ public:
 
 Value *AlignmentValue = CGF.EmitScalarExpr(AVAttr->getAlignment());
 llvm::ConstantInt *AlignmentCI = cast(AlignmentValue);
-CGF.EmitAlignmentAssumption(V, E, AVAttr->getLocation(), AlignmentCI);
+CGF.EmitAlignmentAssumption(V, E, AVAttr->getLocation(),
+AlignmentCI->getZExtValue());
   }
 
   /// EmitLoadOfLValue - Given an expression with complex type that represents 
a

Modified: cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp?rev=374456=374455=374456=diff
==
--- cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp Thu Oct 10 14:34:32 2019
@@ -1519,14 +1519,14 @@ static void emitAlignedClause(CodeGenFun
   if (!CGF.HaveInsertPoint())
 

Re: r374419 - [ARM] Fix arm_neon.h with -flax-vector-conversions=none, part 2.

2019-10-10 Thread Richard Smith via cfe-commits
Getting close now, I think there's just one more problem:

vmaxv_f16, vmaxq_f16, vminv_f16, vminq_f16, vmaxnmv_f16, vmaxnmvq_f16,
vminnmv_f16, and vminnmvq_f16 all have the wrong parameter type, requiring
a lax conversion from vector of signed char to vector of float16_t.

You can reproduce that by running
test/CodeGen/aarch64-v8.2a-neon-intrinsics.c with
-flax-vector-conversions=integer.

On Thu, 10 Oct 2019 at 11:43, Eli Friedman via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: efriedma
> Date: Thu Oct 10 11:45:34 2019
> New Revision: 374419
>
> URL: http://llvm.org/viewvc/llvm-project?rev=374419=rev
> Log:
> [ARM] Fix arm_neon.h with -flax-vector-conversions=none, part 2.
>
> Just running -fsyntax-only over arm_neon.h doesn't cover some intrinsics
> which are defined using macros.  Add more test coverage for that.
>
> arm-neon-header.c wasn't checking the full set of available NEON target
> features; change the target architecture of the test to account for
> that.
>
> Fix the generator for arm_neon.h to generate casts in more cases where
> they are necessary.
>
> Fix VFMLAL_LOW etc. to express their signatures differently, so the
> builtins have the expected type. Maybe the TableGen backend should
> detect intrinsics that are defined the wrong way, and produce an error.
> The rules here are sort of strange.
>
> Differential Revision: https://reviews.llvm.org/D68743
>
>
> Modified:
> cfe/trunk/include/clang/Basic/arm_neon.td
> cfe/trunk/test/CodeGen/aarch64-neon-intrinsics.c
> cfe/trunk/test/CodeGen/arm_neon_intrinsics.c
> cfe/trunk/test/Headers/arm-neon-header.c
> cfe/trunk/utils/TableGen/NeonEmitter.cpp
>
> Modified: cfe/trunk/include/clang/Basic/arm_neon.td
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/arm_neon.td?rev=374419=374418=374419=diff
>
> ==
> --- cfe/trunk/include/clang/Basic/arm_neon.td (original)
> +++ cfe/trunk/include/clang/Basic/arm_neon.td Thu Oct 10 11:45:34 2019
> @@ -1651,10 +1651,10 @@ let ArchGuard = "defined(__ARM_FEATURE_D
>
>  // v8.2-A FP16 fused multiply-add long instructions.
>  let ArchGuard = "defined(__ARM_FEATURE_FP16FML) && defined(__aarch64__)"
> in {
> -  def VFMLAL_LOW  : SInst<"vfmlal_low",  "ffHH", "hQh">;
> -  def VFMLSL_LOW  : SInst<"vfmlsl_low",  "ffHH", "hQh">;
> -  def VFMLAL_HIGH : SInst<"vfmlal_high", "ffHH", "hQh">;
> -  def VFMLSL_HIGH : SInst<"vfmlsl_high", "ffHH", "hQh">;
> +  def VFMLAL_LOW  : SInst<"vfmlal_low",  "nndd", "hQh">;
> +  def VFMLSL_LOW  : SInst<"vfmlsl_low",  "nndd", "hQh">;
> +  def VFMLAL_HIGH : SInst<"vfmlal_high", "nndd", "hQh">;
> +  def VFMLSL_HIGH : SInst<"vfmlsl_high", "nndd", "hQh">;
>
>def VFMLAL_LANE_LOW  : SOpInst<"vfmlal_lane_low",  "ffH0i", "hQh",
> OP_FMLAL_LN>;
>def VFMLSL_LANE_LOW  : SOpInst<"vfmlsl_lane_low",  "ffH0i", "hQh",
> OP_FMLSL_LN>;
>
> Modified: cfe/trunk/test/CodeGen/aarch64-neon-intrinsics.c
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/aarch64-neon-intrinsics.c?rev=374419=374418=374419=diff
>
> ==
> --- cfe/trunk/test/CodeGen/aarch64-neon-intrinsics.c (original)
> +++ cfe/trunk/test/CodeGen/aarch64-neon-intrinsics.c Thu Oct 10 11:45:34
> 2019
> @@ -1,5 +1,6 @@
>  // RUN: %clang_cc1 -triple arm64-none-linux-gnu -target-feature +neon \
> -// RUN: -fallow-half-arguments-and-returns -S -disable-O0-optnone
> -emit-llvm -o - %s \
> +// RUN: -fallow-half-arguments-and-returns -S -disable-O0-optnone \
> +// RUN:  -flax-vector-conversions=none -emit-llvm -o - %s \
>  // RUN: | opt -S -mem2reg \
>  // RUN: | FileCheck %s
>
> @@ -406,7 +407,7 @@ int8x8_t test_vmla_s8(int8x8_t v1, int8x
>  // CHECK:   [[TMP0:%.*]] = bitcast <4 x i16> [[ADD_I]] to <8 x i8>
>  // CHECK:   ret <8 x i8> [[TMP0]]
>  int8x8_t test_vmla_s16(int16x4_t v1, int16x4_t v2, int16x4_t v3) {
> -  return vmla_s16(v1, v2, v3);
> +  return (int8x8_t)vmla_s16(v1, v2, v3);
>  }
>
>  // CHECK-LABEL: @test_vmla_s32(
> @@ -527,7 +528,7 @@ int8x8_t test_vmls_s8(int8x8_t v1, int8x
>  // CHECK:   [[TMP0:%.*]] = bitcast <4 x i16> [[SUB_I]] to <8 x i8>
>  // CHECK:   ret <8 x i8> [[TMP0]]
>  int8x8_t test_vmls_s16(int16x4_t v1, int16x4_t v2, int16x4_t v3) {
> -  return vmls_s16(v1, v2, v3);
> +  return (int8x8_t)vmls_s16(v1, v2, v3);
>  }
>
>  // CHECK-LABEL: @test_vmls_s32(
> @@ -978,7 +979,7 @@ int8x8_t test_vbsl_s8(uint8x8_t v1, int8
>  // CHECK:   [[TMP4:%.*]] = bitcast <4 x i16> [[VBSL5_I]] to <8 x i8>
>  // CHECK:   ret <8 x i8> [[TMP4]]
>  int8x8_t test_vbsl_s16(uint16x4_t v1, int16x4_t v2, int16x4_t v3) {
> -  return vbsl_s16(v1, v2, v3);
> +  return (int8x8_t)vbsl_s16(v1, v2, v3);
>  }
>
>  // CHECK-LABEL: @test_vbsl_s32(
> @@ -1003,7 +1004,7 @@ int32x2_t test_vbsl_s32(uint32x2_t v1, i
>  // CHECK:   [[VBSL4_I:%.*]] = and <1 x i64> [[TMP3]], %v3
>  // CHECK:   [[VBSL5_I:%.*]] = or <1 x i64> [[VBSL3_I]], 

[PATCH] D68807: [ClangTidy] Separate tests for infrastructure and checkers

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

That's a lot of moved files.
How about *only* moving the infrastructure tests?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68807



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


[PATCH] D68660: [tooling] Teach Tooling to understand compilation with offloading.

2019-10-10 Thread Michael Liao via Phabricator via cfe-commits
hliao updated this revision to Diff 224476.
hliao marked an inline comment as done.
hliao added a comment.

revice comment.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68660

Files:
  clang/lib/Tooling/Tooling.cpp
  clang/test/Tooling/clang-check-offload.cpp


Index: clang/test/Tooling/clang-check-offload.cpp
===
--- /dev/null
+++ clang/test/Tooling/clang-check-offload.cpp
@@ -0,0 +1,4 @@
+// RUN: not clang-check "%s" -- -c -x hip -nogpulib 2>&1 | FileCheck %s
+
+// CHECK: C++ requires
+invalid;
Index: clang/lib/Tooling/Tooling.cpp
===
--- clang/lib/Tooling/Tooling.cpp
+++ clang/lib/Tooling/Tooling.cpp
@@ -91,7 +91,29 @@
   // We expect to get back exactly one Command job, if we didn't something
   // failed. Extract that job from the Compilation.
   const driver::JobList  = Compilation->getJobs();
-  if (Jobs.size() != 1 || !isa(*Jobs.begin())) {
+  const driver::ActionList  = Compilation->getActions();
+  bool OffloadCompilation = false;
+  if (Jobs.size() > 1) {
+for (auto A : Actions){
+  // On MacOSX real actions may end up being wrapped in BindArchAction
+  if (isa(A))
+A = *A->input_begin();
+  if (isa(A)) {
+// Offload compilation has 2 top-level actions, one (at the front) is
+// the original host compilation and the other is offload action
+// composed of at least one device compilation. For such case, general
+// tooling will consider host-compilation only. For tooling on device
+// compilation, device compilation only option, such as
+// `--cuda-device-only`, needs specifying.
+assert(Actions.size() == 2);
+assert(isa(Actions.front()));
+OffloadCompilation = true;
+break;
+  }
+}
+  }
+  if (Jobs.size() == 0 || !isa(*Jobs.begin()) ||
+  (Jobs.size() > 1 && !OffloadCompilation)) {
 SmallString<256> error_msg;
 llvm::raw_svector_ostream error_stream(error_msg);
 Jobs.Print(error_stream, "; ", true);


Index: clang/test/Tooling/clang-check-offload.cpp
===
--- /dev/null
+++ clang/test/Tooling/clang-check-offload.cpp
@@ -0,0 +1,4 @@
+// RUN: not clang-check "%s" -- -c -x hip -nogpulib 2>&1 | FileCheck %s
+
+// CHECK: C++ requires
+invalid;
Index: clang/lib/Tooling/Tooling.cpp
===
--- clang/lib/Tooling/Tooling.cpp
+++ clang/lib/Tooling/Tooling.cpp
@@ -91,7 +91,29 @@
   // We expect to get back exactly one Command job, if we didn't something
   // failed. Extract that job from the Compilation.
   const driver::JobList  = Compilation->getJobs();
-  if (Jobs.size() != 1 || !isa(*Jobs.begin())) {
+  const driver::ActionList  = Compilation->getActions();
+  bool OffloadCompilation = false;
+  if (Jobs.size() > 1) {
+for (auto A : Actions){
+  // On MacOSX real actions may end up being wrapped in BindArchAction
+  if (isa(A))
+A = *A->input_begin();
+  if (isa(A)) {
+// Offload compilation has 2 top-level actions, one (at the front) is
+// the original host compilation and the other is offload action
+// composed of at least one device compilation. For such case, general
+// tooling will consider host-compilation only. For tooling on device
+// compilation, device compilation only option, such as
+// `--cuda-device-only`, needs specifying.
+assert(Actions.size() == 2);
+assert(isa(Actions.front()));
+OffloadCompilation = true;
+break;
+  }
+}
+  }
+  if (Jobs.size() == 0 || !isa(*Jobs.begin()) ||
+  (Jobs.size() > 1 && !OffloadCompilation)) {
 SmallString<256> error_msg;
 llvm::raw_svector_ostream error_stream(error_msg);
 Jobs.Print(error_stream, "; ", true);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D29039: [clang-format] Proposal for clang-format -r option

2019-10-10 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

In D29039#1704166 , @zturner wrote:

> In Windows you just write a Python script to do this, and this works 
> everywhere, not just on one platform or the other, so bash isn't even 
> necessary and Python is easy to write so I wouldn't really say it's "even 
> harder".  If you google for `run-clang-format.py` you'll find a script that 
> actually branches out and does this in parallel.  There's a lot of logic and 
> smarts you could bake into an external tool which can then be used for many 
> different programs, not just clang-format.


@zturner thanks for the feedback, I took a look and run-clang-format.py at 
(https://github.com/Sarcasm/run-clang-format), and whilst I have a reasonable 
knowledge of python, reading the python code just makes me ask why isn't all of 
this just in clang-format in the first place?

To me I think these are unaddressed clang-format requirements that other 
third-party developers are providing, without having to conform to some agreed 
upstream set of rules or gaining consensus. The author has coded it the way 
they want, how they want and can add to it to do what they want (good on them). 
But that doesn't mean that's the only approach or best choice of technology, or 
that someone should follow the same model or develop something similar. Its one 
option, a good option, but not the only option.

I've personally been burnt on Windows using a combination of python in both the 
python windows distribution and cygwin together, the windows version doesn't 
understand Cygwin paths (as expected). I know I do my own development in clang 
with 1 Visual Studio Command Prompt setup to pick up VS2019 and one bash prompt 
to ensure it picks up python correctly,  (I don't use CMake to make visual 
studio projects but use the Code Blocks CMake options as that works nicely with 
cygwin, allowing me to do a make -jN which is essential, the visual studio 
projects are pretty unworkable)

I have to build in the windows shell so it finds the correct compiler cl.exe 
and not the cygwin's gcc, but I can't run `git clang-format` or `git llvm push` 
in those windows shells as the python breaks. and that all comes down to the 
interaction of different pythons. (and I just cannot justify to myself 
proliferating that pain to others by using python as a solution when we have a 
perfectly good solution in C++) . Ask yourself how many people have trouble 
getting the lit tests to work in LLVM on windows I know I do. Which I'm sure is 
resolved by some configuration magic but I haven't found it yet.

But I am grateful for the evidence that needing this capability is obviously 
required (otherwise someone wouldn't have written this script)

if we take a look at the script what is it doing... the script is ~ 350 lines

1. A certain section is covering recursive running (about 20-40 lines)
2. A reasonable amount  is simply handling the command line arguments (30-50 
lines)
3. About 40 lines is colourizing a diff
4. And about 70-100 lines is handling running in parallel

The command-line options it supports just:

--clang-format-executable (to tell it where to find the executable)
-extensions to tell it what to file types to handle (which actually their list 
is out of date as it only covers some C++ code and not js,C#,protobuf etc)
-r for recursive
-q for quiet 
-j for the number of parallel jobs
-color for showing a colored diff
--exclude for paths to exclude.

Of that which parts are useful? the colored diff? maybe.. the parallelizm is 
nice but that's not essential in my view on a fast machine and there are other 
ways of doing that especially in makefiles which are already running -j N maybe 
you could even use gnu parallel for that?

So basically we are down to --extensions, -r, --exclude ... as perhaps the real 
benefit, I think its this functionality that this revision is/should be adding. 
I think its relatively simple and is already partially covered in about 30+ 
lines above.

But the existence of this script just means I'm even more sold on the fact that 
we should do it..so I really appreciate you bringing that to my attention.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D29039



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


[PATCH] D68660: [tooling] Teach Tooling to understand compilation with offloading.

2019-10-10 Thread Michael Liao via Phabricator via cfe-commits
hliao marked an inline comment as done.
hliao added inline comments.



Comment at: clang/lib/Tooling/Tooling.cpp:102
+  if (isa(A)) {
+assert(Actions.size() == 2);
+assert(isa(Actions.front()));

tra wrote:
> Why 2? Will it not be different if user targeted multiple GPUs?
> 
that's the number of top-level actions. no matter how many GPUs are specified, 
that offload action is the top-level action masters all of them.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68660



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


[PATCH] D67678: PR17164: Change clang's default behavior from -flax-vector-conversions=all to -flax-vector-conversions=integer.

2019-10-10 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith updated this revision to Diff 224473.
rsmith added a comment.

Test fixup.


Repository:
  rC Clang

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

https://reviews.llvm.org/D67678

Files:
  docs/CommandGuide/clang.rst
  docs/ReleaseNotes.rst
  include/clang/Basic/LangOptions.def
  test/Headers/altivec-header.c
  test/Headers/arm-neon-header.c
  test/Headers/x86-intrinsics-headers.c
  test/Headers/x86intrin-2.c
  test/Headers/x86intrin.c
  test/Sema/vector-assign.c
  test/Sema/vector-cast.c
  test/Sema/vector-ops.c

Index: test/Sema/vector-ops.c
===
--- test/Sema/vector-ops.c
+++ test/Sema/vector-ops.c
@@ -1,4 +1,5 @@
-// RUN: %clang_cc1 %s -verify -fsyntax-only -Wvector-conversion -triple x86_64-apple-darwin10
+// RUN: %clang_cc1 %s -verify -fsyntax-only -Wvector-conversion -triple x86_64-apple-darwin10 -flax-vector-conversions=all
+// FIXME: We get worse diagnostics here with -flax-vector-conversions disabled.
 typedef unsigned int v2u __attribute__ ((vector_size (8)));
 typedef int v2s __attribute__ ((vector_size (8)));
 typedef float v2f __attribute__ ((vector_size(8)));
Index: test/Sema/vector-cast.c
===
--- test/Sema/vector-cast.c
+++ test/Sema/vector-cast.c
@@ -1,4 +1,5 @@
-// RUN: %clang_cc1 -fsyntax-only %s -verify -Wvector-conversion
+// RUN: %clang_cc1 -fsyntax-only %s -verify=expected,no-lax -Wvector-conversion -flax-vector-conversions=none
+// RUN: %clang_cc1 -fsyntax-only %s -verify=expected,lax -Wvector-conversion -flax-vector-conversions=all
 
 typedef long long t1 __attribute__ ((vector_size (8)));
 typedef char t2 __attribute__ ((vector_size (16)));
@@ -41,7 +42,9 @@
 void f2(t2 X); // expected-note{{passing argument to parameter 'X' here}}
 
 void f3(t3 Y) {
-  f2(Y);  // expected-warning {{incompatible vector types passing 't3' (vector of 4 'float' values) to parameter of type 't2' (vector of 16 'char' values)}}
+  f2(Y);
+  // lax-warning@-1 {{incompatible vector types passing 't3' (vector of 4 'float' values) to parameter of type 't2' (vector of 16 'char' values)}}
+  // no-lax-error@-2 {{passing 't3' (vector of 4 'float' values) to parameter of incompatible type 't2' (vector of 16 'char' values)}}
 }
 
 typedef float float2 __attribute__ ((vector_size (8)));
@@ -58,13 +61,15 @@
   float64x2_t v = {0.0, 1.0};
   f2 += d; // expected-error {{cannot convert between scalar type 'double' and vector type 'float2' (vector of 2 'float' values) as implicit conversion would cause truncation}}
   d += f2; // expected-error {{assigning to 'double' from incompatible type 'float2' (vector of 2 'float' values)}}
-  a = 3.0 + vget_low_f64(v);
-  b = vget_low_f64(v) + 3.0;
-  c = vget_low_f64(v);
-  c -= vget_low_f64(v);
+  a = 3.0 + vget_low_f64(v); // no-lax-error {{assigning to 'double' from incompatible type 'float64x1_t' (vector of 1 'double' value)}}
+  b = vget_low_f64(v) + 3.0; // no-lax-error {{assigning to 'double' from incompatible type 'float64x1_t' (vector of 1 'double' value)}}
+  c = vget_low_f64(v); // no-lax-error {{assigning to 'double' from incompatible type 'float64x1_t' (vector of 1 'double' value)}}
+  c -= vget_low_f64(v); // no-lax-error {{assigning to 'double' from incompatible type 'float64x1_t' (vector of 1 'double' value)}}
   // LAX conversions between scalar and vector types require same size and one element sized vectors.
   d = f2; // expected-error {{assigning to 'double' from incompatible type 'float2'}}
-  d = d + f2; // expected-error {{assigning to 'double' from incompatible type 'float2'}}
+  d = d + f2;
+  // lax-error@-1 {{assigning to 'double' from incompatible type 'float2' (vector of 2 'float' values)}}
+  // no-lax-error@-2 {{cannot convert between scalar type 'double' and vector type 'float2' (vector of 2 'float' values) as implicit conversion would cause truncation}}
 }
 
 // rdar://15931426
@@ -78,6 +83,8 @@
 }
 
 void f6(vSInt32 a0) {
-  vUInt32 counter = (float16){0.0f, 0.0f, 0.0f, 0.0f}; // expected-warning {{incompatible vector types initializing 'vUInt32' (vector of 4 'unsigned int' values) with an expression of type 'float16' (vector of 4 'float' values)}}
+  vUInt32 counter = (float16){0.0f, 0.0f, 0.0f, 0.0f};
+  // lax-warning@-1 {{incompatible vector types initializing 'vUInt32' (vector of 4 'unsigned int' values) with an expression of type 'float16' (vector of 4 'float' values)}}
+  // no-lax-error@-2 {{initializing 'vUInt32' (vector of 4 'unsigned int' values) with an expression of incompatible type 'float16' (vector of 4 'float' values)}}
   counter -= a0;
 }
Index: test/Sema/vector-assign.c
===
--- test/Sema/vector-assign.c
+++ test/Sema/vector-assign.c
@@ -14,12 +14,12 @@
   
   v1 = v2; // expected-warning {{incompatible vector types assigning to 'v2s' (vector of 2 'int' values) from 'v2u' (vector of 2 'unsigned int' 

r374450 - Fix __builtin_assume_aligned with too large values.

2019-10-10 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Thu Oct 10 14:08:28 2019
New Revision: 374450

URL: http://llvm.org/viewvc/llvm-project?rev=374450=rev
Log:
Fix __builtin_assume_aligned with too large values.

Code to handle __builtin_assume_aligned was allowing larger values, but
would convert this to unsigned along the way. This patch removes the
EmitAssumeAligned overloads that take unsigned to do away with this
problem.

Additionally, it adds a warning that values greater than 1 <<29 are
ignored by LLVM.

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

Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
cfe/trunk/lib/CodeGen/CGCall.cpp
cfe/trunk/lib/CodeGen/CGExprScalar.cpp
cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.h
cfe/trunk/lib/Sema/SemaChecking.cpp
cfe/trunk/test/Sema/builtin-assume-aligned.c

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=374450=374449=374450=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Thu Oct 10 14:08:28 
2019
@@ -2853,6 +2853,10 @@ def err_alignment_dependent_typedef_name
 
 def err_attribute_aligned_too_great : Error<
   "requested alignment must be %0 bytes or smaller">;
+def warn_assume_aligned_too_great
+: Warning<"requested alignment must be %0 bytes or smaller; assumption "
+  "ignored">,
+  InGroup>;
 def warn_redeclaration_without_attribute_prev_attribute_ignored : Warning<
   "%q0 redeclared without %1 attribute: previous %1 ignored">,
   InGroup;

Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=374450=374449=374450=diff
==
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Thu Oct 10 14:08:28 2019
@@ -2048,11 +2048,10 @@ RValue CodeGenFunction::EmitBuiltinExpr(
 
 Value *AlignmentValue = EmitScalarExpr(E->getArg(1));
 ConstantInt *AlignmentCI = cast(AlignmentValue);
-unsigned Alignment = (unsigned)AlignmentCI->getZExtValue();
 
 EmitAlignmentAssumption(PtrValue, Ptr,
 /*The expr loc is sufficient.*/ SourceLocation(),
-Alignment, OffsetValue);
+AlignmentCI, OffsetValue);
 return RValue::get(PtrValue);
   }
   case Builtin::BI__assume:

Modified: cfe/trunk/lib/CodeGen/CGCall.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCall.cpp?rev=374450=374449=374450=diff
==
--- cfe/trunk/lib/CodeGen/CGCall.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCall.cpp Thu Oct 10 14:08:28 2019
@@ -4569,7 +4569,7 @@ RValue CodeGenFunction::EmitCall(const C
   llvm::Value *Alignment = EmitScalarExpr(AA->getAlignment());
   llvm::ConstantInt *AlignmentCI = cast(Alignment);
   EmitAlignmentAssumption(Ret.getScalarVal(), RetTy, Loc, 
AA->getLocation(),
-  AlignmentCI->getZExtValue(), OffsetValue);
+  AlignmentCI, OffsetValue);
 } else if (const auto *AA = TargetDecl->getAttr()) {
   llvm::Value *AlignmentVal = CallArgs[AA->getParamIndex().getLLVMIndex()]
   .getRValue(*this)

Modified: cfe/trunk/lib/CodeGen/CGExprScalar.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprScalar.cpp?rev=374450=374449=374450=diff
==
--- cfe/trunk/lib/CodeGen/CGExprScalar.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprScalar.cpp Thu Oct 10 14:08:28 2019
@@ -294,8 +294,7 @@ public:
 
 Value *AlignmentValue = CGF.EmitScalarExpr(AVAttr->getAlignment());
 llvm::ConstantInt *AlignmentCI = cast(AlignmentValue);
-CGF.EmitAlignmentAssumption(V, E, AVAttr->getLocation(),
-AlignmentCI->getZExtValue());
+CGF.EmitAlignmentAssumption(V, E, AVAttr->getLocation(), AlignmentCI);
   }
 
   /// EmitLoadOfLValue - Given an expression with complex type that represents 
a

Modified: cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp?rev=374450=374449=374450=diff
==
--- cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp Thu Oct 10 14:08:28 2019
@@ -1519,14 +1519,14 @@ static void emitAlignedClause(CodeGenFun
   if (!CGF.HaveInsertPoint())
 return;
   for (const auto 

[PATCH] D68055: Add -fgnuc-version= to control __GNUC__ and other GCC macros

2019-10-10 Thread Reid Kleckner via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG5e866e411caa: Add -fgnuc-version= to control __GNUC__ and 
other GCC macros (authored by rnk).

Changed prior to commit:
  https://reviews.llvm.org/D68055?vs=224155=224472#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68055

Files:
  clang/docs/ReleaseNotes.rst
  clang/docs/UsersManual.rst
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Frontend/InitPreprocessor.cpp
  clang/test/Driver/fgnuc-version.c
  clang/test/Driver/rewrite-legacy-objc.m
  clang/test/Driver/rewrite-objc.m
  clang/test/Frontend/gnu-inline.c
  clang/test/Headers/stdbool.cpp
  clang/test/Preprocessor/init.c
  clang/test/Sema/atomic-ops.c

Index: clang/test/Sema/atomic-ops.c
===
--- clang/test/Sema/atomic-ops.c
+++ clang/test/Sema/atomic-ops.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -verify -ffreestanding -fsyntax-only -triple=i686-linux-gnu -std=c11
+// RUN: %clang_cc1 %s -verify -fgnuc-version=4.2.1 -ffreestanding -fsyntax-only -triple=i686-linux-gnu -std=c11
 
 // Basic parsing/Sema tests for __c11_atomic_*
 
Index: clang/test/Preprocessor/init.c
===
--- clang/test/Preprocessor/init.c
+++ clang/test/Preprocessor/init.c
@@ -9,18 +9,18 @@
 // BLOCKS:#define __block __attribute__((__blocks__(byref)))
 //
 //
-// RUN: %clang_cc1 -x c++ -std=c++2a -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix CXX2A %s
+// RUN: %clang_cc1 -x c++ -fgnuc-version=4.2.1 -std=c++2a -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix CXX2A %s
 //
-// CXX2A:#define __GNUG__ {{.*}}
+// CXX2A:#define __GNUG__ 4
 // CXX2A:#define __GXX_EXPERIMENTAL_CXX0X__ 1
 // CXX2A:#define __GXX_RTTI 1
 // CXX2A:#define __GXX_WEAK__ 1
 // CXX2A:#define __cplusplus 201707L
 // CXX2A:#define __private_extern__ extern
 //
-// RUN: %clang_cc1 -x c++ -std=c++1z -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix CXX1Z %s
+// RUN: %clang_cc1 -x c++ -fgnuc-version=4.2.1 -std=c++1z -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix CXX1Z %s
 //
-// CXX1Z:#define __GNUG__ {{.*}}
+// CXX1Z:#define __GNUG__ 4
 // CXX1Z:#define __GXX_EXPERIMENTAL_CXX0X__ 1
 // CXX1Z:#define __GXX_RTTI 1
 // CXX1Z:#define __GXX_WEAK__ 1
@@ -28,9 +28,9 @@
 // CXX1Z:#define __private_extern__ extern
 //
 //
-// RUN: %clang_cc1 -x c++ -std=c++1y -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix CXX1Y %s
+// RUN: %clang_cc1 -x c++ -fgnuc-version=4.2.1 -std=c++1y -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix CXX1Y %s
 //
-// CXX1Y:#define __GNUG__ {{.*}}
+// CXX1Y:#define __GNUG__ 4
 // CXX1Y:#define __GXX_EXPERIMENTAL_CXX0X__ 1
 // CXX1Y:#define __GXX_RTTI 1
 // CXX1Y:#define __GXX_WEAK__ 1
@@ -38,9 +38,9 @@
 // CXX1Y:#define __private_extern__ extern
 //
 //
-// RUN: %clang_cc1 -x c++ -std=c++11 -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix CXX11 %s
+// RUN: %clang_cc1 -x c++ -fgnuc-version=4.2.1 -std=c++11 -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix CXX11 %s
 //
-// CXX11:#define __GNUG__ {{.*}}
+// CXX11:#define __GNUG__ 4
 // CXX11:#define __GXX_EXPERIMENTAL_CXX0X__ 1
 // CXX11:#define __GXX_RTTI 1
 // CXX11:#define __GXX_WEAK__ 1
@@ -48,9 +48,9 @@
 // CXX11:#define __private_extern__ extern
 //
 //
-// RUN: %clang_cc1 -x c++ -std=c++98 -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix CXX98 %s
+// RUN: %clang_cc1 -x c++ -fgnuc-version=4.2.1 -std=c++98 -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix CXX98 %s
 //
-// CXX98:#define __GNUG__ {{.*}}
+// CXX98:#define __GNUG__ 4
 // CXX98:#define __GXX_RTTI 1
 // CXX98:#define __GXX_WEAK__ 1
 // CXX98:#define __cplusplus 199711L
@@ -87,7 +87,7 @@
 // C11-NOT: __cplusplus
 //
 //
-// RUN: %clang_cc1 -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix COMMON %s
+// RUN: %clang_cc1 -fgnuc-version=4.2.1 -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix COMMON %s
 //
 // COMMON:#define __CONSTANT_CFSTRINGS__ 1
 // COMMON:#define __FINITE_MATH_ONLY__ 0
@@ -119,41 +119,41 @@
 // RUN: %clang_cc1 -ffreestanding -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix FREESTANDING %s
 // FREESTANDING:#define __STDC_HOSTED__ 0
 //
-// RUN: %clang_cc1 -x c++ -std=gnu++2a -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix GXX2A %s
+// RUN: %clang_cc1 -x c++ -fgnuc-version=4.2.1 -std=gnu++2a -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix GXX2A %s
 //
-// GXX2A:#define __GNUG__ {{.*}}
+// GXX2A:#define __GNUG__ 4
 // GXX2A:#define __GXX_WEAK__ 1
 // GXX2A:#define __cplusplus 201707L
 // GXX2A:#define __private_extern__ extern
 //
 //
-// RUN: 

[PATCH] D67160: [clang, ARM] Default to -fno-lax-vector-conversions in ARM v8.1-M.

2019-10-10 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith requested changes to this revision.
rsmith added a comment.
This revision now requires changes to proceed.

It is not reasonable to make this change on a per-target basis. We should work 
towards turning lax vector conversions off globally instead.

If overload resolution can't distinguish between overloads that perform a lax 
vector conversions and those that do not, we should fix that in overload 
resolution rather than papering over it with a change of per-target default -- 
this target's headers should still work even when users turn lax vector 
conversions back on.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67160



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


[PATCH] D68753: [CUDA][HIP} Add a test for constexpr default ctor

2019-10-10 Thread Artem Belevich via Phabricator via cfe-commits
tra added inline comments.



Comment at: test/SemaCUDA/constexpr-ctor.cu:14-27
+template  struct B {
+  T a;
+  constexpr B() = default;
+};
+
+template  struct C {
+  T a;

yaxunl wrote:
> tra wrote:
> > Do we really need three identical templates? If they are needed to let 
> > compiler emit multiple diagnostics, perhaps we could just add another 
> > template parameter so we can get different instantiations.
> the error is emitted on the default ctor of the template. If we do not use 
> different templates, all errors are emitted on the same line, we cannot make 
> sure some instantiations do not cause error and some instantiations should 
> cause error.
> 
> Adding template parameter will not help, because the error will still be 
> emitted to the same line.
Having multiple errors attributed to the same source is OK. You can specify 
expected count. E.g.
`dev-error 2 {{something}}`. Single template appears to be sufficient 
(https://godbolt.org/z/G3WvYD).

You'll have different note diags emitted for individual errors, so checking 
them would both provide more info about that exactly the problem is and will 
verify that they are reported in the correct locations. Right now you are 
describing what/where triggers an error that as a comment. Letting compiler 
verify that instead would be better, IMO.




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

https://reviews.llvm.org/D68753



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


r374449 - Add -fgnuc-version= to control __GNUC__ and other GCC macros

2019-10-10 Thread Reid Kleckner via cfe-commits
Author: rnk
Date: Thu Oct 10 14:04:25 2019
New Revision: 374449

URL: http://llvm.org/viewvc/llvm-project?rev=374449=rev
Log:
Add -fgnuc-version= to control __GNUC__ and other GCC macros

I noticed that compiling on Windows with -fno-ms-compatibility had the
side effect of defining __GNUC__, along with __GNUG__, __GXX_RTTI__, and
a number of other macros for GCC compatibility. This is undesirable and
causes Chromium to do things like mix __attribute__ and __declspec,
which doesn't work. We should have a positive language option to enable
GCC compatibility features so that we can experiment with
-fno-ms-compatibility on Windows. This change adds -fgnuc-version= to be
that option.

My issue aside, users have, for a long time, reported that __GNUC__
doesn't match their expectations in one way or another. We have
encouraged users to migrate code away from this macro, but new code
continues to be written assuming a GCC-only environment. There's really
nothing we can do to stop that. By adding this flag, we can allow them
to choose their own adventure with __GNUC__.

This overlaps a bit with the "GNUMode" language option from -std=gnu*.
The gnu language mode tends to enable non-conforming behaviors that we'd
rather not enable by default, but the we want to set things like
__GXX_RTTI__ by default, so I've kept these separate.

Helps address PR42817

Reviewed By: hans, nickdesaulniers, MaskRay

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

Added:
cfe/trunk/test/Driver/fgnuc-version.c
Modified:
cfe/trunk/docs/ReleaseNotes.rst
cfe/trunk/docs/UsersManual.rst
cfe/trunk/include/clang/Basic/LangOptions.def
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/lib/Driver/ToolChains/Clang.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/lib/Frontend/InitPreprocessor.cpp
cfe/trunk/test/Driver/rewrite-legacy-objc.m
cfe/trunk/test/Driver/rewrite-objc.m
cfe/trunk/test/Frontend/gnu-inline.c
cfe/trunk/test/Headers/stdbool.cpp
cfe/trunk/test/Preprocessor/init.c
cfe/trunk/test/Sema/atomic-ops.c

Modified: cfe/trunk/docs/ReleaseNotes.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ReleaseNotes.rst?rev=374449=374448=374449=diff
==
--- cfe/trunk/docs/ReleaseNotes.rst (original)
+++ cfe/trunk/docs/ReleaseNotes.rst Thu Oct 10 14:04:25 2019
@@ -80,7 +80,10 @@ Non-comprehensive list of changes in thi
 New Compiler Flags
 --
 
-- ...
+- The -fgnuc-version= flag now controls the value of ``__GNUC__`` and related
+  macros. This flag does not enable or disable any GCC extensions implemented 
in
+  Clang. Setting the version to zero causes Clang to leave ``__GNUC__`` and
+  other GNU-namespaced macros, such as ``__GXX_WEAK__``, undefined.
 
 Deprecated Compiler Flags
 -

Modified: cfe/trunk/docs/UsersManual.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/UsersManual.rst?rev=374449=374448=374449=diff
==
--- cfe/trunk/docs/UsersManual.rst (original)
+++ cfe/trunk/docs/UsersManual.rst Thu Oct 10 14:04:25 2019
@@ -701,6 +701,13 @@ Other Options
 -
 Clang options that don't fit neatly into other categories.
 
+.. option:: -fgnuc-version=
+
+  This flag controls the value of ``__GNUC__`` and related macros. This flag
+  does not enable or disable any GCC extensions implemented in Clang. Setting
+  the version to zero causes Clang to leave ``__GNUC__`` and other
+  GNU-namespaced macros, such as ``__GXX_WEAK__``, undefined.
+
 .. option:: -MV
 
   When emitting a dependency file, use formatting conventions appropriate

Modified: cfe/trunk/include/clang/Basic/LangOptions.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/LangOptions.def?rev=374449=374448=374449=diff
==
--- cfe/trunk/include/clang/Basic/LangOptions.def (original)
+++ cfe/trunk/include/clang/Basic/LangOptions.def Thu Oct 10 14:04:25 2019
@@ -111,6 +111,7 @@ BENIGN_LANGOPT(DollarIdents   , 1, 1, "'
 BENIGN_LANGOPT(AsmPreprocessor, 1, 0, "preprocessor in asm mode")
 LANGOPT(GNUMode   , 1, 1, "GNU extensions")
 LANGOPT(GNUKeywords   , 1, 1, "GNU keywords")
+VALUE_LANGOPT(GNUCVersion , 32, 0, "GNU C compatibility version")
 BENIGN_LANGOPT(ImplicitInt, 1, !C99 && !CPlusPlus, "C89 implicit 'int'")
 LANGOPT(Digraphs  , 1, 0, "digraphs")
 BENIGN_LANGOPT(HexFloats  , 1, C99, "C99 hexadecimal float constants")

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=374449=374448=374449=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Thu Oct 10 14:04:25 

[PATCH] D68832: [tsan,msan] Insert module constructors in a module pass

2019-10-10 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka created this revision.
vitalybuka added reviewers: eugenis, leonardchan.
Herald added subscribers: llvm-commits, cfe-commits, hiraditya.
Herald added projects: clang, LLVM.

If we insert them from function pass some analysis may be missing or invalid.
Fixes PR42877.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D68832

Files:
  clang/lib/CodeGen/BackendUtil.cpp
  clang/test/CodeGen/sanitizer-module-constructor.c
  llvm/include/llvm/Transforms/Instrumentation/MemorySanitizer.h
  llvm/include/llvm/Transforms/Instrumentation/ThreadSanitizer.h
  llvm/lib/Passes/PassRegistry.def
  llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
  llvm/lib/Transforms/Instrumentation/ThreadSanitizer.cpp
  llvm/test/Instrumentation/MemorySanitizer/msan_basic.ll
  llvm/test/Instrumentation/ThreadSanitizer/tsan_basic.ll

Index: llvm/test/Instrumentation/ThreadSanitizer/tsan_basic.ll
===
--- llvm/test/Instrumentation/ThreadSanitizer/tsan_basic.ll
+++ llvm/test/Instrumentation/ThreadSanitizer/tsan_basic.ll
@@ -1,5 +1,5 @@
 ; RUN: opt < %s -tsan -S | FileCheck %s
-; RUN: opt < %s -passes=tsan -S | FileCheck %s
+; RUN: opt < %s -passes='function(tsan),module(tsan-module)' -S | FileCheck %s
 
 target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64"
 target triple = "x86_64-unknown-linux-gnu"
Index: llvm/test/Instrumentation/MemorySanitizer/msan_basic.ll
===
--- llvm/test/Instrumentation/MemorySanitizer/msan_basic.ll
+++ llvm/test/Instrumentation/MemorySanitizer/msan_basic.ll
@@ -1,10 +1,9 @@
-; RUN: opt < %s -msan-check-access-address=0 -S -passes=msan 2>&1 | FileCheck  \
-; RUN: -allow-deprecated-dag-overlap %s
-; RUN: opt < %s -msan -msan-check-access-address=0 -S | FileCheck -allow-deprecated-dag-overlap %s
-; RUN: opt < %s -msan-check-access-address=0 -msan-track-origins=1 -S  \
-; RUN: -passes=msan 2>&1 | FileCheck -allow-deprecated-dag-overlap \
-; RUN: -check-prefix=CHECK -check-prefix=CHECK-ORIGINS %s
-; RUN: opt < %s -msan -msan-check-access-address=0 -msan-track-origins=1 -S | FileCheck -allow-deprecated-dag-overlap -check-prefix=CHECK -check-prefix=CHECK-ORIGINS %s
+; RUN: opt < %s -msan-check-access-address=0 -S -passes='module(msan-module),function(msan)' 2>&1 | FileCheck -allow-deprecated-dag-overlap %s
+; RUN: opt < %s --passes='module(msan-module),function(msan)' -msan-check-access-address=0 -S | FileCheck -allow-deprecated-dag-overlap %s
+; RUN: opt < %s -msan-check-access-address=0 -msan-track-origins=1 -S -passes='module(msan-module),function(msan)' 2>&1 | \
+; RUN:   FileCheck -allow-deprecated-dag-overlap -check-prefixes=CHECK,CHECK-ORIGINS %s
+; RUN: opt < %s -passes='module(msan-module),function(msan)' -msan-check-access-address=0 -msan-track-origins=1 -S | \
+; RUN:   FileCheck -allow-deprecated-dag-overlap -check-prefixes=CHECK,CHECK-ORIGINS %s
 
 target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
 target triple = "x86_64-unknown-linux-gnu"
Index: llvm/lib/Transforms/Instrumentation/ThreadSanitizer.cpp
===
--- llvm/lib/Transforms/Instrumentation/ThreadSanitizer.cpp
+++ llvm/lib/Transforms/Instrumentation/ThreadSanitizer.cpp
@@ -92,11 +92,10 @@
 /// ensures the __tsan_init function is in the list of global constructors for
 /// the module.
 struct ThreadSanitizer {
-  ThreadSanitizer(Module );
   bool sanitizeFunction(Function , const TargetLibraryInfo );
 
 private:
-  void initializeCallbacks(Module );
+  void initialize(Module );
   bool instrumentLoadOrStore(Instruction *I, const DataLayout );
   bool instrumentAtomic(Instruction *I, const DataLayout );
   bool instrumentMemIntrinsic(Instruction *I);
@@ -108,8 +107,6 @@
   void InsertRuntimeIgnores(Function );
 
   Type *IntptrTy;
-  IntegerType *OrdTy;
-  // Callbacks to run-time library are computed in doInitialization.
   FunctionCallee TsanFuncEntry;
   FunctionCallee TsanFuncExit;
   FunctionCallee TsanIgnoreBegin;
@@ -130,7 +127,6 @@
   FunctionCallee TsanVptrUpdate;
   FunctionCallee TsanVptrLoad;
   FunctionCallee MemmoveFn, MemcpyFn, MemsetFn;
-  Function *TsanCtorFunction;
 };
 
 struct ThreadSanitizerLegacyPass : FunctionPass {
@@ -143,16 +139,32 @@
 private:
   Optional TSan;
 };
+
+static void insertModuleCtor(Module ) {
+  getOrCreateSanitizerCtorAndInitFunctions(
+  M, kTsanModuleCtorName, kTsanInitName, /*InitArgTypes=*/{},
+  /*InitArgs=*/{},
+  // This callback is invoked when the functions are created the first
+  // time. Hook them into the global ctors list in that case:
+  [&](Function *Ctor, FunctionCallee) { appendToGlobalCtors(M, Ctor, 0); });
+}
+
 

[PATCH] D68660: [tooling] Teach Tooling to understand compilation with offloading.

2019-10-10 Thread Artem Belevich via Phabricator via cfe-commits
tra added inline comments.



Comment at: clang/lib/Tooling/Tooling.cpp:102
+  if (isa(A)) {
+assert(Actions.size() == 2);
+assert(isa(Actions.front()));

Why 2? Will it not be different if user targeted multiple GPUs?




Comment at: clang/lib/Tooling/Tooling.cpp:103
+assert(Actions.size() == 2);
+assert(isa(Actions.front()));
+OffloadCompilation = true;

I'd add a comment describing that we expect the first jub to be a 
(host-side)compilation.
It would not be obvious to someone w/o familiarity of cuda/hip compilation.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68660



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


[PATCH] D68823: Fix help message for -ffp-contract

2019-10-10 Thread Artem Belevich via Phabricator via cfe-commits
tra added inline comments.



Comment at: include/clang/Driver/Options.td:1148
+  " | on (according to FP_CONTRACT pragma) | off (never fuse). Default"
+  " is 'fast' for CUDA/HIP and 'on' otherwise.">, Values<"fast,on,off">;
 

Could you point me where we set it? I'm having trouble finding the code that 
controls it for CUDA.


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

https://reviews.llvm.org/D68823



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


[PATCH] D68736: [MSVC] Automatically add atlmfc include and lib directories as system paths.

2019-10-10 Thread Zachary Turner via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG79f243296654: [MSVC] Automatically add atlmfc folder to 
include and libpath. (authored by zturner).
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68736

Files:
  clang/lib/Driver/ToolChains/MSVC.cpp
  clang/lib/Driver/ToolChains/MSVC.h


Index: clang/lib/Driver/ToolChains/MSVC.h
===
--- clang/lib/Driver/ToolChains/MSVC.h
+++ clang/lib/Driver/ToolChains/MSVC.h
@@ -98,12 +98,14 @@
 Lib,
   };
   std::string getSubDirectoryPath(SubDirectoryType Type,
+  llvm::StringRef SubdirParent,
   llvm::Triple::ArchType TargetArch) const;
 
   // Convenience overload.
   // Uses the current target arch.
-  std::string getSubDirectoryPath(SubDirectoryType Type) const {
-return getSubDirectoryPath(Type, getArch());
+  std::string getSubDirectoryPath(SubDirectoryType Type,
+  llvm::StringRef SubdirParent = "") const {
+return getSubDirectoryPath(Type, SubdirParent, getArch());
   }
 
   enum class ToolsetLayout {
Index: clang/lib/Driver/ToolChains/MSVC.cpp
===
--- clang/lib/Driver/ToolChains/MSVC.cpp
+++ clang/lib/Driver/ToolChains/MSVC.cpp
@@ -331,6 +331,11 @@
 TC.getSubDirectoryPath(
 toolchains::MSVCToolChain::SubDirectoryType::Lib)));
 
+CmdArgs.push_back(Args.MakeArgString(
+Twine("-libpath:") +
+
TC.getSubDirectoryPath(toolchains::MSVCToolChain::SubDirectoryType::Lib,
+   "atlmfc")));
+
 if (TC.useUniversalCRT()) {
   std::string UniversalCRTLibPath;
   if (TC.getUniversalCRTLibraryPath(UniversalCRTLibPath))
@@ -548,7 +553,7 @@
   EnvVar.substr(0, PrefixLen) +
   TC.getSubDirectoryPath(SubDirectoryType::Bin) +
   llvm::Twine(llvm::sys::EnvPathSeparator) +
-  TC.getSubDirectoryPath(SubDirectoryType::Bin, HostArch) +
+  TC.getSubDirectoryPath(SubDirectoryType::Bin, "", HostArch) +
   (EnvVar.size() > PrefixLen
? llvm::Twine(llvm::sys::EnvPathSeparator) +
  EnvVar.substr(PrefixLen)
@@ -824,6 +829,7 @@
 // of hardcoding paths.
 std::string
 MSVCToolChain::getSubDirectoryPath(SubDirectoryType Type,
+   llvm::StringRef SubdirParent,
llvm::Triple::ArchType TargetArch) const {
   const char *SubdirName;
   const char *IncludeName;
@@ -843,6 +849,9 @@
   }
 
   llvm::SmallString<256> Path(VCToolChainPath);
+  if (!SubdirParent.empty())
+llvm::sys::path::append(Path, SubdirParent);
+
   switch (Type) {
   case SubDirectoryType::Bin:
 if (VSLayout == ToolsetLayout::VS2017OrNewer) {
@@ -1228,6 +1237,8 @@
   if (!VCToolChainPath.empty()) {
 addSystemInclude(DriverArgs, CC1Args,
  getSubDirectoryPath(SubDirectoryType::Include));
+addSystemInclude(DriverArgs, CC1Args,
+ getSubDirectoryPath(SubDirectoryType::Include, "atlmfc"));
 
 if (useUniversalCRT()) {
   std::string UniversalCRTSdkPath;


Index: clang/lib/Driver/ToolChains/MSVC.h
===
--- clang/lib/Driver/ToolChains/MSVC.h
+++ clang/lib/Driver/ToolChains/MSVC.h
@@ -98,12 +98,14 @@
 Lib,
   };
   std::string getSubDirectoryPath(SubDirectoryType Type,
+  llvm::StringRef SubdirParent,
   llvm::Triple::ArchType TargetArch) const;
 
   // Convenience overload.
   // Uses the current target arch.
-  std::string getSubDirectoryPath(SubDirectoryType Type) const {
-return getSubDirectoryPath(Type, getArch());
+  std::string getSubDirectoryPath(SubDirectoryType Type,
+  llvm::StringRef SubdirParent = "") const {
+return getSubDirectoryPath(Type, SubdirParent, getArch());
   }
 
   enum class ToolsetLayout {
Index: clang/lib/Driver/ToolChains/MSVC.cpp
===
--- clang/lib/Driver/ToolChains/MSVC.cpp
+++ clang/lib/Driver/ToolChains/MSVC.cpp
@@ -331,6 +331,11 @@
 TC.getSubDirectoryPath(
 toolchains::MSVCToolChain::SubDirectoryType::Lib)));
 
+CmdArgs.push_back(Args.MakeArgString(
+Twine("-libpath:") +
+TC.getSubDirectoryPath(toolchains::MSVCToolChain::SubDirectoryType::Lib,
+   "atlmfc")));
+
 if (TC.useUniversalCRT()) {
   std::string UniversalCRTLibPath;
   if (TC.getUniversalCRTLibraryPath(UniversalCRTLibPath))
@@ -548,7 +553,7 @@
   EnvVar.substr(0, PrefixLen) +
   

r374443 - [MSVC] Automatically add atlmfc folder to include and libpath.

2019-10-10 Thread Zachary Turner via cfe-commits
Author: zturner
Date: Thu Oct 10 13:25:54 2019
New Revision: 374443

URL: http://llvm.org/viewvc/llvm-project?rev=374443=rev
Log:
[MSVC] Automatically add atlmfc folder to include and libpath.

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

Modified:
cfe/trunk/lib/Driver/ToolChains/MSVC.cpp
cfe/trunk/lib/Driver/ToolChains/MSVC.h

Modified: cfe/trunk/lib/Driver/ToolChains/MSVC.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/MSVC.cpp?rev=374443=374442=374443=diff
==
--- cfe/trunk/lib/Driver/ToolChains/MSVC.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/MSVC.cpp Thu Oct 10 13:25:54 2019
@@ -331,6 +331,11 @@ void visualstudio::Linker::ConstructJob(
 TC.getSubDirectoryPath(
 toolchains::MSVCToolChain::SubDirectoryType::Lib)));
 
+CmdArgs.push_back(Args.MakeArgString(
+Twine("-libpath:") +
+
TC.getSubDirectoryPath(toolchains::MSVCToolChain::SubDirectoryType::Lib,
+   "atlmfc")));
+
 if (TC.useUniversalCRT()) {
   std::string UniversalCRTLibPath;
   if (TC.getUniversalCRTLibraryPath(UniversalCRTLibPath))
@@ -548,7 +553,7 @@ void visualstudio::Linker::ConstructJob(
   EnvVar.substr(0, PrefixLen) +
   TC.getSubDirectoryPath(SubDirectoryType::Bin) +
   llvm::Twine(llvm::sys::EnvPathSeparator) +
-  TC.getSubDirectoryPath(SubDirectoryType::Bin, HostArch) +
+  TC.getSubDirectoryPath(SubDirectoryType::Bin, "", HostArch) +
   (EnvVar.size() > PrefixLen
? llvm::Twine(llvm::sys::EnvPathSeparator) +
  EnvVar.substr(PrefixLen)
@@ -824,6 +829,7 @@ static const char *llvmArchToDevDivInter
 // of hardcoding paths.
 std::string
 MSVCToolChain::getSubDirectoryPath(SubDirectoryType Type,
+   llvm::StringRef SubdirParent,
llvm::Triple::ArchType TargetArch) const {
   const char *SubdirName;
   const char *IncludeName;
@@ -843,6 +849,9 @@ MSVCToolChain::getSubDirectoryPath(SubDi
   }
 
   llvm::SmallString<256> Path(VCToolChainPath);
+  if (!SubdirParent.empty())
+llvm::sys::path::append(Path, SubdirParent);
+
   switch (Type) {
   case SubDirectoryType::Bin:
 if (VSLayout == ToolsetLayout::VS2017OrNewer) {
@@ -1228,6 +1237,8 @@ void MSVCToolChain::AddClangSystemInclud
   if (!VCToolChainPath.empty()) {
 addSystemInclude(DriverArgs, CC1Args,
  getSubDirectoryPath(SubDirectoryType::Include));
+addSystemInclude(DriverArgs, CC1Args,
+ getSubDirectoryPath(SubDirectoryType::Include, "atlmfc"));
 
 if (useUniversalCRT()) {
   std::string UniversalCRTSdkPath;

Modified: cfe/trunk/lib/Driver/ToolChains/MSVC.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/MSVC.h?rev=374443=374442=374443=diff
==
--- cfe/trunk/lib/Driver/ToolChains/MSVC.h (original)
+++ cfe/trunk/lib/Driver/ToolChains/MSVC.h Thu Oct 10 13:25:54 2019
@@ -98,12 +98,14 @@ public:
 Lib,
   };
   std::string getSubDirectoryPath(SubDirectoryType Type,
+  llvm::StringRef SubdirParent,
   llvm::Triple::ArchType TargetArch) const;
 
   // Convenience overload.
   // Uses the current target arch.
-  std::string getSubDirectoryPath(SubDirectoryType Type) const {
-return getSubDirectoryPath(Type, getArch());
+  std::string getSubDirectoryPath(SubDirectoryType Type,
+  llvm::StringRef SubdirParent = "") const {
+return getSubDirectoryPath(Type, SubdirParent, getArch());
   }
 
   enum class ToolsetLayout {


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


r374439 - [ScanDeps] clang-format, 80 cols.

2019-10-10 Thread Michael J. Spencer via cfe-commits
Author: mspencer
Date: Thu Oct 10 13:19:02 2019
New Revision: 374439

URL: http://llvm.org/viewvc/llvm-project?rev=374439=rev
Log:
[ScanDeps] clang-format, 80 cols.

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

Modified: 
cfe/trunk/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp?rev=374439=374438=374439=diff
==
--- cfe/trunk/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp 
(original)
+++ cfe/trunk/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp 
Thu Oct 10 13:19:02 2019
@@ -123,8 +123,9 @@ DependencyScanningFilesystemSharedCache:
 }
 
 llvm::ErrorOr
-DependencyScanningWorkerFilesystem::getOrCreateFileSystemEntry(const StringRef 
Filename) {
-  if (const CachedFileSystemEntry* Entry = getCachedEntry(Filename)) {
+DependencyScanningWorkerFilesystem::getOrCreateFileSystemEntry(
+const StringRef Filename) {
+  if (const CachedFileSystemEntry *Entry = getCachedEntry(Filename)) {
 return Entry;
   }
 
@@ -164,7 +165,8 @@ llvm::ErrorOr
 DependencyScanningWorkerFilesystem::status(const Twine ) {
   SmallString<256> OwnedFilename;
   StringRef Filename = Path.toStringRef(OwnedFilename);
-  const llvm::ErrorOr Result = 
getOrCreateFileSystemEntry(Filename);
+  const llvm::ErrorOr Result =
+  getOrCreateFileSystemEntry(Filename);
   if (!Result)
 return Result.getError();
   return (*Result)->getStatus();
@@ -224,7 +226,8 @@ DependencyScanningWorkerFilesystem::open
   SmallString<256> OwnedFilename;
   StringRef Filename = Path.toStringRef(OwnedFilename);
 
-  const llvm::ErrorOr Result = 
getOrCreateFileSystemEntry(Filename);
+  const llvm::ErrorOr Result =
+  getOrCreateFileSystemEntry(Filename);
   if (!Result)
 return Result.getError();
   return createFile(Result.get(), PPSkipMappings);


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


r374438 - [OPENMP]Update doc for supported constructs, NFC.

2019-10-10 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Thu Oct 10 13:15:54 2019
New Revision: 374438

URL: http://llvm.org/viewvc/llvm-project?rev=374438=rev
Log:
[OPENMP]Update doc for supported constructs, NFC.

Modified:
cfe/trunk/docs/OpenMPSupport.rst

Modified: cfe/trunk/docs/OpenMPSupport.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/OpenMPSupport.rst?rev=374438=374437=374438=diff
==
--- cfe/trunk/docs/OpenMPSupport.rst (original)
+++ cfe/trunk/docs/OpenMPSupport.rst Thu Oct 10 13:15:54 2019
@@ -179,7 +179,7 @@ implementation.
 
+--+--+--+---+
 | task extension   | combined taskloop constructs  
   | :none:`unclaimed`| 
  |
 
+--+--+--+---+
-| task extension   | master taskloop   
   | :none:`unclaimed`| 
  |
+| task extension   | master taskloop   
   | :good:`done` | 
  |
 
+--+--+--+---+
 | task extension   | parallel master taskloop  
   | :none:`unclaimed`| 
  |
 
+--+--+--+---+


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


[PATCH] D68824: Fix __builtin_assume_aligned with too large values.

2019-10-10 Thread Erich Keane via Phabricator via cfe-commits
erichkeane updated this revision to Diff 224456.
erichkeane added a comment.

cant use llvm::Value in Sema without some linker issues.


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

https://reviews.llvm.org/D68824

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/CodeGen/CGExprScalar.cpp
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/lib/Sema/SemaChecking.cpp
  clang/test/Sema/builtin-assume-aligned.c

Index: clang/test/Sema/builtin-assume-aligned.c
===
--- clang/test/Sema/builtin-assume-aligned.c
+++ clang/test/Sema/builtin-assume-aligned.c
@@ -58,3 +58,7 @@
 void *test_no_fn_proto() __attribute__((assume_aligned())); // expected-error {{'assume_aligned' attribute takes at least 1 argument}}
 void *test_no_fn_proto() __attribute__((assume_aligned(32, 45, 37))); // expected-error {{'assume_aligned' attribute takes no more than 2 arguments}}
 
+int pr43638(int *a) {
+  a = __builtin_assume_aligned(a, 4294967296); // expected-warning {{requested alignment must be %0 bytes or smaller; assumption ignored}}
+return a[0];
+}
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -6063,6 +6063,14 @@
 if (!Result.isPowerOf2())
   return Diag(TheCall->getBeginLoc(), diag::err_alignment_not_power_of_two)
  << Arg->getSourceRange();
+
+// Alignment calculations can wrap around if it's greater than 2**28.
+unsigned MaximumAlignment =
+Context.getTargetInfo().getTriple().isOSBinFormatCOFF() ? 8192
+: 268435456;
+if (Result > MaximumAlignment)
+  Diag(TheCall->getBeginLoc(), diag::warn_assume_aligned_too_great)
+  << Arg->getSourceRange() << MaximumAlignment;
   }
 
   if (NumArgs > 2) {
Index: clang/lib/CodeGen/CodeGenFunction.h
===
--- clang/lib/CodeGen/CodeGenFunction.h
+++ clang/lib/CodeGen/CodeGenFunction.h
@@ -2829,13 +2829,8 @@
llvm::Value *Alignment,
llvm::Value *OffsetValue = nullptr);
 
-  void EmitAlignmentAssumption(llvm::Value *PtrValue, QualType Ty,
-   SourceLocation Loc, SourceLocation AssumptionLoc,
-   unsigned Alignment,
-   llvm::Value *OffsetValue = nullptr);
-
   void EmitAlignmentAssumption(llvm::Value *PtrValue, const Expr *E,
-   SourceLocation AssumptionLoc, unsigned Alignment,
+   SourceLocation AssumptionLoc, llvm::Value *Alignment,
llvm::Value *OffsetValue = nullptr);
 
   //======//
Index: clang/lib/CodeGen/CodeGenFunction.cpp
===
--- clang/lib/CodeGen/CodeGenFunction.cpp
+++ clang/lib/CodeGen/CodeGenFunction.cpp
@@ -2057,24 +2057,9 @@
 }
 
 void CodeGenFunction::EmitAlignmentAssumption(llvm::Value *PtrValue,
-  QualType Ty, SourceLocation Loc,
-  SourceLocation AssumptionLoc,
-  unsigned Alignment,
-  llvm::Value *OffsetValue) {
-  llvm::Value *TheCheck;
-  llvm::Instruction *Assumption = Builder.CreateAlignmentAssumption(
-  CGM.getDataLayout(), PtrValue, Alignment, OffsetValue, );
-  if (SanOpts.has(SanitizerKind::Alignment)) {
-llvm::Value *AlignmentVal = llvm::ConstantInt::get(IntPtrTy, Alignment);
-EmitAlignmentAssumptionCheck(PtrValue, Ty, Loc, AssumptionLoc, AlignmentVal,
- OffsetValue, TheCheck, Assumption);
-  }
-}
-
-void CodeGenFunction::EmitAlignmentAssumption(llvm::Value *PtrValue,
   const Expr *E,
   SourceLocation AssumptionLoc,
-  unsigned Alignment,
+  llvm::Value *Alignment,
   llvm::Value *OffsetValue) {
   if (auto *CE = dyn_cast(E))
 E = CE->getSubExprAsWritten();
Index: clang/lib/CodeGen/CGStmtOpenMP.cpp
===
--- clang/lib/CodeGen/CGStmtOpenMP.cpp
+++ clang/lib/CodeGen/CGStmtOpenMP.cpp
@@ -1519,14 +1519,14 @@
   if (!CGF.HaveInsertPoint())
 return;
   for (const auto *Clause : D.getClausesOfKind()) {
-unsigned ClauseAlignment = 0;
+size_t 

[PATCH] D68824: Fix __builtin_assume_aligned with too large values.

2019-10-10 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri accepted this revision.
lebedev.ri added a comment.
This revision is now accepted and ready to land.

LG, thanks.


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

https://reviews.llvm.org/D68824



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


[PATCH] D68824: Fix __builtin_assume_aligned with too large values.

2019-10-10 Thread Erich Keane via Phabricator via cfe-commits
erichkeane updated this revision to Diff 224455.
erichkeane marked 5 inline comments as done.
erichkeane added a comment.

Hal's comments


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

https://reviews.llvm.org/D68824

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/CodeGen/CGExprScalar.cpp
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/lib/Sema/SemaChecking.cpp
  clang/test/Sema/builtin-assume-aligned.c

Index: clang/test/Sema/builtin-assume-aligned.c
===
--- clang/test/Sema/builtin-assume-aligned.c
+++ clang/test/Sema/builtin-assume-aligned.c
@@ -58,3 +58,7 @@
 void *test_no_fn_proto() __attribute__((assume_aligned())); // expected-error {{'assume_aligned' attribute takes at least 1 argument}}
 void *test_no_fn_proto() __attribute__((assume_aligned(32, 45, 37))); // expected-error {{'assume_aligned' attribute takes no more than 2 arguments}}
 
+int pr43638(int *a) {
+  a = __builtin_assume_aligned(a, 4294967296); // expected-warning {{requested alignment must be %0 bytes or smaller; assumption ignored}}
+return a[0];
+}
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -76,6 +76,7 @@
 #include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/StringSwitch.h"
 #include "llvm/ADT/Triple.h"
+#include "llvm/IR/Value.h"
 #include "llvm/Support/AtomicOrdering.h"
 #include "llvm/Support/Casting.h"
 #include "llvm/Support/Compiler.h"
@@ -6063,6 +6064,9 @@
 if (!Result.isPowerOf2())
   return Diag(TheCall->getBeginLoc(), diag::err_alignment_not_power_of_two)
  << Arg->getSourceRange();
+if (Result > llvm::Value::MaximumAlignment)
+  Diag(TheCall->getBeginLoc(), diag::warn_assume_aligned_too_great)
+  << Arg->getSourceRange() << llvm::Value::MaximumAlignment;
   }
 
   if (NumArgs > 2) {
Index: clang/lib/CodeGen/CodeGenFunction.h
===
--- clang/lib/CodeGen/CodeGenFunction.h
+++ clang/lib/CodeGen/CodeGenFunction.h
@@ -2829,13 +2829,8 @@
llvm::Value *Alignment,
llvm::Value *OffsetValue = nullptr);
 
-  void EmitAlignmentAssumption(llvm::Value *PtrValue, QualType Ty,
-   SourceLocation Loc, SourceLocation AssumptionLoc,
-   unsigned Alignment,
-   llvm::Value *OffsetValue = nullptr);
-
   void EmitAlignmentAssumption(llvm::Value *PtrValue, const Expr *E,
-   SourceLocation AssumptionLoc, unsigned Alignment,
+   SourceLocation AssumptionLoc, llvm::Value *Alignment,
llvm::Value *OffsetValue = nullptr);
 
   //======//
Index: clang/lib/CodeGen/CodeGenFunction.cpp
===
--- clang/lib/CodeGen/CodeGenFunction.cpp
+++ clang/lib/CodeGen/CodeGenFunction.cpp
@@ -2057,24 +2057,9 @@
 }
 
 void CodeGenFunction::EmitAlignmentAssumption(llvm::Value *PtrValue,
-  QualType Ty, SourceLocation Loc,
-  SourceLocation AssumptionLoc,
-  unsigned Alignment,
-  llvm::Value *OffsetValue) {
-  llvm::Value *TheCheck;
-  llvm::Instruction *Assumption = Builder.CreateAlignmentAssumption(
-  CGM.getDataLayout(), PtrValue, Alignment, OffsetValue, );
-  if (SanOpts.has(SanitizerKind::Alignment)) {
-llvm::Value *AlignmentVal = llvm::ConstantInt::get(IntPtrTy, Alignment);
-EmitAlignmentAssumptionCheck(PtrValue, Ty, Loc, AssumptionLoc, AlignmentVal,
- OffsetValue, TheCheck, Assumption);
-  }
-}
-
-void CodeGenFunction::EmitAlignmentAssumption(llvm::Value *PtrValue,
   const Expr *E,
   SourceLocation AssumptionLoc,
-  unsigned Alignment,
+  llvm::Value *Alignment,
   llvm::Value *OffsetValue) {
   if (auto *CE = dyn_cast(E))
 E = CE->getSubExprAsWritten();
Index: clang/lib/CodeGen/CGStmtOpenMP.cpp
===
--- clang/lib/CodeGen/CGStmtOpenMP.cpp
+++ clang/lib/CodeGen/CGStmtOpenMP.cpp
@@ -1519,14 +1519,14 @@
   if (!CGF.HaveInsertPoint())
 return;
   for (const auto *Clause : D.getClausesOfKind()) {
-unsigned ClauseAlignment = 0;

[PATCH] D67901: [clangd] Improve semantic highlighting in dependent contexts (fixes #154)

2019-10-10 Thread Nathan Ridge via Phabricator via cfe-commits
nridge marked 3 inline comments as done.
nridge added a comment.

I like how we went from using heuristics, to not using heuristics, to using 
heuristics again :)

But admittedly, the new heuristics are more accurate because they're based on 
phase 1 lookup results rather than just syntax, so I'm happy with the outcome!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67901



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


[PATCH] D67901: [clangd] Improve semantic highlighting in dependent contexts (fixes #154)

2019-10-10 Thread Nathan Ridge via Phabricator via cfe-commits
nridge updated this revision to Diff 224453.
nridge added a comment.

Updated to use heuristics based on OverloadExpr::decl()

Also folded VisitUnresolvedLookupExpr and VisitUnresolvedMemberExpr together
into a single VisitOverloadExpr


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67901

Files:
  clang-tools-extra/clangd/SemanticHighlighting.cpp
  clang-tools-extra/clangd/SemanticHighlighting.h
  clang-tools-extra/clangd/test/semantic-highlighting.test
  clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp

Index: clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
===
--- clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
+++ clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
@@ -51,6 +51,9 @@
   {HighlightingKind::StaticField, "StaticField"},
   {HighlightingKind::Method, "Method"},
   {HighlightingKind::StaticMethod, "StaticMethod"},
+  {HighlightingKind::Typedef, "Typedef"},
+  {HighlightingKind::DependentType, "DependentType"},
+  {HighlightingKind::DependentName, "DependentName"},
   {HighlightingKind::TemplateParameter, "TemplateParameter"},
   {HighlightingKind::Primitive, "Primitive"},
   {HighlightingKind::Macro, "Macro"}};
@@ -175,7 +178,7 @@
   }
   template
   struct $Class[[C]] : $Namespace[[abc]]::$Class[[A]]<$TemplateParameter[[T]]> {
-typename $TemplateParameter[[T]]::A* $Field[[D]];
+typename $TemplateParameter[[T]]::$DependentType[[A]]* $Field[[D]];
   };
   $Namespace[[abc]]::$Class[[A]]<$Primitive[[int]]> $Variable[[AA]];
   typedef $Namespace[[abc]]::$Class[[A]]<$Primitive[[int]]> $Class[[AAA]];
@@ -523,6 +526,58 @@
   $Typedef[[Pointer]], $Typedef[[LVReference]], $Typedef[[RVReference]],
   $Typedef[[Array]], $Typedef[[MemberPointer]]);
   };
+)cpp",
+  R"cpp(
+  template 
+  $Primitive[[void]] $Function[[phase1]]($TemplateParameter[[T]]);
+  template 
+  $Primitive[[void]] $Function[[foo]]($TemplateParameter[[T]] $Parameter[[P]]) {
+$Function[[phase1]]($Parameter[[P]]);
+$DependentName[[phase2]]($Parameter[[P]]);
+  }
+)cpp",
+  R"cpp(
+  class $Class[[A]] {
+template 
+$Primitive[[void]] $Method[[bar]]($TemplateParameter[[T]]);
+  };
+
+  template 
+  $Primitive[[void]] $Function[[foo]]($TemplateParameter[[U]] $Parameter[[P]]) {
+$Class[[A]]().$Method[[bar]]($Parameter[[P]]);
+  }
+)cpp",
+  R"cpp(
+  struct $Class[[A]] {
+template 
+static $Primitive[[void]] $StaticMethod[[foo]]($TemplateParameter[[T]]);
+  };
+
+  template 
+  struct $Class[[B]] {
+$Primitive[[void]] $Method[[bar]]() {
+  $Class[[A]]::$StaticMethod[[foo]]($TemplateParameter[[T]]());
+}
+  };
+)cpp",
+  R"cpp(
+  template 
+  $Primitive[[void]] $Function[[foo]](typename $TemplateParameter[[T]]::$DependentType[[Type]]
+= $TemplateParameter[[T]]::$DependentName[[val]]);
+)cpp",
+  R"cpp(
+  template 
+  $Primitive[[void]] $Function[[foo]]($TemplateParameter[[T]] $Parameter[[P]]) {
+$Parameter[[P]].$DependentName[[Field]];
+  }
+)cpp",
+  R"cpp(
+  template 
+  class $Class[[A]] {
+$Primitive[[int]] $Method[[foo]]() {
+  return $TemplateParameter[[T]]::$DependentName[[Field]];
+}
+  };
 )cpp"};
   for (const auto  : TestCases) {
 checkHighlightings(TestCase);
Index: clang-tools-extra/clangd/test/semantic-highlighting.test
===
--- clang-tools-extra/clangd/test/semantic-highlighting.test
+++ clang-tools-extra/clangd/test/semantic-highlighting.test
@@ -41,6 +41,12 @@
 # CHECK-NEXT:"entity.name.type.typedef.cpp"
 # CHECK-NEXT:  ],
 # CHECK-NEXT:  [
+# CHECK-NEXT:"entity.name.type.dependent.cpp"
+# CHECK-NEXT:  ],
+# CHECK-NEXT:  [
+# CHECK-NEXT:"entity.name.other.dependent.cpp"
+# CHECK-NEXT:  ],
+# CHECK-NEXT:  [
 # CHECK-NEXT:"entity.name.namespace.cpp"
 # CHECK-NEXT:  ],
 # CHECK-NEXT:  [
@@ -61,7 +67,7 @@
 # CHECK-NEXT:"lines": [
 # CHECK-NEXT:  {
 # CHECK-NEXT:"line": 0,
-# CHECK-NEXT:"tokens": "AAADAA4EAAEAAA=="
+# CHECK-NEXT:"tokens": "AAADABAEAAEAAA=="
 # CHECK-NEXT:  }
 # CHECK-NEXT:],
 # CHECK-NEXT:"textDocument": {
@@ -76,11 +82,11 @@
 # CHECK-NEXT:"lines": [
 # CHECK-NEXT:  {
 # CHECK-NEXT:"line": 0,
-# CHECK-NEXT:"tokens": "AAADAA4EAAEAAA=="
+# CHECK-NEXT:"tokens": "AAADABAEAAEAAA=="
 # CHECK-NEXT:  }
 # CHECK-NEXT:  {
 # 

[PATCH] D68824: Fix __builtin_assume_aligned with too large values.

2019-10-10 Thread Hal Finkel via Phabricator via cfe-commits
hfinkel added inline comments.



Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:2854
+def warn_assume_align_too_big : Warning<"alignments greater than 1 << 29 are "
+  "unsupported by LLVM">, InGroup;
 

Should this be in the IgnoredAttributes group? The builtin is not an attribute.

Also, I'd rather that the wording were similar to that used by 
err_attribute_aligned_too_great and other errors, and use 268435456 (which is 
what we get for MaxValidAlignment based on LLVM restrictions) instead of '1 << 
29'.





Comment at: clang/lib/Sema/SemaChecking.cpp:6066
  << Arg->getSourceRange();
+if (Result > (1 << 29ULL))
+  Diag(TheCall->getBeginLoc(), diag::warn_assume_align_too_big)

lebedev.ri wrote:
> `(1ULL << 29ULL)`.
> Is there some define for this somwhere, don't like magic numbers.
Yep, there's Value::MaximumAlignment.

We have:


  // Alignment calculations can wrap around if it's greater than 2**28.
  unsigned MaxValidAlignment =
  Context.getTargetInfo().getTriple().isOSBinFormatCOFF() ? 8192
  : 268435456;

in Sema::AddAlignedAttr. which also has the magic-number problem.


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

https://reviews.llvm.org/D68824



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


[PATCH] D68824: Fix __builtin_assume_aligned with too large values.

2019-10-10 Thread Erich Keane via Phabricator via cfe-commits
erichkeane updated this revision to Diff 224449.
erichkeane added a comment.

Remove unused code


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

https://reviews.llvm.org/D68824

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/CodeGen/CGExprScalar.cpp
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/lib/Sema/SemaChecking.cpp
  clang/test/Sema/builtin-assume-aligned.c

Index: clang/test/Sema/builtin-assume-aligned.c
===
--- clang/test/Sema/builtin-assume-aligned.c
+++ clang/test/Sema/builtin-assume-aligned.c
@@ -58,3 +58,7 @@
 void *test_no_fn_proto() __attribute__((assume_aligned())); // expected-error {{'assume_aligned' attribute takes at least 1 argument}}
 void *test_no_fn_proto() __attribute__((assume_aligned(32, 45, 37))); // expected-error {{'assume_aligned' attribute takes no more than 2 arguments}}
 
+int pr43638(int *a) {
+  a = __builtin_assume_aligned(a, 4294967296); // expected-warning {{alignments greater than 1 << 29 are unsupported by LLVM}}
+  return a[0];
+}
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -6063,6 +6063,9 @@
 if (!Result.isPowerOf2())
   return Diag(TheCall->getBeginLoc(), diag::err_alignment_not_power_of_two)
  << Arg->getSourceRange();
+if (Result > (1 << 29ULL))
+  Diag(TheCall->getBeginLoc(), diag::warn_assume_align_too_big)
+ << Arg->getSourceRange();
   }
 
   if (NumArgs > 2) {
Index: clang/lib/CodeGen/CodeGenFunction.h
===
--- clang/lib/CodeGen/CodeGenFunction.h
+++ clang/lib/CodeGen/CodeGenFunction.h
@@ -2829,13 +2829,8 @@
llvm::Value *Alignment,
llvm::Value *OffsetValue = nullptr);
 
-  void EmitAlignmentAssumption(llvm::Value *PtrValue, QualType Ty,
-   SourceLocation Loc, SourceLocation AssumptionLoc,
-   unsigned Alignment,
-   llvm::Value *OffsetValue = nullptr);
-
   void EmitAlignmentAssumption(llvm::Value *PtrValue, const Expr *E,
-   SourceLocation AssumptionLoc, unsigned Alignment,
+   SourceLocation AssumptionLoc, llvm::Value *Alignment,
llvm::Value *OffsetValue = nullptr);
 
   //======//
Index: clang/lib/CodeGen/CodeGenFunction.cpp
===
--- clang/lib/CodeGen/CodeGenFunction.cpp
+++ clang/lib/CodeGen/CodeGenFunction.cpp
@@ -2057,24 +2057,9 @@
 }
 
 void CodeGenFunction::EmitAlignmentAssumption(llvm::Value *PtrValue,
-  QualType Ty, SourceLocation Loc,
-  SourceLocation AssumptionLoc,
-  unsigned Alignment,
-  llvm::Value *OffsetValue) {
-  llvm::Value *TheCheck;
-  llvm::Instruction *Assumption = Builder.CreateAlignmentAssumption(
-  CGM.getDataLayout(), PtrValue, Alignment, OffsetValue, );
-  if (SanOpts.has(SanitizerKind::Alignment)) {
-llvm::Value *AlignmentVal = llvm::ConstantInt::get(IntPtrTy, Alignment);
-EmitAlignmentAssumptionCheck(PtrValue, Ty, Loc, AssumptionLoc, AlignmentVal,
- OffsetValue, TheCheck, Assumption);
-  }
-}
-
-void CodeGenFunction::EmitAlignmentAssumption(llvm::Value *PtrValue,
   const Expr *E,
   SourceLocation AssumptionLoc,
-  unsigned Alignment,
+  llvm::Value *Alignment,
   llvm::Value *OffsetValue) {
   if (auto *CE = dyn_cast(E))
 E = CE->getSubExprAsWritten();
Index: clang/lib/CodeGen/CGStmtOpenMP.cpp
===
--- clang/lib/CodeGen/CGStmtOpenMP.cpp
+++ clang/lib/CodeGen/CGStmtOpenMP.cpp
@@ -1519,14 +1519,14 @@
   if (!CGF.HaveInsertPoint())
 return;
   for (const auto *Clause : D.getClausesOfKind()) {
-unsigned ClauseAlignment = 0;
+size_t ClauseAlignment = 0;
 if (const Expr *AlignmentExpr = Clause->getAlignment()) {
   auto *AlignmentCI =
   cast(CGF.EmitScalarExpr(AlignmentExpr));
-  ClauseAlignment = static_cast(AlignmentCI->getZExtValue());
+  ClauseAlignment = AlignmentCI->getZExtValue();
 }
 for (const Expr *E : Clause->varlists()) {
-  

[PATCH] D68825: [libTooling] Change Stencil equality to use `toString()`

2019-10-10 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel created this revision.
ymandel added a reviewer: gribozavr.
Herald added a project: clang.
ymandel edited the summary of this revision.

Removes the `isEqual` method from StencilPartInterface and modifies equality to
use the string representation returned by the `toString` method for comparison.

This means the `run` and `selection` stencils return true by default, and
clients should be cautious in relying on equality operator for comparison of
stencils containing parts generated by these functions.

It also means we no longer need the custom RTTI support, so it has been removed.

Patch by Harshal T. Lehri.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D68825

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

Index: clang/unittests/Tooling/StencilTest.cpp
===
--- clang/unittests/Tooling/StencilTest.cpp
+++ clang/unittests/Tooling/StencilTest.cpp
@@ -375,19 +375,30 @@
   EXPECT_NE(Lhs, Rhs);
 }
 
-// node is opaque and therefore cannot be examined for equality.
-TEST(StencilEqualityTest, InEqualitySelection) {
-  auto S1 = cat(node("node"));
-  auto S2 = cat(node("node"));
-  EXPECT_NE(S1, S2);
-}
-
-// `run` is opaque.
-TEST(StencilEqualityTest, InEqualityRun) {
-  auto F = [](const MatchResult ) { return "foo"; };
-  auto S1 = cat(run(F));
-  auto S2 = cat(run(F));
-  EXPECT_NE(S1, S2);
+// For stencils generated by `selection`, equality returns true by default
+// even if different selectors are used in the stencils.
+TEST(StencilEqualityTest, EqualitySelection) {
+  auto S1 = cat(node("node1"));
+  auto S1Dup = cat(node("node1"));
+  auto S2 = cat(node("node2"));
+  auto T = cat("foo");
+  EXPECT_EQ(S1, S1Dup);
+  EXPECT_EQ(S1, S2);
+  EXPECT_NE(S1, T);
+}
+
+// For stencils generated by `run`, equality returns true by default even if
+// different functions are used in the stencils.
+TEST(StencilEqualityTest, EqualityRun) {
+  auto F1 = [](const MatchResult ) { return "foo"; };
+  auto F2 = [](const MatchResult ) { return "bar"; };
+  auto S1 = cat(run(F1));
+  auto S1Dup = cat(run(F1));
+  auto S2 = cat(run(F2));
+  auto T = cat("foo");
+  EXPECT_EQ(S1, S1Dup);
+  EXPECT_EQ(S1, S2);
+  EXPECT_NE(S1, T);
 }
 
 TEST(StencilToStringTest, RawTextOp) {
Index: clang/lib/Tooling/Transformer/Stencil.cpp
===
--- clang/lib/Tooling/Transformer/Stencil.cpp
+++ clang/lib/Tooling/Transformer/Stencil.cpp
@@ -31,14 +31,6 @@
 using llvm::Expected;
 using llvm::StringError;
 
-// A down_cast function to safely down cast a StencilPartInterface to a subclass
-// D. Returns nullptr if P is not an instance of D.
-template  const D *down_cast(const StencilPartInterface *P) {
-  if (P == nullptr || D::typeId() != P->typeId())
-return nullptr;
-  return static_cast(P);
-}
-
 static llvm::Expected
 getNode(const ast_matchers::BoundNodes , StringRef Id) {
   auto  = Nodes.getMap();
@@ -100,35 +92,6 @@
   StencilPart FalsePart;
 };
 
-bool isEqualData(const RawTextData , const RawTextData ) {
-  return A.Text == B.Text;
-}
-
-bool isEqualData(const DebugPrintNodeData , const DebugPrintNodeData ) {
-  return A.Id == B.Id;
-}
-
-bool isEqualData(const UnaryOperationData , const UnaryOperationData ) {
-  return A.Op == B.Op && A.Id == B.Id;
-}
-
-// Equality is not (yet) defined for \c RangeSelector.
-bool isEqualData(const SelectorData &, const SelectorData &) { return false; }
-
-bool isEqualData(const AccessData , const AccessData ) {
-  return A.BaseId == B.BaseId && A.Member == B.Member;
-}
-
-bool isEqualData(const IfBoundData , const IfBoundData ) {
-  return A.Id == B.Id && A.TruePart == B.TruePart && A.FalsePart == B.FalsePart;
-}
-
-// Equality is not defined over MatchConsumers, which are opaque.
-bool isEqualData(const MatchConsumer ,
- const MatchConsumer ) {
-  return false;
-}
-
 std::string toStringData(const RawTextData ) {
   std::string Result;
   llvm::raw_string_ostream OS(Result);
@@ -275,28 +238,13 @@
 
 public:
   template 
-  explicit StencilPartImpl(Ps &&... Args)
-  : StencilPartInterface(StencilPartImpl::typeId()),
-Data(std::forward(Args)...) {}
-
-  // Generates a unique identifier for this class (specifically, one per
-  // instantiation of the template).
-  static const void* typeId() {
-static bool b;
-return 
-  }
+  explicit StencilPartImpl(Ps &&... Args) : Data(std::forward(Args)...) {}
 
   Error eval(const MatchFinder::MatchResult ,
  std::string *Result) const override {
 return evalData(Data, Match, Result);
   }
 
-  bool isEqual(const StencilPartInterface ) const override {
-if (const auto *OtherPtr = down_cast())
-  return isEqualData(Data, OtherPtr->Data);
-return false;
-  }
-
   std::string toString() const override { return toStringData(Data); }
 };
 } // namespace

[PATCH] D68824: Fix __builtin_assume_aligned with too large values.

2019-10-10 Thread Erich Keane via Phabricator via cfe-commits
erichkeane created this revision.
erichkeane added reviewers: lebedev.ri, hfinkel, joey, jdoerfert.
lebedev.ri added a comment.

Thanks, i like it.




Comment at: clang/lib/CodeGen/CodeGenFunction.cpp:2058-2073
+/*
 void CodeGenFunction::EmitAlignmentAssumption(llvm::Value *PtrValue,
   QualType Ty, SourceLocation Loc,
   SourceLocation AssumptionLoc,
   unsigned Alignment,
   llvm::Value *OffsetValue) {
   llvm::Value *TheCheck;

Just remove.



Comment at: clang/lib/CodeGen/CodeGenFunction.h:2831-2836
+/*
   void EmitAlignmentAssumption(llvm::Value *PtrValue, QualType Ty,
SourceLocation Loc, SourceLocation 
AssumptionLoc,
unsigned Alignment,
llvm::Value *OffsetValue = nullptr);
+*/

Just remove.



Comment at: clang/lib/Sema/SemaChecking.cpp:6066
  << Arg->getSourceRange();
+if (Result > (1 << 29ULL))
+  Diag(TheCall->getBeginLoc(), diag::warn_assume_align_too_big)

`(1ULL << 29ULL)`.
Is there some define for this somwhere, don't like magic numbers.


Code to handle __builtin_assume_aligned was allowing larger values, but
would convert this to unsigned along the way. This patch removes the
EmitAssumeAligned overloads that take unsigned to do away with this
problem.

Additionally, it adds a warning that values greater than 1 <<29 are
ignored by LLVM.


https://reviews.llvm.org/D68824

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/CodeGen/CGExprScalar.cpp
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/lib/Sema/SemaChecking.cpp
  clang/test/Sema/builtin-assume-aligned.c

Index: clang/test/Sema/builtin-assume-aligned.c
===
--- clang/test/Sema/builtin-assume-aligned.c
+++ clang/test/Sema/builtin-assume-aligned.c
@@ -58,3 +58,7 @@
 void *test_no_fn_proto() __attribute__((assume_aligned())); // expected-error {{'assume_aligned' attribute takes at least 1 argument}}
 void *test_no_fn_proto() __attribute__((assume_aligned(32, 45, 37))); // expected-error {{'assume_aligned' attribute takes no more than 2 arguments}}
 
+int pr43638(int *a) {
+  a = __builtin_assume_aligned(a, 4294967296); // expected-warning {{alignments greater than 1 << 29 are unsupported by LLVM}}
+  return a[0];
+}
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -6063,6 +6063,9 @@
 if (!Result.isPowerOf2())
   return Diag(TheCall->getBeginLoc(), diag::err_alignment_not_power_of_two)
  << Arg->getSourceRange();
+if (Result > (1 << 29ULL))
+  Diag(TheCall->getBeginLoc(), diag::warn_assume_align_too_big)
+ << Arg->getSourceRange();
   }
 
   if (NumArgs > 2) {
Index: clang/lib/CodeGen/CodeGenFunction.h
===
--- clang/lib/CodeGen/CodeGenFunction.h
+++ clang/lib/CodeGen/CodeGenFunction.h
@@ -2828,14 +2828,14 @@
SourceLocation Loc, SourceLocation AssumptionLoc,
llvm::Value *Alignment,
llvm::Value *OffsetValue = nullptr);
-
+/*
   void EmitAlignmentAssumption(llvm::Value *PtrValue, QualType Ty,
SourceLocation Loc, SourceLocation AssumptionLoc,
unsigned Alignment,
llvm::Value *OffsetValue = nullptr);
-
+*/
   void EmitAlignmentAssumption(llvm::Value *PtrValue, const Expr *E,
-   SourceLocation AssumptionLoc, unsigned Alignment,
+   SourceLocation AssumptionLoc, llvm::Value *Alignment,
llvm::Value *OffsetValue = nullptr);
 
   //======//
Index: clang/lib/CodeGen/CodeGenFunction.cpp
===
--- clang/lib/CodeGen/CodeGenFunction.cpp
+++ clang/lib/CodeGen/CodeGenFunction.cpp
@@ -2055,7 +2055,7 @@
  OffsetValue, TheCheck, Assumption);
   }
 }
-
+/*
 void CodeGenFunction::EmitAlignmentAssumption(llvm::Value *PtrValue,
   QualType Ty, SourceLocation Loc,
   SourceLocation AssumptionLoc,
@@ -2070,11 +2070,11 @@
  OffsetValue, TheCheck, Assumption);
   }
 }
-
+*/
 void 

[PATCH] D68753: [CUDA][HIP} Add a test for constexpr default ctor

2019-10-10 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl marked an inline comment as done.
yaxunl added inline comments.



Comment at: test/SemaCUDA/constexpr-ctor.cu:14-27
+template  struct B {
+  T a;
+  constexpr B() = default;
+};
+
+template  struct C {
+  T a;

tra wrote:
> Do we really need three identical templates? If they are needed to let 
> compiler emit multiple diagnostics, perhaps we could just add another 
> template parameter so we can get different instantiations.
the error is emitted on the default ctor of the template. If we do not use 
different templates, all errors are emitted on the same line, we cannot make 
sure some instantiations do not cause error and some instantiations should 
cause error.

Adding template parameter will not help, because the error will still be 
emitted to the same line.


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

https://reviews.llvm.org/D68753



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


[PATCH] D68824: Fix __builtin_assume_aligned with too large values.

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

Thanks, i like it.




Comment at: clang/lib/CodeGen/CodeGenFunction.cpp:2058-2073
+/*
 void CodeGenFunction::EmitAlignmentAssumption(llvm::Value *PtrValue,
   QualType Ty, SourceLocation Loc,
   SourceLocation AssumptionLoc,
   unsigned Alignment,
   llvm::Value *OffsetValue) {
   llvm::Value *TheCheck;

Just remove.



Comment at: clang/lib/CodeGen/CodeGenFunction.h:2831-2836
+/*
   void EmitAlignmentAssumption(llvm::Value *PtrValue, QualType Ty,
SourceLocation Loc, SourceLocation 
AssumptionLoc,
unsigned Alignment,
llvm::Value *OffsetValue = nullptr);
+*/

Just remove.



Comment at: clang/lib/Sema/SemaChecking.cpp:6066
  << Arg->getSourceRange();
+if (Result > (1 << 29ULL))
+  Diag(TheCall->getBeginLoc(), diag::warn_assume_align_too_big)

`(1ULL << 29ULL)`.
Is there some define for this somwhere, don't like magic numbers.


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

https://reviews.llvm.org/D68824



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


  1   2   >