[PATCH] D36070: [coroutines] Evaluate the operand of void `co_return` expressions.

2017-07-31 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF added inline comments.



Comment at: test/CodeGenCoroutines/coro-ret-void.cpp:30
+coro1 f2() {
+  co_return(void) A{};
+}

rsmith wrote:
> This seems like an extremely confusing way to format this statement. Maybe 
> move the space left a bit?
Urg. `git clang-format` strikes again. I'm working on a patch to teach 
`clang-format` about coroutines. This is just more motivation :-)

I'll fix the formatting before committing. 


https://reviews.llvm.org/D36070



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


r309545 - [coroutines] Evaluate the operand of void `co_return` expressions.

2017-07-31 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Mon Jul 31 00:48:13 2017
New Revision: 309545

URL: http://llvm.org/viewvc/llvm-project?rev=309545&view=rev
Log:
[coroutines] Evaluate the operand of void `co_return` expressions.

Summary:
Previously Clang incorrectly ignored the expression of a void `co_return`. This 
patch addresses that bug.

I'm not quite sure if I got the code-gen right, but this patch is at least a 
start.

Reviewers: rsmith, GorNishanov

Reviewed By: rsmith, GorNishanov

Subscribers: cfe-commits

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

Modified:
cfe/trunk/lib/CodeGen/CGCoroutine.cpp
cfe/trunk/test/CodeGenCoroutines/coro-ret-void.cpp

Modified: cfe/trunk/lib/CodeGen/CGCoroutine.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCoroutine.cpp?rev=309545&r1=309544&r2=309545&view=diff
==
--- cfe/trunk/lib/CodeGen/CGCoroutine.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCoroutine.cpp Mon Jul 31 00:48:13 2017
@@ -234,6 +234,13 @@ RValue CodeGenFunction::EmitCoyieldExpr(
 
 void CodeGenFunction::EmitCoreturnStmt(CoreturnStmt const &S) {
   ++CurCoro.Data->CoreturnCount;
+  const Expr *RV = S.getOperand();
+  if (RV && RV->getType()->isVoidType()) {
+// Make sure to evaluate the expression of a co_return with a void
+// expression for side effects.
+RunCleanupsScope cleanupScope(*this);
+EmitIgnoredExpr(RV);
+  }
   EmitStmt(S.getPromiseCall());
   EmitBranchThroughCleanup(CurCoro.Data->FinalJD);
 }

Modified: cfe/trunk/test/CodeGenCoroutines/coro-ret-void.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCoroutines/coro-ret-void.cpp?rev=309545&r1=309544&r2=309545&view=diff
==
--- cfe/trunk/test/CodeGenCoroutines/coro-ret-void.cpp (original)
+++ cfe/trunk/test/CodeGenCoroutines/coro-ret-void.cpp Mon Jul 31 00:48:13 2017
@@ -21,6 +21,20 @@ coro1 f() {
 // CHECK: call void 
@_ZNSt12experimental13coroutines_v113suspend_never12await_resumeEv(%"struct.std::experimental::coroutines_v1::suspend_never"*
 // CHECK: call void 
@_ZN5coro112promise_type11return_voidEv(%"struct.coro1::promise_type"* 
%__promise)
 
+struct A {
+  A();
+  ~A();
+};
+
+coro1 f2() {
+  co_return (void) A{};
+}
+
+// CHECK-LABEL: define void @_Z2f2v(
+// CHECK: call void @_ZN1AC1Ev(%struct.A* %[[AVar:.*]])
+// CHECK-NEXT: call void @_ZN1AD1Ev(%struct.A* %[[AVar]])
+// CHECK-NEXT: call void 
@_ZN5coro112promise_type11return_voidEv(%"struct.coro1::promise_type"*
+
 struct coro2 {
   struct promise_type {
 coro2 get_return_object();


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


[PATCH] D36074: [x86][inline-asm]Allow a pack of Control Debug to be properly picked

2017-07-31 Thread coby via Phabricator via cfe-commits
coby created this revision.
Herald added a subscriber: eraman.

Allows the incorporation of legit (x86) Debug Regs within inline asm stataements


Repository:
  rL LLVM

https://reviews.llvm.org/D36074

Files:
  lib/Basic/Targets/X86.cpp
  test/CodeGen/ms-inline-asm.c


Index: lib/Basic/Targets/X86.cpp
===
--- lib/Basic/Targets/X86.cpp
+++ lib/Basic/Targets/X86.cpp
@@ -59,6 +59,7 @@
 "zmm26", "zmm27", "zmm28", "zmm29", "zmm30",   "zmm31", "k0","k1",
 "k2","k3","k4","k5","k6",  "k7",
 "cr0",   "cr2",   "cr3",   "cr4",   "cr8",
+"dr0",   "dr1",   "dr2",   "dr3",   "dr6", "dr7",
 };
 
 const TargetInfo::AddlRegName AddlRegNames[] = {
Index: test/CodeGen/ms-inline-asm.c
===
--- test/CodeGen/ms-inline-asm.c
+++ test/CodeGen/ms-inline-asm.c
@@ -638,6 +638,19 @@
   // CHECK: call void asm sideeffect inteldialect "mov cr0, eax\0A\09mov cr2, 
ebx\0A\09mov cr3, ecx\0A\09mov cr4, edx", 
"~{cr0},~{cr2},~{cr3},~{cr4},~{dirflag},~{fpsr},~{flags}"()
 }
 
+void t45() {
+  // CHECK-LABEL: define void @t45
+  __asm {
+mov dr0, eax
+mov dr1, ebx
+mov dr2, ebx
+mov dr3, ecx
+mov dr6, edx
+mov dr7, ecx
+  }
+  // CHECK: call void asm sideeffect inteldialect "mov dr0, eax\0A\09mov dr1, 
ebx\0A\09mov dr2, ebx\0A\09mov dr3, ecx\0A\09mov dr6, edx\0A\09mov dr7, ecx", 
"~{dr0},~{dr1},~{dr2},~{dr3},~{dr6},~{dr7},~{dirflag},~{fpsr},~{flags}"()
+}
+
 void dot_operator(){
 // CHECK-LABEL: define void @dot_operator
__asm { mov eax, 3[ebx]A.b}


Index: lib/Basic/Targets/X86.cpp
===
--- lib/Basic/Targets/X86.cpp
+++ lib/Basic/Targets/X86.cpp
@@ -59,6 +59,7 @@
 "zmm26", "zmm27", "zmm28", "zmm29", "zmm30",   "zmm31", "k0","k1",
 "k2","k3","k4","k5","k6",  "k7",
 "cr0",   "cr2",   "cr3",   "cr4",   "cr8",
+"dr0",   "dr1",   "dr2",   "dr3",   "dr6", "dr7",
 };
 
 const TargetInfo::AddlRegName AddlRegNames[] = {
Index: test/CodeGen/ms-inline-asm.c
===
--- test/CodeGen/ms-inline-asm.c
+++ test/CodeGen/ms-inline-asm.c
@@ -638,6 +638,19 @@
   // CHECK: call void asm sideeffect inteldialect "mov cr0, eax\0A\09mov cr2, ebx\0A\09mov cr3, ecx\0A\09mov cr4, edx", "~{cr0},~{cr2},~{cr3},~{cr4},~{dirflag},~{fpsr},~{flags}"()
 }
 
+void t45() {
+  // CHECK-LABEL: define void @t45
+  __asm {
+mov dr0, eax
+mov dr1, ebx
+mov dr2, ebx
+mov dr3, ecx
+mov dr6, edx
+mov dr7, ecx
+  }
+  // CHECK: call void asm sideeffect inteldialect "mov dr0, eax\0A\09mov dr1, ebx\0A\09mov dr2, ebx\0A\09mov dr3, ecx\0A\09mov dr6, edx\0A\09mov dr7, ecx", "~{dr0},~{dr1},~{dr2},~{dr3},~{dr6},~{dr7},~{dirflag},~{fpsr},~{flags}"()
+}
+
 void dot_operator(){
 // CHECK-LABEL: define void @dot_operator
 	__asm { mov eax, 3[ebx]A.b}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D36075: [refactor] Initial support for refactoring action rules

2017-07-31 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman created this revision.
Herald added a subscriber: mgorny.

This patch implements a couple of functions that were described in my RFC from 
last week that’s available at 
http://lists.llvm.org/pipermail/cfe-dev/2017-July/054831.html. This patch adds 
the following pieces: `apply` function, `selectionRequirement` function, and 
the `selection::SourceSelectionRange` constraint.

This code will be used as a base to start moving the functionality and tests 
for clang-rename over to clang-refactor.

Unfortunately I had to use slightly different code for MSVC in the 
`selectionRequirement` overloads that take a lambda as MSVC fails to deduce the 
return type because of how it handles templates. I came up with a solution that 
seems to work with MSVC 2015 (the min version supported by LLVM), and I’ve 
tested the lambda overload code with cl 19.00.23506.


Repository:
  rL LLVM

https://reviews.llvm.org/D36075

Files:
  include/clang/Basic/LLVM.h
  include/clang/Tooling/Refactoring/AtomicChange.h
  include/clang/Tooling/Refactoring/DiagOr.h
  include/clang/Tooling/Refactoring/RefactoringActionRules.h
  include/clang/Tooling/Refactoring/RefactoringOperationController.h
  include/clang/Tooling/Refactoring/RefactoringResult.h
  include/clang/Tooling/Refactoring/SourceSelectionConstraints.h
  unittests/Tooling/CMakeLists.txt
  unittests/Tooling/RefactoringActionRulesTest.cpp

Index: unittests/Tooling/RefactoringActionRulesTest.cpp
===
--- /dev/null
+++ unittests/Tooling/RefactoringActionRulesTest.cpp
@@ -0,0 +1,148 @@
+//===- unittest/Tooling/RefactoringTestActionRulesTest.cpp ===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "ReplacementTest.h"
+#include "RewriterTestContext.h"
+#include "clang/Tooling/Refactoring.h"
+#include "clang/Tooling/Refactoring/RefactoringActionRules.h"
+#include "clang/Tooling/Tooling.h"
+#include "gtest/gtest.h"
+
+using namespace clang;
+using namespace tooling;
+using namespace refactoring_action_rules;
+
+namespace {
+
+class RefactoringActionRulesTest : public ::testing::Test {
+protected:
+  void SetUp() override {
+Context.Sources.setMainFileID(
+Context.createInMemoryFile("input.cpp", DefaultCode));
+  }
+
+  RewriterTestContext Context;
+  std::string DefaultCode = std::string(100, 'a');
+};
+
+TEST_F(RefactoringActionRulesTest, MyFirstRefactoringRule) {
+  auto ReplaceAWithB =
+  [](std::pair Selection)
+  -> Expected {
+const SourceManager &SM = Selection.first.getSources();
+SourceLocation Loc = Selection.first.getRange().getBegin().getLocWithOffset(
+Selection.second);
+AtomicChange Change(SM, Loc);
+llvm::Error E = Change.replace(SM, Loc, 1, "b");
+if (E)
+  return std::move(E);
+return Change;
+  };
+  auto Rule =
+  apply(ReplaceAWithB,
+selectionRequirement([](selection::SourceSelectionRange Selection) {
+  return std::make_pair(Selection, 20);
+}));
+
+  // When the requirements are satisifed, the rule's function must be invoked.
+  {
+RefactoringOperationController Operation(Context.Sources);
+SourceLocation Cursor =
+Context.Sources.getLocForStartOfFile(Context.Sources.getMainFileID())
+.getLocWithOffset(10);
+Operation.setSelectionRange({Cursor, Cursor});
+
+DiagOr> DiagOrResult = Rule->perform(Operation);
+ASSERT_FALSE(!DiagOrResult);
+Expected Result = std::move(*DiagOrResult);
+ASSERT_FALSE(!Result);
+ASSERT_EQ(Result->getKind(), RefactoringResult::AtomicChanges);
+ASSERT_EQ(Result->getChanges().size(), 1u);
+std::string YAMLString = Result->getChanges()[0].toYAMLString();
+
+ASSERT_STREQ("---\n"
+ "Key: 'input.cpp:30'\n"
+ "FilePath:input.cpp\n"
+ "Error:   ''\n"
+ "InsertedHeaders: \n"
+ "RemovedHeaders:  \n"
+ "Replacements:\n" // Extra whitespace here!
+ "  - FilePath:input.cpp\n"
+ "Offset:  30\n"
+ "Length:  1\n"
+ "ReplacementText: b\n"
+ "...\n",
+ YAMLString.c_str());
+  }
+
+  // When one of the requirements is not satisfied, perform should return either
+  // None or a valid diagnostic.
+  {
+RefactoringOperationController Operation(Context.Sources);
+DiagOr> DiagOrResult = Rule->perform(Operation);
+
+ASSERT_TRUE(!DiagOrResult);
+auto DiagOrNone = DiagOrResult.getDiag();
+ASSERT_TRUE(!DiagOrNone);
+  }
+}
+
+TEST_F(RefactoringActionRulesTest, ReturnError) {
+  Expected (*Func)(selection::SourceSelectionRang

[PATCH] D34873: Fix miscompiled 32bit binaries by mingw

2017-07-31 Thread Ivan Donchevskii via Phabricator via cfe-commits
yvvan updated this revision to Diff 108878.
yvvan marked 2 inline comments as done.
yvvan added a comment.

Make safe solution without regression


https://reviews.llvm.org/D34873

Files:
  lib/AST/ExprConstant.cpp


Index: lib/AST/ExprConstant.cpp
===
--- lib/AST/ExprConstant.cpp
+++ lib/AST/ExprConstant.cpp
@@ -537,7 +537,11 @@
   /// rules.  For example, the RHS of (0 && foo()) is not evaluated.  We can
   /// evaluate the expression regardless of what the RHS is, but C only allows
   /// certain things in certain situations.
+#ifndef _WIN32
   struct LLVM_ALIGNAS(/*alignof(uint64_t)*/ 8) EvalInfo {
+#else
+  struct EvalInfo {
+#endif
 ASTContext &Ctx;
 
 /// EvalStatus - Contains information about the evaluation.
@@ -575,7 +579,21 @@
 
 /// The current array initialization index, if we're performing array
 /// initialization.
+#ifndef _WIN32
 uint64_t ArrayInitIndex = -1;
+#else
+/// uint64_t value is split into two uint32_t values as a workaround
+/// to deal with mingw 32-bit miscompilation
+uint32_t ArrayInitIndex[2] = {static_cast(-1), 
static_cast(-1)};
+uint64_t GetArrayInitIndex() {
+  return (static_cast(ArrayInitIndex[0]) << 32)
++ static_cast(ArrayInitIndex[1]);
+}
+void SetArrayInitIndex(uint64_t index) {
+ArrayInitIndex[0] = static_cast(index >> 32);
+ArrayInitIndex[1] = static_cast(index);
+}
+#endif
 
 /// HasActiveDiagnostic - Was the previous diagnostic stored? If so, 
further
 /// notes attached to it will also be stored, otherwise they will not be.
@@ -922,13 +940,27 @@
   uint64_t OuterIndex;
 
 public:
+#ifndef _WIN32
   ArrayInitLoopIndex(EvalInfo &Info)
   : Info(Info), OuterIndex(Info.ArrayInitIndex) {
 Info.ArrayInitIndex = 0;
   }
   ~ArrayInitLoopIndex() { Info.ArrayInitIndex = OuterIndex; }
 
   operator uint64_t&() { return Info.ArrayInitIndex; }
+#else
+  ArrayInitLoopIndex(EvalInfo &Info)
+  : Info(Info), OuterIndex(Info.GetArrayInitIndex()) {
+Info.SetArrayInitIndex(0);
+  }
+  ~ArrayInitLoopIndex() { Info.SetArrayInitIndex(OuterIndex); }
+
+  operator uint64_t() { return Info.GetArrayInitIndex(); }
+  ArrayInitLoopIndex& operator++() {
+  Info.SetArrayInitIndex(Info.GetArrayInitIndex() + 1);
+  return *this;
+  }
+#endif
 };
   };
 
@@ -6973,13 +7005,21 @@
   }
 
   bool VisitArrayInitIndexExpr(const ArrayInitIndexExpr *E) {
+#ifndef _WIN32
 if (Info.ArrayInitIndex == uint64_t(-1)) {
+#else
+if (Info.GetArrayInitIndex() == uint64_t(-1)) {
+#endif
   // We were asked to evaluate this subexpression independent of the
   // enclosing ArrayInitLoopExpr. We can't do that.
   Info.FFDiag(E);
   return false;
 }
+#ifndef _WIN32
 return Success(Info.ArrayInitIndex, E);
+#else
+return Success(Info.GetArrayInitIndex(), E);
+#endif
   }
 
   // Note, GNU defines __null as an integer, not a pointer.


Index: lib/AST/ExprConstant.cpp
===
--- lib/AST/ExprConstant.cpp
+++ lib/AST/ExprConstant.cpp
@@ -537,7 +537,11 @@
   /// rules.  For example, the RHS of (0 && foo()) is not evaluated.  We can
   /// evaluate the expression regardless of what the RHS is, but C only allows
   /// certain things in certain situations.
+#ifndef _WIN32
   struct LLVM_ALIGNAS(/*alignof(uint64_t)*/ 8) EvalInfo {
+#else
+  struct EvalInfo {
+#endif
 ASTContext &Ctx;
 
 /// EvalStatus - Contains information about the evaluation.
@@ -575,7 +579,21 @@
 
 /// The current array initialization index, if we're performing array
 /// initialization.
+#ifndef _WIN32
 uint64_t ArrayInitIndex = -1;
+#else
+/// uint64_t value is split into two uint32_t values as a workaround
+/// to deal with mingw 32-bit miscompilation
+uint32_t ArrayInitIndex[2] = {static_cast(-1), static_cast(-1)};
+uint64_t GetArrayInitIndex() {
+  return (static_cast(ArrayInitIndex[0]) << 32)
++ static_cast(ArrayInitIndex[1]);
+}
+void SetArrayInitIndex(uint64_t index) {
+ArrayInitIndex[0] = static_cast(index >> 32);
+ArrayInitIndex[1] = static_cast(index);
+}
+#endif
 
 /// HasActiveDiagnostic - Was the previous diagnostic stored? If so, further
 /// notes attached to it will also be stored, otherwise they will not be.
@@ -922,13 +940,27 @@
   uint64_t OuterIndex;
 
 public:
+#ifndef _WIN32
   ArrayInitLoopIndex(EvalInfo &Info)
   : Info(Info), OuterIndex(Info.ArrayInitIndex) {
 Info.ArrayInitIndex = 0;
   }
   ~ArrayInitLoopIndex() { Info.ArrayInitIndex = OuterIndex; }
 
   operator uint64_t&() { return Info.ArrayInitIndex; }
+#else
+  ArrayInitLoopIndex(EvalInfo &Info)
+  : Info(Info), OuterIndex(Info.GetArrayInitIndex()) {
+Info.SetArrayInitIndex(0);
+  }

[PATCH] D30777: Added `applyAtomicChanges` function.

2017-07-31 Thread Eric Liu via Phabricator via cfe-commits
ioeric updated this revision to Diff 108881.
ioeric added a comment.

- Merged with origin/master


https://reviews.llvm.org/D30777

Files:
  include/clang/Tooling/Refactoring/AtomicChange.h
  lib/Tooling/Refactoring/AtomicChange.cpp
  lib/Tooling/Refactoring/CMakeLists.txt
  unittests/Tooling/RefactoringTest.cpp

Index: unittests/Tooling/RefactoringTest.cpp
===
--- unittests/Tooling/RefactoringTest.cpp
+++ unittests/Tooling/RefactoringTest.cpp
@@ -1295,5 +1295,427 @@
   Replacement(Context.Sources, SourceLocation(), 0, "b")));
 }
 
+class ApplyAtomicChangesTest : public ::testing::Test {
+protected:
+  ApplyAtomicChangesTest() : FilePath("file.cc") {
+Spec.Cleanup = true;
+Spec.Format = ApplyChangesSpec::kAll;
+Spec.Style = format::getLLVMStyle();
+  }
+
+  ~ApplyAtomicChangesTest() override {}
+
+  void setInput(llvm::StringRef Input) {
+Code = Input;
+FID = Context.createInMemoryFile(FilePath, Code);
+  }
+
+  SourceLocation getLoc(unsigned Offset) const {
+return Context.Sources.getLocForStartOfFile(FID).getLocWithOffset(Offset);
+  }
+
+  AtomicChange replacementToAtomicChange(llvm::StringRef Key, unsigned Offset,
+ unsigned Length,
+ llvm::StringRef Text) {
+AtomicChange Change(FilePath, Key);
+llvm::Error Err =
+Change.replace(Context.Sources, getLoc(Offset), Length, Text);
+EXPECT_FALSE(Err);
+return Change;
+  }
+
+  std::string rewrite(bool FailureExpected = false) {
+llvm::Expected ChangedCode =
+applyAtomicChanges(FilePath, Code, Changes, Spec);
+EXPECT_EQ(FailureExpected, !ChangedCode);
+if (!ChangedCode) {
+  llvm::errs() << "Failed to apply changes: "
+   << llvm::toString(ChangedCode.takeError()) << "\n";
+  return "";
+}
+return *ChangedCode;
+  }
+
+  RewriterTestContext Context;
+  FileID FID;
+  ApplyChangesSpec Spec;
+  std::string Code;
+  std::string FilePath;
+  llvm::SmallVector Changes;
+};
+
+TEST_F(ApplyAtomicChangesTest, BasicRefactoring) {
+  setInput("int a;");
+  AtomicChange Change(FilePath, "key1");
+  Changes.push_back(replacementToAtomicChange("key1", 4, 1, "b"));
+  EXPECT_EQ("int b;", rewrite());
+}
+
+TEST_F(ApplyAtomicChangesTest, SeveralRefactorings) {
+  setInput("int a;\n"
+   "int b;");
+  Changes.push_back(replacementToAtomicChange("key1", 0, 3, "float"));
+  Changes.push_back(replacementToAtomicChange("key2", 4, 1, "f"));
+  Changes.push_back(replacementToAtomicChange("key3", 11, 1, "g"));
+  Changes.push_back(replacementToAtomicChange("key4", 7, 3, "float"));
+  EXPECT_EQ("float f;\n"
+"float g;",
+rewrite());
+}
+
+TEST_F(ApplyAtomicChangesTest, IgnorePathsInRefactorings) {
+  setInput("int a;\n"
+   "int b;");
+  Changes.push_back(replacementToAtomicChange("key1", 4, 1, "aa"));
+
+  FileID ID = Context.createInMemoryFile("AnotherFile", "12345678912345");
+  Changes.emplace_back("AnotherFile", "key2");
+  auto Err = Changes.back().replace(
+  Context.Sources,
+  Context.Sources.getLocForStartOfFile(ID).getLocWithOffset(11), 1, "bb");
+  ASSERT_TRUE(!Err);
+  EXPECT_EQ("int aa;\n"
+"int bb;",
+rewrite());
+}
+
+TEST_F(ApplyAtomicChangesTest, AppliesDuplicateInsertions) {
+  setInput("int a;");
+  Changes.push_back(replacementToAtomicChange("key1", 5, 0, "b"));
+  Changes.push_back(replacementToAtomicChange("key2", 5, 0, "b"));
+  EXPECT_EQ("int abb;", rewrite());
+}
+
+TEST_F(ApplyAtomicChangesTest, BailsOnOverlappingRefactorings) {
+  setInput("int a;");
+  Changes.push_back(replacementToAtomicChange("key1", 0, 5, "float f"));
+  Changes.push_back(replacementToAtomicChange("key2", 4, 1, "b"));
+  EXPECT_EQ("", rewrite(/*FailureExpected=*/true));
+}
+
+TEST_F(ApplyAtomicChangesTest, BasicReformatting) {
+  setInput("int  a;");
+  Changes.push_back(replacementToAtomicChange("key1", 5, 1, "b"));
+  EXPECT_EQ("int b;", rewrite());
+}
+
+TEST_F(ApplyAtomicChangesTest, OnlyFormatWhenViolateColumnLimits) {
+  Spec.Format = ApplyChangesSpec::kViolations;
+  Spec.Style.ColumnLimit = 8;
+  setInput("int  a;\n"
+   "inta;\n"
+   "int  ;\n");
+  Changes.push_back(replacementToAtomicChange("key1", 5, 1, "x"));
+  Changes.push_back(replacementToAtomicChange("key2", 15, 1, "x"));
+  Changes.push_back(replacementToAtomicChange("key3", 23, 8, "xx"));
+  EXPECT_EQ("int  x;\n"
+"int x;\n"
+"int  xx;\n",
+rewrite());
+}
+
+TEST_F(ApplyAtomicChangesTest, LastLineViolateColumnLimits) {
+  Spec.Format = ApplyChangesSpec::kViolations;
+  Spec.Style.ColumnLimit = 8;
+  setInput("int  a;\n"
+   "inta;");
+  Changes.push_back(replacementToAtomicChange("key1", 0, 1, "i"));
+  Changes.push_back(replacementToAtomicChange("key2", 15, 2, "y;"));
+  EXPECT_EQ("int  a;\n"
+"int y;",
+

r309548 - Added `applyAtomicChanges` function.

2017-07-31 Thread Eric Liu via cfe-commits
Author: ioeric
Date: Mon Jul 31 02:22:34 2017
New Revision: 309548

URL: http://llvm.org/viewvc/llvm-project?rev=309548&view=rev
Log:
Added `applyAtomicChanges` function.

This re-commits r298913.
o See thread 
http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20170327/189084.html
o Tested with -DLLVM_ENABLE_LOCAL_SUBMODULE_VISIBILITY=0.

Summary: ... which applies a set of `AtomicChange`s on code.

Reviewers: klimek, djasper

Reviewed By: djasper

Subscribers: arphaman, mgorny, chapuni, cfe-commits

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

Modified:
cfe/trunk/include/clang/Tooling/Refactoring/AtomicChange.h
cfe/trunk/lib/Tooling/Refactoring/AtomicChange.cpp
cfe/trunk/lib/Tooling/Refactoring/CMakeLists.txt
cfe/trunk/unittests/Tooling/RefactoringTest.cpp

Modified: cfe/trunk/include/clang/Tooling/Refactoring/AtomicChange.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Tooling/Refactoring/AtomicChange.h?rev=309548&r1=309547&r2=309548&view=diff
==
--- cfe/trunk/include/clang/Tooling/Refactoring/AtomicChange.h (original)
+++ cfe/trunk/include/clang/Tooling/Refactoring/AtomicChange.h Mon Jul 31 
02:22:34 2017
@@ -16,6 +16,7 @@
 #define LLVM_CLANG_TOOLING_REFACTOR_ATOMICCHANGE_H
 
 #include "clang/Basic/SourceManager.h"
+#include "clang/Format/Format.h"
 #include "clang/Tooling/Core/Replacement.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Error.h"
@@ -129,6 +130,39 @@ private:
   tooling::Replacements Replaces;
 };
 
+// Defines specs for applying changes.
+struct ApplyChangesSpec {
+  // If true, cleans up redundant/erroneous code around changed code with
+  // clang-format's cleanup functionality, e.g. redundant commas around deleted
+  // parameter or empty namespaces introduced by deletions.
+  bool Cleanup = true;
+
+  format::FormatStyle Style = format::getNoStyle();
+
+  // Options for selectively formatting changes with clang-format:
+  // kAll: Format all changed lines.
+  // kNone: Don't format anything.
+  // kViolations: Format lines exceeding the `ColumnLimit` in `Style`.
+  enum FormatOption { kAll, kNone, kViolations };
+
+  FormatOption Format = kNone;
+};
+
+/// \brief Applies all AtomicChanges in \p Changes to the \p Code.
+///
+/// This completely ignores the file path in each change and replaces them with
+/// \p FilePath, i.e. callers are responsible for ensuring all changes are for
+/// the same file.
+///
+/// \returns The changed code if all changes are applied successfully;
+/// otherwise, an llvm::Error carrying llvm::StringError is returned (the Error
+/// message can be converted to string with `llvm::toString()` and the
+/// error_code should be ignored).
+llvm::Expected
+applyAtomicChanges(llvm::StringRef FilePath, llvm::StringRef Code,
+   llvm::ArrayRef Changes,
+   const ApplyChangesSpec &Spec);
+
 } // end namespace tooling
 } // end namespace clang
 

Modified: cfe/trunk/lib/Tooling/Refactoring/AtomicChange.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/Refactoring/AtomicChange.cpp?rev=309548&r1=309547&r2=309548&view=diff
==
--- cfe/trunk/lib/Tooling/Refactoring/AtomicChange.cpp (original)
+++ cfe/trunk/lib/Tooling/Refactoring/AtomicChange.cpp Mon Jul 31 02:22:34 2017
@@ -83,6 +83,116 @@ template <> struct MappingTraits Lines;
+  Code.substr(StartPos, EndPos - StartPos).split(Lines, '\n');
+  for (llvm::StringRef Line : Lines)
+if (Line.size() > ColumnLimit)
+  return true;
+  return false;
+}
+
+std::vector
+getRangesForFormating(llvm::StringRef Code, unsigned ColumnLimit,
+  ApplyChangesSpec::FormatOption Format,
+  const clang::tooling::Replacements &Replaces) {
+  // kNone suppresses formatting entirely.
+  if (Format == ApplyChangesSpec::kNone)
+return {};
+  std::vector Ranges;
+  // This works assuming that replacements are ordered by offset.
+  // FIXME: use `getAffectedRanges()` to calculate when it does not include 
'\n'
+  // at the end of an insertion in affected ranges.
+  int Offset = 0;
+  for (const clang::tooling::Replacement &R : Replaces) {
+int Start = R.getOffset() + Offset;
+int End = Start + R.getReplacementText().size();
+if (!R.getReplacementText().empty() &&
+R.getReplacementText().back() == '\n' && R.getLength() == 0 &&
+R.getOffset() > 0 && R.getOffset() <= Code.size() &&
+Code[R.getOffset() - 1] == '\n')
+  // If we are inserting at the start of a line and the replacement ends in
+  // a newline, we don't need to format the subsequent line.
+  --End;
+Offset += R.getReplacementText().size() - R.getLength();
+
+if (Format == ApplyChangesSpec::kAll ||
+violatesColumnLimit(Code, ColumnLimit, Start, End))
+  Ranges.emplace_back(Start, End - Start);
+  }
+  return 

[PATCH] D30777: Added `applyAtomicChanges` function.

2017-07-31 Thread Eric Liu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL309548: Added `applyAtomicChanges` function. (authored by 
ioeric).

Repository:
  rL LLVM

https://reviews.llvm.org/D30777

Files:
  cfe/trunk/include/clang/Tooling/Refactoring/AtomicChange.h
  cfe/trunk/lib/Tooling/Refactoring/AtomicChange.cpp
  cfe/trunk/lib/Tooling/Refactoring/CMakeLists.txt
  cfe/trunk/unittests/Tooling/RefactoringTest.cpp

Index: cfe/trunk/unittests/Tooling/RefactoringTest.cpp
===
--- cfe/trunk/unittests/Tooling/RefactoringTest.cpp
+++ cfe/trunk/unittests/Tooling/RefactoringTest.cpp
@@ -1295,5 +1295,427 @@
   Replacement(Context.Sources, SourceLocation(), 0, "b")));
 }
 
+class ApplyAtomicChangesTest : public ::testing::Test {
+protected:
+  ApplyAtomicChangesTest() : FilePath("file.cc") {
+Spec.Cleanup = true;
+Spec.Format = ApplyChangesSpec::kAll;
+Spec.Style = format::getLLVMStyle();
+  }
+
+  ~ApplyAtomicChangesTest() override {}
+
+  void setInput(llvm::StringRef Input) {
+Code = Input;
+FID = Context.createInMemoryFile(FilePath, Code);
+  }
+
+  SourceLocation getLoc(unsigned Offset) const {
+return Context.Sources.getLocForStartOfFile(FID).getLocWithOffset(Offset);
+  }
+
+  AtomicChange replacementToAtomicChange(llvm::StringRef Key, unsigned Offset,
+ unsigned Length,
+ llvm::StringRef Text) {
+AtomicChange Change(FilePath, Key);
+llvm::Error Err =
+Change.replace(Context.Sources, getLoc(Offset), Length, Text);
+EXPECT_FALSE(Err);
+return Change;
+  }
+
+  std::string rewrite(bool FailureExpected = false) {
+llvm::Expected ChangedCode =
+applyAtomicChanges(FilePath, Code, Changes, Spec);
+EXPECT_EQ(FailureExpected, !ChangedCode);
+if (!ChangedCode) {
+  llvm::errs() << "Failed to apply changes: "
+   << llvm::toString(ChangedCode.takeError()) << "\n";
+  return "";
+}
+return *ChangedCode;
+  }
+
+  RewriterTestContext Context;
+  FileID FID;
+  ApplyChangesSpec Spec;
+  std::string Code;
+  std::string FilePath;
+  llvm::SmallVector Changes;
+};
+
+TEST_F(ApplyAtomicChangesTest, BasicRefactoring) {
+  setInput("int a;");
+  AtomicChange Change(FilePath, "key1");
+  Changes.push_back(replacementToAtomicChange("key1", 4, 1, "b"));
+  EXPECT_EQ("int b;", rewrite());
+}
+
+TEST_F(ApplyAtomicChangesTest, SeveralRefactorings) {
+  setInput("int a;\n"
+   "int b;");
+  Changes.push_back(replacementToAtomicChange("key1", 0, 3, "float"));
+  Changes.push_back(replacementToAtomicChange("key2", 4, 1, "f"));
+  Changes.push_back(replacementToAtomicChange("key3", 11, 1, "g"));
+  Changes.push_back(replacementToAtomicChange("key4", 7, 3, "float"));
+  EXPECT_EQ("float f;\n"
+"float g;",
+rewrite());
+}
+
+TEST_F(ApplyAtomicChangesTest, IgnorePathsInRefactorings) {
+  setInput("int a;\n"
+   "int b;");
+  Changes.push_back(replacementToAtomicChange("key1", 4, 1, "aa"));
+
+  FileID ID = Context.createInMemoryFile("AnotherFile", "12345678912345");
+  Changes.emplace_back("AnotherFile", "key2");
+  auto Err = Changes.back().replace(
+  Context.Sources,
+  Context.Sources.getLocForStartOfFile(ID).getLocWithOffset(11), 1, "bb");
+  ASSERT_TRUE(!Err);
+  EXPECT_EQ("int aa;\n"
+"int bb;",
+rewrite());
+}
+
+TEST_F(ApplyAtomicChangesTest, AppliesDuplicateInsertions) {
+  setInput("int a;");
+  Changes.push_back(replacementToAtomicChange("key1", 5, 0, "b"));
+  Changes.push_back(replacementToAtomicChange("key2", 5, 0, "b"));
+  EXPECT_EQ("int abb;", rewrite());
+}
+
+TEST_F(ApplyAtomicChangesTest, BailsOnOverlappingRefactorings) {
+  setInput("int a;");
+  Changes.push_back(replacementToAtomicChange("key1", 0, 5, "float f"));
+  Changes.push_back(replacementToAtomicChange("key2", 4, 1, "b"));
+  EXPECT_EQ("", rewrite(/*FailureExpected=*/true));
+}
+
+TEST_F(ApplyAtomicChangesTest, BasicReformatting) {
+  setInput("int  a;");
+  Changes.push_back(replacementToAtomicChange("key1", 5, 1, "b"));
+  EXPECT_EQ("int b;", rewrite());
+}
+
+TEST_F(ApplyAtomicChangesTest, OnlyFormatWhenViolateColumnLimits) {
+  Spec.Format = ApplyChangesSpec::kViolations;
+  Spec.Style.ColumnLimit = 8;
+  setInput("int  a;\n"
+   "inta;\n"
+   "int  ;\n");
+  Changes.push_back(replacementToAtomicChange("key1", 5, 1, "x"));
+  Changes.push_back(replacementToAtomicChange("key2", 15, 1, "x"));
+  Changes.push_back(replacementToAtomicChange("key3", 23, 8, "xx"));
+  EXPECT_EQ("int  x;\n"
+"int x;\n"
+"int  xx;\n",
+rewrite());
+}
+
+TEST_F(ApplyAtomicChangesTest, LastLineViolateColumnLimits) {
+  Spec.Format = ApplyChangesSpec::kViolations;
+  Spec.Style.ColumnLimit = 8;
+  setInput("int  a;\n"
+   "inta;");
+  Changes.push_back(replacementToAtomic

[PATCH] D35986: [clangd] Add ':' to completion trigger characters.

2017-07-31 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL309550: [clangd] Add ':' to completion trigger characters. 
(authored by ibiryukov).

Changed prior to commit:
  https://reviews.llvm.org/D35986?vs=108621&id=108887#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D35986

Files:
  clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp
  clang-tools-extra/trunk/test/clangd/formatting.test


Index: clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp
===
--- clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp
+++ clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp
@@ -86,7 +86,7 @@
   "documentRangeFormattingProvider": true,
   "documentOnTypeFormattingProvider": 
{"firstTriggerCharacter":"}","moreTriggerCharacter":[]},
   "codeActionProvider": true,
-  "completionProvider": {"resolveProvider": false, 
"triggerCharacters": [".",">"]},
+  "completionProvider": {"resolveProvider": false, 
"triggerCharacters": [".",">",":"]},
   "definitionProvider": true
 }}})");
 }
Index: clang-tools-extra/trunk/test/clangd/formatting.test
===
--- clang-tools-extra/trunk/test/clangd/formatting.test
+++ clang-tools-extra/trunk/test/clangd/formatting.test
@@ -4,14 +4,14 @@
 Content-Length: 125
 
 
{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}}
-# CHECK: Content-Length: 462
+# CHECK: Content-Length: 466
 # CHECK: {"jsonrpc":"2.0","id":0,"result":{"capabilities":{
 # CHECK:   "textDocumentSync": 1,
 # CHECK:   "documentFormattingProvider": true,
 # CHECK:   "documentRangeFormattingProvider": true,
 # CHECK:   "documentOnTypeFormattingProvider": 
{"firstTriggerCharacter":"}","moreTriggerCharacter":[]},
 # CHECK:   "codeActionProvider": true,
-# CHECK:   "completionProvider": {"resolveProvider": false, 
"triggerCharacters": [".",">"]},
+# CHECK:   "completionProvider": {"resolveProvider": false, 
"triggerCharacters": [".",">",":"]},
 # CHECK:   "definitionProvider": true
 # CHECK: }}}
 #


Index: clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp
===
--- clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp
+++ clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp
@@ -86,7 +86,7 @@
   "documentRangeFormattingProvider": true,
   "documentOnTypeFormattingProvider": {"firstTriggerCharacter":"}","moreTriggerCharacter":[]},
   "codeActionProvider": true,
-  "completionProvider": {"resolveProvider": false, "triggerCharacters": [".",">"]},
+  "completionProvider": {"resolveProvider": false, "triggerCharacters": [".",">",":"]},
   "definitionProvider": true
 }}})");
 }
Index: clang-tools-extra/trunk/test/clangd/formatting.test
===
--- clang-tools-extra/trunk/test/clangd/formatting.test
+++ clang-tools-extra/trunk/test/clangd/formatting.test
@@ -4,14 +4,14 @@
 Content-Length: 125
 
 {"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}}
-# CHECK: Content-Length: 462
+# CHECK: Content-Length: 466
 # CHECK: {"jsonrpc":"2.0","id":0,"result":{"capabilities":{
 # CHECK:   "textDocumentSync": 1,
 # CHECK:   "documentFormattingProvider": true,
 # CHECK:   "documentRangeFormattingProvider": true,
 # CHECK:   "documentOnTypeFormattingProvider": {"firstTriggerCharacter":"}","moreTriggerCharacter":[]},
 # CHECK:   "codeActionProvider": true,
-# CHECK:   "completionProvider": {"resolveProvider": false, "triggerCharacters": [".",">"]},
+# CHECK:   "completionProvider": {"resolveProvider": false, "triggerCharacters": [".",">",":"]},
 # CHECK:   "definitionProvider": true
 # CHECK: }}}
 #
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r309550 - [clangd] Add ':' to completion trigger characters.

2017-07-31 Thread Ilya Biryukov via cfe-commits
Author: ibiryukov
Date: Mon Jul 31 02:27:52 2017
New Revision: 309550

URL: http://llvm.org/viewvc/llvm-project?rev=309550&view=rev
Log:
[clangd] Add ':' to completion trigger characters.

Summary:
Without it we don't get completion requests from VSCode after
nested name qualifiers (e.g. after 'std::').

Reviewers: krasimir, bkramer

Reviewed By: krasimir

Subscribers: klimek, cfe-commits

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

Modified:
clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp
clang-tools-extra/trunk/test/clangd/formatting.test

Modified: clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp?rev=309550&r1=309549&r2=309550&view=diff
==
--- clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp (original)
+++ clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp Mon Jul 31 02:27:52 2017
@@ -86,7 +86,7 @@ void ClangdLSPServer::LSPProtocolCallbac
   "documentRangeFormattingProvider": true,
   "documentOnTypeFormattingProvider": 
{"firstTriggerCharacter":"}","moreTriggerCharacter":[]},
   "codeActionProvider": true,
-  "completionProvider": {"resolveProvider": false, 
"triggerCharacters": [".",">"]},
+  "completionProvider": {"resolveProvider": false, 
"triggerCharacters": [".",">",":"]},
   "definitionProvider": true
 }}})");
 }

Modified: clang-tools-extra/trunk/test/clangd/formatting.test
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clangd/formatting.test?rev=309550&r1=309549&r2=309550&view=diff
==
--- clang-tools-extra/trunk/test/clangd/formatting.test (original)
+++ clang-tools-extra/trunk/test/clangd/formatting.test Mon Jul 31 02:27:52 2017
@@ -4,14 +4,14 @@
 Content-Length: 125
 
 
{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}}
-# CHECK: Content-Length: 462
+# CHECK: Content-Length: 466
 # CHECK: {"jsonrpc":"2.0","id":0,"result":{"capabilities":{
 # CHECK:   "textDocumentSync": 1,
 # CHECK:   "documentFormattingProvider": true,
 # CHECK:   "documentRangeFormattingProvider": true,
 # CHECK:   "documentOnTypeFormattingProvider": 
{"firstTriggerCharacter":"}","moreTriggerCharacter":[]},
 # CHECK:   "codeActionProvider": true,
-# CHECK:   "completionProvider": {"resolveProvider": false, 
"triggerCharacters": [".",">"]},
+# CHECK:   "completionProvider": {"resolveProvider": false, 
"triggerCharacters": [".",">",":"]},
 # CHECK:   "definitionProvider": true
 # CHECK: }}}
 #


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


[libcxxabi] r309551 - libcxxabi: Suppress LLVM_ENABLE_MODULES

2017-07-31 Thread NAKAMURA Takumi via cfe-commits
Author: chapuni
Date: Mon Jul 31 02:35:08 2017
New Revision: 309551

URL: http://llvm.org/viewvc/llvm-project?rev=309551&view=rev
Log:
libcxxabi: Suppress LLVM_ENABLE_MODULES

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

Modified:
libcxxabi/trunk/CMakeLists.txt

Modified: libcxxabi/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/CMakeLists.txt?rev=309551&r1=309550&r2=309551&view=diff
==
--- libcxxabi/trunk/CMakeLists.txt (original)
+++ libcxxabi/trunk/CMakeLists.txt Mon Jul 31 02:35:08 2017
@@ -345,6 +345,12 @@ if (LIBCXXABI_HAS_EXTERNAL_THREAD_API)
   endif()
 endif()
 
+if (LLVM_ENABLE_MODULES)
+  # Ignore that the rest of the modules flags are now unused.
+  add_compile_flags_if_supported(-Wno-unused-command-line-argument)
+  add_compile_flags(-fno-modules)
+endif()
+
 set(LIBCXXABI_HAS_UNDEFINED_SYMBOLS OFF)
 if ((NOT LIBCXXABI_ENABLE_NEW_DELETE_DEFINITIONS)
 OR (LIBCXXABI_BUILD_EXTERNAL_THREAD_LIBRARY AND LIBCXXABI_ENABLE_SHARED)


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


[PATCH] D35542: libcxxabi: Suppress LLVM_ENABLE_MODULES

2017-07-31 Thread NAKAMURA Takumi via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL309551: libcxxabi: Suppress LLVM_ENABLE_MODULES (authored by 
chapuni).

Repository:
  rL LLVM

https://reviews.llvm.org/D35542

Files:
  libcxxabi/trunk/CMakeLists.txt


Index: libcxxabi/trunk/CMakeLists.txt
===
--- libcxxabi/trunk/CMakeLists.txt
+++ libcxxabi/trunk/CMakeLists.txt
@@ -345,6 +345,12 @@
   endif()
 endif()
 
+if (LLVM_ENABLE_MODULES)
+  # Ignore that the rest of the modules flags are now unused.
+  add_compile_flags_if_supported(-Wno-unused-command-line-argument)
+  add_compile_flags(-fno-modules)
+endif()
+
 set(LIBCXXABI_HAS_UNDEFINED_SYMBOLS OFF)
 if ((NOT LIBCXXABI_ENABLE_NEW_DELETE_DEFINITIONS)
 OR (LIBCXXABI_BUILD_EXTERNAL_THREAD_LIBRARY AND LIBCXXABI_ENABLE_SHARED)


Index: libcxxabi/trunk/CMakeLists.txt
===
--- libcxxabi/trunk/CMakeLists.txt
+++ libcxxabi/trunk/CMakeLists.txt
@@ -345,6 +345,12 @@
   endif()
 endif()
 
+if (LLVM_ENABLE_MODULES)
+  # Ignore that the rest of the modules flags are now unused.
+  add_compile_flags_if_supported(-Wno-unused-command-line-argument)
+  add_compile_flags(-fno-modules)
+endif()
+
 set(LIBCXXABI_HAS_UNDEFINED_SYMBOLS OFF)
 if ((NOT LIBCXXABI_ENABLE_NEW_DELETE_DEFINITIONS)
 OR (LIBCXXABI_BUILD_EXTERNAL_THREAD_LIBRARY AND LIBCXXABI_ENABLE_SHARED)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r309386 - Recommit r308327 3rd time: Add a warning for missing

2017-07-31 Thread Alex L via cfe-commits
That's an interesting case. I'll tweak the warning to diagnose this
scenario better today.

On 29 July 2017 at 00:56, Hans Wennborg  wrote:

> On Fri, Jul 28, 2017 at 7:41 AM, Alex Lorenz via cfe-commits
>  wrote:
> > Author: arphaman
> > Date: Fri Jul 28 07:41:21 2017
> > New Revision: 309386
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=309386&view=rev
> > Log:
> > Recommit r308327 3rd time: Add a warning for missing
> > '#pragma pack (pop)' and suspicious uses of '#pragma pack' in included
> files
> >
> > The second recommit (r309106) was reverted because the "non-default
> #pragma
> > pack value chages the alignment of struct or union members in the
> included file"
> > warning proved to be too aggressive for external projects like Chromium
> > (https://bugs.chromium.org/p/chromium/issues/detail?id=749197). This
> recommit
> > makes the problematic warning a non-default one, and gives it the
> > -Wpragma-pack-suspicious-include warning option.
> >
> > The first recommit (r308441) caused a "non-default #pragma pack value
> might
> > change the alignment of struct or union members in the included file"
> warning
> > in LLVM itself. This recommit tweaks the added warning to avoid warnings
> for
> > #includes that don't have any records that are affected by the
> non-default
> > alignment. This tweak avoids the previously emitted warning in LLVM.
> >
> > Original message:
> >
> > This commit adds a new -Wpragma-pack warning. It warns in the following
> cases:
> >
> > - When a translation unit is missing terminating #pragma pack (pop)
> directives.
> > - When entering an included file if the current alignment value as
> determined
> >   by '#pragma pack' directives is different from the default alignment
> value.
> > - When leaving an included file that changed the state of the current
> alignment
> >   value.
> >
> > rdar://10184173
> >
> > Differential Revision: https://reviews.llvm.org/D35484
>
> We did get warnings with this version too, but this time it looks like
> a real bug :-)
>
> C:\b\c\builder\ClangToTWin_dll_\src\third_party\usrsctp\
> usrsctplib\usrsctplib\netinet\sctp.h(51,9):
>  error: unterminated '#pragma pack (push, ...)' at end of file
> [-Werror,-Wpragma-pack]
>
> The interesting thing is that the file does reset the alignment, but
> it does it with a "#pragma pack()" which doesn't pop the stack, but
> just resets to the default value.
>
> It might be worth tweaking the warning to give a better message for
> this. A "#pragma pack(push, ..)" followed by "#pragma pack()" seems
> pretty dodgy since there's no point in pushing if the code isn't going
> to pop.
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D36067: [analyzer] Create infrastructure for organizing and declaring analyzer configs.

2017-07-31 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun added a comment.

I like the directions of this patch.
In general, I am in favor of explicitly registering the options from user 
defined checkers. 
But changing a config option will now break the command line compatibility, so 
I wonder how do we want to handle this:

- Have a list of no-op configs that we accept but warn that it has been 
replaced/removed?
- Just do not care and break compatibility?
- Something else?

I have a wishlist for this feature but I am perfectly fine to only address 
those in follow-up patches:

- Ability to set descriptions and maybe default values in the Checkers.td
- Command line argument to dump the list of options with descriptions (and 
defaults)


https://reviews.llvm.org/D36067



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


[PATCH] D34512: Add preliminary Cross Translation Unit support library

2017-07-31 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun added a comment.

In https://reviews.llvm.org/D34512#806505, @klimek wrote:

> Yep, I want Richard's approval for the name. I think he already expressed a 
> pro-pulling-out stance.


Great! Ping for the name approval.


https://reviews.llvm.org/D34512



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


[PATCH] D34440: [Clang] Expand response files before loading compilation database

2017-07-31 Thread Vladimir Plyashkun via Phabricator via cfe-commits
vladimir.plyashkun added a comment.

> Many build systems normally generate response files on-fly in some 
> circumstances (e.g. if command line is longer than some platform-imposed 
> limit). So IMO response files should be a perfect citizen here.

friendly ping


Repository:
  rL LLVM

https://reviews.llvm.org/D34440



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


r309557 - [CMake][Modules] libclang: Ignore _CINDEX_LIB_ and CLANG_TOOL_EXTRA_BUILD for -fmodules.

2017-07-31 Thread NAKAMURA Takumi via cfe-commits
Author: chapuni
Date: Mon Jul 31 04:45:20 2017
New Revision: 309557

URL: http://llvm.org/viewvc/llvm-project?rev=309557&view=rev
Log:
[CMake][Modules] libclang: Ignore _CINDEX_LIB_ and CLANG_TOOL_EXTRA_BUILD for 
-fmodules.

CLANG_TOOL_EXTRA_BUILD doesn't affect headers.

_CINDEX_LIB_ is defined when the target is SHARED.
On Win32, it affects clang-c/Platform.h and it shouldn't be ignored.

This is part of https://reviews.llvm.org/D35559

Modified:
cfe/trunk/tools/libclang/CMakeLists.txt

Modified: cfe/trunk/tools/libclang/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CMakeLists.txt?rev=309557&r1=309556&r2=309557&view=diff
==
--- cfe/trunk/tools/libclang/CMakeLists.txt (original)
+++ cfe/trunk/tools/libclang/CMakeLists.txt Mon Jul 31 04:45:20 2017
@@ -51,6 +51,9 @@ if (TARGET clangTidyPlugin)
   add_definitions(-DCLANG_TOOL_EXTRA_BUILD)
   list(APPEND LIBS clangTidyPlugin)
   list(APPEND LIBS clangIncludeFixerPlugin)
+  if(LLVM_ENABLE_MODULES)
+list(APPEND LLVM_COMPILE_FLAGS 
"-fmodules-ignore-macro=CLANG_TOOL_EXTRA_BUILD")
+  endif()
 endif ()
 
 find_library(DL_LIBRARY_PATH dl)
@@ -115,6 +118,12 @@ if(ENABLE_SHARED)
   PROPERTIES
   VERSION ${LIBCLANG_LIBRARY_VERSION}
   DEFINE_SYMBOL _CINDEX_LIB_)
+# FIXME: _CINDEX_LIB_ affects dllexport/dllimport on Win32.
+if(LLVM_ENABLE_MODULES AND NOT WIN32)
+  target_compile_options(libclang PRIVATE
+"-fmodules-ignore-macro=_CINDEX_LIB_"
+)
+endif()
   endif()
 endif()
 


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


[PATCH] D36083: [utils] Add a script that runs clang in LLDB and stops it when a specified diagnostic is emitted

2017-07-31 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman created this revision.

This script is useful while working on and debugging Clang's diagnostics, as 
you don't have to figure out where the diagnostic is emitted before setting a 
breakpoint for the emission of that diagnostic.


Repository:
  rL LLVM

https://reviews.llvm.org/D36083

Files:
  utils/debug-diag.py


Index: utils/debug-diag.py
===
--- /dev/null
+++ utils/debug-diag.py
@@ -0,0 +1,79 @@
+#!/usr/bin/env python
+
+# This tool allows you to find a backtrace for a reported diagnostic in Clang.
+#
+# To use:
+#  1) Ensure that diagtool is compiled and is up-to-date
+#  2) Invoke the tool:
+#   debug-diag warn_some_warning /path/to/clang -- -cc1 myfile.cpp
+
+import os
+import subprocess
+import sys
+import tempfile
+
+def invokeLLDB(diagCode, clang, args):
+# Set a breakpoint at the diagnostic
+command = """breakpoint set -n DiagnosticsEngine::Report
+breakpoint modify -c "DiagID == %d"
+run
+bt""" % (diagCode)
+
+filename = ""
+with tempfile.NamedTemporaryFile(delete=False) as f:
+f.write(command)
+filename = f.name
+f.close()
+
+p = None
+try:
+p = subprocess.Popen(["lldb","-s",f.name, clang,"--"] + args)
+p.wait()
+except KeyboardInterrupt:
+print  >>sys.stderr, 'Killing LLDB.'
+p.terminate()
+os.unlink(filename)
+except:
+os.unlink(filename)
+raise
+
+def main():
+import argparse
+
+description = "Runs clang in a debugger and stops at a breakpoint when the 
given diagnostic is reported"
+parser = argparse.ArgumentParser(description=description)
+parser.add_argument("diag", metavar="diagnostic", nargs=1,
+help="name of the diagnostic")
+parser.add_argument("clang", metavar="clang", nargs=1,
+help="path to clang")
+parser.add_argument("arguments", metavar="arg", nargs="+",
+help="command line arguments that should be passed to 
clang")
+args = parser.parse_args()
+
+if args.arguments[0] != "-cc1":
+# Clang must run in -cc1 to avoid the fork which breaks debugging.
+# FIXME: Invoke the driver and figure out the -cc1 options.
+print >>sys.stderr, "The '-cc1' option should be passed to clang"
+sys.exit(1)
+
+# Compute the diagnostic code for the given diagnostic.
+# FIXME: Diagtool binary might have out-of-date ids, when clang's
+# diagnostics are modified and clang is rebuilt but diagtool wasn't. The
+# script should try to identify this issue.
+diagtool = os.path.join(os.path.dirname(args.clang[0]), "diagtool")
+p = subprocess.Popen([diagtool,'find-diagnostic-id',args.diag[0]],
+ stdin=subprocess.PIPE,
+ stdout=subprocess.PIPE)
+out,_ = p.communicate()
+diagCode = None
+try:
+diagCode = int(out)
+except ValueError:
+# diag-tool will report to stderr.
+sys.exit(1)
+
+# Use LLDB to run clang and stop at the diagnostic.
+invokeLLDB(diagCode, args.clang[0], args.arguments)
+
+if __name__ == '__main__':
+main()


Index: utils/debug-diag.py
===
--- /dev/null
+++ utils/debug-diag.py
@@ -0,0 +1,79 @@
+#!/usr/bin/env python
+
+# This tool allows you to find a backtrace for a reported diagnostic in Clang.
+#
+# To use:
+#  1) Ensure that diagtool is compiled and is up-to-date
+#  2) Invoke the tool:
+#   debug-diag warn_some_warning /path/to/clang -- -cc1 myfile.cpp
+
+import os
+import subprocess
+import sys
+import tempfile
+
+def invokeLLDB(diagCode, clang, args):
+# Set a breakpoint at the diagnostic
+command = """breakpoint set -n DiagnosticsEngine::Report
+breakpoint modify -c "DiagID == %d"
+run
+bt""" % (diagCode)
+
+filename = ""
+with tempfile.NamedTemporaryFile(delete=False) as f:
+f.write(command)
+filename = f.name
+f.close()
+
+p = None
+try:
+p = subprocess.Popen(["lldb","-s",f.name, clang,"--"] + args)
+p.wait()
+except KeyboardInterrupt:
+print  >>sys.stderr, 'Killing LLDB.'
+p.terminate()
+os.unlink(filename)
+except:
+os.unlink(filename)
+raise
+
+def main():
+import argparse
+
+description = "Runs clang in a debugger and stops at a breakpoint when the given diagnostic is reported"
+parser = argparse.ArgumentParser(description=description)
+parser.add_argument("diag", metavar="diagnostic", nargs=1,
+help="name of the diagnostic")
+parser.add_argument("clang", metavar="clang", nargs=1,
+help="path to clang")
+parser.add_argument("arguments", metavar="arg", nargs="+",
+help="command line arguments that should be passed to clang")
+args = parser.parse_args()
+
+if args.ar

[PATCH] D18174: Fix libcxx build on musl

2017-07-31 Thread Ben Craig via Phabricator via cfe-commits
bcraig added inline comments.



Comment at: include/__mutex_base:51
 #ifndef _LIBCPP_CXX03_LANG
-constexpr mutex() = default;
+#ifdef __GLIBC__
+constexpr

smeenai wrote:
> EricWF wrote:
> > Limiting `constexpr` to GLIBC implementations only is incorrect; you want 
> > to exclude MUSL.
> > 
> > Also MUSL is wrong for not allowing `pthread_mutex_t mut = 
> > PTHREAD_MUTEX_INITIALIZER` to be a constant expression, and MUSL should fix 
> > that.
> I've used `__builtin_constant_p` to wok around a similarly non-conforming 
> `PTHREAD_MUTEX_INITIALIZER` (from pthread-win32, which defines it to be 
> `(void *)-1`): see the last part of 
> https://stackoverflow.com/a/10376574/382079. It's a terrible hack, but it 
> works.
musl's pthread_mutex_t has volatile members if I recall correctly.  It's hard 
to validate that statement without building musl, because the header that 
defines pthread_mutex_t is code generated.


https://reviews.llvm.org/D18174



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


r309559 - -Wpragma-pack: add an additional note and fixit when warning

2017-07-31 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Mon Jul 31 06:37:50 2017
New Revision: 309559

URL: http://llvm.org/viewvc/llvm-project?rev=309559&view=rev
Log:
-Wpragma-pack: add an additional note and fixit when warning
about unterminated push directives that are followed by a reset
('#pragma pack()')

This has been suggested by Hans Wennborg.

Added:
cfe/trunk/test/FixIt/fixit-pragma-pack.c
Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaAttr.cpp
cfe/trunk/test/PCH/suspicious-pragma-pack.c
cfe/trunk/test/Sema/pragma-pack.c

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=309559&r1=309558&r2=309559&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Mon Jul 31 06:37:50 
2017
@@ -723,6 +723,8 @@ def warn_pragma_pack_no_pop_eof : Warnin
   "'#pragma pack (push, ...)' at end of file">, InGroup;
 def note_pragma_pack_here : Note<
   "previous '#pragma pack' directive that modifies alignment is here">;
+def note_pragma_pack_pop_instead_reset : Note<
+  "did you intend to use '#pragma pack (pop)' instead of '#pragma pack()'?">;
 // Follow the Microsoft implementation.
 def warn_pragma_pack_show : Warning<"value of #pragma pack(show) == %0">;
 def warn_pragma_pack_pop_identifer_and_alignment : Warning<

Modified: cfe/trunk/lib/Sema/SemaAttr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaAttr.cpp?rev=309559&r1=309558&r2=309559&view=diff
==
--- cfe/trunk/lib/Sema/SemaAttr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaAttr.cpp Mon Jul 31 06:37:50 2017
@@ -250,8 +250,22 @@ void Sema::DiagnoseNonDefaultPragmaPack(
 void Sema::DiagnoseUnterminatedPragmaPack() {
   if (PackStack.Stack.empty())
 return;
-  for (const auto &StackSlot : llvm::reverse(PackStack.Stack))
+  bool IsInnermost = true;
+  for (const auto &StackSlot : llvm::reverse(PackStack.Stack)) {
 Diag(StackSlot.PragmaPushLocation, diag::warn_pragma_pack_no_pop_eof);
+// The user might have already reset the alignment, so suggest replacing
+// the reset with a pop.
+if (IsInnermost && PackStack.CurrentValue == PackStack.DefaultValue) {
+  DiagnosticBuilder DB = Diag(PackStack.CurrentPragmaLocation,
+  diag::note_pragma_pack_pop_instead_reset);
+  SourceLocation FixItLoc = Lexer::findLocationAfterToken(
+  PackStack.CurrentPragmaLocation, tok::l_paren, SourceMgr, LangOpts,
+  /*SkipTrailing=*/false);
+  if (FixItLoc.isValid())
+DB << FixItHint::CreateInsertion(FixItLoc, "pop");
+}
+IsInnermost = false;
+  }
 }
 
 void Sema::ActOnPragmaMSStruct(PragmaMSStructKind Kind) { 

Added: cfe/trunk/test/FixIt/fixit-pragma-pack.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/FixIt/fixit-pragma-pack.c?rev=309559&view=auto
==
--- cfe/trunk/test/FixIt/fixit-pragma-pack.c (added)
+++ cfe/trunk/test/FixIt/fixit-pragma-pack.c Mon Jul 31 06:37:50 2017
@@ -0,0 +1,5 @@
+// RUN: %clang_cc1 -fsyntax-only -fdiagnostics-parseable-fixits %s 2>&1 | 
FileCheck %s
+
+#pragma pack (push, 1)
+#pragma pack()
+// CHECK: fix-it:{{.*}}:{[[@LINE-1]]:14-[[@LINE-1]]:14}:"pop"

Modified: cfe/trunk/test/PCH/suspicious-pragma-pack.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/PCH/suspicious-pragma-pack.c?rev=309559&r1=309558&r2=309559&view=diff
==
--- cfe/trunk/test/PCH/suspicious-pragma-pack.c (original)
+++ cfe/trunk/test/PCH/suspicious-pragma-pack.c Mon Jul 31 06:37:50 2017
@@ -4,5 +4,7 @@
 #ifndef HEADER
 #define HEADER
 #pragma pack (push, 1)
+#else
+#pragma pack (2)
 #endif
-// expected-warning@-2 {{unterminated '#pragma pack (push, ...)' at end of 
file}}
+// expected-warning@-4 {{unterminated '#pragma pack (push, ...)' at end of 
file}}

Modified: cfe/trunk/test/Sema/pragma-pack.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/pragma-pack.c?rev=309559&r1=309558&r2=309559&view=diff
==
--- cfe/trunk/test/Sema/pragma-pack.c (original)
+++ cfe/trunk/test/Sema/pragma-pack.c Mon Jul 31 06:37:50 2017
@@ -29,4 +29,4 @@
 // Warn about unbalanced pushes.
 #pragma pack (push,4) // expected-warning {{unterminated '#pragma pack (push, 
...)' at end of file}}
 #pragma pack (push)   // expected-warning {{unterminated '#pragma pack (push, 
...)' at end of file}}
-#pragma pack ()
+#pragma pack () // expected-note {{did you intend to use '#pragma pack (pop)' 
instead of '#pragma pack()'?}}


___
cfe-commits maili

Re: r309386 - Recommit r308327 3rd time: Add a warning for missing

2017-07-31 Thread Alex L via cfe-commits
Add a note with a fixit in r309559.

On 31 July 2017 at 10:50, Alex L  wrote:

> That's an interesting case. I'll tweak the warning to diagnose this
> scenario better today.
>
> On 29 July 2017 at 00:56, Hans Wennborg  wrote:
>
>> On Fri, Jul 28, 2017 at 7:41 AM, Alex Lorenz via cfe-commits
>>  wrote:
>> > Author: arphaman
>> > Date: Fri Jul 28 07:41:21 2017
>> > New Revision: 309386
>> >
>> > URL: http://llvm.org/viewvc/llvm-project?rev=309386&view=rev
>> > Log:
>> > Recommit r308327 3rd time: Add a warning for missing
>> > '#pragma pack (pop)' and suspicious uses of '#pragma pack' in included
>> files
>> >
>> > The second recommit (r309106) was reverted because the "non-default
>> #pragma
>> > pack value chages the alignment of struct or union members in the
>> included file"
>> > warning proved to be too aggressive for external projects like Chromium
>> > (https://bugs.chromium.org/p/chromium/issues/detail?id=749197). This
>> recommit
>> > makes the problematic warning a non-default one, and gives it the
>> > -Wpragma-pack-suspicious-include warning option.
>> >
>> > The first recommit (r308441) caused a "non-default #pragma pack value
>> might
>> > change the alignment of struct or union members in the included file"
>> warning
>> > in LLVM itself. This recommit tweaks the added warning to avoid
>> warnings for
>> > #includes that don't have any records that are affected by the
>> non-default
>> > alignment. This tweak avoids the previously emitted warning in LLVM.
>> >
>> > Original message:
>> >
>> > This commit adds a new -Wpragma-pack warning. It warns in the following
>> cases:
>> >
>> > - When a translation unit is missing terminating #pragma pack (pop)
>> directives.
>> > - When entering an included file if the current alignment value as
>> determined
>> >   by '#pragma pack' directives is different from the default alignment
>> value.
>> > - When leaving an included file that changed the state of the current
>> alignment
>> >   value.
>> >
>> > rdar://10184173
>> >
>> > Differential Revision: https://reviews.llvm.org/D35484
>>
>> We did get warnings with this version too, but this time it looks like
>> a real bug :-)
>>
>> C:\b\c\builder\ClangToTWin_dll_\src\third_party\usrsctp\usrs
>> ctplib\usrsctplib\netinet\sctp.h(51,9):
>>  error: unterminated '#pragma pack (push, ...)' at end of file
>> [-Werror,-Wpragma-pack]
>>
>> The interesting thing is that the file does reset the alignment, but
>> it does it with a "#pragma pack()" which doesn't pop the stack, but
>> just resets to the default value.
>>
>> It might be worth tweaking the warning to give a better message for
>> this. A "#pragma pack(push, ..)" followed by "#pragma pack()" seems
>> pretty dodgy since there's no point in pushing if the code isn't going
>> to pop.
>>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D33722: [clang-tidy] Add checker for undelegated copy of base classes

2017-07-31 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun added inline comments.



Comment at: clang-tidy/misc/CopyConstructorInitCheck.cpp:22
+AST_MATCHER(CXXCtorInitializer, ctorInit) {
+  return cxxCtorInitializer(
+ isBaseInitializer(),

Wouldn't something like:

```
static auto ctorInit = cxxCtorInitializer();
```
work? 

I would prefer that rather than a new AST_MATCHER.

And later you could use `ctorInit` without parens.



Comment at: test/clang-tidy/misc-copy-constructor-init.cpp:21
+// CHECK-MESSAGES: :[[@LINE-1]]:22: warning: calling an inherited 
constructor other than the copy constructor [misc-copy-constructor-init]
+   // CHECK-FIXES: : Copyable2(other)
+};

These check-fixes lines should contain the whole line after the fixit is 
applied. 


https://reviews.llvm.org/D33722



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


r309562 - Document '-Wpragma-pack' in the release notes

2017-07-31 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Mon Jul 31 07:08:41 2017
New Revision: 309562

URL: http://llvm.org/viewvc/llvm-project?rev=309562&view=rev
Log:
Document '-Wpragma-pack' in the release notes

Modified:
cfe/trunk/docs/ReleaseNotes.rst

Modified: cfe/trunk/docs/ReleaseNotes.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ReleaseNotes.rst?rev=309562&r1=309561&r2=309562&view=diff
==
--- cfe/trunk/docs/ReleaseNotes.rst (original)
+++ cfe/trunk/docs/ReleaseNotes.rst Mon Jul 31 07:08:41 2017
@@ -52,7 +52,16 @@ Major New Features
 Improvements to Clang's diagnostics
 ^^^
 
--  ...
+- `-Wpragma-pack` is a new warning that warns in the following cases:
+  - When a translation unit is missing terminating `#pragma pack (pop)`
+directives.
+  - When leaving an included file that changes the current alignment value,
+i.e. when the alignment before `#include` is different to the alignment
+after `#include`.
+  - `-Wpragma-pack-suspicious-include` (disabled by default) warns on an
+`#include` when the included file contains structures or unions affected by
+a non-default alignment that has been specified using a `#pragma pack`
+directive prior to the `#include`.
 
 Non-comprehensive list of changes in this release
 -


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


r309564 - Fix release notes indentation from r309562

2017-07-31 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Mon Jul 31 07:22:43 2017
New Revision: 309564

URL: http://llvm.org/viewvc/llvm-project?rev=309564&view=rev
Log:
Fix release notes indentation from r309562

The additions in r309562 triggered a docs buildbot failure.

Modified:
cfe/trunk/docs/ReleaseNotes.rst

Modified: cfe/trunk/docs/ReleaseNotes.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ReleaseNotes.rst?rev=309564&r1=309563&r2=309564&view=diff
==
--- cfe/trunk/docs/ReleaseNotes.rst (original)
+++ cfe/trunk/docs/ReleaseNotes.rst Mon Jul 31 07:22:43 2017
@@ -52,16 +52,19 @@ Major New Features
 Improvements to Clang's diagnostics
 ^^^
 
-- `-Wpragma-pack` is a new warning that warns in the following cases:
-  - When a translation unit is missing terminating `#pragma pack (pop)`
+- ``-Wpragma-pack`` is a new warning that warns in the following cases:
+
+  - When a translation unit is missing terminating ``#pragma pack (pop)``
 directives.
+
   - When leaving an included file that changes the current alignment value,
-i.e. when the alignment before `#include` is different to the alignment
-after `#include`.
-  - `-Wpragma-pack-suspicious-include` (disabled by default) warns on an
-`#include` when the included file contains structures or unions affected by
-a non-default alignment that has been specified using a `#pragma pack`
-directive prior to the `#include`.
+i.e. when the alignment before ``#include`` is different to the alignment
+after ``#include``.
+
+  - ``-Wpragma-pack-suspicious-include`` (disabled by default) warns on an
+``#include`` when the included file contains structures or unions affected 
by
+a non-default alignment that has been specified using a ``#pragma pack``
+directive prior to the ``#include``.
 
 Non-comprehensive list of changes in this release
 -


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


[PATCH] D35542: libcxxabi: Suppress LLVM_ENABLE_MODULES

2017-07-31 Thread Jonathan Roelofs via Phabricator via cfe-commits
jroelofs added a comment.

Does the unwinder need this too?


Repository:
  rL LLVM

https://reviews.llvm.org/D35542



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


[PATCH] D36044: [OpenCL] -cl-ext option can overwrite OpenCL features imported from a module

2017-07-31 Thread Alexey Bader via Phabricator via cfe-commits
bader added inline comments.



Comment at: test/SemaOpenCL/extensions-import.cl:14
+
+#ifdef FP64
+// expected-no-diagnostics

You can use `#ifdef cl_khr_fp64` to check if extension is supported.


https://reviews.llvm.org/D36044



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


r309567 - [OpenCL] Add extension Sema check for subgroup builtins

2017-07-31 Thread Joey Gouly via cfe-commits
Author: joey
Date: Mon Jul 31 08:15:59 2017
New Revision: 309567

URL: http://llvm.org/viewvc/llvm-project?rev=309567&view=rev
Log:
[OpenCL] Add extension Sema check for subgroup builtins

Check the subgroup extension is enabled, before doing other Sema checks.

Modified:
cfe/trunk/lib/Sema/SemaChecking.cpp
cfe/trunk/test/CodeGenOpenCL/cl20-device-side-enqueue.cl
cfe/trunk/test/CodeGenOpenCL/pipe_builtin.cl
cfe/trunk/test/SemaOpenCL/invalid-pipe-builtin-cl2.0.cl

Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=309567&r1=309566&r2=309567&view=diff
==
--- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
+++ cfe/trunk/lib/Sema/SemaChecking.cpp Mon Jul 31 08:15:59 2017
@@ -299,6 +299,15 @@ static bool checkOpenCLBlockArgs(Sema &S
   return IllegalParams;
 }
 
+static bool checkOpenCLSubgroupExt(Sema &S, CallExpr *Call) {
+  if (!S.getOpenCLOptions().isEnabled("cl_khr_subgroups")) {
+S.Diag(Call->getLocStart(), diag::err_opencl_requires_extension)
+  << 1 << Call->getDirectCallee() << "cl_khr_subgroups";
+return true;
+  }
+  return false;
+}
+
 /// OpenCL C v2.0, s6.13.17.6 - Check the argument to the
 /// get_kernel_work_group_size
 /// and get_kernel_preferred_work_group_size_multiple builtin functions.
@@ -1048,9 +1057,17 @@ Sema::CheckBuiltinFunctionCall(FunctionD
   case Builtin::BIreserve_write_pipe:
   case Builtin::BIwork_group_reserve_read_pipe:
   case Builtin::BIwork_group_reserve_write_pipe:
+if (SemaBuiltinReserveRWPipe(*this, TheCall))
+  return ExprError();
+// Since return type of reserve_read/write_pipe built-in function is
+// reserve_id_t, which is not defined in the builtin def file , we used int
+// as return type and need to override the return type of these functions.
+TheCall->setType(Context.OCLReserveIDTy);
+break;
   case Builtin::BIsub_group_reserve_read_pipe:
   case Builtin::BIsub_group_reserve_write_pipe:
-if (SemaBuiltinReserveRWPipe(*this, TheCall))
+if (checkOpenCLSubgroupExt(*this, TheCall) ||
+SemaBuiltinReserveRWPipe(*this, TheCall))
   return ExprError();
 // Since return type of reserve_read/write_pipe built-in function is
 // reserve_id_t, which is not defined in the builtin def file , we used int
@@ -1061,9 +1078,13 @@ Sema::CheckBuiltinFunctionCall(FunctionD
   case Builtin::BIcommit_write_pipe:
   case Builtin::BIwork_group_commit_read_pipe:
   case Builtin::BIwork_group_commit_write_pipe:
+if (SemaBuiltinCommitRWPipe(*this, TheCall))
+  return ExprError();
+break;
   case Builtin::BIsub_group_commit_read_pipe:
   case Builtin::BIsub_group_commit_write_pipe:
-if (SemaBuiltinCommitRWPipe(*this, TheCall))
+if (checkOpenCLSubgroupExt(*this, TheCall) ||
+SemaBuiltinCommitRWPipe(*this, TheCall))
   return ExprError();
 break;
   case Builtin::BIget_pipe_num_packets:

Modified: cfe/trunk/test/CodeGenOpenCL/cl20-device-side-enqueue.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCL/cl20-device-side-enqueue.cl?rev=309567&r1=309566&r2=309567&view=diff
==
--- cfe/trunk/test/CodeGenOpenCL/cl20-device-side-enqueue.cl (original)
+++ cfe/trunk/test/CodeGenOpenCL/cl20-device-side-enqueue.cl Mon Jul 31 
08:15:59 2017
@@ -1,6 +1,8 @@
 // RUN: %clang_cc1 %s -cl-std=CL2.0 -ffake-address-space-map -O0 -emit-llvm -o 
- -triple "spir-unknown-unknown" | FileCheck %s --check-prefix=COMMON 
--check-prefix=B32
 // RUN: %clang_cc1 %s -cl-std=CL2.0 -ffake-address-space-map -O0 -emit-llvm -o 
- -triple "spir64-unknown-unknown" | FileCheck %s --check-prefix=COMMON 
--check-prefix=B64
 
+#pragma OPENCL EXTENSION cl_khr_subgroups : enable
+
 typedef void (^bl_t)(local void *);
 typedef struct {int a;} ndrange_t;
 

Modified: cfe/trunk/test/CodeGenOpenCL/pipe_builtin.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCL/pipe_builtin.cl?rev=309567&r1=309566&r2=309567&view=diff
==
--- cfe/trunk/test/CodeGenOpenCL/pipe_builtin.cl (original)
+++ cfe/trunk/test/CodeGenOpenCL/pipe_builtin.cl Mon Jul 31 08:15:59 2017
@@ -3,6 +3,8 @@
 // CHECK: %opencl.pipe_t = type opaque
 // CHECK: %opencl.reserve_id_t = type opaque
 
+#pragma OPENCL EXTENSION cl_khr_subgroups : enable
+
 void test1(read_only pipe int p, global int *ptr) {
   // CHECK: call i32 @__read_pipe_2(%opencl.pipe_t* %{{.*}}, i8* %{{.*}}, i32 
4, i32 4)
   read_pipe(p, ptr);

Modified: cfe/trunk/test/SemaOpenCL/invalid-pipe-builtin-cl2.0.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaOpenCL/invalid-pipe-builtin-cl2.0.cl?rev=309567&r1=309566&r2=309567&view=diff
==
--- cfe/trunk/test/SemaOpenCL/

r309569 - Fix -Wshadow false positives with function-local classes.

2017-07-31 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Mon Jul 31 08:21:26 2017
New Revision: 309569

URL: http://llvm.org/viewvc/llvm-project?rev=309569&view=rev
Log:
Fix -Wshadow false positives with function-local classes.

Summary:
Fixes http://llvm.org/PR33947.

https://godbolt.org/g/54XRMT

void f(int a) {
  struct A {
void g(int a) {}
A() { int a; }
  };
}

3 : :3:16: warning: declaration shadows a local variable [-Wshadow]
void g(int a) {}
   ^
1 : :1:12: note: previous declaration is here
void f(int a) {
   ^
4 : :4:15: warning: declaration shadows a local variable [-Wshadow]
A() { int a; }
  ^
1 : :1:12: note: previous declaration is here
void f(int a) {
   ^
2 warnings generated.

The local variable `a` of the function `f` can't be accessed from a method of
the function-local class A, thus no shadowing occurs and no diagnostic is
needed.

Reviewers: rnk, rsmith, arphaman, Quuxplusone

Reviewed By: rnk, Quuxplusone

Subscribers: Quuxplusone, cfe-commits

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

Modified:
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/test/SemaCXX/warn-shadow.cpp

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=309569&r1=309568&r2=309569&view=diff
==
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Mon Jul 31 08:21:26 2017
@@ -6999,6 +6999,21 @@ void Sema::CheckShadow(NamedDecl *D, Nam
   return;
 }
   }
+
+  if (cast(ShadowedDecl)->hasLocalStorage()) {
+// A variable can't shadow a local variable in an enclosing scope, if
+// they are separated by a non-capturing declaration context.
+for (DeclContext *ParentDC = NewDC;
+ ParentDC && !ParentDC->Equals(OldDC);
+ ParentDC = getLambdaAwareParentOfDeclContext(ParentDC)) {
+  // Only block literals, captured statements, and lambda expressions
+  // can capture; other scopes don't.
+  if (!isa(ParentDC) && !isa(ParentDC) &&
+  !isLambdaCallOperator(ParentDC)) {
+return;
+  }
+}
+  }
 }
   }
 

Modified: cfe/trunk/test/SemaCXX/warn-shadow.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/warn-shadow.cpp?rev=309569&r1=309568&r2=309569&view=diff
==
--- cfe/trunk/test/SemaCXX/warn-shadow.cpp (original)
+++ cfe/trunk/test/SemaCXX/warn-shadow.cpp Mon Jul 31 08:21:26 2017
@@ -213,3 +213,12 @@ typedef int externC; // expected-note {{
 void handleLinkageSpec() {
   typedef void externC; // expected-warning {{declaration shadows a typedef in 
the global namespace}}
 }
+
+namespace PR33947 {
+void f(int a) {
+  struct A {
+void g(int a) {}
+A() { int a; }
+  };
+}
+}


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


[PATCH] D35941: Fix -Wshadow false positives with function-local classes.

2017-07-31 Thread Alexander Kornienko via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL309569: Fix -Wshadow false positives with function-local 
classes. (authored by alexfh).

Repository:
  rL LLVM

https://reviews.llvm.org/D35941

Files:
  cfe/trunk/lib/Sema/SemaDecl.cpp
  cfe/trunk/test/SemaCXX/warn-shadow.cpp


Index: cfe/trunk/lib/Sema/SemaDecl.cpp
===
--- cfe/trunk/lib/Sema/SemaDecl.cpp
+++ cfe/trunk/lib/Sema/SemaDecl.cpp
@@ -6999,6 +6999,21 @@
   return;
 }
   }
+
+  if (cast(ShadowedDecl)->hasLocalStorage()) {
+// A variable can't shadow a local variable in an enclosing scope, if
+// they are separated by a non-capturing declaration context.
+for (DeclContext *ParentDC = NewDC;
+ ParentDC && !ParentDC->Equals(OldDC);
+ ParentDC = getLambdaAwareParentOfDeclContext(ParentDC)) {
+  // Only block literals, captured statements, and lambda expressions
+  // can capture; other scopes don't.
+  if (!isa(ParentDC) && !isa(ParentDC) &&
+  !isLambdaCallOperator(ParentDC)) {
+return;
+  }
+}
+  }
 }
   }
 
Index: cfe/trunk/test/SemaCXX/warn-shadow.cpp
===
--- cfe/trunk/test/SemaCXX/warn-shadow.cpp
+++ cfe/trunk/test/SemaCXX/warn-shadow.cpp
@@ -213,3 +213,12 @@
 void handleLinkageSpec() {
   typedef void externC; // expected-warning {{declaration shadows a typedef in 
the global namespace}}
 }
+
+namespace PR33947 {
+void f(int a) {
+  struct A {
+void g(int a) {}
+A() { int a; }
+  };
+}
+}


Index: cfe/trunk/lib/Sema/SemaDecl.cpp
===
--- cfe/trunk/lib/Sema/SemaDecl.cpp
+++ cfe/trunk/lib/Sema/SemaDecl.cpp
@@ -6999,6 +6999,21 @@
   return;
 }
   }
+
+  if (cast(ShadowedDecl)->hasLocalStorage()) {
+// A variable can't shadow a local variable in an enclosing scope, if
+// they are separated by a non-capturing declaration context.
+for (DeclContext *ParentDC = NewDC;
+ ParentDC && !ParentDC->Equals(OldDC);
+ ParentDC = getLambdaAwareParentOfDeclContext(ParentDC)) {
+  // Only block literals, captured statements, and lambda expressions
+  // can capture; other scopes don't.
+  if (!isa(ParentDC) && !isa(ParentDC) &&
+  !isLambdaCallOperator(ParentDC)) {
+return;
+  }
+}
+  }
 }
   }
 
Index: cfe/trunk/test/SemaCXX/warn-shadow.cpp
===
--- cfe/trunk/test/SemaCXX/warn-shadow.cpp
+++ cfe/trunk/test/SemaCXX/warn-shadow.cpp
@@ -213,3 +213,12 @@
 void handleLinkageSpec() {
   typedef void externC; // expected-warning {{declaration shadows a typedef in the global namespace}}
 }
+
+namespace PR33947 {
+void f(int a) {
+  struct A {
+void g(int a) {}
+A() { int a; }
+  };
+}
+}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D36072: [Targets] Move addCygMingDefines into the arch-independent Targets.cpp (NFC)

2017-07-31 Thread Erich Keane via Phabricator via cfe-commits
erichkeane accepted this revision.
erichkeane added a comment.
This revision is now accepted and ready to land.

Good catch, thanks!


https://reviews.llvm.org/D36072



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


[PATCH] D35982: [mips] Introducing option -mabs=[legacy/2008]

2017-07-31 Thread Simon Atanasyan via Phabricator via cfe-commits
atanasyan added a comment.

Is it possible to factor out Nan =>  IEEE754 renaming into the separate patch?


Repository:
  rL LLVM

https://reviews.llvm.org/D35982



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


r309571 - [OpenCL] Enable subgroup extension in tests

2017-07-31 Thread Joey Gouly via cfe-commits
Author: joey
Date: Mon Jul 31 08:50:27 2017
New Revision: 309571

URL: http://llvm.org/viewvc/llvm-project?rev=309571&view=rev
Log:
[OpenCL] Enable subgroup extension in tests

This fixes the test, so that it can be run on different hosts that may have
different OpenCL extensions enabled.

Modified:
cfe/trunk/test/CodeGenOpenCL/pipe_builtin.cl
cfe/trunk/test/SemaOpenCL/invalid-pipe-builtin-cl2.0.cl

Modified: cfe/trunk/test/CodeGenOpenCL/pipe_builtin.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCL/pipe_builtin.cl?rev=309571&r1=309570&r2=309571&view=diff
==
--- cfe/trunk/test/CodeGenOpenCL/pipe_builtin.cl (original)
+++ cfe/trunk/test/CodeGenOpenCL/pipe_builtin.cl Mon Jul 31 08:50:27 2017
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -emit-llvm -O0 -cl-std=CL2.0 -o - %s | FileCheck %s
+// RUN: %clang_cc1 -emit-llvm -cl-ext=+cl_khr_subgroups -O0 -cl-std=CL2.0 -o - 
%s | FileCheck %s
 
 // CHECK: %opencl.pipe_t = type opaque
 // CHECK: %opencl.reserve_id_t = type opaque

Modified: cfe/trunk/test/SemaOpenCL/invalid-pipe-builtin-cl2.0.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaOpenCL/invalid-pipe-builtin-cl2.0.cl?rev=309571&r1=309570&r2=309571&view=diff
==
--- cfe/trunk/test/SemaOpenCL/invalid-pipe-builtin-cl2.0.cl (original)
+++ cfe/trunk/test/SemaOpenCL/invalid-pipe-builtin-cl2.0.cl Mon Jul 31 08:50:27 
2017
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL2.0
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL2.0 
-cl-ext=+cl_khr_subgroups
 
 #pragma OPENCL EXTENSION cl_khr_subgroups : enable
 


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


Re: r309007 - [ubsan] Null-check pointers in -fsanitize=vptr (PR33881)

2017-07-31 Thread Nico Weber via cfe-commits
Hi Vedant,

after this change our ubsanvptr bot fails like so:

clang-6.0: error: implicitly disabling vptr sanitizer because null checking
wasn't enabled [-Werror,-Wauto-disable-vptr-sanitizer]

The bot uses -fsanitize=vptr. I have no idea what this warning is supposed
to tell me. Maybe it could be reworded, or maybe it shouldn't be emitted?

Thanks,
Nico

On Tue, Jul 25, 2017 at 3:34 PM, Vedant Kumar via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: vedantk
> Date: Tue Jul 25 12:34:23 2017
> New Revision: 309007
>
> URL: http://llvm.org/viewvc/llvm-project?rev=309007&view=rev
> Log:
> [ubsan] Null-check pointers in -fsanitize=vptr (PR33881)
>
> The instrumentation generated by -fsanitize=vptr does not null check a
> user pointer before loading from it. This causes crashes in the face of
> UB member calls (this=nullptr), i.e it's causing user programs to crash
> only after UBSan is turned on.
>
> The fix is to make run-time null checking a prerequisite for enabling
> -fsanitize=vptr, and to then teach UBSan to reuse these run-time null
> checks to make -fsanitize=vptr safe.
>
> Testing: check-clang, check-ubsan, a stage2 ubsan-enabled build
>
> Differential Revision: https://reviews.llvm.org/D35735
>
> https://bugs.llvm.org/show_bug.cgi?id=33881
>
> Modified:
> cfe/trunk/docs/ReleaseNotes.rst
> cfe/trunk/docs/UndefinedBehaviorSanitizer.rst
> cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
> cfe/trunk/include/clang/Basic/DiagnosticGroups.td
> cfe/trunk/lib/CodeGen/CGExpr.cpp
> cfe/trunk/lib/Driver/SanitizerArgs.cpp
> cfe/trunk/test/CodeGenCXX/catch-undef-behavior.cpp
> cfe/trunk/test/CodeGenCXX/ubsan-devirtualized-calls.cpp
> cfe/trunk/test/CodeGenCXX/ubsan-type-checks.cpp
> cfe/trunk/test/CodeGenCXX/ubsan-vtable-checks.cpp
> cfe/trunk/test/Driver/fsanitize.c
> cfe/trunk/test/Driver/rtti-options.cpp
>
> Modified: cfe/trunk/docs/ReleaseNotes.rst
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/
> ReleaseNotes.rst?rev=309007&r1=309006&r2=309007&view=diff
> 
> ==
> --- cfe/trunk/docs/ReleaseNotes.rst (original)
> +++ cfe/trunk/docs/ReleaseNotes.rst Tue Jul 25 12:34:23 2017
> @@ -155,7 +155,9 @@ Static Analyzer
>  Undefined Behavior Sanitizer (UBSan)
>  
>
> -...
> +The C++ dynamic type check now requires run-time null checking (i.e,
> +`-fsanitize=vptr` cannot be used without `-fsanitize=null`). This change
> does
> +not impact users who rely on UBSan check groups (e.g
> `-fsanitize=undefined`).
>
>  Core Analysis Improvements
>  ==
>
> Modified: cfe/trunk/docs/UndefinedBehaviorSanitizer.rst
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/
> UndefinedBehaviorSanitizer.rst?rev=309007&r1=309006&r2=309007&view=diff
> 
> ==
> --- cfe/trunk/docs/UndefinedBehaviorSanitizer.rst (original)
> +++ cfe/trunk/docs/UndefinedBehaviorSanitizer.rst Tue Jul 25 12:34:23 2017
> @@ -130,11 +130,11 @@ Available checks are:
>   it is often unintentional, so UBSan offers to catch it.
>-  ``-fsanitize=vla-bound``: A variable-length array whose bound
>   does not evaluate to a positive value.
> -  -  ``-fsanitize=vptr``: Use of an object whose vptr indicates that
> - it is of the wrong dynamic type, or that its lifetime has not
> - begun or has ended. Incompatible with ``-fno-rtti``. Link must
> - be performed by ``clang++``, not ``clang``, to make sure C++-specific
> - parts of the runtime library and C++ standard libraries are present.
> +  -  ``-fsanitize=vptr``: Use of an object whose vptr indicates that it
> is of
> + the wrong dynamic type, or that its lifetime has not begun or has
> ended.
> + Incompatible with ``-fno-rtti`` and ``-fno-sanitize=null``. Link
> must be
> + performed by ``clang++``, not ``clang``, to make sure C++-specific
> parts of
> + the runtime library and C++ standard libraries are present.
>
>  You can also use the following check groups:
>-  ``-fsanitize=undefined``: All of the checks listed above other than
>
> Modified: cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/
> DiagnosticDriverKinds.td?rev=309007&r1=309006&r2=309007&view=diff
> 
> ==
> --- cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td (original)
> +++ cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td Tue Jul 25
> 12:34:23 2017
> @@ -230,7 +230,10 @@ def warn_drv_enabling_rtti_with_exceptio
>InGroup>;
>  def warn_drv_disabling_vptr_no_rtti_default : Warning<
>"implicitly disabling vptr sanitizer because rtti wasn't enabled">,
> -  InGroup>;
> +  InGroup;
> +def warn_drv_disabling_vptr_no_null_check : Warning<
> +  "implicitly dis

[PATCH] D34796: upporting -f(no)-reorder-functions flag, clang side change

2017-07-31 Thread Taewook Oh via Phabricator via cfe-commits
twoh added a comment.

Ping. Thanks!


https://reviews.llvm.org/D34796



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


Re: r308996 - [coroutines] Add serialization/deserialization of coroutines

2017-07-31 Thread Hans Wennborg via cfe-commits
Richard, Gor asked for this to be merged to 5.0. What do you think?

On Tue, Jul 25, 2017 at 11:01 AM, Gor Nishanov via cfe-commits
 wrote:
> Author: gornishanov
> Date: Tue Jul 25 11:01:49 2017
> New Revision: 308996
>
> URL: http://llvm.org/viewvc/llvm-project?rev=308996&view=rev
> Log:
> [coroutines] Add serialization/deserialization of coroutines
>
> Reviewers: rsmith
>
> Reviewed By: rsmith
>
> Subscribers: EricWF, cfe-commits
>
> Differential Revision: https://reviews.llvm.org/D35383
>
> Added:
> cfe/trunk/test/PCH/coroutines.cpp
> Modified:
> cfe/trunk/include/clang/AST/StmtCXX.h
> cfe/trunk/include/clang/Serialization/ASTBitCodes.h
> cfe/trunk/lib/AST/StmtCXX.cpp
> cfe/trunk/lib/Serialization/ASTReaderStmt.cpp
> cfe/trunk/lib/Serialization/ASTWriterStmt.cpp
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r309007 - [ubsan] Null-check pointers in -fsanitize=vptr (PR33881)

2017-07-31 Thread Hans Wennborg via cfe-commits
/sub

I believe Vedant asked for this to be merged to 5.0, so I'd like to
merge the resolution too.

On Mon, Jul 31, 2017 at 8:51 AM, Nico Weber via cfe-commits
 wrote:
> Hi Vedant,
>
> after this change our ubsanvptr bot fails like so:
>
> clang-6.0: error: implicitly disabling vptr sanitizer because null checking
> wasn't enabled [-Werror,-Wauto-disable-vptr-sanitizer]
>
> The bot uses -fsanitize=vptr. I have no idea what this warning is supposed
> to tell me. Maybe it could be reworded, or maybe it shouldn't be emitted?
>
> Thanks,
> Nico
>
> On Tue, Jul 25, 2017 at 3:34 PM, Vedant Kumar via cfe-commits
>  wrote:
>>
>> Author: vedantk
>> Date: Tue Jul 25 12:34:23 2017
>> New Revision: 309007
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=309007&view=rev
>> Log:
>> [ubsan] Null-check pointers in -fsanitize=vptr (PR33881)
>>
>> The instrumentation generated by -fsanitize=vptr does not null check a
>> user pointer before loading from it. This causes crashes in the face of
>> UB member calls (this=nullptr), i.e it's causing user programs to crash
>> only after UBSan is turned on.
>>
>> The fix is to make run-time null checking a prerequisite for enabling
>> -fsanitize=vptr, and to then teach UBSan to reuse these run-time null
>> checks to make -fsanitize=vptr safe.
>>
>> Testing: check-clang, check-ubsan, a stage2 ubsan-enabled build
>>
>> Differential Revision: https://reviews.llvm.org/D35735
>>
>> https://bugs.llvm.org/show_bug.cgi?id=33881
>>
>> Modified:
>> cfe/trunk/docs/ReleaseNotes.rst
>> cfe/trunk/docs/UndefinedBehaviorSanitizer.rst
>> cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
>> cfe/trunk/include/clang/Basic/DiagnosticGroups.td
>> cfe/trunk/lib/CodeGen/CGExpr.cpp
>> cfe/trunk/lib/Driver/SanitizerArgs.cpp
>> cfe/trunk/test/CodeGenCXX/catch-undef-behavior.cpp
>> cfe/trunk/test/CodeGenCXX/ubsan-devirtualized-calls.cpp
>> cfe/trunk/test/CodeGenCXX/ubsan-type-checks.cpp
>> cfe/trunk/test/CodeGenCXX/ubsan-vtable-checks.cpp
>> cfe/trunk/test/Driver/fsanitize.c
>> cfe/trunk/test/Driver/rtti-options.cpp
>>
>> Modified: cfe/trunk/docs/ReleaseNotes.rst
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ReleaseNotes.rst?rev=309007&r1=309006&r2=309007&view=diff
>>
>> ==
>> --- cfe/trunk/docs/ReleaseNotes.rst (original)
>> +++ cfe/trunk/docs/ReleaseNotes.rst Tue Jul 25 12:34:23 2017
>> @@ -155,7 +155,9 @@ Static Analyzer
>>  Undefined Behavior Sanitizer (UBSan)
>>  
>>
>> -...
>> +The C++ dynamic type check now requires run-time null checking (i.e,
>> +`-fsanitize=vptr` cannot be used without `-fsanitize=null`). This change
>> does
>> +not impact users who rely on UBSan check groups (e.g
>> `-fsanitize=undefined`).
>>
>>  Core Analysis Improvements
>>  ==
>>
>> Modified: cfe/trunk/docs/UndefinedBehaviorSanitizer.rst
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/UndefinedBehaviorSanitizer.rst?rev=309007&r1=309006&r2=309007&view=diff
>>
>> ==
>> --- cfe/trunk/docs/UndefinedBehaviorSanitizer.rst (original)
>> +++ cfe/trunk/docs/UndefinedBehaviorSanitizer.rst Tue Jul 25 12:34:23 2017
>> @@ -130,11 +130,11 @@ Available checks are:
>>   it is often unintentional, so UBSan offers to catch it.
>>-  ``-fsanitize=vla-bound``: A variable-length array whose bound
>>   does not evaluate to a positive value.
>> -  -  ``-fsanitize=vptr``: Use of an object whose vptr indicates that
>> - it is of the wrong dynamic type, or that its lifetime has not
>> - begun or has ended. Incompatible with ``-fno-rtti``. Link must
>> - be performed by ``clang++``, not ``clang``, to make sure
>> C++-specific
>> - parts of the runtime library and C++ standard libraries are present.
>> +  -  ``-fsanitize=vptr``: Use of an object whose vptr indicates that it
>> is of
>> + the wrong dynamic type, or that its lifetime has not begun or has
>> ended.
>> + Incompatible with ``-fno-rtti`` and ``-fno-sanitize=null``. Link
>> must be
>> + performed by ``clang++``, not ``clang``, to make sure C++-specific
>> parts of
>> + the runtime library and C++ standard libraries are present.
>>
>>  You can also use the following check groups:
>>-  ``-fsanitize=undefined``: All of the checks listed above other than
>>
>> Modified: cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td?rev=309007&r1=309006&r2=309007&view=diff
>>
>> ==
>> --- cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td (original)
>> +++ cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td Tue Jul 25
>> 12:34:23 2017
>> @@ -230,7 +230,10 @@ def warn_drv_enabling_rtti_with_

[PATCH] D34796: upporting -f(no)-reorder-functions flag, clang side change

2017-07-31 Thread David Li via Phabricator via cfe-commits
davidxl added a comment.

The patch is missing documentation  change.


https://reviews.llvm.org/D34796



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


r309575 - [OPENMP] Change the name of outer non-debug function in debug mode, NFC.

2017-07-31 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Mon Jul 31 09:43:06 2017
New Revision: 309575

URL: http://llvm.org/viewvc/llvm-project?rev=309575&view=rev
Log:
[OPENMP] Change the name of outer non-debug function in debug mode, NFC.

Modified:
cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp

Modified: cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp?rev=309575&r1=309574&r2=309575&view=diff
==
--- cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp Mon Jul 31 09:43:06 2017
@@ -448,9 +448,11 @@ CodeGenFunction::GenerateOpenMPCapturedS
   if (!NeedWrapperFunction || !HasUIntPtrArgs)
 return F;
 
+  SmallString<256> Buffer;
+  llvm::raw_svector_ostream Out(Buffer);
+  Out << "__nondebug_wrapper_" << CapturedStmtInfo->getHelperName();
   FunctionOptions WrapperFO(&S, /*UIntPtrCastRequired=*/true,
-/*RegisterCastedArgsOnly=*/true,
-".nondebug_wrapper.");
+/*RegisterCastedArgsOnly=*/true, Out.str());
   CodeGenFunction WrapperCGF(CGM, /*suppressNewContext=*/true);
   WrapperCGF.disableDebugInfo();
   Args.clear();


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


[PATCH] D36095: [clangd] Allow to get vfs::FileSystem used inside codeComplete.

2017-07-31 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov created this revision.

This is useful for managing lifetime of VFS-based caches.


https://reviews.llvm.org/D36095

Files:
  clangd/ClangdServer.cpp
  clangd/ClangdServer.h


Index: clangd/ClangdServer.h
===
--- clangd/ClangdServer.h
+++ clangd/ClangdServer.h
@@ -175,10 +175,14 @@
   /// will be scheduled and a draft for \p File will not be updated.
   /// If \p OverridenContents is None, contents of the current draft for \p 
File
   /// will be used.
-  /// This method should only be called for currently tracked files.
+  /// If \p UsedFS is non-null, it will be overwritten by vfs::FileSystem used
+  /// for completion.
+  /// This method should only be called for currently tracked
+  /// files.
   Tagged>
   codeComplete(PathRef File, Position Pos,
-   llvm::Optional OverridenContents = llvm::None);
+   llvm::Optional OverridenContents = llvm::None,
+   IntrusiveRefCntPtr *UsedFS = nullptr);
   /// Get definition of symbol at a specified \p Line and \p Column in \p File.
   Tagged> findDefinitions(PathRef File, Position Pos);
 
Index: clangd/ClangdServer.cpp
===
--- clangd/ClangdServer.cpp
+++ clangd/ClangdServer.cpp
@@ -192,7 +192,8 @@
 
 Tagged>
 ClangdServer::codeComplete(PathRef File, Position Pos,
-   llvm::Optional OverridenContents) {
+   llvm::Optional OverridenContents,
+   IntrusiveRefCntPtr *UsedFS) {
   std::string DraftStorage;
   if (!OverridenContents) {
 auto FileContents = DraftMgr.getDraft(File);
@@ -203,8 +204,11 @@
 OverridenContents = DraftStorage;
   }
 
-  std::vector Result;
   auto TaggedFS = FSProvider.getTaggedFileSystem(File);
+  if (UsedFS)
+*UsedFS = TaggedFS.Value;
+
+  std::vector Result;
   Units.runOnUnitWithoutReparse(File, *OverridenContents, ResourceDir, CDB,
 PCHs, TaggedFS.Value, [&](ClangdUnit &Unit) {
   Result = Unit.codeComplete(


Index: clangd/ClangdServer.h
===
--- clangd/ClangdServer.h
+++ clangd/ClangdServer.h
@@ -175,10 +175,14 @@
   /// will be scheduled and a draft for \p File will not be updated.
   /// If \p OverridenContents is None, contents of the current draft for \p File
   /// will be used.
-  /// This method should only be called for currently tracked files.
+  /// If \p UsedFS is non-null, it will be overwritten by vfs::FileSystem used
+  /// for completion.
+  /// This method should only be called for currently tracked
+  /// files.
   Tagged>
   codeComplete(PathRef File, Position Pos,
-   llvm::Optional OverridenContents = llvm::None);
+   llvm::Optional OverridenContents = llvm::None,
+   IntrusiveRefCntPtr *UsedFS = nullptr);
   /// Get definition of symbol at a specified \p Line and \p Column in \p File.
   Tagged> findDefinitions(PathRef File, Position Pos);
 
Index: clangd/ClangdServer.cpp
===
--- clangd/ClangdServer.cpp
+++ clangd/ClangdServer.cpp
@@ -192,7 +192,8 @@
 
 Tagged>
 ClangdServer::codeComplete(PathRef File, Position Pos,
-   llvm::Optional OverridenContents) {
+   llvm::Optional OverridenContents,
+   IntrusiveRefCntPtr *UsedFS) {
   std::string DraftStorage;
   if (!OverridenContents) {
 auto FileContents = DraftMgr.getDraft(File);
@@ -203,8 +204,11 @@
 OverridenContents = DraftStorage;
   }
 
-  std::vector Result;
   auto TaggedFS = FSProvider.getTaggedFileSystem(File);
+  if (UsedFS)
+*UsedFS = TaggedFS.Value;
+
+  std::vector Result;
   Units.runOnUnitWithoutReparse(File, *OverridenContents, ResourceDir, CDB,
 PCHs, TaggedFS.Value, [&](ClangdUnit &Unit) {
   Result = Unit.codeComplete(
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r309488 - [X86][AVX] Ensure vector non-temporal load/store intrinsics force pointer alignment (PR33830)

2017-07-31 Thread Hans Wennborg via cfe-commits
Craig, Simon asked for this to be merged to 5.0 together with r309382
and r309383 for PR33830. What do you think?

On Sat, Jul 29, 2017 at 8:33 AM, Simon Pilgrim via cfe-commits
 wrote:
> Author: rksimon
> Date: Sat Jul 29 08:33:34 2017
> New Revision: 309488
>
> URL: http://llvm.org/viewvc/llvm-project?rev=309488&view=rev
> Log:
> [X86][AVX] Ensure vector non-temporal load/store intrinsics force pointer 
> alignment (PR33830)
>
> Clang specifies a max type alignment of 16 bytes on darwin targets 
> (annoyingly in the driver not via cc1), meaning that the builtin nontemporal 
> stores don't correctly align the loads/stores to 32 or 64 bytes when 
> required, resulting in lowering to temporal unaligned loads/stores.
>
> This patch casts the vectors to explicitly aligned types prior to the 
> load/store to ensure that the require alignment is respected.
>
> Differential Revision: https://reviews.llvm.org/D35996
>
> Modified:
> cfe/trunk/lib/Headers/avx2intrin.h
> cfe/trunk/lib/Headers/avx512fintrin.h
> cfe/trunk/lib/Headers/avxintrin.h
> cfe/trunk/test/CodeGen/x86-nontemporal.c
>
> Modified: cfe/trunk/lib/Headers/avx2intrin.h
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/avx2intrin.h?rev=309488&r1=309487&r2=309488&view=diff
> ==
> --- cfe/trunk/lib/Headers/avx2intrin.h (original)
> +++ cfe/trunk/lib/Headers/avx2intrin.h Sat Jul 29 08:33:34 2017
> @@ -832,7 +832,8 @@ _mm256_xor_si256(__m256i __a, __m256i __
>  static __inline__ __m256i __DEFAULT_FN_ATTRS
>  _mm256_stream_load_si256(__m256i const *__V)
>  {
> -  return (__m256i)__builtin_nontemporal_load((const __v4di *)__V);
> +  typedef __v4di __v4di_aligned __attribute__((aligned(32)));
> +  return (__m256i)__builtin_nontemporal_load((const __v4di_aligned *)__V);
>  }
>
>  static __inline__ __m128 __DEFAULT_FN_ATTRS
>
> Modified: cfe/trunk/lib/Headers/avx512fintrin.h
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/avx512fintrin.h?rev=309488&r1=309487&r2=309488&view=diff
> ==
> --- cfe/trunk/lib/Headers/avx512fintrin.h (original)
> +++ cfe/trunk/lib/Headers/avx512fintrin.h Sat Jul 29 08:33:34 2017
> @@ -9035,25 +9035,29 @@ _mm512_kxor (__mmask16 __A, __mmask16 __
>  static __inline__ void __DEFAULT_FN_ATTRS
>  _mm512_stream_si512 (__m512i * __P, __m512i __A)
>  {
> -  __builtin_nontemporal_store((__v8di)__A, (__v8di*)__P);
> +  typedef __v8di __v8di_aligned __attribute__((aligned(64)));
> +  __builtin_nontemporal_store((__v8di_aligned)__A, (__v8di_aligned*)__P);
>  }
>
>  static __inline__ __m512i __DEFAULT_FN_ATTRS
>  _mm512_stream_load_si512 (void *__P)
>  {
> -  return (__m512i) __builtin_nontemporal_load((const __v8di *)__P);
> +  typedef __v8di __v8di_aligned __attribute__((aligned(64)));
> +  return (__m512i) __builtin_nontemporal_load((const __v8di_aligned *)__P);
>  }
>
>  static __inline__ void __DEFAULT_FN_ATTRS
>  _mm512_stream_pd (double *__P, __m512d __A)
>  {
> -  __builtin_nontemporal_store((__v8df)__A, (__v8df*)__P);
> +  typedef __v8df __v8df_aligned __attribute__((aligned(64)));
> +  __builtin_nontemporal_store((__v8df_aligned)__A, (__v8df_aligned*)__P);
>  }
>
>  static __inline__ void __DEFAULT_FN_ATTRS
>  _mm512_stream_ps (float *__P, __m512 __A)
>  {
> -  __builtin_nontemporal_store((__v16sf)__A, (__v16sf*)__P);
> +  typedef __v16sf __v16sf_aligned __attribute__((aligned(64)));
> +  __builtin_nontemporal_store((__v16sf_aligned)__A, (__v16sf_aligned*)__P);
>  }
>
>  static __inline__ __m512d __DEFAULT_FN_ATTRS
>
> Modified: cfe/trunk/lib/Headers/avxintrin.h
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/avxintrin.h?rev=309488&r1=309487&r2=309488&view=diff
> ==
> --- cfe/trunk/lib/Headers/avxintrin.h (original)
> +++ cfe/trunk/lib/Headers/avxintrin.h Sat Jul 29 08:33:34 2017
> @@ -3590,7 +3590,8 @@ _mm_maskstore_ps(float *__p, __m128i __m
>  static __inline void __DEFAULT_FN_ATTRS
>  _mm256_stream_si256(__m256i *__a, __m256i __b)
>  {
> -  __builtin_nontemporal_store((__v4di)__b, (__v4di*)__a);
> +  typedef __v4di __v4di_aligned __attribute__((aligned(32)));
> +  __builtin_nontemporal_store((__v4di_aligned)__b, (__v4di_aligned*)__a);
>  }
>
>  /// \brief Moves double-precision values from a 256-bit vector of [4 x 
> double]
> @@ -3609,7 +3610,8 @@ _mm256_stream_si256(__m256i *__a, __m256
>  static __inline void __DEFAULT_FN_ATTRS
>  _mm256_stream_pd(double *__a, __m256d __b)
>  {
> -  __builtin_nontemporal_store((__v4df)__b, (__v4df*)__a);
> +  typedef __v4df __v4df_aligned __attribute__((aligned(32)));
> +  __builtin_nontemporal_store((__v4df_aligned)__b, (__v4df_aligned*)__a);
>  }
>
>  /// \brief Moves single-precision floating point values from a 256-bit vector
> @@ -3629,7 +3631,8 @@ _mm256_stream_pd(double *__a, __m256d __
>  stati

[PATCH] D35817: Ban implicit _Complex to scalar conversions in C++

2017-07-31 Thread Tim Northover via Phabricator via cfe-commits
t.p.northover added a comment.

Ping.


https://reviews.llvm.org/D35817



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


[PATCH] D36095: [clangd] Allow to get vfs::FileSystem used inside codeComplete.

2017-07-31 Thread Benjamin Kramer via Phabricator via cfe-commits
bkramer accepted this revision.
bkramer added a comment.
This revision is now accepted and ready to land.

lg (it could use a test case though)


https://reviews.llvm.org/D36095



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


Re: r309503 - PR33902: Invalidate line number cache when adding more text to existing buffer.

2017-07-31 Thread Hans Wennborg via cfe-commits
r309580. Thanks!

On Sat, Jul 29, 2017 at 11:33 PM, Richard Smith  wrote:
> We should take this fix for Clang 5.
>
> On 29 July 2017 at 23:31, Richard Smith via cfe-commits
>  wrote:
>>
>> Author: rsmith
>> Date: Sat Jul 29 23:31:29 2017
>> New Revision: 309503
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=309503&view=rev
>> Log:
>> PR33902: Invalidate line number cache when adding more text to existing
>> buffer.
>>
>> This led to crashes as the line number cache would report a bogus line
>> number
>> for a line of code, and we'd try to find a nonexistent column within the
>> line
>> when printing diagnostics.
>>
>> Modified:
>> cfe/trunk/lib/Lex/ScratchBuffer.cpp
>> cfe/trunk/test/Misc/caret-diags-multiline.cpp
>>
>> Modified: cfe/trunk/lib/Lex/ScratchBuffer.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/ScratchBuffer.cpp?rev=309503&r1=309502&r2=309503&view=diff
>>
>> ==
>> --- cfe/trunk/lib/Lex/ScratchBuffer.cpp (original)
>> +++ cfe/trunk/lib/Lex/ScratchBuffer.cpp Sat Jul 29 23:31:29 2017
>> @@ -35,6 +35,14 @@ SourceLocation ScratchBuffer::getToken(c
>> const char *&DestPtr) {
>>if (BytesUsed+Len+2 > ScratchBufSize)
>>  AllocScratchBuffer(Len+2);
>> +  else {
>> +// Clear out the source line cache if it's already been computed.
>> +// FIXME: Allow this to be incrementally extended.
>> +auto *ContentCache = const_cast(
>> +SourceMgr.getSLocEntry(SourceMgr.getFileID(BufferStartLoc))
>> + .getFile().getContentCache());
>> +ContentCache->SourceLineCache = nullptr;
>> +  }
>>
>>// Prefix the token with a \n, so that it looks like it is the first
>> thing on
>>// its own virtual line in caret diagnostics.
>>
>> Modified: cfe/trunk/test/Misc/caret-diags-multiline.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Misc/caret-diags-multiline.cpp?rev=309503&r1=309502&r2=309503&view=diff
>>
>> ==
>> --- cfe/trunk/test/Misc/caret-diags-multiline.cpp (original)
>> +++ cfe/trunk/test/Misc/caret-diags-multiline.cpp Sat Jul 29 23:31:29 2017
>> @@ -232,3 +232,8 @@ void multiple_ranges(int a, int b) {
>>b
>>);
>>  }
>> +
>> +#define pr33902_a(b) #b
>> +#define pr33902_c(d) _Pragma(pr33902_a(d))
>> +#define pr33902_e(f) pr33902_c(GCC warning #f)
>> +pr33902_e() pr33902_e()
>>
>>
>> ___
>> cfe-commits mailing list
>> cfe-commits@lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D35755: [Solaris] gcc toolchain handling revamp

2017-07-31 Thread Fedor Sergeev via Phabricator via cfe-commits
fedor.sergeev added a comment.

ping?


https://reviews.llvm.org/D35755



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


[PATCH] D36095: [clangd] Allow to get vfs::FileSystem used inside codeComplete.

2017-07-31 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL309585: [clangd] Allow to get vfs::FileSystem used inside 
codeComplete. (authored by ibiryukov).

Repository:
  rL LLVM

https://reviews.llvm.org/D36095

Files:
  clang-tools-extra/trunk/clangd/ClangdServer.cpp
  clang-tools-extra/trunk/clangd/ClangdServer.h


Index: clang-tools-extra/trunk/clangd/ClangdServer.h
===
--- clang-tools-extra/trunk/clangd/ClangdServer.h
+++ clang-tools-extra/trunk/clangd/ClangdServer.h
@@ -175,10 +175,14 @@
   /// will be scheduled and a draft for \p File will not be updated.
   /// If \p OverridenContents is None, contents of the current draft for \p 
File
   /// will be used.
-  /// This method should only be called for currently tracked files.
+  /// If \p UsedFS is non-null, it will be overwritten by vfs::FileSystem used
+  /// for completion.
+  /// This method should only be called for currently tracked
+  /// files.
   Tagged>
   codeComplete(PathRef File, Position Pos,
-   llvm::Optional OverridenContents = llvm::None);
+   llvm::Optional OverridenContents = llvm::None,
+   IntrusiveRefCntPtr *UsedFS = nullptr);
   /// Get definition of symbol at a specified \p Line and \p Column in \p File.
   Tagged> findDefinitions(PathRef File, Position Pos);
 
Index: clang-tools-extra/trunk/clangd/ClangdServer.cpp
===
--- clang-tools-extra/trunk/clangd/ClangdServer.cpp
+++ clang-tools-extra/trunk/clangd/ClangdServer.cpp
@@ -192,7 +192,8 @@
 
 Tagged>
 ClangdServer::codeComplete(PathRef File, Position Pos,
-   llvm::Optional OverridenContents) {
+   llvm::Optional OverridenContents,
+   IntrusiveRefCntPtr *UsedFS) {
   std::string DraftStorage;
   if (!OverridenContents) {
 auto FileContents = DraftMgr.getDraft(File);
@@ -203,8 +204,11 @@
 OverridenContents = DraftStorage;
   }
 
-  std::vector Result;
   auto TaggedFS = FSProvider.getTaggedFileSystem(File);
+  if (UsedFS)
+*UsedFS = TaggedFS.Value;
+
+  std::vector Result;
   Units.runOnUnitWithoutReparse(File, *OverridenContents, ResourceDir, CDB,
 PCHs, TaggedFS.Value, [&](ClangdUnit &Unit) {
   Result = Unit.codeComplete(


Index: clang-tools-extra/trunk/clangd/ClangdServer.h
===
--- clang-tools-extra/trunk/clangd/ClangdServer.h
+++ clang-tools-extra/trunk/clangd/ClangdServer.h
@@ -175,10 +175,14 @@
   /// will be scheduled and a draft for \p File will not be updated.
   /// If \p OverridenContents is None, contents of the current draft for \p File
   /// will be used.
-  /// This method should only be called for currently tracked files.
+  /// If \p UsedFS is non-null, it will be overwritten by vfs::FileSystem used
+  /// for completion.
+  /// This method should only be called for currently tracked
+  /// files.
   Tagged>
   codeComplete(PathRef File, Position Pos,
-   llvm::Optional OverridenContents = llvm::None);
+   llvm::Optional OverridenContents = llvm::None,
+   IntrusiveRefCntPtr *UsedFS = nullptr);
   /// Get definition of symbol at a specified \p Line and \p Column in \p File.
   Tagged> findDefinitions(PathRef File, Position Pos);
 
Index: clang-tools-extra/trunk/clangd/ClangdServer.cpp
===
--- clang-tools-extra/trunk/clangd/ClangdServer.cpp
+++ clang-tools-extra/trunk/clangd/ClangdServer.cpp
@@ -192,7 +192,8 @@
 
 Tagged>
 ClangdServer::codeComplete(PathRef File, Position Pos,
-   llvm::Optional OverridenContents) {
+   llvm::Optional OverridenContents,
+   IntrusiveRefCntPtr *UsedFS) {
   std::string DraftStorage;
   if (!OverridenContents) {
 auto FileContents = DraftMgr.getDraft(File);
@@ -203,8 +204,11 @@
 OverridenContents = DraftStorage;
   }
 
-  std::vector Result;
   auto TaggedFS = FSProvider.getTaggedFileSystem(File);
+  if (UsedFS)
+*UsedFS = TaggedFS.Value;
+
+  std::vector Result;
   Units.runOnUnitWithoutReparse(File, *OverridenContents, ResourceDir, CDB,
 PCHs, TaggedFS.Value, [&](ClangdUnit &Unit) {
   Result = Unit.codeComplete(
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r309585 - [clangd] Allow to get vfs::FileSystem used inside codeComplete.

2017-07-31 Thread Ilya Biryukov via cfe-commits
Author: ibiryukov
Date: Mon Jul 31 10:09:29 2017
New Revision: 309585

URL: http://llvm.org/viewvc/llvm-project?rev=309585&view=rev
Log:
[clangd] Allow to get vfs::FileSystem used inside codeComplete.

Summary: This is useful for managing lifetime of VFS-based caches.

Reviewers: bkramer, krasimir

Reviewed By: bkramer

Subscribers: klimek, cfe-commits

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

Modified:
clang-tools-extra/trunk/clangd/ClangdServer.cpp
clang-tools-extra/trunk/clangd/ClangdServer.h

Modified: clang-tools-extra/trunk/clangd/ClangdServer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdServer.cpp?rev=309585&r1=309584&r2=309585&view=diff
==
--- clang-tools-extra/trunk/clangd/ClangdServer.cpp (original)
+++ clang-tools-extra/trunk/clangd/ClangdServer.cpp Mon Jul 31 10:09:29 2017
@@ -192,7 +192,8 @@ void ClangdServer::forceReparse(PathRef
 
 Tagged>
 ClangdServer::codeComplete(PathRef File, Position Pos,
-   llvm::Optional OverridenContents) {
+   llvm::Optional OverridenContents,
+   IntrusiveRefCntPtr *UsedFS) {
   std::string DraftStorage;
   if (!OverridenContents) {
 auto FileContents = DraftMgr.getDraft(File);
@@ -203,8 +204,11 @@ ClangdServer::codeComplete(PathRef File,
 OverridenContents = DraftStorage;
   }
 
-  std::vector Result;
   auto TaggedFS = FSProvider.getTaggedFileSystem(File);
+  if (UsedFS)
+*UsedFS = TaggedFS.Value;
+
+  std::vector Result;
   Units.runOnUnitWithoutReparse(File, *OverridenContents, ResourceDir, CDB,
 PCHs, TaggedFS.Value, [&](ClangdUnit &Unit) {
   Result = Unit.codeComplete(

Modified: clang-tools-extra/trunk/clangd/ClangdServer.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdServer.h?rev=309585&r1=309584&r2=309585&view=diff
==
--- clang-tools-extra/trunk/clangd/ClangdServer.h (original)
+++ clang-tools-extra/trunk/clangd/ClangdServer.h Mon Jul 31 10:09:29 2017
@@ -175,10 +175,14 @@ public:
   /// will be scheduled and a draft for \p File will not be updated.
   /// If \p OverridenContents is None, contents of the current draft for \p 
File
   /// will be used.
-  /// This method should only be called for currently tracked files.
+  /// If \p UsedFS is non-null, it will be overwritten by vfs::FileSystem used
+  /// for completion.
+  /// This method should only be called for currently tracked
+  /// files.
   Tagged>
   codeComplete(PathRef File, Position Pos,
-   llvm::Optional OverridenContents = llvm::None);
+   llvm::Optional OverridenContents = llvm::None,
+   IntrusiveRefCntPtr *UsedFS = nullptr);
   /// Get definition of symbol at a specified \p Line and \p Column in \p File.
   Tagged> findDefinitions(PathRef File, Position Pos);
 


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


[PATCH] D34158: For standards compatibility, preinclude if the file is available

2017-07-31 Thread Fedor Sergeev via Phabricator via cfe-commits
fedor.sergeev added inline comments.



Comment at: test/Driver/stdc-predef.c:15
+  /* In this test, the file stdc-predef.h is missing from the installation */
+#if _STDC_PREDEF_H
+  #error "stdc-predef.h should not be included"

I would rather see a real check on include file inclusion (say, checking -H 
output) than a check for a macro.
Exact macro guard name is not a public interface at all. You might be lucky 
with current stdc-predef.h on Linux, but on other platforms it could be named 
differently.


Repository:
  rL LLVM

https://reviews.llvm.org/D34158



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


Re: r309007 - [ubsan] Null-check pointers in -fsanitize=vptr (PR33881)

2017-07-31 Thread Vedant Kumar via cfe-commits
The bot should start working again with -fsanitize=vptr,null.

The warning can be improved. If we find -fno-sanitize=null in the argument 
list, we might say:
implicitly disabling vptr sanitizer because "-fno-sanitize=null" was specified

Otherwise we might say:
implicitly disabling vptr sanitizer because null checking wasn't enabled, try 
specifying -fsanitize=null or -fsanitize=undefined

I'll send out a patch for review.

vedant

> On Jul 31, 2017, at 9:37 AM, Hans Wennborg  wrote:
> 
> /sub
> 
> I believe Vedant asked for this to be merged to 5.0, so I'd like to
> merge the resolution too.
> 
> On Mon, Jul 31, 2017 at 8:51 AM, Nico Weber via cfe-commits
>  wrote:
>> Hi Vedant,
>> 
>> after this change our ubsanvptr bot fails like so:
>> 
>> clang-6.0: error: implicitly disabling vptr sanitizer because null checking
>> wasn't enabled [-Werror,-Wauto-disable-vptr-sanitizer]
>> 
>> The bot uses -fsanitize=vptr. I have no idea what this warning is supposed
>> to tell me. Maybe it could be reworded, or maybe it shouldn't be emitted?
>> 
>> Thanks,
>> Nico
>> 
>> On Tue, Jul 25, 2017 at 3:34 PM, Vedant Kumar via cfe-commits
>>  wrote:
>>> 
>>> Author: vedantk
>>> Date: Tue Jul 25 12:34:23 2017
>>> New Revision: 309007
>>> 
>>> URL: http://llvm.org/viewvc/llvm-project?rev=309007&view=rev
>>> Log:
>>> [ubsan] Null-check pointers in -fsanitize=vptr (PR33881)
>>> 
>>> The instrumentation generated by -fsanitize=vptr does not null check a
>>> user pointer before loading from it. This causes crashes in the face of
>>> UB member calls (this=nullptr), i.e it's causing user programs to crash
>>> only after UBSan is turned on.
>>> 
>>> The fix is to make run-time null checking a prerequisite for enabling
>>> -fsanitize=vptr, and to then teach UBSan to reuse these run-time null
>>> checks to make -fsanitize=vptr safe.
>>> 
>>> Testing: check-clang, check-ubsan, a stage2 ubsan-enabled build
>>> 
>>> Differential Revision: https://reviews.llvm.org/D35735
>>> 
>>> https://bugs.llvm.org/show_bug.cgi?id=33881
>>> 
>>> Modified:
>>>cfe/trunk/docs/ReleaseNotes.rst
>>>cfe/trunk/docs/UndefinedBehaviorSanitizer.rst
>>>cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
>>>cfe/trunk/include/clang/Basic/DiagnosticGroups.td
>>>cfe/trunk/lib/CodeGen/CGExpr.cpp
>>>cfe/trunk/lib/Driver/SanitizerArgs.cpp
>>>cfe/trunk/test/CodeGenCXX/catch-undef-behavior.cpp
>>>cfe/trunk/test/CodeGenCXX/ubsan-devirtualized-calls.cpp
>>>cfe/trunk/test/CodeGenCXX/ubsan-type-checks.cpp
>>>cfe/trunk/test/CodeGenCXX/ubsan-vtable-checks.cpp
>>>cfe/trunk/test/Driver/fsanitize.c
>>>cfe/trunk/test/Driver/rtti-options.cpp
>>> 
>>> Modified: cfe/trunk/docs/ReleaseNotes.rst
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ReleaseNotes.rst?rev=309007&r1=309006&r2=309007&view=diff
>>> 
>>> ==
>>> --- cfe/trunk/docs/ReleaseNotes.rst (original)
>>> +++ cfe/trunk/docs/ReleaseNotes.rst Tue Jul 25 12:34:23 2017
>>> @@ -155,7 +155,9 @@ Static Analyzer
>>> Undefined Behavior Sanitizer (UBSan)
>>> 
>>> 
>>> -...
>>> +The C++ dynamic type check now requires run-time null checking (i.e,
>>> +`-fsanitize=vptr` cannot be used without `-fsanitize=null`). This change
>>> does
>>> +not impact users who rely on UBSan check groups (e.g
>>> `-fsanitize=undefined`).
>>> 
>>> Core Analysis Improvements
>>> ==
>>> 
>>> Modified: cfe/trunk/docs/UndefinedBehaviorSanitizer.rst
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/UndefinedBehaviorSanitizer.rst?rev=309007&r1=309006&r2=309007&view=diff
>>> 
>>> ==
>>> --- cfe/trunk/docs/UndefinedBehaviorSanitizer.rst (original)
>>> +++ cfe/trunk/docs/UndefinedBehaviorSanitizer.rst Tue Jul 25 12:34:23 2017
>>> @@ -130,11 +130,11 @@ Available checks are:
>>>  it is often unintentional, so UBSan offers to catch it.
>>>   -  ``-fsanitize=vla-bound``: A variable-length array whose bound
>>>  does not evaluate to a positive value.
>>> -  -  ``-fsanitize=vptr``: Use of an object whose vptr indicates that
>>> - it is of the wrong dynamic type, or that its lifetime has not
>>> - begun or has ended. Incompatible with ``-fno-rtti``. Link must
>>> - be performed by ``clang++``, not ``clang``, to make sure
>>> C++-specific
>>> - parts of the runtime library and C++ standard libraries are present.
>>> +  -  ``-fsanitize=vptr``: Use of an object whose vptr indicates that it
>>> is of
>>> + the wrong dynamic type, or that its lifetime has not begun or has
>>> ended.
>>> + Incompatible with ``-fno-rtti`` and ``-fno-sanitize=null``. Link
>>> must be
>>> + performed by ``clang++``, not ``clang``, to make sure C++-specific
>>> parts of
>>> + the runtime library and C++ standard libraries are present.
>>> 
>>> You can also use the following 

Re: r309484 - Fix incorrect assertion condition.

2017-07-31 Thread Vedant Kumar via cfe-commits
Thank you!

vedant

> On Jul 29, 2017, at 1:18 AM, Victor Leschuk via cfe-commits 
>  wrote:
> 
> Author: vleschuk
> Date: Sat Jul 29 01:18:38 2017
> New Revision: 309484
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=309484&view=rev
> Log:
> Fix incorrect assertion condition.
> 
> Modified:
>cfe/trunk/lib/CodeGen/CGBuiltin.cpp
> 
> Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=309484&r1=309483&r2=309484&view=diff
> ==
> --- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Sat Jul 29 01:18:38 2017
> @@ -643,8 +643,8 @@ struct CallObjCArcUse final : EHScopeSta
> 
> Value *CodeGenFunction::EmitCheckedArgForBuiltin(const Expr *E,
>  BuiltinCheckKind Kind) {
> -  assert(Kind == BCK_CLZPassedZero ||
> - Kind == BCK_CTZPassedZero && "Unsupported builtin check kind");
> +  assert((Kind == BCK_CLZPassedZero || Kind == BCK_CTZPassedZero)
> +  && "Unsupported builtin check kind");
> 
>   Value *ArgValue = EmitScalarExpr(E);
>   if (!SanOpts.has(SanitizerKind::Builtin) || 
> !getTarget().isCLZForZeroUndef())
> 
> 
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

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


[PATCH] D36095: [clangd] Allow to get vfs::FileSystem used inside codeComplete.

2017-07-31 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

In https://reviews.llvm.org/D36095#826275, @bkramer wrote:

> lg (it could use a test case though)


Will add a test case in one of further commits.


Repository:
  rL LLVM

https://reviews.llvm.org/D36095



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


Re: r309488 - [X86][AVX] Ensure vector non-temporal load/store intrinsics force pointer alignment (PR33830)

2017-07-31 Thread Craig Topper via cfe-commits
We can merge all three patches to 5.0.

~Craig

On Mon, Jul 31, 2017 at 9:59 AM, Hans Wennborg  wrote:

> Craig, Simon asked for this to be merged to 5.0 together with r309382
> and r309383 for PR33830. What do you think?
>
> On Sat, Jul 29, 2017 at 8:33 AM, Simon Pilgrim via cfe-commits
>  wrote:
> > Author: rksimon
> > Date: Sat Jul 29 08:33:34 2017
> > New Revision: 309488
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=309488&view=rev
> > Log:
> > [X86][AVX] Ensure vector non-temporal load/store intrinsics force
> pointer alignment (PR33830)
> >
> > Clang specifies a max type alignment of 16 bytes on darwin targets
> (annoyingly in the driver not via cc1), meaning that the builtin
> nontemporal stores don't correctly align the loads/stores to 32 or 64 bytes
> when required, resulting in lowering to temporal unaligned loads/stores.
> >
> > This patch casts the vectors to explicitly aligned types prior to the
> load/store to ensure that the require alignment is respected.
> >
> > Differential Revision: https://reviews.llvm.org/D35996
> >
> > Modified:
> > cfe/trunk/lib/Headers/avx2intrin.h
> > cfe/trunk/lib/Headers/avx512fintrin.h
> > cfe/trunk/lib/Headers/avxintrin.h
> > cfe/trunk/test/CodeGen/x86-nontemporal.c
> >
> > Modified: cfe/trunk/lib/Headers/avx2intrin.h
> > URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/
> avx2intrin.h?rev=309488&r1=309487&r2=309488&view=diff
> > 
> ==
> > --- cfe/trunk/lib/Headers/avx2intrin.h (original)
> > +++ cfe/trunk/lib/Headers/avx2intrin.h Sat Jul 29 08:33:34 2017
> > @@ -832,7 +832,8 @@ _mm256_xor_si256(__m256i __a, __m256i __
> >  static __inline__ __m256i __DEFAULT_FN_ATTRS
> >  _mm256_stream_load_si256(__m256i const *__V)
> >  {
> > -  return (__m256i)__builtin_nontemporal_load((const __v4di *)__V);
> > +  typedef __v4di __v4di_aligned __attribute__((aligned(32)));
> > +  return (__m256i)__builtin_nontemporal_load((const __v4di_aligned
> *)__V);
> >  }
> >
> >  static __inline__ __m128 __DEFAULT_FN_ATTRS
> >
> > Modified: cfe/trunk/lib/Headers/avx512fintrin.h
> > URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/
> avx512fintrin.h?rev=309488&r1=309487&r2=309488&view=diff
> > 
> ==
> > --- cfe/trunk/lib/Headers/avx512fintrin.h (original)
> > +++ cfe/trunk/lib/Headers/avx512fintrin.h Sat Jul 29 08:33:34 2017
> > @@ -9035,25 +9035,29 @@ _mm512_kxor (__mmask16 __A, __mmask16 __
> >  static __inline__ void __DEFAULT_FN_ATTRS
> >  _mm512_stream_si512 (__m512i * __P, __m512i __A)
> >  {
> > -  __builtin_nontemporal_store((__v8di)__A, (__v8di*)__P);
> > +  typedef __v8di __v8di_aligned __attribute__((aligned(64)));
> > +  __builtin_nontemporal_store((__v8di_aligned)__A,
> (__v8di_aligned*)__P);
> >  }
> >
> >  static __inline__ __m512i __DEFAULT_FN_ATTRS
> >  _mm512_stream_load_si512 (void *__P)
> >  {
> > -  return (__m512i) __builtin_nontemporal_load((const __v8di *)__P);
> > +  typedef __v8di __v8di_aligned __attribute__((aligned(64)));
> > +  return (__m512i) __builtin_nontemporal_load((const __v8di_aligned
> *)__P);
> >  }
> >
> >  static __inline__ void __DEFAULT_FN_ATTRS
> >  _mm512_stream_pd (double *__P, __m512d __A)
> >  {
> > -  __builtin_nontemporal_store((__v8df)__A, (__v8df*)__P);
> > +  typedef __v8df __v8df_aligned __attribute__((aligned(64)));
> > +  __builtin_nontemporal_store((__v8df_aligned)__A,
> (__v8df_aligned*)__P);
> >  }
> >
> >  static __inline__ void __DEFAULT_FN_ATTRS
> >  _mm512_stream_ps (float *__P, __m512 __A)
> >  {
> > -  __builtin_nontemporal_store((__v16sf)__A, (__v16sf*)__P);
> > +  typedef __v16sf __v16sf_aligned __attribute__((aligned(64)));
> > +  __builtin_nontemporal_store((__v16sf_aligned)__A,
> (__v16sf_aligned*)__P);
> >  }
> >
> >  static __inline__ __m512d __DEFAULT_FN_ATTRS
> >
> > Modified: cfe/trunk/lib/Headers/avxintrin.h
> > URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/
> avxintrin.h?rev=309488&r1=309487&r2=309488&view=diff
> > 
> ==
> > --- cfe/trunk/lib/Headers/avxintrin.h (original)
> > +++ cfe/trunk/lib/Headers/avxintrin.h Sat Jul 29 08:33:34 2017
> > @@ -3590,7 +3590,8 @@ _mm_maskstore_ps(float *__p, __m128i __m
> >  static __inline void __DEFAULT_FN_ATTRS
> >  _mm256_stream_si256(__m256i *__a, __m256i __b)
> >  {
> > -  __builtin_nontemporal_store((__v4di)__b, (__v4di*)__a);
> > +  typedef __v4di __v4di_aligned __attribute__((aligned(32)));
> > +  __builtin_nontemporal_store((__v4di_aligned)__b,
> (__v4di_aligned*)__a);
> >  }
> >
> >  /// \brief Moves double-precision values from a 256-bit vector of [4 x
> double]
> > @@ -3609,7 +3610,8 @@ _mm256_stream_si256(__m256i *__a, __m256
> >  static __inline void __DEFAULT_FN_ATTRS
> >  _mm256_stream_pd(double *__a, __m256d __b)
> >  {
> > -  __builtin_nontemporal_store((__v4df)__b

[PATCH] D36083: [utils] Add a script that runs clang in LLDB and stops it when a specified diagnostic is emitted

2017-07-31 Thread don hinton via Phabricator via cfe-commits
hintonda added a comment.

Cool, I'll try to play with this later today.

BTW, since the call to DiagnosticsEngine::Report is delayed when using 
PartialDiagnostic, would it make sense to add them as well?  Also, this doesn't 
seem to solve the initial problem of finding the Diag name in the first place.

Eventually, I'd like a scan-build like tool that let you rerun a particular 
compilation command (without needing to construct the -cc1 command yourself), 
that adds breakpoints for all warning/error diagnostics seen before invoking 
lldb -- perhaps even leveraging the compilation database, a la clang-tidy.


Repository:
  rL LLVM

https://reviews.llvm.org/D36083



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


Re: r309488 - [X86][AVX] Ensure vector non-temporal load/store intrinsics force pointer alignment (PR33830)

2017-07-31 Thread Hans Wennborg via cfe-commits
Thanks! r309588.

On Mon, Jul 31, 2017 at 10:25 AM, Craig Topper  wrote:
> We can merge all three patches to 5.0.
>
> ~Craig
>
> On Mon, Jul 31, 2017 at 9:59 AM, Hans Wennborg  wrote:
>>
>> Craig, Simon asked for this to be merged to 5.0 together with r309382
>> and r309383 for PR33830. What do you think?
>>
>> On Sat, Jul 29, 2017 at 8:33 AM, Simon Pilgrim via cfe-commits
>>  wrote:
>> > Author: rksimon
>> > Date: Sat Jul 29 08:33:34 2017
>> > New Revision: 309488
>> >
>> > URL: http://llvm.org/viewvc/llvm-project?rev=309488&view=rev
>> > Log:
>> > [X86][AVX] Ensure vector non-temporal load/store intrinsics force
>> > pointer alignment (PR33830)
>> >
>> > Clang specifies a max type alignment of 16 bytes on darwin targets
>> > (annoyingly in the driver not via cc1), meaning that the builtin 
>> > nontemporal
>> > stores don't correctly align the loads/stores to 32 or 64 bytes when
>> > required, resulting in lowering to temporal unaligned loads/stores.
>> >
>> > This patch casts the vectors to explicitly aligned types prior to the
>> > load/store to ensure that the require alignment is respected.
>> >
>> > Differential Revision: https://reviews.llvm.org/D35996
>> >
>> > Modified:
>> > cfe/trunk/lib/Headers/avx2intrin.h
>> > cfe/trunk/lib/Headers/avx512fintrin.h
>> > cfe/trunk/lib/Headers/avxintrin.h
>> > cfe/trunk/test/CodeGen/x86-nontemporal.c
>> >
>> > Modified: cfe/trunk/lib/Headers/avx2intrin.h
>> > URL:
>> > http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/avx2intrin.h?rev=309488&r1=309487&r2=309488&view=diff
>> >
>> > ==
>> > --- cfe/trunk/lib/Headers/avx2intrin.h (original)
>> > +++ cfe/trunk/lib/Headers/avx2intrin.h Sat Jul 29 08:33:34 2017
>> > @@ -832,7 +832,8 @@ _mm256_xor_si256(__m256i __a, __m256i __
>> >  static __inline__ __m256i __DEFAULT_FN_ATTRS
>> >  _mm256_stream_load_si256(__m256i const *__V)
>> >  {
>> > -  return (__m256i)__builtin_nontemporal_load((const __v4di *)__V);
>> > +  typedef __v4di __v4di_aligned __attribute__((aligned(32)));
>> > +  return (__m256i)__builtin_nontemporal_load((const __v4di_aligned
>> > *)__V);
>> >  }
>> >
>> >  static __inline__ __m128 __DEFAULT_FN_ATTRS
>> >
>> > Modified: cfe/trunk/lib/Headers/avx512fintrin.h
>> > URL:
>> > http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/avx512fintrin.h?rev=309488&r1=309487&r2=309488&view=diff
>> >
>> > ==
>> > --- cfe/trunk/lib/Headers/avx512fintrin.h (original)
>> > +++ cfe/trunk/lib/Headers/avx512fintrin.h Sat Jul 29 08:33:34 2017
>> > @@ -9035,25 +9035,29 @@ _mm512_kxor (__mmask16 __A, __mmask16 __
>> >  static __inline__ void __DEFAULT_FN_ATTRS
>> >  _mm512_stream_si512 (__m512i * __P, __m512i __A)
>> >  {
>> > -  __builtin_nontemporal_store((__v8di)__A, (__v8di*)__P);
>> > +  typedef __v8di __v8di_aligned __attribute__((aligned(64)));
>> > +  __builtin_nontemporal_store((__v8di_aligned)__A,
>> > (__v8di_aligned*)__P);
>> >  }
>> >
>> >  static __inline__ __m512i __DEFAULT_FN_ATTRS
>> >  _mm512_stream_load_si512 (void *__P)
>> >  {
>> > -  return (__m512i) __builtin_nontemporal_load((const __v8di *)__P);
>> > +  typedef __v8di __v8di_aligned __attribute__((aligned(64)));
>> > +  return (__m512i) __builtin_nontemporal_load((const __v8di_aligned
>> > *)__P);
>> >  }
>> >
>> >  static __inline__ void __DEFAULT_FN_ATTRS
>> >  _mm512_stream_pd (double *__P, __m512d __A)
>> >  {
>> > -  __builtin_nontemporal_store((__v8df)__A, (__v8df*)__P);
>> > +  typedef __v8df __v8df_aligned __attribute__((aligned(64)));
>> > +  __builtin_nontemporal_store((__v8df_aligned)__A,
>> > (__v8df_aligned*)__P);
>> >  }
>> >
>> >  static __inline__ void __DEFAULT_FN_ATTRS
>> >  _mm512_stream_ps (float *__P, __m512 __A)
>> >  {
>> > -  __builtin_nontemporal_store((__v16sf)__A, (__v16sf*)__P);
>> > +  typedef __v16sf __v16sf_aligned __attribute__((aligned(64)));
>> > +  __builtin_nontemporal_store((__v16sf_aligned)__A,
>> > (__v16sf_aligned*)__P);
>> >  }
>> >
>> >  static __inline__ __m512d __DEFAULT_FN_ATTRS
>> >
>> > Modified: cfe/trunk/lib/Headers/avxintrin.h
>> > URL:
>> > http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/avxintrin.h?rev=309488&r1=309487&r2=309488&view=diff
>> >
>> > ==
>> > --- cfe/trunk/lib/Headers/avxintrin.h (original)
>> > +++ cfe/trunk/lib/Headers/avxintrin.h Sat Jul 29 08:33:34 2017
>> > @@ -3590,7 +3590,8 @@ _mm_maskstore_ps(float *__p, __m128i __m
>> >  static __inline void __DEFAULT_FN_ATTRS
>> >  _mm256_stream_si256(__m256i *__a, __m256i __b)
>> >  {
>> > -  __builtin_nontemporal_store((__v4di)__b, (__v4di*)__a);
>> > +  typedef __v4di __v4di_aligned __attribute__((aligned(32)));
>> > +  __builtin_nontemporal_store((__v4di_aligned)__b,
>> > (__v4di_aligned*)__a);
>> >  }
>> >
>> >  /// \brief Moves double-precision values from a 256-bit vector o

[PATCH] D36083: [utils] Add a script that runs clang in LLDB and stops it when a specified diagnostic is emitted

2017-07-31 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added a comment.

It might make sense to add a breakpoint at `PartialDiagnostic(unsigned DiagID, 
StorageAllocator &Allocator)`, I'll check how that works.

I reckon it should be possible to have a script that could find the name of all 
emitted diagnostics. Let's say we'd like to run clang with `-cc1 main.cpp`.
If we run it in LLDB and put a breakpoint at DiagnosticsEngine::Report, we 
could add a command to that breakpoint that would print a unique string and the 
diagnostic id.
The script would redirect the stdout from LLDB/Clang, but it would replace the 
occurrence of the unique string and diagnostic id with the name of the 
diagnostic by evaluating some `diagtool` that maps the id back to the 
diagnostic (If there are multiple same diagnostics it could also add an id and 
then we could extend this script to stop at the Nth specific diagnostic).


Repository:
  rL LLVM

https://reviews.llvm.org/D36083



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


r309598 - [Targets] Move addCygMingDefines into the arch-independent Targets.cpp (NFC)

2017-07-31 Thread Martin Storsjo via cfe-commits
Author: mstorsjo
Date: Mon Jul 31 11:17:38 2017
New Revision: 309598

URL: http://llvm.org/viewvc/llvm-project?rev=309598&view=rev
Log:
[Targets] Move addCygMingDefines into the arch-independent Targets.cpp (NFC)

This fixes a dependency inconsistency, where addMinGWDefines in Targets.cpp
(used from other architectures than X86) called the addCygMingDefines function
in X86.h.

This was inconsistently split in SVN r308791 (D35701).

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

Modified:
cfe/trunk/lib/Basic/Targets.cpp
cfe/trunk/lib/Basic/Targets.h
cfe/trunk/lib/Basic/Targets/X86.h

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=309598&r1=309597&r2=309598&view=diff
==
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Mon Jul 31 11:17:38 2017
@@ -73,6 +73,30 @@ void defineCPUMacros(MacroBuilder &Build
 Builder.defineMacro("__tune_" + CPUName + "__");
 }
 
+void addCygMingDefines(const LangOptions &Opts, MacroBuilder &Builder) {
+  // Mingw and cygwin define __declspec(a) to __attribute__((a)).  Clang
+  // supports __declspec natively under -fms-extensions, but we define a no-op
+  // __declspec macro anyway for pre-processor compatibility.
+  if (Opts.MicrosoftExt)
+Builder.defineMacro("__declspec", "__declspec");
+  else
+Builder.defineMacro("__declspec(a)", "__attribute__((a))");
+
+  if (!Opts.MicrosoftExt) {
+// Provide macros for all the calling convention keywords.  Provide both
+// single and double underscore prefixed variants.  These are available on
+// x64 as well as x86, even though they have no effect.
+const char *CCs[] = {"cdecl", "stdcall", "fastcall", "thiscall", "pascal"};
+for (const char *CC : CCs) {
+  std::string GCCSpelling = "__attribute__((__";
+  GCCSpelling += CC;
+  GCCSpelling += "__))";
+  Builder.defineMacro(Twine("_") + CC, GCCSpelling);
+  Builder.defineMacro(Twine("__") + CC, GCCSpelling);
+}
+  }
+}
+
 void addMinGWDefines(const LangOptions &Opts, MacroBuilder &Builder) {
   Builder.defineMacro("__MSVCRT__");
   Builder.defineMacro("__MINGW32__");

Modified: cfe/trunk/lib/Basic/Targets.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.h?rev=309598&r1=309597&r2=309598&view=diff
==
--- cfe/trunk/lib/Basic/Targets.h (original)
+++ cfe/trunk/lib/Basic/Targets.h Mon Jul 31 11:17:38 2017
@@ -42,6 +42,10 @@ void defineCPUMacros(clang::MacroBuilder
 LLVM_LIBRARY_VISIBILITY
 void addMinGWDefines(const clang::LangOptions &Opts,
  clang::MacroBuilder &Builder);
+
+LLVM_LIBRARY_VISIBILITY
+void addCygMingDefines(const clang::LangOptions &Opts,
+   clang::MacroBuilder &Builder);
 } // namespace targets
 } // namespace clang
 #endif // LLVM_CLANG_LIB_BASIC_TARGETS_H

Modified: cfe/trunk/lib/Basic/Targets/X86.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/X86.h?rev=309598&r1=309597&r2=309598&view=diff
==
--- cfe/trunk/lib/Basic/Targets/X86.h (original)
+++ cfe/trunk/lib/Basic/Targets/X86.h Mon Jul 31 11:17:38 2017
@@ -691,30 +691,6 @@ public:
   }
 };
 
-static void addCygMingDefines(const LangOptions &Opts, MacroBuilder &Builder) {
-  // Mingw and cygwin define __declspec(a) to __attribute__((a)).  Clang
-  // supports __declspec natively under -fms-extensions, but we define a no-op
-  // __declspec macro anyway for pre-processor compatibility.
-  if (Opts.MicrosoftExt)
-Builder.defineMacro("__declspec", "__declspec");
-  else
-Builder.defineMacro("__declspec(a)", "__attribute__((a))");
-
-  if (!Opts.MicrosoftExt) {
-// Provide macros for all the calling convention keywords.  Provide both
-// single and double underscore prefixed variants.  These are available on
-// x64 as well as x86, even though they have no effect.
-const char *CCs[] = {"cdecl", "stdcall", "fastcall", "thiscall", "pascal"};
-for (const char *CC : CCs) {
-  std::string GCCSpelling = "__attribute__((__";
-  GCCSpelling += CC;
-  GCCSpelling += "__))";
-  Builder.defineMacro(Twine("_") + CC, GCCSpelling);
-  Builder.defineMacro(Twine("__") + CC, GCCSpelling);
-}
-  }
-}
-
 // x86-32 MinGW target
 class LLVM_LIBRARY_VISIBILITY MinGWX86_32TargetInfo
 : public WindowsX86_32TargetInfo {


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


[PATCH] D36072: [Targets] Move addCygMingDefines into the arch-independent Targets.cpp (NFC)

2017-07-31 Thread Martin Storsjö via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL309598: [Targets] Move addCygMingDefines into the 
arch-independent Targets.cpp (NFC) (authored by mstorsjo).

Changed prior to commit:
  https://reviews.llvm.org/D36072?vs=108865&id=108954#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D36072

Files:
  cfe/trunk/lib/Basic/Targets.cpp
  cfe/trunk/lib/Basic/Targets.h
  cfe/trunk/lib/Basic/Targets/X86.h


Index: cfe/trunk/lib/Basic/Targets/X86.h
===
--- cfe/trunk/lib/Basic/Targets/X86.h
+++ cfe/trunk/lib/Basic/Targets/X86.h
@@ -691,30 +691,6 @@
   }
 };
 
-static void addCygMingDefines(const LangOptions &Opts, MacroBuilder &Builder) {
-  // Mingw and cygwin define __declspec(a) to __attribute__((a)).  Clang
-  // supports __declspec natively under -fms-extensions, but we define a no-op
-  // __declspec macro anyway for pre-processor compatibility.
-  if (Opts.MicrosoftExt)
-Builder.defineMacro("__declspec", "__declspec");
-  else
-Builder.defineMacro("__declspec(a)", "__attribute__((a))");
-
-  if (!Opts.MicrosoftExt) {
-// Provide macros for all the calling convention keywords.  Provide both
-// single and double underscore prefixed variants.  These are available on
-// x64 as well as x86, even though they have no effect.
-const char *CCs[] = {"cdecl", "stdcall", "fastcall", "thiscall", "pascal"};
-for (const char *CC : CCs) {
-  std::string GCCSpelling = "__attribute__((__";
-  GCCSpelling += CC;
-  GCCSpelling += "__))";
-  Builder.defineMacro(Twine("_") + CC, GCCSpelling);
-  Builder.defineMacro(Twine("__") + CC, GCCSpelling);
-}
-  }
-}
-
 // x86-32 MinGW target
 class LLVM_LIBRARY_VISIBILITY MinGWX86_32TargetInfo
 : public WindowsX86_32TargetInfo {
Index: cfe/trunk/lib/Basic/Targets.h
===
--- cfe/trunk/lib/Basic/Targets.h
+++ cfe/trunk/lib/Basic/Targets.h
@@ -42,6 +42,10 @@
 LLVM_LIBRARY_VISIBILITY
 void addMinGWDefines(const clang::LangOptions &Opts,
  clang::MacroBuilder &Builder);
+
+LLVM_LIBRARY_VISIBILITY
+void addCygMingDefines(const clang::LangOptions &Opts,
+   clang::MacroBuilder &Builder);
 } // namespace targets
 } // namespace clang
 #endif // LLVM_CLANG_LIB_BASIC_TARGETS_H
Index: cfe/trunk/lib/Basic/Targets.cpp
===
--- cfe/trunk/lib/Basic/Targets.cpp
+++ cfe/trunk/lib/Basic/Targets.cpp
@@ -73,6 +73,30 @@
 Builder.defineMacro("__tune_" + CPUName + "__");
 }
 
+void addCygMingDefines(const LangOptions &Opts, MacroBuilder &Builder) {
+  // Mingw and cygwin define __declspec(a) to __attribute__((a)).  Clang
+  // supports __declspec natively under -fms-extensions, but we define a no-op
+  // __declspec macro anyway for pre-processor compatibility.
+  if (Opts.MicrosoftExt)
+Builder.defineMacro("__declspec", "__declspec");
+  else
+Builder.defineMacro("__declspec(a)", "__attribute__((a))");
+
+  if (!Opts.MicrosoftExt) {
+// Provide macros for all the calling convention keywords.  Provide both
+// single and double underscore prefixed variants.  These are available on
+// x64 as well as x86, even though they have no effect.
+const char *CCs[] = {"cdecl", "stdcall", "fastcall", "thiscall", "pascal"};
+for (const char *CC : CCs) {
+  std::string GCCSpelling = "__attribute__((__";
+  GCCSpelling += CC;
+  GCCSpelling += "__))";
+  Builder.defineMacro(Twine("_") + CC, GCCSpelling);
+  Builder.defineMacro(Twine("__") + CC, GCCSpelling);
+}
+  }
+}
+
 void addMinGWDefines(const LangOptions &Opts, MacroBuilder &Builder) {
   Builder.defineMacro("__MSVCRT__");
   Builder.defineMacro("__MINGW32__");


Index: cfe/trunk/lib/Basic/Targets/X86.h
===
--- cfe/trunk/lib/Basic/Targets/X86.h
+++ cfe/trunk/lib/Basic/Targets/X86.h
@@ -691,30 +691,6 @@
   }
 };
 
-static void addCygMingDefines(const LangOptions &Opts, MacroBuilder &Builder) {
-  // Mingw and cygwin define __declspec(a) to __attribute__((a)).  Clang
-  // supports __declspec natively under -fms-extensions, but we define a no-op
-  // __declspec macro anyway for pre-processor compatibility.
-  if (Opts.MicrosoftExt)
-Builder.defineMacro("__declspec", "__declspec");
-  else
-Builder.defineMacro("__declspec(a)", "__attribute__((a))");
-
-  if (!Opts.MicrosoftExt) {
-// Provide macros for all the calling convention keywords.  Provide both
-// single and double underscore prefixed variants.  These are available on
-// x64 as well as x86, even though they have no effect.
-const char *CCs[] = {"cdecl", "stdcall", "fastcall", "thiscall", "pascal"};
-for (const char *CC : CCs) {
-  std::string GCCSpelling = "__attribute__((__";
-  GCCSpelling += CC;
-  GCCSpelling += "__)

[PATCH] D36096: [ubsan] Make the 'vptr check disabled' warning more helpful

2017-07-31 Thread Vedant Kumar via Phabricator via cfe-commits
vsk created this revision.

If -fsanitize=vptr is passed without -fsanitize=null being specified, it will 
say:

  warning: implicitly disabling vptr sanitizer because null checking wasn't 
enabled (try specifying -fsanitize=null or -fsanitize=undefined)

Otherwise if the vptr check is enabled and null checking is explicitly 
disabled, it will say:

warning: implicitly disabling vptr sanitizer because null checking wasn't 
enabled (try removing -fno-sanitize=null)

See the mailing list thread re: r309007


https://reviews.llvm.org/D36096

Files:
  include/clang/Basic/DiagnosticDriverKinds.td
  lib/Driver/SanitizerArgs.cpp
  test/Driver/fsanitize.c


Index: test/Driver/fsanitize.c
===
--- test/Driver/fsanitize.c
+++ test/Driver/fsanitize.c
@@ -58,9 +58,10 @@
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=undefined -fno-rtti %s -### 
2>&1 | FileCheck %s --check-prefix=CHECK-UNDEFINED-NO-RTTI
 // CHECK-UNDEFINED-NO-RTTI-NOT: vptr
 
-// RUN: %clang -target x86_64-linux-gnu -fsanitize=undefined 
-fno-sanitize=null %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-VPTR-NO-NULL
-// RUN: %clang -target x86_64-linux-gnu -fsanitize=vptr %s -### 2>&1 | 
FileCheck %s --check-prefix=CHECK-VPTR-NO-NULL
-// CHECK-VPTR-NO-NULL: warning: implicitly disabling vptr sanitizer because 
null checking wasn't enabled
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=undefined 
-fno-sanitize=null %s -### 2>&1 | FileCheck %s 
--check-prefix=CHECK-VPTR-EXPLICIT-NO-NULL
+// CHECK-VPTR-EXPLICIT-NO-NULL: warning: implicitly disabling vptr sanitizer 
because null checking wasn't enabled (try removing -fno-sanitize=null)
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=vptr %s -### 2>&1 | 
FileCheck %s --check-prefix=CHECK-VPTR-IMPLICIT-NO-NULL
+// CHECK-VPTR-IMPLICIT-NO-NULL: warning: implicitly disabling vptr sanitizer 
because null checking wasn't enabled (try specifying -fsanitize=null or 
-fsanitize=undefined)
 
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=address,thread -fno-rtti %s 
-### 2>&1 | FileCheck %s --check-prefix=CHECK-SANA-SANT
 // CHECK-SANA-SANT: '-fsanitize=address' not allowed with '-fsanitize=thread'
Index: lib/Driver/SanitizerArgs.cpp
===
--- lib/Driver/SanitizerArgs.cpp
+++ lib/Driver/SanitizerArgs.cpp
@@ -311,7 +311,7 @@
   // instrumentation is broken without run-time null checks).
   if ((Kinds & Vptr) && !(Kinds & Null)) {
 Kinds &= ~Vptr;
-D.Diag(diag::warn_drv_disabling_vptr_no_null_check);
+D.Diag(diag::warn_drv_disabling_vptr_no_null_check) << !!(AllRemove & 
Null);
   }
 
   // Check that LTO is enabled if we need it.
Index: include/clang/Basic/DiagnosticDriverKinds.td
===
--- include/clang/Basic/DiagnosticDriverKinds.td
+++ include/clang/Basic/DiagnosticDriverKinds.td
@@ -232,7 +232,7 @@
   "implicitly disabling vptr sanitizer because rtti wasn't enabled">,
   InGroup;
 def warn_drv_disabling_vptr_no_null_check : Warning<
-  "implicitly disabling vptr sanitizer because null checking wasn't enabled">,
+  "implicitly disabling vptr sanitizer because null checking wasn't enabled 
(try %select{specifying -fsanitize=null or -fsanitize=undefined|removing 
-fno-sanitize=null}0)">,
   InGroup;
 def warn_drv_object_size_disabled_O0 : Warning<
   "the object size sanitizer has no effect at -O0, but is explicitly enabled: 
%0">,


Index: test/Driver/fsanitize.c
===
--- test/Driver/fsanitize.c
+++ test/Driver/fsanitize.c
@@ -58,9 +58,10 @@
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=undefined -fno-rtti %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-UNDEFINED-NO-RTTI
 // CHECK-UNDEFINED-NO-RTTI-NOT: vptr
 
-// RUN: %clang -target x86_64-linux-gnu -fsanitize=undefined -fno-sanitize=null %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-VPTR-NO-NULL
-// RUN: %clang -target x86_64-linux-gnu -fsanitize=vptr %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-VPTR-NO-NULL
-// CHECK-VPTR-NO-NULL: warning: implicitly disabling vptr sanitizer because null checking wasn't enabled
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=undefined -fno-sanitize=null %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-VPTR-EXPLICIT-NO-NULL
+// CHECK-VPTR-EXPLICIT-NO-NULL: warning: implicitly disabling vptr sanitizer because null checking wasn't enabled (try removing -fno-sanitize=null)
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=vptr %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-VPTR-IMPLICIT-NO-NULL
+// CHECK-VPTR-IMPLICIT-NO-NULL: warning: implicitly disabling vptr sanitizer because null checking wasn't enabled (try specifying -fsanitize=null or -fsanitize=undefined)
 
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=address,thread -fno-rtti %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SANA-SANT
 // CHECK-SANA-SANT: '-fsanitize=addr

[PATCH] D35564: Suppress -pedantic warnings about GNU extension StmtExpr in glibc's assert macro

2017-07-31 Thread Khem Raj via Phabricator via cfe-commits
raj.khem added a comment.

There is a proposed fix for glibc's assert here

https://sourceware.org/ml/libc-alpha/2017-07/msg00227.html

despite that, this patch in general seems useful.


https://reviews.llvm.org/D35564



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


Re: r309007 - [ubsan] Null-check pointers in -fsanitize=vptr (PR33881)

2017-07-31 Thread Vedant Kumar via cfe-commits
+ Nico, sorry I missed your email in the reply-all. Here's a revised version of 
the warning:

https://reviews.llvm.org/D36096 

vedant

> On Jul 31, 2017, at 10:18 AM, Vedant Kumar via cfe-commits 
>  wrote:
> 
> The bot should start working again with -fsanitize=vptr,null.
> 
> The warning can be improved. If we find -fno-sanitize=null in the argument 
> list, we might say:
> implicitly disabling vptr sanitizer because "-fno-sanitize=null" was specified
> 
> Otherwise we might say:
> implicitly disabling vptr sanitizer because null checking wasn't enabled, try 
> specifying -fsanitize=null or -fsanitize=undefined
> 
> I'll send out a patch for review.
> 
> vedant
> 
>> On Jul 31, 2017, at 9:37 AM, Hans Wennborg  wrote:
>> 
>> /sub
>> 
>> I believe Vedant asked for this to be merged to 5.0, so I'd like to
>> merge the resolution too.
>> 
>> On Mon, Jul 31, 2017 at 8:51 AM, Nico Weber via cfe-commits
>>  wrote:
>>> Hi Vedant,
>>> 
>>> after this change our ubsanvptr bot fails like so:
>>> 
>>> clang-6.0: error: implicitly disabling vptr sanitizer because null checking
>>> wasn't enabled [-Werror,-Wauto-disable-vptr-sanitizer]
>>> 
>>> The bot uses -fsanitize=vptr. I have no idea what this warning is supposed
>>> to tell me. Maybe it could be reworded, or maybe it shouldn't be emitted?
>>> 
>>> Thanks,
>>> Nico
>>> 
>>> On Tue, Jul 25, 2017 at 3:34 PM, Vedant Kumar via cfe-commits
>>>  wrote:
 
 Author: vedantk
 Date: Tue Jul 25 12:34:23 2017
 New Revision: 309007
 
 URL: http://llvm.org/viewvc/llvm-project?rev=309007&view=rev
 Log:
 [ubsan] Null-check pointers in -fsanitize=vptr (PR33881)
 
 The instrumentation generated by -fsanitize=vptr does not null check a
 user pointer before loading from it. This causes crashes in the face of
 UB member calls (this=nullptr), i.e it's causing user programs to crash
 only after UBSan is turned on.
 
 The fix is to make run-time null checking a prerequisite for enabling
 -fsanitize=vptr, and to then teach UBSan to reuse these run-time null
 checks to make -fsanitize=vptr safe.
 
 Testing: check-clang, check-ubsan, a stage2 ubsan-enabled build
 
 Differential Revision: https://reviews.llvm.org/D35735
 
 https://bugs.llvm.org/show_bug.cgi?id=33881
 
 Modified:
   cfe/trunk/docs/ReleaseNotes.rst
   cfe/trunk/docs/UndefinedBehaviorSanitizer.rst
   cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
   cfe/trunk/include/clang/Basic/DiagnosticGroups.td
   cfe/trunk/lib/CodeGen/CGExpr.cpp
   cfe/trunk/lib/Driver/SanitizerArgs.cpp
   cfe/trunk/test/CodeGenCXX/catch-undef-behavior.cpp
   cfe/trunk/test/CodeGenCXX/ubsan-devirtualized-calls.cpp
   cfe/trunk/test/CodeGenCXX/ubsan-type-checks.cpp
   cfe/trunk/test/CodeGenCXX/ubsan-vtable-checks.cpp
   cfe/trunk/test/Driver/fsanitize.c
   cfe/trunk/test/Driver/rtti-options.cpp
 
 Modified: cfe/trunk/docs/ReleaseNotes.rst
 URL:
 http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ReleaseNotes.rst?rev=309007&r1=309006&r2=309007&view=diff
 
 ==
 --- cfe/trunk/docs/ReleaseNotes.rst (original)
 +++ cfe/trunk/docs/ReleaseNotes.rst Tue Jul 25 12:34:23 2017
 @@ -155,7 +155,9 @@ Static Analyzer
 Undefined Behavior Sanitizer (UBSan)
 
 
 -...
 +The C++ dynamic type check now requires run-time null checking (i.e,
 +`-fsanitize=vptr` cannot be used without `-fsanitize=null`). This change
 does
 +not impact users who rely on UBSan check groups (e.g
 `-fsanitize=undefined`).
 
 Core Analysis Improvements
 ==
 
 Modified: cfe/trunk/docs/UndefinedBehaviorSanitizer.rst
 URL:
 http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/UndefinedBehaviorSanitizer.rst?rev=309007&r1=309006&r2=309007&view=diff
 
 ==
 --- cfe/trunk/docs/UndefinedBehaviorSanitizer.rst (original)
 +++ cfe/trunk/docs/UndefinedBehaviorSanitizer.rst Tue Jul 25 12:34:23 2017
 @@ -130,11 +130,11 @@ Available checks are:
 it is often unintentional, so UBSan offers to catch it.
  -  ``-fsanitize=vla-bound``: A variable-length array whose bound
 does not evaluate to a positive value.
 -  -  ``-fsanitize=vptr``: Use of an object whose vptr indicates that
 - it is of the wrong dynamic type, or that its lifetime has not
 - begun or has ended. Incompatible with ``-fno-rtti``. Link must
 - be performed by ``clang++``, not ``clang``, to make sure
 C++-specific
 - parts of the runtime library and C++ standard libraries are present.
 +  -  ``-fsanitize=vptr``: Use of an object whose vptr indicates that it
 is of
 + the

Re: [libcxxabi] r309349 - [demangler] Fix some overzealous -Wreturn-type errors

2017-07-31 Thread David Blaikie via cfe-commits
On Thu, Jul 27, 2017 at 6:35 PM Erik Pilkington via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: epilk
> Date: Thu Jul 27 18:35:14 2017
> New Revision: 309349
>
> URL: http://llvm.org/viewvc/llvm-project?rev=309349&view=rev
> Log:
> [demangler] Fix some overzealous -Wreturn-type errors
>

I'm guessing this is GCC's -Wreturn-type after a
fully-covered-all-returning switch?

That's usually addressed by using llvm_unreachable after the switch, rather
than a dead return. (not sure if you've something like llvm_unreachable in
libcxxabi to use?)


>
> Modified:
> libcxxabi/trunk/src/cxa_demangle.cpp
>
> Modified: libcxxabi/trunk/src/cxa_demangle.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/cxa_demangle.cpp?rev=309349&r1=309348&r2=309349&view=diff
>
> ==
> --- libcxxabi/trunk/src/cxa_demangle.cpp (original)
> +++ libcxxabi/trunk/src/cxa_demangle.cpp Thu Jul 27 18:35:14 2017
> @@ -896,6 +896,7 @@ public:
>  case SpecialSubKind::iostream:
>return StringView("basic_iostream");
>  }
> +return StringView();
>}
>
>void printLeft(OutputStream &S) const override {
> @@ -944,6 +945,7 @@ public:
>  case SpecialSubKind::iostream:
>return StringView("iostream");
>  }
> +return StringView();
>}
>
>void printLeft(OutputStream &S) const override {
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r309496 - Improve readability of CXX method overrides list

2017-07-31 Thread David Blaikie via cfe-commits
Test coverage?

On Sun, Jul 30, 2017 at 5:52 AM Lenar Safin via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: lll
> Date: Sat Jul 29 13:42:58 2017
> New Revision: 309496
>
> URL: http://llvm.org/viewvc/llvm-project?rev=309496&view=rev
> Log:
> Improve readability of CXX method overrides list
>
> Summary:
> Separate CXX method overrides list entries with commas.
>
> Reviewers: lhames
>
> Reviewed By: lhames
>
> Subscribers: llvm-commits
>
> Differential Revision: https://reviews.llvm.org/D35800
>
>
> Modified:
> cfe/trunk/lib/AST/ASTDumper.cpp
>
> Modified: cfe/trunk/lib/AST/ASTDumper.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTDumper.cpp?rev=309496&r1=309495&r2=309496&view=diff
>
> ==
> --- cfe/trunk/lib/AST/ASTDumper.cpp (original)
> +++ cfe/trunk/lib/AST/ASTDumper.cpp Sat Jul 29 13:42:58 2017
> @@ -1184,7 +1184,7 @@ void ASTDumper::VisitFunctionDecl(const
>   I != E; ++I)
>dumpCXXCtorInitializer(*I);
>
> -  if (const CXXMethodDecl *MD = dyn_cast(D))
> +  if (const CXXMethodDecl *MD = dyn_cast(D)) {
>  if (MD->size_overridden_methods() != 0) {
>auto dumpOverride =
>  [=](const CXXMethodDecl *D) {
> @@ -1199,11 +1199,14 @@ void ASTDumper::VisitFunctionDecl(const
>  dumpOverride(*FirstOverrideItr);
>  for (const auto *Override :
> llvm::make_range(FirstOverrideItr + 1,
> -MD->end_overridden_methods()))
> +MD->end_overridden_methods())) {
> +  OS << ", ";
>dumpOverride(Override);
> +}
>  OS << " ]";
>});
>  }
> +  }
>
>if (D->doesThisDeclarationHaveABody())
>  dumpStmt(D->getBody());
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D35783: Ignore shadowing for declarations coming from within macros.

2017-07-31 Thread David Blaikie via cfe-commits
On Tue, Jul 25, 2017 at 1:19 AM Roman Lebedev via Phabricator via
cfe-commits  wrote:

> lebedev.ri added a comment.
>
> How does this relate to the gcc behavior?
> I suspect not everyone would want to have this relaxed `-Wshadow` mode.
>

Generally I think the goal hasn't been to allow a clang user to keep their
code GCC warning clean - if a warning has too many false positives, it
can/will be changed in clang, even if it means it misses cases GCC will
flag. (for example -Wreturn-type, which pops up a lot in the LLVM codebase
when it fires on code that's probably unreachable that Clang is nice enough
to assume won't be reached (code after a fully covered switch over enum,
where each case returns))

Though it's not unheard of to bisect the diagnostic space to provide these
variations if suitable - but I wouldn't suggest doing so 'just' for
compatibility with GCC.


> Perhaps it could be hidden under some new flag, which is not going to be
> automatically enabled by `-Weverything`.
>

Nothing is ever not going to be automatically enabled by -Weverything (the
intent is that it's really, always, everything). Or perhaps you meant
-Wall? (which isn't everything & that ship's already sailed, so usually
more nuanced choices are made about what goes in there, etc)


> Like, `-Wshadow-in-macros` which does nothing compared to `-Wshadow`, and
> then `-Wno-shadow-in-macros` which enables this relaxed mode?
>
>
> https://reviews.llvm.org/D35783
>
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D34796: upporting -f(no)-reorder-functions flag, clang side change

2017-07-31 Thread Taewook Oh via Phabricator via cfe-commits
twoh updated this revision to Diff 108967.
twoh added a comment.

Update documentation. Please let me know if I need to update other documents as 
well. Thanks!


https://reviews.llvm.org/D34796

Files:
  docs/ClangCommandLineReference.rst
  include/clang/Driver/Options.td
  include/clang/Frontend/CodeGenOptions.def
  lib/CodeGen/BackendUtil.cpp
  lib/Driver/ToolChains/Clang.cpp
  lib/Frontend/CompilerInvocation.cpp
  test/CodeGen/Inputs/freorder-functions.prof
  test/CodeGen/freorder-functions.c
  test/Driver/function-sections.c

Index: test/Driver/function-sections.c
===
--- test/Driver/function-sections.c
+++ test/Driver/function-sections.c
@@ -6,6 +6,8 @@
 // CHECK-NODS-NOT: -fdata-sections
 // CHECK-US-NOT: -fno-unique-section-names
 // CHECK-NOUS: -fno-unique-section-names
+// CHECK-RF-NOT: -fno-reorder-functions
+// CHECK-NORF: -fno-reorder-functions
 
 // RUN: %clang -no-canonical-prefixes %s -### -fsyntax-only 2>&1   \
 // RUN: -target i386-unknown-linux \
@@ -72,3 +74,13 @@
 // RUN: -target i386-unknown-linux \
 // RUN: -fno-unique-section-names \
 // RUN:   | FileCheck --check-prefix=CHECK-NOUS %s
+
+// RUN: %clang -no-canonical-prefixes %s -### -fsyntax-only 2>&1\
+// RUN: -target i386-unknown-linux \
+// RUN: -freorder-functions \
+// RUN:   | FileCheck --check-prefix=CHECK-RF %s
+
+// RUN: %clang -no-canonical-prefixes %s -### -fsyntax-only 2>&1\
+// RUN: -target i386-unknown-linux \
+// RUN: -fno-reorder-functions \
+// RUN:   | FileCheck --check-prefix=CHECK-NORF %s
Index: test/CodeGen/freorder-functions.c
===
--- /dev/null
+++ test/CodeGen/freorder-functions.c
@@ -0,0 +1,22 @@
+// REQUIRES: x86-registered-target
+
+// RUN: %clang_cc1 -triple x86_64-pc-linux -S -O3 -ffunction-sections -fprofile-sample-use=%S/Inputs/freorder-functions.prof -o - < %s | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-pc-linux -S -O3 -ffunction-sections -fprofile-sample-use=%S/Inputs/freorder-functions.prof -fno-reorder-functions -o - < %s | FileCheck --check-prefix=CHECK-NOPREFIX %s
+
+// opt tool option precedes driver option.
+// RUN: %clang_cc1 -triple x86_64-pc-linux -S -O3 -ffunction-sections -fprofile-sample-use=%S/Inputs/freorder-functions.prof -fno-reorder-functions -mllvm -profile-guided-section-prefix=true -o - < %s | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-pc-linux -S -O3 -ffunction-sections -fprofile-sample-use=%S/Inputs/freorder-functions.prof -freorder-functions -mllvm -profile-guided-section-prefix=false -o - < %s | FileCheck --check-prefix=CHECK-NOPREFIX %s
+
+void hot_func() {
+  return;
+}
+
+void cold_func() {
+  hot_func();
+  return;
+}
+
+// CHECK: .section .text.hot.hot_func,"ax",@progbits
+// CHECK: .section .text.unlikely.cold_func,"ax",@progbits
+// CHECK-NOPREFIX: .section .text.hot_func,"ax",@progbits
+// CHECK-NOPREFIX: .section .text.cold_func,"ax",@progbits
Index: test/CodeGen/Inputs/freorder-functions.prof
===
--- /dev/null
+++ test/CodeGen/Inputs/freorder-functions.prof
@@ -0,0 +1,5 @@
+hot_func:1000:0
+ 1: 0
+cold_func:0:0
+ 1: 1
+ 2: 1
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -647,6 +647,8 @@
OPT_fno_data_sections, false);
   Opts.UniqueSectionNames = Args.hasFlag(OPT_funique_section_names,
  OPT_fno_unique_section_names, true);
+  Opts.ReorderFunctions =
+  Args.hasFlag(OPT_freorder_functions, OPT_fno_reorder_functions, true);
 
   Opts.MergeFunctions = Args.hasArg(OPT_fmerge_functions);
 
Index: lib/Driver/ToolChains/Clang.cpp
===
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/ToolChains/Clang.cpp
@@ -2899,6 +2899,10 @@
 options::OPT_fno_unique_section_names, true))
 CmdArgs.push_back("-fno-unique-section-names");
 
+  if (!Args.hasFlag(options::OPT_freorder_functions,
+options::OPT_fno_reorder_functions, true))
+CmdArgs.push_back("-fno-reorder-functions");
+
   Args.AddAllArgs(CmdArgs, options::OPT_finstrument_functions);
 
   addPGOAndCoverageFlags(C, D, Output, Args, CmdArgs);
Index: lib/CodeGen/BackendUtil.cpp
===
--- lib/CodeGen/BackendUtil.cpp
+++ lib/CodeGen/BackendUtil.cpp
@@ -429,6 +429,7 @@
   Options.FunctionSections = CodeGenOpts.FunctionSections;
   Options.DataSections = CodeGenOpts.DataSections;
   Options.UniqueSectionNames = CodeGenOpts.UniqueSectionNames;
+  Options.ReorderFunctions = CodeGenOpts.ReorderFunctions;
   Options.EmulatedTLS = CodeGenOpts.EmulatedTLS;
   Options.DebuggerTuning = CodeGenOpts.getDe

[PATCH] D35449: [X86] Implement __builtin_cpu_is

2017-07-31 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added a comment.

@erichkeane are you ok with this code for now? I think validateCPUIs gives you 
what you need at least for Sema support for target attribute. You'll probably 
need to refactor the CG code to make your ifunc resolver. But I think you need 
to do that for the existing feature code that's similar anyway. And from our 
side conversation it sounds like you're not ready for that yet.


https://reviews.llvm.org/D35449



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


[PATCH] D32842: Specify which sanitizers are covered by a sanitizer blacklist

2017-07-31 Thread Han Shen via Phabricator via cfe-commits
shenhan added a comment.

Ping? Can we make a decision on this? 
I've this simple one D35849: [UBSan] Provide default blacklist filename for 
UBSan  which, depending on this, shall be 
discarded or move forward.
If this CL stalls, I'll seek to proceed with https://reviews.llvm.org/D35849. 
Any how, https://reviews.llvm.org/D35849 gets wiped out whence this CL 
(https://reviews.llvm.org/D32842) is submitted.


https://reviews.llvm.org/D32842



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


[PATCH] D35449: [X86] Implement __builtin_cpu_is

2017-07-31 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

In https://reviews.llvm.org/D35449#826381, @craig.topper wrote:

> @erichkeane are you ok with this code for now? I think validateCPUIs gives 
> you what you need at least for Sema support for target attribute. You'll 
> probably need to refactor the CG code to make your ifunc resolver. But I 
> think you need to do that for the existing feature code that's similar 
> anyway. And from our side conversation it sounds like you're not ready for 
> that yet.


Thats correct.  I think this is right based on what I currently understand, 
though you/I will likely need to make some additional modifications to support 
my features.


https://reviews.llvm.org/D35449



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


Re: [PATCH] D35746: Make new PM honor -fdebug-info-for-profiling (clang side)

2017-07-31 Thread David Blaikie via cfe-commits
On Thu, Jul 27, 2017 at 8:30 AM Dehao Chen via Phabricator via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> danielcdh marked an inline comment as done.
> danielcdh added a comment.
>
> Thanks for the review!
>
> In https://reviews.llvm.org/D35746#822498, @chandlerc wrote:
>
> > LGTM with a tiny tweak below.
> >
> > Would be good to add a test that this flag is being honored, either in
> this patch or in a follow-up.
>
>
> I'll add the test in a follow-up patch. Could you help suggest how to add
> a test for this? Shall I just invoke "clang -cc1
> -fexperimental-new-pass-manager" and check if discriminator is generated?
> That seems an integration test.
>

Yeah, things that interact between Clang and LLVM that aren't part of IR
basically slip through the cracks of the nice separation of testing here.
Either they go untested, or are tested in a more 'integration' like test -
though trying to find the minimal thing to examine that's not testing all
the features, etc.

If there's a clang argument that dumps the pass sequence? Or some other
'earlier' observable property like that? (how's the
-fexperimental-new-pass-manager flag tested, for example? maybe it isn't)


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


[PATCH] D36074: [x86][inline-asm]Allow a pack of Control Debug to be properly picked

2017-07-31 Thread Reid Kleckner via Phabricator via cfe-commits
rnk accepted this revision.
rnk added a comment.
This revision is now accepted and ready to land.

lgtm


Repository:
  rL LLVM

https://reviews.llvm.org/D36074



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


[PATCH] D36098: [AArch64] Don't define __LP64__ when targeting Windows

2017-07-31 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo created this revision.
Herald added subscribers: kristof.beyls, javed.absar, rengolin, aemerson.

Windows/ARM64 is a LLP64 environment, so don't set this default define.


https://reviews.llvm.org/D36098

Files:
  lib/Basic/Targets/AArch64.cpp
  test/Preprocessor/init.c

Index: test/Preprocessor/init.c
===
--- test/Preprocessor/init.c
+++ test/Preprocessor/init.c
@@ -1424,6 +1424,167 @@
 // AARCH64-DARWIN: #define __WINT_WIDTH__ 32
 // AARCH64-DARWIN: #define __aarch64__ 1
 
+// RUN: %clang_cc1 -E -dM -ffreestanding -triple=aarch64-windows-msvc < /dev/null | FileCheck -match-full-lines -check-prefix AARCH64-MSVC %s
+//
+// AARCH64-MSVC: #define _INTEGRAL_MAX_BITS 64
+// AARCH64-MSVC-NOT: #define _LP64 1
+// AARCH64-MSVC: #define _M_ARM64 1
+// AARCH64-MSVC: #define _WIN32 1
+// AARCH64-MSVC: #define _WIN64 1
+// AARCH64-MSVC: #define __AARCH64EL__ 1
+// AARCH64-MSVC: #define __ARM_64BIT_STATE 1
+// AARCH64-MSVC: #define __ARM_ACLE 200
+// AARCH64-MSVC: #define __ARM_ALIGN_MAX_STACK_PWR 4
+// AARCH64-MSVC: #define __ARM_ARCH 8
+// AARCH64-MSVC: #define __ARM_ARCH_ISA_A64 1
+// AARCH64-MSVC: #define __ARM_ARCH_PROFILE 'A'
+// AARCH64-MSVC: #define __ARM_FEATURE_CLZ 1
+// AARCH64-MSVC: #define __ARM_FEATURE_DIRECTED_ROUNDING 1
+// AARCH64-MSVC: #define __ARM_FEATURE_DIV 1
+// AARCH64-MSVC: #define __ARM_FEATURE_FMA 1
+// AARCH64-MSVC: #define __ARM_FEATURE_IDIV 1
+// AARCH64-MSVC: #define __ARM_FEATURE_LDREX 0xF
+// AARCH64-MSVC: #define __ARM_FEATURE_NUMERIC_MAXMIN 1
+// AARCH64-MSVC: #define __ARM_FEATURE_UNALIGNED 1
+// AARCH64-MSVC: #define __ARM_FP 0xE
+// AARCH64-MSVC: #define __ARM_FP16_ARGS 1
+// AARCH64-MSVC: #define __ARM_FP16_FORMAT_IEEE 1
+// AARCH64-MSVC: #define __ARM_PCS_AAPCS64 1
+// AARCH64-MSVC: #define __ARM_SIZEOF_MINIMAL_ENUM 4
+// AARCH64-MSVC: #define __ARM_SIZEOF_WCHAR_T 4
+// AARCH64-MSVC: #define __BIGGEST_ALIGNMENT__ 16
+// AARCH64-MSVC: #define __BYTE_ORDER__ __ORDER_LITTLE_ENDIAN__
+// AARCH64-MSVC: #define __CHAR16_TYPE__ unsigned short
+// AARCH64-MSVC: #define __CHAR32_TYPE__ unsigned int
+// AARCH64-MSVC: #define __CHAR_BIT__ 8
+// AARCH64-MSVC: #define __CONSTANT_CFSTRINGS__ 1
+// AARCH64-MSVC: #define __DBL_DECIMAL_DIG__ 17
+// AARCH64-MSVC: #define __DBL_DENORM_MIN__ 4.9406564584124654e-324
+// AARCH64-MSVC: #define __DBL_DIG__ 15
+// AARCH64-MSVC: #define __DBL_EPSILON__ 2.2204460492503131e-16
+// AARCH64-MSVC: #define __DBL_HAS_DENORM__ 1
+// AARCH64-MSVC: #define __DBL_HAS_INFINITY__ 1
+// AARCH64-MSVC: #define __DBL_HAS_QUIET_NAN__ 1
+// AARCH64-MSVC: #define __DBL_MANT_DIG__ 53
+// AARCH64-MSVC: #define __DBL_MAX_10_EXP__ 308
+// AARCH64-MSVC: #define __DBL_MAX_EXP__ 1024
+// AARCH64-MSVC: #define __DBL_MAX__ 1.7976931348623157e+308
+// AARCH64-MSVC: #define __DBL_MIN_10_EXP__ (-307)
+// AARCH64-MSVC: #define __DBL_MIN_EXP__ (-1021)
+// AARCH64-MSVC: #define __DBL_MIN__ 2.2250738585072014e-308
+// AARCH64-MSVC: #define __DECIMAL_DIG__ __LDBL_DECIMAL_DIG__
+// AARCH64-MSVC: #define __FINITE_MATH_ONLY__ 0
+// AARCH64-MSVC: #define __FLT_DECIMAL_DIG__ 9
+// AARCH64-MSVC: #define __FLT_DENORM_MIN__ 1.40129846e-45F
+// AARCH64-MSVC: #define __FLT_DIG__ 6
+// AARCH64-MSVC: #define __FLT_EPSILON__ 1.19209290e-7F
+// AARCH64-MSVC: #define __FLT_EVAL_METHOD__ 0
+// AARCH64-MSVC: #define __FLT_HAS_DENORM__ 1
+// AARCH64-MSVC: #define __FLT_HAS_INFINITY__ 1
+// AARCH64-MSVC: #define __FLT_HAS_QUIET_NAN__ 1
+// AARCH64-MSVC: #define __FLT_MANT_DIG__ 24
+// AARCH64-MSVC: #define __FLT_MAX_10_EXP__ 38
+// AARCH64-MSVC: #define __FLT_MAX_EXP__ 128
+// AARCH64-MSVC: #define __FLT_MAX__ 3.40282347e+38F
+// AARCH64-MSVC: #define __FLT_MIN_10_EXP__ (-37)
+// AARCH64-MSVC: #define __FLT_MIN_EXP__ (-125)
+// AARCH64-MSVC: #define __FLT_MIN__ 1.17549435e-38F
+// AARCH64-MSVC: #define __FLT_RADIX__ 2
+// AARCH64-MSVC: #define __INT_MAX__ 2147483647
+// AARCH64-MSVC: #define __LDBL_DECIMAL_DIG__ 17
+// AARCH64-MSVC: #define __LDBL_DENORM_MIN__ 4.9406564584124654e-324L
+// AARCH64-MSVC: #define __LDBL_DIG__ 15
+// AARCH64-MSVC: #define __LDBL_EPSILON__ 2.2204460492503131e-16L
+// AARCH64-MSVC: #define __LDBL_HAS_DENORM__ 1
+// AARCH64-MSVC: #define __LDBL_HAS_INFINITY__ 1
+// AARCH64-MSVC: #define __LDBL_HAS_QUIET_NAN__ 1
+// AARCH64-MSVC: #define __LDBL_MANT_DIG__ 53
+// AARCH64-MSVC: #define __LDBL_MAX_10_EXP__ 308
+// AARCH64-MSVC: #define __LDBL_MAX_EXP__ 1024
+// AARCH64-MSVC: #define __LDBL_MAX__ 1.7976931348623157e+308L
+// AARCH64-MSVC: #define __LDBL_MIN_10_EXP__ (-307)
+// AARCH64-MSVC: #define __LDBL_MIN_EXP__ (-1021)
+// AARCH64-MSVC: #define __LDBL_MIN__ 2.2250738585072014e-308L
+// AARCH64-MSVC: #define __LITTLE_ENDIAN__ 1
+// AARCH64-MSVC: #define __LONG_LONG_MAX__ 9223372036854775807LL
+// AARCH64-MSVC: #define __LONG_MAX__ 2147483647L
+// AARCH64-MSVC-NOT: #define __LP64__ 1
+// AARCH64-MSVC: #define __NO_INLINE__ 1
+// AARCH64-MSVC: #define __OBJC_BOOL_IS_BOOL 0
+// AARCH64-MSVC: #define __ORDER_BIG_ENDI

[PATCH] D36099: [test] Fix mistagged CHECK-NOT-lines for AARCH64-DARWIN in Preprocessor/init.c

2017-07-31 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo created this revision.
Herald added subscribers: kristof.beyls, rengolin, aemerson.

https://reviews.llvm.org/D36099

Files:
  test/Preprocessor/init.c


Index: test/Preprocessor/init.c
===
--- test/Preprocessor/init.c
+++ test/Preprocessor/init.c
@@ -1236,13 +1236,13 @@
 // RUN: %clang_cc1 -E -dM -ffreestanding -triple=aarch64-apple-ios7.0 < 
/dev/null | FileCheck -match-full-lines -check-prefix AARCH64-DARWIN %s
 //
 // AARCH64-DARWIN: #define _LP64 1
-// AARCH64-NOT: #define __AARCH64EB__ 1
+// AARCH64-DARWIN-NOT: #define __AARCH64EB__ 1
 // AARCH64-DARWIN: #define __AARCH64EL__ 1
-// AARCH64-NOT: #define __AARCH_BIG_ENDIAN 1
+// AARCH64-DARWIN-NOT: #define __AARCH_BIG_ENDIAN 1
 // AARCH64-DARWIN: #define __ARM_64BIT_STATE 1
 // AARCH64-DARWIN: #define __ARM_ARCH 8
 // AARCH64-DARWIN: #define __ARM_ARCH_ISA_A64 1
-// AARCH64-NOT: #define __ARM_BIG_ENDIAN 1
+// AARCH64-DARWIN-NOT: #define __ARM_BIG_ENDIAN 1
 // AARCH64-DARWIN: #define __BIGGEST_ALIGNMENT__ 8
 // AARCH64-DARWIN: #define __BYTE_ORDER__ __ORDER_LITTLE_ENDIAN__
 // AARCH64-DARWIN: #define __CHAR16_TYPE__ unsigned short


Index: test/Preprocessor/init.c
===
--- test/Preprocessor/init.c
+++ test/Preprocessor/init.c
@@ -1236,13 +1236,13 @@
 // RUN: %clang_cc1 -E -dM -ffreestanding -triple=aarch64-apple-ios7.0 < /dev/null | FileCheck -match-full-lines -check-prefix AARCH64-DARWIN %s
 //
 // AARCH64-DARWIN: #define _LP64 1
-// AARCH64-NOT: #define __AARCH64EB__ 1
+// AARCH64-DARWIN-NOT: #define __AARCH64EB__ 1
 // AARCH64-DARWIN: #define __AARCH64EL__ 1
-// AARCH64-NOT: #define __AARCH_BIG_ENDIAN 1
+// AARCH64-DARWIN-NOT: #define __AARCH_BIG_ENDIAN 1
 // AARCH64-DARWIN: #define __ARM_64BIT_STATE 1
 // AARCH64-DARWIN: #define __ARM_ARCH 8
 // AARCH64-DARWIN: #define __ARM_ARCH_ISA_A64 1
-// AARCH64-NOT: #define __ARM_BIG_ENDIAN 1
+// AARCH64-DARWIN-NOT: #define __ARM_BIG_ENDIAN 1
 // AARCH64-DARWIN: #define __BIGGEST_ALIGNMENT__ 8
 // AARCH64-DARWIN: #define __BYTE_ORDER__ __ORDER_LITTLE_ENDIAN__
 // AARCH64-DARWIN: #define __CHAR16_TYPE__ unsigned short
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r309607 - [Driver] Allow users to silence the warning that is issued when the

2017-07-31 Thread Akira Hatanaka via cfe-commits
Author: ahatanak
Date: Mon Jul 31 12:16:40 2017
New Revision: 309607

URL: http://llvm.org/viewvc/llvm-project?rev=309607&view=rev
Log:
[Driver] Allow users to silence the warning that is issued when the
deployment target is earlier than iOS 11 and the target is 32-bit.

This is a follow-up to r306922.

rdar://problem/32230613

Modified:
cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
cfe/trunk/include/clang/Basic/DiagnosticGroups.td
cfe/trunk/lib/Driver/ToolChains/Darwin.cpp
cfe/trunk/test/Driver/darwin-version.c

Modified: cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td?rev=309607&r1=309606&r2=309607&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td Mon Jul 31 12:16:40 
2017
@@ -138,9 +138,10 @@ def err_drv_cc_print_options_failure : E
 def err_drv_lto_without_lld : Error<"LTO requires -fuse-ld=lld">;
 def err_drv_preamble_format : Error<
 "incorrect format for -preamble-bytes=N,END">;
-def err_invalid_ios_deployment_target : Error<
+def warn_invalid_ios_deployment_target : Warning<
   "invalid iOS deployment version '%0', iOS 10 is the maximum deployment "
-  "target for 32-bit targets">;
+  "target for 32-bit targets">, InGroup,
+  DefaultError;
 def err_drv_conflicting_deployment_targets : Error<
   "conflicting deployment targets, both '%0' and '%1' are present in 
environment">;
 def err_arc_unsupported_on_runtime : Error<

Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticGroups.td?rev=309607&r1=309606&r2=309607&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticGroups.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td Mon Jul 31 12:16:40 2017
@@ -153,6 +153,9 @@ def GNUFlexibleArrayUnionMember : DiagGr
 def GNUFoldingConstant : DiagGroup<"gnu-folding-constant">;
 def FormatExtraArgs : DiagGroup<"format-extra-args">;
 def FormatZeroLength : DiagGroup<"format-zero-length">;
+
+def InvalidIOSDeploymentTarget : DiagGroup<"invalid-ios-deployment-target">;
+
 def CXX1zCompatMangling : DiagGroup<"c++1z-compat-mangling">;
 // Name of this warning in GCC.
 def NoexceptType : DiagGroup<"noexcept-type", [CXX1zCompatMangling]>;

Modified: cfe/trunk/lib/Driver/ToolChains/Darwin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Darwin.cpp?rev=309607&r1=309606&r2=309607&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Darwin.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Darwin.cpp Mon Jul 31 12:16:40 2017
@@ -1179,7 +1179,7 @@ void Darwin::AddDeploymentTarget(Derived
   Driver::GetReleaseVersion(iOSVersion->getValue(), Major, Minor, Micro,
 HadExtra) &&
   Major > 10)
-getDriver().Diag(diag::err_invalid_ios_deployment_target)
+getDriver().Diag(diag::warn_invalid_ios_deployment_target)
 << iOSVersion->getAsString(Args);
 
   // Add a macro to differentiate between m(iphone|tv|watch)os-version-min=X.Y 
and
@@ -1228,7 +1228,7 @@ void Darwin::AddDeploymentTarget(Derived
 Driver::GetReleaseVersion(iOSTarget.c_str(), Major, Minor, Micro,
   HadExtra) &&
 Major > 10)
-  getDriver().Diag(diag::err_invalid_ios_deployment_target)
+  getDriver().Diag(diag::warn_invalid_ios_deployment_target)
   << std::string("IPHONEOS_DEPLOYMENT_TARGET=") + iOSTarget;
 
 // If there is no command-line argument to specify the Target version and
@@ -1298,6 +1298,15 @@ void Darwin::AddDeploymentTarget(Derived
   break;
 case llvm::Triple::IOS:
   getTriple().getiOSVersion(Major, Minor, Micro);
+
+  // iOS 10 is the maximum deployment target for 32-bit targets. If the
+  // inferred deployment target is iOS 11 or later, set it to 10.99.
+  if (getTriple().isArch32Bit() && Major >= 11) {
+Major = 10;
+Minor = 99;
+Micro = 99;
+  }
+
   OSTarget = &iOSTarget;
   break;
 case llvm::Triple::TvOS:
@@ -1393,13 +1402,6 @@ void Darwin::AddDeploymentTarget(Derived
 HadExtra || Major >= 100 || Minor >= 100 || Micro >= 100)
   getDriver().Diag(diag::err_drv_invalid_version_number)
   << iOSVersion->getAsString(Args);
-// iOS 10 is the maximum deployment target for 32-bit targets. If the
-// inferred deployment target is iOS 11 or later, set it to 10.99.
-if (getTriple().isArch32Bit() && Major >= 11) {
-  Major = 10;
-  Minor = 99;
-  Micro = 99;
-}
   } else if (Platform == TvOS) {
 

[PATCH] D36098: [AArch64] Don't define __LP64__ when targeting Windows

2017-07-31 Thread Mandeep Singh Grang via Phabricator via cfe-commits
mgrang accepted this revision.
mgrang added a comment.
This revision is now accepted and ready to land.

LGTM.


https://reviews.llvm.org/D36098



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


[PATCH] D36100: [Attr] Make TargetWindows and TargetMicrosoftCXXABI match on aarch64 as well

2017-07-31 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo created this revision.
Herald added subscribers: kristof.beyls, rengolin, aemerson.

https://reviews.llvm.org/D36100

Files:
  include/clang/Basic/Attr.td
  test/Sema/dllimport.c


Index: test/Sema/dllimport.c
===
--- test/Sema/dllimport.c
+++ test/Sema/dllimport.c
@@ -2,6 +2,7 @@
 // RUN: %clang_cc1 -triple x86_64-win32   -fsyntax-only -fms-extensions 
-verify -std=c11 -DMS %s
 // RUN: %clang_cc1 -triple i686-mingw32   -fsyntax-only -fms-extensions 
-verify -std=c11 -DGNU %s
 // RUN: %clang_cc1 -triple x86_64-mingw32 -fsyntax-only -fms-extensions 
-verify -std=c99 -DGNU %s
+// RUN: %clang_cc1 -triple aarch64-win32  -fsyntax-only -fms-extensions 
-verify -std=c99 -DMS %s
 
 // Invalid usage.
 __declspec(dllimport) typedef int typedef1;
Index: include/clang/Basic/Attr.td
===
--- include/clang/Basic/Attr.td
+++ include/clang/Basic/Attr.td
@@ -268,10 +268,10 @@
 def TargetMSP430 : TargetArch<["msp430"]>;
 def TargetX86 : TargetArch<["x86"]>;
 def TargetAnyX86 : TargetArch<["x86", "x86_64"]>;
-def TargetWindows : TargetArch<["x86", "x86_64", "arm", "thumb"]> {
+def TargetWindows : TargetArch<["x86", "x86_64", "arm", "thumb", "aarch64"]> {
   let OSes = ["Win32"];
 }
-def TargetMicrosoftCXXABI : TargetArch<["x86", "x86_64", "arm", "thumb"]> {
+def TargetMicrosoftCXXABI : TargetArch<["x86", "x86_64", "arm", "thumb", 
"aarch64"]> {
   let CXXABIs = ["Microsoft"];
 }
 


Index: test/Sema/dllimport.c
===
--- test/Sema/dllimport.c
+++ test/Sema/dllimport.c
@@ -2,6 +2,7 @@
 // RUN: %clang_cc1 -triple x86_64-win32   -fsyntax-only -fms-extensions -verify -std=c11 -DMS %s
 // RUN: %clang_cc1 -triple i686-mingw32   -fsyntax-only -fms-extensions -verify -std=c11 -DGNU %s
 // RUN: %clang_cc1 -triple x86_64-mingw32 -fsyntax-only -fms-extensions -verify -std=c99 -DGNU %s
+// RUN: %clang_cc1 -triple aarch64-win32  -fsyntax-only -fms-extensions -verify -std=c99 -DMS %s
 
 // Invalid usage.
 __declspec(dllimport) typedef int typedef1;
Index: include/clang/Basic/Attr.td
===
--- include/clang/Basic/Attr.td
+++ include/clang/Basic/Attr.td
@@ -268,10 +268,10 @@
 def TargetMSP430 : TargetArch<["msp430"]>;
 def TargetX86 : TargetArch<["x86"]>;
 def TargetAnyX86 : TargetArch<["x86", "x86_64"]>;
-def TargetWindows : TargetArch<["x86", "x86_64", "arm", "thumb"]> {
+def TargetWindows : TargetArch<["x86", "x86_64", "arm", "thumb", "aarch64"]> {
   let OSes = ["Win32"];
 }
-def TargetMicrosoftCXXABI : TargetArch<["x86", "x86_64", "arm", "thumb"]> {
+def TargetMicrosoftCXXABI : TargetArch<["x86", "x86_64", "arm", "thumb", "aarch64"]> {
   let CXXABIs = ["Microsoft"];
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D36101: Fix usage of right shift operator in fold expressions

2017-07-31 Thread Blitz Rakete via Phabricator via cfe-commits
Rakete created this revision.

The right shift operator was not seen as a valid operator in a fold expression, 
which is PR32563.


https://reviews.llvm.org/D36101

Files:
  lib/Parse/ParseExpr.cpp
  test/CXX/expr/expr.prim/expr.prim.fold/p2.cpp


Index: test/CXX/expr/expr.prim/expr.prim.fold/p2.cpp
===
--- test/CXX/expr/expr.prim/expr.prim.fold/p2.cpp
+++ test/CXX/expr/expr.prim/expr.prim.fold/p2.cpp
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -std=c++1z -verify %s
+
+// PR32563
+template
+constexpr int right_shift(int value, Ts... args) {
+  return (value >> ... >> args); // expected-no-diagnostics
+}
+
+void test_folds() {
+  static_assert(right_shift(10, 2) == 2);
+}
+
Index: lib/Parse/ParseExpr.cpp
===
--- lib/Parse/ParseExpr.cpp
+++ lib/Parse/ParseExpr.cpp
@@ -270,7 +270,7 @@
   return Level > prec::Unknown && Level != prec::Conditional;
 }
 static bool isFoldOperator(tok::TokenKind Kind) {
-  return isFoldOperator(getBinOpPrecedence(Kind, false, true));
+  return isFoldOperator(getBinOpPrecedence(Kind, true, true));
 }
 
 /// \brief Parse a binary expression that starts with \p LHS and has a


Index: test/CXX/expr/expr.prim/expr.prim.fold/p2.cpp
===
--- test/CXX/expr/expr.prim/expr.prim.fold/p2.cpp
+++ test/CXX/expr/expr.prim/expr.prim.fold/p2.cpp
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -std=c++1z -verify %s
+
+// PR32563
+template
+constexpr int right_shift(int value, Ts... args) {
+  return (value >> ... >> args); // expected-no-diagnostics
+}
+
+void test_folds() {
+  static_assert(right_shift(10, 2) == 2);
+}
+
Index: lib/Parse/ParseExpr.cpp
===
--- lib/Parse/ParseExpr.cpp
+++ lib/Parse/ParseExpr.cpp
@@ -270,7 +270,7 @@
   return Level > prec::Unknown && Level != prec::Conditional;
 }
 static bool isFoldOperator(tok::TokenKind Kind) {
-  return isFoldOperator(getBinOpPrecedence(Kind, false, true));
+  return isFoldOperator(getBinOpPrecedence(Kind, true, true));
 }
 
 /// \brief Parse a binary expression that starts with \p LHS and has a
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r309007 - [ubsan] Null-check pointers in -fsanitize=vptr (PR33881)

2017-07-31 Thread Nico Weber via cfe-commits
On Mon, Jul 31, 2017 at 1:18 PM, Vedant Kumar  wrote:

> The bot should start working again with -fsanitize=vptr,null.
>
> The warning can be improved. If we find -fno-sanitize=null in the argument
> list, we might say:
> implicitly disabling vptr sanitizer because "-fno-sanitize=null" was
> specified
>
> Otherwise we might say:
> implicitly disabling vptr sanitizer because null checking wasn't enabled,
> try specifying -fsanitize=null or -fsanitize=undefined
>

Hm, I still don't understand. I enable vptr ubsan checking, and I don't
want null checking (because chromium happens to be vptr clean and we want
to keep it that way, but we're not nullptr clean due to for example v8's
SMIs). How do I get yesterday's behavior back?


>
> I'll send out a patch for review.
>
> vedant
>
> > On Jul 31, 2017, at 9:37 AM, Hans Wennborg  wrote:
> >
> > /sub
> >
> > I believe Vedant asked for this to be merged to 5.0, so I'd like to
> > merge the resolution too.
> >
> > On Mon, Jul 31, 2017 at 8:51 AM, Nico Weber via cfe-commits
> >  wrote:
> >> Hi Vedant,
> >>
> >> after this change our ubsanvptr bot fails like so:
> >>
> >> clang-6.0: error: implicitly disabling vptr sanitizer because null
> checking
> >> wasn't enabled [-Werror,-Wauto-disable-vptr-sanitizer]
> >>
> >> The bot uses -fsanitize=vptr. I have no idea what this warning is
> supposed
> >> to tell me. Maybe it could be reworded, or maybe it shouldn't be
> emitted?
> >>
> >> Thanks,
> >> Nico
> >>
> >> On Tue, Jul 25, 2017 at 3:34 PM, Vedant Kumar via cfe-commits
> >>  wrote:
> >>>
> >>> Author: vedantk
> >>> Date: Tue Jul 25 12:34:23 2017
> >>> New Revision: 309007
> >>>
> >>> URL: http://llvm.org/viewvc/llvm-project?rev=309007&view=rev
> >>> Log:
> >>> [ubsan] Null-check pointers in -fsanitize=vptr (PR33881)
> >>>
> >>> The instrumentation generated by -fsanitize=vptr does not null check a
> >>> user pointer before loading from it. This causes crashes in the face of
> >>> UB member calls (this=nullptr), i.e it's causing user programs to crash
> >>> only after UBSan is turned on.
> >>>
> >>> The fix is to make run-time null checking a prerequisite for enabling
> >>> -fsanitize=vptr, and to then teach UBSan to reuse these run-time null
> >>> checks to make -fsanitize=vptr safe.
> >>>
> >>> Testing: check-clang, check-ubsan, a stage2 ubsan-enabled build
> >>>
> >>> Differential Revision: https://reviews.llvm.org/D35735
> >>>
> >>> https://bugs.llvm.org/show_bug.cgi?id=33881
> >>>
> >>> Modified:
> >>>cfe/trunk/docs/ReleaseNotes.rst
> >>>cfe/trunk/docs/UndefinedBehaviorSanitizer.rst
> >>>cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
> >>>cfe/trunk/include/clang/Basic/DiagnosticGroups.td
> >>>cfe/trunk/lib/CodeGen/CGExpr.cpp
> >>>cfe/trunk/lib/Driver/SanitizerArgs.cpp
> >>>cfe/trunk/test/CodeGenCXX/catch-undef-behavior.cpp
> >>>cfe/trunk/test/CodeGenCXX/ubsan-devirtualized-calls.cpp
> >>>cfe/trunk/test/CodeGenCXX/ubsan-type-checks.cpp
> >>>cfe/trunk/test/CodeGenCXX/ubsan-vtable-checks.cpp
> >>>cfe/trunk/test/Driver/fsanitize.c
> >>>cfe/trunk/test/Driver/rtti-options.cpp
> >>>
> >>> Modified: cfe/trunk/docs/ReleaseNotes.rst
> >>> URL:
> >>> http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/
> ReleaseNotes.rst?rev=309007&r1=309006&r2=309007&view=diff
> >>>
> >>> 
> ==
> >>> --- cfe/trunk/docs/ReleaseNotes.rst (original)
> >>> +++ cfe/trunk/docs/ReleaseNotes.rst Tue Jul 25 12:34:23 2017
> >>> @@ -155,7 +155,9 @@ Static Analyzer
> >>> Undefined Behavior Sanitizer (UBSan)
> >>> 
> >>>
> >>> -...
> >>> +The C++ dynamic type check now requires run-time null checking (i.e,
> >>> +`-fsanitize=vptr` cannot be used without `-fsanitize=null`). This
> change
> >>> does
> >>> +not impact users who rely on UBSan check groups (e.g
> >>> `-fsanitize=undefined`).
> >>>
> >>> Core Analysis Improvements
> >>> ==
> >>>
> >>> Modified: cfe/trunk/docs/UndefinedBehaviorSanitizer.rst
> >>> URL:
> >>> http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/
> UndefinedBehaviorSanitizer.rst?rev=309007&r1=309006&r2=309007&view=diff
> >>>
> >>> 
> ==
> >>> --- cfe/trunk/docs/UndefinedBehaviorSanitizer.rst (original)
> >>> +++ cfe/trunk/docs/UndefinedBehaviorSanitizer.rst Tue Jul 25 12:34:23
> 2017
> >>> @@ -130,11 +130,11 @@ Available checks are:
> >>>  it is often unintentional, so UBSan offers to catch it.
> >>>   -  ``-fsanitize=vla-bound``: A variable-length array whose bound
> >>>  does not evaluate to a positive value.
> >>> -  -  ``-fsanitize=vptr``: Use of an object whose vptr indicates that
> >>> - it is of the wrong dynamic type, or that its lifetime has not
> >>> - begun or has ended. Incompatible with ``-fno-rtti``. Link must
> >>> - be performed by ``clang++``, not ``clang``, to make sure
> >>> C++-sp

[PATCH] D36105: [AArch64] Ignore stdcall and similar on aarch64/windows

2017-07-31 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo created this revision.
Herald added subscribers: kristof.beyls, javed.absar, rengolin, aemerson.

This is similar to what's done on arm and x86_64, where these calling 
conventions are silently ignored, as in SVN r245076 
(https://reviews.llvm.org/D12034).


https://reviews.llvm.org/D36105

Files:
  lib/Basic/Targets/AArch64.cpp
  lib/Basic/Targets/AArch64.h
  test/Parser/arm-windows-calling-convention-handling.c


Index: test/Parser/arm-windows-calling-convention-handling.c
===
--- test/Parser/arm-windows-calling-convention-handling.c
+++ test/Parser/arm-windows-calling-convention-handling.c
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -triple thumbv7-windows -fms-compatibility -fsyntax-only 
-verify %s
+// RUN: %clang_cc1 -triple aarch64-windows -fms-compatibility -fsyntax-only 
-verify %s
 
 int __cdecl cdecl(int a, int b, int c, int d) { // expected-no-diagnostics
   return a + b + c + d;
Index: lib/Basic/Targets/AArch64.h
===
--- lib/Basic/Targets/AArch64.h
+++ lib/Basic/Targets/AArch64.h
@@ -105,6 +105,8 @@
 MacroBuilder &Builder) const override;
 
   BuiltinVaListKind getBuiltinVaListKind() const override;
+
+  CallingConvCheckResult checkCallingConvention(CallingConv CC) const override;
 };
 
 class LLVM_LIBRARY_VISIBILITY AArch64beTargetInfo : public AArch64TargetInfo {
Index: lib/Basic/Targets/AArch64.cpp
===
--- lib/Basic/Targets/AArch64.cpp
+++ lib/Basic/Targets/AArch64.cpp
@@ -458,6 +458,23 @@
   return TargetInfo::CharPtrBuiltinVaList;
 }
 
+TargetInfo::CallingConvCheckResult
+MicrosoftARM64TargetInfo::checkCallingConvention(CallingConv CC) const {
+  switch (CC) {
+  case CC_X86StdCall:
+  case CC_X86ThisCall:
+  case CC_X86FastCall:
+  case CC_X86VectorCall:
+return CCCR_Ignore;
+  case CC_C:
+  case CC_OpenCLKernel:
+  case CC_Win64:
+return CCCR_OK;
+  default:
+return CCCR_Warning;
+  }
+}
+
 DarwinAArch64TargetInfo::DarwinAArch64TargetInfo(const llvm::Triple &Triple,
  const TargetOptions &Opts)
 : DarwinTargetInfo(Triple, Opts) {


Index: test/Parser/arm-windows-calling-convention-handling.c
===
--- test/Parser/arm-windows-calling-convention-handling.c
+++ test/Parser/arm-windows-calling-convention-handling.c
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -triple thumbv7-windows -fms-compatibility -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple aarch64-windows -fms-compatibility -fsyntax-only -verify %s
 
 int __cdecl cdecl(int a, int b, int c, int d) { // expected-no-diagnostics
   return a + b + c + d;
Index: lib/Basic/Targets/AArch64.h
===
--- lib/Basic/Targets/AArch64.h
+++ lib/Basic/Targets/AArch64.h
@@ -105,6 +105,8 @@
 MacroBuilder &Builder) const override;
 
   BuiltinVaListKind getBuiltinVaListKind() const override;
+
+  CallingConvCheckResult checkCallingConvention(CallingConv CC) const override;
 };
 
 class LLVM_LIBRARY_VISIBILITY AArch64beTargetInfo : public AArch64TargetInfo {
Index: lib/Basic/Targets/AArch64.cpp
===
--- lib/Basic/Targets/AArch64.cpp
+++ lib/Basic/Targets/AArch64.cpp
@@ -458,6 +458,23 @@
   return TargetInfo::CharPtrBuiltinVaList;
 }
 
+TargetInfo::CallingConvCheckResult
+MicrosoftARM64TargetInfo::checkCallingConvention(CallingConv CC) const {
+  switch (CC) {
+  case CC_X86StdCall:
+  case CC_X86ThisCall:
+  case CC_X86FastCall:
+  case CC_X86VectorCall:
+return CCCR_Ignore;
+  case CC_C:
+  case CC_OpenCLKernel:
+  case CC_Win64:
+return CCCR_OK;
+  default:
+return CCCR_Warning;
+  }
+}
+
 DarwinAArch64TargetInfo::DarwinAArch64TargetInfo(const llvm::Triple &Triple,
  const TargetOptions &Opts)
 : DarwinTargetInfo(Triple, Opts) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D36100: [Attr] Make TargetWindows and TargetMicrosoftCXXABI match on aarch64 as well

2017-07-31 Thread Reid Kleckner via Phabricator via cfe-commits
rnk accepted this revision.
rnk added a comment.
This revision is now accepted and ready to land.

lgtm


https://reviews.llvm.org/D36100



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


[PATCH] D36098: [AArch64] Don't define __LP64__ when targeting Windows

2017-07-31 Thread Reid Kleckner via Phabricator via cfe-commits
rnk accepted this revision.
rnk added a comment.

lgtm


https://reviews.llvm.org/D36098



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


[PATCH] D36105: [AArch64] Ignore stdcall and similar on aarch64/windows

2017-07-31 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added inline comments.



Comment at: lib/Basic/Targets/AArch64.cpp:466-467
+  case CC_X86ThisCall:
+  case CC_X86FastCall:
+  case CC_X86VectorCall:
+return CCCR_Ignore;

Do they really ignore __fastcall and __vectorcall on arm64?

I assume __thiscall and __stdcall are all over various Win SDK headers, so they 
need to be ignored for compatibility, but I've never seen public documented 
APIs using __vectorcall. The STL ifdefs out those overloads, right?


https://reviews.llvm.org/D36105



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


[PATCH] D36099: [test] Fix mistagged CHECK-NOT-lines for AARCH64-DARWIN in Preprocessor/init.c

2017-07-31 Thread Reid Kleckner via Phabricator via cfe-commits
rnk accepted this revision.
rnk added a comment.
This revision is now accepted and ready to land.

lgtm


https://reviews.llvm.org/D36099



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


[PATCH] D36105: [AArch64] Ignore stdcall and similar on aarch64/windows

2017-07-31 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo added inline comments.



Comment at: lib/Basic/Targets/AArch64.cpp:466-467
+  case CC_X86ThisCall:
+  case CC_X86FastCall:
+  case CC_X86VectorCall:
+return CCCR_Ignore;

rnk wrote:
> Do they really ignore __fastcall and __vectorcall on arm64?
> 
> I assume __thiscall and __stdcall are all over various Win SDK headers, so 
> they need to be ignored for compatibility, but I've never seen public 
> documented APIs using __vectorcall. The STL ifdefs out those overloads, right?
I don't have MSVC for arm64 to test with (but @mgrang does so he can check), 
but I included them for consistency and completeness.


https://reviews.llvm.org/D36105



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


Re: r309007 - [ubsan] Null-check pointers in -fsanitize=vptr (PR33881)

2017-07-31 Thread Vedant Kumar via cfe-commits

> On Jul 31, 2017, at 12:30 PM, Nico Weber  wrote:
> 
> On Mon, Jul 31, 2017 at 1:18 PM, Vedant Kumar  > wrote:
> The bot should start working again with -fsanitize=vptr,null.
> 
> The warning can be improved. If we find -fno-sanitize=null in the argument 
> list, we might say:
> implicitly disabling vptr sanitizer because "-fno-sanitize=null" was specified
> 
> Otherwise we might say:
> implicitly disabling vptr sanitizer because null checking wasn't enabled, try 
> specifying -fsanitize=null or -fsanitize=undefined
> 
> Hm, I still don't understand. I enable vptr ubsan checking, and I don't want 
> null checking (because chromium happens to be vptr clean and we want to keep 
> it that way, but we're not nullptr clean due to for example v8's SMIs). How 
> do I get yesterday's behavior back?

We can teach the -fsanitize=vptr to emit its own null check when 
-fsanitize=null isn't available (I'll send a patch out for this). I opted not 
to do this initially to because I expected the two checks to either always be 
enabled together, or to be mutually compatible.

vedant

>  
> 
> I'll send out a patch for review.
> 
> vedant
> 
> > On Jul 31, 2017, at 9:37 AM, Hans Wennborg  > > wrote:
> >
> > /sub
> >
> > I believe Vedant asked for this to be merged to 5.0, so I'd like to
> > merge the resolution too.
> >
> > On Mon, Jul 31, 2017 at 8:51 AM, Nico Weber via cfe-commits
> > mailto:cfe-commits@lists.llvm.org>> wrote:
> >> Hi Vedant,
> >>
> >> after this change our ubsanvptr bot fails like so:
> >>
> >> clang-6.0: error: implicitly disabling vptr sanitizer because null checking
> >> wasn't enabled [-Werror,-Wauto-disable-vptr-sanitizer]
> >>
> >> The bot uses -fsanitize=vptr. I have no idea what this warning is supposed
> >> to tell me. Maybe it could be reworded, or maybe it shouldn't be emitted?
> >>
> >> Thanks,
> >> Nico
> >>
> >> On Tue, Jul 25, 2017 at 3:34 PM, Vedant Kumar via cfe-commits
> >> mailto:cfe-commits@lists.llvm.org>> wrote:
> >>>
> >>> Author: vedantk
> >>> Date: Tue Jul 25 12:34:23 2017
> >>> New Revision: 309007
> >>>
> >>> URL: http://llvm.org/viewvc/llvm-project?rev=309007&view=rev 
> >>> 
> >>> Log:
> >>> [ubsan] Null-check pointers in -fsanitize=vptr (PR33881)
> >>>
> >>> The instrumentation generated by -fsanitize=vptr does not null check a
> >>> user pointer before loading from it. This causes crashes in the face of
> >>> UB member calls (this=nullptr), i.e it's causing user programs to crash
> >>> only after UBSan is turned on.
> >>>
> >>> The fix is to make run-time null checking a prerequisite for enabling
> >>> -fsanitize=vptr, and to then teach UBSan to reuse these run-time null
> >>> checks to make -fsanitize=vptr safe.
> >>>
> >>> Testing: check-clang, check-ubsan, a stage2 ubsan-enabled build
> >>>
> >>> Differential Revision: https://reviews.llvm.org/D35735 
> >>> 
> >>>
> >>> https://bugs.llvm.org/show_bug.cgi?id=33881 
> >>> 
> >>>
> >>> Modified:
> >>>cfe/trunk/docs/ReleaseNotes.rst
> >>>cfe/trunk/docs/UndefinedBehaviorSanitizer.rst
> >>>cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
> >>>cfe/trunk/include/clang/Basic/DiagnosticGroups.td
> >>>cfe/trunk/lib/CodeGen/CGExpr.cpp
> >>>cfe/trunk/lib/Driver/SanitizerArgs.cpp
> >>>cfe/trunk/test/CodeGenCXX/catch-undef-behavior.cpp
> >>>cfe/trunk/test/CodeGenCXX/ubsan-devirtualized-calls.cpp
> >>>cfe/trunk/test/CodeGenCXX/ubsan-type-checks.cpp
> >>>cfe/trunk/test/CodeGenCXX/ubsan-vtable-checks.cpp
> >>>cfe/trunk/test/Driver/fsanitize.c
> >>>cfe/trunk/test/Driver/rtti-options.cpp
> >>>
> >>> Modified: cfe/trunk/docs/ReleaseNotes.rst
> >>> URL:
> >>> http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ReleaseNotes.rst?rev=309007&r1=309006&r2=309007&view=diff
> >>>  
> >>> 
> >>>
> >>> ==
> >>> --- cfe/trunk/docs/ReleaseNotes.rst (original)
> >>> +++ cfe/trunk/docs/ReleaseNotes.rst Tue Jul 25 12:34:23 2017
> >>> @@ -155,7 +155,9 @@ Static Analyzer
> >>> Undefined Behavior Sanitizer (UBSan)
> >>> 
> >>>
> >>> -...
> >>> +The C++ dynamic type check now requires run-time null checking (i.e,
> >>> +`-fsanitize=vptr` cannot be used without `-fsanitize=null`). This change
> >>> does
> >>> +not impact users who rely on UBSan check groups (e.g
> >>> `-fsanitize=undefined`).
> >>>
> >>> Core Analysis Improvements
> >>> ==
> >>>
> >>> Modified: cfe/trunk/docs/UndefinedBehaviorSanitizer.rst
> >>> URL:
> >>> http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/UndefinedBehaviorSanitizer.rst?rev=309007&r1=309006&r2=309007&view=diff
> >>>  
> >>> 

[PATCH] D35894: [clangd] Code hover for Clangd

2017-07-31 Thread William Enright via Phabricator via cfe-commits
Nebiroth updated this revision to Diff 108979.
Nebiroth marked 19 inline comments as done.
Nebiroth added a comment.

Implemention of Code Hover as described in LSP definition.
Removed unintentional changes to formatting.
Removed file id field in Location struct.


https://reviews.llvm.org/D35894

Files:
  clangd/ClangdLSPServer.cpp
  clangd/ClangdServer.cpp
  clangd/ClangdServer.h
  clangd/ClangdUnit.h
  clangd/Protocol.cpp
  clangd/Protocol.h
  clangd/ProtocolHandlers.cpp
  clangd/ProtocolHandlers.h
  clangd/clients/clangd-vscode/src/extension.ts
  test/clangd/hover.test

Index: test/clangd/hover.test
===
--- /dev/null
+++ test/clangd/hover.test
@@ -0,0 +1,26 @@
+# RUN: clangd -run-synchronously < %s | FileCheck %s
+# It is absolutely vital that this file has CRLF line endings.
+#
+Content-Length: 125
+
+{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}}
+
+Content-Length: 172
+
+{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"file:///main.cpp","languageId":"cpp","version":1,"text":"int main() {\nint a;\na;\n}\n"}}}
+
+Content-Length: 143
+
+{"jsonrpc":"2.0","id":1,"method":"textDocument/hover","params":{"textDocument":{"uri":"file:///main.cpp"},"position":{"line":0,"character":5}}}
+# Go to local variable
+# CHECK: {"jsonrpc":"2.0","id":1,"result":{"contents": {"language": "C++", "value": "int main() {\nint a;\na;\n}"}, "range": {"start": {"line": 0, "character": 0}, "end": {"line": 3, "character": 1
+
+Content-Length: 143
+
+{"jsonrpc":"2.0","id":1,"method":"textDocument/hover","params":{"textDocument":{"uri":"file:///main.cpp"},"position":{"line":1,"character":5}}}
+# Go to local variable
+# CHECK: {"jsonrpc":"2.0","id":1,"result":{"contents": {"language": "C++", "value": "int a"}, "range": {"start": {"line": 1, "character": 0}, "end": {"line": 1, "character": 5
+
+Content-Length: 44
+
+{"jsonrpc":"2.0","id":3,"method":"shutdown"}
Index: clangd/clients/clangd-vscode/src/extension.ts
===
--- clangd/clients/clangd-vscode/src/extension.ts
+++ clangd/clients/clangd-vscode/src/extension.ts
@@ -1,5 +1,6 @@
 import * as vscode from 'vscode';
 import * as vscodelc from 'vscode-languageclient';
+import * as vscodejsonrpc from 'vscode-jsonrpc';
 
 /**
  * Method to get workspace configuration option
Index: clangd/ProtocolHandlers.h
===
--- clangd/ProtocolHandlers.h
+++ clangd/ProtocolHandlers.h
@@ -48,6 +48,8 @@
 JSONOutput &Out) = 0;
   virtual void onGoToDefinition(TextDocumentPositionParams Params, StringRef ID,
 JSONOutput &Out) = 0;
+  virtual void onCodeHover(TextDocumentPositionParams Params, StringRef ID,
+JSONOutput &Out) = 0;
 };
 
 void regiterCallbackHandlers(JSONRPCDispatcher &Dispatcher, JSONOutput &Out,
Index: clangd/ProtocolHandlers.cpp
===
--- clangd/ProtocolHandlers.cpp
+++ clangd/ProtocolHandlers.cpp
@@ -204,6 +204,24 @@
   ProtocolCallbacks &Callbacks;
 };
 
+struct CodeHoverHandler : Handler {
+  CodeHoverHandler(JSONOutput &Output, ProtocolCallbacks &Callbacks)
+  : Handler(Output), Callbacks(Callbacks) {}
+
+  void handleMethod(llvm::yaml::MappingNode *Params, StringRef ID) override {
+auto TDPP = TextDocumentPositionParams::parse(Params);
+if (!TDPP) {
+  Output.log("Failed to decode TextDocumentPositionParams!\n");
+  return;
+}
+
+Callbacks.onCodeHover(*TDPP, ID, Output);
+  }
+
+private:
+  ProtocolCallbacks &Callbacks;
+};
+
 } // namespace
 
 void clangd::regiterCallbackHandlers(JSONRPCDispatcher &Dispatcher,
@@ -239,4 +257,7 @@
   llvm::make_unique(Out, Callbacks));
   Dispatcher.registerHandler("textDocument/definition",
   llvm::make_unique(Out, Callbacks));
+  Dispatcher.registerHandler(
+  "textDocument/hover",
+  llvm::make_unique(Out, Callbacks));
 }
Index: clangd/Protocol.h
===
--- clangd/Protocol.h
+++ clangd/Protocol.h
@@ -23,6 +23,7 @@
 
 #include "llvm/ADT/Optional.h"
 #include "llvm/Support/YAMLParser.h"
+#include "clang/Basic/SourceLocation.h"
 #include 
 #include 
 
@@ -304,7 +305,59 @@
   parse(llvm::yaml::MappingNode *Params);
 };
 
-/// The kind of a completion entry.
+struct MarkedString {
+  /**
+ * MarkedString can be used to render human readable text. It is either a
+ * markdown string
+ * or a code-block that provides a language and a code snippet. The language
+ * identifier
+ * is sematically equal to the optional language identifier in fenced code
+ * blocks in GitHub
+ * issues. See
+ * https://help.github.com/articles/creating-and-highlighting-code-blocks/#syntax-highlighting
+ *
+ * The pair of a la

[PATCH] D32842: Specify which sanitizers are covered by a sanitizer blacklist

2017-07-31 Thread Vedant Kumar via Phabricator via cfe-commits
vsk added a comment.

In https://reviews.llvm.org/D32842#826383, @shenhan wrote:

> Ping? Can we make a decision on this? 
>  I've this simple one D35849: [UBSan] Provide default blacklist filename for 
> UBSan  which, depending on this, shall be 
> discarded or move forward.
>  If this CL stalls, I'll seek to proceed with 
> https://reviews.llvm.org/D35849. Any how, https://reviews.llvm.org/D35849 
> gets wiped out whence this CL (https://reviews.llvm.org/D32842) is submitted.


Please go ahead with https://reviews.llvm.org/D35849, I believe @pcc sgtm'd an 
identical patch of mine a while back, and it lgtm as well. Once I have time to 
revisit this I'll make sure to consider ubsan_blacklist.txt.


https://reviews.llvm.org/D32842



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


[PATCH] D35849: [UBSan] Provide default blacklist filename for UBSan

2017-07-31 Thread Vedant Kumar via Phabricator via cfe-commits
vsk accepted this revision.
vsk added a comment.
This revision is now accepted and ready to land.

This lgtm, we shouldn't defer this until https://reviews.llvm.org/D32842 is 
done, as that may take a while.


https://reviews.llvm.org/D35849



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


[PATCH] D36108: Add powerpc64 to compiler-rt build infrastructure.

2017-07-31 Thread Sterling Augustine via Phabricator via cfe-commits
saugustine created this revision.
Herald added subscribers: aheejin, mgorny, dberris, nemanjai.

Add powerpc64 to compiler-rt build infrastructure.


https://reviews.llvm.org/D36108

Files:
  compiler-rt/cmake/Modules/CompilerRTUtils.cmake
  compiler-rt/cmake/builtin-config-ix.cmake
  compiler-rt/lib/builtins/CMakeLists.txt


Index: compiler-rt/lib/builtins/CMakeLists.txt
===
--- compiler-rt/lib/builtins/CMakeLists.txt
+++ compiler-rt/lib/builtins/CMakeLists.txt
@@ -458,6 +458,20 @@
 set(mips64el_SOURCES ${GENERIC_TF_SOURCES}
  ${mips_SOURCES})
 
+set(powerpc64_SOURCES
+  ppc/divtc3.c
+  ppc/fixtfdi.c
+  ppc/fixunstfdi.c
+  ppc/floatditf.c
+  ppc/floatunditf.c
+  ppc/gcc_qadd.c
+  ppc/gcc_qdiv.c
+  ppc/gcc_qmul.c
+  ppc/gcc_qsub.c
+  ppc/multc3.c
+  ${GENERIC_SOURCES})
+set(powerpc64le_SOURCES ${powerpc64_SOURCES})
+
 set(wasm32_SOURCES ${GENERIC_SOURCES})
 set(wasm64_SOURCES ${GENERIC_SOURCES})
 
Index: compiler-rt/cmake/builtin-config-ix.cmake
===
--- compiler-rt/cmake/builtin-config-ix.cmake
+++ compiler-rt/cmake/builtin-config-ix.cmake
@@ -40,7 +40,7 @@
 endif()
 
 set(ALL_BUILTIN_SUPPORTED_ARCH ${X86} ${X86_64} ${ARM32} ${ARM64}
-${MIPS32} ${MIPS64} ${WASM32} ${WASM64})
+${MIPS32} ${MIPS64} ${PPC64} ${WASM32} ${WASM64})
 
 include(CompilerRTUtils)
 include(CompilerRTDarwinUtils)
Index: compiler-rt/cmake/Modules/CompilerRTUtils.cmake
===
--- compiler-rt/cmake/Modules/CompilerRTUtils.cmake
+++ compiler-rt/cmake/Modules/CompilerRTUtils.cmake
@@ -167,6 +167,8 @@
   check_symbol_exists(__i386__ "" __I386)
   check_symbol_exists(__mips__ "" __MIPS)
   check_symbol_exists(__mips64__ "" __MIPS64)
+  check_symbol_exists(__powerpc64__ "" __PPC64)
+  check_symbol_exists(__powerpc64le__ "" __PPC64LE)
   check_symbol_exists(__s390x__ "" __S390X)
   check_symbol_exists(__wasm32__ "" __WEBASSEMBLY32)
   check_symbol_exists(__wasm64__ "" __WEBASSEMBLY64)
@@ -184,6 +186,10 @@
 add_default_target_arch(mips64)
   elseif(__MIPS)
 add_default_target_arch(mips)
+  elseif(__PPC64)
+add_default_target_arch(powerpc64)
+  elseif(__PPC64LE)
+add_default_target_arch(powerpc64le)
   elseif(__S390X)
 add_default_target_arch(s390x)
   elseif(__WEBASSEMBLY32)


Index: compiler-rt/lib/builtins/CMakeLists.txt
===
--- compiler-rt/lib/builtins/CMakeLists.txt
+++ compiler-rt/lib/builtins/CMakeLists.txt
@@ -458,6 +458,20 @@
 set(mips64el_SOURCES ${GENERIC_TF_SOURCES}
  ${mips_SOURCES})
 
+set(powerpc64_SOURCES
+  ppc/divtc3.c
+  ppc/fixtfdi.c
+  ppc/fixunstfdi.c
+  ppc/floatditf.c
+  ppc/floatunditf.c
+  ppc/gcc_qadd.c
+  ppc/gcc_qdiv.c
+  ppc/gcc_qmul.c
+  ppc/gcc_qsub.c
+  ppc/multc3.c
+  ${GENERIC_SOURCES})
+set(powerpc64le_SOURCES ${powerpc64_SOURCES})
+
 set(wasm32_SOURCES ${GENERIC_SOURCES})
 set(wasm64_SOURCES ${GENERIC_SOURCES})
 
Index: compiler-rt/cmake/builtin-config-ix.cmake
===
--- compiler-rt/cmake/builtin-config-ix.cmake
+++ compiler-rt/cmake/builtin-config-ix.cmake
@@ -40,7 +40,7 @@
 endif()
 
 set(ALL_BUILTIN_SUPPORTED_ARCH ${X86} ${X86_64} ${ARM32} ${ARM64}
-${MIPS32} ${MIPS64} ${WASM32} ${WASM64})
+${MIPS32} ${MIPS64} ${PPC64} ${WASM32} ${WASM64})
 
 include(CompilerRTUtils)
 include(CompilerRTDarwinUtils)
Index: compiler-rt/cmake/Modules/CompilerRTUtils.cmake
===
--- compiler-rt/cmake/Modules/CompilerRTUtils.cmake
+++ compiler-rt/cmake/Modules/CompilerRTUtils.cmake
@@ -167,6 +167,8 @@
   check_symbol_exists(__i386__ "" __I386)
   check_symbol_exists(__mips__ "" __MIPS)
   check_symbol_exists(__mips64__ "" __MIPS64)
+  check_symbol_exists(__powerpc64__ "" __PPC64)
+  check_symbol_exists(__powerpc64le__ "" __PPC64LE)
   check_symbol_exists(__s390x__ "" __S390X)
   check_symbol_exists(__wasm32__ "" __WEBASSEMBLY32)
   check_symbol_exists(__wasm64__ "" __WEBASSEMBLY64)
@@ -184,6 +186,10 @@
 add_default_target_arch(mips64)
   elseif(__MIPS)
 add_default_target_arch(mips)
+  elseif(__PPC64)
+add_default_target_arch(powerpc64)
+  elseif(__PPC64LE)
+add_default_target_arch(powerpc64le)
   elseif(__S390X)
 add_default_target_arch(s390x)
   elseif(__WEBASSEMBLY32)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r309616 - [X86] Remove -O3 from tbm-builtins.c test file.

2017-07-31 Thread Craig Topper via cfe-commits
Author: ctopper
Date: Mon Jul 31 13:21:53 2017
New Revision: 309616

URL: http://llvm.org/viewvc/llvm-project?rev=309616&view=rev
Log:
[X86] Remove -O3 from tbm-builtins.c test file.

A change to InstCombine broke this test, but we generally frown on running 
optimizations clang tests anyway. So I've updated the checks to not depend on 
optimizations anymore.

Modified:
cfe/trunk/test/CodeGen/tbm-builtins.c

Modified: cfe/trunk/test/CodeGen/tbm-builtins.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/tbm-builtins.c?rev=309616&r1=309615&r2=309616&view=diff
==
--- cfe/trunk/test/CodeGen/tbm-builtins.c (original)
+++ cfe/trunk/test/CodeGen/tbm-builtins.c Mon Jul 31 13:21:53 2017
@@ -1,8 +1,4 @@
-// RUN: %clang_cc1 -ffreestanding %s -O3 -triple=x86_64-unknown-unknown 
-target-feature +tbm -emit-llvm -o - | FileCheck %s
-// FIXME: The code generation checks for add/sub and/or are depending on the 
optimizer.
-// The REQUIRES keyword will be removed when the FIXME is complete.
-// REQUIRES: x86-registered-target
-
+// RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-unknown-unknown 
-target-feature +tbm -emit-llvm -o - | FileCheck %s
 
 #include 
 
@@ -28,134 +24,136 @@ unsigned long long test__bextri_u64_bigi
 
 unsigned int test__blcfill_u32(unsigned int a) {
   // CHECK-LABEL: test__blcfill_u32
-  // CHECK: [[TMP:%.*]] = add i32 [[SRC:%.*]], 1
-  // CHECK-NEXT: %{{.*}} = and i32 [[TMP]], [[SRC]]
+  // CHECK: [[TMP:%.*]] = add i32 %{{.*}}, 1
+  // CHECK: %{{.*}} = and i32 %{{.*}}, [[TMP]]
   return __blcfill_u32(a);
 }
 
 unsigned long long test__blcfill_u64(unsigned long long a) {
   // CHECK-LABEL: test__blcfill_u64
-  // CHECK: [[TMPT:%.*]] = add i64 [[SRC:%.*]], 1
-  // CHECK-NEXT: %{{.*}} = and i64 [[TMP]], [[SRC]]
+  // CHECK: [[TMP:%.*]] = add i64 %{{.*}}, 1
+  // CHECK: %{{.*}} = and i64 %{{.*}}, [[TMP]]
   return __blcfill_u64(a);
 }
 
 unsigned int test__blci_u32(unsigned int a) {
   // CHECK-LABEL: test__blci_u32
-  // CHECK: [[TMP:%.*]] = sub i32 -2, [[SRC:%.*]]
-  // CHECK-NEXT: %{{.*}} = or i32 [[TMP]], [[SRC]]
+  // CHECK: [[TMP1:%.*]] = add i32 %{{.*}}, 1
+  // CHECK: [[TMP2:%.*]] = xor i32 [[TMP1]], -1
+  // CHECK: %{{.*}} = or i32 %{{.*}}, [[TMP2]]
   return __blci_u32(a);
 }
 
 unsigned long long test__blci_u64(unsigned long long a) {
   // CHECK-LABEL: test__blci_u64
-  // CHECK: [[TMP:%.*]] = sub i64 -2, [[SRC:%.*]]
-  // CHECK-NEXT: %{{.*}} = or i64 [[TMP]], [[SRC]]
+  // CHECK: [[TMP1:%.*]] = add i64 %{{.*}}, 1
+  // CHECK: [[TMP2:%.*]] = xor i64 [[TMP1]], -1
+  // CHECK: %{{.*}} = or i64 %{{.*}}, [[TMP2]]
   return __blci_u64(a);
 }
 
 unsigned int test__blcic_u32(unsigned int a) {
   // CHECK-LABEL: test__blcic_u32
-  // CHECK: [[TMP1:%.*]] = xor i32 [[SRC:%.*]], -1
-  // CHECK-NEXT: [[TMP2:%.*]] = add i32 [[SRC]], 1
-  // CHECK-NEXT: {{.*}} = and i32 [[TMP2]], [[TMP1]]
+  // CHECK: [[TMP1:%.*]] = xor i32 %{{.*}}, -1
+  // CHECK: [[TMP2:%.*]] = add i32 %{{.*}}, 1
+  // CHECK-NEXT: {{.*}} = and i32 [[TMP1]], [[TMP2]]
   return __blcic_u32(a);
 }
 
 unsigned long long test__blcic_u64(unsigned long long a) {
   // CHECK-LABEL: test__blcic_u64
-  // CHECK: [[TMP1:%.*]] = xor i64 [[SRC:%.*]], -1
-  // CHECK-NEXT: [[TMP2:%.*]] = add i64 [[SRC]], 1
-  // CHECK-NEXT: {{.*}} = and i64 [[TMP2]], [[TMP1]]
+  // CHECK: [[TMP1:%.*]] = xor i64 %{{.*}}, -1
+  // CHECK: [[TMP2:%.*]] = add i64 %{{.*}}, 1
+  // CHECK-NEXT: {{.*}} = and i64 [[TMP1]], [[TMP2]]
   return __blcic_u64(a);
 }
 
 unsigned int test__blcmsk_u32(unsigned int a) {
   // CHECK-LABEL: test__blcmsk_u32
-  // CHECK: [[TMP:%.*]] = add i32 [[SRC:%.*]], 1
-  // CHECK-NEXT: {{.*}} = xor i32 [[TMP]], [[SRC]]
+  // CHECK: [[TMP:%.*]] = add i32 %{{.*}}, 1
+  // CHECK-NEXT: {{.*}} = xor i32 %{{.*}}, [[TMP]]
   return __blcmsk_u32(a);
 }
 
 unsigned long long test__blcmsk_u64(unsigned long long a) {
   // CHECK-LABEL: test__blcmsk_u64
-  // CHECK: [[TMP:%.*]] = add i64 [[SRC:%.*]], 1
-  // CHECK-NEXT: {{.*}} = xor i64 [[TMP]], [[SRC]]
+  // CHECK: [[TMP:%.*]] = add i64 %{{.*}}, 1
+  // CHECK-NEXT: {{.*}} = xor i64 %{{.*}}, [[TMP]]
   return __blcmsk_u64(a);
 }
 
 unsigned int test__blcs_u32(unsigned int a) {
   // CHECK-LABEL: test__blcs_u32
-  // CHECK: [[TMP:%.*]] = add i32 [[SRC:%.*]], 1
-  // CHECK-NEXT: {{.*}} = or i32 [[TMP]], [[SRC]]
+  // CHECK: [[TMP:%.*]] = add i32 %{{.*}}, 1
+  // CHECK-NEXT: {{.*}} = or i32 %{{.*}}, [[TMP]]
   return __blcs_u32(a);
 }
 
 unsigned long long test__blcs_u64(unsigned long long a) {
   // CHECK-LABEL: test__blcs_u64
-  // CHECK: [[TMP:%.*]] = add i64 [[SRC:%.*]], 1
-  // CHECK-NEXT: {{.*}} = or i64 [[TMP]], [[SRC]]
+  // CHECK: [[TMP:%.*]] = add i64 %{{.*}}, 1
+  // CHECK-NEXT: {{.*}} = or i64 %{{.*}}, [[TMP]]
   return __blcs_u64(a);
 }
 
 unsigned int test__blsfill_u32(unsigned int a) {
   // CHECK-LABEL: test__blsfill_u32
-  // CHECK: [[TMP:%.*]] = add i32 [[SRC:%.*]], -1
-  // CHECK-NEXT: {{.*}} = or i

[PATCH] D36111: [COFF, ARM64] Add MS builtins __dmb, __dsb, __isb

2017-07-31 Thread Mandeep Singh Grang via Phabricator via cfe-commits
mgrang created this revision.
Herald added subscribers: kristof.beyls, javed.absar, aemerson.

https://reviews.llvm.org/D36111

Files:
  include/clang/Basic/BuiltinsAArch64.def
  test/CodeGen/builtins-arm64.c


Index: test/CodeGen/builtins-arm64.c
===
--- test/CodeGen/builtins-arm64.c
+++ test/CodeGen/builtins-arm64.c
@@ -30,6 +30,9 @@
 }
 
 void barriers() {
+  __dmb(1);  //CHECK: call {{.*}} @llvm.aarch64.dmb(i32 1)
+  __dsb(2);  //CHECK: call {{.*}} @llvm.aarch64.dsb(i32 2)
+  __isb(3);  //CHECK: call {{.*}} @llvm.aarch64.isb(i32 3)
   __builtin_arm_dmb(1);  //CHECK: call {{.*}} @llvm.aarch64.dmb(i32 1)
   __builtin_arm_dsb(2);  //CHECK: call {{.*}} @llvm.aarch64.dsb(i32 2)
   __builtin_arm_isb(3);  //CHECK: call {{.*}} @llvm.aarch64.isb(i32 3)
Index: include/clang/Basic/BuiltinsAArch64.def
===
--- include/clang/Basic/BuiltinsAArch64.def
+++ include/clang/Basic/BuiltinsAArch64.def
@@ -46,6 +46,9 @@
 BUILTIN(__builtin_arm_crc32cd, "UiUiLUi", "nc")
 
 // Memory barrier
+BUILTIN(__dmb, "vUi", "nc")
+BUILTIN(__dsb, "vUi", "nc")
+BUILTIN(__isb, "vUi", "nc")
 BUILTIN(__builtin_arm_dmb, "vUi", "nc")
 BUILTIN(__builtin_arm_dsb, "vUi", "nc")
 BUILTIN(__builtin_arm_isb, "vUi", "nc")


Index: test/CodeGen/builtins-arm64.c
===
--- test/CodeGen/builtins-arm64.c
+++ test/CodeGen/builtins-arm64.c
@@ -30,6 +30,9 @@
 }
 
 void barriers() {
+  __dmb(1);  //CHECK: call {{.*}} @llvm.aarch64.dmb(i32 1)
+  __dsb(2);  //CHECK: call {{.*}} @llvm.aarch64.dsb(i32 2)
+  __isb(3);  //CHECK: call {{.*}} @llvm.aarch64.isb(i32 3)
   __builtin_arm_dmb(1);  //CHECK: call {{.*}} @llvm.aarch64.dmb(i32 1)
   __builtin_arm_dsb(2);  //CHECK: call {{.*}} @llvm.aarch64.dsb(i32 2)
   __builtin_arm_isb(3);  //CHECK: call {{.*}} @llvm.aarch64.isb(i32 3)
Index: include/clang/Basic/BuiltinsAArch64.def
===
--- include/clang/Basic/BuiltinsAArch64.def
+++ include/clang/Basic/BuiltinsAArch64.def
@@ -46,6 +46,9 @@
 BUILTIN(__builtin_arm_crc32cd, "UiUiLUi", "nc")
 
 // Memory barrier
+BUILTIN(__dmb, "vUi", "nc")
+BUILTIN(__dsb, "vUi", "nc")
+BUILTIN(__isb, "vUi", "nc")
 BUILTIN(__builtin_arm_dmb, "vUi", "nc")
 BUILTIN(__builtin_arm_dsb, "vUi", "nc")
 BUILTIN(__builtin_arm_isb, "vUi", "nc")
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D36111: [COFF, ARM64] Add MS builtins __dmb, __dsb, __isb

2017-07-31 Thread Mandeep Singh Grang via Phabricator via cfe-commits
mgrang added a comment.

Related llvm patch: https://reviews.llvm.org/D36110


https://reviews.llvm.org/D36111



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


[PATCH] D36111: [COFF, ARM64] Add MS builtins __dmb, __dsb, __isb

2017-07-31 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo added inline comments.



Comment at: include/clang/Basic/BuiltinsAArch64.def:49
 // Memory barrier
+BUILTIN(__dmb, "vUi", "nc")
+BUILTIN(__dsb, "vUi", "nc")

Shouldn't these be limited to MSVC mode only? Have a look at `BuiltinsARM.def`, 
where there's cases like `LANGBUILTIN(__dmb, "vUi", "nc", ALL_MS_LANGUAGES)` 
instead.


https://reviews.llvm.org/D36111



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


r309619 - [AArch64] Don't define __LP64__ when targeting Windows

2017-07-31 Thread Martin Storsjo via cfe-commits
Author: mstorsjo
Date: Mon Jul 31 13:40:53 2017
New Revision: 309619

URL: http://llvm.org/viewvc/llvm-project?rev=309619&view=rev
Log:
[AArch64] Don't define __LP64__ when targeting Windows

Windows/ARM64 is a LLP64 environment, so don't set this default
define.

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

Modified:
cfe/trunk/lib/Basic/Targets/AArch64.cpp
cfe/trunk/test/Preprocessor/init.c

Modified: cfe/trunk/lib/Basic/Targets/AArch64.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/AArch64.cpp?rev=309619&r1=309618&r2=309619&view=diff
==
--- cfe/trunk/lib/Basic/Targets/AArch64.cpp (original)
+++ cfe/trunk/lib/Basic/Targets/AArch64.cpp Mon Jul 31 13:40:53 2017
@@ -119,8 +119,10 @@ void AArch64TargetInfo::getTargetDefines
 Builder.defineMacro("__ELF__");
 
   // Target properties.
-  Builder.defineMacro("_LP64");
-  Builder.defineMacro("__LP64__");
+  if (!getTriple().isOSWindows()) {
+Builder.defineMacro("_LP64");
+Builder.defineMacro("__LP64__");
+  }
 
   // ACLE predefines. Many can only have one possible value on v8 AArch64.
   Builder.defineMacro("__ARM_ACLE", "200");

Modified: cfe/trunk/test/Preprocessor/init.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/init.c?rev=309619&r1=309618&r2=309619&view=diff
==
--- cfe/trunk/test/Preprocessor/init.c (original)
+++ cfe/trunk/test/Preprocessor/init.c Mon Jul 31 13:40:53 2017
@@ -1424,6 +1424,167 @@
 // AARCH64-DARWIN: #define __WINT_WIDTH__ 32
 // AARCH64-DARWIN: #define __aarch64__ 1
 
+// RUN: %clang_cc1 -E -dM -ffreestanding -triple=aarch64-windows-msvc < 
/dev/null | FileCheck -match-full-lines -check-prefix AARCH64-MSVC %s
+//
+// AARCH64-MSVC: #define _INTEGRAL_MAX_BITS 64
+// AARCH64-MSVC-NOT: #define _LP64 1
+// AARCH64-MSVC: #define _M_ARM64 1
+// AARCH64-MSVC: #define _WIN32 1
+// AARCH64-MSVC: #define _WIN64 1
+// AARCH64-MSVC: #define __AARCH64EL__ 1
+// AARCH64-MSVC: #define __ARM_64BIT_STATE 1
+// AARCH64-MSVC: #define __ARM_ACLE 200
+// AARCH64-MSVC: #define __ARM_ALIGN_MAX_STACK_PWR 4
+// AARCH64-MSVC: #define __ARM_ARCH 8
+// AARCH64-MSVC: #define __ARM_ARCH_ISA_A64 1
+// AARCH64-MSVC: #define __ARM_ARCH_PROFILE 'A'
+// AARCH64-MSVC: #define __ARM_FEATURE_CLZ 1
+// AARCH64-MSVC: #define __ARM_FEATURE_DIRECTED_ROUNDING 1
+// AARCH64-MSVC: #define __ARM_FEATURE_DIV 1
+// AARCH64-MSVC: #define __ARM_FEATURE_FMA 1
+// AARCH64-MSVC: #define __ARM_FEATURE_IDIV 1
+// AARCH64-MSVC: #define __ARM_FEATURE_LDREX 0xF
+// AARCH64-MSVC: #define __ARM_FEATURE_NUMERIC_MAXMIN 1
+// AARCH64-MSVC: #define __ARM_FEATURE_UNALIGNED 1
+// AARCH64-MSVC: #define __ARM_FP 0xE
+// AARCH64-MSVC: #define __ARM_FP16_ARGS 1
+// AARCH64-MSVC: #define __ARM_FP16_FORMAT_IEEE 1
+// AARCH64-MSVC: #define __ARM_PCS_AAPCS64 1
+// AARCH64-MSVC: #define __ARM_SIZEOF_MINIMAL_ENUM 4
+// AARCH64-MSVC: #define __ARM_SIZEOF_WCHAR_T 4
+// AARCH64-MSVC: #define __BIGGEST_ALIGNMENT__ 16
+// AARCH64-MSVC: #define __BYTE_ORDER__ __ORDER_LITTLE_ENDIAN__
+// AARCH64-MSVC: #define __CHAR16_TYPE__ unsigned short
+// AARCH64-MSVC: #define __CHAR32_TYPE__ unsigned int
+// AARCH64-MSVC: #define __CHAR_BIT__ 8
+// AARCH64-MSVC: #define __CONSTANT_CFSTRINGS__ 1
+// AARCH64-MSVC: #define __DBL_DECIMAL_DIG__ 17
+// AARCH64-MSVC: #define __DBL_DENORM_MIN__ 4.9406564584124654e-324
+// AARCH64-MSVC: #define __DBL_DIG__ 15
+// AARCH64-MSVC: #define __DBL_EPSILON__ 2.2204460492503131e-16
+// AARCH64-MSVC: #define __DBL_HAS_DENORM__ 1
+// AARCH64-MSVC: #define __DBL_HAS_INFINITY__ 1
+// AARCH64-MSVC: #define __DBL_HAS_QUIET_NAN__ 1
+// AARCH64-MSVC: #define __DBL_MANT_DIG__ 53
+// AARCH64-MSVC: #define __DBL_MAX_10_EXP__ 308
+// AARCH64-MSVC: #define __DBL_MAX_EXP__ 1024
+// AARCH64-MSVC: #define __DBL_MAX__ 1.7976931348623157e+308
+// AARCH64-MSVC: #define __DBL_MIN_10_EXP__ (-307)
+// AARCH64-MSVC: #define __DBL_MIN_EXP__ (-1021)
+// AARCH64-MSVC: #define __DBL_MIN__ 2.2250738585072014e-308
+// AARCH64-MSVC: #define __DECIMAL_DIG__ __LDBL_DECIMAL_DIG__
+// AARCH64-MSVC: #define __FINITE_MATH_ONLY__ 0
+// AARCH64-MSVC: #define __FLT_DECIMAL_DIG__ 9
+// AARCH64-MSVC: #define __FLT_DENORM_MIN__ 1.40129846e-45F
+// AARCH64-MSVC: #define __FLT_DIG__ 6
+// AARCH64-MSVC: #define __FLT_EPSILON__ 1.19209290e-7F
+// AARCH64-MSVC: #define __FLT_EVAL_METHOD__ 0
+// AARCH64-MSVC: #define __FLT_HAS_DENORM__ 1
+// AARCH64-MSVC: #define __FLT_HAS_INFINITY__ 1
+// AARCH64-MSVC: #define __FLT_HAS_QUIET_NAN__ 1
+// AARCH64-MSVC: #define __FLT_MANT_DIG__ 24
+// AARCH64-MSVC: #define __FLT_MAX_10_EXP__ 38
+// AARCH64-MSVC: #define __FLT_MAX_EXP__ 128
+// AARCH64-MSVC: #define __FLT_MAX__ 3.40282347e+38F
+// AARCH64-MSVC: #define __FLT_MIN_10_EXP__ (-37)
+// AARCH64-MSVC: #define __FLT_MIN_EXP__ (-125)
+// AARCH64-MSVC: #define __FLT_MIN__ 1.17549435e-38F
+// AARCH64-MSVC: #define __FLT_RADIX__ 

r309618 - [test] Fix mistagged CHECK-NOT-lines for AARCH64-DARWIN in Preprocessor/init.c

2017-07-31 Thread Martin Storsjo via cfe-commits
Author: mstorsjo
Date: Mon Jul 31 13:40:48 2017
New Revision: 309618

URL: http://llvm.org/viewvc/llvm-project?rev=309618&view=rev
Log:
[test] Fix mistagged CHECK-NOT-lines for AARCH64-DARWIN in Preprocessor/init.c

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

Modified:
cfe/trunk/test/Preprocessor/init.c

Modified: cfe/trunk/test/Preprocessor/init.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/init.c?rev=309618&r1=309617&r2=309618&view=diff
==
--- cfe/trunk/test/Preprocessor/init.c (original)
+++ cfe/trunk/test/Preprocessor/init.c Mon Jul 31 13:40:48 2017
@@ -1236,13 +1236,13 @@
 // RUN: %clang_cc1 -E -dM -ffreestanding -triple=aarch64-apple-ios7.0 < 
/dev/null | FileCheck -match-full-lines -check-prefix AARCH64-DARWIN %s
 //
 // AARCH64-DARWIN: #define _LP64 1
-// AARCH64-NOT: #define __AARCH64EB__ 1
+// AARCH64-DARWIN-NOT: #define __AARCH64EB__ 1
 // AARCH64-DARWIN: #define __AARCH64EL__ 1
-// AARCH64-NOT: #define __AARCH_BIG_ENDIAN 1
+// AARCH64-DARWIN-NOT: #define __AARCH_BIG_ENDIAN 1
 // AARCH64-DARWIN: #define __ARM_64BIT_STATE 1
 // AARCH64-DARWIN: #define __ARM_ARCH 8
 // AARCH64-DARWIN: #define __ARM_ARCH_ISA_A64 1
-// AARCH64-NOT: #define __ARM_BIG_ENDIAN 1
+// AARCH64-DARWIN-NOT: #define __ARM_BIG_ENDIAN 1
 // AARCH64-DARWIN: #define __BIGGEST_ALIGNMENT__ 8
 // AARCH64-DARWIN: #define __BYTE_ORDER__ __ORDER_LITTLE_ENDIAN__
 // AARCH64-DARWIN: #define __CHAR16_TYPE__ unsigned short


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


r309620 - [Attr] Make TargetWindows and TargetMicrosoftCXXABI match on aarch64 as well

2017-07-31 Thread Martin Storsjo via cfe-commits
Author: mstorsjo
Date: Mon Jul 31 13:40:59 2017
New Revision: 309620

URL: http://llvm.org/viewvc/llvm-project?rev=309620&view=rev
Log:
[Attr] Make TargetWindows and TargetMicrosoftCXXABI match on aarch64 as well

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

Modified:
cfe/trunk/include/clang/Basic/Attr.td
cfe/trunk/test/Sema/dllimport.c

Modified: cfe/trunk/include/clang/Basic/Attr.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=309620&r1=309619&r2=309620&view=diff
==
--- cfe/trunk/include/clang/Basic/Attr.td (original)
+++ cfe/trunk/include/clang/Basic/Attr.td Mon Jul 31 13:40:59 2017
@@ -268,10 +268,10 @@ def TargetMips : TargetArch<["mips", "mi
 def TargetMSP430 : TargetArch<["msp430"]>;
 def TargetX86 : TargetArch<["x86"]>;
 def TargetAnyX86 : TargetArch<["x86", "x86_64"]>;
-def TargetWindows : TargetArch<["x86", "x86_64", "arm", "thumb"]> {
+def TargetWindows : TargetArch<["x86", "x86_64", "arm", "thumb", "aarch64"]> {
   let OSes = ["Win32"];
 }
-def TargetMicrosoftCXXABI : TargetArch<["x86", "x86_64", "arm", "thumb"]> {
+def TargetMicrosoftCXXABI : TargetArch<["x86", "x86_64", "arm", "thumb", 
"aarch64"]> {
   let CXXABIs = ["Microsoft"];
 }
 

Modified: cfe/trunk/test/Sema/dllimport.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/dllimport.c?rev=309620&r1=309619&r2=309620&view=diff
==
--- cfe/trunk/test/Sema/dllimport.c (original)
+++ cfe/trunk/test/Sema/dllimport.c Mon Jul 31 13:40:59 2017
@@ -2,6 +2,7 @@
 // RUN: %clang_cc1 -triple x86_64-win32   -fsyntax-only -fms-extensions 
-verify -std=c11 -DMS %s
 // RUN: %clang_cc1 -triple i686-mingw32   -fsyntax-only -fms-extensions 
-verify -std=c11 -DGNU %s
 // RUN: %clang_cc1 -triple x86_64-mingw32 -fsyntax-only -fms-extensions 
-verify -std=c99 -DGNU %s
+// RUN: %clang_cc1 -triple aarch64-win32  -fsyntax-only -fms-extensions 
-verify -std=c99 -DMS %s
 
 // Invalid usage.
 __declspec(dllimport) typedef int typedef1;


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


[PATCH] D36099: [test] Fix mistagged CHECK-NOT-lines for AARCH64-DARWIN in Preprocessor/init.c

2017-07-31 Thread Martin Storsjö via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL309618: [test] Fix mistagged CHECK-NOT-lines for 
AARCH64-DARWIN in Preprocessor/init.c (authored by mstorsjo).

Changed prior to commit:
  https://reviews.llvm.org/D36099?vs=108969&id=108990#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D36099

Files:
  cfe/trunk/test/Preprocessor/init.c


Index: cfe/trunk/test/Preprocessor/init.c
===
--- cfe/trunk/test/Preprocessor/init.c
+++ cfe/trunk/test/Preprocessor/init.c
@@ -1236,13 +1236,13 @@
 // RUN: %clang_cc1 -E -dM -ffreestanding -triple=aarch64-apple-ios7.0 < 
/dev/null | FileCheck -match-full-lines -check-prefix AARCH64-DARWIN %s
 //
 // AARCH64-DARWIN: #define _LP64 1
-// AARCH64-NOT: #define __AARCH64EB__ 1
+// AARCH64-DARWIN-NOT: #define __AARCH64EB__ 1
 // AARCH64-DARWIN: #define __AARCH64EL__ 1
-// AARCH64-NOT: #define __AARCH_BIG_ENDIAN 1
+// AARCH64-DARWIN-NOT: #define __AARCH_BIG_ENDIAN 1
 // AARCH64-DARWIN: #define __ARM_64BIT_STATE 1
 // AARCH64-DARWIN: #define __ARM_ARCH 8
 // AARCH64-DARWIN: #define __ARM_ARCH_ISA_A64 1
-// AARCH64-NOT: #define __ARM_BIG_ENDIAN 1
+// AARCH64-DARWIN-NOT: #define __ARM_BIG_ENDIAN 1
 // AARCH64-DARWIN: #define __BIGGEST_ALIGNMENT__ 8
 // AARCH64-DARWIN: #define __BYTE_ORDER__ __ORDER_LITTLE_ENDIAN__
 // AARCH64-DARWIN: #define __CHAR16_TYPE__ unsigned short


Index: cfe/trunk/test/Preprocessor/init.c
===
--- cfe/trunk/test/Preprocessor/init.c
+++ cfe/trunk/test/Preprocessor/init.c
@@ -1236,13 +1236,13 @@
 // RUN: %clang_cc1 -E -dM -ffreestanding -triple=aarch64-apple-ios7.0 < /dev/null | FileCheck -match-full-lines -check-prefix AARCH64-DARWIN %s
 //
 // AARCH64-DARWIN: #define _LP64 1
-// AARCH64-NOT: #define __AARCH64EB__ 1
+// AARCH64-DARWIN-NOT: #define __AARCH64EB__ 1
 // AARCH64-DARWIN: #define __AARCH64EL__ 1
-// AARCH64-NOT: #define __AARCH_BIG_ENDIAN 1
+// AARCH64-DARWIN-NOT: #define __AARCH_BIG_ENDIAN 1
 // AARCH64-DARWIN: #define __ARM_64BIT_STATE 1
 // AARCH64-DARWIN: #define __ARM_ARCH 8
 // AARCH64-DARWIN: #define __ARM_ARCH_ISA_A64 1
-// AARCH64-NOT: #define __ARM_BIG_ENDIAN 1
+// AARCH64-DARWIN-NOT: #define __ARM_BIG_ENDIAN 1
 // AARCH64-DARWIN: #define __BIGGEST_ALIGNMENT__ 8
 // AARCH64-DARWIN: #define __BYTE_ORDER__ __ORDER_LITTLE_ENDIAN__
 // AARCH64-DARWIN: #define __CHAR16_TYPE__ unsigned short
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D36100: [Attr] Make TargetWindows and TargetMicrosoftCXXABI match on aarch64 as well

2017-07-31 Thread Martin Storsjö via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL309620: [Attr] Make TargetWindows and TargetMicrosoftCXXABI 
match on aarch64 as well (authored by mstorsjo).

Changed prior to commit:
  https://reviews.llvm.org/D36100?vs=108971&id=108992#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D36100

Files:
  cfe/trunk/include/clang/Basic/Attr.td
  cfe/trunk/test/Sema/dllimport.c


Index: cfe/trunk/include/clang/Basic/Attr.td
===
--- cfe/trunk/include/clang/Basic/Attr.td
+++ cfe/trunk/include/clang/Basic/Attr.td
@@ -268,10 +268,10 @@
 def TargetMSP430 : TargetArch<["msp430"]>;
 def TargetX86 : TargetArch<["x86"]>;
 def TargetAnyX86 : TargetArch<["x86", "x86_64"]>;
-def TargetWindows : TargetArch<["x86", "x86_64", "arm", "thumb"]> {
+def TargetWindows : TargetArch<["x86", "x86_64", "arm", "thumb", "aarch64"]> {
   let OSes = ["Win32"];
 }
-def TargetMicrosoftCXXABI : TargetArch<["x86", "x86_64", "arm", "thumb"]> {
+def TargetMicrosoftCXXABI : TargetArch<["x86", "x86_64", "arm", "thumb", 
"aarch64"]> {
   let CXXABIs = ["Microsoft"];
 }
 
Index: cfe/trunk/test/Sema/dllimport.c
===
--- cfe/trunk/test/Sema/dllimport.c
+++ cfe/trunk/test/Sema/dllimport.c
@@ -2,6 +2,7 @@
 // RUN: %clang_cc1 -triple x86_64-win32   -fsyntax-only -fms-extensions 
-verify -std=c11 -DMS %s
 // RUN: %clang_cc1 -triple i686-mingw32   -fsyntax-only -fms-extensions 
-verify -std=c11 -DGNU %s
 // RUN: %clang_cc1 -triple x86_64-mingw32 -fsyntax-only -fms-extensions 
-verify -std=c99 -DGNU %s
+// RUN: %clang_cc1 -triple aarch64-win32  -fsyntax-only -fms-extensions 
-verify -std=c99 -DMS %s
 
 // Invalid usage.
 __declspec(dllimport) typedef int typedef1;


Index: cfe/trunk/include/clang/Basic/Attr.td
===
--- cfe/trunk/include/clang/Basic/Attr.td
+++ cfe/trunk/include/clang/Basic/Attr.td
@@ -268,10 +268,10 @@
 def TargetMSP430 : TargetArch<["msp430"]>;
 def TargetX86 : TargetArch<["x86"]>;
 def TargetAnyX86 : TargetArch<["x86", "x86_64"]>;
-def TargetWindows : TargetArch<["x86", "x86_64", "arm", "thumb"]> {
+def TargetWindows : TargetArch<["x86", "x86_64", "arm", "thumb", "aarch64"]> {
   let OSes = ["Win32"];
 }
-def TargetMicrosoftCXXABI : TargetArch<["x86", "x86_64", "arm", "thumb"]> {
+def TargetMicrosoftCXXABI : TargetArch<["x86", "x86_64", "arm", "thumb", "aarch64"]> {
   let CXXABIs = ["Microsoft"];
 }
 
Index: cfe/trunk/test/Sema/dllimport.c
===
--- cfe/trunk/test/Sema/dllimport.c
+++ cfe/trunk/test/Sema/dllimport.c
@@ -2,6 +2,7 @@
 // RUN: %clang_cc1 -triple x86_64-win32   -fsyntax-only -fms-extensions -verify -std=c11 -DMS %s
 // RUN: %clang_cc1 -triple i686-mingw32   -fsyntax-only -fms-extensions -verify -std=c11 -DGNU %s
 // RUN: %clang_cc1 -triple x86_64-mingw32 -fsyntax-only -fms-extensions -verify -std=c99 -DGNU %s
+// RUN: %clang_cc1 -triple aarch64-win32  -fsyntax-only -fms-extensions -verify -std=c99 -DMS %s
 
 // Invalid usage.
 __declspec(dllimport) typedef int typedef1;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D36098: [AArch64] Don't define __LP64__ when targeting Windows

2017-07-31 Thread Martin Storsjö via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL309619: [AArch64] Don't define __LP64__ when targeting 
Windows (authored by mstorsjo).

Changed prior to commit:
  https://reviews.llvm.org/D36098?vs=108968&id=108991#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D36098

Files:
  cfe/trunk/lib/Basic/Targets/AArch64.cpp
  cfe/trunk/test/Preprocessor/init.c

Index: cfe/trunk/test/Preprocessor/init.c
===
--- cfe/trunk/test/Preprocessor/init.c
+++ cfe/trunk/test/Preprocessor/init.c
@@ -1424,6 +1424,167 @@
 // AARCH64-DARWIN: #define __WINT_WIDTH__ 32
 // AARCH64-DARWIN: #define __aarch64__ 1
 
+// RUN: %clang_cc1 -E -dM -ffreestanding -triple=aarch64-windows-msvc < /dev/null | FileCheck -match-full-lines -check-prefix AARCH64-MSVC %s
+//
+// AARCH64-MSVC: #define _INTEGRAL_MAX_BITS 64
+// AARCH64-MSVC-NOT: #define _LP64 1
+// AARCH64-MSVC: #define _M_ARM64 1
+// AARCH64-MSVC: #define _WIN32 1
+// AARCH64-MSVC: #define _WIN64 1
+// AARCH64-MSVC: #define __AARCH64EL__ 1
+// AARCH64-MSVC: #define __ARM_64BIT_STATE 1
+// AARCH64-MSVC: #define __ARM_ACLE 200
+// AARCH64-MSVC: #define __ARM_ALIGN_MAX_STACK_PWR 4
+// AARCH64-MSVC: #define __ARM_ARCH 8
+// AARCH64-MSVC: #define __ARM_ARCH_ISA_A64 1
+// AARCH64-MSVC: #define __ARM_ARCH_PROFILE 'A'
+// AARCH64-MSVC: #define __ARM_FEATURE_CLZ 1
+// AARCH64-MSVC: #define __ARM_FEATURE_DIRECTED_ROUNDING 1
+// AARCH64-MSVC: #define __ARM_FEATURE_DIV 1
+// AARCH64-MSVC: #define __ARM_FEATURE_FMA 1
+// AARCH64-MSVC: #define __ARM_FEATURE_IDIV 1
+// AARCH64-MSVC: #define __ARM_FEATURE_LDREX 0xF
+// AARCH64-MSVC: #define __ARM_FEATURE_NUMERIC_MAXMIN 1
+// AARCH64-MSVC: #define __ARM_FEATURE_UNALIGNED 1
+// AARCH64-MSVC: #define __ARM_FP 0xE
+// AARCH64-MSVC: #define __ARM_FP16_ARGS 1
+// AARCH64-MSVC: #define __ARM_FP16_FORMAT_IEEE 1
+// AARCH64-MSVC: #define __ARM_PCS_AAPCS64 1
+// AARCH64-MSVC: #define __ARM_SIZEOF_MINIMAL_ENUM 4
+// AARCH64-MSVC: #define __ARM_SIZEOF_WCHAR_T 4
+// AARCH64-MSVC: #define __BIGGEST_ALIGNMENT__ 16
+// AARCH64-MSVC: #define __BYTE_ORDER__ __ORDER_LITTLE_ENDIAN__
+// AARCH64-MSVC: #define __CHAR16_TYPE__ unsigned short
+// AARCH64-MSVC: #define __CHAR32_TYPE__ unsigned int
+// AARCH64-MSVC: #define __CHAR_BIT__ 8
+// AARCH64-MSVC: #define __CONSTANT_CFSTRINGS__ 1
+// AARCH64-MSVC: #define __DBL_DECIMAL_DIG__ 17
+// AARCH64-MSVC: #define __DBL_DENORM_MIN__ 4.9406564584124654e-324
+// AARCH64-MSVC: #define __DBL_DIG__ 15
+// AARCH64-MSVC: #define __DBL_EPSILON__ 2.2204460492503131e-16
+// AARCH64-MSVC: #define __DBL_HAS_DENORM__ 1
+// AARCH64-MSVC: #define __DBL_HAS_INFINITY__ 1
+// AARCH64-MSVC: #define __DBL_HAS_QUIET_NAN__ 1
+// AARCH64-MSVC: #define __DBL_MANT_DIG__ 53
+// AARCH64-MSVC: #define __DBL_MAX_10_EXP__ 308
+// AARCH64-MSVC: #define __DBL_MAX_EXP__ 1024
+// AARCH64-MSVC: #define __DBL_MAX__ 1.7976931348623157e+308
+// AARCH64-MSVC: #define __DBL_MIN_10_EXP__ (-307)
+// AARCH64-MSVC: #define __DBL_MIN_EXP__ (-1021)
+// AARCH64-MSVC: #define __DBL_MIN__ 2.2250738585072014e-308
+// AARCH64-MSVC: #define __DECIMAL_DIG__ __LDBL_DECIMAL_DIG__
+// AARCH64-MSVC: #define __FINITE_MATH_ONLY__ 0
+// AARCH64-MSVC: #define __FLT_DECIMAL_DIG__ 9
+// AARCH64-MSVC: #define __FLT_DENORM_MIN__ 1.40129846e-45F
+// AARCH64-MSVC: #define __FLT_DIG__ 6
+// AARCH64-MSVC: #define __FLT_EPSILON__ 1.19209290e-7F
+// AARCH64-MSVC: #define __FLT_EVAL_METHOD__ 0
+// AARCH64-MSVC: #define __FLT_HAS_DENORM__ 1
+// AARCH64-MSVC: #define __FLT_HAS_INFINITY__ 1
+// AARCH64-MSVC: #define __FLT_HAS_QUIET_NAN__ 1
+// AARCH64-MSVC: #define __FLT_MANT_DIG__ 24
+// AARCH64-MSVC: #define __FLT_MAX_10_EXP__ 38
+// AARCH64-MSVC: #define __FLT_MAX_EXP__ 128
+// AARCH64-MSVC: #define __FLT_MAX__ 3.40282347e+38F
+// AARCH64-MSVC: #define __FLT_MIN_10_EXP__ (-37)
+// AARCH64-MSVC: #define __FLT_MIN_EXP__ (-125)
+// AARCH64-MSVC: #define __FLT_MIN__ 1.17549435e-38F
+// AARCH64-MSVC: #define __FLT_RADIX__ 2
+// AARCH64-MSVC: #define __INT_MAX__ 2147483647
+// AARCH64-MSVC: #define __LDBL_DECIMAL_DIG__ 17
+// AARCH64-MSVC: #define __LDBL_DENORM_MIN__ 4.9406564584124654e-324L
+// AARCH64-MSVC: #define __LDBL_DIG__ 15
+// AARCH64-MSVC: #define __LDBL_EPSILON__ 2.2204460492503131e-16L
+// AARCH64-MSVC: #define __LDBL_HAS_DENORM__ 1
+// AARCH64-MSVC: #define __LDBL_HAS_INFINITY__ 1
+// AARCH64-MSVC: #define __LDBL_HAS_QUIET_NAN__ 1
+// AARCH64-MSVC: #define __LDBL_MANT_DIG__ 53
+// AARCH64-MSVC: #define __LDBL_MAX_10_EXP__ 308
+// AARCH64-MSVC: #define __LDBL_MAX_EXP__ 1024
+// AARCH64-MSVC: #define __LDBL_MAX__ 1.7976931348623157e+308L
+// AARCH64-MSVC: #define __LDBL_MIN_10_EXP__ (-307)
+// AARCH64-MSVC: #define __LDBL_MIN_EXP__ (-1021)
+// AARCH64-MSVC: #define __LDBL_MIN__ 2.2250738585072014e-308L
+// AARCH64-MSVC: #define __LITTLE_ENDIAN__ 1
+// AARCH64-MSVC: #define __LONG_LONG_MAX__ 9223372036854775807LL
+// AARCH64-MSVC: #define __LONG_MAX__ 2147483647L
+// AARCH64-MSV

[PATCH] D36112: [ubsan] Have -fsanitize=vptr emit a null check if -fsanitize=null isn't available

2017-07-31 Thread Vedant Kumar via Phabricator via cfe-commits
vsk created this revision.

In r309007, I made -fsanitize=null a hard prerequisite for -fsanitize=vptr. I 
did not see the need for the two checks to have separate null checking logic 
for the same pointer. I expected the two checks to either always be enabled 
together, or to be mutually compatible.

In the mailing list discussion re: r309007 it became clear that that isn't the 
case. If a codebase is -fsanitize=vptr clean but not -fsanitize=null clean, 
it's useful to have -fsanitize=vptr emit its own null check. That's what this 
patch does: with it, -fsanitize=vptr can be used without -fsanitize=null.


https://reviews.llvm.org/D36112

Files:
  docs/ReleaseNotes.rst
  docs/UndefinedBehaviorSanitizer.rst
  include/clang/Basic/DiagnosticDriverKinds.td
  lib/CodeGen/CGExpr.cpp
  lib/Driver/SanitizerArgs.cpp
  test/CodeGenCXX/catch-undef-behavior.cpp
  test/CodeGenCXX/ubsan-type-checks.cpp
  test/Driver/fsanitize.c
  test/Driver/rtti-options.cpp

Index: test/Driver/rtti-options.cpp
===
--- test/Driver/rtti-options.cpp
+++ test/Driver/rtti-options.cpp
@@ -16,14 +16,14 @@
 // Make sure we only error/warn once, when trying to enable vptr and
 // undefined and have -fno-rtti
 // RUN: %clang -### -c -target x86_64-unknown-linux -fsanitize=undefined -fsanitize=vptr -fno-rtti %s 2>&1 | FileCheck -check-prefix=CHECK-SAN-ERROR -check-prefix=CHECK-OK %s
-// RUN: %clang -### -c -target x86_64-unknown-linux -fsanitize=null,vptr %s 2>&1 | FileCheck -check-prefix=CHECK-OK %s
-// RUN: %clang -### -c -target x86_64-unknown-linux -fsanitize=null,vptr -frtti %s 2>&1 | FileCheck -check-prefix=CHECK-OK %s
-// RUN: %clang -### -c -target x86_64-unknown-linux -fsanitize=null,vptr -fno-rtti %s 2>&1 | FileCheck -check-prefix=CHECK-SAN-ERROR %s
+// RUN: %clang -### -c -target x86_64-unknown-linux -fsanitize=vptr %s 2>&1 | FileCheck -check-prefix=CHECK-OK %s
+// RUN: %clang -### -c -target x86_64-unknown-linux -fsanitize=vptr -frtti %s 2>&1 | FileCheck -check-prefix=CHECK-OK %s
+// RUN: %clang -### -c -target x86_64-unknown-linux -fsanitize=vptr -fno-rtti %s 2>&1 | FileCheck -check-prefix=CHECK-SAN-ERROR %s
 // RUN: %clang -### -c -target x86_64-unknown-linux -fsanitize=undefined %s 2>&1 | FileCheck -check-prefix=CHECK-OK %s
 // RUN: %clang -### -c -target x86_64-unknown-linux -fsanitize=undefined -frtti %s 2>&1 | FileCheck -check-prefix=CHECK-OK %s
-// RUN: %clang -### -c -target x86_64-scei-ps4 -fsanitize=null,vptr %s 2>&1 | FileCheck -check-prefix=CHECK-SAN-WARN %s
-// RUN: %clang -### -c -target x86_64-scei-ps4 -fsanitize=null,vptr -frtti %s 2>&1 | FileCheck -check-prefix=CHECK-OK %s
-// RUN: %clang -### -c -target x86_64-scei-ps4 -fsanitize=null,vptr -fno-rtti %s 2>&1 | FileCheck -check-prefix=CHECK-SAN-ERROR %s
+// RUN: %clang -### -c -target x86_64-scei-ps4 -fsanitize=vptr %s 2>&1 | FileCheck -check-prefix=CHECK-SAN-WARN %s
+// RUN: %clang -### -c -target x86_64-scei-ps4 -fsanitize=vptr -frtti %s 2>&1 | FileCheck -check-prefix=CHECK-OK %s
+// RUN: %clang -### -c -target x86_64-scei-ps4 -fsanitize=vptr -fno-rtti %s 2>&1 | FileCheck -check-prefix=CHECK-SAN-ERROR %s
 // RUN: %clang -### -c -target x86_64-scei-ps4 -fsanitize=undefined -frtti %s 2>&1 | FileCheck -check-prefix=CHECK-OK %s
 
 // Exceptions + no/default rtti
Index: test/Driver/fsanitize.c
===
--- test/Driver/fsanitize.c
+++ test/Driver/fsanitize.c
@@ -58,10 +58,6 @@
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=undefined -fno-rtti %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-UNDEFINED-NO-RTTI
 // CHECK-UNDEFINED-NO-RTTI-NOT: vptr
 
-// RUN: %clang -target x86_64-linux-gnu -fsanitize=undefined -fno-sanitize=null %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-VPTR-NO-NULL
-// RUN: %clang -target x86_64-linux-gnu -fsanitize=vptr %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-VPTR-NO-NULL
-// CHECK-VPTR-NO-NULL: warning: implicitly disabling vptr sanitizer because null checking wasn't enabled
-
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=address,thread -fno-rtti %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SANA-SANT
 // CHECK-SANA-SANT: '-fsanitize=address' not allowed with '-fsanitize=thread'
 
@@ -366,8 +362,8 @@
 // RUN: %clang -target x86_64-apple-darwin10 -mmacosx-version-min=10.8 -fsanitize=vptr %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-VPTR-DARWIN-OLD
 // CHECK-VPTR-DARWIN-OLD: unsupported option '-fsanitize=vptr' for target 'x86_64-apple-darwin10'
 
-// RUN: %clang -target x86_64-apple-darwin10 -mmacosx-version-min=10.9 -fsanitize=alignment,null,vptr %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-VPTR-DARWIN-NEW
-// CHECK-VPTR-DARWIN-NEW: -fsanitize=alignment,null,vptr
+// RUN: %clang -target x86_64-apple-darwin10 -mmacosx-version-min=10.9 -fsanitize=alignment,vptr %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-VPTR-DARWIN-NEW
+// CHECK-VPTR-DARWIN-NEW: -fsanitize=alignment,vptr
 
 // RUN: %clang -ta

[PATCH] D36096: [ubsan] Make the 'vptr check disabled' warning more helpful

2017-07-31 Thread Vedant Kumar via Phabricator via cfe-commits
vsk abandoned this revision.
vsk added a comment.

Abandoned in favor of https://reviews.llvm.org/D36112, since it turns out 
-fsanitize=null,vptr doesn't work for some use cases.


https://reviews.llvm.org/D36096



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


r309622 - Fix logic for generating llvm.type.test()s

2017-07-31 Thread Peter Collingbourne via cfe-commits
Author: pcc
Date: Mon Jul 31 13:45:14 2017
New Revision: 309622

URL: http://llvm.org/viewvc/llvm-project?rev=309622&view=rev
Log:
Fix logic for generating llvm.type.test()s

CodeGenFunction::EmitTypeMetadataCodeForVCall() could output an
llvm.assume(llvm.type.test())when CFI was enabled, optimizing out the
vcall check. This case was only reached when: 1) CFI-vcall was enabled,
2) -fwhole-program-tables was specified, and 3)
-fno-sanitize-trap=cfi-vcall was specified.

Patch by Vlad Tsyrklevich!

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

Added:
cfe/trunk/test/CodeGenCXX/cfi-vcall-no-trap.cpp
Modified:
cfe/trunk/lib/CodeGen/CGClass.cpp

Modified: cfe/trunk/lib/CodeGen/CGClass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGClass.cpp?rev=309622&r1=309621&r2=309622&view=diff
==
--- cfe/trunk/lib/CodeGen/CGClass.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGClass.cpp Mon Jul 31 13:45:14 2017
@@ -2523,8 +2523,10 @@ LeastDerivedClassWithSameLayout(const CX
 void CodeGenFunction::EmitTypeMetadataCodeForVCall(const CXXRecordDecl *RD,
llvm::Value *VTable,
SourceLocation Loc) {
-  if (CGM.getCodeGenOpts().WholeProgramVTables &&
-  CGM.HasHiddenLTOVisibility(RD)) {
+  if (SanOpts.has(SanitizerKind::CFIVCall))
+EmitVTablePtrCheckForCall(RD, VTable, CodeGenFunction::CFITCK_VCall, Loc);
+  else if (CGM.getCodeGenOpts().WholeProgramVTables &&
+   CGM.HasHiddenLTOVisibility(RD)) {
 llvm::Metadata *MD =
 CGM.CreateMetadataIdentifierForType(QualType(RD->getTypeForDecl(), 0));
 llvm::Value *TypeId =
@@ -2536,9 +2538,6 @@ void CodeGenFunction::EmitTypeMetadataCo
{CastedVTable, TypeId});
 Builder.CreateCall(CGM.getIntrinsic(llvm::Intrinsic::assume), TypeTest);
   }
-
-  if (SanOpts.has(SanitizerKind::CFIVCall))
-EmitVTablePtrCheckForCall(RD, VTable, CodeGenFunction::CFITCK_VCall, Loc);
 }
 
 void CodeGenFunction::EmitVTablePtrCheckForCall(const CXXRecordDecl *RD,

Added: cfe/trunk/test/CodeGenCXX/cfi-vcall-no-trap.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/cfi-vcall-no-trap.cpp?rev=309622&view=auto
==
--- cfe/trunk/test/CodeGenCXX/cfi-vcall-no-trap.cpp (added)
+++ cfe/trunk/test/CodeGenCXX/cfi-vcall-no-trap.cpp Mon Jul 31 13:45:14 2017
@@ -0,0 +1,15 @@
+// Only output llvm.assume(llvm.type.test()) if cfi-vcall is disabled and 
whole-program-vtables is enabled
+// RUN: %clang_cc1 -fvisibility hidden -fsanitize=cfi-vcall 
-fwhole-program-vtables -emit-llvm -o - %s | FileCheck --check-prefix=CHECK 
--check-prefix=CFI %s
+// RUN: %clang_cc1 -fvisibility hidden -fwhole-program-vtables -emit-llvm -o - 
%s | FileCheck --check-prefix=CHECK --check-prefix=NOCFI %s
+
+struct S1 {
+  virtual void f();
+};
+
+// CHECK: define{{.*}}s1f
+// CHECK: llvm.type.test
+// CFI-NOT: llvm.assume
+// NOCFI: llvm.assume
+void s1f(S1 *s1) {
+  s1->f();
+}


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


[PATCH] D36013: Fix logic for generating llvm.type.test()s

2017-07-31 Thread Peter Collingbourne via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL309622: Fix logic for generating llvm.type.test()s (authored 
by pcc).

Changed prior to commit:
  https://reviews.llvm.org/D36013?vs=108702&id=108994#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D36013

Files:
  cfe/trunk/lib/CodeGen/CGClass.cpp
  cfe/trunk/test/CodeGenCXX/cfi-vcall-no-trap.cpp


Index: cfe/trunk/lib/CodeGen/CGClass.cpp
===
--- cfe/trunk/lib/CodeGen/CGClass.cpp
+++ cfe/trunk/lib/CodeGen/CGClass.cpp
@@ -2523,8 +2523,10 @@
 void CodeGenFunction::EmitTypeMetadataCodeForVCall(const CXXRecordDecl *RD,
llvm::Value *VTable,
SourceLocation Loc) {
-  if (CGM.getCodeGenOpts().WholeProgramVTables &&
-  CGM.HasHiddenLTOVisibility(RD)) {
+  if (SanOpts.has(SanitizerKind::CFIVCall))
+EmitVTablePtrCheckForCall(RD, VTable, CodeGenFunction::CFITCK_VCall, Loc);
+  else if (CGM.getCodeGenOpts().WholeProgramVTables &&
+   CGM.HasHiddenLTOVisibility(RD)) {
 llvm::Metadata *MD =
 CGM.CreateMetadataIdentifierForType(QualType(RD->getTypeForDecl(), 0));
 llvm::Value *TypeId =
@@ -2536,9 +2538,6 @@
{CastedVTable, TypeId});
 Builder.CreateCall(CGM.getIntrinsic(llvm::Intrinsic::assume), TypeTest);
   }
-
-  if (SanOpts.has(SanitizerKind::CFIVCall))
-EmitVTablePtrCheckForCall(RD, VTable, CodeGenFunction::CFITCK_VCall, Loc);
 }
 
 void CodeGenFunction::EmitVTablePtrCheckForCall(const CXXRecordDecl *RD,
Index: cfe/trunk/test/CodeGenCXX/cfi-vcall-no-trap.cpp
===
--- cfe/trunk/test/CodeGenCXX/cfi-vcall-no-trap.cpp
+++ cfe/trunk/test/CodeGenCXX/cfi-vcall-no-trap.cpp
@@ -0,0 +1,15 @@
+// Only output llvm.assume(llvm.type.test()) if cfi-vcall is disabled and 
whole-program-vtables is enabled
+// RUN: %clang_cc1 -fvisibility hidden -fsanitize=cfi-vcall 
-fwhole-program-vtables -emit-llvm -o - %s | FileCheck --check-prefix=CHECK 
--check-prefix=CFI %s
+// RUN: %clang_cc1 -fvisibility hidden -fwhole-program-vtables -emit-llvm -o - 
%s | FileCheck --check-prefix=CHECK --check-prefix=NOCFI %s
+
+struct S1 {
+  virtual void f();
+};
+
+// CHECK: define{{.*}}s1f
+// CHECK: llvm.type.test
+// CFI-NOT: llvm.assume
+// NOCFI: llvm.assume
+void s1f(S1 *s1) {
+  s1->f();
+}


Index: cfe/trunk/lib/CodeGen/CGClass.cpp
===
--- cfe/trunk/lib/CodeGen/CGClass.cpp
+++ cfe/trunk/lib/CodeGen/CGClass.cpp
@@ -2523,8 +2523,10 @@
 void CodeGenFunction::EmitTypeMetadataCodeForVCall(const CXXRecordDecl *RD,
llvm::Value *VTable,
SourceLocation Loc) {
-  if (CGM.getCodeGenOpts().WholeProgramVTables &&
-  CGM.HasHiddenLTOVisibility(RD)) {
+  if (SanOpts.has(SanitizerKind::CFIVCall))
+EmitVTablePtrCheckForCall(RD, VTable, CodeGenFunction::CFITCK_VCall, Loc);
+  else if (CGM.getCodeGenOpts().WholeProgramVTables &&
+   CGM.HasHiddenLTOVisibility(RD)) {
 llvm::Metadata *MD =
 CGM.CreateMetadataIdentifierForType(QualType(RD->getTypeForDecl(), 0));
 llvm::Value *TypeId =
@@ -2536,9 +2538,6 @@
{CastedVTable, TypeId});
 Builder.CreateCall(CGM.getIntrinsic(llvm::Intrinsic::assume), TypeTest);
   }
-
-  if (SanOpts.has(SanitizerKind::CFIVCall))
-EmitVTablePtrCheckForCall(RD, VTable, CodeGenFunction::CFITCK_VCall, Loc);
 }
 
 void CodeGenFunction::EmitVTablePtrCheckForCall(const CXXRecordDecl *RD,
Index: cfe/trunk/test/CodeGenCXX/cfi-vcall-no-trap.cpp
===
--- cfe/trunk/test/CodeGenCXX/cfi-vcall-no-trap.cpp
+++ cfe/trunk/test/CodeGenCXX/cfi-vcall-no-trap.cpp
@@ -0,0 +1,15 @@
+// Only output llvm.assume(llvm.type.test()) if cfi-vcall is disabled and whole-program-vtables is enabled
+// RUN: %clang_cc1 -fvisibility hidden -fsanitize=cfi-vcall -fwhole-program-vtables -emit-llvm -o - %s | FileCheck --check-prefix=CHECK --check-prefix=CFI %s
+// RUN: %clang_cc1 -fvisibility hidden -fwhole-program-vtables -emit-llvm -o - %s | FileCheck --check-prefix=CHECK --check-prefix=NOCFI %s
+
+struct S1 {
+  virtual void f();
+};
+
+// CHECK: define{{.*}}s1f
+// CHECK: llvm.type.test
+// CFI-NOT: llvm.assume
+// NOCFI: llvm.assume
+void s1f(S1 *s1) {
+  s1->f();
+}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


  1   2   >