[PATCH] D38835: [refactor] selection: new CodeRangeASTSelection represents a set of selected consecu

2017-10-11 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman created this revision.

Repository:
  rL LLVM

https://reviews.llvm.org/D38835

Files:
  include/clang/Tooling/Refactoring/ASTSelection.h
  lib/Tooling/Refactoring/ASTSelection.cpp
  unittests/Tooling/ASTSelectionTest.cpp

Index: unittests/Tooling/ASTSelectionTest.cpp
===
--- unittests/Tooling/ASTSelectionTest.cpp
+++ unittests/Tooling/ASTSelectionTest.cpp
@@ -29,12 +29,16 @@
 class SelectionFinderVisitor : public TestVisitor {
   FileLocation Location;
   Optional SelectionRange;
-  llvm::function_ref Consumer;
+  llvm::function_ref
+  Consumer;
 
 public:
-  SelectionFinderVisitor(
-  FileLocation Location, Optional SelectionRange,
-  llvm::function_ref Consumer)
+  SelectionFinderVisitor(FileLocation Location,
+ Optional SelectionRange,
+ llvm::function_ref
+ Consumer)
   : Location(Location), SelectionRange(SelectionRange), Consumer(Consumer) {
   }
 
@@ -50,20 +54,35 @@
   SourceLocation Loc = Location.translate(SM);
   SelRange = SourceRange(Loc, Loc);
 }
-Consumer(findSelectedASTNodes(Context, SelRange));
+Consumer(SelRange, findSelectedASTNodes(Context, SelRange));
 return false;
   }
 };
 
-void findSelectedASTNodes(
+void findSelectedASTNodesWithRange(
 StringRef Source, FileLocation Location, Optional SelectionRange,
-llvm::function_ref Consumer,
+llvm::function_ref
+Consumer,
 SelectionFinderVisitor::Language Language =
 SelectionFinderVisitor::Lang_CXX11) {
   SelectionFinderVisitor Visitor(Location, SelectionRange, Consumer);
   EXPECT_TRUE(Visitor.runOver(Source, Language));
 }
 
+void findSelectedASTNodes(
+StringRef Source, FileLocation Location, Optional SelectionRange,
+llvm::function_ref Consumer,
+SelectionFinderVisitor::Language Language =
+SelectionFinderVisitor::Lang_CXX11) {
+  findSelectedASTNodesWithRange(
+  Source, Location, SelectionRange,
+  [&](SourceRange, Optional Selection) {
+Consumer(std::move(Selection));
+  },
+  Language);
+}
+
 void checkNodeImpl(bool IsTypeMatched, const SelectedASTNode ,
SourceSelectionKind SelectionKind, unsigned NumChildren) {
   ASSERT_TRUE(IsTypeMatched);
@@ -649,4 +668,103 @@
   SelectionFinderVisitor::Lang_OBJC);
 }
 
+TEST(ASTSelectionFinder, SimpleCodeRangeASTSelection) {
+  StringRef Source = R"(void f(int x, int y) {
+  int z = x;
+  f(2, 3);
+  if (x == 0) {
+return;
+  }
+  x = 1;
+  return;
+}
+void f2() {
+  int m = 0;
+}
+)";
+  // Empty range is an invalid code range.
+  findSelectedASTNodesWithRange(
+  Source, {2, 2}, None,
+  [](SourceRange SelectionRange, Optional Node) {
+EXPECT_TRUE(Node);
+Optional SelectedCode =
+CodeRangeASTSelection::create(SelectionRange, std::move(*Node));
+EXPECT_FALSE(SelectedCode);
+  });
+  // Range that spans multiple functions is an invalid code range.
+  findSelectedASTNodesWithRange(
+  Source, {2, 2}, FileRange{{7, 2}, {12, 1}},
+  [](SourceRange SelectionRange, Optional Node) {
+EXPECT_TRUE(Node);
+Optional SelectedCode =
+CodeRangeASTSelection::create(SelectionRange, std::move(*Node));
+EXPECT_FALSE(SelectedCode);
+  });
+  // Just 'z = x;':
+  findSelectedASTNodesWithRange(
+  Source, {2, 2}, FileRange{{2, 2}, {2, 13}},
+  [](SourceRange SelectionRange, Optional Node) {
+EXPECT_TRUE(Node);
+Optional SelectedCode =
+CodeRangeASTSelection::create(SelectionRange, std::move(*Node));
+EXPECT_TRUE(SelectedCode);
+EXPECT_EQ(SelectedCode->size(), 1u);
+EXPECT_TRUE(isa((*SelectedCode)[0]));
+ArrayRef Parents =
+SelectedCode->getParents();
+EXPECT_EQ(Parents.size(), 3u);
+EXPECT_TRUE(
+isa(Parents[0].get().Node.get()));
+EXPECT_TRUE(isa(Parents[1].get().Node.get()));
+EXPECT_TRUE(isa(Parents[2].get().Node.get()));
+  });
+  // From 'f(2,3)' until just before 'x = 1;':
+  findSelectedASTNodesWithRange(
+  Source, {3, 2}, FileRange{{3, 2}, {7, 1}},
+  [](SourceRange SelectionRange, Optional Node) {
+EXPECT_TRUE(Node);
+Optional SelectedCode =
+CodeRangeASTSelection::create(SelectionRange, std::move(*Node));
+EXPECT_TRUE(SelectedCode);
+EXPECT_EQ(SelectedCode->size(), 2u);
+EXPECT_TRUE(isa((*SelectedCode)[0]));
+EXPECT_TRUE(isa((*SelectedCode)[1]));
+ArrayRef Parents =
+SelectedCode->getParents();
+

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

2017-10-11 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo added a comment.

In https://reviews.llvm.org/D38821#895527, @compnerd wrote:

> Don't you need a change to the intrinsics to actually map the builtin?


Apparently, this change is all that's needed since the tests pass. I can of 
course try to look closer and see what actually makes it work.


https://reviews.llvm.org/D38821



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


[PATCH] D38680: [libunwind] Fix handling of DW_CFA_GNU_args_size

2017-10-11 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo added inline comments.



Comment at: src/libunwind.cpp:188
+  co->getInfo();
+  pint_t orgArgSize = (pint_t)info.gp;
+  uint64_t orgFuncStart = info.start_ip;

rnk wrote:
> I think it makes sense to have this here: the contract is that if the 
> personality sets the IP when the cursor pointed to a PC with a non-zero arg 
> size, we should adjust SP for the personality.
> 
> However, it's not clear to me that we don't need the same adjustment when 
> stepping across frames that use arg size without a frame pointer.
When stepping across frames, the gnu args size is already included in, as part 
of the CFA offset, so with the current code, it steps too far.


https://reviews.llvm.org/D38680



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


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

2017-10-11 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd added a comment.

Don't you need a change to the intrinsics to actually map the builtin?


https://reviews.llvm.org/D38821



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


r315547 - [X86] Remove a few unnecessary check lines from the predefined-arch-macros test.

2017-10-11 Thread Craig Topper via cfe-commits
Author: ctopper
Date: Wed Oct 11 19:06:17 2017
New Revision: 315547

URL: http://llvm.org/viewvc/llvm-project?rev=315547=rev
Log:
[X86] Remove a few unnecessary check lines from the predefined-arch-macros test.

These were testing OS macros and clang/llvm macros.

Modified:
cfe/trunk/test/Preprocessor/predefined-arch-macros.c

Modified: cfe/trunk/test/Preprocessor/predefined-arch-macros.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/predefined-arch-macros.c?rev=315547=315546=315547=diff
==
--- cfe/trunk/test/Preprocessor/predefined-arch-macros.c (original)
+++ cfe/trunk/test/Preprocessor/predefined-arch-macros.c Wed Oct 11 19:06:17 
2017
@@ -1011,20 +1011,12 @@
 // CHECK_GLM_M32: #define __XSAVEOPT__ 1
 // CHECK_GLM_M32: #define __XSAVES__ 1
 // CHECK_GLM_M32: #define __XSAVE__ 1
-// CHECK_GLM_M32: #define __clang__ 1
 // CHECK_GLM_M32: #define __goldmont 1
 // CHECK_GLM_M32: #define __goldmont__ 1
 // CHECK_GLM_M32: #define __i386 1
 // CHECK_GLM_M32: #define __i386__ 1
-// CHECK_GLM_M32: #define __linux 1
-// CHECK_GLM_M32: #define __linux__ 1
-// CHECK_GLM_M32: #define __llvm__ 1
 // CHECK_GLM_M32: #define __tune_goldmont__ 1
-// CHECK_GLM_M32: #define __unix 1
-// CHECK_GLM_M32: #define __unix__ 1
 // CHECK_GLM_M32: #define i386 1
-// CHECK_GLM_M32: #define linux 1
-// CHECK_GLM_M32: #define unix 1
 //
 // RUN: %clang -march=goldmont -m64 -E -dM %s -o - 2>&1 \
 // RUN: -target i386-unknown-linux \
@@ -1049,19 +1041,11 @@
 // CHECK_GLM_M64: #define __XSAVEOPT__ 1
 // CHECK_GLM_M64: #define __XSAVES__ 1
 // CHECK_GLM_M64: #define __XSAVE__ 1
-// CHECK_GLM_M64: #define __gnu_linux__ 1
 // CHECK_GLM_M64: #define __goldmont 1
 // CHECK_GLM_M64: #define __goldmont__ 1
-// CHECK_GLM_M64: #define __linux 1
-// CHECK_GLM_M64: #define __linux__ 1
-// CHECK_GLM_M64: #define __llvm__ 1
 // CHECK_GLM_M64: #define __tune_goldmont__ 1
-// CHECK_GLM_M64: #define __unix 1
-// CHECK_GLM_M64: #define __unix__ 1
 // CHECK_GLM_M64: #define __x86_64 1
 // CHECK_GLM_M64: #define __x86_64__ 1
-// CHECK_GLM_M64: #define linux 1
-// CHECK_GLM_M64: #define unix 1
 //
 // RUN: %clang -march=slm -m32 -E -dM %s -o - 2>&1 \
 // RUN: -target i386-unknown-linux \


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


[PATCH] D38101: [Sema] Diagnose tautological comparison with type's min/max values

2017-10-11 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added inline comments.



Comment at: lib/Sema/SemaChecking.cpp:8667-8679
+  bool Result; // The result of the comparison
+  if ((Op == BO_GT && ValueType == LimitType::Max && ConstOnRight) ||
+  (Op == BO_GT && ValueType == LimitType::Min && !ConstOnRight) ||
+  (Op == BO_LT && ValueType == LimitType::Max && !ConstOnRight) ||
+  (Op == BO_LT && ValueType == LimitType::Min && ConstOnRight)) {
+Result = false;
+  } else if ((Op == BO_GE && ValueType == LimitType::Max && !ConstOnRight) ||

The exhaustive case analysis is a little hard to verify. Perhaps something like 
this would be clearer:

```
bool ConstIsLowerBound = (Op == BO_LT || Op == BO_LE) ^ ConstOnRight;
bool ResultWhenConstEqualsOther = (Op == BO_LE || Op == BO_GE);
bool ResultWhenConstNeOther = ConstIsLowerBound ^ ValueType == LimitType::Max;
if (ResultWhenConstEqualsOther != ResultWhenConstNeOther)
  return false;
```



Comment at: lib/Sema/SemaChecking.cpp:8940
+  } else if (!T->hasUnsignedIntegerRepresentation())
+IsComparisonConstant = E->isIntegerConstantExpr(S.Context);
+

It seems suboptimal to evaluate both sides of the comparison and then evaluate 
the entire comparison again in this case. Presumably the point is to catch 
comparisons whose operands are not of integral type (eg, floating point), but 
we could get that benefit and also catch more integral cases by switching from 
`isIntegerConstantExpr` to the more appropriate `EvaluateAsRValue`.

I'm fine with a cleanup to avoid the repeated evaluation here being deferred to 
a later patch.



Comment at: lib/Sema/SemaChecking.cpp:8949
+  if (T->isIntegralType(S.Context)) {
+if (CheckTautologicalComparison(S, E))
+  return AnalyzeImpConvsInComparison(S, E);

Pass `LHSValue` and `RHSValue` in here rather than recomputing them.



Comment at: test/Sema/tautological-constant-compare.c:1-4
+// RUN: %clang_cc1 -fsyntax-only -DTEST -verify %s
+// RUN: %clang_cc1 -fsyntax-only -Wno-tautological-constant-compare -verify %s
+// RUN: %clang_cc1 -fsyntax-only -DTEST -verify -x c++ %s
+// RUN: %clang_cc1 -fsyntax-only -Wno-tautological-constant-compare -verify -x 
c++ %s

This test makes assumptions about the valid ranges of certain built-in types, 
so should specify a target triple. (Eg, `-triple x86_64-linux-gnu`)


Repository:
  rL LLVM

https://reviews.llvm.org/D38101



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


r315536 - Revert "[ADT] Make Twine's copy constructor private."

2017-10-11 Thread Zachary Turner via cfe-commits
Author: zturner
Date: Wed Oct 11 16:54:34 2017
New Revision: 315536

URL: http://llvm.org/viewvc/llvm-project?rev=315536=rev
Log:
Revert "[ADT] Make Twine's copy constructor private."

This reverts commit 4e4ee1c507e2707bb3c208e1e1b6551c3015cbf5.

This is failing due to some code that isn't built on MSVC
so I didn't catch.  Not immediately obvious how to fix this
at first glance, so I'm reverting for now.

Modified:
cfe/trunk/include/clang/Tooling/CompilationDatabase.h
cfe/trunk/lib/CodeGen/CGObjCMac.cpp
cfe/trunk/lib/CodeGen/CodeGenAction.cpp
cfe/trunk/lib/Driver/ToolChains/MSVC.cpp
cfe/trunk/lib/Driver/ToolChains/MinGW.cpp
cfe/trunk/lib/Tooling/CompilationDatabase.cpp
cfe/trunk/unittests/Tooling/TestVisitor.h

Modified: cfe/trunk/include/clang/Tooling/CompilationDatabase.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Tooling/CompilationDatabase.h?rev=315536=315535=315536=diff
==
--- cfe/trunk/include/clang/Tooling/CompilationDatabase.h (original)
+++ cfe/trunk/include/clang/Tooling/CompilationDatabase.h Wed Oct 11 16:54:34 
2017
@@ -42,10 +42,12 @@ namespace tooling {
 /// \brief Specifies the working directory and command of a compilation.
 struct CompileCommand {
   CompileCommand() {}
-  CompileCommand(const Twine , const Twine ,
- std::vector CommandLine, const Twine )
-  : Directory(Directory.str()), Filename(Filename.str()),
-CommandLine(std::move(CommandLine)), Output(Output.str()) {}
+  CompileCommand(Twine Directory, Twine Filename,
+ std::vector CommandLine, Twine Output)
+  : Directory(Directory.str()),
+Filename(Filename.str()),
+CommandLine(std::move(CommandLine)),
+Output(Output.str()){}
 
   /// \brief The working directory the command was executed from.
   std::string Directory;
@@ -176,14 +178,13 @@ public:
   /// \param Argv Points to the command line arguments.
   /// \param ErrorMsg Contains error text if the function returns null pointer.
   /// \param Directory The base directory used in the FixedCompilationDatabase.
-  static std::unique_ptr
-  loadFromCommandLine(int , const char *const *Argv, std::string 
,
-  const Twine  = ".");
+  static std::unique_ptr loadFromCommandLine(
+  int , const char *const *Argv, std::string ,
+  Twine Directory = ".");
 
   /// \brief Constructs a compilation data base from a specified directory
   /// and command line.
-  FixedCompilationDatabase(const Twine ,
-   ArrayRef CommandLine);
+  FixedCompilationDatabase(Twine Directory, ArrayRef CommandLine);
 
   /// \brief Returns the given compile command.
   ///

Modified: cfe/trunk/lib/CodeGen/CGObjCMac.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjCMac.cpp?rev=315536=315535=315536=diff
==
--- cfe/trunk/lib/CodeGen/CGObjCMac.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGObjCMac.cpp Wed Oct 11 16:54:34 2017
@@ -981,17 +981,17 @@ protected:
 
   /// EmitPropertyList - Emit the given property list. The return
   /// value has type PropertyListPtrTy.
-  llvm::Constant *EmitPropertyList(const Twine , const Decl *Container,
+  llvm::Constant *EmitPropertyList(Twine Name,
+   const Decl *Container,
const ObjCContainerDecl *OCD,
const ObjCCommonTypesHelper ,
bool IsClassProperty);
 
   /// EmitProtocolMethodTypes - Generate the array of extended method type 
   /// strings. The return value has type Int8PtrPtrTy.
-  llvm::Constant *
-  EmitProtocolMethodTypes(const Twine ,
-  ArrayRef MethodTypes,
-  const ObjCCommonTypesHelper );
+  llvm::Constant *EmitProtocolMethodTypes(Twine Name, 
+  ArrayRef 
MethodTypes,
+   const ObjCCommonTypesHelper );
 
   /// GetProtocolRef - Return a reference to the internal protocol
   /// description, creating an empty one if it has not been
@@ -1021,11 +1021,11 @@ public:
   /// \param Align - The alignment for the variable, or 0.
   /// \param AddToUsed - Whether the variable should be added to
   ///   "llvm.used".
-  llvm::GlobalVariable *CreateMetadataVar(const Twine ,
+  llvm::GlobalVariable *CreateMetadataVar(Twine Name,
   ConstantStructBuilder ,
   StringRef Section, CharUnits Align,
   bool AddToUsed);
-  llvm::GlobalVariable *CreateMetadataVar(const Twine ,
+  llvm::GlobalVariable *CreateMetadataVar(Twine Name,
   llvm::Constant *Init,
   StringRef 

[PATCH] D38831: [libcxx] P0604, invoke_result and is_invocable

2017-10-11 Thread Agustín Bergé via Phabricator via cfe-commits
K-ballo created this revision.

Introduce a new form of `result_of` without function type encoding.

Rename and split `is_callable/is_nothrow_callable` into 
`is_invocable/is_nothrow_invocable/is_invocable_r/is_nothrow_invocable_r` (and 
associated types accordingly)

Change function type encoding of previous `is_callable/is_nothrow_callable` 
traits to conventional template type parameter lists.


https://reviews.llvm.org/D38831

Files:
  include/type_traits
  include/variant
  test/std/utilities/function.objects/func.not_fn/not_fn.pass.cpp
  test/std/utilities/function.objects/unord.hash/non_enum.pass.cpp
  test/std/utilities/meta/meta.rel/is_callable.pass.cpp
  test/std/utilities/meta/meta.rel/is_invocable.pass.cpp
  test/std/utilities/meta/meta.rel/is_nothrow_callable.pass.cpp
  test/std/utilities/meta/meta.rel/is_nothrow_invocable.pass.cpp
  test/std/utilities/meta/meta.trans/meta.trans.other/result_of.pass.cpp
  test/std/utilities/meta/meta.trans/meta.trans.other/result_of11.pass.cpp

Index: test/std/utilities/meta/meta.trans/meta.trans.other/result_of11.pass.cpp
===
--- test/std/utilities/meta/meta.trans/meta.trans.other/result_of11.pass.cpp
+++ test/std/utilities/meta/meta.trans/meta.trans.other/result_of11.pass.cpp
@@ -27,6 +27,23 @@
 struct F {};
 struct FD : public F {};
 
+#if TEST_STD_VER > 14
+template 
+struct test_invoke_result;
+
+template 
+struct test_invoke_result
+{
+static void call()
+{
+static_assert(std::is_invocable::value, "");
+static_assert(std::is_invocable_r::value, "");
+static_assert((std::is_same::type, Ret>::value), "");
+static_assert((std::is_same, Ret>::value), "");
+}
+};
+#endif
+
 template 
 void test_result_of_imp()
 {
@@ -35,8 +52,7 @@
 static_assert((std::is_same::value), "");
 #endif
 #if TEST_STD_VER > 14
-static_assert(std::is_callable::value, "");
-static_assert(std::is_callable::value, "");
+test_invoke_result::call();
 #endif
 }
 
Index: test/std/utilities/meta/meta.trans/meta.trans.other/result_of.pass.cpp
===
--- test/std/utilities/meta/meta.trans/meta.trans.other/result_of.pass.cpp
+++ test/std/utilities/meta/meta.trans/meta.trans.other/result_of.pass.cpp
@@ -42,16 +42,46 @@
 template 
 struct HasType : std::true_type {};
 
+#if TEST_STD_VER > 14
+template 
+struct test_invoke_result;
+
+template 
+struct test_invoke_result
+{
+static void call()
+{
+static_assert(std::is_invocable::value, "");
+static_assert(std::is_invocable_r::value, "");
+static_assert((std::is_same::type, Ret>::value), "");
+}
+};
+#endif
+
 template 
 void test_result_of()
 {
+static_assert((std::is_same::type, U>::value), "");
 #if TEST_STD_VER > 14
-static_assert(std::is_callable::value, "");
-static_assert(std::is_callable::value, "");
+test_invoke_result::call();
 #endif
-static_assert((std::is_same::type, U>::value), "");
 }
 
+#if TEST_STD_VER > 14
+template 
+struct test_invoke_no_result;
+
+template 
+struct test_invoke_no_result
+{
+static void call()
+{
+static_assert(std::is_invocable::value == false, "");
+static_assert((!HasType >::value), "");
+}
+};
+#endif
+
 template 
 void test_no_result()
 {
@@ -59,7 +89,7 @@
 static_assert((!HasType::value), "");
 #endif
 #if TEST_STD_VER > 14
-static_assert(std::is_callable::value == false, "");
+test_invoke_no_result::call();
 #endif
 }
 
Index: test/std/utilities/meta/meta.rel/is_nothrow_invocable.pass.cpp
===
--- /dev/null
+++ test/std/utilities/meta/meta.rel/is_nothrow_invocable.pass.cpp
@@ -0,0 +1,121 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// UNSUPPORTED: c++98, c++03, c++11, c++14
+
+// type_traits
+
+// is_nothrow_invocable
+
+#include 
+#include 
+
+#include "test_macros.h"
+
+struct Tag {};
+
+struct Implicit {
+  Implicit(int) noexcept {}
+};
+
+struct ThrowsImplicit {
+  ThrowsImplicit(int) {}
+};
+
+struct Explicit {
+  explicit Explicit(int) noexcept {}
+};
+
+template 
+struct CallObject {
+  Ret operator()(Args&&...) const noexcept(IsNoexcept);
+};
+
+template 
+constexpr bool throws_invocable() {
+return std::is_invocable::value &&
+

Buildbot numbers for the last week of 10/1/2017 - 10/7/2017

2017-10-11 Thread Galina Kistanova via cfe-commits
Hello everyone,

Below are some buildbot numbers for the last week of 10/1/2017 - 10/7/2017.

Please see the same data in attached csv files:

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

Thanks

Galina


The longest time each builder was red during the week:

  buildername  | was_red
---+-
 sanitizer-x86_64-linux-bootstrap  | 78:03:54
 lld-x86_64-win7   | 69:09:59
 clang-cmake-armv7-a15-selfhost-neon   | 65:44:08
 sanitizer-x86_64-linux| 25:13:47
 clang-with-thin-lto-windows   | 24:59:05
 clang-with-thin-lto-ubuntu| 24:44:08
 libcxx-libcxxabi-libunwind-aarch64-linux-noexceptions | 22:13:47
 sanitizer-windows | 21:25:59
 sanitizer-x86_64-linux-fast   | 21:20:26
 aosp-O3-polly-before-vectorizer-unprofitable  | 20:57:27
 lldb-windows7-android | 20:28:12
 lldb-x86_64-darwin-13.4   | 20:27:12
 clang-cmake-aarch64-global-isel   | 18:09:29
 clang-cmake-aarch64-quick | 18:05:17
 libcxx-libcxxabi-x86_64-linux-debian-noexceptions | 17:57:43
 clang-cmake-aarch64-full  | 16:48:25
 clang-x86-windows-msvc2015| 16:17:39
 clang-cmake-aarch64-lld   | 16:03:10
 llvm-clang-x86_64-expensive-checks-win| 09:54:55
 clang-x64-ninja-win7  | 09:13:33
 polly-amd64-linux | 07:54:18
 clang-cmake-thumbv7-a15-full-sh   | 07:53:35
 clang-with-lto-ubuntu | 07:33:01
 lld-x86_64-darwin13   | 07:27:15
 lld-x86_64-freebsd| 07:26:10
 clang-hexagon-elf | 07:00:34
 sanitizer-ppc64be-linux   | 06:22:26
 clang-ppc64be-linux-multistage| 06:06:20
 clang-x86_64-linux-abi-test   | 05:59:22
 clang-cuda-build  | 05:53:47
 clang-cmake-thumbv7-a15   | 05:44:44
 clang-cmake-armv7-a15 | 05:44:10
 clang-ppc64le-linux-lnt   | 05:37:15
 clang-cmake-armv7-a15-full| 05:35:23
 lldb-x86_64-ubuntu-14.04-cmake| 05:33:30
 clang-ppc64le-linux-multistage| 05:30:27
 llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast  | 05:23:50
 clang-ppc64le-linux   | 05:22:18
 clang-cmake-armv7-a15-selfhost| 05:16:07
 llvm-clang-lld-x86_64-debian-fast | 05:05:30
 clang-native-arm-lnt  | 04:51:41
 llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast| 04:46:18
 clang-cmake-x86_64-sde-avx512-linux   | 04:18:33
 llvm-hexagon-elf  | 04:00:23
 llvm-mips-linux   | 03:51:35
 clang-cmake-x86_64-avx2-linux | 03:51:09
 clang-x86_64-linux-selfhost-modules-2 | 03:46:35
 clang-s390x-linux-lnt | 03:44:31
 clang-s390x-linux-multistage  | 03:43:19
 clang-s390x-linux | 03:33:10
 clang-ppc64be-linux-lnt   | 03:32:53
 clang-x86_64-debian-fast  | 03:23:13
 clang-ppc64be-linux   | 03:22:15
 lldb-x86-windows-msvc2015 | 03:15:31
 clang-x86_64-linux-selfhost-modules   | 03:14:30
 ubuntu-gcc7.1-werror  | 02:40:31
 clang-cmake-x86_64-avx2-linux-perf| 02:24:35
 sanitizer-x86_64-linux-android| 02:11:09
 sanitizer-x86_64-linux-autoconf   | 01:59:25
 clang-atom-d525-fedora-rel| 01:49:06
 lldb-amd64-ninja-netbsd8  | 01:25:40
 lldb-x86_64-ubuntu-14.04-buildserver  | 01:03:47
 libcxx-libcxxabi-libunwind-aarch64-linux  | 00:57:23
 lldb-x86_64-ubuntu-14.04-android  | 00:32:28
 

Buildbot numbers for the week of 09/24/2017 - 09/30/2017

2017-10-11 Thread Galina Kistanova via cfe-commits
Hello everyone,

Below are some buildbot numbers for the week of 09/24/2017 - 09/30/2017.

Please see the same data in attached csv files:

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

Thanks

Galina


The longest time each builder was red during the week:

  buildername  |  was_red
---+--
 clang-cmake-mipsel| 118:41:58
 lldb-windows7-android | 113:06:23
 llvm-clang-x86_64-expensive-checks-win| 111:13:05
 clang-cmake-thumbv7-a15-full-sh   | 88:17:13
 clang-cmake-armv7-a15-full| 85:32:13
 libcxx-libcxxabi-libunwind-aarch64-linux-noexceptions | 43:27:02
 clang-x64-ninja-win7  | 25:28:49
 ubuntu-gcc7.1-werror  | 21:44:21
 clang-with-thin-lto-ubuntu| 13:50:57
 sanitizer-x86_64-linux-bootstrap  | 13:42:38
 sanitizer-x86_64-linux| 13:09:18
 clang-x86_64-linux-abi-test   | 12:47:56
 clang-lld-x86_64-2stage   | 12:38:40
 llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast  | 12:00:36
 polly-amd64-linux | 11:50:34
 clang-x86-windows-msvc2015| 11:40:45
 clang-ppc64le-linux-multistage| 11:32:27
 sanitizer-x86_64-linux-fast   | 11:17:27
 polly-arm-linux   | 10:29:45
 libcxx-libcxxabi-libunwind-aarch64-linux  | 09:46:05
 lldb-x86_64-ubuntu-14.04-cmake| 09:20:13
 sanitizer-x86_64-linux-autoconf   | 08:38:21
 clang-with-lto-ubuntu | 08:20:55
 clang-atom-d525-fedora-rel| 08:04:52
 clang-x86_64-linux-selfhost-modules   | 07:48:15
 lldb-x86-windows-msvc2015 | 07:42:51
 clang-x86_64-linux-selfhost-modules-2 | 07:32:46
 lldb-x86_64-ubuntu-14.04-buildserver  | 07:31:06
 lldb-amd64-ninja-netbsd8  | 07:26:02
 sanitizer-x86_64-linux-fuzzer | 07:25:18
 clang-cuda-build  | 07:21:59
 llvm-clang-lld-x86_64-debian-fast | 07:16:39
 lldb-amd64-ninja-freebsd11| 07:06:53
 llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast| 07:06:15
 clang-cmake-armv7-a15-selfhost| 06:55:20
 sanitizer-ppc64be-linux   | 05:47:20
 clang-cmake-armv7-a15-selfhost-neon   | 05:41:54
 clang-cmake-aarch64-full  | 04:33:11
 clang-s390x-linux-multistage  | 04:33:10
 sanitizer-x86_64-linux-android| 04:30:42
 clang-ppc64be-linux-multistage| 03:59:02
 clang-x86_64-debian-fast  | 03:46:40
 clang-cmake-aarch64-lld   | 03:20:36
 clang-cmake-aarch64-global-isel   | 03:16:37
 clang-ppc64be-linux-lnt   | 03:15:28
 clang-ppc64be-linux   | 03:06:10
 clang-cmake-x86_64-avx2-linux | 03:01:35
 clang-cmake-armv7-a15 | 02:55:51
 clang-cmake-thumbv7-a15   | 02:55:30
 lld-x86_64-darwin13   | 02:50:47
 clang-ppc64le-linux-lnt   | 02:50:12
 clang-with-thin-lto-windows   | 02:48:35
 clang-ppc64le-linux   | 02:48:02
 clang-native-arm-lnt  | 02:43:56
 clang-s390x-linux-lnt | 02:38:37
 clang-s390x-linux | 02:30:33
 clang-hexagon-elf | 02:19:10
 clang-cmake-x86_64-sde-avx512-linux   | 02:15:00
 sanitizer-windows | 01:34:52
 clang-cmake-x86_64-avx2-linux-perf| 01:31:02
 lld-x86_64-freebsd| 01:25:51
 clang-cmake-aarch64-quick | 01:18:44
 lld-x86_64-win7   | 00:36:33
 lldb-x86_64-ubuntu-14.04-android  | 00:30:49
(64 rows)

r315532 - Update cc1as_main for MCCodeEmitter ownership change in r315531.

2017-10-11 Thread Lang Hames via cfe-commits
Author: lhames
Date: Wed Oct 11 16:35:27 2017
New Revision: 315532

URL: http://llvm.org/viewvc/llvm-project?rev=315532=rev
Log:
Update cc1as_main for MCCodeEmitter ownership change in r315531.

Modified:
cfe/trunk/tools/driver/cc1as_main.cpp

Modified: cfe/trunk/tools/driver/cc1as_main.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/driver/cc1as_main.cpp?rev=315532=315531=315532=diff
==
--- cfe/trunk/tools/driver/cc1as_main.cpp (original)
+++ cfe/trunk/tools/driver/cc1as_main.cpp Wed Oct 11 16:35:27 2017
@@ -419,7 +419,7 @@ static bool ExecuteAssembler(AssemblerIn
   Opts.CPU, Options);
 Triple T(Opts.Triple);
 Str.reset(TheTarget->createMCObjectStreamer(
-T, Ctx, std::unique_ptr(MAB), *Out, CE, *STI,
+T, Ctx, std::unique_ptr(MAB), *Out, 
std::unique_ptr(CE), *STI,
 Opts.RelaxAll, Opts.IncrementalLinkerCompatible,
 /*DWARFMustBeAtTheEnd*/ true));
 Str.get()->InitSections(Opts.NoExecStack);


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


r315530 - [ADT] Make Twine's copy constructor private.

2017-10-11 Thread Zachary Turner via cfe-commits
Author: zturner
Date: Wed Oct 11 16:33:06 2017
New Revision: 315530

URL: http://llvm.org/viewvc/llvm-project?rev=315530=rev
Log:
[ADT] Make Twine's copy constructor private.

There's a lot of misuse of Twine scattered around LLVM.  This
ranges in severity from benign (returning a Twine from a function
by value that is just a string literal) to pretty sketchy (storing
a Twine by value in a class).  While there are some uses for
copying Twines, most of the very compelling ones are confined
to the Twine class implementation itself, and other uses are
either dubious or easily worked around.

This patch makes Twine's copy constructor private, and fixes up
all callsites.

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

Modified:
cfe/trunk/include/clang/Tooling/CompilationDatabase.h
cfe/trunk/lib/CodeGen/CGObjCMac.cpp
cfe/trunk/lib/CodeGen/CodeGenAction.cpp
cfe/trunk/lib/Driver/ToolChains/MSVC.cpp
cfe/trunk/lib/Driver/ToolChains/MinGW.cpp
cfe/trunk/lib/Tooling/CompilationDatabase.cpp
cfe/trunk/unittests/Tooling/TestVisitor.h

Modified: cfe/trunk/include/clang/Tooling/CompilationDatabase.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Tooling/CompilationDatabase.h?rev=315530=315529=315530=diff
==
--- cfe/trunk/include/clang/Tooling/CompilationDatabase.h (original)
+++ cfe/trunk/include/clang/Tooling/CompilationDatabase.h Wed Oct 11 16:33:06 
2017
@@ -42,12 +42,10 @@ namespace tooling {
 /// \brief Specifies the working directory and command of a compilation.
 struct CompileCommand {
   CompileCommand() {}
-  CompileCommand(Twine Directory, Twine Filename,
- std::vector CommandLine, Twine Output)
-  : Directory(Directory.str()),
-Filename(Filename.str()),
-CommandLine(std::move(CommandLine)),
-Output(Output.str()){}
+  CompileCommand(const Twine , const Twine ,
+ std::vector CommandLine, const Twine )
+  : Directory(Directory.str()), Filename(Filename.str()),
+CommandLine(std::move(CommandLine)), Output(Output.str()) {}
 
   /// \brief The working directory the command was executed from.
   std::string Directory;
@@ -178,13 +176,14 @@ public:
   /// \param Argv Points to the command line arguments.
   /// \param ErrorMsg Contains error text if the function returns null pointer.
   /// \param Directory The base directory used in the FixedCompilationDatabase.
-  static std::unique_ptr loadFromCommandLine(
-  int , const char *const *Argv, std::string ,
-  Twine Directory = ".");
+  static std::unique_ptr
+  loadFromCommandLine(int , const char *const *Argv, std::string 
,
+  const Twine  = ".");
 
   /// \brief Constructs a compilation data base from a specified directory
   /// and command line.
-  FixedCompilationDatabase(Twine Directory, ArrayRef CommandLine);
+  FixedCompilationDatabase(const Twine ,
+   ArrayRef CommandLine);
 
   /// \brief Returns the given compile command.
   ///

Modified: cfe/trunk/lib/CodeGen/CGObjCMac.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjCMac.cpp?rev=315530=315529=315530=diff
==
--- cfe/trunk/lib/CodeGen/CGObjCMac.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGObjCMac.cpp Wed Oct 11 16:33:06 2017
@@ -981,17 +981,17 @@ protected:
 
   /// EmitPropertyList - Emit the given property list. The return
   /// value has type PropertyListPtrTy.
-  llvm::Constant *EmitPropertyList(Twine Name,
-   const Decl *Container,
+  llvm::Constant *EmitPropertyList(const Twine , const Decl *Container,
const ObjCContainerDecl *OCD,
const ObjCCommonTypesHelper ,
bool IsClassProperty);
 
   /// EmitProtocolMethodTypes - Generate the array of extended method type 
   /// strings. The return value has type Int8PtrPtrTy.
-  llvm::Constant *EmitProtocolMethodTypes(Twine Name, 
-  ArrayRef 
MethodTypes,
-   const ObjCCommonTypesHelper );
+  llvm::Constant *
+  EmitProtocolMethodTypes(const Twine ,
+  ArrayRef MethodTypes,
+  const ObjCCommonTypesHelper );
 
   /// GetProtocolRef - Return a reference to the internal protocol
   /// description, creating an empty one if it has not been
@@ -1021,11 +1021,11 @@ public:
   /// \param Align - The alignment for the variable, or 0.
   /// \param AddToUsed - Whether the variable should be added to
   ///   "llvm.used".
-  llvm::GlobalVariable *CreateMetadataVar(Twine Name,
+  llvm::GlobalVariable *CreateMetadataVar(const Twine ,
   ConstantStructBuilder ,
   

[PATCH] D38599: Remove warnings for dynamic_cast fallback.

2017-10-11 Thread Dan Albert via Phabricator via cfe-commits
danalbert abandoned this revision.
danalbert added a comment.

nbjoerg and zygoloid got me pointed in the right direction. Both `Base` and 
`BaseImpl` are missing their key functions, and that's the problem here. Patch 
should be unnecessary.


https://reviews.llvm.org/D38599



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


[PATCH] D38827: Add a cmake option for using strcmp for type_infos.

2017-10-11 Thread Dan Albert via Phabricator via cfe-commits
danalbert abandoned this revision.
danalbert added a comment.

zygoloid and nbjoerg got me pointed in the right direction on this. Looks like 
the user didn't have a key function defined for one of their classes, which was 
actually the root of the problem.


Repository:
  rL LLVM

https://reviews.llvm.org/D38827



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


[PATCH] D38444: [compiler-rt] [cmake] Create dummy gtest target for stand-alone builds

2017-10-11 Thread George Karpenkov via Phabricator via cfe-commits
george.karpenkov added a comment.

@mgorny I've replied via email, but the message didn't seem to appear here.

From my (maybe limited) understanding, running tests on standalone compiler-rt 
builds was never something which was supported, as that required a fresh 
compiler.
I've just tried running them, and for me even `check-*` targets don't exist.

How do you create the standalone build? I've checked out `compiler-rt` 
separately, and ran

  cmake -GNinja 
-DLLVM_CONFIG=/Users/george/code/llvm/release-build/bin/llvm-config  ../.

but the resulting build directory does not have any `check-*` targets.

In the refactoring I did try to make the dependence conditional: all 
compilation goes through `sanitizer_test_compile`,
but looking into the `sanitizer_test_compile` macro there is an obvious bug.
Would it be better to fix that instead?


Repository:
  rL LLVM

https://reviews.llvm.org/D38444



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


[PATCH] D38824: [X86] Synchronize the CPU predefined macros with gcc

2017-10-11 Thread Chandler Carruth via Phabricator via cfe-commits
chandlerc added inline comments.



Comment at: lib/Basic/Targets/X86.cpp:844-845
-// FIXME: Historically, we defined this legacy name, it would be nice to
-// remove it at some point. We've never exposed fine-grained names for
-// recent primary x86 CPUs, and we should keep it that way.
-defineCPUMacros(Builder, "corei7");

craig.topper wrote:
> chandlerc wrote:
> > This seems to undo the idea that we should keep avoiding exposing 
> > fine-grained CPU names? What's new that changes this?
> CPUs newer than the ones with that comment seem to have ignored said comment.
> 
> Probably be cause we don't have a definition for what to do for new CPUs if 
> we aren't going to expose fine grained names. Do we just call everything 
> corei7 forever?
My hope would have been that people use *ISA*-based macros rather than anything 
w/ a specific CPU. So I would have *removed* the corei7 for future CPUs and 
simply not defined anything for them at all.

I think exposing something beyond ISA featureset through preprocessor macros is 
questionable at best. I would at least want to see concrete use cases first.



Comment at: lib/Basic/Targets/X86.cpp:852
+defineCPUMacros(Builder, "core_avx2");
+defineCPUMacros(Builder, "haswell");
 break;

craig.topper wrote:
> chandlerc wrote:
> > I find calling a Westmere CPU `nehalem` a little odd. Calling IvyBridge a 
> > `sandybridge' CPU seems quite confusing. But calling Skylake (client) and 
> > Cannonlake (all? client?) `haswell` seems  deeply weird.
> This implementation matches what gcc does. I agree its weird.
> 
> gcc doesn't implement cannonlake yet so i don't know what they'll do.
Ok, but maybe we should ask GCC to stop doing this. ;] We could talk to them 
and try to figure out the right strategy is. My proposed strategy (see other 
comment) is to restrict macros to ISA facilities.


https://reviews.llvm.org/D38824



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


Re: r313386 - [Sema] Error out early for tags defined inside an enumeration.

2017-10-11 Thread Richard Smith via cfe-commits
On 22 September 2017 at 18:00, Volodymyr Sapsai via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

>
>
> On Sep 21, 2017, at 15:17, Richard Smith  wrote:
>
> On 15 September 2017 at 12:51, Volodymyr Sapsai via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: vsapsai
>> Date: Fri Sep 15 12:51:42 2017
>> New Revision: 313386
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=313386=rev
>> Log:
>> [Sema] Error out early for tags defined inside an enumeration.
>>
>> This fixes PR28903 by avoiding access check for inner enum constant. We
>> are performing access check because one enum constant references another
>> and because enum is defined in CXXRecordDecl. But access check doesn't
>> work because FindDeclaringClass doesn't expect more than one EnumDecl
>> and because inner enum has access AS_none due to not being an immediate
>> child of a record.
>>
>> The change detects an enum is defined in wrong place and allows to skip
>> parsing its body. Access check is skipped together with body parsing.
>> There was no crash in C, added test case to cover the new error.
>>
>> rdar://problem/28530809
>>
>> Reviewers: rnk, doug.gregor, rsmith
>>
>> Reviewed By: doug.gregor
>>
>> Subscribers: cfe-commits
>>
>> Differential Revision: https://reviews.llvm.org/D37089
>>
>>
>> Modified:
>> cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
>> cfe/trunk/lib/Sema/SemaDecl.cpp
>> cfe/trunk/test/Sema/enum.c
>> cfe/trunk/test/SemaCXX/enum.cpp
>>
>> Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/
>> include/clang/Basic/DiagnosticSemaKinds.td?rev=313386=
>> 313385=313386=diff
>> 
>> ==
>> --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
>> +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Fri Sep 15
>> 12:51:42 2017
>> @@ -1335,6 +1335,8 @@ def err_type_defined_in_alias_template :
>>"%0 cannot be defined in a type alias template">;
>>  def err_type_defined_in_condition : Error<
>>"%0 cannot be defined in a condition">;
>> +def err_type_defined_in_enum : Error<
>> +  "%0 cannot be defined in an enumeration">;
>>
>>  def note_pure_virtual_function : Note<
>>"unimplemented pure virtual method %0 in %1">;
>>
>> Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/
>> Sema/SemaDecl.cpp?rev=313386=313385=313386=diff
>> 
>> ==
>> --- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
>> +++ cfe/trunk/lib/Sema/SemaDecl.cpp Fri Sep 15 12:51:42 2017
>> @@ -13928,6 +13928,12 @@ CreateNewDecl:
>>  Invalid = true;
>>}
>>
>> +  if (!Invalid && TUK == TUK_Definition && DC->getDeclKind() ==
>> Decl::Enum) {
>> +Diag(New->getLocation(), diag::err_type_defined_in_enum)
>> +  << Context.getTagDeclType(New);
>> +Invalid = true;
>> +  }
>>
>
> This looks like the wrong fix. As noted elsewhere, this is wrong in C. And
> in C++, the relevant context is a type-specifier, which should be rejected
> due to the check 7 lines above.
>
> It looks like the actual bug is that we don't consider the type within a
> C99 compound literal to be a type-specifier. The fact that the context is
> an enumeration is irrelevant.
>
>
> At which point can we detect IsTypeSpecifier should be true? Which in turn
> boils down to DeclSpecContext should be DSC_type_specifier. Currently we
> have DeclSpecContext DSC_normal because it is a default argument in 
> Parser::ParseSpecifierQualifierList.
> Which is called from
>
> #4 clang::Parser::ParseParenExpression(clang::Parser::ParenParseOption&,
> bool, bool, clang::OpaquePtr&, clang::SourceLocation&)
> at llvm-project/clang/lib/Parse/ParseExpr.cpp:2375
>

The call to ParseSpecifierQualfiierList here should always pass
DSC_type_specifier. We're parsing a type within parentheses (which we've
already disambiguated as being a type cast / compound literal rather than
an expression), which is the DSC_type_specifier case.


> #5 clang::Parser::ParseCastExpression(bool, bool, bool&,
> clang::Parser::TypeCastState, bool) at llvm-project/clang/lib/Parse/
> ParseExpr.cpp:768
> #6 clang::Parser::ParseCastExpression(bool, bool,
> clang::Parser::TypeCastState, bool) at llvm-project/clang/lib/Parse/
> ParseExpr.cpp:521
> #7 
> clang::Parser::ParseConstantExpressionInExprEvalContext(clang::Parser::TypeCastState)
> at llvm-project/clang/lib/Parse/ParseExpr.cpp:201
>
> I have considered using TypeCastState for setting DeclSpecContext but its
> value is NotTypeCast because Parser::ParseEnumBody calls
> ParseConstantExpression with default argument. And it looks correct as
> parsing enum body doesn't imply presence of a type cast.
>
> I was struggling to find a good indication we are parsing type specifier
> and the best option seems to be ParseCastExpression because it 

[PATCH] D38599: Remove warnings for dynamic_cast fallback.

2017-10-11 Thread Jonathan Roelofs via Phabricator via cfe-commits
jroelofs added a comment.

Needs a docs entry for the new flag (in libcxx's BuildingLibcxx.rst). Other 
than that, all the stuff I've asked you to add LGTM. I'd still appreciate 
@EricWF/@mclow's opinion on the meat of the functional change part of this 
though... I don't know all the implications relaxing the search here.


https://reviews.llvm.org/D38599



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


[PATCH] D38599: Remove warnings for dynamic_cast fallback.

2017-10-11 Thread Dan Albert via Phabricator via cfe-commits
danalbert planned changes to this revision.
danalbert added a comment.

In https://reviews.llvm.org/D38599#894041, @jroelofs wrote:

> (possibly renamed to _LIBCXXABI_DYNAMIC_FALLBACK)


I opted for adding this switch to libc++ instead. Like @rprichard points out, 
we'll need to do this in `std::type_info::operator==` as well. I thought that 
code wasn't in libc++ yet, but it seems it is. I'm going to rename this option 
in libc++abi to match the one in libc++.


https://reviews.llvm.org/D38599



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


[PATCH] D38824: [X86] Synchronize the CPU predefined macros with gcc

2017-10-11 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added inline comments.



Comment at: lib/Basic/Targets/X86.cpp:844-845
-// FIXME: Historically, we defined this legacy name, it would be nice to
-// remove it at some point. We've never exposed fine-grained names for
-// recent primary x86 CPUs, and we should keep it that way.
-defineCPUMacros(Builder, "corei7");

chandlerc wrote:
> This seems to undo the idea that we should keep avoiding exposing 
> fine-grained CPU names? What's new that changes this?
CPUs newer than the ones with that comment seem to have ignored said comment.

Probably be cause we don't have a definition for what to do for new CPUs if we 
aren't going to expose fine grained names. Do we just call everything corei7 
forever?



Comment at: lib/Basic/Targets/X86.cpp:852
+defineCPUMacros(Builder, "core_avx2");
+defineCPUMacros(Builder, "haswell");
 break;

chandlerc wrote:
> I find calling a Westmere CPU `nehalem` a little odd. Calling IvyBridge a 
> `sandybridge' CPU seems quite confusing. But calling Skylake (client) and 
> Cannonlake (all? client?) `haswell` seems  deeply weird.
This implementation matches what gcc does. I agree its weird.

gcc doesn't implement cannonlake yet so i don't know what they'll do.


https://reviews.llvm.org/D38824



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


[PATCH] D38827: Add a cmake option for using strcmp for type_infos.

2017-10-11 Thread Dan Albert via Phabricator via cfe-commits
danalbert planned changes to this revision.
danalbert added a comment.

Actually, I was wrong. This is implemented. Will update to set the flag the 
configures this and add a test.


Repository:
  rL LLVM

https://reviews.llvm.org/D38827



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


[PATCH] D38827: Add a cmake option for using strcmp for type_infos.

2017-10-11 Thread Dan Albert via Phabricator via cfe-commits
danalbert created this revision.
Herald added a subscriber: mgorny.

libc++ doesn't yet have the code for this, but libc++abi does. Adding
the switch to libc++ since the flag in libc++abi is
`_LIBCXX_DYNAMIC_FALLBACK`, not `_LIBCXXABI_DYNAMIC_FALLBACK`, and it
will be needed here as well.


Repository:
  rL LLVM

https://reviews.llvm.org/D38827

Files:
  CMakeLists.txt


Index: CMakeLists.txt
===
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -103,6 +103,7 @@
 option(LIBCXX_ABI_FORCE_MICROSOFT "Ignore auto-detection and force use of the 
Microsoft ABI.")
 set(LIBCXX_ABI_DEFINES "" CACHE STRING "A semicolon separated list of ABI 
macros to define in the site config header.")
 option(LIBCXX_USE_COMPILER_RT "Use compiler-rt instead of libgcc" OFF)
+option(LIBCXX_DYNAMIC_FALLBACK  "Use strcmp fallback for comparing 
type_infos." OFF)
 
 if (NOT LIBCXX_ENABLE_SHARED AND NOT LIBCXX_ENABLE_STATIC)
   message(FATAL_ERROR "libc++ must be built as either a shared or static 
library.")


Index: CMakeLists.txt
===
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -103,6 +103,7 @@
 option(LIBCXX_ABI_FORCE_MICROSOFT "Ignore auto-detection and force use of the Microsoft ABI.")
 set(LIBCXX_ABI_DEFINES "" CACHE STRING "A semicolon separated list of ABI macros to define in the site config header.")
 option(LIBCXX_USE_COMPILER_RT "Use compiler-rt instead of libgcc" OFF)
+option(LIBCXX_DYNAMIC_FALLBACK  "Use strcmp fallback for comparing type_infos." OFF)
 
 if (NOT LIBCXX_ENABLE_SHARED AND NOT LIBCXX_ENABLE_STATIC)
   message(FATAL_ERROR "libc++ must be built as either a shared or static library.")
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D38599: Remove warnings for dynamic_cast fallback.

2017-10-11 Thread Dan Albert via Phabricator via cfe-commits
danalbert updated this revision to Diff 118711.
danalbert added a comment.
Herald added a subscriber: mgorny.

Update the test with an XFAIL when _LIBCXX_DYNAMIC_FALLBACK is not set.

https://reviews.llvm.org/D38827 adds this cmake option to libc++.


https://reviews.llvm.org/D38599

Files:
  CMakeLists.txt
  src/private_typeinfo.cpp
  test/CMakeLists.txt
  test/dlopen_dynamic_cast.sh.cpp
  test/libcxxabi/test/config.py
  test/lit.site.cfg.in

Index: test/lit.site.cfg.in
===
--- test/lit.site.cfg.in
+++ test/lit.site.cfg.in
@@ -16,6 +16,7 @@
 config.executor = "@LIBCXXABI_EXECUTOR@"
 config.libcxxabi_shared = "@LIBCXXABI_ENABLE_SHARED@"
 config.enable_shared= "@LIBCXX_ENABLE_SHARED@"
+config.dynamic_fallback = "@LIBCXX_DYNAMIC_FALLBACK@"
 config.enable_exceptions= "@LIBCXXABI_ENABLE_EXCEPTIONS@"
 config.host_triple  = "@LLVM_HOST_TRIPLE@"
 config.target_triple= "@TARGET_TRIPLE@"
Index: test/libcxxabi/test/config.py
===
--- test/libcxxabi/test/config.py
+++ test/libcxxabi/test/config.py
@@ -48,6 +48,11 @@
 if not self.get_lit_bool('llvm_unwinder', False):
 self.config.available_features.add('libcxxabi-has-system-unwinder')
 
+if self.get_lit_bool('dynamic_fallback', False):
+self.config.available_features.add('libcxx-dynamic-fallback')
+else:
+self.config.available_features.add('libcxx-no-dynamic-fallback')
+
 def configure_compile_flags(self):
 self.cxx.compile_flags += ['-DLIBCXXABI_NO_TIMER']
 if self.get_lit_bool('enable_exceptions', True):
Index: test/dlopen_dynamic_cast.sh.cpp
===
--- /dev/null
+++ test/dlopen_dynamic_cast.sh.cpp
@@ -0,0 +1,89 @@
+//=== dlopen_dynamic_cast.sh.cpp --===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// type_infos are not coalesced across dlopen boundaries when RTLD_LOCAL is
+// used, as is common in plugin interfaces and JNI libraries. For dynamic_cast
+// to work across a dlopen boundary, we must use a string comparison of the type
+// names instead of a pointer comparison of the type_infos.
+// https://reviews.llvm.org/D38599
+
+// XFAIL: libcxx-no-dynamic-fallback
+
+// RUN: %cxx %flags %compile_flags -DBUILD_BASE -fPIC -c %s -o %T/base.o
+// RUN: %cxx %flags %link_flags -shared %T/base.o -o %T/libbase.so
+// RUN: %cxx %flags %compile_flags -DBUILD_TEST -fPIC -c %s -o %T/test.o
+// RUN: %cxx %flags %link_flags -shared %T/test.o -o %T/libtest.so -L%T -lbase
+// RUN: %cxx %flags %compile_flags -DBUILD_EXE -c %s -o %t.o
+// RUN: %cxx %flags %link_flags %t.o -o %t.exe -ldl
+// RUN: LD_LIBRARY_PATH=%T %t.exe
+
+class Base {
+public:
+  virtual ~Base(){};
+};
+
+class BaseImpl : public Base {
+public:
+  BaseImpl();
+};
+
+#ifdef BUILD_BASE
+BaseImpl::BaseImpl() {}
+#endif
+
+#ifdef BUILD_TEST
+extern "C" bool do_test() {
+  BaseImpl base_impl;
+  Base* base = _impl;
+  return dynamic_cast(base) != nullptr;
+}
+#endif
+
+#ifdef BUILD_EXE
+#include 
+#include 
+#include 
+
+typedef bool (*test_func)();
+
+void* load_library(const char* name) {
+  void* lib = dlopen(name, RTLD_NOW | RTLD_LOCAL);
+  if (lib == nullptr) {
+fprintf(stderr, "dlopen %s failed: %s\n", name, dlerror());
+abort();
+  }
+  return lib;
+}
+
+test_func load_func(void* lib, const char* name) {
+  test_func sym = reinterpret_cast(dlsym(lib, name));
+  if (sym == nullptr) {
+fprintf(stderr, "dlsym %s failed: %s\n", name, dlerror());
+abort();
+  }
+  return sym;
+}
+
+int main(int argc, char**) {
+  // Explicitly loading libbase.so before libtest.so causes the test to fail
+  // because the type_infos do not get coalesced.
+  load_library("libbase.so");
+
+  void* libtest = load_library("libtest.so");
+  test_func do_test = load_func(libtest, "do_test");
+
+  if (!do_test()) {
+fprintf(stderr, "do_test() failed!\n");
+return EXIT_FAILURE;
+  } else {
+fprintf(stderr, "do_test() passed!\n");
+return EXIT_SUCCESS;
+  }
+}
+#endif
Index: test/CMakeLists.txt
===
--- test/CMakeLists.txt
+++ test/CMakeLists.txt
@@ -18,6 +18,7 @@
 pythonize_bool(LIBCXXABI_ENABLE_EXCEPTIONS)
 pythonize_bool(LIBCXXABI_USE_LLVM_UNWINDER)
 pythonize_bool(LIBCXXABI_BUILD_EXTERNAL_THREAD_LIBRARY)
+pythonize_bool(LIBCXX_DYNAMIC_FALLBACK)
 set(LIBCXXABI_TARGET_INFO "libcxx.test.target_info.LocalTI" CACHE STRING
 "TargetInfo to use when setting up test environment.")
 set(LIBCXXABI_EXECUTOR "None" CACHE STRING

[PATCH] D38824: [X86] Synchronize the CPU predefined macros with gcc

2017-10-11 Thread Chandler Carruth via Phabricator via cfe-commits
chandlerc added inline comments.



Comment at: lib/Basic/Targets/X86.cpp:844-845
-// FIXME: Historically, we defined this legacy name, it would be nice to
-// remove it at some point. We've never exposed fine-grained names for
-// recent primary x86 CPUs, and we should keep it that way.
-defineCPUMacros(Builder, "corei7");

This seems to undo the idea that we should keep avoiding exposing fine-grained 
CPU names? What's new that changes this?



Comment at: lib/Basic/Targets/X86.cpp:852
+defineCPUMacros(Builder, "core_avx2");
+defineCPUMacros(Builder, "haswell");
 break;

I find calling a Westmere CPU `nehalem` a little odd. Calling IvyBridge a 
`sandybridge' CPU seems quite confusing. But calling Skylake (client) and 
Cannonlake (all? client?) `haswell` seems  deeply weird.


https://reviews.llvm.org/D38824



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


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

2017-10-11 Thread Mandeep Singh Grang via Phabricator via cfe-commits
mgrang added a comment.

LGTM.


https://reviews.llvm.org/D38821



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


[PATCH] D35082: [OpenCL] Add LangAS::opencl_private to represent private address space in AST

2017-10-11 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl marked 2 inline comments as done.
yaxunl added a comment.

In https://reviews.llvm.org/D35082#895230, @rjmccall wrote:

> It sounds like there's agreement about the basic technical direction of 
> introducing LangAS::opencl_private.  Please introduce 
> isAddressSpaceImplicit() in a different patch and make this patch just about 
> the introduction of LangAS::opencl_private.  You can have the pretty-printer 
> just ignore __private for now, which should avoid gratuitous diagnostic 
> changes.
>
> I would like you to investigate using AttributedType for the pretty-printing 
> and address-space semantic checks before adding isAddressSpaceImplicit().


Thanks. I will separate the implicit addr space flag to another patch.




Comment at: include/clang/AST/Type.h:562
+  static const uint32_t IMask = 0x200;
+  static const uint32_t IShift = 9;
   static const uint32_t AddressSpaceMask =

rjmccall wrote:
> "I" is not an appropriate abbreviation for "AddressSpaceImplicit".
Will change it to ImplictAddrSpace.



Comment at: include/clang/Basic/AddressSpaces.h:34
 
   // OpenCL specific address spaces.
   opencl_global,

rjmccall wrote:
> I think you need a real comment about the design of OpenCL address spaces 
> here.  Specifically, it is important to note that OpenCL no longer uses 
> LangAS::Default for anything except r-values.
Will do.


https://reviews.llvm.org/D35082



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


r315518 - [Driver] Export symbols needed to use profile runtime

2017-10-11 Thread Vedant Kumar via cfe-commits
Author: vedantk
Date: Wed Oct 11 14:54:09 2017
New Revision: 315518

URL: http://llvm.org/viewvc/llvm-project?rev=315518=rev
Log:
[Driver] Export symbols needed to use profile runtime

Apple's API verification tool (tapi) checks that the symbols exported
from a program match a whitelist. When the program uses the profile
runtime, some additional symbols which are typically not part of the
regular whitelist must be exported.

If we're using symbol export directives along with the profile runtime
on Darwin, the driver needs to export the additional symbols to avoid
verification failures.

rdar://problem/30067753

Modified:
cfe/trunk/lib/Driver/ToolChains/Darwin.cpp
cfe/trunk/test/Driver/darwin-ld.c

Modified: cfe/trunk/lib/Driver/ToolChains/Darwin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Darwin.cpp?rev=315518=315517=315518=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Darwin.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Darwin.cpp Wed Oct 11 14:54:09 2017
@@ -986,6 +986,25 @@ StringRef Darwin::getOSLibraryNameSuffix
   llvm_unreachable("Unsupported platform");
 }
 
+/// Check if the link command contains a symbol export directive.
+static bool hasExportSymbolDirective(const ArgList ) {
+  for (Arg *A : Args) {
+if (!A->getOption().matches(options::OPT_Wl_COMMA) &&
+!A->getOption().matches(options::OPT_Xlinker))
+  continue;
+if (A->containsValue("-exported_symbols_list") ||
+A->containsValue("-exported_symbol"))
+  return true;
+  }
+  return false;
+}
+
+/// Add an export directive for \p Symbol to the link command.
+static void addExportedSymbol(ArgStringList , const char *Symbol) {
+  CmdArgs.push_back("-exported_symbol");
+  CmdArgs.push_back(Symbol);
+}
+
 void Darwin::addProfileRTLibs(const ArgList ,
   ArgStringList ) const {
   if (!needsProfileRT(Args)) return;
@@ -994,6 +1013,16 @@ void Darwin::addProfileRTLibs(const ArgL
   Args, CmdArgs,
   (Twine("libclang_rt.profile_") + getOSLibraryNameSuffix() + ".a").str(),
   RuntimeLinkOptions(RLO_AlwaysLink | RLO_FirstLink));
+
+  // If we have a symbol export directive and we're linking in the profile
+  // runtime, automatically export symbols necessary to implement some of the
+  // runtime's functionality.
+  if (hasExportSymbolDirective(Args)) {
+addExportedSymbol(CmdArgs, "_VPMergeHook");
+addExportedSymbol(CmdArgs, "___llvm_profile_filename");
+addExportedSymbol(CmdArgs, "___llvm_profile_raw_version");
+addExportedSymbol(CmdArgs, "_lprofCurFilename");
+  }
 }
 
 void DarwinClang::AddLinkSanitizerLibArgs(const ArgList ,

Modified: cfe/trunk/test/Driver/darwin-ld.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/darwin-ld.c?rev=315518=315517=315518=diff
==
--- cfe/trunk/test/Driver/darwin-ld.c (original)
+++ cfe/trunk/test/Driver/darwin-ld.c Wed Oct 11 14:54:09 2017
@@ -351,3 +351,17 @@
 // RUN: %clang -target arm64-apple-ios5.0 -miphoneos-version-min=5.0 
-fprofile-instr-generate -### %t.o 2> %t.log
 // RUN: FileCheck -check-prefix=LINK_PROFILE_FIRST %s < %t.log
 // LINK_PROFILE_FIRST: {{ld(.exe)?"}} 
"{{[^"]+}}libclang_rt.profile_{{[a-z]+}}.a"
+
+// RUN: %clang -target x86_64-apple-darwin12 -fprofile-instr-generate 
-Wl,-exported_symbols_list,/dev/null -### %t.o 2> %t.log
+// RUN: FileCheck -check-prefix=PROFILE_EXPORT %s < %t.log
+// RUN: %clang -target x86_64-apple-darwin12 -fprofile-instr-generate 
-Wl,-exported_symbol,foo -### %t.o 2> %t.log
+// RUN: FileCheck -check-prefix=PROFILE_EXPORT %s < %t.log
+// RUN: %clang -target x86_64-apple-darwin12 -fprofile-instr-generate -Xlinker 
-exported_symbol -Xlinker foo -### %t.o 2> %t.log
+// RUN: FileCheck -check-prefix=PROFILE_EXPORT %s < %t.log
+// RUN: %clang -target x86_64-apple-darwin12 -fprofile-instr-generate -Xlinker 
-exported_symbols_list -Xlinker /dev/null -### %t.o 2> %t.log
+// RUN: FileCheck -check-prefix=PROFILE_EXPORT %s < %t.log
+// PROFILE_EXPORT: "-exported_symbol" "_VPMergeHook" "-exported_symbol" 
"___llvm_profile_filename" "-exported_symbol" "___llvm_profile_raw_version" 
"-exported_symbol" "_lprofCurFilename"
+//
+// RUN: %clang -target x86_64-apple-darwin12 -fprofile-instr-generate -### 
%t.o 2> %t.log
+// RUN: FileCheck -check-prefix=NO_PROFILE_EXPORT %s < %t.log
+// NO_PROFILE_EXPORT-NOT: "-exported_symbol"


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


[PATCH] D38680: [libunwind] Fix handling of DW_CFA_GNU_args_size

2017-10-11 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added inline comments.



Comment at: src/libunwind.cpp:188
+  co->getInfo();
+  pint_t orgArgSize = (pint_t)info.gp;
+  uint64_t orgFuncStart = info.start_ip;

I think it makes sense to have this here: the contract is that if the 
personality sets the IP when the cursor pointed to a PC with a non-zero arg 
size, we should adjust SP for the personality.

However, it's not clear to me that we don't need the same adjustment when 
stepping across frames that use arg size without a frame pointer.


https://reviews.llvm.org/D38680



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


r315517 - [X86] Add support for 'amdfam17h' to __builtin_cpu_is to match gcc.

2017-10-11 Thread Craig Topper via cfe-commits
Author: ctopper
Date: Wed Oct 11 14:42:02 2017
New Revision: 315517

URL: http://llvm.org/viewvc/llvm-project?rev=315517=rev
Log:
[X86] Add support for 'amdfam17h' to __builtin_cpu_is to match gcc.

The compiler-rt implementation already supported it, it just wasn't exposed.

Modified:
cfe/trunk/lib/Basic/Targets/X86.cpp
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
cfe/trunk/test/CodeGen/target-builtin-noerror.c

Modified: cfe/trunk/lib/Basic/Targets/X86.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/X86.cpp?rev=315517=315516=315517=diff
==
--- cfe/trunk/lib/Basic/Targets/X86.cpp (original)
+++ cfe/trunk/lib/Basic/Targets/X86.cpp Wed Oct 11 14:42:02 2017
@@ -1293,6 +1293,7 @@ bool X86TargetInfo::validateCpuIs(String
   .Case("amd", true)
   .Case("amdfam10h", true)
   .Case("amdfam15h", true)
+  .Case("amdfam17h", true)
   .Case("atom", true)
   .Case("barcelona", true)
   .Case("bdver1", true)

Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=315517=315516=315517=diff
==
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Wed Oct 11 14:42:02 2017
@@ -7501,6 +7501,7 @@ Value *CodeGenFunction::EmitX86CpuIs(Str
 INTEL_KNL,
 AMD_BTVER1,
 AMD_BTVER2,
+AMDFAM17H,
 CPU_SUBTYPE_START,
 INTEL_COREI7_NEHALEM,
 INTEL_COREI7_WESTMERE,
@@ -7527,6 +7528,7 @@ Value *CodeGenFunction::EmitX86CpuIs(Str
   .Case("amdfam10", AMDFAM10H)
   .Case("amdfam15h", AMDFAM15H)
   .Case("amdfam15", AMDFAM15H)
+  .Case("amdfam17h", AMDFAM17H)
   .Case("atom", INTEL_BONNELL)
   .Case("barcelona", AMDFAM10H_BARCELONA)
   .Case("bdver1", AMDFAM15H_BDVER1)

Modified: cfe/trunk/test/CodeGen/target-builtin-noerror.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/target-builtin-noerror.c?rev=315517=315516=315517=diff
==
--- cfe/trunk/test/CodeGen/target-builtin-noerror.c (original)
+++ cfe/trunk/test/CodeGen/target-builtin-noerror.c Wed Oct 11 14:42:02 2017
@@ -81,6 +81,7 @@ void verifycpustrings() {
   (void)__builtin_cpu_is("amd");
   (void)__builtin_cpu_is("amdfam10h");
   (void)__builtin_cpu_is("amdfam15h");
+  (void)__builtin_cpu_is("amdfam17h");
   (void)__builtin_cpu_is("atom");
   (void)__builtin_cpu_is("barcelona");
   (void)__builtin_cpu_is("bdver1");


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


[PATCH] D38816: Convert clang::LangAS to a strongly typed enum

2017-10-11 Thread Justin Lebar via Phabricator via cfe-commits
jlebar added a comment.

> The only reason I added this namespace is that I wasn't sure whether having 
> those functions in the clang namespace is acceptable.

Maybe someone else will object, or suggest an existing namespace they should be 
in.  FWIW I think it's fine.

> Not quite sure what to call the functions though. langASFromTargetAS?

sgtm!


Repository:
  rL LLVM

https://reviews.llvm.org/D38816



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


[PATCH] D38816: Convert clang::LangAS to a strongly typed enum

2017-10-11 Thread Alexander Richardson via Phabricator via cfe-commits
arichardson added inline comments.



Comment at: include/clang/Basic/AddressSpaces.h:51
 
+namespace LanguageAS {
 /// The type of a lookup table which maps from language-specific address spaces

jlebar wrote:
> I wonder if you need this namespace?  LangAS right next to LanguageAS reads 
> strangely to me -- "what's the difference?".
> 
> I guess you'd need to rename Map and fromTargetAS, but the other two members 
> are probably OK?
The only reason I added this namespace is that I wasn't sure whether having 
those functions in the clang namespace is acceptable.

Not quite sure what to call the functions though. `langASFromTargetAS`?


Repository:
  rL LLVM

https://reviews.llvm.org/D38816



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


[PATCH] D38772: [refactor] allow the use of refactoring diagnostics

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



Comment at: lib/Basic/DiagnosticIDs.cpp:46
   unsigned WarnShowInSystemHeader : 1;
-  unsigned Category : 5;
+  unsigned Category : 6;
 

hokein wrote:
> just curious: is this change needed?
I get a build warning without this change as the bitfield becomes too narrow 
with the new category, so yeah.



Comment at: tools/clang-refactor/ToolRefactoringResultConsumer.h:19
+
+/// A subclass of \c RefactoringResultConsumer that stores the reference to the
+/// TU-specific diagnostics engine.

hokein wrote:
> I'd name it "interface", because it has unimplemented virtual function 
> (`handleError`), clients can't create an instance of it. 
> 
> or alternatively,  does it make more sense to just add these methods and 
> `DiagnosticsEngine` variable to the `tooling::RefactoringResultConsumer` 
> interface? I see you have replaced "RefactoringResultConsumer" with this new 
> interface in many places. 
Right now I don't think having the diagnostics engine will be useful for 
clients outside of tool, so I'd prefer to keep it here. We can reconsider this 
decision in the future if we need to.


Repository:
  rL LLVM

https://reviews.llvm.org/D38772



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


[PATCH] D38772: [refactor] allow the use of refactoring diagnostics

2017-10-11 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman updated this revision to Diff 118701.
arphaman marked 2 inline comments as done.
arphaman added a comment.

- rename the common consumer class.


Repository:
  rL LLVM

https://reviews.llvm.org/D38772

Files:
  include/clang/Basic/AllDiagnostics.h
  include/clang/Basic/CMakeLists.txt
  include/clang/Basic/Diagnostic.td
  include/clang/Basic/DiagnosticIDs.h
  include/clang/Basic/DiagnosticRefactoringKinds.td
  include/clang/Tooling/Refactoring/RefactoringActionRuleRequirements.h
  include/clang/Tooling/Refactoring/RefactoringDiagnostic.h
  include/clang/Tooling/Refactoring/RefactoringRuleContext.h
  lib/Basic/DiagnosticIDs.cpp
  lib/Tooling/Refactoring/Rename/RenamingAction.cpp
  test/Refactor/LocalRename/NoSymbolSelectedError.cpp
  tools/clang-refactor/ClangRefactor.cpp
  tools/clang-refactor/TestSupport.cpp
  tools/clang-refactor/TestSupport.h
  tools/clang-refactor/ToolRefactoringResultConsumer.h
  tools/diagtool/DiagnosticNames.cpp

Index: tools/diagtool/DiagnosticNames.cpp
===
--- tools/diagtool/DiagnosticNames.cpp
+++ tools/diagtool/DiagnosticNames.cpp
@@ -42,6 +42,7 @@
 #include "clang/Basic/DiagnosticCommentKinds.inc"
 #include "clang/Basic/DiagnosticSemaKinds.inc"
 #include "clang/Basic/DiagnosticAnalysisKinds.inc"
+#include "clang/Basic/DiagnosticRefactoringKinds.inc"
 #undef DIAG
 };
 
Index: tools/clang-refactor/ToolRefactoringResultConsumer.h
===
--- /dev/null
+++ tools/clang-refactor/ToolRefactoringResultConsumer.h
@@ -0,0 +1,48 @@
+//===--- ToolRefactoringResultConsumer.h - --*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_CLANG_REFACTOR_TOOL_REFACTORING_RESULT_CONSUMER_H
+#define LLVM_CLANG_TOOLS_CLANG_REFACTOR_TOOL_REFACTORING_RESULT_CONSUMER_H
+
+#include "clang/AST/ASTContext.h"
+#include "clang/Tooling/Refactoring/RefactoringResultConsumer.h"
+
+namespace clang {
+namespace refactor {
+
+/// An interface that subclasses the \c RefactoringResultConsumer interface
+/// that stores the reference to the TU-specific diagnostics engine.
+class ClangRefactorToolConsumerInterface
+: public tooling::RefactoringResultConsumer {
+public:
+  /// Called when a TU is entered.
+  void beginTU(ASTContext ) {
+assert(!Diags && "Diags has been set");
+Diags = ();
+  }
+
+  /// Called when the tool is done with a TU.
+  void endTU() {
+assert(Diags && "Diags unset");
+Diags = nullptr;
+  }
+
+  DiagnosticsEngine () const {
+assert(Diags && "no diags");
+return *Diags;
+  }
+
+private:
+  DiagnosticsEngine *Diags = nullptr;
+};
+
+} // end namespace refactor
+} // end namespace clang
+
+#endif // LLVM_CLANG_TOOLS_CLANG_REFACTOR_TOOL_REFACTORING_RESULT_CONSUMER_H
Index: tools/clang-refactor/TestSupport.h
===
--- tools/clang-refactor/TestSupport.h
+++ tools/clang-refactor/TestSupport.h
@@ -16,9 +16,9 @@
 #ifndef LLVM_CLANG_TOOLS_CLANG_REFACTOR_TEST_SUPPORT_H
 #define LLVM_CLANG_TOOLS_CLANG_REFACTOR_TEST_SUPPORT_H
 
+#include "ToolRefactoringResultConsumer.h"
 #include "clang/Basic/LLVM.h"
 #include "clang/Basic/SourceLocation.h"
-#include "clang/Tooling/Refactoring/RefactoringResultConsumer.h"
 #include "llvm/ADT/Optional.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/Support/Error.h"
@@ -65,7 +65,7 @@
   bool foreachRange(const SourceManager ,
 llvm::function_ref Callback) const;
 
-  std::unique_ptr createConsumer() const;
+  std::unique_ptr createConsumer() const;
 
   void dump(llvm::raw_ostream ) const;
 };
Index: tools/clang-refactor/TestSupport.cpp
===
--- tools/clang-refactor/TestSupport.cpp
+++ tools/clang-refactor/TestSupport.cpp
@@ -14,6 +14,7 @@
 //===--===//
 
 #include "TestSupport.h"
+#include "clang/Basic/DiagnosticError.h"
 #include "clang/Basic/SourceManager.h"
 #include "clang/Lex/Lexer.h"
 #include "llvm/ADT/STLExtras.h"
@@ -106,7 +107,7 @@
 }
 
 class TestRefactoringResultConsumer final
-: public tooling::RefactoringResultConsumer {
+: public ClangRefactorToolConsumerInterface {
 public:
   TestRefactoringResultConsumer(const TestSelectionRangesInFile )
   : TestRanges(TestRanges) {
@@ -182,10 +183,15 @@
   std::string ErrorMessage;
   bool HasResult = !!Result;
   if (!HasResult) {
-// FIXME: Handle diagnostic error as well.
-handleAllErrors(Result.takeError(), [&](StringError ) {
-  ErrorMessage = Err.getMessage();
-});
+handleAllErrors(
+

[PATCH] D38824: [X86] Synchronize the CPU predefined macros with gcc

2017-10-11 Thread Craig Topper via Phabricator via cfe-commits
craig.topper created this revision.
Herald added a subscriber: krytarowski.

We were using corei7 for a large swatch of Intel CPUs. gcc has a different 
defines that more closely match the march flags. This updates to match.  It 
also fixes skylake-avx512 and adds silvermont in addition to slm.


https://reviews.llvm.org/D38824

Files:
  lib/Basic/Targets/X86.cpp
  test/Preprocessor/predefined-arch-macros.c

Index: test/Preprocessor/predefined-arch-macros.c
===
--- test/Preprocessor/predefined-arch-macros.c
+++ test/Preprocessor/predefined-arch-macros.c
@@ -427,11 +427,14 @@
 // CHECK_COREI7_AVX_M32: #define __SSSE3__ 1
 // CHECK_COREI7_AVX_M32: #define __XSAVEOPT__ 1
 // CHECK_COREI7_AVX_M32: #define __XSAVE__ 1
-// CHECK_COREI7_AVX_M32: #define __corei7 1
-// CHECK_COREI7_AVX_M32: #define __corei7__ 1
+// CHECK_COREI7_AVX_M32: #define __corei7_avx 1
+// CHECK_COREI7_AVX_M32: #define __corei7_avx__ 1
 // CHECK_COREI7_AVX_M32: #define __i386 1
 // CHECK_COREI7_AVX_M32: #define __i386__ 1
-// CHECK_COREI7_AVX_M32: #define __tune_corei7__ 1
+// CHECK_COREI7_AVX_M32: #define __sandybridge 1
+// CHECK_COREI7_AVX_M32: #define __sandybridge__ 1
+// CHECK_COREI7_AVX_M32: #define __tune_corei7_avx__ 1
+// CHECK_COREI7_AVX_M32: #define __tune_sandybridge__ 1
 // CHECK_COREI7_AVX_M32: #define i386 1
 // RUN: %clang -march=corei7-avx -m64 -E -dM %s -o - 2>&1 \
 // RUN: -target i386-unknown-linux \
@@ -454,9 +457,12 @@
 // CHECK_COREI7_AVX_M64: #define __XSAVE__ 1
 // CHECK_COREI7_AVX_M64: #define __amd64 1
 // CHECK_COREI7_AVX_M64: #define __amd64__ 1
-// CHECK_COREI7_AVX_M64: #define __corei7 1
-// CHECK_COREI7_AVX_M64: #define __corei7__ 1
-// CHECK_COREI7_AVX_M64: #define __tune_corei7__ 1
+// CHECK_COREI7_AVX_M64: #define __corei7_avx 1
+// CHECK_COREI7_AVX_M64: #define __corei7_avx__ 1
+// CHECK_COREI7_AVX_M64: #define __sandybridge 1
+// CHECK_COREI7_AVX_M64: #define __sandybridge__ 1
+// CHECK_COREI7_AVX_M64: #define __tune_corei7_avx__ 1
+// CHECK_COREI7_AVX_M64: #define __tune_sandybridge__ 1
 // CHECK_COREI7_AVX_M64: #define __x86_64 1
 // CHECK_COREI7_AVX_M64: #define __x86_64__ 1
 //
@@ -477,11 +483,14 @@
 // CHECK_CORE_AVX_I_M32: #define __SSSE3__ 1
 // CHECK_CORE_AVX_I_M32: #define __XSAVEOPT__ 1
 // CHECK_CORE_AVX_I_M32: #define __XSAVE__ 1
-// CHECK_CORE_AVX_I_M32: #define __corei7 1
-// CHECK_CORE_AVX_I_M32: #define __corei7__ 1
+// CHECK_CORE_AVX_I_M32: #define __corei7_avx 1
+// CHECK_CORE_AVX_I_M32: #define __corei7_avx__ 1
 // CHECK_CORE_AVX_I_M32: #define __i386 1
 // CHECK_CORE_AVX_I_M32: #define __i386__ 1
-// CHECK_CORE_AVX_I_M32: #define __tune_corei7__ 1
+// CHECK_CORE_AVX_I_M32: #define __sandybridge 1
+// CHECK_CORE_AVX_I_M32: #define __sandybridge__ 1
+// CHECK_CORE_AVX_I_M32: #define __tune_corei7_avx__ 1
+// CHECK_CORE_AVX_I_M32: #define __tune_sandybridge__ 1
 // CHECK_CORE_AVX_I_M32: #define i386 1
 // RUN: %clang -march=core-avx-i -m64 -E -dM %s -o - 2>&1 \
 // RUN: -target i386-unknown-linux \
@@ -504,9 +513,12 @@
 // CHECK_CORE_AVX_I_M64: #define __XSAVE__ 1
 // CHECK_CORE_AVX_I_M64: #define __amd64 1
 // CHECK_CORE_AVX_I_M64: #define __amd64__ 1
-// CHECK_CORE_AVX_I_M64: #define __corei7 1
-// CHECK_CORE_AVX_I_M64: #define __corei7__ 1
-// CHECK_CORE_AVX_I_M64: #define __tune_corei7__ 1
+// CHECK_CORE_AVX_I_M64: #define __corei7_avx 1
+// CHECK_CORE_AVX_I_M64: #define __corei7_avx__ 1
+// CHECK_CORE_AVX_I_M64: #define __sandybridge 1
+// CHECK_CORE_AVX_I_M64: #define __sandybridge__ 1
+// CHECK_CORE_AVX_I_M64: #define __tune_corei7_avx__ 1
+// CHECK_CORE_AVX_I_M64: #define __tune_sandybridge__ 1
 // CHECK_CORE_AVX_I_M64: #define __x86_64 1
 // CHECK_CORE_AVX_I_M64: #define __x86_64__ 1
 //
@@ -533,11 +545,14 @@
 // CHECK_CORE_AVX2_M32: #define __SSSE3__ 1
 // CHECK_CORE_AVX2_M32: #define __XSAVEOPT__ 1
 // CHECK_CORE_AVX2_M32: #define __XSAVE__ 1
-// CHECK_CORE_AVX2_M32: #define __corei7 1
-// CHECK_CORE_AVX2_M32: #define __corei7__ 1
+// CHECK_CORE_AVX2_M32: #define __core_avx2 1
+// CHECK_CORE_AVX2_M32: #define __core_avx2__ 1
+// CHECK_CORE_AVX2_M32: #define __haswell 1
+// CHECK_CORE_AVX2_M32: #define __haswell__ 1
 // CHECK_CORE_AVX2_M32: #define __i386 1
 // CHECK_CORE_AVX2_M32: #define __i386__ 1
-// CHECK_CORE_AVX2_M32: #define __tune_corei7__ 1
+// CHECK_CORE_AVX2_M32: #define __tune_core_avx2__ 1
+// CHECK_CORE_AVX2_M32: #define __tune_haswell__ 1
 // CHECK_CORE_AVX2_M32: #define i386 1
 // RUN: %clang -march=core-avx2 -m64 -E -dM %s -o - 2>&1 \
 // RUN: -target i386-unknown-linux \
@@ -566,9 +581,12 @@
 // CHECK_CORE_AVX2_M64: #define __XSAVE__ 1
 // CHECK_CORE_AVX2_M64: #define __amd64 1
 // CHECK_CORE_AVX2_M64: #define __amd64__ 1
-// CHECK_CORE_AVX2_M64: #define __corei7 1
-// CHECK_CORE_AVX2_M64: #define __corei7__ 1
-// CHECK_CORE_AVX2_M64: #define __tune_corei7__ 1
+// CHECK_CORE_AVX2_M64: #define __core_avx2 1
+// CHECK_CORE_AVX2_M64: #define __core_avx2__ 1
+// CHECK_CORE_AVX2_M64: 

[PATCH] D35082: [OpenCL] Add LangAS::opencl_private to represent private address space in AST

2017-10-11 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

It sounds like there's agreement about the basic technical direction of 
introducing LangAS::opencl_private.  Please introduce isAddressSpaceImplicit() 
in a different patch and make this patch just about the introduction of 
LangAS::opencl_private.  You can have the pretty-printer just ignore __private 
for now, which should avoid gratuitous diagnostic changes.

I would like you to investigate using AttributedType for the pretty-printing 
and address-space semantic checks before adding isAddressSpaceImplicit().




Comment at: include/clang/AST/Type.h:562
+  static const uint32_t IMask = 0x200;
+  static const uint32_t IShift = 9;
   static const uint32_t AddressSpaceMask =

"I" is not an appropriate abbreviation for "AddressSpaceImplicit".



Comment at: include/clang/Basic/AddressSpaces.h:34
 
   // OpenCL specific address spaces.
   opencl_global,

I think you need a real comment about the design of OpenCL address spaces here. 
 Specifically, it is important to note that OpenCL no longer uses 
LangAS::Default for anything except r-values.


https://reviews.llvm.org/D35082



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


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

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

This is an update to https://reviews.llvm.org/D36111 by @mgrang, taking over 
finishing of this patch. Compared to his version, this makes the intrinsics 
conditional to ALL_MS_LANGUAGES.


https://reviews.llvm.org/D38821

Files:
  include/clang/Basic/BuiltinsAArch64.def
  lib/Basic/Targets/AArch64.cpp
  test/CodeGen/arm64-microsoft-intrinsics.c


Index: test/CodeGen/arm64-microsoft-intrinsics.c
===
--- /dev/null
+++ test/CodeGen/arm64-microsoft-intrinsics.c
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 -triple arm64-windows -fms-compatibility -emit-llvm -o - %s 
\
+// RUN:| FileCheck %s -check-prefix CHECK-MSVC
+
+// RUN: not %clang_cc1 -triple arm64-linux -Werror -S -o /dev/null %s 2>&1 \
+// RUN:| FileCheck %s -check-prefix CHECK-LINUX
+
+void check__dmb(void) {
+  __dmb(0);
+}
+
+// CHECK-MSVC: @llvm.aarch64.dmb(i32 0)
+// CHECK-LINUX: error: implicit declaration of function '__dmb'
+
+void check__dsb(void) {
+  __dsb(0);
+}
+
+// CHECK-MSVC: @llvm.aarch64.dsb(i32 0)
+// CHECK-LINUX: error: implicit declaration of function '__dsb'
+
+void check__isb(void) {
+  __isb(0);
+}
+
+// CHECK-MSVC: @llvm.aarch64.isb(i32 0)
+// CHECK-LINUX: error: implicit declaration of function '__isb'
Index: lib/Basic/Targets/AArch64.cpp
===
--- lib/Basic/Targets/AArch64.cpp
+++ lib/Basic/Targets/AArch64.cpp
@@ -27,6 +27,8 @@
 
 #define BUILTIN(ID, TYPE, ATTRS)   
\
{#ID, TYPE, ATTRS, nullptr, ALL_LANGUAGES, nullptr},
+#define LANGBUILTIN(ID, TYPE, ATTRS, LANG) 
\
+  {#ID, TYPE, ATTRS, nullptr, LANG, nullptr},
 #include "clang/Basic/BuiltinsAArch64.def"
 };
 
Index: include/clang/Basic/BuiltinsAArch64.def
===
--- include/clang/Basic/BuiltinsAArch64.def
+++ include/clang/Basic/BuiltinsAArch64.def
@@ -14,6 +14,10 @@
 
 // The format of this database matches clang/Basic/Builtins.def.
 
+#if defined(BUILTIN) && !defined(LANGBUILTIN)
+#   define LANGBUILTIN(ID, TYPE, ATTRS, BUILTIN_LANG) BUILTIN(ID, TYPE, ATTRS)
+#endif
+
 // In libgcc
 BUILTIN(__clear_cache, "vv*v*", "i")
 
@@ -61,4 +65,9 @@
 BUILTIN(__builtin_arm_wsr64, "vcC*LUi", "nc")
 BUILTIN(__builtin_arm_wsrp, "vcC*vC*", "nc")
 
+LANGBUILTIN(__dmb, "vUi", "nc", ALL_MS_LANGUAGES)
+LANGBUILTIN(__dsb, "vUi", "nc", ALL_MS_LANGUAGES)
+LANGBUILTIN(__isb, "vUi", "nc", ALL_MS_LANGUAGES)
+
 #undef BUILTIN
+#undef LANGBUILTIN


Index: test/CodeGen/arm64-microsoft-intrinsics.c
===
--- /dev/null
+++ test/CodeGen/arm64-microsoft-intrinsics.c
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 -triple arm64-windows -fms-compatibility -emit-llvm -o - %s \
+// RUN:| FileCheck %s -check-prefix CHECK-MSVC
+
+// RUN: not %clang_cc1 -triple arm64-linux -Werror -S -o /dev/null %s 2>&1 \
+// RUN:| FileCheck %s -check-prefix CHECK-LINUX
+
+void check__dmb(void) {
+  __dmb(0);
+}
+
+// CHECK-MSVC: @llvm.aarch64.dmb(i32 0)
+// CHECK-LINUX: error: implicit declaration of function '__dmb'
+
+void check__dsb(void) {
+  __dsb(0);
+}
+
+// CHECK-MSVC: @llvm.aarch64.dsb(i32 0)
+// CHECK-LINUX: error: implicit declaration of function '__dsb'
+
+void check__isb(void) {
+  __isb(0);
+}
+
+// CHECK-MSVC: @llvm.aarch64.isb(i32 0)
+// CHECK-LINUX: error: implicit declaration of function '__isb'
Index: lib/Basic/Targets/AArch64.cpp
===
--- lib/Basic/Targets/AArch64.cpp
+++ lib/Basic/Targets/AArch64.cpp
@@ -27,6 +27,8 @@
 
 #define BUILTIN(ID, TYPE, ATTRS)   \
{#ID, TYPE, ATTRS, nullptr, ALL_LANGUAGES, nullptr},
+#define LANGBUILTIN(ID, TYPE, ATTRS, LANG) \
+  {#ID, TYPE, ATTRS, nullptr, LANG, nullptr},
 #include "clang/Basic/BuiltinsAArch64.def"
 };
 
Index: include/clang/Basic/BuiltinsAArch64.def
===
--- include/clang/Basic/BuiltinsAArch64.def
+++ include/clang/Basic/BuiltinsAArch64.def
@@ -14,6 +14,10 @@
 
 // The format of this database matches clang/Basic/Builtins.def.
 
+#if defined(BUILTIN) && !defined(LANGBUILTIN)
+#   define LANGBUILTIN(ID, TYPE, ATTRS, BUILTIN_LANG) BUILTIN(ID, TYPE, ATTRS)
+#endif
+
 // In libgcc
 BUILTIN(__clear_cache, "vv*v*", "i")
 
@@ -61,4 +65,9 @@
 BUILTIN(__builtin_arm_wsr64, "vcC*LUi", "nc")
 BUILTIN(__builtin_arm_wsrp, "vcC*vC*", "nc")
 
+LANGBUILTIN(__dmb, "vUi", "nc", ALL_MS_LANGUAGES)
+LANGBUILTIN(__dsb, "vUi", "nc", ALL_MS_LANGUAGES)
+LANGBUILTIN(__isb, "vUi", "nc", ALL_MS_LANGUAGES)
+
 #undef BUILTIN
+#undef LANGBUILTIN
___
cfe-commits mailing list
cfe-commits@lists.llvm.org

[PATCH] D38425: [clangd] Document highlights for clangd

2017-10-11 Thread William Enright via Phabricator via cfe-commits
Nebiroth marked an inline comment as done.
Nebiroth added inline comments.



Comment at: clangd/ClangdUnit.cpp:784
+/// Finds declarations locations that a given source location refers to.
+class TargetDeclarationFinder : public index::IndexDataConsumer {
+  std::vector DeclarationLocations;

ilya-biryukov wrote:
> This `IndexDataConsumer` effectively does the same thing as 
> `DeclarationLocationsFinder`.
> We should reuse the code between those two.
> 
> To do that we could:
> 1. Change `DeclarationLocationsFinder` to return a list of `Decl*`s and 
> `MacroDef*`s that are under caret.
> 2. In `findDefinition` we should return locations of found `Decl` and 
> `MacroDef`.
> 3. In `documentHighlights` we would rerun `DocumentHighlightsFinder`to 
> capture locations of `Decls` referenced in step 1.
> 
> Do you think this approach would work?
I have something similar to this implemented. Will upstream it soon.


https://reviews.llvm.org/D38425



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


r315508 - [Analyzer] Support bodyfarming libstdc++ implementation of std::call_once.

2017-10-11 Thread George Karpenkov via cfe-commits
Author: george.karpenkov
Date: Wed Oct 11 13:53:01 2017
New Revision: 315508

URL: http://llvm.org/viewvc/llvm-project?rev=315508=rev
Log:
[Analyzer] Support bodyfarming libstdc++ implementation of std::call_once.

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

Modified:
cfe/trunk/lib/Analysis/BodyFarm.cpp
cfe/trunk/test/Analysis/call_once.cpp

Modified: cfe/trunk/lib/Analysis/BodyFarm.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/BodyFarm.cpp?rev=315508=315507=315508=diff
==
--- cfe/trunk/lib/Analysis/BodyFarm.cpp (original)
+++ cfe/trunk/lib/Analysis/BodyFarm.cpp Wed Oct 11 13:53:01 2017
@@ -108,7 +108,7 @@ public:
 
   /// Returns a *first* member field of a record declaration with a given name.
   /// \return an nullptr if no member with such a name exists.
-  NamedDecl *findMemberField(const CXXRecordDecl *RD, StringRef Name);
+  ValueDecl *findMemberField(const RecordDecl *RD, StringRef Name);
 
 private:
   ASTContext 
@@ -234,7 +234,7 @@ MemberExpr *ASTMaker::makeMemberExpressi
   OK_Ordinary);
 }
 
-NamedDecl *ASTMaker::findMemberField(const CXXRecordDecl *RD, StringRef Name) {
+ValueDecl *ASTMaker::findMemberField(const RecordDecl *RD, StringRef Name) {
 
   CXXBasePaths Paths(
   /* FindAmbiguities=*/false,
@@ -246,7 +246,7 @@ NamedDecl *ASTMaker::findMemberField(con
   DeclContextLookupResult Decls = RD->lookup(DeclName);
   for (NamedDecl *FoundDecl : Decls)
 if (!FoundDecl->getDeclContext()->isFunctionOrMethod())
-  return FoundDecl;
+  return cast(FoundDecl);
 
   return nullptr;
 }
@@ -328,25 +328,31 @@ static Stmt *create_call_once(ASTContext
   const ParmVarDecl *Callback = D->getParamDecl(1);
   QualType CallbackType = Callback->getType().getNonReferenceType();
   QualType FlagType = Flag->getType().getNonReferenceType();
-  CXXRecordDecl *FlagCXXDecl = FlagType->getAsCXXRecordDecl();
-  if (!FlagCXXDecl) {
-DEBUG(llvm::dbgs() << "Flag field is not a CXX record: "
-   << "unknown std::call_once implementation."
-   << "Ignoring the call.\n");
+  auto *FlagRecordDecl = 
dyn_cast_or_null(FlagType->getAsTagDecl());
+
+  if (!FlagRecordDecl) {
+DEBUG(llvm::dbgs() << "Flag field is not a record: "
+   << "unknown std::call_once implementation, "
+   << "ignoring the call.\n");
 return nullptr;
   }
 
-  // Note: here we are assuming libc++ implementation of call_once,
-  // which has a struct with a field `__state_`.
-  // Body farming might not work for other `call_once` implementations.
-  NamedDecl *FoundDecl = M.findMemberField(FlagCXXDecl, "__state_");
-  ValueDecl *FieldDecl;
-  if (FoundDecl) {
-FieldDecl = dyn_cast(FoundDecl);
-  } else {
+  // We initially assume libc++ implementation of call_once,
+  // where the once_flag struct has a field `__state_`.
+  ValueDecl *FlagFieldDecl = M.findMemberField(FlagRecordDecl, "__state_");
+
+  // Otherwise, try libstdc++ implementation, with a field
+  // `_M_once`
+  if (!FlagFieldDecl) {
 DEBUG(llvm::dbgs() << "No field __state_ found on std::once_flag struct, "
-   << "unable to synthesize call_once body, ignoring "
-   << "the call.\n");
+   << "assuming libstdc++ implementation\n");
+FlagFieldDecl = M.findMemberField(FlagRecordDecl, "_M_once");
+  }
+
+  if (!FlagFieldDecl) {
+DEBUG(llvm::dbgs() << "No field _M_once found on std::once flag struct: "
+   << "unknown std::call_once implementation, "
+   << "ignoring the call");
 return nullptr;
   }
 
@@ -383,7 +389,7 @@ static Stmt *create_call_once(ASTContext
 /* GetNonReferenceType=*/true);
 
 
-  MemberExpr *Deref = M.makeMemberExpression(FlagDecl, FieldDecl);
+  MemberExpr *Deref = M.makeMemberExpression(FlagDecl, FlagFieldDecl);
   assert(Deref->isLValue());
   QualType DerefType = Deref->getType();
 

Modified: cfe/trunk/test/Analysis/call_once.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/call_once.cpp?rev=315508=315507=315508=diff
==
--- cfe/trunk/test/Analysis/call_once.cpp (original)
+++ cfe/trunk/test/Analysis/call_once.cpp Wed Oct 11 13:53:01 2017
@@ -1,15 +1,24 @@
-// RUN: %clang_analyze_cc1 -std=c++11 -fblocks 
-analyzer-checker=core,debug.ExprInspection -w -verify %s
+// RUN: %clang_analyze_cc1 -std=c++11 -fblocks 
-analyzer-checker=core,debug.ExprInspection -verify %s
+// RUN: %clang_analyze_cc1 -std=c++11 -fblocks 
-analyzer-checker=core,debug.ExprInspection -DEMULATE_LIBSTDCPP -verify %s
 
 void clang_analyzer_eval(bool);
 
 // Faking std::std::call_once implementation.
 namespace std {
+
+#ifndef EMULATE_LIBSTDCPP
 typedef struct once_flag_s {
   unsigned long __state_ = 0;
 } once_flag;
+#else
+typedef 

[PATCH] D38810: [Analyzer] Support bodyfarming std::call_once for libstdc++

2017-10-11 Thread George Karpenkov via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL315508: [Analyzer] Support bodyfarming libstdc++ 
implementation of std::call_once. (authored by george.karpenkov).

Changed prior to commit:
  https://reviews.llvm.org/D38810?vs=118644=118686#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D38810

Files:
  cfe/trunk/lib/Analysis/BodyFarm.cpp
  cfe/trunk/test/Analysis/call_once.cpp

Index: cfe/trunk/test/Analysis/call_once.cpp
===
--- cfe/trunk/test/Analysis/call_once.cpp
+++ cfe/trunk/test/Analysis/call_once.cpp
@@ -1,15 +1,24 @@
-// RUN: %clang_analyze_cc1 -std=c++11 -fblocks -analyzer-checker=core,debug.ExprInspection -w -verify %s
+// RUN: %clang_analyze_cc1 -std=c++11 -fblocks -analyzer-checker=core,debug.ExprInspection -verify %s
+// RUN: %clang_analyze_cc1 -std=c++11 -fblocks -analyzer-checker=core,debug.ExprInspection -DEMULATE_LIBSTDCPP -verify %s
 
 void clang_analyzer_eval(bool);
 
 // Faking std::std::call_once implementation.
 namespace std {
+
+#ifndef EMULATE_LIBSTDCPP
 typedef struct once_flag_s {
   unsigned long __state_ = 0;
 } once_flag;
+#else
+typedef struct once_flag_s {
+  int _M_once = 0;
+} once_flag;
+#endif
 
 template 
 void call_once(once_flag , Callable func, Args... args) {};
+
 } // namespace std
 
 // Check with Lambdas.
Index: cfe/trunk/lib/Analysis/BodyFarm.cpp
===
--- cfe/trunk/lib/Analysis/BodyFarm.cpp
+++ cfe/trunk/lib/Analysis/BodyFarm.cpp
@@ -108,7 +108,7 @@
 
   /// Returns a *first* member field of a record declaration with a given name.
   /// \return an nullptr if no member with such a name exists.
-  NamedDecl *findMemberField(const CXXRecordDecl *RD, StringRef Name);
+  ValueDecl *findMemberField(const RecordDecl *RD, StringRef Name);
 
 private:
   ASTContext 
@@ -234,7 +234,7 @@
   OK_Ordinary);
 }
 
-NamedDecl *ASTMaker::findMemberField(const CXXRecordDecl *RD, StringRef Name) {
+ValueDecl *ASTMaker::findMemberField(const RecordDecl *RD, StringRef Name) {
 
   CXXBasePaths Paths(
   /* FindAmbiguities=*/false,
@@ -246,7 +246,7 @@
   DeclContextLookupResult Decls = RD->lookup(DeclName);
   for (NamedDecl *FoundDecl : Decls)
 if (!FoundDecl->getDeclContext()->isFunctionOrMethod())
-  return FoundDecl;
+  return cast(FoundDecl);
 
   return nullptr;
 }
@@ -328,25 +328,31 @@
   const ParmVarDecl *Callback = D->getParamDecl(1);
   QualType CallbackType = Callback->getType().getNonReferenceType();
   QualType FlagType = Flag->getType().getNonReferenceType();
-  CXXRecordDecl *FlagCXXDecl = FlagType->getAsCXXRecordDecl();
-  if (!FlagCXXDecl) {
-DEBUG(llvm::dbgs() << "Flag field is not a CXX record: "
-   << "unknown std::call_once implementation."
-   << "Ignoring the call.\n");
+  auto *FlagRecordDecl = dyn_cast_or_null(FlagType->getAsTagDecl());
+
+  if (!FlagRecordDecl) {
+DEBUG(llvm::dbgs() << "Flag field is not a record: "
+   << "unknown std::call_once implementation, "
+   << "ignoring the call.\n");
 return nullptr;
   }
 
-  // Note: here we are assuming libc++ implementation of call_once,
-  // which has a struct with a field `__state_`.
-  // Body farming might not work for other `call_once` implementations.
-  NamedDecl *FoundDecl = M.findMemberField(FlagCXXDecl, "__state_");
-  ValueDecl *FieldDecl;
-  if (FoundDecl) {
-FieldDecl = dyn_cast(FoundDecl);
-  } else {
+  // We initially assume libc++ implementation of call_once,
+  // where the once_flag struct has a field `__state_`.
+  ValueDecl *FlagFieldDecl = M.findMemberField(FlagRecordDecl, "__state_");
+
+  // Otherwise, try libstdc++ implementation, with a field
+  // `_M_once`
+  if (!FlagFieldDecl) {
 DEBUG(llvm::dbgs() << "No field __state_ found on std::once_flag struct, "
-   << "unable to synthesize call_once body, ignoring "
-   << "the call.\n");
+   << "assuming libstdc++ implementation\n");
+FlagFieldDecl = M.findMemberField(FlagRecordDecl, "_M_once");
+  }
+
+  if (!FlagFieldDecl) {
+DEBUG(llvm::dbgs() << "No field _M_once found on std::once flag struct: "
+   << "unknown std::call_once implementation, "
+   << "ignoring the call");
 return nullptr;
   }
 
@@ -383,7 +389,7 @@
 /* GetNonReferenceType=*/true);
 
 
-  MemberExpr *Deref = M.makeMemberExpression(FlagDecl, FieldDecl);
+  MemberExpr *Deref = M.makeMemberExpression(FlagDecl, FlagFieldDecl);
   assert(Deref->isLValue());
   QualType DerefType = Deref->getType();
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D38819: [libunwind] Add support for dwarf unwinding on windows on x86_64

2017-10-11 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo added a comment.

As further explanation/justification - libcxxabi and libunwind don't support 
SEH exceptions yet.


https://reviews.llvm.org/D38819



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


r315506 - [clang-fuzzer] Build with newer protobuf-mutator.

2017-10-11 Thread Matt Morehouse via cfe-commits
Author: morehouse
Date: Wed Oct 11 13:45:10 2017
New Revision: 315506

URL: http://llvm.org/viewvc/llvm-project?rev=315506=rev
Log:
[clang-fuzzer] Build with newer protobuf-mutator.

Modified:
cfe/trunk/cmake/modules/ProtobufMutator.cmake

Modified: cfe/trunk/cmake/modules/ProtobufMutator.cmake
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/cmake/modules/ProtobufMutator.cmake?rev=315506=315505=315506=diff
==
--- cfe/trunk/cmake/modules/ProtobufMutator.cmake (original)
+++ cfe/trunk/cmake/modules/ProtobufMutator.cmake Wed Oct 11 13:45:10 2017
@@ -6,7 +6,7 @@ set(PBM_FUZZ_LIB_PATH ${PBM_PATH}/src/li
 ExternalProject_Add(${PBM_PREFIX}
   PREFIX ${PBM_PREFIX}
   GIT_REPOSITORY https://github.com/google/libprotobuf-mutator.git
-  GIT_TAG 17789d1
+  GIT_TAG e4eae60
   CONFIGURE_COMMAND ${CMAKE_COMMAND} -G${CMAKE_GENERATOR}
 -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
 -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}


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


[PATCH] D38430: Enable -pie and --enable-new-dtags by default on Android.

2017-10-11 Thread Evgenii Stepanov via Phabricator via cfe-commits
eugenis added a comment.

ping


https://reviews.llvm.org/D38430



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


[PATCH] D38816: Convert clang::LangAS to a strongly typed enum

2017-10-11 Thread Justin Lebar via Phabricator via cfe-commits
jlebar added a comment.

My only regret is that I have but one +1 to give to this patch.




Comment at: include/clang/Basic/AddressSpaces.h:51
 
+namespace LanguageAS {
 /// The type of a lookup table which maps from language-specific address spaces

I wonder if you need this namespace?  LangAS right next to LanguageAS reads 
strangely to me -- "what's the difference?".

I guess you'd need to rename Map and fromTargetAS, but the other two members 
are probably OK?


Repository:
  rL LLVM

https://reviews.llvm.org/D38816



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


[PATCH] D38820: [CGExprScalar] Add missing types in function GetIntrinsic

2017-10-11 Thread Guozhi Wei via Phabricator via cfe-commits
Carrot created this revision.

In function GetIntrinsic, not all types are covered. Types double and long long 
are missed, type long is wrongly treated same as int, it should be same as long 
long. These problems cause compiler crashes when compiling code in PR31161. 
This patch fixed the problem.


https://reviews.llvm.org/D38820

Files:
  lib/CodeGen/CGExprScalar.cpp
  test/CodeGen/ppc-vector-compare.cc


Index: test/CodeGen/ppc-vector-compare.cc
===
--- test/CodeGen/ppc-vector-compare.cc
+++ test/CodeGen/ppc-vector-compare.cc
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -target-feature +altivec -triple powerpc64-unknown-unknown 
-emit-llvm %s \
+// RUN: %clang_cc1 -target-feature +vsx -triple powerpc64-unknown-unknown 
-emit-llvm %s \
 // RUN:-o - | FileCheck %s
 
 #include 
@@ -9,3 +9,26 @@
   return v1 == v2;
 }
 
+// CHECK-LABEL: @_Z5test2Dv2_mS_Dv2_lS0_Dv2_yS1_Dv2_xS2_Dv2_dS3_
+bool test2(vector unsigned long v1, vector unsigned long v2,
+   vector long v3, vector long v4,
+   vector unsigned long long v5, vector unsigned long long v6,
+   vector long long v7, vector long long v8,
+   vector double v9, vector double v10) {
+  // CHECK: @llvm.ppc.altivec.vcmpequd.p
+  bool res = v1 == v2;
+
+  // CHECK: @llvm.ppc.altivec.vcmpequd.p
+  res |= v3 == v4;
+
+  // CHECK: @llvm.ppc.altivec.vcmpequd.p
+  res |= v5 == v6;
+
+  // CHECK: @llvm.ppc.altivec.vcmpequd.p
+  res |= v7 == v8;
+
+  // CHECK: @llvm.ppc.vsx.xvcmpeqdp.p
+  res |= v9 == v10;
+  return res;
+}
+
Index: lib/CodeGen/CGExprScalar.cpp
===
--- lib/CodeGen/CGExprScalar.cpp
+++ lib/CodeGen/CGExprScalar.cpp
@@ -3120,16 +3120,25 @@
 return (IT == VCMPEQ) ? llvm::Intrinsic::ppc_altivec_vcmpequh_p :
 llvm::Intrinsic::ppc_altivec_vcmpgtsh_p;
   case BuiltinType::UInt:
-  case BuiltinType::ULong:
 return (IT == VCMPEQ) ? llvm::Intrinsic::ppc_altivec_vcmpequw_p :
 llvm::Intrinsic::ppc_altivec_vcmpgtuw_p;
   case BuiltinType::Int:
-  case BuiltinType::Long:
 return (IT == VCMPEQ) ? llvm::Intrinsic::ppc_altivec_vcmpequw_p :
 llvm::Intrinsic::ppc_altivec_vcmpgtsw_p;
+  case BuiltinType::ULong:
+  case BuiltinType::ULongLong:
+return (IT == VCMPEQ) ? llvm::Intrinsic::ppc_altivec_vcmpequd_p :
+llvm::Intrinsic::ppc_altivec_vcmpgtud_p;
+  case BuiltinType::Long:
+  case BuiltinType::LongLong:
+return (IT == VCMPEQ) ? llvm::Intrinsic::ppc_altivec_vcmpequd_p :
+llvm::Intrinsic::ppc_altivec_vcmpgtsd_p;
   case BuiltinType::Float:
 return (IT == VCMPEQ) ? llvm::Intrinsic::ppc_altivec_vcmpeqfp_p :
 llvm::Intrinsic::ppc_altivec_vcmpgtfp_p;
+  case BuiltinType::Double:
+return (IT == VCMPEQ) ? llvm::Intrinsic::ppc_vsx_xvcmpeqdp_p :
+llvm::Intrinsic::ppc_vsx_xvcmpgtdp_p;
   }
 }
 


Index: test/CodeGen/ppc-vector-compare.cc
===
--- test/CodeGen/ppc-vector-compare.cc
+++ test/CodeGen/ppc-vector-compare.cc
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -target-feature +altivec -triple powerpc64-unknown-unknown -emit-llvm %s \
+// RUN: %clang_cc1 -target-feature +vsx -triple powerpc64-unknown-unknown -emit-llvm %s \
 // RUN:-o - | FileCheck %s
 
 #include 
@@ -9,3 +9,26 @@
   return v1 == v2;
 }
 
+// CHECK-LABEL: @_Z5test2Dv2_mS_Dv2_lS0_Dv2_yS1_Dv2_xS2_Dv2_dS3_
+bool test2(vector unsigned long v1, vector unsigned long v2,
+   vector long v3, vector long v4,
+   vector unsigned long long v5, vector unsigned long long v6,
+   vector long long v7, vector long long v8,
+   vector double v9, vector double v10) {
+  // CHECK: @llvm.ppc.altivec.vcmpequd.p
+  bool res = v1 == v2;
+
+  // CHECK: @llvm.ppc.altivec.vcmpequd.p
+  res |= v3 == v4;
+
+  // CHECK: @llvm.ppc.altivec.vcmpequd.p
+  res |= v5 == v6;
+
+  // CHECK: @llvm.ppc.altivec.vcmpequd.p
+  res |= v7 == v8;
+
+  // CHECK: @llvm.ppc.vsx.xvcmpeqdp.p
+  res |= v9 == v10;
+  return res;
+}
+
Index: lib/CodeGen/CGExprScalar.cpp
===
--- lib/CodeGen/CGExprScalar.cpp
+++ lib/CodeGen/CGExprScalar.cpp
@@ -3120,16 +3120,25 @@
 return (IT == VCMPEQ) ? llvm::Intrinsic::ppc_altivec_vcmpequh_p :
 llvm::Intrinsic::ppc_altivec_vcmpgtsh_p;
   case BuiltinType::UInt:
-  case BuiltinType::ULong:
 return (IT == VCMPEQ) ? llvm::Intrinsic::ppc_altivec_vcmpequw_p :
 llvm::Intrinsic::ppc_altivec_vcmpgtuw_p;
   case BuiltinType::Int:
-  case BuiltinType::Long:
 return (IT == VCMPEQ) ? llvm::Intrinsic::ppc_altivec_vcmpequw_p :
 llvm::Intrinsic::ppc_altivec_vcmpgtsw_p;
+  case BuiltinType::ULong:
+  case 

[PATCH] D35082: [OpenCL] Add LangAS::opencl_private to represent private address space in AST

2017-10-11 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

If there is no other issues. May I commit this patch now? Thanks.


https://reviews.llvm.org/D35082



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


[PATCH] D38819: [libunwind] Add support for dwarf unwinding on windows on x86_64

2017-10-11 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo created this revision.
Herald added a subscriber: aprantl.

Clang doesn't currently support building for windows/x86_64 with dwarf by 
setting command line parameters, but if manually modified to use dwarf, we can 
make libunwind work in this configuration as well.

Even if support for this is deemed pointless, I guess one could omit the 
assembly changes, but the fixes for the generic code probably are worthwhile at 
least.


https://reviews.llvm.org/D38819

Files:
  docs/index.rst
  include/unwind.h
  src/AddressSpace.hpp
  src/UnwindLevel1.c
  src/UnwindRegistersRestore.S
  src/UnwindRegistersSave.S

Index: src/UnwindRegistersSave.S
===
--- src/UnwindRegistersSave.S
+++ src/UnwindRegistersSave.S
@@ -63,6 +63,27 @@
 #  thread_state pointer is in rdi
 #
 DEFINE_LIBUNWIND_FUNCTION(unw_getcontext)
+#if defined(_WIN32)
+  movq  %rax,   (%rcx)
+  movq  %rbx,  8(%rcx)
+  movq  %rcx, 16(%rcx)
+  movq  %rdx, 24(%rcx)
+  movq  %rdi, 32(%rcx)
+  movq  %rsi, 40(%rcx)
+  movq  %rbp, 48(%rcx)
+  movq  %rsp, 56(%rcx)
+  addq  $8,   56(%rcx)
+  movq  %r8,  64(%rcx)
+  movq  %r9,  72(%rcx)
+  movq  %r10, 80(%rcx)
+  movq  %r11, 88(%rcx)
+  movq  %r12, 96(%rcx)
+  movq  %r13,104(%rcx)
+  movq  %r14,112(%rcx)
+  movq  %r15,120(%rcx)
+  movq  (%rsp),%rdx
+  movq  %rdx,128(%rcx) # store return address as rip
+#else
   movq  %rax,   (%rdi)
   movq  %rbx,  8(%rdi)
   movq  %rcx, 16(%rdi)
@@ -82,6 +103,7 @@
   movq  %r15,120(%rdi)
   movq  (%rsp),%rsi
   movq  %rsi,128(%rdi) # store return address as rip
+#endif
   # skip rflags
   # skip cs
   # skip fs
Index: src/UnwindRegistersRestore.S
===
--- src/UnwindRegistersRestore.S
+++ src/UnwindRegistersRestore.S
@@ -65,6 +65,40 @@
 #
 # void libunwind::Registers_x86_64::jumpto()
 #
+#if defined(_WIN32)
+# On entry, thread_state pointer is in rcx
+
+  movq  56(%rcx), %rax # rax holds new stack pointer
+  subq  $16, %rax
+  movq  %rax, 56(%rcx)
+  movq  16(%rcx), %rdx  # store new rcx on new stack
+  movq  %rdx, 0(%rax)
+  movq  128(%rcx), %rdx # store new rip on new stack
+  movq  %rdx, 8(%rax)
+  # restore all registers
+  movq0(%rcx), %rax
+  movq8(%rcx), %rbx
+  # restore rcx later
+  movq   24(%rcx), %rdx
+  movq   32(%rcx), %rdi
+  movq   40(%rcx), %rsi
+  movq   48(%rcx), %rbp
+  # restore rsp later
+  movq   64(%rcx), %r8
+  movq   72(%rcx), %r9
+  movq   80(%rcx), %r10
+  movq   88(%rcx), %r11
+  movq   96(%rcx), %r12
+  movq  104(%rcx), %r13
+  movq  112(%rcx), %r14
+  movq  120(%rcx), %r15
+  # skip rflags
+  # skip cs
+  # skip fs
+  # skip gs
+  movq  56(%rcx), %rsp  # cut back rsp to new location
+  pop%rcx  # rcx was saved here earlier
+#else
 # On entry, thread_state pointer is in rdi
 
   movq  56(%rdi), %rax # rax holds new stack pointer
@@ -97,6 +131,7 @@
   # skip gs
   movq  56(%rdi), %rsp  # cut back rsp to new location
   pop%rdi  # rdi was saved here earlier
+#endif
   ret# rip was saved here
 
 
Index: src/UnwindLevel1.c
===
--- src/UnwindLevel1.c
+++ src/UnwindLevel1.c
@@ -86,7 +86,7 @@
 // this frame.
 if (frameInfo.handler != 0) {
   __personality_routine p =
-  (__personality_routine)(long)(frameInfo.handler);
+  (__personality_routine)(uintptr_t)(frameInfo.handler);
   _LIBUNWIND_TRACE_UNWINDING(
   "unwind_phase1(ex_ojb=%p): calling personality function %p",
   (void *)exception_object, (void *)(uintptr_t)p);
@@ -181,7 +181,7 @@
 // If there is a personality routine, tell it we are unwinding.
 if (frameInfo.handler != 0) {
   __personality_routine p =
-  (__personality_routine)(long)(frameInfo.handler);
+  (__personality_routine)(uintptr_t)(frameInfo.handler);
   _Unwind_Action action = _UA_CLEANUP_PHASE;
   if (sp == exception_object->private_2) {
 // Tell personality this was the frame it marked in phase 1.
Index: src/AddressSpace.hpp
===
--- src/AddressSpace.hpp
+++ src/AddressSpace.hpp
@@ -142,7 +142,7 @@
 /// making local unwinds fast.
 class __attribute__((visibility("hidden"))) LocalAddressSpace {
 public:
-#ifdef __LP64__
+#if defined(__LP64__) || defined(_WIN64)
   typedef uint64_t pint_t;
   typedef int64_t  sint_t;
 #else
@@ -194,7 +194,7 @@
 };
 
 inline uintptr_t LocalAddressSpace::getP(pint_t addr) {
-#ifdef __LP64__
+#if defined(__LP64__) || defined(_WIN64)
   return get64(addr);
 #else
   return get32(addr);
Index: include/unwind.h
===
--- include/unwind.h
+++ include/unwind.h
@@ -122,7 +122,7 @@
 _Unwind_Exception *exc);
   uintptr_t private_1; // non-zero means forced unwind
   uintptr_t private_2; // holds sp that phase1 found for phase2 to use
-#ifndef 

[PATCH] D38134: [OpenCL] Emit enqueued block as kernel

2017-10-11 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 118677.
yaxunl marked 2 inline comments as done.
yaxunl added a comment.

Revised by Anastasia's comments. Get block invoke function by API instead of 
iterate through IR's. Pass the block kernel directly to `__enqueu_kernel 
functions`.


https://reviews.llvm.org/D38134

Files:
  lib/CodeGen/CGBlocks.cpp
  lib/CodeGen/CGBuiltin.cpp
  lib/CodeGen/CGOpenCLRuntime.cpp
  lib/CodeGen/CGOpenCLRuntime.h
  lib/CodeGen/CodeGenFunction.h
  lib/CodeGen/CodeGenTypes.h
  lib/CodeGen/TargetInfo.cpp
  lib/CodeGen/TargetInfo.h
  test/CodeGenOpenCL/amdgpu-enqueue-kernel.cl
  test/CodeGenOpenCL/cl20-device-side-enqueue.cl

Index: test/CodeGenOpenCL/cl20-device-side-enqueue.cl
===
--- test/CodeGenOpenCL/cl20-device-side-enqueue.cl
+++ test/CodeGenOpenCL/cl20-device-side-enqueue.cl
@@ -6,10 +6,30 @@
 typedef void (^bl_t)(local void *);
 typedef struct {int a;} ndrange_t;
 
-// N.B. The check here only exists to set BL_GLOBAL
-// COMMON: @block_G =  addrspace(1) constant void (i8 addrspace(3)*) addrspace(4)* addrspacecast (void (i8 addrspace(3)*) addrspace(1)* bitcast ({ i32, i32, i8 addrspace(4)* } addrspace(1)* [[BL_GLOBAL:@__block_literal_global(\.[0-9]+)?]] to void (i8 addrspace(3)*) addrspace(1)*) to void (i8 addrspace(3)*) addrspace(4)*)
+// COMMON: %struct.__opencl_block_literal_generic = type { i32, i32, i8 addrspace(4)* }
+
+// For a block global variable, first emit the block literal as a global variable, then emit the block variable itself.
+// COMMON: [[BL_GLOBAL:@__block_literal_global[^ ]*]] = internal addrspace(1) constant { i32, i32, i8 addrspace(4)* } { i32 {{[0-9]+}}, i32 {{[0-9]+}}, i8 addrspace(4)* addrspacecast (i8* bitcast (void (i8 addrspace(4)*, i8 addrspace(3)*)* [[INV_G:@[^ ]+]] to i8*) to i8 addrspace(4)*) }
+// COMMON: @block_G =  addrspace(1) constant void (i8 addrspace(3)*) addrspace(4)* addrspacecast (void (i8 addrspace(3)*) addrspace(1)* bitcast ({ i32, i32, i8 addrspace(4)* } addrspace(1)* [[BL_GLOBAL]] to void (i8 addrspace(3)*) addrspace(1)*) to void (i8 addrspace(3)*) addrspace(4)*)
+
+// For anonymous blocks without captures, emit block literals as global variable.
+// COMMON: [[BLG1:@__block_literal_global[^ ]*]] = internal addrspace(1) constant { i32, i32, i8 addrspace(4)* } { i32 {{[0-9]+}}, i32 {{[0-9]+}}, i8 addrspace(4)* addrspacecast (i8* bitcast (void (i8 addrspace(4)*, i8 addrspace(3)*)* {{@[^ ]+}} to i8*) to i8 addrspace(4)*) }
+// COMMON: [[BLG2:@__block_literal_global[^ ]*]] = internal addrspace(1) constant { i32, i32, i8 addrspace(4)* } { i32 {{[0-9]+}}, i32 {{[0-9]+}}, i8 addrspace(4)* addrspacecast (i8* bitcast (void (i8 addrspace(4)*, i8 addrspace(3)*)* {{@[^ ]+}} to i8*) to i8 addrspace(4)*) }
+// COMMON: [[BLG3:@__block_literal_global[^ ]*]] = internal addrspace(1) constant { i32, i32, i8 addrspace(4)* } { i32 {{[0-9]+}}, i32 {{[0-9]+}}, i8 addrspace(4)* addrspacecast (i8* bitcast (void (i8 addrspace(4)*, i8 addrspace(3)*)* {{@[^ ]+}} to i8*) to i8 addrspace(4)*) }
+// COMMON: [[BLG4:@__block_literal_global[^ ]*]] = internal addrspace(1) constant { i32, i32, i8 addrspace(4)* } { i32 {{[0-9]+}}, i32 {{[0-9]+}}, i8 addrspace(4)* addrspacecast (i8* bitcast (void (i8 addrspace(4)*, i8 addrspace(3)*)* {{@[^ ]+}} to i8*) to i8 addrspace(4)*) }
+// COMMON: [[BLG5:@__block_literal_global[^ ]*]] = internal addrspace(1) constant { i32, i32, i8 addrspace(4)* } { i32 {{[0-9]+}}, i32 {{[0-9]+}}, i8 addrspace(4)* addrspacecast (i8* bitcast (void (i8 addrspace(4)*, i8 addrspace(3)*)* {{@[^ ]+}} to i8*) to i8 addrspace(4)*) }
+// COMMON: [[BLG6:@__block_literal_global[^ ]*]] = internal addrspace(1) constant { i32, i32, i8 addrspace(4)* } { i32 {{[0-9]+}}, i32 {{[0-9]+}}, i8 addrspace(4)* addrspacecast (i8* bitcast (void (i8 addrspace(4)*, i8 addrspace(3)*, i8 addrspace(3)*, i8 addrspace(3)*)* {{@[^ ]+}} to i8*) to i8 addrspace(4)*) }
+// COMMON: [[BLG7:@__block_literal_global[^ ]*]] = internal addrspace(1) constant { i32, i32, i8 addrspace(4)* } { i32 {{[0-9]+}}, i32 {{[0-9]+}}, i8 addrspace(4)* addrspacecast (i8* bitcast (void (i8 addrspace(4)*, i8 addrspace(3)*)* {{@[^ ]+}} to i8*) to i8 addrspace(4)*) }
+// COMMON: [[BLG8:@__block_literal_global[^ ]*]] = internal addrspace(1) constant { i32, i32, i8 addrspace(4)* } { i32 {{[0-9]+}}, i32 {{[0-9]+}}, i8 addrspace(4)* addrspacecast (i8* bitcast (void (i8 addrspace(4)*)* [[INVG8:@[^ ]+]] to i8*) to i8 addrspace(4)*) }
+// COMMON: [[BLG9:@__block_literal_global[^ ]*]] = internal addrspace(1) constant { i32, i32, i8 addrspace(4)* } { i32 {{[0-9]+}}, i32 {{[0-9]+}}, i8 addrspace(4)* addrspacecast (i8* bitcast (void (i8 addrspace(4)*, i8 addrspace(3)*)* [[INVG9:@[^ ]+]] to i8*) to i8 addrspace(4)*) }
+// COMMON: [[BLG10:@__block_literal_global[^ ]*]] = internal addrspace(1) constant { i32, i32, i8 addrspace(4)* } { i32 {{[0-9]+}}, i32 {{[0-9]+}}, i8 addrspace(4)* addrspacecast (i8* bitcast (void (i8 addrspace(4)*)* {{@[^ ]+}} to i8*) to i8 

[PATCH] D38679: [libunwind] Support dwarf unwinding on i386 windows

2017-10-11 Thread Martin Storsjö via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL315498: Support DWARF unwinding on i386 windows (authored by 
mstorsjo).

Changed prior to commit:
  https://reviews.llvm.org/D38679?vs=118263=118673#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D38679

Files:
  libunwind/trunk/src/AddressSpace.hpp
  libunwind/trunk/src/UnwindRegistersRestore.S
  libunwind/trunk/src/assembly.h
  libunwind/trunk/src/config.h

Index: libunwind/trunk/src/UnwindRegistersRestore.S
===
--- libunwind/trunk/src/UnwindRegistersRestore.S
+++ libunwind/trunk/src/UnwindRegistersRestore.S
@@ -18,6 +18,10 @@
 #
 # void libunwind::Registers_x86::jumpto()
 #
+#if defined(_WIN32)
+# On windows, the 'this' pointer is passed in ecx instead of on the stack
+  movl   %ecx, %eax
+#else
 # On entry:
 #  +   +
 #  +---+
@@ -27,6 +31,7 @@
 #  +---+   <-- SP
 #  +   +
   movl   4(%esp), %eax
+#endif
   # set up eax and ret on new stack location
   movl  28(%eax), %edx # edx holds new stack pointer
   subl  $8,%edx
Index: libunwind/trunk/src/config.h
===
--- libunwind/trunk/src/config.h
+++ libunwind/trunk/src/config.h
@@ -37,6 +37,8 @@
 #define _LIBUNWIND_SUPPORT_COMPACT_UNWIND
 #define _LIBUNWIND_SUPPORT_DWARF_UNWIND   1
   #endif
+#elif defined(_WIN32)
+  #define _LIBUNWIND_SUPPORT_DWARF_UNWIND 1
 #else
   #if defined(__ARM_DWARF_EH__) || !defined(__arm__)
 #define _LIBUNWIND_SUPPORT_DWARF_UNWIND 1
Index: libunwind/trunk/src/AddressSpace.hpp
===
--- libunwind/trunk/src/AddressSpace.hpp
+++ libunwind/trunk/src/AddressSpace.hpp
@@ -18,7 +18,7 @@
 #include 
 #include 
 
-#ifndef _LIBUNWIND_IS_BAREMETAL
+#if !defined(_LIBUNWIND_IS_BAREMETAL) && !defined(_WIN32)
 #include 
 #endif
 
@@ -97,7 +97,12 @@
 // independent ELF header traversal is not provided by  on some
 // systems (e.g., FreeBSD). On these systems the data structures are
 // just called Elf_XXX. Define ElfW() locally.
+#ifndef _WIN32
 #include 
+#else
+#include 
+#include 
+#endif
 #if !defined(ElfW)
 #define ElfW(type) Elf_##type
 #endif
@@ -356,6 +361,43 @@
  info.arm_section, info.arm_section_length);
   if (info.arm_section && info.arm_section_length)
 return true;
+#elif defined(_LIBUNWIND_SUPPORT_DWARF_UNWIND) && defined(_WIN32)
+  HMODULE mods[1024];
+  HANDLE process = GetCurrentProcess();
+  DWORD needed;
+
+  if (!EnumProcessModules(process, mods, sizeof(mods), ))
+return false;
+
+  for (unsigned i = 0; i < (needed / sizeof(HMODULE)); i++) {
+PIMAGE_DOS_HEADER pidh = (PIMAGE_DOS_HEADER)mods[i];
+PIMAGE_NT_HEADERS pinh = (PIMAGE_NT_HEADERS)((BYTE *)pidh + pidh->e_lfanew);
+PIMAGE_FILE_HEADER pifh = (PIMAGE_FILE_HEADER)>FileHeader;
+PIMAGE_SECTION_HEADER pish = IMAGE_FIRST_SECTION(pinh);
+bool found_obj = false;
+bool found_hdr = false;
+
+info.dso_base = (uintptr_t)mods[i];
+for (unsigned j = 0; j < pifh->NumberOfSections; j++, pish++) {
+  uintptr_t begin = pish->VirtualAddress + (uintptr_t)mods[i];
+  uintptr_t end = begin + pish->Misc.VirtualSize;
+  if (!strncmp((const char *)pish->Name, ".text",
+   IMAGE_SIZEOF_SHORT_NAME)) {
+if (targetAddr >= begin && targetAddr < end)
+  found_obj = true;
+  } else if (!strncmp((const char *)pish->Name, ".eh_frame",
+  IMAGE_SIZEOF_SHORT_NAME)) {
+// FIXME: This section name actually is truncated, ideally we
+// should locate and check the full long name instead.
+info.dwarf_section = begin;
+info.dwarf_section_length = pish->Misc.VirtualSize;
+found_hdr = true;
+  }
+  if (found_obj && found_hdr)
+return true;
+}
+  }
+  return false;
 #elif defined(_LIBUNWIND_ARM_EHABI) || defined(_LIBUNWIND_SUPPORT_DWARF_UNWIND)
   struct dl_iterate_cb_data {
 LocalAddressSpace *addressSpace;
@@ -478,7 +520,7 @@
 inline bool LocalAddressSpace::findFunctionName(pint_t addr, char *buf,
 size_t bufLen,
 unw_word_t *offset) {
-#ifndef _LIBUNWIND_IS_BAREMETAL
+#if !defined(_LIBUNWIND_IS_BAREMETAL) && !defined(_WIN32)
   Dl_info dyldInfo;
   if (dladdr((void *)addr, )) {
 if (dyldInfo.dli_sname != NULL) {
Index: libunwind/trunk/src/assembly.h
===
--- libunwind/trunk/src/assembly.h
+++ libunwind/trunk/src/assembly.h
@@ -26,6 +26,14 @@
 
 #if defined(__APPLE__)
 #define HIDDEN_DIRECTIVE .private_extern
+#elif defined(_WIN32)
+// In the COFF object file format, there's no attributes for a global,
+// non-static symbol to make it somehow hidden. So on windows, we don't

[libunwind] r315498 - Support DWARF unwinding on i386 windows

2017-10-11 Thread Martin Storsjo via cfe-commits
Author: mstorsjo
Date: Wed Oct 11 13:06:18 2017
New Revision: 315498

URL: http://llvm.org/viewvc/llvm-project?rev=315498=rev
Log:
Support DWARF unwinding on i386 windows

In practice, with code built with clang, there are still unresolved
issues with DW_CFA_GNU_args_size though.

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

Modified:
libunwind/trunk/src/AddressSpace.hpp
libunwind/trunk/src/UnwindRegistersRestore.S
libunwind/trunk/src/assembly.h
libunwind/trunk/src/config.h

Modified: libunwind/trunk/src/AddressSpace.hpp
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/src/AddressSpace.hpp?rev=315498=315497=315498=diff
==
--- libunwind/trunk/src/AddressSpace.hpp (original)
+++ libunwind/trunk/src/AddressSpace.hpp Wed Oct 11 13:06:18 2017
@@ -18,7 +18,7 @@
 #include 
 #include 
 
-#ifndef _LIBUNWIND_IS_BAREMETAL
+#if !defined(_LIBUNWIND_IS_BAREMETAL) && !defined(_WIN32)
 #include 
 #endif
 
@@ -97,7 +97,12 @@ extern char __exidx_end;
 // independent ELF header traversal is not provided by  on some
 // systems (e.g., FreeBSD). On these systems the data structures are
 // just called Elf_XXX. Define ElfW() locally.
+#ifndef _WIN32
 #include 
+#else
+#include 
+#include 
+#endif
 #if !defined(ElfW)
 #define ElfW(type) Elf_##type
 #endif
@@ -356,6 +361,43 @@ inline bool LocalAddressSpace::findUnwin
  info.arm_section, info.arm_section_length);
   if (info.arm_section && info.arm_section_length)
 return true;
+#elif defined(_LIBUNWIND_SUPPORT_DWARF_UNWIND) && defined(_WIN32)
+  HMODULE mods[1024];
+  HANDLE process = GetCurrentProcess();
+  DWORD needed;
+
+  if (!EnumProcessModules(process, mods, sizeof(mods), ))
+return false;
+
+  for (unsigned i = 0; i < (needed / sizeof(HMODULE)); i++) {
+PIMAGE_DOS_HEADER pidh = (PIMAGE_DOS_HEADER)mods[i];
+PIMAGE_NT_HEADERS pinh = (PIMAGE_NT_HEADERS)((BYTE *)pidh + 
pidh->e_lfanew);
+PIMAGE_FILE_HEADER pifh = (PIMAGE_FILE_HEADER)>FileHeader;
+PIMAGE_SECTION_HEADER pish = IMAGE_FIRST_SECTION(pinh);
+bool found_obj = false;
+bool found_hdr = false;
+
+info.dso_base = (uintptr_t)mods[i];
+for (unsigned j = 0; j < pifh->NumberOfSections; j++, pish++) {
+  uintptr_t begin = pish->VirtualAddress + (uintptr_t)mods[i];
+  uintptr_t end = begin + pish->Misc.VirtualSize;
+  if (!strncmp((const char *)pish->Name, ".text",
+   IMAGE_SIZEOF_SHORT_NAME)) {
+if (targetAddr >= begin && targetAddr < end)
+  found_obj = true;
+  } else if (!strncmp((const char *)pish->Name, ".eh_frame",
+  IMAGE_SIZEOF_SHORT_NAME)) {
+// FIXME: This section name actually is truncated, ideally we
+// should locate and check the full long name instead.
+info.dwarf_section = begin;
+info.dwarf_section_length = pish->Misc.VirtualSize;
+found_hdr = true;
+  }
+  if (found_obj && found_hdr)
+return true;
+}
+  }
+  return false;
 #elif defined(_LIBUNWIND_ARM_EHABI) || defined(_LIBUNWIND_SUPPORT_DWARF_UNWIND)
   struct dl_iterate_cb_data {
 LocalAddressSpace *addressSpace;
@@ -478,7 +520,7 @@ inline bool LocalAddressSpace::findOther
 inline bool LocalAddressSpace::findFunctionName(pint_t addr, char *buf,
 size_t bufLen,
 unw_word_t *offset) {
-#ifndef _LIBUNWIND_IS_BAREMETAL
+#if !defined(_LIBUNWIND_IS_BAREMETAL) && !defined(_WIN32)
   Dl_info dyldInfo;
   if (dladdr((void *)addr, )) {
 if (dyldInfo.dli_sname != NULL) {

Modified: libunwind/trunk/src/UnwindRegistersRestore.S
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/src/UnwindRegistersRestore.S?rev=315498=315497=315498=diff
==
--- libunwind/trunk/src/UnwindRegistersRestore.S (original)
+++ libunwind/trunk/src/UnwindRegistersRestore.S Wed Oct 11 13:06:18 2017
@@ -18,6 +18,10 @@ DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9li
 #
 # void libunwind::Registers_x86::jumpto()
 #
+#if defined(_WIN32)
+# On windows, the 'this' pointer is passed in ecx instead of on the stack
+  movl   %ecx, %eax
+#else
 # On entry:
 #  +   +
 #  +---+
@@ -27,6 +31,7 @@ DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9li
 #  +---+   <-- SP
 #  +   +
   movl   4(%esp), %eax
+#endif
   # set up eax and ret on new stack location
   movl  28(%eax), %edx # edx holds new stack pointer
   subl  $8,%edx

Modified: libunwind/trunk/src/assembly.h
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/src/assembly.h?rev=315498=315497=315498=diff
==
--- libunwind/trunk/src/assembly.h (original)
+++ libunwind/trunk/src/assembly.h Wed Oct 11 13:06:18 2017
@@ -26,6 

[PATCH] D38816: Convert clang::LangAS to a strongly typed enum

2017-10-11 Thread Alexander Richardson via Phabricator via cfe-commits
arichardson created this revision.
Herald added subscribers: Anastasia, nhaehnle, jholewinski.

Currently both clang AST address spaces and target specific address spaces
are represented as unsigned which can lead to subtle errors if the wrong
type is passed. It is especially confusing in the CodeGen files as it is
not possible to see what kind of address space should be passed to a
function without looking at the implementation.
I originally made this change for our LLVM fork for the CHERI architecture
where we make extensive use of address spaces to differentiate between
capabilities and pointers. When merging the upstream changes I usually
run into some test failures or runtime crashes because the wrong kind of
address space is passed to a function. By converting the LangAS enum to a
C++11 we can catch these errors at compile time. Additionally, it is now
obvious from the function signature which kind of address space it expects.

I found the following errors while writing this patch:

- ItaniumRecordLayoutBuilder::LayoutField was passing a clang AST address space 
to  TargetInfo::getPointer{Width,Align}()
- TypePrinter::printAttributedAfter() was printing the numeric value of the 
clang AST address space instead of the target address space
- initializeForBlockHeader() in CGBlocks.cpp was passing LangAS::opencl_generic 
to TargetInfo::getPointer{Width,Align}()
- CodeGenFunction::EmitBlockLiteral() was passing a AST address space to 
TargetInfo::getPointerWidth()
- clang_getAddressSpace() was returning either a LangAS or a target address 
address space. I made it consistently return a target address space
- CGOpenMPRuntimeNVPTX::translateParameter() passed a target address space to 
Qualifiers::addAddressSpace()
- CGOpenMPRuntimeNVPTX::getParameterAddress() was using 
llvm::Type::getPointerTo() with a AST address space

Other than this the patch should not cause any functional changes.


Repository:
  rL LLVM

https://reviews.llvm.org/D38816

Files:
  include/clang/AST/ASTContext.h
  include/clang/AST/Type.h
  include/clang/Basic/AddressSpaces.h
  include/clang/Basic/TargetInfo.h
  lib/AST/ASTContext.cpp
  lib/AST/ItaniumMangle.cpp
  lib/AST/RecordLayoutBuilder.cpp
  lib/AST/TypePrinter.cpp
  lib/Basic/TargetInfo.cpp
  lib/Basic/Targets/AMDGPU.cpp
  lib/Basic/Targets/AMDGPU.h
  lib/CodeGen/CGBlocks.cpp
  lib/CodeGen/CGDecl.cpp
  lib/CodeGen/CGExprConstant.cpp
  lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
  lib/CodeGen/CGValue.h
  lib/CodeGen/CodeGenFunction.cpp
  lib/CodeGen/CodeGenModule.cpp
  lib/CodeGen/CodeGenModule.h
  lib/CodeGen/CodeGenTypeCache.h
  lib/CodeGen/ConstantEmitter.h
  lib/CodeGen/TargetInfo.cpp
  lib/CodeGen/TargetInfo.h
  lib/Sema/SemaChecking.cpp
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaDeclAttr.cpp
  lib/Sema/SemaDeclObjC.cpp
  lib/Sema/SemaExpr.cpp
  lib/Sema/SemaExprCXX.cpp
  lib/Sema/SemaTemplateDeduction.cpp
  lib/Sema/SemaType.cpp
  tools/libclang/CXType.cpp

Index: tools/libclang/CXType.cpp
===
--- tools/libclang/CXType.cpp
+++ tools/libclang/CXType.cpp
@@ -398,12 +398,8 @@
 
 unsigned clang_getAddressSpace(CXType CT) {
   QualType T = GetQualType(CT);
-
-  // For non language-specific address space, use separate helper function.
-  if (T.getAddressSpace() >= LangAS::FirstTargetAddressSpace) {
-return T.getQualifiers().getAddressSpaceAttributePrintValue();
-  }
-  return T.getAddressSpace();
+  ASTContext  = cxtu::getASTUnit(GetTU(CT))->getASTContext();
+  return Ctx.getTargetAddressSpace(T);
 }
 
 CXString clang_getTypedefName(CXType CT) {
Index: lib/Sema/SemaType.cpp
===
--- lib/Sema/SemaType.cpp
+++ lib/Sema/SemaType.cpp
@@ -5632,7 +5632,7 @@
 // If this type is already address space qualified, reject it.
 // ISO/IEC TR 18037 S5.3 (amending C99 6.7.3): "No type shall be qualified
 // by qualifiers for two or more different address spaces."
-if (T.getAddressSpace()) {
+if (T.getAddressSpace() != LangAS::Default) {
   Diag(AttrLoc, diag::err_attribute_address_multiple_qualifiers);
   return QualType();
 }
@@ -5656,15 +5656,16 @@
 }
 
 llvm::APSInt max(addrSpace.getBitWidth());
-max = Qualifiers::MaxAddressSpace - LangAS::FirstTargetAddressSpace;
+max =
+Qualifiers::MaxAddressSpace - (unsigned)LangAS::FirstTargetAddressSpace;
 if (addrSpace > max) {
   Diag(AttrLoc, diag::err_attribute_address_space_too_high)
   << (unsigned)max.getZExtValue() << AddrSpace->getSourceRange();
   return QualType();
 }
 
-unsigned ASIdx = static_cast(addrSpace.getZExtValue()) +
- LangAS::FirstTargetAddressSpace;
+LangAS ASIdx = LanguageAS::fromTargetAS(
+static_cast(addrSpace.getZExtValue()));
 
 return Context.getAddrSpaceQualType(T, ASIdx);
   }
@@ -5690,7 +5691,7 @@
   // If this type is already address space qualified, reject it.
   // ISO/IEC TR 18037 

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

2017-10-11 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo added a comment.

In https://reviews.llvm.org/D36111#895084, @mgrang wrote:

> Sorry, I never got to complete this as I moved to other priorities. I do not 
> think I have cycles to do this now. Please feel free to take over this patch 
> :)


Ok - will do! Thanks for letting me know!


https://reviews.llvm.org/D36111



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


Re: [clang-tools-extra] r315060 - Renaming a test to start with the name of the check based on post-commit review feedback; NFC.

2017-10-11 Thread Aaron Ballman via cfe-commits
On Wed, Oct 11, 2017 at 3:29 PM, Alexander Kornienko  wrote:
> On Fri, Oct 6, 2017 at 3:27 PM, Aaron Ballman via cfe-commits
>  wrote:
>>
>> Author: aaronballman
>> Date: Fri Oct  6 06:27:59 2017
>> New Revision: 315060
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=315060=rev
>> Log:
>> Renaming a test to start with the name of the check based on post-commit
>> review feedback; NFC.
>>
>> Added:
>>
>> clang-tools-extra/trunk/test/clang-tidy/google-readability-namespace-comments-cxx17
>
>
> Sorry for not being clear. I didn't mean the `.cpp` extension should be
> removed. This effectively disables the test, since lit only runs tests in
> files with certain extensions (under clang-tools-extra/test these are '.c',
> '.cpp', '.hpp', '.m', '.mm', '.cu', '.ll', '.cl', '.s', '.modularize',
> '.module-map-checker', '.test').

That's entirely my fault -- I should have recognized that. Sorry for
the trouble!

> I've just renamed the file to *.cpp and the test fails for me:
>
> [0/1] Running the Clang extra tools' regression tests
> FAIL: Clang Tools ::
> clang-tidy/google-readability-namespace-comments-cxx17.cpp (102 of 674)
>  TEST 'Clang Tools ::
> clang-tidy/google-readability-namespace-comments-cxx17.cpp' FAILED
> 
> Script:
> --
> /usr/bin/python2.7
> /src/tools/clang/tools/extra/test/../test/clang-tidy/check_clang_tidy.py
> /src/tools/clang/tools/extra/test/clang-tidy/google-readability-namespace-comments-cxx17.cpp
> google-readability-namespace-comments
> /build/tools/clang/tools/extra/test/clang-tidy/Output/google-readability-namespace-comments-cxx17.cpp.tmp
> -- -- -std=c++17
> --
> Exit Code: 1
>
> Command Output (stdout):
> --
> Running ['clang-tidy',
> '/build/tools/clang/tools/extra/test/clang-tidy/Output/google-readability-namespace-comments-cxx17.cpp.tmp.cpp',
> '-fix', '--checks=-*,google-readability-namespace-comments', '--',
> '-std=c++17', '-nostdinc++']...
>  clang-tidy output ---
>
> --
> -- Fixes -
>
> --
> FileCheck failed:
> /src/tools/clang/tools/extra/test/clang-tidy/google-readability-namespace-comments-cxx17.cpp:13:17:
> error: expected string not found in input
> // CHECK-FIXES: }  // namespace n3
> ^
> /build/tools/clang/tools/extra/test/clang-tidy/Output/google-readability-namespace-comments-cxx17.cpp.tmp.cpp:1:1:
> note: scanning from here
> // RUN: %check_clang_tidy %s google-readability-namespace-comments %t -- --
> -std=c++17
> ^
> /build/tools/clang/tools/extra/test/clang-tidy/Output/google-readability-namespace-comments-cxx17.cpp.tmp.cpp:5:7:
> note: possible intended match here
>   // So that namespace is not empty.
>   ^
>
>
> --
> Command Output (stderr):
> --
> Traceback (most recent call last):
>   File
> "/src/tools/clang/tools/extra/test/../test/clang-tidy/check_clang_tidy.py",
> line 140, in 
> main()
>   File
> "/src/tools/clang/tools/extra/test/../test/clang-tidy/check_clang_tidy.py",
> line 121, in main
> stderr=subprocess.STDOUT)
>   File "/usr/lib/python2.7/subprocess.py", line 573, in check_output
> raise CalledProcessError(retcode, cmd, output=output)
> subprocess.CalledProcessError: Command '['FileCheck',
> '-input-file=/build/tools/clang/tools/extra/test/clang-tidy/Output/google-readability-namespace-comments-cxx17.cpp.tmp.cpp',
> '/src/tools/clang/tools/extra/test/clang-tidy/google-readability-namespace-comments-cxx17.cpp',
> '-check-prefix=CHECK-FIXES', '-strict-whitespace']' returned non-zero exit
> status 1
>
> --
>
> 
> Testing Time: 13.07s
> 
> Failing Tests (1):
> Clang Tools ::
> clang-tidy/google-readability-namespace-comments-cxx17.cpp
>
>   Expected Passes: 673
>   Unexpected Failures: 1
> FAILED: tools/clang/tools/extra/test/CMakeFiles/check-clang-tools
>
>
> Did you experience anything similar? Any ideas?

I now get the same behavior that you're seeing. I'm not certain what's
going on there (and don't have the time to look into it at the
moment), but perhaps Jonas has ideas.

~Aaron

>
>>   - copied unchanged from r315059,
>> clang-tools-extra/trunk/test/clang-tidy/google-readability-nested-namespace-comments.cpp
>> Removed:
>>
>> clang-tools-extra/trunk/test/clang-tidy/google-readability-nested-namespace-comments.cpp
>>
>> Removed:
>> clang-tools-extra/trunk/test/clang-tidy/google-readability-nested-namespace-comments.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/google-readability-nested-namespace-comments.cpp?rev=315059=auto
>>
>> ==
>> ---
>> clang-tools-extra/trunk/test/clang-tidy/google-readability-nested-namespace-comments.cpp

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

2017-10-11 Thread Mandeep Singh Grang via Phabricator via cfe-commits
mgrang added a comment.

In https://reviews.llvm.org/D36111#894604, @mstorsjo wrote:

> @mgrang, did you ever get to completing this? I've got a need for this now 
> (only `__dmb` so far), and if you don't have time, I can try to finish it.


Sorry, I never got to complete this as I moved to other priorities. I do not 
think I have cycles to do this now. Please feel free to take over this patch :)


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] D38679: [libunwind] Support dwarf unwinding on i386 windows

2017-10-11 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo added a comment.

In https://reviews.llvm.org/D38679#894668, @jroelofs wrote:

> LGTM


Thanks, will push this one without the docs update since it's still buggy in 
practice on windows until https://reviews.llvm.org/D38680 gets resolved.


https://reviews.llvm.org/D38679



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


Re: [clang-tools-extra] r315060 - Renaming a test to start with the name of the check based on post-commit review feedback; NFC.

2017-10-11 Thread Alexander Kornienko via cfe-commits
On Fri, Oct 6, 2017 at 3:27 PM, Aaron Ballman via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: aaronballman
> Date: Fri Oct  6 06:27:59 2017
> New Revision: 315060
>
> URL: http://llvm.org/viewvc/llvm-project?rev=315060=rev
> Log:
> Renaming a test to start with the name of the check based on post-commit
> review feedback; NFC.
>
> Added:
> clang-tools-extra/trunk/test/clang-tidy/google-readability-
> namespace-comments-cxx17
>

Sorry for not being clear. I didn't mean the `.cpp` extension should be
removed. This effectively disables the test, since lit only runs tests in
files with certain extensions (under clang-tools-extra/test these are '.c',
'.cpp', '.hpp', '.m', '.mm', '.cu', '.ll', '.cl', '.s', '.modularize',
'.module-map-checker', '.test').

I've just renamed the file to *.cpp and the test fails for me:

[0/1] Running the Clang extra tools' regression tests
FAIL: Clang Tools ::
clang-tidy/google-readability-namespace-comments-cxx17.cpp (102 of 674)

 TEST 'Clang Tools ::
clang-tidy/google-readability-namespace-comments-cxx17.cpp' FAILED


Script:
--
/usr/bin/python2.7
/src/tools/clang/tools/extra/test/../test/clang-tidy/check_clang_tidy.py
/src/tools/clang/tools/extra/test/clang-tidy/google-readability-namespace-comments-cxx17.cpp
google-readability-namespace-comments
/build/tools/clang/tools/extra/test/clang-tidy/Output/google-readability-namespace-comments-cxx17.cpp.tmp
-- -- -std=c++17
--
Exit Code: 1

Command Output (stdout):
--
Running ['clang-tidy',
'/build/tools/clang/tools/extra/test/clang-tidy/Output/google-readability-namespace-comments-cxx17.cpp.tmp.cpp',
'-fix', '--checks=-*,google-readability-namespace-comments', '--',
'-std=c++17', '-nostdinc++']...
 clang-tidy output ---


--

-- Fixes -


--

FileCheck failed:
/src/tools/clang/tools/extra/test/clang-tidy/google-readability-namespace-comments-cxx17.cpp:13:17:
error: expected string not found in input

// CHECK-FIXES: }  // namespace n3
^
/build/tools/clang/tools/extra/test/clang-tidy/Output/google-readability-namespace-comments-cxx17.cpp.tmp.cpp:1:1:
note: scanning from here

// RUN: %check_clang_tidy %s google-readability-namespace-comments %t -- --
-std=c++17
^
/build/tools/clang/tools/extra/test/clang-tidy/Output/google-readability-namespace-comments-cxx17.cpp.tmp.cpp:5:7:
note: possible intended match here

  // So that namespace is not empty.
  ^


--
Command Output (stderr):
--
Traceback (most recent call last):
  File
"/src/tools/clang/tools/extra/test/../test/clang-tidy/check_clang_tidy.py",
line 140, in 
main()
  File
"/src/tools/clang/tools/extra/test/../test/clang-tidy/check_clang_tidy.py",
line 121, in main
stderr=subprocess.STDOUT)
  File "/usr/lib/python2.7/subprocess.py", line 573, in check_output

raise CalledProcessError(retcode, cmd, output=output)
subprocess.CalledProcessError: Command '['FileCheck',
'-input-file=/build/tools/clang/tools/extra/test/clang-tidy/Output/google-readability-namespace-comments-cxx17.cpp.tmp.cpp',
'/src/tools/clang/tools/extra/test/clang-tidy/google-readability-namespace-comments-cxx17.cpp',
'-check-prefix=CHECK-FIXES', '-strict-whitespace']' returned non-zero exit
status 1


--


Testing Time: 13.07s

Failing Tests (1):
Clang Tools ::
clang-tidy/google-readability-namespace-comments-cxx17.cpp


  Expected Passes: 673
  Unexpected Failures: 1
FAILED: tools/clang/tools/extra/test/CMakeFiles/check-clang-tools



Did you experience anything similar? Any ideas?

  - copied unchanged from r315059, clang-tools-extra/trunk/test/
> clang-tidy/google-readability-nested-namespace-comments.cpp
> Removed:
> clang-tools-extra/trunk/test/clang-tidy/google-readability-
> nested-namespace-comments.cpp
>
> Removed: clang-tools-extra/trunk/test/clang-tidy/google-readability-
> nested-namespace-comments.cpp
> URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/
> trunk/test/clang-tidy/google-readability-nested-namespace-
> comments.cpp?rev=315059=auto
> 
> ==
> --- 
> clang-tools-extra/trunk/test/clang-tidy/google-readability-nested-namespace-comments.cpp
> (original)
> +++ 
> clang-tools-extra/trunk/test/clang-tidy/google-readability-nested-namespace-comments.cpp
> (removed)
> @@ -1,15 +0,0 @@
> -// RUN: %check_clang_tidy %s google-readability-namespace-comments %t --
> -- -std=c++17
> -
> -namespace n1::n2 {
> -namespace n3 {
> -  // So that namespace is not empty.
> -  void f();
> -
> -// CHECK-MESSAGES: :[[@LINE+4]]:2: warning: namespace 'n3' not terminated
> with
> -// CHECK-MESSAGES: :[[@LINE-7]]:11: note: namespace 'n3' starts here
> -// 

r315492 - [Analyzer] Fix introduced regression: properly check for nullable attribute.

2017-10-11 Thread George Karpenkov via cfe-commits
Author: george.karpenkov
Date: Wed Oct 11 12:13:15 2017
New Revision: 315492

URL: http://llvm.org/viewvc/llvm-project?rev=315492=rev
Log:
[Analyzer] Fix introduced regression: properly check for nullable attribute.

Modified:
cfe/trunk/lib/StaticAnalyzer/Checkers/NonnullStringConstantsChecker.cpp

Modified: 
cfe/trunk/lib/StaticAnalyzer/Checkers/NonnullStringConstantsChecker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/NonnullStringConstantsChecker.cpp?rev=315492=315491=315492=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/NonnullStringConstantsChecker.cpp 
(original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/NonnullStringConstantsChecker.cpp Wed 
Oct 11 12:13:15 2017
@@ -122,7 +122,8 @@ bool NonnullStringConstantsChecker::isSt
 return true;
 
   if (auto *T = dyn_cast(Ty)) {
-return T->getInterfaceDecl()->getIdentifier() == NSStringII;
+return T->getInterfaceDecl() &&
+  T->getInterfaceDecl()->getIdentifier() == NSStringII;
   } else if (auto *T = dyn_cast(Ty)) {
 return T->getDecl()->getIdentifier() == CFStringRefII;
   }


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


[PATCH] D23963: [analyzer] pr28449 - Move literal rvalue construction away from RegionStore.

2017-10-11 Thread Devin Coughlin via Phabricator via cfe-commits
dcoughlin accepted this revision.
dcoughlin added a comment.
This revision is now accepted and ready to land.

OK. Seems reasonable!


https://reviews.llvm.org/D23963



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


[PATCH] D38733: [CodeGen] Generate TBAA info along with LValue base info

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

Sure.


https://reviews.llvm.org/D38733



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


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

2017-10-11 Thread William Enright via Phabricator via cfe-commits
Nebiroth added a comment.

Bumping this.

I've worked on a patch for this feature that currently supports showing the 
declaration of whatever is being hovered on instead of the raw source code. It 
also has basic support to distinguish declarations in types ( class/struct, 
namespace, global variable,  typedef, enum, namespace, etc.) so that we can 
have a 'kind' of a symbol like mentioned in the comments above.

The step I am at right now is figuring out a way to display this information 
inside the box that will be displayed to the client once a response 
(MarkedString) is sent back by the server. I would like some 
feedback/suggestions on whether it's possible to "append" information to a 
MarkedString to be displayed on client? I was also considering extending LSP to 
include more than just a MarkedString for the response in order to have 
something a bit more flexible to use in-client.


https://reviews.llvm.org/D35894



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


r315489 - [Analyzer] Remove dead code from testing scripts

2017-10-11 Thread George Karpenkov via cfe-commits
Author: george.karpenkov
Date: Wed Oct 11 11:42:39 2017
New Revision: 315489

URL: http://llvm.org/viewvc/llvm-project?rev=315489=rev
Log:
[Analyzer] Remove dead code from testing scripts

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

Modified:
cfe/trunk/utils/analyzer/SATestBuild.py

Modified: cfe/trunk/utils/analyzer/SATestBuild.py
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/analyzer/SATestBuild.py?rev=315489=315488=315489=diff
==
--- cfe/trunk/utils/analyzer/SATestBuild.py (original)
+++ cfe/trunk/utils/analyzer/SATestBuild.py Wed Oct 11 11:42:39 2017
@@ -653,40 +653,6 @@ def cleanupReferenceResults(SBOutputDir)
 removeLogFile(SBOutputDir)
 
 
-def updateSVN(Mode, PMapFile):
-"""
-svn delete or svn add (depending on `Mode`) all folders defined in the file
-handler `PMapFile`.
-Commit the result to SVN.
-"""
-try:
-for I in iterateOverProjects(PMapFile):
-ProjName = I[0]
-Path = os.path.join(ProjName, getSBOutputDirName(True))
-
-if Mode == "delete":
-Command = "svn delete '%s'" % (Path,)
-else:
-Command = "svn add '%s'" % (Path,)
-
-if Verbose == 1:
-print "  Executing: %s" % (Command,)
-check_call(Command, shell=True)
-
-if Mode == "delete":
-CommitCommand = "svn commit -m \"[analyzer tests] Remove " \
-"reference results.\""
-else:
-CommitCommand = "svn commit -m \"[analyzer tests] Add new " \
-"reference results.\""
-if Verbose == 1:
-print "  Executing: %s" % (CommitCommand,)
-check_call(CommitCommand, shell=True)
-except:
-print "Error: SVN update failed."
-sys.exit(-1)
-
-
 def testProject(ID, ProjectBuildMode, IsReferenceBuild=False, Strictness=0):
 """
 Test a given project.
@@ -757,26 +723,16 @@ def validateProjectFile(PMapFile):
 raise Exception()
 
 
-def testAll(IsReferenceBuild=False, UpdateSVN=False, Strictness=0):
+def testAll(IsReferenceBuild=False, Strictness=0):
 TestsPassed = True
 with projectFileHandler() as PMapFile:
 validateProjectFile(PMapFile)
 
-# When we are regenerating the reference results, we might need to
-# update svn. Remove reference results from SVN.
-if UpdateSVN:
-assert(IsReferenceBuild)
-updateSVN("delete", PMapFile)
-
 # Test the projects.
 for (ProjName, ProjBuildMode) in iterateOverProjects(PMapFile):
 TestsPassed &= testProject(
 ProjName, int(ProjBuildMode), IsReferenceBuild, Strictness)
 
-# Re-add reference results to SVN.
-if UpdateSVN:
-updateSVN("add", PMapFile)
-
 
 if __name__ == '__main__':
 # Parse command line arguments.
@@ -789,20 +745,13 @@ if __name__ == '__main__':
  reference. Default is 0.')
 Parser.add_argument('-r', dest='regenerate', action='store_true',
 default=False, help='Regenerate reference output.')
-Parser.add_argument('-rs', dest='update_reference', action='store_true',
-default=False,
-help='Regenerate reference output and update svn.')
 Args = Parser.parse_args()
 
 IsReference = False
-UpdateSVN = False
 Strictness = Args.strictness
 if Args.regenerate:
 IsReference = True
-elif Args.update_reference:
-IsReference = True
-UpdateSVN = True
 
-TestsPassed = testAll(IsReference, UpdateSVN, Strictness)
+TestsPassed = testAll(IsReference, Strictness)
 if not TestsPassed:
 sys.exit(-1)


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


[PATCH] D38764: [Analyzer] Assume const string-like globals are non-null

2017-10-11 Thread George Karpenkov via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL315488: [Analyzer] Assume that string-like const globals are 
non-nil. (authored by george.karpenkov).

Changed prior to commit:
  https://reviews.llvm.org/D38764?vs=118657=118660#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D38764

Files:
  cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td
  cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt
  cfe/trunk/lib/StaticAnalyzer/Checkers/NonnullStringConstantsChecker.cpp
  cfe/trunk/test/Analysis/nonnull-string-constants.mm

Index: cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt
===
--- cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt
@@ -57,6 +57,7 @@
   NSErrorChecker.cpp
   NoReturnFunctionChecker.cpp
   NonNullParamChecker.cpp
+  NonnullStringConstantsChecker.cpp
   NullabilityChecker.cpp
   NumberObjectConversionChecker.cpp
   ObjCAtSyncChecker.cpp
Index: cfe/trunk/lib/StaticAnalyzer/Checkers/NonnullStringConstantsChecker.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Checkers/NonnullStringConstantsChecker.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/NonnullStringConstantsChecker.cpp
@@ -0,0 +1,134 @@
+//==- NonnullStringConstantsChecker.cpp ---*- C++ -*--//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+//  This checker adds an assumption that constant string-like globals are
+//  non-null, as otherwise they generally do not convey any useful information.
+//  The assumption is useful, as many framework use such global const strings,
+//  and the analyzer might not be able to infer the global value if the
+//  definition is in a separate translation unit.
+//  The following types (and their typedef aliases) are considered string-like:
+//   - `char* const`
+//   - `const CFStringRef` from CoreFoundation
+//   - `NSString* const` from Foundation
+//
+//===--===//
+
+#include "ClangSACheckers.h"
+#include "clang/StaticAnalyzer/Core/BugReporter/BugType.h"
+#include "clang/StaticAnalyzer/Core/Checker.h"
+#include "clang/StaticAnalyzer/Core/CheckerManager.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h"
+
+using namespace clang;
+using namespace ento;
+
+namespace {
+
+class NonnullStringConstantsChecker : public Checker {
+  mutable IdentifierInfo *NSStringII = nullptr;
+  mutable IdentifierInfo *CFStringRefII = nullptr;
+
+public:
+  NonnullStringConstantsChecker() {}
+
+  void checkLocation(SVal l, bool isLoad, const Stmt *S,
+ CheckerContext ) const;
+
+private:
+  void initIdentifierInfo(ASTContext ) const;
+
+  bool isGlobalConstString(SVal V) const;
+
+  bool isStringlike(QualType Ty) const;
+};
+
+} // namespace
+
+/// Lazily initialize cache for required identifier informations.
+void NonnullStringConstantsChecker::initIdentifierInfo(ASTContext ) const {
+  if (NSStringII)
+return;
+
+  NSStringII = ("NSString");
+  CFStringRefII = ("CFStringRef");
+}
+
+/// Add an assumption that const string-like globals are non-null.
+void NonnullStringConstantsChecker::checkLocation(SVal location, bool isLoad,
+ const Stmt *S,
+ CheckerContext ) const {
+  initIdentifierInfo(C.getASTContext());
+  if (!isLoad || !location.isValid())
+return;
+
+  ProgramStateRef State = C.getState();
+  SVal V = State->getSVal(location.castAs());
+
+  if (isGlobalConstString(location)) {
+Optional Constr = V.getAs();
+
+if (Constr) {
+
+  // Assume that the variable is non-null.
+  ProgramStateRef OutputState = State->assume(*Constr, true);
+  C.addTransition(OutputState);
+}
+  }
+}
+
+/// \param V loaded lvalue.
+/// \return whether {@code val} is a string-like const global.
+bool NonnullStringConstantsChecker::isGlobalConstString(SVal V) const {
+  Optional RegionVal = V.getAs();
+  if (!RegionVal)
+return false;
+  auto *Region = dyn_cast(RegionVal->getAsRegion());
+  if (!Region)
+return false;
+  const VarDecl *Decl = Region->getDecl();
+
+  if (!Decl->hasGlobalStorage())
+return false;
+
+  QualType Ty = Decl->getType();
+  bool HasConst = Ty.isConstQualified();
+  if (isStringlike(Ty) && HasConst)
+return true;
+
+  // Look through the typedefs.
+  while (auto *T = dyn_cast(Ty)) {
+Ty = T->getDecl()->getUnderlyingType();
+
+// It is sufficient for any intermediate typedef
+// to be classified const.
+

r315488 - [Analyzer] Assume that string-like const globals are non-nil.

2017-10-11 Thread George Karpenkov via cfe-commits
Author: george.karpenkov
Date: Wed Oct 11 11:39:40 2017
New Revision: 315488

URL: http://llvm.org/viewvc/llvm-project?rev=315488=rev
Log:
[Analyzer] Assume that string-like const globals are non-nil.

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

Added:
cfe/trunk/lib/StaticAnalyzer/Checkers/NonnullStringConstantsChecker.cpp
cfe/trunk/test/Analysis/nonnull-string-constants.mm
Modified:
cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td
cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt

Modified: cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td?rev=315488=315487=315488=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td (original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td Wed Oct 11 
11:39:40 2017
@@ -132,6 +132,10 @@ def DynamicTypePropagation : Checker<"Dy
   HelpText<"Generate dynamic type information">,
   DescFile<"DynamicTypePropagation.cpp">;
 
+def NonnullStringConstantsChecker: Checker<"NonnilStringConstants">,
+  HelpText<"Assume that const string-like globals are non-null">,
+  DescFile<"NonilStringConstantsChecker.cpp">;
+
 } // end "core"
 
 let ParentPackage = CoreAlpha in {

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt?rev=315488=315487=315488=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt Wed Oct 11 11:39:40 
2017
@@ -57,6 +57,7 @@ add_clang_library(clangStaticAnalyzerChe
   NSErrorChecker.cpp
   NoReturnFunctionChecker.cpp
   NonNullParamChecker.cpp
+  NonnullStringConstantsChecker.cpp
   NullabilityChecker.cpp
   NumberObjectConversionChecker.cpp
   ObjCAtSyncChecker.cpp

Added: cfe/trunk/lib/StaticAnalyzer/Checkers/NonnullStringConstantsChecker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/NonnullStringConstantsChecker.cpp?rev=315488=auto
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/NonnullStringConstantsChecker.cpp 
(added)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/NonnullStringConstantsChecker.cpp Wed 
Oct 11 11:39:40 2017
@@ -0,0 +1,134 @@
+//==- NonnullStringConstantsChecker.cpp ---*- C++ 
-*--//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+//  This checker adds an assumption that constant string-like globals are
+//  non-null, as otherwise they generally do not convey any useful information.
+//  The assumption is useful, as many framework use such global const strings,
+//  and the analyzer might not be able to infer the global value if the
+//  definition is in a separate translation unit.
+//  The following types (and their typedef aliases) are considered string-like:
+//   - `char* const`
+//   - `const CFStringRef` from CoreFoundation
+//   - `NSString* const` from Foundation
+//
+//===--===//
+
+#include "ClangSACheckers.h"
+#include "clang/StaticAnalyzer/Core/BugReporter/BugType.h"
+#include "clang/StaticAnalyzer/Core/Checker.h"
+#include "clang/StaticAnalyzer/Core/CheckerManager.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h"
+
+using namespace clang;
+using namespace ento;
+
+namespace {
+
+class NonnullStringConstantsChecker : public Checker {
+  mutable IdentifierInfo *NSStringII = nullptr;
+  mutable IdentifierInfo *CFStringRefII = nullptr;
+
+public:
+  NonnullStringConstantsChecker() {}
+
+  void checkLocation(SVal l, bool isLoad, const Stmt *S,
+ CheckerContext ) const;
+
+private:
+  void initIdentifierInfo(ASTContext ) const;
+
+  bool isGlobalConstString(SVal V) const;
+
+  bool isStringlike(QualType Ty) const;
+};
+
+} // namespace
+
+/// Lazily initialize cache for required identifier informations.
+void NonnullStringConstantsChecker::initIdentifierInfo(ASTContext ) const {
+  if (NSStringII)
+return;
+
+  NSStringII = ("NSString");
+  CFStringRefII = ("CFStringRef");
+}
+
+/// Add an assumption that const string-like globals are non-null.
+void NonnullStringConstantsChecker::checkLocation(SVal location, bool isLoad,
+ const Stmt *S,
+ CheckerContext ) const {
+  

[PATCH] D38764: [Analyzer] Assume const string-like globals are non-null

2017-10-11 Thread George Karpenkov via Phabricator via cfe-commits
george.karpenkov updated this revision to Diff 118657.
george.karpenkov marked 2 inline comments as done.

https://reviews.llvm.org/D38764

Files:
  include/clang/StaticAnalyzer/Checkers/Checkers.td
  lib/StaticAnalyzer/Checkers/CMakeLists.txt
  lib/StaticAnalyzer/Checkers/NonnullStringConstantsChecker.cpp
  test/Analysis/nonnull-string-constants.mm

Index: test/Analysis/nonnull-string-constants.mm
===
--- /dev/null
+++ test/Analysis/nonnull-string-constants.mm
@@ -0,0 +1,90 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -verify %s
+
+// Nullability of const string-like globals, testing
+// NonnullStringConstantsChecker.
+
+void clang_analyzer_eval(bool);
+
+@class NSString;
+typedef const struct __CFString *CFStringRef;
+
+// Global NSString* is non-null.
+extern NSString *const StringConstGlobal;
+void stringConstGlobal() {
+  clang_analyzer_eval(StringConstGlobal); // expected-warning{{TRUE}}
+}
+
+// The logic does not apply to local variables though.
+extern NSString *stringGetter();
+void stringConstLocal() {
+  NSString *const local = stringGetter();
+  clang_analyzer_eval(local); // expected-warning{{UNKNOWN}}
+}
+
+// Global const CFStringRef's are also assumed to be non-null.
+extern const CFStringRef CFStringConstGlobal;
+void cfStringCheckGlobal() {
+  clang_analyzer_eval(CFStringConstGlobal); // expected-warning{{TRUE}}
+}
+
+// But only "const" ones.
+extern CFStringRef CFStringNonConstGlobal;
+void cfStringCheckMutableGlobal() {
+  clang_analyzer_eval(CFStringNonConstGlobal); // expected-warning{{UNKNOWN}}
+}
+
+// char* const is also assumed to be non-null.
+extern const char *const ConstCharStarConst;
+void constCharStarCheckGlobal() {
+  clang_analyzer_eval(ConstCharStarConst); // expected-warning{{TRUE}}
+}
+
+// Pointer value can be mutable.
+extern char *const CharStarConst;
+void charStarCheckGlobal() {
+  clang_analyzer_eval(CharStarConst); // expected-warning{{TRUE}}
+}
+
+// But the pointer itself should be immutable.
+extern char *CharStar;
+void charStartCheckMutableGlobal() {
+  clang_analyzer_eval(CharStar); // expected-warning{{UNKNOWN}}
+}
+
+// Type definitions should also work across typedefs, for pointers:
+typedef char *const str;
+extern str globalStr;
+void charStarCheckTypedef() {
+  clang_analyzer_eval(globalStr); // expected-warning{{TRUE}}
+}
+
+// And for types.
+typedef NSString *const NStr;
+extern NStr globalNSString;
+void NSStringCheckTypedef() {
+  clang_analyzer_eval(globalNSString); // expected-warning{{TRUE}}
+}
+
+// Note that constness could be either inside
+// the var declaration, or in a typedef.
+typedef NSString *NStr2;
+extern const NStr2 globalNSString2;
+void NSStringCheckConstTypedef() {
+  clang_analyzer_eval(globalNSString2); // expected-warning{{TRUE}}
+}
+
+// Nested typedefs should work as well.
+typedef const CFStringRef str1;
+typedef str1 str2;
+extern str2 globalStr2;
+void testNestedTypedefs() {
+  clang_analyzer_eval(globalStr2); // expected-warning{{TRUE}}
+}
+
+// And for NSString *.
+typedef NSString *const nstr1;
+typedef nstr1 nstr2;
+extern nstr2 nglobalStr2;
+void testNestedTypedefsForNSString() {
+  clang_analyzer_eval(nglobalStr2); // expected-warning{{TRUE}}
+}
Index: lib/StaticAnalyzer/Checkers/NonnullStringConstantsChecker.cpp
===
--- /dev/null
+++ lib/StaticAnalyzer/Checkers/NonnullStringConstantsChecker.cpp
@@ -0,0 +1,134 @@
+//==- NonnullStringConstantsChecker.cpp ---*- C++ -*--//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+//  This checker adds an assumption that constant string-like globals are
+//  non-null, as otherwise they generally do not convey any useful information.
+//  The assumption is useful, as many framework use such global const strings,
+//  and the analyzer might not be able to infer the global value if the
+//  definition is in a separate translation unit.
+//  The following types (and their typedef aliases) are considered string-like:
+//   - `char* const`
+//   - `const CFStringRef` from CoreFoundation
+//   - `NSString* const` from Foundation
+//
+//===--===//
+
+#include "ClangSACheckers.h"
+#include "clang/StaticAnalyzer/Core/BugReporter/BugType.h"
+#include "clang/StaticAnalyzer/Core/Checker.h"
+#include "clang/StaticAnalyzer/Core/CheckerManager.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h"
+
+using namespace clang;
+using namespace ento;
+
+namespace {
+
+class NonnullStringConstantsChecker : public Checker {
+  mutable IdentifierInfo 

[PATCH] D38764: [Analyzer] Assume const string-like globals are non-null

2017-10-11 Thread George Karpenkov via Phabricator via cfe-commits
george.karpenkov marked 9 inline comments as done.
george.karpenkov added inline comments.



Comment at: lib/StaticAnalyzer/Checkers/NonnullStringConstantsChecker.cpp:22
+//  Checker uses are defined in the test file:
+//   - test/Analysis/nonnull-string-constants.mm
+//

dcoughlin wrote:
> We generally don't do this kind of cross-reference in comments since they 
> tend to get stale fast when things get moved around. There is no tool support 
> to keep them in sync.
:(
I guess I'm too spoiled by Javadoc.



Comment at: lib/StaticAnalyzer/Checkers/NonnullStringConstantsChecker.cpp:53
+private:
+  /// Lazily initialize cache for required identifier informations.
+  void initIdentifierInfo(ASTContext ) const;

dcoughlin wrote:
> We usually put the oxygen comments on checkers on the implementation and not 
> the interface since they aren't API and people reading the code generally 
> look at the implementations. Can you move them to the implementations?
OK. I assume there's no good universal solution here.


https://reviews.llvm.org/D38764



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


[PATCH] D38797: [analyzer] CStringChecker: pr34460: Admit that some casts are hard to model.

2017-10-11 Thread Devin Coughlin via Phabricator via cfe-commits
dcoughlin accepted this revision.
dcoughlin added a comment.
This revision is now accepted and ready to land.

This looks good to me.


https://reviews.llvm.org/D38797



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


[PATCH] D38812: [clang-fuzzer] Allow linking with any fuzzing engine.

2017-10-11 Thread Matt Morehouse via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL315486: [clang-fuzzer] Allow linking with any fuzzing 
engine. (authored by morehouse).

Changed prior to commit:
  https://reviews.llvm.org/D38812?vs=118651=118655#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D38812

Files:
  cfe/trunk/tools/clang-fuzzer/CMakeLists.txt


Index: cfe/trunk/tools/clang-fuzzer/CMakeLists.txt
===
--- cfe/trunk/tools/clang-fuzzer/CMakeLists.txt
+++ cfe/trunk/tools/clang-fuzzer/CMakeLists.txt
@@ -1,7 +1,9 @@
 set(LLVM_LINK_COMPONENTS ${LLVM_TARGETS_TO_BUILD} FuzzMutate)
 set(CXX_FLAGS_NOFUZZ ${CMAKE_CXX_FLAGS})
 set(DUMMY_MAIN DummyClangFuzzer.cpp)
-if(LLVM_USE_SANITIZE_COVERAGE)
+if(DEFINED LIB_FUZZING_ENGINE)
+  unset(DUMMY_MAIN)
+elseif(LLVM_USE_SANITIZE_COVERAGE)
   set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=fuzzer")
   set(CXX_FLAGS_NOFUZZ "${CXX_FLAGS_NOFUZZ} -fsanitize=fuzzer-no-link")
   unset(DUMMY_MAIN)
@@ -48,6 +50,7 @@
   target_link_libraries(clang-proto-fuzzer
 ${ProtobufMutator_LIBRARIES}
 ${PROTOBUF_LIBRARIES}
+${LIB_FUZZING_ENGINE}
 clangCXXProto
 clangHandleCXX
 clangProtoToCXX
@@ -63,5 +66,6 @@
   )
 
 target_link_libraries(clang-fuzzer
+  ${LIB_FUZZING_ENGINE}
   clangHandleCXX
   )


Index: cfe/trunk/tools/clang-fuzzer/CMakeLists.txt
===
--- cfe/trunk/tools/clang-fuzzer/CMakeLists.txt
+++ cfe/trunk/tools/clang-fuzzer/CMakeLists.txt
@@ -1,7 +1,9 @@
 set(LLVM_LINK_COMPONENTS ${LLVM_TARGETS_TO_BUILD} FuzzMutate)
 set(CXX_FLAGS_NOFUZZ ${CMAKE_CXX_FLAGS})
 set(DUMMY_MAIN DummyClangFuzzer.cpp)
-if(LLVM_USE_SANITIZE_COVERAGE)
+if(DEFINED LIB_FUZZING_ENGINE)
+  unset(DUMMY_MAIN)
+elseif(LLVM_USE_SANITIZE_COVERAGE)
   set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=fuzzer")
   set(CXX_FLAGS_NOFUZZ "${CXX_FLAGS_NOFUZZ} -fsanitize=fuzzer-no-link")
   unset(DUMMY_MAIN)
@@ -48,6 +50,7 @@
   target_link_libraries(clang-proto-fuzzer
 ${ProtobufMutator_LIBRARIES}
 ${PROTOBUF_LIBRARIES}
+${LIB_FUZZING_ENGINE}
 clangCXXProto
 clangHandleCXX
 clangProtoToCXX
@@ -63,5 +66,6 @@
   )
 
 target_link_libraries(clang-fuzzer
+  ${LIB_FUZZING_ENGINE}
   clangHandleCXX
   )
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r315486 - [clang-fuzzer] Allow linking with any fuzzing engine.

2017-10-11 Thread Matt Morehouse via cfe-commits
Author: morehouse
Date: Wed Oct 11 11:29:24 2017
New Revision: 315486

URL: http://llvm.org/viewvc/llvm-project?rev=315486=rev
Log:
[clang-fuzzer] Allow linking with any fuzzing engine.

Summary:
Makes clang-[proto-]fuzzer compatible with flags specified by OSS-Fuzz.

https://llvm.org/pr34314

Reviewers: vitalybuka, kcc

Reviewed By: kcc

Subscribers: cfe-commits, mgorny

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

Modified:
cfe/trunk/tools/clang-fuzzer/CMakeLists.txt

Modified: cfe/trunk/tools/clang-fuzzer/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-fuzzer/CMakeLists.txt?rev=315486=315485=315486=diff
==
--- cfe/trunk/tools/clang-fuzzer/CMakeLists.txt (original)
+++ cfe/trunk/tools/clang-fuzzer/CMakeLists.txt Wed Oct 11 11:29:24 2017
@@ -1,7 +1,9 @@
 set(LLVM_LINK_COMPONENTS ${LLVM_TARGETS_TO_BUILD} FuzzMutate)
 set(CXX_FLAGS_NOFUZZ ${CMAKE_CXX_FLAGS})
 set(DUMMY_MAIN DummyClangFuzzer.cpp)
-if(LLVM_USE_SANITIZE_COVERAGE)
+if(DEFINED LIB_FUZZING_ENGINE)
+  unset(DUMMY_MAIN)
+elseif(LLVM_USE_SANITIZE_COVERAGE)
   set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=fuzzer")
   set(CXX_FLAGS_NOFUZZ "${CXX_FLAGS_NOFUZZ} -fsanitize=fuzzer-no-link")
   unset(DUMMY_MAIN)
@@ -48,6 +50,7 @@ if(CLANG_ENABLE_PROTO_FUZZER)
   target_link_libraries(clang-proto-fuzzer
 ${ProtobufMutator_LIBRARIES}
 ${PROTOBUF_LIBRARIES}
+${LIB_FUZZING_ENGINE}
 clangCXXProto
 clangHandleCXX
 clangProtoToCXX
@@ -63,5 +66,6 @@ add_clang_executable(clang-fuzzer
   )
 
 target_link_libraries(clang-fuzzer
+  ${LIB_FUZZING_ENGINE}
   clangHandleCXX
   )


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


[PATCH] D38810: [Analyzer] Support bodyfarming std::call_once for libstdc++

2017-10-11 Thread Devin Coughlin via Phabricator via cfe-commits
dcoughlin accepted this revision.
dcoughlin added a comment.
This revision is now accepted and ready to land.

LGTM with the dyn_cast mentioned inline changed.




Comment at: lib/Analysis/BodyFarm.cpp:359
 
+  ValueDecl *FieldDecl = dyn_cast(FoundDecl);
   bool isLambdaCall = CallbackType->getAsCXXRecordDecl() &&

Should this be a cast<>() rather than a dyn_cast<>()? Do you expect this to 
fail? If so then you should check the result for null. If not then the idiom is 
to use cast<>().

An alternative would be to change findMemberField() to return a FieldDecl.


https://reviews.llvm.org/D38810



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


[PATCH] D38812: [clang-fuzzer] Allow linking with any fuzzing engine.

2017-10-11 Thread Kostya Serebryany via Phabricator via cfe-commits
kcc accepted this revision.
kcc added a comment.
This revision is now accepted and ready to land.

LGTM


https://reviews.llvm.org/D38812



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


[PATCH] D38812: [clang-fuzzer] Allow linking with any fuzzing engine.

2017-10-11 Thread Matt Morehouse via Phabricator via cfe-commits
morehouse created this revision.
Herald added a subscriber: mgorny.

Makes clang-[proto-]fuzzer compatible with flags specified by OSS-Fuzz.

https://llvm.org/pr34314


https://reviews.llvm.org/D38812

Files:
  clang/tools/clang-fuzzer/CMakeLists.txt


Index: clang/tools/clang-fuzzer/CMakeLists.txt
===
--- clang/tools/clang-fuzzer/CMakeLists.txt
+++ clang/tools/clang-fuzzer/CMakeLists.txt
@@ -1,7 +1,9 @@
 set(LLVM_LINK_COMPONENTS ${LLVM_TARGETS_TO_BUILD} FuzzMutate)
 set(CXX_FLAGS_NOFUZZ ${CMAKE_CXX_FLAGS})
 set(DUMMY_MAIN DummyClangFuzzer.cpp)
-if(LLVM_USE_SANITIZE_COVERAGE)
+if(DEFINED LIB_FUZZING_ENGINE)
+  unset(DUMMY_MAIN)
+elseif(LLVM_USE_SANITIZE_COVERAGE)
   set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=fuzzer")
   set(CXX_FLAGS_NOFUZZ "${CXX_FLAGS_NOFUZZ} -fsanitize=fuzzer-no-link")
   unset(DUMMY_MAIN)
@@ -48,6 +50,7 @@
   target_link_libraries(clang-proto-fuzzer
 ${ProtobufMutator_LIBRARIES}
 ${PROTOBUF_LIBRARIES}
+${LIB_FUZZING_ENGINE}
 clangCXXProto
 clangHandleCXX
 clangProtoToCXX
@@ -63,5 +66,6 @@
   )
 
 target_link_libraries(clang-fuzzer
+  ${LIB_FUZZING_ENGINE}
   clangHandleCXX
   )


Index: clang/tools/clang-fuzzer/CMakeLists.txt
===
--- clang/tools/clang-fuzzer/CMakeLists.txt
+++ clang/tools/clang-fuzzer/CMakeLists.txt
@@ -1,7 +1,9 @@
 set(LLVM_LINK_COMPONENTS ${LLVM_TARGETS_TO_BUILD} FuzzMutate)
 set(CXX_FLAGS_NOFUZZ ${CMAKE_CXX_FLAGS})
 set(DUMMY_MAIN DummyClangFuzzer.cpp)
-if(LLVM_USE_SANITIZE_COVERAGE)
+if(DEFINED LIB_FUZZING_ENGINE)
+  unset(DUMMY_MAIN)
+elseif(LLVM_USE_SANITIZE_COVERAGE)
   set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=fuzzer")
   set(CXX_FLAGS_NOFUZZ "${CXX_FLAGS_NOFUZZ} -fsanitize=fuzzer-no-link")
   unset(DUMMY_MAIN)
@@ -48,6 +50,7 @@
   target_link_libraries(clang-proto-fuzzer
 ${ProtobufMutator_LIBRARIES}
 ${PROTOBUF_LIBRARIES}
+${LIB_FUZZING_ENGINE}
 clangCXXProto
 clangHandleCXX
 clangProtoToCXX
@@ -63,5 +66,6 @@
   )
 
 target_link_libraries(clang-fuzzer
+  ${LIB_FUZZING_ENGINE}
   clangHandleCXX
   )
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D37897: [StaticAnalyzer] Fix ProgramState for static variables that are not written

2017-10-11 Thread Daniel Marjamäki via Phabricator via cfe-commits
danielmarjamaki added a comment.

In https://reviews.llvm.org/D37897#892667, @dcoughlin wrote:

> Apologies for the delay reviewing! As I noted inline, I'm pretty worried 
> about the performance impact of this. Is it possible to do the analysis in a 
> single traversal of the translation unit?


I agree. I first tried more like that but ran into problems. Don't remember the 
details. I will try again.. however as far as I see this will mean the 
LoopUnroller AST matchers can't be reused unless I change them.


Repository:
  rL LLVM

https://reviews.llvm.org/D37897



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


[PATCH] D38596: Implement attribute target multiversioning

2017-10-11 Thread Erich Keane via Phabricator via cfe-commits
erichkeane updated this revision to Diff 118648.
erichkeane added a comment.

Craig noticed a pair of ordering issues in the TargetArray list, so fixed htose.


https://reviews.llvm.org/D38596

Files:
  include/clang/AST/Decl.h
  include/clang/Basic/Attr.td
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Basic/TargetInfo.h
  include/clang/Sema/Sema.h
  lib/Basic/Targets/X86.cpp
  lib/Basic/Targets/X86.h
  lib/CodeGen/CGBuiltin.cpp
  lib/CodeGen/CodeGenFunction.cpp
  lib/CodeGen/CodeGenFunction.h
  lib/CodeGen/CodeGenModule.cpp
  lib/CodeGen/CodeGenModule.h
  lib/Sema/SemaDecl.cpp
  test/CodeGen/attr-target-multiversion.c
  test/CodeGenCXX/attr-target-multiversion.cpp
  test/Sema/attr-target-multiversion.c
  test/SemaCXX/attr-target-multiversion.cpp

Index: test/SemaCXX/attr-target-multiversion.cpp
===
--- /dev/null
+++ test/SemaCXX/attr-target-multiversion.cpp
@@ -0,0 +1,49 @@
+// RUN: %clang_cc1 -triple x86_64-linux -fsyntax-only -verify -emit-llvm-only %s
+
+struct S {
+  __attribute__((target("arch=sandybridge")))
+  void mv(){}
+  __attribute__((target("arch=ivybridge")))
+  void mv(){}
+  __attribute__((target("default")))
+  void mv(){}
+
+  // NOTE: Virtual functions aren't implement for multiversioning in GCC either,
+  // so this is a 'TBD' feature.
+  // expected-error@+2 {{function multiversioning with 'target' doesn't support virtual functions yet}}
+  __attribute__((target("arch=sandybridge")))
+  virtual void mv_2(){}
+  // expected-error@+4 {{function multiversioning with 'target' doesn't support virtual functions yet}}
+  // expected-error@+3 {{class member cannot be redeclared}}
+  // expected-note@-3 {{previous definition is here}}
+  __attribute__((target("arch=ivybridge")))
+  virtual void mv_2(){}
+  // expected-error@+3 {{class member cannot be redeclared}}
+  // expected-note@-7 {{previous definition is here}}
+  __attribute__((target("default")))
+  virtual void mv_2(){}
+};
+
+// Note: Template attribute 'target' isn't implemented in GCC either, and would
+// end up causing some nasty issues attempting it, so ensure that it still gives
+// the same errors as without the attribute.
+
+template
+__attribute__((target("arch=sandybridge")))
+void mv_temp(){}
+
+template
+__attribute__((target("arch=ivybridge")))
+//expected-error@+2 {{redefinition of}}
+//expected-note@-5{{previous definition is here}}
+void mv_temp(){}
+
+template
+__attribute__((target("default")))
+void mv_temp(){}
+
+void foo() {
+  //expected-error@+2{{no matching function for call to}}
+  //expected-note@-8{{candidate template ignored}}
+  mv_temp();
+}
Index: test/Sema/attr-target-multiversion.c
===
--- /dev/null
+++ test/Sema/attr-target-multiversion.c
@@ -0,0 +1,136 @@
+// RUN: %clang_cc1 -triple x86_64-linux -fsyntax-only -verify -emit-llvm-only %s
+// RUN: %clang_cc1 -triple x86_64-linux -fsyntax-only -verify -emit-llvm-only -DCHECK_DEFAULT %s
+
+#if defined(CHECK_DEFAULT)
+__attribute__((target("arch=sandybridge")))
+//expected-error@+1 {{function multiversioning with 'target' requires a 'default' implementation}}
+void no_default(){}
+__attribute__((target("arch=ivybridge")))
+void no_default(){}
+#else
+// Only multiversioning causes issues with redeclaration changing 'target'.
+__attribute__((target("arch=sandybridge")))
+void fine_since_no_mv();
+void fine_since_no_mv();
+
+void also_fine_since_no_mv();
+__attribute__((target("arch=sandybridge")))
+void also_fine_since_no_mv();
+
+__attribute__((target("arch=sandybridge")))
+void also_fine_since_no_mv2();
+__attribute__((target("arch=sandybridge")))
+void also_fine_since_no_mv2();
+void also_fine_since_no_mv2();
+
+__attribute__((target("arch=sandybridge")))
+void mv(){}
+__attribute__((target("arch=ivybridge")))
+void mv(){}
+__attribute__((target("default")))
+void mv(){}
+
+void redecl_causes_mv();
+__attribute__((target("arch=sandybridge")))
+void redecl_causes_mv();
+// expected-error@+3 {{function redeclaration declares a multiversioned function, but a previous declaration lacks a 'target' attribute}}
+// expected-note@-4 {{previous declaration is here}}
+__attribute__((target("arch=ivybridge")))
+void redecl_causes_mv();
+
+__attribute__((target("arch=sandybridge")))
+void redecl_causes_mv2();
+void redecl_causes_mv2();
+// expected-error@+3 {{function redeclaration declares a multiversioned function, but a previous declaration lacks a 'target' attribute}}
+// expected-note@-2 {{previous declaration is here}}
+__attribute__((target("arch=ivybridge")))
+void redecl_causes_mv2();
+
+__attribute__((target("arch=sandybridge")))
+void redecl_without_attr();
+__attribute__((target("arch=ivybridge")))
+void redecl_without_attr();
+// expected-error@+2 {{function redeclaration is missing 'target' attribute in a multiversioned function}}
+// expected-note@-4 {{previous declaration is here}}
+void 

[PATCH] D38810: [Analyzer] Support bodyfarming std::call_once for libstdc++

2017-10-11 Thread George Karpenkov via Phabricator via cfe-commits
george.karpenkov created this revision.
Herald added subscribers: szepet, kristof.beyls, xazax.hun, javed.absar, 
aemerson.

https://reviews.llvm.org/D38810

Files:
  lib/Analysis/BodyFarm.cpp
  test/Analysis/call_once.cpp

Index: test/Analysis/call_once.cpp
===
--- test/Analysis/call_once.cpp
+++ test/Analysis/call_once.cpp
@@ -1,15 +1,24 @@
-// RUN: %clang_analyze_cc1 -std=c++11 -fblocks -analyzer-checker=core,debug.ExprInspection -w -verify %s
+// RUN: %clang_analyze_cc1 -std=c++11 -fblocks -analyzer-checker=core,debug.ExprInspection -verify %s
+// RUN: %clang_analyze_cc1 -std=c++11 -fblocks -analyzer-checker=core,debug.ExprInspection -DEMULATE_LIBSTDCPP -verify %s
 
 void clang_analyzer_eval(bool);
 
 // Faking std::std::call_once implementation.
 namespace std {
+
+#ifndef EMULATE_LIBSTDCPP
 typedef struct once_flag_s {
   unsigned long __state_ = 0;
 } once_flag;
+#else
+typedef struct once_flag_s {
+  int _M_once = 0;
+} once_flag;
+#endif
 
 template 
 void call_once(once_flag , Callable func, Args... args) {};
+
 } // namespace std
 
 // Check with Lambdas.
Index: lib/Analysis/BodyFarm.cpp
===
--- lib/Analysis/BodyFarm.cpp
+++ lib/Analysis/BodyFarm.cpp
@@ -108,7 +108,7 @@
 
   /// Returns a *first* member field of a record declaration with a given name.
   /// \return an nullptr if no member with such a name exists.
-  NamedDecl *findMemberField(const CXXRecordDecl *RD, StringRef Name);
+  NamedDecl *findMemberField(const RecordDecl *RD, StringRef Name);
 
 private:
   ASTContext 
@@ -234,7 +234,7 @@
   OK_Ordinary);
 }
 
-NamedDecl *ASTMaker::findMemberField(const CXXRecordDecl *RD, StringRef Name) {
+NamedDecl *ASTMaker::findMemberField(const RecordDecl *RD, StringRef Name) {
 
   CXXBasePaths Paths(
   /* FindAmbiguities=*/false,
@@ -328,28 +328,35 @@
   const ParmVarDecl *Callback = D->getParamDecl(1);
   QualType CallbackType = Callback->getType().getNonReferenceType();
   QualType FlagType = Flag->getType().getNonReferenceType();
-  CXXRecordDecl *FlagCXXDecl = FlagType->getAsCXXRecordDecl();
-  if (!FlagCXXDecl) {
-DEBUG(llvm::dbgs() << "Flag field is not a CXX record: "
-   << "unknown std::call_once implementation."
-   << "Ignoring the call.\n");
+  auto *FlagRecordDecl = dyn_cast_or_null(FlagType->getAsTagDecl());
+
+  if (!FlagRecordDecl) {
+DEBUG(llvm::dbgs() << "Flag field is not a record: "
+   << "unknown std::call_once implementation, "
+   << "ignoring the call.\n");
 return nullptr;
   }
 
-  // Note: here we are assuming libc++ implementation of call_once,
-  // which has a struct with a field `__state_`.
-  // Body farming might not work for other `call_once` implementations.
-  NamedDecl *FoundDecl = M.findMemberField(FlagCXXDecl, "__state_");
-  ValueDecl *FieldDecl;
-  if (FoundDecl) {
-FieldDecl = dyn_cast(FoundDecl);
-  } else {
+  // We initially assume libc++ implementation of call_once,
+  // where the once_flag struct has a field `__state_`.
+  NamedDecl *FoundDecl = M.findMemberField(FlagRecordDecl, "__state_");
+
+  // Otherwise, try libstdc++ implementation, with a field
+  // `_M_once`
+  if (!FoundDecl) {
 DEBUG(llvm::dbgs() << "No field __state_ found on std::once_flag struct, "
-   << "unable to synthesize call_once body, ignoring "
-   << "the call.\n");
+   << "trying libstdc++ implementation\n");
+FoundDecl = M.findMemberField(FlagRecordDecl, "_M_once");
+  }
+
+  if (!FoundDecl) {
+DEBUG(llvm::dbgs() << "No field _M_once found on std::once flag struct: "
+   << "unknown std::call_once implementation, "
+   << "ignoring the call");
 return nullptr;
   }
 
+  ValueDecl *FieldDecl = dyn_cast(FoundDecl);
   bool isLambdaCall = CallbackType->getAsCXXRecordDecl() &&
   CallbackType->getAsCXXRecordDecl()->isLambda();
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D38742: [CUDA] Added __hmma_m16n16k16_* builtins to support mma instructions in sm_70

2017-10-11 Thread Justin Lebar via Phabricator via cfe-commits
jlebar added inline comments.



Comment at: clang/lib/CodeGen/CGBuiltin.cpp:9733
+  return nullptr;
+bool isColMajor = isColMajorArg.getZExtValue();
+unsigned IID;

tra wrote:
> jlebar wrote:
> > Urg, this isn't a bool?  Do we want it to be?
> There are no explicit declarations for these builtins in CUDA headers. 
> Callers of these builtins pass 0/1 and corresponding intrinsic described in 
> [[ 
> http://docs.nvidia.com/cuda/nvvm-ir-spec/index.html#nvvm-intrin-warp-level-matrix-ld
>  | NVVM-IR spec ]] shows the argument type as i32, so I've made the type 
> integer in clang. 
> 
> 
sgtm


https://reviews.llvm.org/D38742



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


[PATCH] D38110: [libunwind][MIPS]: Add support for unwinding in O32 and N64 processes.

2017-10-11 Thread John Baldwin via Phabricator via cfe-commits
bsdjhb updated this revision to Diff 118638.
bsdjhb added a comment.

- Add more soft-float checks.


https://reviews.llvm.org/D38110

Files:
  include/__libunwind_config.h
  include/libunwind.h
  src/Registers.hpp
  src/UnwindCursor.hpp
  src/UnwindRegistersRestore.S
  src/UnwindRegistersSave.S
  src/config.h
  src/libunwind.cpp

Index: src/libunwind.cpp
===
--- src/libunwind.cpp
+++ src/libunwind.cpp
@@ -58,8 +58,12 @@
 # define REGISTER_KIND Registers_arm
 #elif defined(__or1k__)
 # define REGISTER_KIND Registers_or1k
+#elif defined(__mips__) && _MIPS_SIM == _ABIO32 && defined(__mips_soft_float)
+# define REGISTER_KIND Registers_mips_o32
+#elif defined(__mips__) && _MIPS_SIM == _ABI64 && defined(__mips_soft_float)
+# define REGISTER_KIND Registers_mips_n64
 #elif defined(__mips__)
-# warning The MIPS architecture is not supported.
+# warning The MIPS architecture is not supported with this ABI and environment!
 #else
 # error Architecture not supported
 #endif
Index: src/config.h
===
--- src/config.h
+++ src/config.h
@@ -65,7 +65,7 @@
 defined(__ppc__) || defined(__ppc64__) ||  \
 (!defined(__APPLE__) && defined(__arm__)) ||   \
 (defined(__arm64__) || defined(__aarch64__)) ||\
-(defined(__APPLE__) && defined(__mips__))
+defined(__mips__)
 #define _LIBUNWIND_BUILD_ZERO_COST_APIS
 #endif
 
Index: src/UnwindRegistersSave.S
===
--- src/UnwindRegistersSave.S
+++ src/UnwindRegistersSave.S
@@ -87,6 +87,76 @@
   xorl  %eax, %eax# return UNW_ESUCCESS
   ret
 
+#elif defined(__mips__) && _MIPS_SIM == _ABIO32 && defined(__mips_soft_float)
+
+#
+# extern int unw_getcontext(unw_context_t* thread_state)
+#
+# On entry:
+#  thread_state pointer is in a0 ($4)
+#
+# Only save registers preserved across calls.
+#
+DEFINE_LIBUNWIND_FUNCTION(unw_getcontext)
+  .set push
+  .set noat
+  .set noreorder
+  .set nomacro
+  # s0 - s7
+  sw$16, (4 * 16)($4)
+  sw$17, (4 * 17)($4)
+  sw$18, (4 * 18)($4)
+  sw$19, (4 * 19)($4)
+  sw$20, (4 * 20)($4)
+  sw$21, (4 * 21)($4)
+  sw$22, (4 * 22)($4)
+  sw$23, (4 * 23)($4)
+  # gp
+  sw$28, (4 * 28)($4)
+  # sp
+  sw$29, (4 * 29)($4)
+  # Store return address to pc
+  sw$31, (4 * 32)($4)
+  jr	$31
+  # fp (in delay slot)
+  sw$30, (4 * 30)($4)
+  .set pop
+
+#elif defined(__mips__) && _MIPS_SIM == _ABI64 && defined(__mips_soft_float)
+
+#
+# extern int unw_getcontext(unw_context_t* thread_state)
+#
+# On entry:
+#  thread_state pointer is in a0 ($4)
+#
+# Only save registers preserved across calls.
+#
+DEFINE_LIBUNWIND_FUNCTION(unw_getcontext)
+  .set push
+  .set noat
+  .set noreorder
+  .set nomacro
+  # s0 - s7
+  sd$16, (8 * 16)($4)
+  sd$17, (8 * 17)($4)
+  sd$18, (8 * 18)($4)
+  sd$19, (8 * 19)($4)
+  sd$20, (8 * 20)($4)
+  sd$21, (8 * 21)($4)
+  sd$22, (8 * 22)($4)
+  sd$23, (8 * 23)($4)
+  # gp
+  sd$28, (8 * 28)($4)
+  # sp
+  sd$29, (8 * 29)($4)
+  # Store return address to pc
+  sd$31, (8 * 32)($4)
+  jr	$31
+  # fp (in delay slot)
+  sd$30, (8 * 30)($4)
+  .set pop
+
 # elif defined(__mips__)
 
 #
Index: src/UnwindRegistersRestore.S
===
--- src/UnwindRegistersRestore.S
+++ src/UnwindRegistersRestore.S
@@ -489,6 +489,108 @@
   l.jr r9
l.nop
 
+#elif defined(__mips__) && _MIPS_SIM == _ABIO32 && defined(__mips_soft_float)
+
+//
+// void libunwind::Registers_mips_o32::jumpto()
+//
+// On entry:
+//  thread state pointer is in a0 ($4)
+//
+DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9libunwind18Registers_mips_o326jumptoEv)
+  .set push
+  .set noat
+  .set noreorder
+  .set nomacro
+  // r0 is zero
+  lw$1, (4 * 1)($4)
+  lw$2, (4 * 2)($4)
+  lw$3, (4 * 3)($4)
+  // skip a0 for now
+  lw$5, (4 * 5)($4)
+  lw$6, (4 * 6)($4)
+  lw$7, (4 * 7)($4)
+  lw$8, (4 * 8)($4)
+  lw$9, (4 * 9)($4)
+  lw$10, (4 * 10)($4)
+  lw$11, (4 * 11)($4)
+  lw$12, (4 * 12)($4)
+  lw$13, (4 * 13)($4)
+  lw$14, (4 * 14)($4)
+  lw$15, (4 * 15)($4)
+  lw$16, (4 * 16)($4)
+  lw$17, (4 * 17)($4)
+  lw$18, (4 * 18)($4)
+  lw$19, (4 * 19)($4)
+  lw$20, (4 * 20)($4)
+  lw$21, (4 * 21)($4)
+  lw$22, (4 * 22)($4)
+  lw$23, (4 * 23)($4)
+  lw$24, (4 * 24)($4)
+  lw$25, (4 * 25)($4)
+  lw$26, (4 * 26)($4)
+  lw$27, (4 * 27)($4)
+  lw$28, (4 * 28)($4)
+  lw$29, (4 * 29)($4)
+  lw$30, (4 * 30)($4)
+  // load new pc into ra
+  lw$31, (4 * 32)($4)
+  // jump to ra, load a0 in the delay slot
+  jr$31
+  lw$4, (4 * 4)($4)
+  .set pop
+
+#elif defined(__mips__) && _MIPS_SIM == _ABI64 && defined(__mips_soft_float)
+
+//
+// void 

[PATCH] D38425: [clangd] Document highlights for clangd

2017-10-11 Thread William Enright via Phabricator via cfe-commits
Nebiroth marked 3 inline comments as done.
Nebiroth added inline comments.



Comment at: clangd/ClangdUnit.cpp:1017
+
+  auto DeclLocationsFinder = std::make_shared(
+  llvm::errs(), SourceLocationBeg, AST.getASTContext(),

ilya-biryukov wrote:
> I wonder if we really need to rerun indexer twice here. Probably ok for the 
> first version, but we should definitely think about a faster way to get the 
> `Decl` under cursor than visiting the whole AST. Not sure if it's easy to do 
> with clang's AST, though, maybe we'll need a separate index for that.
Yeah I realise it's definitely not the fastest way to go about it. Maybe there 
is a way to stop handling occurrences once the highlighted declaration is 
found. This would be the most straightforward way of improving the performance 
of the feature without re-writing a new AST indexer.


https://reviews.llvm.org/D38425



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


[PATCH] D38742: [CUDA] Added __hmma_m16n16k16_* builtins to support mma instructions in sm_70

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



Comment at: clang/lib/CodeGen/CGBuiltin.cpp:9726
+  case NVPTX::BI__hmma_m16n16k16_ld_c_f16:
+case NVPTX::BI__hmma_m16n16k16_ld_c_f32:{
+Address Dst = EmitPointerWithAlignment(E->getArg(0));

jlebar wrote:
> weird indentation?
My emacs and clang-format keep fighting case indentation... Fixed.



Comment at: clang/lib/CodeGen/CGBuiltin.cpp:9733
+  return nullptr;
+bool isColMajor = isColMajorArg.getZExtValue();
+unsigned IID;

jlebar wrote:
> Urg, this isn't a bool?  Do we want it to be?
There are no explicit declarations for these builtins in CUDA headers. Callers 
of these builtins pass 0/1 and corresponding intrinsic described in [[ 
http://docs.nvidia.com/cuda/nvvm-ir-spec/index.html#nvvm-intrin-warp-level-matrix-ld
 | NVVM-IR spec ]] shows the argument type as i32, so I've made the type 
integer in clang. 





Comment at: clang/lib/CodeGen/CGBuiltin.cpp:9762
+//auto EltTy = cast(Src->getType())->getElementType();
+// Returned are 8 16x2 elements.
+for (unsigned i = 0; i < NumResults; ++i) {

jlebar wrote:
> s/8/NumElements/?
> s/16/f16/?
> 
> Maybe it would be better to write it as "Return value has type [[f16 x 2] x 
> NumResults]."?
That was part of the leftover block. Particular types are irrelevant here. All 
we care is to store whatever intrinsic call returned ([4 or 8 elements of v2f16 
or float] ) in the destination array (which is int[] ). 



Comment at: clang/lib/CodeGen/CGBuiltin.cpp:9802
+llvm::Type *ParamType = Intrinsic->getFunctionType()->getParamType(1);
+SmallVector Values;
+Values.push_back(Builder.CreatePointerCast(Dst, VoidPtrTy));

jlebar wrote:
> Nit, we know that there won't ever be more than 8 elements...
We have two extra arguments -- destination buffer and stride.


https://reviews.llvm.org/D38742



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


[PATCH] D38742: [CUDA] Added __hmma_m16n16k16_* builtins to support mma instructions in sm_70

2017-10-11 Thread Artem Belevich via Phabricator via cfe-commits
tra updated this revision to Diff 118636.
tra marked 6 inline comments as done.
tra added a comment.

Addressed Justin's comments.


https://reviews.llvm.org/D38742

Files:
  clang/include/clang/Basic/BuiltinsNVPTX.def
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/builtins-nvptx-sm_70.cu

Index: clang/test/CodeGen/builtins-nvptx-sm_70.cu
===
--- /dev/null
+++ clang/test/CodeGen/builtins-nvptx-sm_70.cu
@@ -0,0 +1,166 @@
+// RUN: %clang_cc1 -triple nvptx64-unknown-unknown -target-cpu sm_70 \
+// RUN:-fcuda-is-device -target-feature +ptx60 \
+// RUN:-S -emit-llvm -o - -x cuda %s \
+// RUN:   | FileCheck -check-prefix=CHECK %s
+// RUN: %clang_cc1 -triple nvptx-unknown-unknown -target-cpu sm_60 \
+// RUN:   -fcuda-is-device -S -o /dev/null -x cuda -verify %s
+
+#if !defined(CUDA_VERSION)
+#define __device__ __attribute__((device))
+#define __global__ __attribute__((global))
+#define __shared__ __attribute__((shared))
+#define __constant__ __attribute__((constant))
+
+typedef unsigned long long uint64_t;
+#endif
+// We have to keep all builtins that depend on particular target feature in the
+// same function, because the codegen will stop after the very first function
+// that encounters an error, so -verify will not be able to find errors in
+// subsequent functions.
+
+// CHECK-LABEL: nvvm_wmma
+__device__ void nvvm_wmma(int *src, int *dst,
+  float *fsrc, float *fdst,
+  int ldm) {
+  // CHECK: call {{.*}} @llvm.nvvm.wmma.load.a.sync.row.m16n16k16.stride.f16
+  // expected-error@+1 {{'__hmma_m16n16k16_ld_a' needs target feature ptx60}}
+  __hmma_m16n16k16_ld_a(dst, src, ldm, 0);
+  // CHECK: call {{.*}} @llvm.nvvm.wmma.load.a.sync.col.m16n16k16.stride.f16
+  // expected-error@+1 {{'__hmma_m16n16k16_ld_a' needs target feature ptx60}}
+  __hmma_m16n16k16_ld_a(dst, src+1, ldm, 1);
+
+  // CHECK: call {{.*}} @llvm.nvvm.wmma.load.b.sync.row.m16n16k16.stride.f16
+  // expected-error@+1 {{'__hmma_m16n16k16_ld_b' needs target feature ptx60}}
+  __hmma_m16n16k16_ld_b(dst, src, ldm, 0);
+  // CHECK: call {{.*}} @llvm.nvvm.wmma.load.b.sync.col.m16n16k16.stride.f16
+  // expected-error@+1 {{'__hmma_m16n16k16_ld_b' needs target feature ptx60}}
+  __hmma_m16n16k16_ld_b(dst, src+2, ldm, 1);
+
+  // CHECK: call {{.*}} @llvm.nvvm.wmma.load.c.sync.row.m16n16k16.stride.f16
+  // expected-error@+1 {{'__hmma_m16n16k16_ld_c_f16' needs target feature ptx60}}
+  __hmma_m16n16k16_ld_c_f16(dst, src, ldm, 0);
+  // CHECK: call {{.*}} @llvm.nvvm.wmma.load.c.sync.col.m16n16k16.stride.f16
+  // expected-error@+1 {{'__hmma_m16n16k16_ld_c_f16' needs target feature ptx60}}
+  __hmma_m16n16k16_ld_c_f16(dst, src, ldm, 1);
+
+  // CHECK: call {{.*}} @llvm.nvvm.wmma.load.c.sync.row.m16n16k16.stride.f32
+  // expected-error@+1 {{'__hmma_m16n16k16_ld_c_f32' needs target feature ptx60}}
+  __hmma_m16n16k16_ld_c_f32(fdst, fsrc, ldm, 0);
+  // CHECK: call {{.*}} @llvm.nvvm.wmma.load.c.sync.col.m16n16k16.stride.f32
+  // expected-error@+1 {{'__hmma_m16n16k16_ld_c_f32' needs target feature ptx60}}
+  __hmma_m16n16k16_ld_c_f32(fdst, fsrc, ldm, 1);
+
+  // CHECK: call {{.*}} @llvm.nvvm.wmma.store.d.sync.row.m16n16k16.stride.f16
+  // expected-error@+1 {{'__hmma_m16n16k16_st_c_f16' needs target feature ptx60}}
+  __hmma_m16n16k16_st_c_f16(dst, src, ldm, 0);
+  // CHECK: call {{.*}} @llvm.nvvm.wmma.store.d.sync.col.m16n16k16.stride.f16
+  // expected-error@+1 {{'__hmma_m16n16k16_st_c_f16' needs target feature ptx60}}
+  __hmma_m16n16k16_st_c_f16(dst, src, ldm, 1);
+
+  // CHECK: call {{.*}} @llvm.nvvm.wmma.store.d.sync.row.m16n16k16.stride.f32
+  // expected-error@+1 {{'__hmma_m16n16k16_st_c_f32' needs target feature ptx60}}
+  __hmma_m16n16k16_st_c_f32(fdst, fsrc, ldm, 0);
+  // CHECK: call {{.*}} @llvm.nvvm.wmma.store.d.sync.col.m16n16k16.stride.f32
+  // expected-error@+1 {{'__hmma_m16n16k16_st_c_f32' needs target feature ptx60}}
+  __hmma_m16n16k16_st_c_f32(fdst, fsrc, ldm, 1);
+
+  // CHECK: call {{.*}} @llvm.nvvm.wmma.mma.sync.row.row.m16n16k16.f16.f16
+  // expected-error@+1 {{'__hmma_m16n16k16_mma_f16f16' needs target feature ptx60}}
+  __hmma_m16n16k16_mma_f16f16(dst, src, src, src, 0, 0);
+  // CHECK: call {{.*}} @llvm.nvvm.wmma.mma.sync.row.row.m16n16k16.f16.f16.satfinite
+  // expected-error@+1 {{'__hmma_m16n16k16_mma_f16f16' needs target feature ptx60}}
+  __hmma_m16n16k16_mma_f16f16(dst, src, src, src, 0, 1);
+  // CHECK: call {{.*}} @llvm.nvvm.wmma.mma.sync.row.col.m16n16k16.f16.f16
+  // expected-error@+1 {{'__hmma_m16n16k16_mma_f16f16' needs target feature ptx60}}
+  __hmma_m16n16k16_mma_f16f16(dst, src, src, src, 1, 0);
+  // CHECK: call {{.*}} @llvm.nvvm.wmma.mma.sync.row.col.m16n16k16.f16.f16.satfinite
+  // expected-error@+1 {{'__hmma_m16n16k16_mma_f16f16' needs target feature ptx60}}
+  __hmma_m16n16k16_mma_f16f16(dst, src, src, src, 1, 1);
+  // CHECK: call {{.*}} 

[PATCH] D38742: [CUDA] Added __hmma_m16n16k16_* builtins to support mma instructions in sm_70

2017-10-11 Thread Justin Lebar via Phabricator via cfe-commits
jlebar accepted this revision.
jlebar added inline comments.
This revision is now accepted and ready to land.



Comment at: clang/lib/CodeGen/CGBuiltin.cpp:9726
+  case NVPTX::BI__hmma_m16n16k16_ld_c_f16:
+case NVPTX::BI__hmma_m16n16k16_ld_c_f32:{
+Address Dst = EmitPointerWithAlignment(E->getArg(0));

weird indentation?



Comment at: clang/lib/CodeGen/CGBuiltin.cpp:9733
+  return nullptr;
+bool isColMajor = isColMajorArg.getZExtValue();
+unsigned IID;

Urg, this isn't a bool?  Do we want it to be?



Comment at: clang/lib/CodeGen/CGBuiltin.cpp:9761
+
+//auto EltTy = cast(Src->getType())->getElementType();
+// Returned are 8 16x2 elements.

Accidentally left over?



Comment at: clang/lib/CodeGen/CGBuiltin.cpp:9762
+//auto EltTy = cast(Src->getType())->getElementType();
+// Returned are 8 16x2 elements.
+for (unsigned i = 0; i < NumResults; ++i) {

s/8/NumElements/?
s/16/f16/?

Maybe it would be better to write it as "Return value has type [[f16 x 2] x 
NumResults]."?



Comment at: clang/lib/CodeGen/CGBuiltin.cpp:9784
+unsigned IID;
+unsigned NumResults = 8;
+// PTX Instructions (and LLVM instrinsics) are defined for slice _d_, yet

Nit, at this point it's probably better to assign NumResults in each branch, 
since there are only two.  clang should make sure that we don't accidentally 
use it uninitialized.



Comment at: clang/lib/CodeGen/CGBuiltin.cpp:9786
+// PTX Instructions (and LLVM instrinsics) are defined for slice _d_, yet
+// for some reason nvcc buildtins are using _c_.
+switch(BuiltinID) {

s/are using/use/



Comment at: clang/lib/CodeGen/CGBuiltin.cpp:9800
+}
+Function * Intrinsic = CGM.getIntrinsic(IID);
+llvm::Type *ParamType = Intrinsic->getFunctionType()->getParamType(1);

spacing.  (Probably just worth clang-formatting this and the other patch.)



Comment at: clang/lib/CodeGen/CGBuiltin.cpp:9802
+llvm::Type *ParamType = Intrinsic->getFunctionType()->getParamType(1);
+SmallVector Values;
+Values.push_back(Builder.CreatePointerCast(Dst, VoidPtrTy));

Nit, we know that there won't ever be more than 8 elements...


https://reviews.llvm.org/D38742



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


[PATCH] D37856: [refactor] add support for refactoring options

2017-10-11 Thread Haojian Wu via Phabricator via cfe-commits
hokein added inline comments.



Comment at: cfe/trunk/lib/Tooling/Refactoring/Rename/RenamingAction.cpp:113
 Rules.push_back(createRefactoringActionRule(
-SymbolSelectionRequirement()));
+SymbolSelectionRequirement(), OptionRequirement()));
 return Rules;

arphaman wrote:
> hokein wrote:
> > Thought it a bit more: it requires all of the requirements are satisfied, I 
> > think we need to support "one-of" option. For example,  we have two option 
> > "-a" and "-b",  only one of them is allowed to be present at the same time.
> That should be straightforward enough to implement, either with a custom 
> class or with a built-in requirement class. I'll probably add a builtin one 
> when the need comes up.
Thanks. I'm asking it because I plan to add the `-qualified-name` option to the 
clang-refactor rename subtool. And obviously "-qualified-name" can not be 
present with "-selection".


Repository:
  rL LLVM

https://reviews.llvm.org/D37856



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


r315470 - [X86] Correct type for argument to clflushopt intrinsic.

2017-10-11 Thread Craig Topper via cfe-commits
Author: ctopper
Date: Wed Oct 11 09:06:08 2017
New Revision: 315470

URL: http://llvm.org/viewvc/llvm-project?rev=315470=rev
Log:
[X86] Correct type for argument to clflushopt intrinsic.

Summary: According to Intel docs this should take void const *. We had char*. 
The lack of const is the main issue.

Reviewers: RKSimon, zvi, igorb

Reviewed By: igorb

Subscribers: llvm-commits

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

Modified:
cfe/trunk/include/clang/Basic/BuiltinsX86.def
cfe/trunk/lib/Headers/clflushoptintrin.h

Modified: cfe/trunk/include/clang/Basic/BuiltinsX86.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsX86.def?rev=315470=315469=315470=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsX86.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsX86.def Wed Oct 11 09:06:08 2017
@@ -639,7 +639,7 @@ TARGET_BUILTIN(__builtin_ia32_xsavec, "v
 TARGET_BUILTIN(__builtin_ia32_xsaves, "vv*ULLi", "", "xsaves")
 
 //CLFLUSHOPT
-TARGET_BUILTIN(__builtin_ia32_clflushopt, "vc*", "", "clflushopt")
+TARGET_BUILTIN(__builtin_ia32_clflushopt, "vvC*", "", "clflushopt")
 
 // ADX
 TARGET_BUILTIN(__builtin_ia32_addcarryx_u32, "UcUcUiUiUi*", "", "adx")

Modified: cfe/trunk/lib/Headers/clflushoptintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/clflushoptintrin.h?rev=315470=315469=315470=diff
==
--- cfe/trunk/lib/Headers/clflushoptintrin.h (original)
+++ cfe/trunk/lib/Headers/clflushoptintrin.h Wed Oct 11 09:06:08 2017
@@ -32,7 +32,7 @@
 #define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__,  
__target__("clflushopt")))
 
 static __inline__ void __DEFAULT_FN_ATTRS
-_mm_clflushopt(char * __m) {
+_mm_clflushopt(void const * __m) {
   __builtin_ia32_clflushopt(__m);
 }
 


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


r315467 - [OPENMP] Remove extra if, NFC.

2017-10-11 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Wed Oct 11 08:56:38 2017
New Revision: 315467

URL: http://llvm.org/viewvc/llvm-project?rev=315467=rev
Log:
[OPENMP] Remove extra if, NFC.

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

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp?rev=315467=315466=315467=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp Wed Oct 11 08:56:38 2017
@@ -4274,7 +4274,7 @@ CGOpenMPRuntime::emitTaskInit(CodeGenFun
   CGM, D.getDirectiveKind(), KmpInt32Ty, KmpRoutineEntryPtrQTy));
 }
 KmpTaskTQTy = SavedKmpTaskloopTQTy;
-  } else if (D.getDirectiveKind() == OMPD_task) {
+  } else {
 assert(D.getDirectiveKind() == OMPD_task &&
"Expected taskloop or task directive");
 if (SavedKmpTaskTQTy.isNull()) {


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


r315465 - Reland "[clang-fuzzer] Allow building without coverage instrumentation."

2017-10-11 Thread Matt Morehouse via cfe-commits
Author: morehouse
Date: Wed Oct 11 08:51:12 2017
New Revision: 315465

URL: http://llvm.org/viewvc/llvm-project?rev=315465=rev
Log:
Reland "[clang-fuzzer] Allow building without coverage instrumentation."

This relands r315336 after fixing bot breakage.

Added:
cfe/trunk/tools/clang-fuzzer/DummyClangFuzzer.cpp
Modified:
cfe/trunk/tools/clang-fuzzer/CMakeLists.txt
cfe/trunk/tools/clang-fuzzer/ClangFuzzer.cpp

Modified: cfe/trunk/tools/clang-fuzzer/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-fuzzer/CMakeLists.txt?rev=315465=315464=315465=diff
==
--- cfe/trunk/tools/clang-fuzzer/CMakeLists.txt (original)
+++ cfe/trunk/tools/clang-fuzzer/CMakeLists.txt Wed Oct 11 08:51:12 2017
@@ -1,61 +1,67 @@
-if( LLVM_USE_SANITIZE_COVERAGE )
-  set(LLVM_LINK_COMPONENTS ${LLVM_TARGETS_TO_BUILD})
-  set(CXX_FLAGS_NOFUZZ "${CMAKE_CXX_FLAGS} -fsanitize=fuzzer-no-link")
+set(LLVM_LINK_COMPONENTS ${LLVM_TARGETS_TO_BUILD} FuzzMutate)
+set(CXX_FLAGS_NOFUZZ ${CMAKE_CXX_FLAGS})
+set(DUMMY_MAIN DummyClangFuzzer.cpp)
+if(LLVM_USE_SANITIZE_COVERAGE)
   set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=fuzzer")
+  set(CXX_FLAGS_NOFUZZ "${CXX_FLAGS_NOFUZZ} -fsanitize=fuzzer-no-link")
+  unset(DUMMY_MAIN)
+endif()
+
+# Hack to bypass LLVM's cmake sources check and allow multiple libraries and
+# executables from this directory.
+set(LLVM_OPTIONAL_SOURCES
+  ClangFuzzer.cpp
+  DummyClangFuzzer.cpp
+  ExampleClangProtoFuzzer.cpp
+  )
+
+if(CLANG_ENABLE_PROTO_FUZZER)
+  # Create protobuf .h and .cc files, and put them in a library for use by
+  # clang-proto-fuzzer components.
+  find_package(Protobuf REQUIRED)
+  add_definitions(-DGOOGLE_PROTOBUF_NO_RTTI)
+  include_directories(${PROTOBUF_INCLUDE_DIRS})
+  include_directories(${CMAKE_CURRENT_BINARY_DIR})
+  protobuf_generate_cpp(PROTO_SRCS PROTO_HDRS cxx_proto.proto)
+  set(LLVM_OPTIONAL_SOURCES ${LLVM_OPTIONAL_SOURCES} ${PROTO_SRCS})
+  add_clang_library(clangCXXProto
+${PROTO_SRCS}
+${PROTO_HDRS}
+
+LINK_LIBS
+${PROTOBUF_LIBRARIES}
+)
 
-  if(CLANG_ENABLE_PROTO_FUZZER)
-# Create protobuf .h and .cc files, and put them in a library for use by
-# clang-proto-fuzzer components.
-find_package(Protobuf REQUIRED)
-add_definitions(-DGOOGLE_PROTOBUF_NO_RTTI)
-include_directories(${PROTOBUF_INCLUDE_DIRS})
-include_directories(${CMAKE_CURRENT_BINARY_DIR})
-protobuf_generate_cpp(PROTO_SRCS PROTO_HDRS cxx_proto.proto)
-# Hack to bypass LLVM's cmake sources check and allow multiple libraries 
and
-# executables from this directory.
-set(LLVM_OPTIONAL_SOURCES
-  ClangFuzzer.cpp
-  ExampleClangProtoFuzzer.cpp
-  ${PROTO_SRCS}
-  )
-add_clang_library(clangCXXProto
-  ${PROTO_SRCS}
-  ${PROTO_HDRS}
-
-  LINK_LIBS
-  ${PROTOBUF_LIBRARIES}
-  )
-
-# Build and include libprotobuf-mutator
-include(ProtobufMutator)
-include_directories(${ProtobufMutator_INCLUDE_DIRS})
-
-# Build the protobuf->C++ translation library and driver.
-add_clang_subdirectory(proto-to-cxx)
-
-# Build the protobuf fuzzer
-add_clang_executable(clang-proto-fuzzer ExampleClangProtoFuzzer.cpp)
-target_link_libraries(clang-proto-fuzzer
-  ${ProtobufMutator_LIBRARIES}
-  ${PROTOBUF_LIBRARIES}
-  clangCXXProto
-  clangHandleCXX
-  clangProtoToCXX
-  )
-  else()
-# Hack to bypass LLVM's cmake sources check and allow multiple libraries 
and
-# executables from this directory.
-set(LLVM_OPTIONAL_SOURCES ClangFuzzer.cpp ExampleClangProtoFuzzer.cpp)
-  endif()
-
-  add_clang_subdirectory(handle-cxx)
-
-  add_clang_executable(clang-fuzzer
-EXCLUDE_FROM_ALL
-ClangFuzzer.cpp
+  # Build and include libprotobuf-mutator
+  include(ProtobufMutator)
+  include_directories(${ProtobufMutator_INCLUDE_DIRS})
+
+  # Build the protobuf->C++ translation library and driver.
+  add_clang_subdirectory(proto-to-cxx)
+
+  # Build the protobuf fuzzer
+  add_clang_executable(clang-proto-fuzzer
+${DUMMY_MAIN}
+ExampleClangProtoFuzzer.cpp
 )
 
-  target_link_libraries(clang-fuzzer
+  target_link_libraries(clang-proto-fuzzer
+${ProtobufMutator_LIBRARIES}
+${PROTOBUF_LIBRARIES}
+clangCXXProto
 clangHandleCXX
+clangProtoToCXX
 )
 endif()
+
+add_clang_subdirectory(handle-cxx)
+
+add_clang_executable(clang-fuzzer
+  EXCLUDE_FROM_ALL
+  ${DUMMY_MAIN}
+  ClangFuzzer.cpp
+  )
+
+target_link_libraries(clang-fuzzer
+  clangHandleCXX
+  )

Modified: cfe/trunk/tools/clang-fuzzer/ClangFuzzer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-fuzzer/ClangFuzzer.cpp?rev=315465=315464=315465=diff
==
--- cfe/trunk/tools/clang-fuzzer/ClangFuzzer.cpp (original)
+++ cfe/trunk/tools/clang-fuzzer/ClangFuzzer.cpp Wed Oct 11 08:51:12 2017
@@ -17,6 +17,8 @@
 
 using 

[PATCH] D38757: [libc++] Fix PR34898 - vector iterator constructors and assign method perform push_back instead of emplace_back.

2017-10-11 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists accepted this revision.
mclow.lists added a comment.
This revision is now accepted and ready to land.

LGTM - thanks!


https://reviews.llvm.org/D38757



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


[PATCH] D38720: [clangd] Report proper kinds for 'Keyword' and 'Snippet' completion items.

2017-10-11 Thread Raoul Wols via Phabricator via cfe-commits
rwols accepted this revision.
rwols added a comment.
This revision is now accepted and ready to land.

LGTM


https://reviews.llvm.org/D38720



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


r315464 - [OPENMP] Fix PR34916: Crash on mixing taskloop|tasks directives.

2017-10-11 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Wed Oct 11 08:29:40 2017
New Revision: 315464

URL: http://llvm.org/viewvc/llvm-project?rev=315464=rev
Log:
[OPENMP] Fix PR34916: Crash on mixing taskloop|tasks directives.

If both taskloop and task directives are used at the same time in one
program, we may ran into the situation when the particular type for task
directive is reused for taskloop directives. Patch fixes this problem.

Modified:
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h
cfe/trunk/test/OpenMP/taskloop_codegen.cpp

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp?rev=315464=315463=315464=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp Wed Oct 11 08:29:40 2017
@@ -4268,9 +4268,20 @@ CGOpenMPRuntime::emitTaskInit(CodeGenFun
   // Build type kmp_routine_entry_t (if not built yet).
   emitKmpRoutineEntryT(KmpInt32Ty);
   // Build type kmp_task_t (if not built yet).
-  if (KmpTaskTQTy.isNull()) {
-KmpTaskTQTy = C.getRecordType(createKmpTaskTRecordDecl(
-CGM, D.getDirectiveKind(), KmpInt32Ty, KmpRoutineEntryPtrQTy));
+  if (isOpenMPTaskLoopDirective(D.getDirectiveKind())) {
+if (SavedKmpTaskloopTQTy.isNull()) {
+  SavedKmpTaskloopTQTy = C.getRecordType(createKmpTaskTRecordDecl(
+  CGM, D.getDirectiveKind(), KmpInt32Ty, KmpRoutineEntryPtrQTy));
+}
+KmpTaskTQTy = SavedKmpTaskloopTQTy;
+  } else if (D.getDirectiveKind() == OMPD_task) {
+assert(D.getDirectiveKind() == OMPD_task &&
+   "Expected taskloop or task directive");
+if (SavedKmpTaskTQTy.isNull()) {
+  SavedKmpTaskTQTy = C.getRecordType(createKmpTaskTRecordDecl(
+  CGM, D.getDirectiveKind(), KmpInt32Ty, KmpRoutineEntryPtrQTy));
+}
+KmpTaskTQTy = SavedKmpTaskTQTy;
   }
   auto *KmpTaskTQTyRD = cast(KmpTaskTQTy->getAsTagDecl());
   // Build particular struct kmp_task_t for the given task.

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h?rev=315464=315463=315464=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h Wed Oct 11 08:29:40 2017
@@ -318,6 +318,10 @@ private:
   ///deconstructors of firstprivate C++ objects */
   /// } kmp_task_t;
   QualType KmpTaskTQTy;
+  /// Saved kmp_task_t for task directive.
+  QualType SavedKmpTaskTQTy;
+  /// Saved kmp_task_t for taskloop-based directive.
+  QualType SavedKmpTaskloopTQTy;
   /// \brief Type typedef struct kmp_depend_info {
   ///kmp_intptr_t   base_addr;
   ///size_t len;

Modified: cfe/trunk/test/OpenMP/taskloop_codegen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/taskloop_codegen.cpp?rev=315464=315463=315464=diff
==
--- cfe/trunk/test/OpenMP/taskloop_codegen.cpp (original)
+++ cfe/trunk/test/OpenMP/taskloop_codegen.cpp Wed Oct 11 08:29:40 2017
@@ -8,6 +8,10 @@
 // CHECK-LABEL: @main
 int main(int argc, char **argv) {
 // CHECK: [[GTID:%.+]] = call i32 @__kmpc_global_thread_num(%ident_t* 
[[DEFLOC:@.+]])
+// CHECK: call i8* @__kmpc_omp_task_alloc(%ident_t* [[DEFLOC]], i32 [[GTID]],
+// CHECK: call i32 @__kmpc_omp_task(%ident_t* [[DEFLOC]], i32 [[GTID]],
+#pragma omp task
+  ;
 // CHECK: call void @__kmpc_taskgroup(%ident_t* [[DEFLOC]], i32 [[GTID]])
 // CHECK: [[TASKV:%.+]] = call i8* @__kmpc_omp_task_alloc(%ident_t* 
[[DEFLOC]], i32 [[GTID]], i32 33, i64 80, i64 1, i32 (i32, i8*)* bitcast (i32 
(i32, [[TDP_TY:%.+]]*)* [[TASK1:@.+]] to i32 (i32, i8*)*))
 // CHECK: [[TASK:%.+]] = bitcast i8* [[TASKV]] to [[TDP_TY]]*


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


[PATCH] D23963: [analyzer] pr28449 - Move literal rvalue construction away from RegionStore.

2017-10-11 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ updated this revision to Diff 118625.
NoQ added a comment.
Herald added a subscriber: szepet.

Because i didn't get back to this in a while, and similar crashes keep coming, 
i decided to leave this refactoring as a FIXME.


https://reviews.llvm.org/D23963

Files:
  lib/StaticAnalyzer/Core/RegionStore.cpp
  test/Analysis/compound-literals.c
  test/Analysis/objc-encode.m


Index: test/Analysis/objc-encode.m
===
--- /dev/null
+++ test/Analysis/objc-encode.m
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=debug.ExprInspection -verify %s
+// expected-no-diagnostics
+
+void clang_analyzer_eval(int);
+
+// rdar://problem/34831581: Used to crash.
+void foo(void) {
+  char buf1[] = @encode(int **);
+}
Index: test/Analysis/compound-literals.c
===
--- /dev/null
+++ test/Analysis/compound-literals.c
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -triple=i386-apple-darwin10 -analyze 
-analyzer-checker=debug.ExprInspection -verify %s
+void clang_analyzer_eval(int);
+
+// pr28449: Used to crash.
+void foo(void) {
+  static const unsigned short array[] = (const unsigned short[]){0x0F00};
+  // FIXME: Should be true.
+  clang_analyzer_eval(array[0] == 0x0F00); // expected-warning{{UNKNOWN}}
+}
Index: lib/StaticAnalyzer/Core/RegionStore.cpp
===
--- lib/StaticAnalyzer/Core/RegionStore.cpp
+++ lib/StaticAnalyzer/Core/RegionStore.cpp
@@ -2085,15 +2085,12 @@
   if (const ConstantArrayType* CAT = dyn_cast(AT))
 Size = CAT->getSize().getZExtValue();
 
-  // Check if the init expr is a string literal.
+  // Check if the init expr is a literal. If so, bind the rvalue instead.
+  // FIXME: It's not responsibility of the Store to transform this lvalue
+  // to rvalue. ExprEngine or maybe even CFG should do this before binding.
   if (Optional MRV = Init.getAs()) {
-const StringRegion *S = cast(MRV->getRegion());
-
-// Treat the string as a lazy compound value.
-StoreRef store(B.asStore(), *this);
-nonloc::LazyCompoundVal LCV = svalBuilder.makeLazyCompoundVal(store, S)
-.castAs();
-return bindAggregate(B, R, LCV);
+SVal V = getBinding(B.asStore(), *MRV, R->getValueType());
+return bindAggregate(B, R, V);
   }
 
   // Handle lazy compound values.


Index: test/Analysis/objc-encode.m
===
--- /dev/null
+++ test/Analysis/objc-encode.m
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=debug.ExprInspection -verify %s
+// expected-no-diagnostics
+
+void clang_analyzer_eval(int);
+
+// rdar://problem/34831581: Used to crash.
+void foo(void) {
+  char buf1[] = @encode(int **);
+}
Index: test/Analysis/compound-literals.c
===
--- /dev/null
+++ test/Analysis/compound-literals.c
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -triple=i386-apple-darwin10 -analyze -analyzer-checker=debug.ExprInspection -verify %s
+void clang_analyzer_eval(int);
+
+// pr28449: Used to crash.
+void foo(void) {
+  static const unsigned short array[] = (const unsigned short[]){0x0F00};
+  // FIXME: Should be true.
+  clang_analyzer_eval(array[0] == 0x0F00); // expected-warning{{UNKNOWN}}
+}
Index: lib/StaticAnalyzer/Core/RegionStore.cpp
===
--- lib/StaticAnalyzer/Core/RegionStore.cpp
+++ lib/StaticAnalyzer/Core/RegionStore.cpp
@@ -2085,15 +2085,12 @@
   if (const ConstantArrayType* CAT = dyn_cast(AT))
 Size = CAT->getSize().getZExtValue();
 
-  // Check if the init expr is a string literal.
+  // Check if the init expr is a literal. If so, bind the rvalue instead.
+  // FIXME: It's not responsibility of the Store to transform this lvalue
+  // to rvalue. ExprEngine or maybe even CFG should do this before binding.
   if (Optional MRV = Init.getAs()) {
-const StringRegion *S = cast(MRV->getRegion());
-
-// Treat the string as a lazy compound value.
-StoreRef store(B.asStore(), *this);
-nonloc::LazyCompoundVal LCV = svalBuilder.makeLazyCompoundVal(store, S)
-.castAs();
-return bindAggregate(B, R, LCV);
+SVal V = getBinding(B.asStore(), *MRV, R->getValueType());
+return bindAggregate(B, R, V);
   }
 
   // Handle lazy compound values.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r315463 - [clang-fuzzer] Fix shared library dependencies.

2017-10-11 Thread Matt Morehouse via cfe-commits
Author: morehouse
Date: Wed Oct 11 08:13:53 2017
New Revision: 315463

URL: http://llvm.org/viewvc/llvm-project?rev=315463=rev
Log:
[clang-fuzzer] Fix shared library dependencies.

Modified:
cfe/trunk/tools/clang-fuzzer/CMakeLists.txt
cfe/trunk/tools/clang-fuzzer/handle-cxx/CMakeLists.txt
cfe/trunk/tools/clang-fuzzer/proto-to-cxx/CMakeLists.txt

Modified: cfe/trunk/tools/clang-fuzzer/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-fuzzer/CMakeLists.txt?rev=315463=315462=315463=diff
==
--- cfe/trunk/tools/clang-fuzzer/CMakeLists.txt (original)
+++ cfe/trunk/tools/clang-fuzzer/CMakeLists.txt Wed Oct 11 08:13:53 2017
@@ -37,6 +37,7 @@ if( LLVM_USE_SANITIZE_COVERAGE )
 add_clang_executable(clang-proto-fuzzer ExampleClangProtoFuzzer.cpp)
 target_link_libraries(clang-proto-fuzzer
   ${ProtobufMutator_LIBRARIES}
+  ${PROTOBUF_LIBRARIES}
   clangCXXProto
   clangHandleCXX
   clangProtoToCXX

Modified: cfe/trunk/tools/clang-fuzzer/handle-cxx/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-fuzzer/handle-cxx/CMakeLists.txt?rev=315463=315462=315463=diff
==
--- cfe/trunk/tools/clang-fuzzer/handle-cxx/CMakeLists.txt (original)
+++ cfe/trunk/tools/clang-fuzzer/handle-cxx/CMakeLists.txt Wed Oct 11 08:13:53 
2017
@@ -1,9 +1,10 @@
-set(LLVM_LINK_COMPONENTS ${LLVM_TARGETS_TO_BUILD})
+set(LLVM_LINK_COMPONENTS ${LLVM_TARGETS_TO_BUILD} Support)
 
 add_clang_library(clangHandleCXX
   handle_cxx.cpp
 
   LINK_LIBS
+  clangBasic
   clangCodeGen
   clangFrontend
   clangLex

Modified: cfe/trunk/tools/clang-fuzzer/proto-to-cxx/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-fuzzer/proto-to-cxx/CMakeLists.txt?rev=315463=315462=315463=diff
==
--- cfe/trunk/tools/clang-fuzzer/proto-to-cxx/CMakeLists.txt (original)
+++ cfe/trunk/tools/clang-fuzzer/proto-to-cxx/CMakeLists.txt Wed Oct 11 
08:13:53 2017
@@ -5,9 +5,9 @@ set(CMAKE_CXX_FLAGS ${CXX_FLAGS_NOFUZZ})
 # an executable built from this directory.
 set(LLVM_OPTIONAL_SOURCES proto_to_cxx.cpp proto_to_cxx_main.cpp)
 
-add_clang_library(clangProtoToCXX proto_to_cxx.cpp 
+add_clang_library(clangProtoToCXX proto_to_cxx.cpp
   DEPENDS clangCXXProto
-  LINK_LIBS clangCXXProto
+  LINK_LIBS clangCXXProto ${PROTOBUF_LIBRARIES}
   )
 
 add_clang_executable(clang-proto-to-cxx proto_to_cxx_main.cpp)


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


[PATCH] D30295: [analyzer] clarify undef shift result when shift count is negative or exceeds the bit width

2017-10-11 Thread Daniel Marjamäki via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL315462: [Analyzer] Clarify error messages for undefined 
result (authored by danielmarjamaki).

Changed prior to commit:
  https://reviews.llvm.org/D30295?vs=116865=118620#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D30295

Files:
  cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h
  cfe/trunk/lib/StaticAnalyzer/Checkers/ConversionChecker.cpp
  cfe/trunk/lib/StaticAnalyzer/Checkers/UndefResultChecker.cpp
  cfe/trunk/lib/StaticAnalyzer/Core/CheckerContext.cpp
  cfe/trunk/test/Analysis/bitwise-ops.c

Index: cfe/trunk/lib/StaticAnalyzer/Core/CheckerContext.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Core/CheckerContext.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Core/CheckerContext.cpp
@@ -99,3 +99,35 @@
   return Lexer::getSpelling(Loc, buf, getSourceManager(), getLangOpts());
 }
 
+/// Evaluate comparison and return true if it's known that condition is true
+static bool evalComparison(SVal LHSVal, BinaryOperatorKind ComparisonOp,
+   SVal RHSVal, ProgramStateRef State) {
+  if (LHSVal.isUnknownOrUndef())
+return false;
+  ProgramStateManager  = State->getStateManager();
+  if (!LHSVal.getAs()) {
+LHSVal = Mgr.getStoreManager().getBinding(State->getStore(),
+  LHSVal.castAs());
+if (LHSVal.isUnknownOrUndef() || !LHSVal.getAs())
+  return false;
+  }
+
+  SValBuilder  = Mgr.getSValBuilder();
+  SVal Eval = Bldr.evalBinOp(State, ComparisonOp, LHSVal, RHSVal,
+ Bldr.getConditionType());
+  if (Eval.isUnknownOrUndef())
+return false;
+  ProgramStateRef StTrue, StFalse;
+  std::tie(StTrue, StFalse) = State->assume(Eval.castAs());
+  return StTrue && !StFalse;
+}
+
+bool CheckerContext::isGreaterOrEqual(const Expr *E, unsigned long long Val) {
+  DefinedSVal V = getSValBuilder().makeIntVal(Val, getASTContext().LongLongTy);
+  return evalComparison(getSVal(E), BO_GE, V, getState());
+}
+
+bool CheckerContext::isNegative(const Expr *E) {
+  DefinedSVal V = getSValBuilder().makeIntVal(0, false);
+  return evalComparison(getSVal(E), BO_LT, V, getState());
+}
Index: cfe/trunk/lib/StaticAnalyzer/Checkers/ConversionChecker.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Checkers/ConversionChecker.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/ConversionChecker.cpp
@@ -123,57 +123,6 @@
   C.emitReport(std::move(R));
 }
 
-// Is E value greater or equal than Val?
-static bool isGreaterEqual(CheckerContext , const Expr *E,
-   unsigned long long Val) {
-  ProgramStateRef State = C.getState();
-  SVal EVal = C.getSVal(E);
-  if (EVal.isUnknownOrUndef())
-return false;
-  if (!EVal.getAs() && EVal.getAs()) {
-ProgramStateManager  = C.getStateManager();
-EVal =
-Mgr.getStoreManager().getBinding(State->getStore(), EVal.castAs());
-  }
-  if (EVal.isUnknownOrUndef() || !EVal.getAs())
-return false;
-
-  SValBuilder  = C.getSValBuilder();
-  DefinedSVal V = Bldr.makeIntVal(Val, C.getASTContext().LongLongTy);
-
-  // Is DefinedEVal greater or equal with V?
-  SVal GE = Bldr.evalBinOp(State, BO_GE, EVal, V, Bldr.getConditionType());
-  if (GE.isUnknownOrUndef())
-return false;
-  ConstraintManager  = C.getConstraintManager();
-  ProgramStateRef StGE, StLT;
-  std::tie(StGE, StLT) = CM.assumeDual(State, GE.castAs());
-  return StGE && !StLT;
-}
-
-// Is E value negative?
-static bool isNegative(CheckerContext , const Expr *E) {
-  ProgramStateRef State = C.getState();
-  SVal EVal = State->getSVal(E, C.getLocationContext());
-  if (EVal.isUnknownOrUndef() || !EVal.getAs())
-return false;
-  DefinedSVal DefinedEVal = EVal.castAs();
-
-  SValBuilder  = C.getSValBuilder();
-  DefinedSVal V = Bldr.makeIntVal(0, false);
-
-  SVal LT =
-  Bldr.evalBinOp(State, BO_LT, DefinedEVal, V, Bldr.getConditionType());
-
-  // Is E value greater than MaxVal?
-  ConstraintManager  = C.getConstraintManager();
-  ProgramStateRef StNegative, StPositive;
-  std::tie(StNegative, StPositive) =
-  CM.assumeDual(State, LT.castAs());
-
-  return StNegative && !StPositive;
-}
-
 bool ConversionChecker::isLossOfPrecision(const ImplicitCastExpr *Cast,
   QualType DestType,
   CheckerContext ) const {
@@ -195,18 +144,18 @@
 return false;
 
   unsigned long long MaxVal = 1ULL << W;
-  return isGreaterEqual(C, Cast->getSubExpr(), MaxVal);
+  return C.isGreaterOrEqual(Cast->getSubExpr(), MaxVal);
 }
 
 bool ConversionChecker::isLossOfSign(const ImplicitCastExpr *Cast,
-   CheckerContext ) const {
+ CheckerContext ) const {
   QualType CastType = Cast->getType();
   QualType SubType = 

r315462 - [Analyzer] Clarify error messages for undefined result

2017-10-11 Thread Daniel Marjamaki via cfe-commits
Author: danielmarjamaki
Date: Wed Oct 11 07:49:35 2017
New Revision: 315462

URL: http://llvm.org/viewvc/llvm-project?rev=315462=rev
Log:
[Analyzer] Clarify error messages for undefined result

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


Modified:
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h
cfe/trunk/lib/StaticAnalyzer/Checkers/ConversionChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/UndefResultChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Core/CheckerContext.cpp
cfe/trunk/test/Analysis/bitwise-ops.c

Modified: 
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h?rev=315462=315461=315462=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h 
(original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h 
Wed Oct 11 07:49:35 2017
@@ -196,6 +196,13 @@ public:
 return getState()->getSVal(S, getLocationContext());
   }
 
+  /// \brief Returns true if the value of \p E is greater than or equal to \p
+  /// Val under unsigned comparison
+  bool isGreaterOrEqual(const Expr *E, unsigned long long Val);
+
+  /// Returns true if the value of \p E is negative.
+  bool isNegative(const Expr *E);
+
   /// \brief Generates a new transition in the program state graph
   /// (ExplodedGraph). Uses the default CheckerContext predecessor node.
   ///

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/ConversionChecker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/ConversionChecker.cpp?rev=315462=315461=315462=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/ConversionChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/ConversionChecker.cpp Wed Oct 11 
07:49:35 2017
@@ -123,57 +123,6 @@ void ConversionChecker::reportBug(Explod
   C.emitReport(std::move(R));
 }
 
-// Is E value greater or equal than Val?
-static bool isGreaterEqual(CheckerContext , const Expr *E,
-   unsigned long long Val) {
-  ProgramStateRef State = C.getState();
-  SVal EVal = C.getSVal(E);
-  if (EVal.isUnknownOrUndef())
-return false;
-  if (!EVal.getAs() && EVal.getAs()) {
-ProgramStateManager  = C.getStateManager();
-EVal =
-Mgr.getStoreManager().getBinding(State->getStore(), 
EVal.castAs());
-  }
-  if (EVal.isUnknownOrUndef() || !EVal.getAs())
-return false;
-
-  SValBuilder  = C.getSValBuilder();
-  DefinedSVal V = Bldr.makeIntVal(Val, C.getASTContext().LongLongTy);
-
-  // Is DefinedEVal greater or equal with V?
-  SVal GE = Bldr.evalBinOp(State, BO_GE, EVal, V, Bldr.getConditionType());
-  if (GE.isUnknownOrUndef())
-return false;
-  ConstraintManager  = C.getConstraintManager();
-  ProgramStateRef StGE, StLT;
-  std::tie(StGE, StLT) = CM.assumeDual(State, GE.castAs());
-  return StGE && !StLT;
-}
-
-// Is E value negative?
-static bool isNegative(CheckerContext , const Expr *E) {
-  ProgramStateRef State = C.getState();
-  SVal EVal = State->getSVal(E, C.getLocationContext());
-  if (EVal.isUnknownOrUndef() || !EVal.getAs())
-return false;
-  DefinedSVal DefinedEVal = EVal.castAs();
-
-  SValBuilder  = C.getSValBuilder();
-  DefinedSVal V = Bldr.makeIntVal(0, false);
-
-  SVal LT =
-  Bldr.evalBinOp(State, BO_LT, DefinedEVal, V, Bldr.getConditionType());
-
-  // Is E value greater than MaxVal?
-  ConstraintManager  = C.getConstraintManager();
-  ProgramStateRef StNegative, StPositive;
-  std::tie(StNegative, StPositive) =
-  CM.assumeDual(State, LT.castAs());
-
-  return StNegative && !StPositive;
-}
-
 bool ConversionChecker::isLossOfPrecision(const ImplicitCastExpr *Cast,
   QualType DestType,
   CheckerContext ) const {
@@ -195,18 +144,18 @@ bool ConversionChecker::isLossOfPrecisio
 return false;
 
   unsigned long long MaxVal = 1ULL << W;
-  return isGreaterEqual(C, Cast->getSubExpr(), MaxVal);
+  return C.isGreaterOrEqual(Cast->getSubExpr(), MaxVal);
 }
 
 bool ConversionChecker::isLossOfSign(const ImplicitCastExpr *Cast,
-   CheckerContext ) const {
+ CheckerContext ) const {
   QualType CastType = Cast->getType();
   QualType SubType = Cast->IgnoreParenImpCasts()->getType();
 
   if (!CastType->isUnsignedIntegerType() || !SubType->isSignedIntegerType())
 return false;
 
-  return isNegative(C, Cast->getSubExpr());
+  return C.isNegative(Cast->getSubExpr());
 }
 
 void ento::registerConversionChecker(CheckerManager ) {

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/UndefResultChecker.cpp
URL: 

[PATCH] D37856: [refactor] add support for refactoring options

2017-10-11 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added a comment.

In https://reviews.llvm.org/D37856#894638, @hokein wrote:

> Sorry for the delay. I saw you have reverted this commit somehow. A post 
> commit.


I had some issues with ppc64/s390x bots for some reason, so I had to revert. 
I'm still trying to investigate what went wrong there, it looks like ASAN/UBSAN 
are not catching anything though.




Comment at: cfe/trunk/lib/Tooling/Refactoring/Rename/RenamingAction.cpp:113
 Rules.push_back(createRefactoringActionRule(
-SymbolSelectionRequirement()));
+SymbolSelectionRequirement(), OptionRequirement()));
 return Rules;

hokein wrote:
> Thought it a bit more: it requires all of the requirements are satisfied, I 
> think we need to support "one-of" option. For example,  we have two option 
> "-a" and "-b",  only one of them is allowed to be present at the same time.
That should be straightforward enough to implement, either with a custom class 
or with a built-in requirement class. I'll probably add a builtin one when the 
need comes up.


Repository:
  rL LLVM

https://reviews.llvm.org/D37856



___
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-10-11 Thread Dominik Szabó via Phabricator via cfe-commits
szdominik added inline comments.



Comment at: clang-tidy/misc/CopyConstructorInitCheck.cpp:37
+
+  // We match here because we want one warning (and FixIt) for every ctor.
+  const auto Matches = match(

aaron.ballman wrote:
> Wouldn't registering this matcher achieve the same goal instead of needing to 
> re-match?
I wanted to create //only one// FixIt to every ctor - if I move the 
forEachCtorInitializer to the register part, it would warn us twice.



Comment at: clang-tidy/misc/CopyConstructorInitCheck.cpp:104
+
+  diag(Tok.getLocation(),
+   "calling an inherited constructor other than the copy constructor")

aaron.ballman wrote:
> Insteaad of having to re-lex the physical source, can the AST should be 
> modified to carry the information you need if it doesn't already have it? For 
> instance, you can tell there is not initializer list by looking at 
> `CXXConstructorDecl::getNumCtorInitializers()`.
The getNumCtorInitializers method counts the generated initializers as well, 
not just the manually written ones.
My basic problem was that the AST's methods can't really distinguish the 
generated and the manually written initializers, so it's quite complicated to 
find the locations what we need. I found easier & more understandable if I 
start reading the tokens.



Comment at: test/clang-tidy/misc-copy-constructor-init.cpp:27
+   // CHECK-MESSAGES: :[[@LINE-1]]:23: warning: calling an inherited 
constructor other than the copy constructor [misc-copy-constructor-init]
+   // CHECK-FIXES: X3(const X3& other): Copyable2(other), Copyable(other) 
{};
+};

aaron.ballman wrote:
> Don't we want the ctor-inits to be in the same order as the bases are 
> specified?
I think it's more readable if we put the FixIts to the beginning of the 
expression - it's easier to check that everyting is correct & it's more obvious 
what the changes are.


https://reviews.llvm.org/D33722



___
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-10-11 Thread Dominik Szabó via Phabricator via cfe-commits
szdominik updated this revision to Diff 118617.
szdominik marked 4 inline comments as done.
szdominik added a comment.

Small changes after aaron.ballman's comments.


https://reviews.llvm.org/D33722

Files:
  clang-tidy/misc/CMakeLists.txt
  clang-tidy/misc/CopyConstructorInitCheck.cpp
  clang-tidy/misc/CopyConstructorInitCheck.h
  clang-tidy/misc/MiscTidyModule.cpp
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/misc-copy-constructor-init.rst
  test/clang-tidy/misc-copy-constructor-init.cpp

Index: test/clang-tidy/misc-copy-constructor-init.cpp
===
--- /dev/null
+++ test/clang-tidy/misc-copy-constructor-init.cpp
@@ -0,0 +1,95 @@
+// RUN: %check_clang_tidy %s misc-copy-constructor-init %t
+
+class Copyable {
+	public:
+	Copyable() = default;
+	Copyable(const Copyable&) = default;
+};
+class X : public Copyable {
+	X(const X& other) : Copyable(other) {}
+	//Good code: the copy ctor call the ctor of the base class.
+};
+
+class Copyable2 {
+	public:
+	Copyable2() = default;
+	Copyable2(const Copyable2&) = default;
+};
+class X2 : public Copyable2 {
+	X2(const X2& other) {};
+// CHECK-MESSAGES: :[[@LINE-1]]:22: warning: calling an inherited constructor other than the copy constructor [misc-copy-constructor-init]
+	// CHECK-FIXES: X2(const X2& other) : Copyable2(other) {};
+};
+
+class X3 : public Copyable, public Copyable2 {
+	X3(const X3& other): Copyable(other) {};
+	// CHECK-MESSAGES: :[[@LINE-1]]:23: warning: calling an inherited constructor other than the copy constructor [misc-copy-constructor-init]
+	// CHECK-FIXES: X3(const X3& other): Copyable2(other), Copyable(other) {};
+};
+
+class X4 : public Copyable {
+	X4(const X4& other): Copyable() {};
+	// CHECK-MESSAGES: :[[@LINE-1]]:32: warning: calling an inherited constructor other than the copy constructor [misc-copy-constructor-init]
+	// CHECK-FIXES: X4(const X4& other): Copyable(other) {};
+};
+
+class Copyable3 : public Copyable {
+	public:
+	Copyable3() = default;
+	Copyable3(const Copyable3&) = default;
+};
+class X5 : public Copyable3 {
+	X5(const X5& other) {};
+// CHECK-MESSAGES: :[[@LINE-1]]:22: warning: calling an inherited constructor other than the copy constructor [misc-copy-constructor-init]
+	// CHECK-FIXES: X5(const X5& other) : Copyable3(other) {};
+};
+
+class X6 : public Copyable2, public Copyable3 {
+	X6(const X6& other) {};
+	// CHECK-MESSAGES: :[[@LINE-1]]:22: warning: calling an inherited constructor other than the copy constructor [misc-copy-constructor-init]
+	// CHECK-FIXES: X6(const X6& other) : Copyable2(other), Copyable3(other) {};
+};
+
+class X7 : public Copyable, public Copyable2 {
+	X7(const X7& other): Copyable() {};
+	// CHECK-MESSAGES: :[[@LINE-1]]:32: warning: calling an inherited constructor other than the copy constructor [misc-copy-constructor-init]
+	// CHECK-MESSAGES: :[[@LINE-2]]:22: warning: calling an inherited constructor other than the copy constructor [misc-copy-constructor-init]
+	// CHECK-FIXES: X7(const X7& other): Copyable2(other), Copyable(other) {};
+};
+
+template 
+class Copyable4 {
+	public:
+	Copyable4() = default;
+	Copyable4(const Copyable4&) = default;
+};
+
+class X8 : public Copyable4 {
+	X8(const X8& other): Copyable4(other) {};
+	//Good code: the copy ctor call the ctor of the base class.
+};
+
+class X9 : public Copyable4 {
+	X9(const X9& other): Copyable4() {};
+	// CHECK-MESSAGES: :[[@LINE-1]]:37: warning: calling an inherited constructor other than the copy constructor [misc-copy-constructor-init]
+	// CHECK-FIXES: X9(const X9& other): Copyable4(other) {};
+};
+
+class X10 : public Copyable4 {
+	X10(const X10& other) {};
+	// CHECK-MESSAGES: :[[@LINE-1]]:22: warning: calling an inherited constructor other than the copy constructor [misc-copy-constructor-init]
+	// CHECK-FIXES: X10(const X10& other) : Copyable4(other) {};
+};
+
+template 
+class Copyable5 {
+	public:
+	Copyable5() = default;
+	Copyable5(const Copyable5&) = default;
+};
+
+class X11 : public Copyable5 {
+	X11(const X11& other) {};
+	// CHECK-MESSAGES: :[[@LINE-1]]:22: warning: calling an inherited constructor other than the copy constructor [misc-copy-constructor-init]
+	// CHECK-FIXES: X11(const X11& other) : Copyable5(other) {};
+};
Index: docs/clang-tidy/checks/misc-copy-constructor-init.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/misc-copy-constructor-init.rst
@@ -0,0 +1,30 @@
+.. title:: clang-tidy - misc-copy-constructor-init
+
+misc-copy-constructor-init
+=
+
+Finds copy constructors where the constructor don't call 
+the constructor of the base class.
+
+.. code-block:: c++
+
+class Copyable {
+public:
+Copyable() = default;
+Copyable(const Copyable&) = default;
+};
+class X2 : public Copyable {
+X2(const X2& other) {}; // 

[PATCH] D38801: [analyzer] In getSVal() API, disable auto-detection of void type as char type.

2017-10-11 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ created this revision.
Herald added a subscriber: szepet.

In https://reviews.llvm.org/D38358, we ended up believing that reading the 
first byte of the void pointer is not the intended behavior of 
`ProgramState::getSVal(Loc)`. Hence the fix.

Additionally, allow specifying the type in the `ProgramState::getSVal(const 
MemRegion *)` override (i personally like this API better, and it is also used 
in the affected checker).


https://reviews.llvm.org/D38801

Files:
  include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h
  lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp
  lib/StaticAnalyzer/Core/RegionStore.cpp


Index: lib/StaticAnalyzer/Core/RegionStore.cpp
===
--- lib/StaticAnalyzer/Core/RegionStore.cpp
+++ lib/StaticAnalyzer/Core/RegionStore.cpp
@@ -1403,10 +1403,7 @@
 T = Ctx.VoidTy;
 }
 assert(!T.isNull() && "Unable to auto-detect binding type!");
-if (T->isVoidType()) {
-  // When trying to dereference a void pointer, read the first byte.
-  T = Ctx.CharTy;
-}
+assert(!T->isVoidType() && "Attempting to dereference a void pointer!");
 MR = GetElementZeroRegion(cast(MR), T);
   }
 
Index: lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp
+++ lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp
@@ -179,7 +179,7 @@
 
   if (const MemRegion *SValMemRegion = V.getAsRegion()) {
 const ProgramStateRef State = C.getState();
-const SVal PSV = State->getSVal(SValMemRegion);
+const SVal PSV = State->getSVal(SValMemRegion, C.getASTContext().CharTy);
 if (PSV.isUndef()) {
   if (ExplodedNode *N = C.generateErrorNode()) {
 LazyInit_BT(BD, BT);
Index: include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h
===
--- include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h
+++ include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h
@@ -308,8 +308,12 @@
 
   /// \brief Return the value bound to the specified location.
   /// Returns UnknownVal() if none found.
-  SVal getSVal(const MemRegion* R) const;
+  SVal getSVal(const MemRegion* R, QualType T = QualType()) const;
 
+  /// \brief Return the value bound to the specified location, assuming
+  /// that the value is a scalar integer or an enumeration or a pointer.
+  /// Returns UnknownVal() if none found or the region is not known to hold
+  /// a value of such type.
   SVal getSValAsScalarOrLoc(const MemRegion *R) const;
 
   /// \brief Visits the symbols reachable from the given SVal using the 
provided
@@ -758,9 +762,10 @@
   return getStateManager().StoreMgr->getBinding(getStore(), LV, T);
 }
 
-inline SVal ProgramState::getSVal(const MemRegion* R) const {
+inline SVal ProgramState::getSVal(const MemRegion* R, QualType T) const {
   return getStateManager().StoreMgr->getBinding(getStore(),
-loc::MemRegionVal(R));
+loc::MemRegionVal(R),
+T);
 }
 
 inline BasicValueFactory ::getBasicVals() const {


Index: lib/StaticAnalyzer/Core/RegionStore.cpp
===
--- lib/StaticAnalyzer/Core/RegionStore.cpp
+++ lib/StaticAnalyzer/Core/RegionStore.cpp
@@ -1403,10 +1403,7 @@
 T = Ctx.VoidTy;
 }
 assert(!T.isNull() && "Unable to auto-detect binding type!");
-if (T->isVoidType()) {
-  // When trying to dereference a void pointer, read the first byte.
-  T = Ctx.CharTy;
-}
+assert(!T->isVoidType() && "Attempting to dereference a void pointer!");
 MR = GetElementZeroRegion(cast(MR), T);
   }
 
Index: lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp
+++ lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp
@@ -179,7 +179,7 @@
 
   if (const MemRegion *SValMemRegion = V.getAsRegion()) {
 const ProgramStateRef State = C.getState();
-const SVal PSV = State->getSVal(SValMemRegion);
+const SVal PSV = State->getSVal(SValMemRegion, C.getASTContext().CharTy);
 if (PSV.isUndef()) {
   if (ExplodedNode *N = C.generateErrorNode()) {
 LazyInit_BT(BD, BT);
Index: include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h
===
--- include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h
+++ include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h
@@ -308,8 +308,12 @@
 
   /// \brief Return the value bound to the specified location.
   /// Returns UnknownVal() if none found.
-  SVal getSVal(const MemRegion* R) const;
+  SVal getSVal(const MemRegion* R, QualType T = 

[PATCH] D38679: [libunwind] Support dwarf unwinding on i386 windows

2017-10-11 Thread Jonathan Roelofs via Phabricator via cfe-commits
jroelofs accepted this revision.
jroelofs added a comment.
This revision is now accepted and ready to land.

LGTM


https://reviews.llvm.org/D38679



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


[PATCH] D38798: [OpenMP] Support for implicit "declare target" functions - Sema patch

2017-10-11 Thread George Rokos via Phabricator via cfe-commits
grokos created this revision.
grokos added a project: clang.

This patch completes the support for the "declare target" directive in Sema. 
With this patch Sema handles implicitly used functions (i.e. functions which 
are used inside a target region without having been "declared target") 
including lambdas, templated functions, functions called from within target 
functions and ctors/dtors.

By default, use of implicit declare target functions is enabled. An upcoming 
driver patch will change that.


Repository:
  rL LLVM

https://reviews.llvm.org/D38798

Files:
  include/clang/Basic/LangOptions.def
  include/clang/Sema/Sema.h
  include/clang/Sema/SemaInternal.h
  lib/Parse/ParseOpenMP.cpp
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaOpenMP.cpp

Index: lib/Sema/SemaOpenMP.cpp
===
--- lib/Sema/SemaOpenMP.cpp
+++ lib/Sema/SemaOpenMP.cpp
@@ -19,6 +19,7 @@
 #include "clang/AST/Decl.h"
 #include "clang/AST/DeclCXX.h"
 #include "clang/AST/DeclOpenMP.h"
+#include "clang/AST/RecursiveASTVisitor.h"
 #include "clang/AST/StmtCXX.h"
 #include "clang/AST/StmtOpenMP.h"
 #include "clang/AST/StmtVisitor.h"
@@ -1139,6 +1140,124 @@
   return false;
 }
 
+namespace {
+/// Visit actual function body and its associated nested functions bodies.
+class ImplicitDeviceFunctionChecker
+: public RecursiveASTVisitor {
+  Sema 
+
+public:
+  ImplicitDeviceFunctionChecker(Sema ) : SemaRef(SemaReference){};
+
+  /// Traverse body of lambda, and mark it the with OMPDeclareTargetDeclAttr
+  bool TraverseLambdaCapture(LambdaExpr *LE, const LambdaCapture *C,
+ Expr *Init);
+
+  /// Traverse FunctionDecl and mark it the with OMPDeclareTargetDeclAttr
+  bool VisitFunctionDecl(FunctionDecl *F);
+
+  /// Traverse Callee of Calexpr and mark it the with OMPDeclareTargetDeclAttr
+  bool VisitCallExpr(CallExpr *Call);
+
+  /// Traverse Constructs and mark it the with OMPDeclareTargetDeclAttr
+  bool VisitCXXConstructExpr(CXXConstructExpr *E);
+
+  /// Traverse Destructor and mark it the with OMPDeclareTargetDeclAttr
+  bool VisitCXXDestructorDecl(CXXDestructorDecl *D);
+};
+}
+
+/// Traverse declaration of /param D to check whether it has
+/// OMPDeclareTargetDeclAttr or not. If so, it marks definition with
+/// OMPDeclareTargetDeclAttr.
+static void ImplicitDeclareTargetCheck(Sema , Decl *D) {
+  if (SemaRef.getLangOpts().OpenMPImplicitDeclareTarget) {
+// Structured block of target region is visited to catch function call.
+// Revealed function calls are marked with OMPDeclareTargetDeclAttr
+// attribute,
+// in case -fopenmp-implicit-declare-target extension is enabled.
+ImplicitDeviceFunctionChecker FunctionCallChecker(SemaRef);
+FunctionCallChecker.TraverseDecl(D);
+  }
+}
+
+/// Traverse declaration of /param D to check whether it has
+/// OMPDeclareTargetDeclAttr or not. If so, it marks definition with
+/// OMPDeclareTargetDeclAttr.
+void Sema::checkDeclImplicitlyUsedOpenMPTargetContext(Decl *D) {
+  if (!D || D->isInvalidDecl())
+return;
+
+  if (FunctionDecl *FD = dyn_cast(D)) {
+if (FD->hasBody()) {
+  for (auto RI : FD->redecls()) {
+if (RI->hasAttr()) {
+  Attr *A = OMPDeclareTargetDeclAttr::CreateImplicit(
+  Context, OMPDeclareTargetDeclAttr::MT_To);
+  D->addAttr(A);
+
+  ImplicitDeclareTargetCheck(*this, FD);
+  return;
+}
+  }
+}
+  }
+  return;
+}
+
+bool ImplicitDeviceFunctionChecker::TraverseLambdaCapture(
+LambdaExpr *LE, const LambdaCapture *C, Expr *Init) {
+  if (CXXRecordDecl *Class = LE->getLambdaClass())
+if (!Class->hasAttr()) {
+  Attr *A = OMPDeclareTargetDeclAttr::CreateImplicit(
+  SemaRef.Context, OMPDeclareTargetDeclAttr::MT_To);
+  Class->addAttr(A);
+}
+
+  TraverseStmt(LE->getBody());
+  return true;
+}
+
+bool ImplicitDeviceFunctionChecker::VisitFunctionDecl(FunctionDecl *F) {
+  assert(F);
+  if (!F->hasAttr()) {
+Attr *A = OMPDeclareTargetDeclAttr::CreateImplicit(
+SemaRef.Context, OMPDeclareTargetDeclAttr::MT_To);
+F->addAttr(A);
+TraverseDecl(F);
+  }
+  return true;
+}
+
+bool ImplicitDeviceFunctionChecker::VisitCallExpr(CallExpr *Call) {
+  if (FunctionDecl *Callee = Call->getDirectCallee()) {
+return VisitFunctionDecl(Callee);
+  }
+  return true;
+}
+
+bool ImplicitDeviceFunctionChecker::VisitCXXConstructExpr(CXXConstructExpr *E) {
+  CXXConstructorDecl *Constructor = E->getConstructor();
+  // When constructor is invoked, it is checked whether the object has
+  // destructor or not. In case it has destructor, destructor is automatically
+  // marked with declare target attribute since it is needed to emit for device,
+  QualType Ty = E->getType();
+  const RecordType *RT =
+  SemaRef.Context.getBaseElementType(Ty)->getAs();
+  CXXRecordDecl *RD = cast(RT->getDecl());
+
+  if (auto *Destructor = RD->getDestructor())
+VisitCXXDestructorDecl(Destructor);

r315459 - [clang-rename] Add more unittest.

2017-10-11 Thread Haojian Wu via cfe-commits
Author: hokein
Date: Wed Oct 11 07:00:42 2017
New Revision: 315459

URL: http://llvm.org/viewvc/llvm-project?rev=315459=rev
Log:
[clang-rename] Add more unittest.

Modified:
cfe/trunk/unittests/Rename/RenameClassTest.cpp

Modified: cfe/trunk/unittests/Rename/RenameClassTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Rename/RenameClassTest.cpp?rev=315459=315458=315459=diff
==
--- cfe/trunk/unittests/Rename/RenameClassTest.cpp (original)
+++ cfe/trunk/unittests/Rename/RenameClassTest.cpp Wed Oct 11 07:00:42 2017
@@ -674,6 +674,124 @@ TEST_F(ClangRenameTest, ReferencesInLamb
   CompareSnippets(Expected, After);
 }
 
+TEST_F(ClangRenameTest, DontChangeIfSameName) {
+  std::string Before = R"(
+  namespace foo {
+  class Old {
+   public:
+ static void foo() {}
+  };
+  }
+
+  void f(foo::Old * x) {
+foo::Old::foo() ;
+  }
+  using foo::Old;)";
+  std::string Expected = R"(
+  namespace foo {
+  class Old {
+   public:
+ static void foo() {}
+  };
+  }
+
+  void f(foo::Old * x) {
+foo::Old::foo() ;
+  }
+  using foo::Old;)";
+  std::string After = runClangRenameOnCode(Before, "foo::Old", "foo::Old");
+  CompareSnippets(Expected, After);
+}
+
+TEST_F(ClangRenameTest, ChangeIfNewNameWithLeadingDotDot) {
+  std::string Before = R"(
+  namespace foo {
+  class Old {
+   public:
+ static void foo() {}
+  };
+  }
+
+  void f(foo::Old * x) {
+foo::Old::foo() ;
+  }
+  using foo::Old;)";
+  std::string Expected = R"(
+  namespace foo {
+  class Old {
+   public:
+ static void foo() {}
+  };
+  }
+
+  void f(::foo::Old * x) {
+::foo::Old::foo() ;
+  }
+  using ::foo::Old;)";
+  std::string After = runClangRenameOnCode(Before, "foo::Old", "::foo::Old");
+  CompareSnippets(Expected, After);
+}
+
+TEST_F(ClangRenameTest, ChangeIfSameNameWithLeadingDotDot) {
+  std::string Before = R"(
+  namespace foo {
+  class Old {
+   public:
+ static void foo() {}
+  };
+  }
+
+  void f(foo::Old * x) {
+foo::Old::foo() ;
+  }
+  using foo::Old;)";
+  std::string Expected = R"(
+  namespace foo {
+  class Old {
+   public:
+ static void foo() {}
+  };
+  }
+
+  void f(::foo::Old * x) {
+::foo::Old::foo() ;
+  }
+  using ::foo::Old;)";
+  std::string After = runClangRenameOnCode(Before, "::foo::Old", "::foo::Old");
+  CompareSnippets(Expected, After);
+}
+
+TEST_F(RenameClassTest, UsingAlias) {
+  std::string Before = R"(
+  namespace a { struct A {}; }
+
+  namespace foo {
+  using Alias = a::A;
+  Alias a;
+  })";
+  std::string Expected = R"(
+  namespace a { struct B {}; }
+
+  namespace foo {
+  using Alias = b::B;
+  Alias a;
+  })";
+  std::string After = runClangRenameOnCode(Before, "a::A", "b::B");
+  CompareSnippets(Expected, After);
+}
+
+TEST_F(ClangRenameTest, NestedTemplates) {
+  std::string Before = R"(
+  namespace a { template  struct A {}; }
+  a::A foo;)";
+  std::string Expected = R"(
+  namespace a { template  struct B {}; }
+  b::B foo;)";
+  std::string After = runClangRenameOnCode(Before, "a::A", "b::B");
+  CompareSnippets(Expected, After);
+}
+
+
 } // anonymous namespace
 } // namespace test
 } // namespace clang_rename


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


[PATCH] D37856: [refactor] add support for refactoring options

2017-10-11 Thread Haojian Wu via Phabricator via cfe-commits
hokein added a comment.

Sorry for the delay. I saw you have reverted this commit somehow. A post commit.




Comment at: cfe/trunk/lib/Tooling/Refactoring/Rename/RenamingAction.cpp:113
 Rules.push_back(createRefactoringActionRule(
-SymbolSelectionRequirement()));
+SymbolSelectionRequirement(), OptionRequirement()));
 return Rules;

Thought it a bit more: it requires all of the requirements are satisfied, I 
think we need to support "one-of" option. For example,  we have two option "-a" 
and "-b",  only one of them is allowed to be present at the same time.


Repository:
  rL LLVM

https://reviews.llvm.org/D37856



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


[PATCH] D38797: [analyzer] CStringChecker: pr34460: Admit that some casts are hard to model.

2017-10-11 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added inline comments.



Comment at: test/Analysis/casts.c:134-139
+  clang_analyzer_eval(y1 == y2); // expected-warning{{TRUE}}
+
+  // FIXME: should be FALSE (i.e. equal pointers).
+  clang_analyzer_eval(y1 - y2); // expected-warning{{UNKNOWN}}
+  // FIXME: should be TRUE (i.e. same symbol).
+  clang_analyzer_eval(*y1 == *y2); // expected-warning{{UNKNOWN}}

Here we have `y1` pointing to `element{element{x, 3}, 5}` vs. both `y2` and 
`y3` pointing to `element{x, 35}`. While `y3` is inevitably looking like that, 
`y2` could have been same as `y1` if we didn't unwrap multi-dimensional array 
elements.


https://reviews.llvm.org/D38797



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


[PATCH] D38797: [analyzer] CStringChecker: pr34460: Admit that some casts are hard to model.

2017-10-11 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ created this revision.
Herald added a subscriber: szepet.

In https://bugs.llvm.org/show_bug.cgi?id=34460 CStringChecker tries to 
`evalCast()` a memory region from `void *` to `char *` for the purposes of 
modeling `mempcpy()`. The memory region turned out to be an element region of 
type `unsigned int` with a symbolic index. For such regions, even such trivial 
casts have turned out to be unsupported (modeled as `UnknownVal`), and the 
checker crashed upon asserting them to be supported.

I tried to get such trivial cast working for a few days and ended up believing 
that it not worth the effort because of:

1. How we represent casts in the SVal hierarchy.
  - In our case, the region is an ElementRegion with element type `unsigned 
int`, which //essentially// represents a pointer of type `unsigned int *`, not 
`void *`. It means that the cast is definitely not a no-op; the region needs to 
be modified.
  - Now, if the offset was concrete, we already try to replace ElementRegion 
with another ElementRegion of the other type, and recompute element index 
accordingly. It is only possible if byte offset of the region is divisible by 
size of the target type (in our case it is because the target type is `char`). 
If it's not divisible, we make two ElementRegions on top of each other, first 
with element-type `char` to represent a raw offset, other of the target type to 
represent the cast. It means that for symbolic index case, we need to account 
for being able to receive such two-element-regions construct in the first 
place, and then investigate divisibility of a linear expression of form `a*N + 
b`, where `N` is concrete but `a` and `b` are possibly symbolic, to  a concrete 
type size, which our range constraint manager would never handle.
  - In fact, now we not only unpack the top one or two ElementRegions while 
computing the offset (that needs to be divisible), but also we unpack all other 
top-level element regions (i.e. if we look into a multi-dimensional array; see 
`ElementRegion::getAsArrayOffset()`). This was never tested; i added relevant 
tests into `casts.c` in this patch to demonstrate the problems caused by that 
(which are unrelated to the rest of the patch). I believe that unpacking 
multi-dimensional arrays in this way is not ideal; however, i also added tests 
that would fail if this behavior is disabled. This needs much more work. Of 
course, this work would be even harder if we intend to support symbolic offsets.
2. How we split the responsibilities between entities. When trying to implement 
the plan described in 1., i ended up moving a lot of code around and passing 
ProgramState through dozens of APIs. We need the state to perform binary 
operations on `SVal` objects through `SValBuilder`. Originally, `castRegion()` 
resides in `RegionStore` which is not intended to access the program state. It 
is trivial to move `castRegion` to `SimpleSValBuilder`, but passing `State` 
into it results in a huge cascade of changes in `SValBuilder` method arguments. 
I have given up when i had to pass `State` to 
`SValBuilder::getConstantVal(const Expr *);`, which seemed ridiculous (it's 
constant, why does it depend on the state?). Introducing all this complexity 
only to compute an `SVal` that nobody would be able to understand was not worth 
the effort, in my opinion.

Hence the quick fix. Code slightly simplified to use a more high-level API.


https://reviews.llvm.org/D38797

Files:
  lib/StaticAnalyzer/Checkers/CStringChecker.cpp
  test/Analysis/bstring.cpp
  test/Analysis/casts.c

Index: test/Analysis/casts.c
===
--- test/Analysis/casts.c
+++ test/Analysis/casts.c
@@ -123,3 +123,29 @@
   int x = (int) p;
   clang_analyzer_eval(++x < 10); // no-crash // expected-warning{{UNKNOWN}}
 }
+
+void multiDimensionalArrayPointerCasts() {
+  static int x[10][10];
+  int *y1 = &(x[3][5]);
+  char *z = ((char *) y1) + 2;
+  int *y2 = (int *)(z - 2);
+  int *y3 = ((int *)x) + 35; // This is offset for [3][5].
+
+  clang_analyzer_eval(y1 == y2); // expected-warning{{TRUE}}
+
+  // FIXME: should be FALSE (i.e. equal pointers).
+  clang_analyzer_eval(y1 - y2); // expected-warning{{UNKNOWN}}
+  // FIXME: should be TRUE (i.e. same symbol).
+  clang_analyzer_eval(*y1 == *y2); // expected-warning{{UNKNOWN}}
+
+  clang_analyzer_eval(*((char *)y1) == *((char *) y2)); // expected-warning{{TRUE}}
+
+  clang_analyzer_eval(y1 == y3); // expected-warning{{TRUE}}
+
+  // FIXME: should be FALSE (i.e. equal pointers).
+  clang_analyzer_eval(y1 - y3); // expected-warning{{UNKNOWN}}
+  // FIXME: should be TRUE (i.e. same symbol).
+  clang_analyzer_eval(*y1 == *y3); // expected-warning{{UNKNOWN}}
+
+  clang_analyzer_eval(*((char *)y1) == *((char *) y3)); // expected-warning{{TRUE}}
+}
Index: test/Analysis/bstring.cpp
===
--- test/Analysis/bstring.cpp
+++ test/Analysis/bstring.cpp
@@ -1,8 +1,35 

  1   2   >