Re: [PATCH] D33660: [coroutines] Fix assertion during -Wuninitialized analysis

2017-06-07 Thread Eric Fiselier via cfe-commits
Yes, the thing that it's supposed to be testing is -Wuninitialized and
other analysis warnings.

I'll re-name the test and add more test cases to this effect shortly.
Thanks for the input.

On Mon, Jun 5, 2017 at 10:33 AM, David Blaikie  wrote:

>
>
> On Mon, May 29, 2017 at 3:28 PM Eric Fiselier via Phabricator via
> cfe-commits  wrote:
>
>> EricWF created this revision.
>>
>> @rsmith Is there a better place to put this test?
>>
>>
>> https://reviews.llvm.org/D33660
>>
>> Files:
>>   lib/Sema/SemaCoroutine.cpp
>>   test/SemaCXX/coreturn.cpp
>>   test/SemaCXX/coroutine-uninitialized-warning-crash.cpp
>>
>>
>> Index: test/SemaCXX/coroutine-uninitialized-warning-crash.cpp
>> ===
>> --- /dev/null
>> +++ test/SemaCXX/coroutine-uninitialized-warning-crash.cpp
>> @@ -0,0 +1,44 @@
>> +// RUN: %clang_cc1 -triple x86_64-apple-darwin9 %s -std=c++14
>> -fcoroutines-ts -fsyntax-only -Wall -Wextra -Wuninitialized  -fblocks
>>
>
> A test case that tests only "this doesn't crash" is usually a bit of a
> hint to me, at least, that something's under-tested. I assume there's some
> specific behavior that's desired more than "does anything other than
> crashing" that should be being tested for here?
>
>
>> +#include "Inputs/std-coroutine.h"
>> +
>> +using namespace std::experimental;
>> +
>> +
>> +struct A {
>> +  bool await_ready() { return true; }
>> +  int await_resume() { return 42; }
>> +  template 
>> +  void await_suspend(F) {}
>> +};
>> +
>> +
>> +struct coro_t {
>> +  struct promise_type {
>> +coro_t get_return_object() { return {}; }
>> +suspend_never initial_suspend() { return {}; }
>> +suspend_never final_suspend() { return {}; }
>> +A yield_value(int) { return {}; }
>> +void return_void() {}
>> +static void unhandled_exception() {}
>> +  };
>> +};
>> +
>> +coro_t f(int n) {
>> +  if (n == 0)
>> +co_return;
>> +  co_yield 42;
>> +  int x = co_await A{};
>> +}
>> +
>> +template 
>> +coro_t g(int n) {
>> +  if (n == 0)
>> +co_return;
>> +  co_yield 42;
>> +  int x = co_await Await{};
>> +}
>> +
>> +int main() {
>> +  f(0);
>> +  g(0);
>> +}
>> Index: test/SemaCXX/coreturn.cpp
>> ===
>> --- test/SemaCXX/coreturn.cpp
>> +++ test/SemaCXX/coreturn.cpp
>> @@ -1,4 +1,4 @@
>> -// RUN: %clang_cc1 -triple x86_64-apple-darwin9 %s -std=c++14
>> -fcoroutines-ts -fsyntax-only -Wignored-qualifiers -Wno-error=return-type
>> -verify -fblocks -Wno-unreachable-code -Wno-unused-value
>> +// RUN: %clang_cc1 -triple x86_64-apple-darwin9 %s -std=c++14
>> -fcoroutines-ts -fsyntax-only -Wignored-qualifiers -Wno-error=return-type
>> -verify -fblocks -Wall -Wextra -Wno-error=unreachable-code
>>  #include "Inputs/std-coroutine.h"
>>
>>  using std::experimental::suspend_always;
>> Index: lib/Sema/SemaCoroutine.cpp
>> ===
>> --- lib/Sema/SemaCoroutine.cpp
>> +++ lib/Sema/SemaCoroutine.cpp
>> @@ -437,6 +437,7 @@
>>if (VD->isInvalidDecl())
>>  return nullptr;
>>ActOnUninitializedDecl(VD);
>> +  FD->addDecl(VD);
>>assert(!VD->isInvalidDecl());
>>return VD;
>>  }
>>
>>
>> ___
>> cfe-commits mailing list
>> cfe-commits@lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r304879 - [clang-tidy] Make misc-inaccurate-erase work with real C++11 containers.

2017-06-07 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Wed Jun  7 03:25:51 2017
New Revision: 304879

URL: http://llvm.org/viewvc/llvm-project?rev=304879&view=rev
Log:
[clang-tidy] Make misc-inaccurate-erase work with real C++11 containers.

The check failed to match iterator->const_iterator conversion that is happening
at least when using the libstdc++'s vector. We might want to make it match even
more flexible patterns, if we see more false negatives.

Modified:
clang-tools-extra/trunk/clang-tidy/misc/InaccurateEraseCheck.cpp
clang-tools-extra/trunk/test/clang-tidy/misc-inaccurate-erase.cpp

Modified: clang-tools-extra/trunk/clang-tidy/misc/InaccurateEraseCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/InaccurateEraseCheck.cpp?rev=304879&r1=304878&r2=304879&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/misc/InaccurateEraseCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/misc/InaccurateEraseCheck.cpp Wed Jun  7 
03:25:51 2017
@@ -28,38 +28,40 @@ void InaccurateEraseCheck::registerMatch
   if (!getLangOpts().CPlusPlus)
 return;
 
-  const auto CheckForEndCall = hasArgument(
-  1, anyOf(cxxConstructExpr(has(ignoringParenImpCasts(
-   cxxMemberCallExpr(callee(cxxMethodDecl(hasName("end"
-   .bind("InaccEndCall",
-   anything()));
+  const auto EndCall =
+  callExpr(
+  callee(functionDecl(hasAnyName("remove", "remove_if", "unique"))),
+  hasArgument(
+  1,
+  anyOf(cxxConstructExpr(has(ignoringImplicit(
+
cxxMemberCallExpr(callee(cxxMethodDecl(hasName("end"
+.bind("end",
+anything(
+  .bind("alg");
 
   const auto DeclInStd = decl(isInStdNamespace());
   Finder->addMatcher(
   cxxMemberCallExpr(
   on(anyOf(hasType(DeclInStd), hasType(pointsTo(DeclInStd,
   callee(cxxMethodDecl(hasName("erase"))), argumentCountIs(1),
-  hasArgument(0, has(ignoringParenImpCasts(
- callExpr(callee(functionDecl(hasAnyName(
-  "remove", "remove_if", "unique"))),
-  CheckForEndCall)
- .bind("InaccAlgCall",
+  hasArgument(0, has(ignoringImplicit(
+ anyOf(EndCall, has(ignoringImplicit(EndCall)),
   unless(isInTemplateInstantiation()))
-  .bind("InaccErase"),
+  .bind("erase"),
   this);
 }
 
 void InaccurateEraseCheck::check(const MatchFinder::MatchResult &Result) {
   const auto *MemberCall =
-  Result.Nodes.getNodeAs("InaccErase");
+  Result.Nodes.getNodeAs("erase");
   const auto *EndExpr =
-  Result.Nodes.getNodeAs("InaccEndCall");
+  Result.Nodes.getNodeAs("end");
   const SourceLocation Loc = MemberCall->getLocStart();
 
   FixItHint Hint;
 
   if (!Loc.isMacroID() && EndExpr) {
-const auto *AlgCall = Result.Nodes.getNodeAs("InaccAlgCall");
+const auto *AlgCall = Result.Nodes.getNodeAs("alg");
 std::string ReplacementText = Lexer::getSourceText(
 CharSourceRange::getTokenRange(EndExpr->getSourceRange()),
 *Result.SourceManager, getLangOpts());

Modified: clang-tools-extra/trunk/test/clang-tidy/misc-inaccurate-erase.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/misc-inaccurate-erase.cpp?rev=304879&r1=304878&r2=304879&view=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/misc-inaccurate-erase.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/misc-inaccurate-erase.cpp Wed Jun  
7 03:25:51 2017
@@ -2,12 +2,15 @@
 
 namespace std {
 template  struct vec_iterator {
-  T *ptr;
+  T ptr;
   vec_iterator operator++(int);
+
+  template 
+  vec_iterator(const vec_iterator &); // Omit enable_if<...>.
 };
 
 template  struct vector {
-  typedef vec_iterator iterator;
+  typedef vec_iterator iterator;
 
   iterator begin();
   iterator end();
@@ -16,6 +19,17 @@ template  struct vector {
   void erase(iterator, iterator);
 };
 
+template  struct vector_with_const_iterator {
+  typedef vec_iterator iterator;
+  typedef vec_iterator const_iterator;
+
+  iterator begin();
+  iterator end();
+
+  void erase(const_iterator);
+  void erase(const_iterator, const_iterator);
+};
+
 template 
 FwIt remove(FwIt begin, FwIt end, const T &val);
 
@@ -61,6 +75,10 @@ int main() {
   // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: this call will remove at most one
   // CHECK-FIXES: {{^  }}p->erase(remove(p->begin(), p->end(), 11), 
p->end());{{$}}
 
+  std::vector_with_const_iterator v2;
+  v2.erase(remove(v2.begin(), v2.end(), 12));
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: this call will remove at most one
+  // CHECK-FIXES: {{^  }}v2.erase(re

[PATCH] D32745: Correct debug info bit offset calculation for big-endian targets

2017-06-07 Thread Frej Drejhammar via Phabricator via cfe-commits
frej added a comment.

Ping, I don't have have commit permissions, so I am at the mercy of others for 
getting this fix committed...


https://reviews.llvm.org/D32745



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


[PATCH] D20693: [clang-tidy] New checker to replace dynamic exception specifications

2017-06-07 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added a comment.

In https://reviews.llvm.org/D20693#774693, @hintonda wrote:

> In order to fix diagnostic corruption in some of the buildbot tests
>  (unable to reproduce locally):
>
> - make NoexceptMacro a static variable so it's lifetime doesn't end when 
> UseNoexceptCheck is destroyed.
> - pass a const char* instead of a StringRef to DiagnosticBuilder so it won't 
> create a temporary std::string and cache the address of the temporary char * 
> it owns.


That's pretty hacky, even if this fixes the immediate issue (which I'm somewhat 
skeptical about). Do you have failure logs saved somewhere, by chance? If not, 
I'd suggest to resubmit the original patch (without these two hacks) and grab 
the fresh failure logs. Another suggestion is to run the tests with asan (and 
maybe with msan) to see, whether the issue can be detected by the sanitizers.


https://reviews.llvm.org/D20693



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


[PATCH] D20693: [clang-tidy] New checker to replace dynamic exception specifications

2017-06-07 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh requested changes to this revision.
alexfh added a comment.
This revision now requires changes to proceed.

In any case, I'm strongly against these hacks, please revert them.


https://reviews.llvm.org/D20693



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


r304880 - [Driver] Add test to cover case when LSan is not supported

2017-06-07 Thread Maxim Ostapenko via cfe-commits
Author: chefmax
Date: Wed Jun  7 03:51:15 2017
New Revision: 304880

URL: http://llvm.org/viewvc/llvm-project?rev=304880&view=rev
Log:
[Driver] Add test to cover case when LSan is not supported

This commit adds a testcase for uncovered code paths in LSan options parsing 
logic in driver.

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

Modified:
cfe/trunk/test/Driver/fsanitize.c

Modified: cfe/trunk/test/Driver/fsanitize.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/fsanitize.c?rev=304880&r1=304879&r2=304880&view=diff
==
--- cfe/trunk/test/Driver/fsanitize.c (original)
+++ cfe/trunk/test/Driver/fsanitize.c Wed Jun  7 03:51:15 2017
@@ -271,6 +271,12 @@
 // RUN: %clang -target thumbeb-linux -fsanitize=address,leak 
-fno-sanitize=address %s -### 2>&1 | FileCheck %s 
--check-prefix=CHECK-SANA-SANL-NO-SANA-THUMBEB
 // CHECK-SANA-SANL-NO-SANA-THUMBEB: "-fsanitize=leak"
 
+// RUN: %clang -target mips-unknown-linux -fsanitize=leak %s -### 2>&1 | 
FileCheck %s --check-prefix=CHECK-SANL-MIPS
+// CHECK-SANL-MIPS: unsupported option '-fsanitize=leak' for target 
'mips-unknown-linux'
+
+// RUN: %clang -target powerpc-unknown-linux -fsanitize=leak %s -### 2>&1 | 
FileCheck %s --check-prefix=CHECK-SANL-PPC
+// CHECK-SANL-PPC: unsupported option '-fsanitize=leak' for target 
'powerpc-unknown-linux'
+
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=memory %s -### 2>&1 | 
FileCheck %s --check-prefix=CHECK-MSAN
 // CHECK-MSAN: "-fno-assume-sane-operator-new"
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=address %s -### 2>&1 | 
FileCheck %s --check-prefix=CHECK-ASAN


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


[PATCH] D33941: [Driver] Add test to cover case when LSan is not supported

2017-06-07 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL304880: [Driver] Add test to cover case when LSan is not 
supported (authored by chefmax).

Changed prior to commit:
  https://reviews.llvm.org/D33941?vs=101557&id=101672#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D33941

Files:
  cfe/trunk/test/Driver/fsanitize.c


Index: cfe/trunk/test/Driver/fsanitize.c
===
--- cfe/trunk/test/Driver/fsanitize.c
+++ cfe/trunk/test/Driver/fsanitize.c
@@ -271,6 +271,12 @@
 // RUN: %clang -target thumbeb-linux -fsanitize=address,leak 
-fno-sanitize=address %s -### 2>&1 | FileCheck %s 
--check-prefix=CHECK-SANA-SANL-NO-SANA-THUMBEB
 // CHECK-SANA-SANL-NO-SANA-THUMBEB: "-fsanitize=leak"
 
+// RUN: %clang -target mips-unknown-linux -fsanitize=leak %s -### 2>&1 | 
FileCheck %s --check-prefix=CHECK-SANL-MIPS
+// CHECK-SANL-MIPS: unsupported option '-fsanitize=leak' for target 
'mips-unknown-linux'
+
+// RUN: %clang -target powerpc-unknown-linux -fsanitize=leak %s -### 2>&1 | 
FileCheck %s --check-prefix=CHECK-SANL-PPC
+// CHECK-SANL-PPC: unsupported option '-fsanitize=leak' for target 
'powerpc-unknown-linux'
+
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=memory %s -### 2>&1 | 
FileCheck %s --check-prefix=CHECK-MSAN
 // CHECK-MSAN: "-fno-assume-sane-operator-new"
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=address %s -### 2>&1 | 
FileCheck %s --check-prefix=CHECK-ASAN


Index: cfe/trunk/test/Driver/fsanitize.c
===
--- cfe/trunk/test/Driver/fsanitize.c
+++ cfe/trunk/test/Driver/fsanitize.c
@@ -271,6 +271,12 @@
 // RUN: %clang -target thumbeb-linux -fsanitize=address,leak -fno-sanitize=address %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SANA-SANL-NO-SANA-THUMBEB
 // CHECK-SANA-SANL-NO-SANA-THUMBEB: "-fsanitize=leak"
 
+// RUN: %clang -target mips-unknown-linux -fsanitize=leak %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SANL-MIPS
+// CHECK-SANL-MIPS: unsupported option '-fsanitize=leak' for target 'mips-unknown-linux'
+
+// RUN: %clang -target powerpc-unknown-linux -fsanitize=leak %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SANL-PPC
+// CHECK-SANL-PPC: unsupported option '-fsanitize=leak' for target 'powerpc-unknown-linux'
+
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=memory %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-MSAN
 // CHECK-MSAN: "-fno-assume-sane-operator-new"
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=address %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-ASAN
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] r304883 - Fix test with exceptions disabled

2017-06-07 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Wed Jun  7 04:06:05 2017
New Revision: 304883

URL: http://llvm.org/viewvc/llvm-project?rev=304883&view=rev
Log:
Fix test with exceptions disabled

Modified:

libcxx/trunk/test/std/utilities/variant/variant.variant/variant.assign/copy.pass.cpp

Modified: 
libcxx/trunk/test/std/utilities/variant/variant.variant/variant.assign/copy.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/variant/variant.variant/variant.assign/copy.pass.cpp?rev=304883&r1=304882&r2=304883&view=diff
==
--- 
libcxx/trunk/test/std/utilities/variant/variant.variant/variant.assign/copy.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/utilities/variant/variant.variant/variant.assign/copy.pass.cpp
 Wed Jun  7 04:06:05 2017
@@ -107,35 +107,6 @@ struct CopyDoesThrow {
   CopyDoesThrow &operator=(const CopyDoesThrow &) noexcept(false);
 };
 
-#ifndef TEST_HAS_NO_EXCEPTIONS
-struct CopyThrows {
-  CopyThrows() = default;
-  CopyThrows(const CopyThrows &) { throw 42; }
-  CopyThrows &operator=(const CopyThrows &) { throw 42; }
-};
-
-struct CopyCannotThrow {
-  static int alive;
-  CopyCannotThrow() { ++alive; }
-  CopyCannotThrow(const CopyCannotThrow &) noexcept { ++alive; }
-  CopyCannotThrow(CopyCannotThrow &&) noexcept { assert(false); }
-  CopyCannotThrow &operator=(const CopyCannotThrow &) noexcept = default;
-  CopyCannotThrow &operator=(CopyCannotThrow &&) noexcept { assert(false); 
return *this; }
-};
-
-int CopyCannotThrow::alive = 0;
-
-struct MoveThrows {
-  static int alive;
-  MoveThrows() { ++alive; }
-  MoveThrows(const MoveThrows &) { ++alive; }
-  MoveThrows(MoveThrows &&) { throw 42; }
-  MoveThrows &operator=(const MoveThrows &) { return *this; }
-  MoveThrows &operator=(MoveThrows &&) { throw 42; }
-  ~MoveThrows() { --alive; }
-};
-
-int MoveThrows::alive = 0;
 
 struct NTCopyAssign {
   constexpr NTCopyAssign(int v) : value(v) {}
@@ -178,6 +149,36 @@ struct TCopyAssignNTMoveAssign {
 
 static_assert(std::is_trivially_copy_assignable_v, 
"");
 
+#ifndef TEST_HAS_NO_EXCEPTIONS
+struct CopyThrows {
+  CopyThrows() = default;
+  CopyThrows(const CopyThrows &) { throw 42; }
+  CopyThrows &operator=(const CopyThrows &) { throw 42; }
+};
+
+struct CopyCannotThrow {
+  static int alive;
+  CopyCannotThrow() { ++alive; }
+  CopyCannotThrow(const CopyCannotThrow &) noexcept { ++alive; }
+  CopyCannotThrow(CopyCannotThrow &&) noexcept { assert(false); }
+  CopyCannotThrow &operator=(const CopyCannotThrow &) noexcept = default;
+  CopyCannotThrow &operator=(CopyCannotThrow &&) noexcept { assert(false); 
return *this; }
+};
+
+int CopyCannotThrow::alive = 0;
+
+struct MoveThrows {
+  static int alive;
+  MoveThrows() { ++alive; }
+  MoveThrows(const MoveThrows &) { ++alive; }
+  MoveThrows(MoveThrows &&) { throw 42; }
+  MoveThrows &operator=(const MoveThrows &) { return *this; }
+  MoveThrows &operator=(MoveThrows &&) { throw 42; }
+  ~MoveThrows() { --alive; }
+};
+
+int MoveThrows::alive = 0;
+
 struct MakeEmptyT {
   static int alive;
   MakeEmptyT() { ++alive; }


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


[PATCH] D31972: Do not force the frame pointer by default for ARM EABI

2017-06-07 Thread Christian Bruel via Phabricator via cfe-commits
chrib added a comment.

OK, I have created a RFE tracker (BZ #32501). I will forward to cfe-dev.

Regarding the need to avoid table-based unwinding, the way to handle those 
request for an explicit frame pointer when not required by the ABI is to use 
-fno-omit-frame-pointer flag, catching up with the GCC behavior.

Also I'm not sure that the unwind table space is such an issue (for debugging) 
since they are not loadable. Other uses such as profiling is not be impacted by 
the change, and exceptions unwinder likelibgcc or libunwind should work without 
the frame pointer

I'll amend the patch to check for Darwin and Netbsd.


https://reviews.llvm.org/D31972



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


[PATCH] D31972: Do not force the frame pointer by default for ARM EABI

2017-06-07 Thread Christian Bruel via Phabricator via cfe-commits
chrib updated this revision to Diff 101675.
chrib added a comment.

- do not omit the frame pointer for netbsd-eabi and darwin-eabi


https://reviews.llvm.org/D31972

Files:
  lib/Driver/ToolChains/Clang.cpp
  test/Driver/frame-pointer.c


Index: test/Driver/frame-pointer.c
===
--- test/Driver/frame-pointer.c
+++ test/Driver/frame-pointer.c
@@ -33,6 +33,9 @@
 // RUN: %clang -target mips64el-linux-gnu -### -S -O0 %s -o %t.s 2>&1 | 
FileCheck -check-prefix=CHECK0-32 %s
 // RUN: %clang -target mips64el-linux-gnu -### -S -O1 %s -o %t.s 2>&1 | 
FileCheck -check-prefix=CHECK1-32 %s
 
+// RUN: %clang -target arm-none-eabi -### -S -O0 %s -o %t.s 2>&1 | FileCheck 
-check-prefix=CHECK0-32 %s
+// RUN: %clang -target arm-none-eabi -### -S -O1 %s -o %t.s 2>&1 | FileCheck 
-check-prefix=CHECK1-32 %s
+
 // CHECK0-32: -mdisable-fp-elim
 // CHECK1-32-NOT: -mdisable-fp-elim
 // CHECK2-32-NOT: -mdisable-fp-elim
Index: lib/Driver/ToolChains/Clang.cpp
===
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/ToolChains/Clang.cpp
@@ -566,6 +566,19 @@
 }
   }
 
+  if (!Triple.isOSDarwin() && !Triple.isOSNetBSD() &&
+  (Triple.getEnvironment() == llvm::Triple::EABI ||
+   Triple.getEnvironment() == llvm::Triple::EABIHF)) {
+// Don't use a frame pointer on AAPCS when optimizing.
+switch (Triple.getArch()) {
+case llvm::Triple::arm:
+case llvm::Triple::thumb:
+  return !areOptimizationsEnabled(Args);
+default:
+  return true;
+}
+  }
+
   return true;
 }
 


Index: test/Driver/frame-pointer.c
===
--- test/Driver/frame-pointer.c
+++ test/Driver/frame-pointer.c
@@ -33,6 +33,9 @@
 // RUN: %clang -target mips64el-linux-gnu -### -S -O0 %s -o %t.s 2>&1 | FileCheck -check-prefix=CHECK0-32 %s
 // RUN: %clang -target mips64el-linux-gnu -### -S -O1 %s -o %t.s 2>&1 | FileCheck -check-prefix=CHECK1-32 %s
 
+// RUN: %clang -target arm-none-eabi -### -S -O0 %s -o %t.s 2>&1 | FileCheck -check-prefix=CHECK0-32 %s
+// RUN: %clang -target arm-none-eabi -### -S -O1 %s -o %t.s 2>&1 | FileCheck -check-prefix=CHECK1-32 %s
+
 // CHECK0-32: -mdisable-fp-elim
 // CHECK1-32-NOT: -mdisable-fp-elim
 // CHECK2-32-NOT: -mdisable-fp-elim
Index: lib/Driver/ToolChains/Clang.cpp
===
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/ToolChains/Clang.cpp
@@ -566,6 +566,19 @@
 }
   }
 
+  if (!Triple.isOSDarwin() && !Triple.isOSNetBSD() &&
+  (Triple.getEnvironment() == llvm::Triple::EABI ||
+   Triple.getEnvironment() == llvm::Triple::EABIHF)) {
+// Don't use a frame pointer on AAPCS when optimizing.
+switch (Triple.getArch()) {
+case llvm::Triple::arm:
+case llvm::Triple::thumb:
+  return !areOptimizationsEnabled(Args);
+default:
+  return true;
+}
+  }
+
   return true;
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r304889 - [ARM] Fix Neon vector type alignment to 64-bit

2017-06-07 Thread Javed Absar via cfe-commits
Author: javed.absar
Date: Wed Jun  7 05:02:02 2017
New Revision: 304889

URL: http://llvm.org/viewvc/llvm-project?rev=304889&view=rev
Log:
[ARM] Fix Neon vector type alignment to 64-bit

This is restricted version of patch - https://reviews.llvm.org/D33205
that I reverted as it was leading to ABI breaks on darwin etc.
This patch restricts the fix to AAPCS (Android remains 128-bit).
Reviewed by: Renato Golin, Stephen Hines
Differential Revision: https://reviews.llvm.org/D33786


Added:
cfe/trunk/test/CodeGen/neon-aapcs-align.c
Modified:
cfe/trunk/lib/Basic/Targets.cpp

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=304889&r1=304888&r2=304889&view=diff
==
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Wed Jun  7 05:02:02 2017
@@ -5385,6 +5385,10 @@ public:
 // ARM has atomics up to 8 bytes
 setAtomic();
 
+// Maximum alignment for ARM NEON data types should be 64-bits (AAPCS)
+if (IsAAPCS && (Triple.getEnvironment() != llvm::Triple::Android))
+   MaxVectorAlign = 64;
+
 // Do force alignment of members that follow zero length bitfields.  If
 // the alignment of the zero-length bitfield is greater than the member
 // that follows it, `bar', `bar' will be aligned as the  type of the

Added: cfe/trunk/test/CodeGen/neon-aapcs-align.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/neon-aapcs-align.c?rev=304889&view=auto
==
--- cfe/trunk/test/CodeGen/neon-aapcs-align.c (added)
+++ cfe/trunk/test/CodeGen/neon-aapcs-align.c Wed Jun  7 05:02:02 2017
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -triple armv7a-none-eabi -target-feature +neon -emit-llvm 
-o - %s | FileCheck %s -check-prefix=CHECK -check-prefix=AAPCS
+// RUN: %clang_cc1 -triple armv7a-none-gnueabi -target-feature +neon 
-emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK -check-prefix=AAPCS
+// RUN: %clang_cc1 -triple armv7a-none-freebsd -target-feature +neon 
-emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK -check-prefix=AAPCS
+
+// RUN: %clang_cc1 -triple armv7a-apple-ios -target-feature +neon -emit-llvm 
-o - %s | FileCheck %s -check-prefix=CHECK -check-prefix=DEFAULT
+// RUN: %clang_cc1 -triple armv7a-none-android -target-feature +neon 
-emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK -check-prefix=DEFAULT
+// RUN: %clang_cc1 -triple armv7a-none-androideabi -target-feature +neon 
-emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK -check-prefix=DEFAULT
+
+#include 
+// Neon types have 64-bit alignment
+int32x4_t gl_b;
+void t3(int32x4_t *src) {
+// CHECK: @t3
+  gl_b = *src;
+// AAPCS: store <4 x i32> {{%.*}}, <4 x i32>* @gl_b, align 8
+// DEFAULT: store <4 x i32> {{%.*}}, <4 x i32>* @gl_b, align 16
+}


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


[libcxx] r304891 - Implement LWG 2904.

2017-06-07 Thread Michael Park via cfe-commits
Author: mpark
Date: Wed Jun  7 05:22:43 2017
New Revision: 304891

URL: http://llvm.org/viewvc/llvm-project?rev=304891&view=rev
Log:
Implement LWG 2904.

Summary:
- Removed the move-constructibe requirement from copy-assignable.
- Updated `__assign_alt` such that we direct initialize if
  `_Tp` can be `nothrow`-constructible from `_Arg`, or `_Tp`'s
  move construction can throw. Otherwise, construct a temporary and move it.
- Updated the tests to remove the pre-LWG2904 path.

Depends on D32671.

Reviewers: EricWF, CaseyCarter

Reviewed By: EricWF

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

Modified:
libcxx/trunk/include/variant

libcxx/trunk/test/std/utilities/variant/variant.variant/variant.assign/T.pass.cpp

libcxx/trunk/test/std/utilities/variant/variant.variant/variant.assign/copy.pass.cpp

libcxx/trunk/test/std/utilities/variant/variant.variant/variant.assign/move.pass.cpp

Modified: libcxx/trunk/include/variant
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/variant?rev=304891&r1=304890&r2=304891&view=diff
==
--- libcxx/trunk/include/variant (original)
+++ libcxx/trunk/include/variant Wed Jun  7 05:22:43 2017
@@ -358,7 +358,6 @@ struct __traits {
 
   static constexpr _Trait __copy_assignable_trait = __common_trait(
   {__copy_constructible_trait,
-   __move_constructible_trait,
__trait<_Types, is_trivially_copy_assignable, is_copy_assignable>...});
 
   static constexpr _Trait __move_assignable_trait = __common_trait(
@@ -877,25 +876,24 @@ public:
   }
 
 protected:
-  template 
+  template 
   inline _LIBCPP_INLINE_VISIBILITY
-  void __assign_alt(__alt<_Ip, _Tp>& __a,
-_Arg&& __arg,
-bool_constant<_CopyAssign> __tag) {
+  void __assign_alt(__alt<_Ip, _Tp>& __a, _Arg&& __arg) {
 if (this->index() == _Ip) {
   __a.__value = _VSTD::forward<_Arg>(__arg);
 } else {
   struct {
 void operator()(true_type) const {
-  __this->__emplace<_Ip>(_Tp(_VSTD::forward<_Arg>(__arg)));
+  __this->__emplace<_Ip>(_VSTD::forward<_Arg>(__arg));
 }
 void operator()(false_type) const {
-  __this->__emplace<_Ip>(_VSTD::forward<_Arg>(__arg));
+  __this->__emplace<_Ip>(_Tp(_VSTD::forward<_Arg>(__arg)));
 }
 __assignment* __this;
 _Arg&& __arg;
   } __impl{this, _VSTD::forward<_Arg>(__arg)};
-  __impl(__tag);
+  __impl(bool_constant ||
+   !is_nothrow_move_constructible_v<_Tp>>{});
 }
   }
 
@@ -912,8 +910,7 @@ protected:
   [this](auto& __this_alt, auto&& __that_alt) {
 this->__assign_alt(
 __this_alt,
-_VSTD::forward(__that_alt).__value,
-is_lvalue_reference<_That>{});
+_VSTD::forward(__that_alt).__value);
   },
   *this, _VSTD::forward<_That>(__that));
 }
@@ -1013,8 +1010,7 @@ public:
   inline _LIBCPP_INLINE_VISIBILITY
   void __assign(_Arg&& __arg) {
 this->__assign_alt(__access::__base::__get_alt<_Ip>(*this),
-   _VSTD::forward<_Arg>(__arg),
-   false_type{});
+   _VSTD::forward<_Arg>(__arg));
   }
 
   inline _LIBCPP_INLINE_VISIBILITY
@@ -1088,7 +1084,6 @@ class _LIBCPP_TEMPLATE_VIS variant
   __all...>::value>,
   private __sfinae_assign_base<
   __all<(is_copy_constructible_v<_Types> &&
- is_move_constructible_v<_Types> &&
  is_copy_assignable_v<_Types>)...>::value,
   __all<(is_move_constructible_v<_Types> &&
  is_move_assignable_v<_Types>)...>::value> {

Modified: 
libcxx/trunk/test/std/utilities/variant/variant.variant/variant.assign/T.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/variant/variant.variant/variant.assign/T.pass.cpp?rev=304891&r1=304890&r2=304891&view=diff
==
--- 
libcxx/trunk/test/std/utilities/variant/variant.variant/variant.assign/T.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/utilities/variant/variant.variant/variant.assign/T.pass.cpp
 Wed Jun  7 05:22:43 2017
@@ -199,12 +199,8 @@ void test_T_assignment_performs_construc
   assert(false);
 } catch (...) { /* ... */
 }
-#ifdef _LIBCPP_VERSION // LWG2904
-assert(v.valueless_by_exception());
-#else // _LIBCPP_VERSION
 assert(v.index() == 0);
 assert(std::get<0>(v) == "hello");
-#endif // _LIBCPP_VERSION
   }
   {
 using V = std::variant;
@@ -213,28 +209,6 @@ void test_T_assignment_performs_construc
 assert(v.index() == 0);
 assert(std::get<0>(v).value == 42);
   }
-#ifdef _LIBCPP_VERSION // LWG2904
-  {
-// Test that nothrow direct construction is preferred to nothrow move.
-using V = std::variant;
-V v(std::in_place_type, "hello");
-v = 42

r304892 - [Sema] Silence unused variable warning.

2017-06-07 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Wed Jun  7 05:23:17 2017
New Revision: 304892

URL: http://llvm.org/viewvc/llvm-project?rev=304892&view=rev
Log:
[Sema] Silence unused variable warning.

Modified:
cfe/trunk/lib/Sema/SemaExpr.cpp

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=304892&r1=304891&r2=304892&view=diff
==
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Wed Jun  7 05:23:17 2017
@@ -11843,7 +11843,7 @@ ExprResult Sema::BuildBinOp(Scope *S, So
   std::any_of(OE->decls_begin(), OE->decls_end(), [](NamedDecl *ND) {
 return isa(ND);
   })) {
-if (auto *Q = OE->getQualifier()) {
+if (OE->getQualifier()) {
   Diag(OE->getQualifierLoc().getBeginLoc(),
diag::err_template_kw_missing)
 << OE->getName().getAsString() << "";


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


[libcxx] r304893 - Mark LWG 2904 as complete.

2017-06-07 Thread Michael Park via cfe-commits
Author: mpark
Date: Wed Jun  7 05:27:17 2017
New Revision: 304893

URL: http://llvm.org/viewvc/llvm-project?rev=304893&view=rev
Log:
Mark LWG 2904 as complete.

Modified:
libcxx/trunk/www/cxx1z_status.html

Modified: libcxx/trunk/www/cxx1z_status.html
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/www/cxx1z_status.html?rev=304893&r1=304892&r2=304893&view=diff
==
--- libcxx/trunk/www/cxx1z_status.html (original)
+++ libcxx/trunk/www/cxx1z_status.html Wed Jun  7 05:27:17 2017
@@ -46,7 +46,7 @@
 SG1 - Study group #1 (Concurrency working group)
   
   
-  
+
   Paper Status
   
Paper #GroupPaper 
NameMeetingStatusFirst released version
@@ -477,7 +477,7 @@
http://wg21.link/LWG2890";>2890The 
definition of 'object state' applies only to class 
typesKonaComplete
http://wg21.link/LWG2900";>2900The copy 
and move constructors of optional are not 
constexprKonaComplete
http://wg21.link/LWG2903";>2903The form of 
initialization for the emplace-constructors is not 
specifiedKona
-   http://wg21.link/LWG2904";>2904Make 
variant move-assignment more exception safeKona
+   http://wg21.link/LWG2904";>2904Make 
variant move-assignment more exception 
safeKonaComplete
http://wg21.link/LWG2905";>2905is_constructible_v, P, D const &> should be false when D is not copy 
constructibleKonaComplete
http://wg21.link/LWG2908";>2908The 
less-than operator for shared pointers could do 
moreKona
http://wg21.link/LWG2911";>2911An 
is_aggregate type trait is neededKonaComplete


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


[PATCH] D33448: [CodeGen] Add thumb-mode to target-features for arm/thumb triples.

2017-06-07 Thread Florian Hahn via Phabricator via cfe-commits
fhahn updated this revision to Diff 101687.
fhahn added a comment.

rebased


https://reviews.llvm.org/D33448

Files:
  lib/Basic/Targets.cpp
  test/CodeGen/arm-long-calls.c
  test/CodeGen/arm-no-movt.c
  test/CodeGen/arm-target-features.c
  test/CodeGen/arm-thumb-mode-target-feature.c

Index: test/CodeGen/arm-thumb-mode-target-feature.c
===
--- /dev/null
+++ test/CodeGen/arm-thumb-mode-target-feature.c
@@ -0,0 +1,33 @@
+// REQUIRES: arm-registered-target
+
+// RUN: %clang_cc1 -triple thumbv7-linux-gnueabihf -emit-llvm -o - %s | FileCheck --check-prefix THUMB %s
+// RUN: %clang_cc1 -triple thumbv7eb-linux-gnueabihf -emit-llvm -o - %s | FileCheck --check-prefix THUMB %s
+// RUN: %clang -target armv7-linux-gnueabihf -mthumb -S -emit-llvm -o - %s | FileCheck --check-prefix THUMB-CLANG %s
+// RUN: %clang_cc1 -triple armv7-linux-gnueabihf -emit-llvm -o - %s | FileCheck --check-prefix ARM %s
+// RUN: %clang_cc1 -triple armv7eb-linux-gnueabihf -emit-llvm -o - %s | FileCheck --check-prefix ARM %s
+
+void t1() {}
+
+ __attribute__((target("no-thumb-mode")))
+void t2() {}
+
+ __attribute__((target("thumb-mode")))
+void t3() {}
+
+// THUMB: void @t1() [[ThumbAttr:#[0-7]]]
+// THUMB: void @t2() [[NoThumbAttr:#[0-7]]]
+// THUMB: void @t3() [[ThumbAttr:#[0-7]]]
+// THUMB: attributes [[ThumbAttr]] = { {{.*}} "target-features"="+thumb-mode"
+// THUMB: attributes [[NoThumbAttr]] = { {{.*}} "target-features"="-thumb-mode"
+//
+// THUMB-CLANG: void @t1() [[ThumbAttr:#[0-7]]]
+// THUMB-CLANG: void @t2() [[NoThumbAttr:#[0-7]]]
+// THUMB-CLANG: void @t3() [[ThumbAttr:#[0-7]]]
+// THUMB-CLANG: attributes [[ThumbAttr]] = { {{.*}} "target-features"="{{.*}}+thumb-mode
+// THUMB-CLANG: attributes [[NoThumbAttr]] = { {{.*}} "target-features"="{{.*}}-thumb-mode
+
+// ARM: void @t1() [[NoThumbAtr:#[0-7]]]
+// ARM: void @t2() [[NoThumbAttr:#[0-7]]]
+// ARM: void @t3() [[ThumbAttr:#[0-7]]]
+// ARM: attributes [[NoThumbAttr]] = { {{.*}} "target-features"="-thumb-mode"
+// ARM: attributes [[ThumbAttr]] = { {{.*}} "target-features"="+thumb-mode"
Index: test/CodeGen/arm-target-features.c
===
--- test/CodeGen/arm-target-features.c
+++ test/CodeGen/arm-target-features.c
@@ -1,65 +1,63 @@
 // REQUIRES: arm-registered-target
 
 // RUN: %clang_cc1 -triple thumbv7-linux-gnueabihf -target-cpu cortex-a8 -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-VFP3
-// CHECK-VFP3: "target-features"="+dsp,+neon,+vfp3"
-
-
-// RUN: %clang_cc1 -triple thumbv7-linux-gnueabi -target-cpu cortex-a9 -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-VFP3-FP16
-// CHECK-VFP3-FP16: "target-features"="+dsp,+fp16,+neon,+vfp3"
+// CHECK-VFP3: "target-features"="+dsp,+neon,+thumb-mode
 
 
 // RUN: %clang_cc1 -triple thumbv7-linux-gnueabihf -target-cpu cortex-a5 -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-VFP4
-// CHECK-VFP4: "target-features"="+dsp,+neon,+vfp4"
+// CHECK-VFP4: "target-features"="+dsp,+neon,+thumb-mode,+vfp4"
 
 
 // RUN: %clang_cc1 -triple thumbv7-linux-gnueabihf -target-cpu cortex-a7 -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-VFP4-DIV
 // RUN: %clang_cc1 -triple thumbv7-linux-gnueabi -target-cpu cortex-a12 -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-VFP4-DIV
-// RUN: %clang_cc1 -triple armv7-linux-gnueabihf -target-cpu cortex-a15 -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-VFP4-DIV
-// RUN: %clang_cc1 -triple armv7-linux-gnueabihf -target-cpu cortex-a17 -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-VFP4-DIV
 // RUN: %clang_cc1 -triple thumbv7s-linux-gnueabi -target-cpu swift -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-VFP4-DIV
 // RUN: %clang_cc1 -triple thumbv7-linux-gnueabihf -target-cpu krait -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-VFP4-DIV
-// CHECK-VFP4-DIV: "target-features"="+dsp,+hwdiv,+hwdiv-arm,+neon,+vfp4"
+// CHECK-VFP4-DIV: "target-features"="+dsp,+hwdiv,+hwdiv-arm,+neon,+thumb-mode,+vfp4"
 
+// RUN: %clang_cc1 -triple armv7-linux-gnueabihf -target-cpu cortex-a15 -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-VFP4-DIV-ARM
+// RUN: %clang_cc1 -triple armv7-linux-gnueabihf -target-cpu cortex-a17 -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-VFP4-DIV-ARM
+// CHECK-VFP4-DIV-ARM: "target-features"="+dsp,+hwdiv,+hwdiv-arm,+neon,+vfp4,-thumb-mode"
 
 // RUN: %clang_cc1 -triple thumbv7s-apple-ios7.0 -target-cpu cyclone -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-BASIC-V8
 // RUN: %clang_cc1 -triple thumbv8-linux-gnueabihf -target-cpu cortex-a32 -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-BASIC-V8
 // RUN: %clang_cc1 -triple thumbv8-linux-gnueabihf -target-cpu cortex-a35 -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-BASIC-V8
-// RUN: %clang_cc1 -triple armv8-linux-gnueabi -target-cpu cortex-a53 -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-BASIC-V8
 // RUN: %clang_cc1 -triple thum

[PATCH] D33278: [LLVM][x86][Inline Asm] - Enum support for MS syntax

2017-06-07 Thread Matan via Phabricator via cfe-commits
mharoush updated this revision to Diff 101688.
mharoush marked an inline comment as done.
mharoush added a comment.

Simplified the AsmRewrite condition in x86AsmParser. Some fixes to simplify the 
Intel State Machine immediate value rewrite treatment divergence.


Repository:
  rL LLVM

https://reviews.llvm.org/D33278

Files:
  include/llvm/MC/MCParser/MCAsmParser.h
  lib/Target/X86/AsmParser/X86AsmParser.cpp

Index: lib/Target/X86/AsmParser/X86AsmParser.cpp
===
--- lib/Target/X86/AsmParser/X86AsmParser.cpp
+++ lib/Target/X86/AsmParser/X86AsmParser.cpp
@@ -713,12 +713,13 @@
   std::unique_ptr ParseIntelOffsetOfOperator();
   bool ParseIntelDotOperator(const MCExpr *Disp, const MCExpr *&NewDisp);
   unsigned IdentifyIntelOperator(StringRef Name);
-  unsigned ParseIntelOperator(unsigned OpKind);
+  unsigned ParseIntelOperator(unsigned OpKind, bool AddImmPrefix);
   std::unique_ptr
   ParseIntelSegmentOverride(unsigned SegReg, SMLoc Start, unsigned Size);
   std::unique_ptr ParseRoundingModeOp(SMLoc Start, SMLoc End);
   bool ParseIntelNamedOperator(StringRef Name, IntelExprStateMachine &SM);
-  bool ParseIntelExpression(IntelExprStateMachine &SM, SMLoc &End);
+  bool ParseIntelExpression(IntelExprStateMachine &SM, SMLoc &End,
+bool &ReplaceEnumIdentifier);
   std::unique_ptr
   ParseIntelBracExpression(unsigned SegReg, SMLoc Start, int64_t ImmDisp,
bool isSymbol, unsigned Size);
@@ -1187,7 +1188,7 @@
 InlineAsmIdentifierInfo &Info, bool AllowBetterSizeMatch) {
   // If we found a decl other than a VarDecl, then assume it is a FuncDecl or
   // some other label reference.
-  if (isa(Disp) && Info.OpDecl && !Info.IsVarDecl) {
+  if (isa(Disp) && Info.OpDecl && !Info.isVarDecl()) {
 // Insert an explicit size if the user didn't have one.
 if (!Size) {
   Size = getPointerWidth();
@@ -1306,8 +1307,9 @@
 return false;
   return true;
 }
-
-bool X86AsmParser::ParseIntelExpression(IntelExprStateMachine &SM, SMLoc &End) {
+bool X86AsmParser::ParseIntelExpression(IntelExprStateMachine &SM, SMLoc &End,
+bool &ReplaceEnumIdentifier) {
+  ReplaceEnumIdentifier = false;
   MCAsmParser &Parser = getParser();
   const AsmToken &Tok = Parser.getTok();
 
@@ -1358,7 +1360,7 @@
 if (OpKind == IOK_OFFSET) 
   return Error(IdentLoc, "Dealing OFFSET operator as part of"
 "a compound immediate expression is yet to be supported");
-int64_t Val = ParseIntelOperator(OpKind);
+int64_t Val = ParseIntelOperator(OpKind,SM.getAddImmPrefix());
 if (!Val)
   return true;
 StringRef ErrMsg;
@@ -1368,11 +1370,39 @@
 PrevTK == AsmToken::RBrac) {
   return false;
   } else {
-InlineAsmIdentifierInfo &Info = SM.getIdentifierInfo();
+InlineAsmIdentifierInfo Info;
 if (ParseIntelIdentifier(Val, Identifier, Info,
  /*Unevaluated=*/false, End))
   return true;
-SM.onIdentifierExpr(Val, Identifier);
+// Check if the parsed identifier was a constant Integer. Here we
+// assume Val is of type MCConstantExpr only when it is safe to replace
+// the identifier with its constant value.
+if (const MCConstantExpr *CE =
+dyn_cast_or_null(Val)) {
+  StringRef ErrMsg;
+  // SM should treat the value as it would an explicit integer in the 
+  // expression.
+  if(SM.onInteger(CE->getValue(), ErrMsg)) 
+return Error(IdentLoc, ErrMsg);
+  // In case we are called on a bracketed expression,
+  if (isParsingInlineAsm() && SM.getAddImmPrefix()) {
+// A single rewrite of the integer value is preformed for each enum
+// identifier. This is only done when we are inside a bracketed 
+// expression in order to match the behavior for the equivalent 
+// integer tokens.
+size_t Len = End.getPointer() - IdentLoc.getPointer();
+InstInfo->AsmRewrites->emplace_back(AOK_Imm, IdentLoc,Len,
+CE->getValue());
+break;
+  }
+  // Set force rewrite flag only when not bracketed expression.
+  ReplaceEnumIdentifier = true;
+} else {
+  // Notify the SM a variable identifier was found.
+  InlineAsmIdentifierInfo &SMInfo = SM.getIdentifierInfo();
+  	  SMInfo = Info;
+  SM.onIdentifierExpr(Val, Identifier);
+}
   }
   break;
 }
@@ -1452,7 +1482,8 @@
   // may have already parsed an immediate displacement before the bracketed
   // expression.
   IntelExprStateMachine SM(ImmDisp, /*StopOnLBrac=*/false, /*AddImmPrefix=*/true);
-  if (ParseIntelExpression(SM, End))
+  bool ReplaceEnumIdentifier;
+  if (ParseIntelExpression(SM, End, ReplaceEnum

[PATCH] D33278: [LLVM][x86][Inline Asm] - Enum support for MS syntax

2017-06-07 Thread Matan via Phabricator via cfe-commits
mharoush marked an inline comment as done.
mharoush added inline comments.



Comment at: lib/Target/X86/AsmParser/X86AsmParser.cpp:722
+  bool ParseIntelExpression(IntelExprStateMachine &SM, SMLoc &End, 
+bool &ReplaceEnumIdentifier);
   std::unique_ptr

rnk wrote:
> mharoush wrote:
> > rnk wrote:
> > > Please try to eliminate the need for this extra boolean out parameter.
> > This flag is used in case we try to compile something like mov edx, A+6 ( 
> > when A is defined as ConstantEnum ) the original condition (Line:1905) will 
> > skip the rewrite since we have an identifier as the first Token, however if 
> > we try to compile 6+A it will be rewritten as expected.
> > 
> > I tried to solve this in different ways, I got either the exact opposite 
> > (A+6 was replaced and 6+A wasn't) or a collision of rewrites when trying to 
> > preform other forms of replacements and leaving this section intact. 
> > 
> > I can perhaps change the way we handle general expressions to the same way 
> > we handle them under parseIntelBracExpression, meaning use the first 
> > iteration of X86AsmParser to reformat the string (write imm prefixes and 
> > replace identifiers when needed) then refactor the string to its canonical 
> > form on the second pass. 
> > 
> > In short this was the simplest solution that worked without regression, 
> > maybe you have a better idea?
> > 
> > If the issue is the method signature pollution I can move this flag into 
> > the SM class as a member to indicate a rewrite is needed, however since 
> > this flag and method are limited to this context alone, I am not sure if 
> > the overhead is wanted in such case . 
> I suspect there is a way to simplify the code so that this corner case no 
> longer exists. I don't really have time to dig through the test cases to come 
> up with it, but please make an effort.
I believe this should resolve the complex if statement, However I still need 
the boolean value to enforce the rewrite for enum identifiers.


Repository:
  rL LLVM

https://reviews.llvm.org/D33278



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


[PATCH] D33277: [Clang][x86][Inline Asm] - Enum support for MS syntax

2017-06-07 Thread Matan via Phabricator via cfe-commits
mharoush updated this revision to Diff 101689.

Repository:
  rL LLVM

https://reviews.llvm.org/D33277

Files:
  lib/Sema/SemaStmtAsm.cpp
  test/CodeGen/x86-ms-inline-asm-enum_feature.cpp

Index: lib/Sema/SemaStmtAsm.cpp
===
--- lib/Sema/SemaStmtAsm.cpp
+++ lib/Sema/SemaStmtAsm.cpp
@@ -644,8 +644,8 @@
   // Referring to parameters is not allowed in naked functions.
   if (CheckNakedParmReference(Result.get(), *this))
 return ExprError();
-
-  QualType T = Result.get()->getType();
+  Expr *Res = Result.get();
+  QualType T = Res->getType();
 
   if (T->isDependentType()) {
 return Result;
@@ -657,16 +657,26 @@
   }
 
   // Otherwise, it needs to be a complete type.
-  if (RequireCompleteExprType(Result.get(), diag::err_asm_incomplete_type)) {
+  if (RequireCompleteExprType(Res, diag::err_asm_incomplete_type)) {
 return ExprError();
   }
 
   fillInlineAsmTypeInfo(Context, T, Info);
 
   // We can work with the expression as long as it's not an r-value.
-  if (!Result.get()->isRValue())
-Info.IsVarDecl = true;
+  if (!Res->isRValue()) {
+Info.setKindVariable();
+return Result;
+  }
 
+  Expr::EvalResult EvlResult;
+  // Try to evaluate the identifier as enum constant, currently we do not allow
+  // other constant integers to be folded.
+  if (isa(T) &&
+Res->EvaluateAsRValue(EvlResult, getASTContext())) {
+Info.ConstIntValue = EvlResult.Val.getInt();
+Info.setKindConstEnum();
+  }
   return Result;
 }
 
@@ -773,7 +783,7 @@
   fillInlineAsmTypeInfo(Context, Result.get()->getType(), Info);
 
   // Fields are "variables" as far as inline assembly is concerned.
-  Info.IsVarDecl = true;
+  Info.setKindVariable();
 
   return Result;
 }
Index: test/CodeGen/x86-ms-inline-asm-enum_feature.cpp
===
--- test/CodeGen/x86-ms-inline-asm-enum_feature.cpp
+++ test/CodeGen/x86-ms-inline-asm-enum_feature.cpp
@@ -0,0 +1,46 @@
+// REQUIRES: x86-registered-target
+// RUN: %clang_cc1 %s -fasm-blocks -emit-llvm -o - | FileCHECK %s
+namespace x {
+enum { A = 12 };
+struct y_t {
+enum { A = 17 };
+	int r;
+}y;
+}
+
+void x86_enum_namespaces() {
+  enum { A = 1 };
+  // CHECK: mov eax, $$12
+  __asm mov eax, x::A
+  // CHECK: mov eax, $$17
+  __asm mov eax, x::y_t::A
+  __asm {mov eax, x::y.r}
+ // CHECK: mov eax, $$1
+  __asm {mov eax, A}
+}
+
+void x86_enum_arithmethic() {
+  enum { A = 1, B };
+  // CHECK: mov eax, $$21
+  __asm mov eax, (A + 9) * 2 + A
+  // CHECK: mov eax, $$4
+  __asm mov eax, A << 2
+  // CHECK: mov eax, $$2
+  __asm mov eax, B & 3
+  // CHECK: mov eax, $$5
+  __asm mov eax, 3 + (B & 3)
+  // CHECK: mov eax, $$8
+  __asm mov eax, 2 << A * B
+}
+
+void x86_enum_mem() {
+  int arr[4];
+  enum { A = 4, B };
+
+  // CHECK: mov eax, [($$12 + $$9) + $$4 * $$5 + $$3 + $$3 + eax]
+  __asm { mov eax, [(x::A + 9) + A * B + 3 + 3 + eax] }
+  // CHECK: mov eax, dword ptr $$4$0
+  __asm { mov eax, dword ptr [arr + A] }
+  // CHECK: mov eax, dword ptr $$8$0
+  __asm { mov eax, dword ptr A[arr + A] }
+}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D33981: Only print registered targets for `--version`

2017-06-07 Thread Dimitry Andric via Phabricator via cfe-commits
dim created this revision.

In https://reviews.llvm.org/D33900, I added printing of the registered targets 
in clang's
`PrintVersion` function, which is not only used for `--version` output,
but also for `-v` (verbose mode) and `-###`.  Especially the latter
seems to trip up some test cases, so it is probably better to only print
the registered targets for `--version`.


https://reviews.llvm.org/D33981

Files:
  lib/Driver/Driver.cpp


Index: lib/Driver/Driver.cpp
===
--- lib/Driver/Driver.cpp
+++ lib/Driver/Driver.cpp
@@ -1117,10 +1117,6 @@
 
   // Print out the install directory.
   OS << "InstalledDir: " << InstalledDir << '\n';
-
-  // Print registered targets.
-  OS << '\n';
-  llvm::TargetRegistry::printRegisteredTargetsForVersion(OS);
 }
 
 /// PrintDiagnosticCategories - Implement the --print-diagnostic-categories
@@ -1166,6 +1162,10 @@
   if (C.getArgs().hasArg(options::OPT__version)) {
 // Follow gcc behavior and use stdout for --version and stderr for -v.
 PrintVersion(C, llvm::outs());
+
+// Print registered targets.
+llvm::outs() << '\n';
+llvm::TargetRegistry::printRegisteredTargetsForVersion(llvm::outs());
 return false;
   }
 


Index: lib/Driver/Driver.cpp
===
--- lib/Driver/Driver.cpp
+++ lib/Driver/Driver.cpp
@@ -1117,10 +1117,6 @@
 
   // Print out the install directory.
   OS << "InstalledDir: " << InstalledDir << '\n';
-
-  // Print registered targets.
-  OS << '\n';
-  llvm::TargetRegistry::printRegisteredTargetsForVersion(OS);
 }
 
 /// PrintDiagnosticCategories - Implement the --print-diagnostic-categories
@@ -1166,6 +1162,10 @@
   if (C.getArgs().hasArg(options::OPT__version)) {
 // Follow gcc behavior and use stdout for --version and stderr for -v.
 PrintVersion(C, llvm::outs());
+
+// Print registered targets.
+llvm::outs() << '\n';
+llvm::TargetRegistry::printRegisteredTargetsForVersion(llvm::outs());
 return false;
   }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D33277: [Clang][x86][Inline Asm] - Enum support for MS syntax

2017-06-07 Thread Matan via Phabricator via cfe-commits
mharoush updated this revision to Diff 101693.
mharoush added a comment.

added struct case to the test


Repository:
  rL LLVM

https://reviews.llvm.org/D33277

Files:
  lib/Sema/SemaStmtAsm.cpp
  test/CodeGen/x86-ms-inline-asm-enum_feature.cpp

Index: lib/Sema/SemaStmtAsm.cpp
===
--- lib/Sema/SemaStmtAsm.cpp
+++ lib/Sema/SemaStmtAsm.cpp
@@ -644,8 +644,8 @@
   // Referring to parameters is not allowed in naked functions.
   if (CheckNakedParmReference(Result.get(), *this))
 return ExprError();
-
-  QualType T = Result.get()->getType();
+  Expr *Res = Result.get();
+  QualType T = Res->getType();
 
   if (T->isDependentType()) {
 return Result;
@@ -657,16 +657,26 @@
   }
 
   // Otherwise, it needs to be a complete type.
-  if (RequireCompleteExprType(Result.get(), diag::err_asm_incomplete_type)) {
+  if (RequireCompleteExprType(Res, diag::err_asm_incomplete_type)) {
 return ExprError();
   }
 
   fillInlineAsmTypeInfo(Context, T, Info);
 
   // We can work with the expression as long as it's not an r-value.
-  if (!Result.get()->isRValue())
-Info.IsVarDecl = true;
+  if (!Res->isRValue()) {
+Info.setKindVariable();
+return Result;
+  }
 
+  Expr::EvalResult EvlResult;
+  // Try to evaluate the identifier as enum constant, currently we do not allow
+  // other constant integers to be folded.
+  if (isa(T) &&
+Res->EvaluateAsRValue(EvlResult, getASTContext())) {
+Info.ConstIntValue = EvlResult.Val.getInt();
+Info.setKindConstEnum();
+  }
   return Result;
 }
 
@@ -773,7 +783,7 @@
   fillInlineAsmTypeInfo(Context, Result.get()->getType(), Info);
 
   // Fields are "variables" as far as inline assembly is concerned.
-  Info.IsVarDecl = true;
+  Info.setKindVariable();
 
   return Result;
 }
Index: test/CodeGen/x86-ms-inline-asm-enum_feature.cpp
===
--- test/CodeGen/x86-ms-inline-asm-enum_feature.cpp
+++ test/CodeGen/x86-ms-inline-asm-enum_feature.cpp
@@ -0,0 +1,45 @@
+// REQUIRES: x86-registered-target
+// RUN: %clang_cc1 %s -fasm-blocks -emit-llvm -o - | FileCHECK %s
+namespace x {
+enum { A = 12 };
+struct y_t {
+	enum { A = 17 };
+	int r;
+} y;
+}
+
+void x86_enum_namespaces() {
+  enum { A = 1 };
+  // CHECK: mov eax, $$12
+  __asm mov eax, x::A
+  // CHECK: mov eax, $$17
+  __asm mov eax, x::y_t::A
+  // CHECK: mov eax, $$1
+  __asm {mov eax, A}
+}
+
+void x86_enum_arithmethic() {
+  enum { A = 1, B };
+  // CHECK: mov eax, $$21
+  __asm mov eax, (A + 9) * 2 + A
+  // CHECK: mov eax, $$4
+  __asm mov eax, A << 2
+  // CHECK: mov eax, $$2
+  __asm mov eax, B & 3
+  // CHECK: mov eax, $$5
+  __asm mov eax, 3 + (B & 3)
+  // CHECK: mov eax, $$8
+  __asm mov eax, 2 << A * B
+}
+
+void x86_enum_mem() {
+  int arr[4];
+  enum { A = 4, B };
+
+  // CHECK: mov eax, [($$12 + $$9) + $$4 * $$5 + $$3 + $$3 + eax]
+  __asm { mov eax, [(x::A + 9) + A * B + 3 + 3 + eax] }
+  // CHECK: mov eax, dword ptr $$4$0
+  __asm { mov eax, dword ptr [arr + A] }
+  // CHECK: mov eax, dword ptr $$8$0
+  __asm { mov eax, dword ptr A[arr + A] }
+}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D33981: Only print registered targets for `--version`

2017-06-07 Thread Nemanja Ivanovic via Phabricator via cfe-commits
nemanjai accepted this revision.
nemanjai added a comment.
This revision is now accepted and ready to land.

LGTM. This cleans up the failures on PPC (and probably SystemZ) so the bots 
should go back to green.


https://reviews.llvm.org/D33981



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


r304897 - [CodeGen] Add thumb-mode to target-features for arm/thumb triples.

2017-06-07 Thread Florian Hahn via cfe-commits
Author: fhahn
Date: Wed Jun  7 06:50:45 2017
New Revision: 304897

URL: http://llvm.org/viewvc/llvm-project?rev=304897&view=rev
Log:
[CodeGen] Add thumb-mode to target-features for arm/thumb triples.

Summary:
The thumb-mode target feature is used to force Thumb or ARM code
generation on a per-function basis. Explicitly adding +thumb-mode to
functions for thumbxx triples enables mixed ARM/Thumb code generation in
places where compilation units with thumbxx and armxx triples are merged
together (e.g. the IR linker or LTO).

For armxx triples, -thumb-mode is added in a similar fashion.

Reviewers: echristo, t.p.northover, kristof.beyls, rengolin

Reviewed By: echristo

Subscribers: rinon, aemerson, mehdi_amini, javed.absar, cfe-commits

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

Added:
cfe/trunk/test/CodeGen/arm-thumb-mode-target-feature.c
Modified:
cfe/trunk/lib/Basic/Targets.cpp
cfe/trunk/test/CodeGen/arm-long-calls.c
cfe/trunk/test/CodeGen/arm-no-movt.c
cfe/trunk/test/CodeGen/arm-target-features.c

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=304897&r1=304896&r2=304897&view=diff
==
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Wed Jun  7 06:50:45 2017
@@ -5442,6 +5442,13 @@ public:
   if (Feature[0] == '+')
 Features[Feature.drop_front(1)] = true;
 
+// Enable or disable thumb-mode explicitly per function to enable mixed
+// ARM and Thumb code generation.
+if (isThumb())
+  Features["thumb-mode"] = true;
+else
+  Features["thumb-mode"] = false;
+
 // Convert user-provided arm and thumb GNU target attributes to
 // [-|+]thumb-mode target features respectively.
 std::vector UpdatedFeaturesVec(FeaturesVec);

Modified: cfe/trunk/test/CodeGen/arm-long-calls.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/arm-long-calls.c?rev=304897&r1=304896&r2=304897&view=diff
==
--- cfe/trunk/test/CodeGen/arm-long-calls.c (original)
+++ cfe/trunk/test/CodeGen/arm-long-calls.c Wed Jun  7 06:50:45 2017
@@ -1,7 +1,7 @@
 // RUN: %clang_cc1 -triple thumbv7-apple-ios5  -target-feature +long-calls 
-emit-llvm -o - %s | FileCheck -check-prefix=LONGCALL %s
 // RUN: %clang_cc1 -triple thumbv7-apple-ios5 -emit-llvm -o - %s | FileCheck 
-check-prefix=NOLONGCALL %s
 
-// LONGCALL: attributes #0 = { {{.*}} "target-features"="+long-calls"
-// NOLONGCALL-NOT: attributes #0 = { {{.*}} "target-features"="+long-calls"
+// LONGCALL: attributes #0 = { {{.*}} 
"target-features"="+long-calls,+thumb-mode"
+// NOLONGCALL-NOT: attributes #0 = { {{.*}} 
"target-features"="+long-calls,+thumb-mode"
 
 int foo1(int a) { return a; }

Modified: cfe/trunk/test/CodeGen/arm-no-movt.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/arm-no-movt.c?rev=304897&r1=304896&r2=304897&view=diff
==
--- cfe/trunk/test/CodeGen/arm-no-movt.c (original)
+++ cfe/trunk/test/CodeGen/arm-no-movt.c Wed Jun  7 06:50:45 2017
@@ -1,7 +1,7 @@
 // RUN: %clang_cc1 -triple thumbv7-apple-ios5  -target-feature +no-movt 
-emit-llvm -o - %s | FileCheck -check-prefix=NO-MOVT %s
 // RUN: %clang_cc1 -triple thumbv7-apple-ios5 -emit-llvm -o - %s | FileCheck 
-check-prefix=MOVT %s
 
-// NO-MOVT: attributes #0 = { {{.*}} "target-features"="+no-movt"
-// MOVT-NOT: attributes #0 = { {{.*}} "target-features"="+no-movt"
+// NO-MOVT: attributes #0 = { {{.*}} "target-features"="+no-movt,+thumb-mode"
+// MOVT-NOT: attributes #0 = { {{.*}} "target-features"="+no-movt,+thumb-mode"
 
 int foo1(int a) { return a; }

Modified: cfe/trunk/test/CodeGen/arm-target-features.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/arm-target-features.c?rev=304897&r1=304896&r2=304897&view=diff
==
--- cfe/trunk/test/CodeGen/arm-target-features.c (original)
+++ cfe/trunk/test/CodeGen/arm-target-features.c Wed Jun  7 06:50:45 2017
@@ -1,65 +1,63 @@
 // REQUIRES: arm-registered-target
 
 // RUN: %clang_cc1 -triple thumbv7-linux-gnueabihf -target-cpu cortex-a8 
-emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-VFP3
-// CHECK-VFP3: "target-features"="+dsp,+neon,+vfp3"
-
-
-// RUN: %clang_cc1 -triple thumbv7-linux-gnueabi -target-cpu cortex-a9 
-emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-VFP3-FP16
-// CHECK-VFP3-FP16: "target-features"="+dsp,+fp16,+neon,+vfp3"
+// CHECK-VFP3: "target-features"="+dsp,+neon,+thumb-mode
 
 
 // RUN: %clang_cc1 -triple thumbv7-linux-gnueabihf -target-cpu cortex-a5 
-emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-VFP4
-// CHECK-VFP4: "target-features"="+dsp,+neon,+vfp4"
+// CHECK-VFP4: "target-features"="+dsp,+neon,+thumb-mode,+vfp4"
 
 

[PATCH] D30691: [analyzer] Support for naive cross translational unit analysis

2017-06-07 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun updated this revision to Diff 101695.
xazax.hun edited the summary of this revision.
xazax.hun added a comment.

- Migrate to use USR instead of mangled names. Name mangling related changes 
are reverted.
- Better error handling in some cases.
- File paths containing spaces are now handled correctly.
- Fixes to support scripts.


https://reviews.llvm.org/D30691

Files:
  include/clang/AST/ASTContext.h
  include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
  include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h
  include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
  lib/AST/ASTContext.cpp
  lib/AST/ASTImporter.cpp
  lib/Basic/SourceManager.cpp
  lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
  lib/StaticAnalyzer/Core/CMakeLists.txt
  lib/StaticAnalyzer/Core/CallEvent.cpp
  lib/StaticAnalyzer/Core/ExprEngine.cpp
  lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
  test/Analysis/Inputs/ctu-chain.cpp
  test/Analysis/Inputs/ctu-other.cpp
  test/Analysis/Inputs/externalFnMap.txt
  test/Analysis/ctu-main.cpp
  test/Analysis/func-mapping-test.cpp
  test/CMakeLists.txt
  test/lit.cfg
  tools/CMakeLists.txt
  tools/clang-func-mapping/CMakeLists.txt
  tools/clang-func-mapping/ClangFnMapGen.cpp
  tools/ctu-analysis/ctu-analyze.py
  tools/ctu-analysis/ctu-build.py
  tools/scan-build-py/libscanbuild/analyze.py

Index: tools/scan-build-py/libscanbuild/analyze.py
===
--- tools/scan-build-py/libscanbuild/analyze.py
+++ tools/scan-build-py/libscanbuild/analyze.py
@@ -383,7 +383,8 @@
 
 def target():
 """ Creates output file name for reports. """
-if opts['output_format'] in {'plist', 'plist-html'}:
+if opts['output_format'] in {'plist', 'plist-html',
+ 'plist-multi-file'}:
 (handle, name) = tempfile.mkstemp(prefix='report-',
   suffix='.plist',
   dir=opts['output_dir'])
Index: tools/ctu-analysis/ctu-build.py
===
--- /dev/null
+++ tools/ctu-analysis/ctu-build.py
@@ -0,0 +1,243 @@
+#!/usr/bin/env python
+
+import argparse
+import json
+import glob
+import logging
+import multiprocessing
+import os
+import re
+import signal
+import subprocess
+import shlex
+import shutil
+import tempfile
+
+SOURCE_PATTERN = re.compile('.*\.(C|c|cc|cpp|cxx|ii|m|mm)$', re.IGNORECASE)
+TIMEOUT = 86400
+EXTERNAL_FUNCTION_MAP_FILENAME = 'externalFnMap.txt'
+TEMP_EXTERNAL_FNMAP_FOLDER = 'tmpExternalFnMaps'
+
+
+def get_args():
+parser = argparse.ArgumentParser(
+description='Executes 1st pass of CTU analysis where we preprocess '
+'all files in the compilation database and generate '
+'AST dumps and other necessary information from those '
+'to be used later by the 2nd pass of '
+'Cross Translation Unit analysis',
+formatter_class=argparse.ArgumentDefaultsHelpFormatter)
+parser.add_argument('-b', required=True, dest='buildlog',
+metavar='build.json',
+help='JSON Compilation Database to be used')
+parser.add_argument('-p', metavar='preanalyze-dir', dest='ctuindir',
+help='Target directory for preanalyzation data',
+default='.ctu')
+parser.add_argument('-j', metavar='threads', dest='threads', type=int,
+help='Number of threads to be used',
+default=int(multiprocessing.cpu_count() * 1.0))
+parser.add_argument('-v', dest='verbose', action='store_true',
+help='Verbose output')
+parser.add_argument('--clang-path', metavar='clang-path',
+dest='clang_path',
+help='Set path to directory of clang binaries used '
+ '(default taken from CLANG_PATH envvar)',
+default=os.environ.get('CLANG_PATH'))
+mainargs = parser.parse_args()
+
+if mainargs.verbose:
+logging.getLogger().setLevel(logging.INFO)
+
+if mainargs.clang_path is None:
+clang_path = ''
+else:
+clang_path = os.path.abspath(mainargs.clang_path)
+logging.info('CTU uses clang dir: ' +
+ (clang_path if clang_path != '' else ''))
+
+return mainargs, clang_path
+
+
+def process_buildlog(buildlog_filename, src_2_dir, src_2_cmd, src_order,
+ cmd_2_src, cmd_order):
+with open(buildlog_filename, 'r') as buildlog_file:
+buildlog = json.load(buildlog_file)
+for step in buildlog:
+if SOURCE_PATTERN.match(step['file']):
+if step['file'] not in src_2_dir:
+src_2_dir[step['file']] = step['directory']
+src_2_cmd[step['file']] = step['command']
+src_order.append(step[

r304899 - Only print registered targets for `--version`

2017-06-07 Thread Dimitry Andric via cfe-commits
Author: dim
Date: Wed Jun  7 07:05:41 2017
New Revision: 304899

URL: http://llvm.org/viewvc/llvm-project?rev=304899&view=rev
Log:
Only print registered targets for `--version`

Summary:
In D33900, I added printing of the registered targets in clang's
`PrintVersion` function, which is not only used for `--version` output,
but also for `-v` (verbose mode) and `-###`.  Especially the latter
seems to trip up some test cases, so it is probably better to only print
the registered targets for `--version`.

Reviewers: nemanjai, mehdi_amini

Reviewed By: nemanjai

Subscribers: cfe-commits

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

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

Modified: cfe/trunk/lib/Driver/Driver.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=304899&r1=304898&r2=304899&view=diff
==
--- cfe/trunk/lib/Driver/Driver.cpp (original)
+++ cfe/trunk/lib/Driver/Driver.cpp Wed Jun  7 07:05:41 2017
@@ -1117,10 +1117,6 @@ void Driver::PrintVersion(const Compilat
 
   // Print out the install directory.
   OS << "InstalledDir: " << InstalledDir << '\n';
-
-  // Print registered targets.
-  OS << '\n';
-  llvm::TargetRegistry::printRegisteredTargetsForVersion(OS);
 }
 
 /// PrintDiagnosticCategories - Implement the --print-diagnostic-categories
@@ -1166,6 +1162,10 @@ bool Driver::HandleImmediateArgs(const C
   if (C.getArgs().hasArg(options::OPT__version)) {
 // Follow gcc behavior and use stdout for --version and stderr for -v.
 PrintVersion(C, llvm::outs());
+
+// Print registered targets.
+llvm::outs() << '\n';
+llvm::TargetRegistry::printRegisteredTargetsForVersion(llvm::outs());
 return false;
   }
 


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


[PATCH] D33981: Only print registered targets for `--version`

2017-06-07 Thread Dimitry Andric via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL304899: Only print registered targets for `--version` 
(authored by dim).

Changed prior to commit:
  https://reviews.llvm.org/D33981?vs=101690&id=101697#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D33981

Files:
  cfe/trunk/lib/Driver/Driver.cpp


Index: cfe/trunk/lib/Driver/Driver.cpp
===
--- cfe/trunk/lib/Driver/Driver.cpp
+++ cfe/trunk/lib/Driver/Driver.cpp
@@ -1117,10 +1117,6 @@
 
   // Print out the install directory.
   OS << "InstalledDir: " << InstalledDir << '\n';
-
-  // Print registered targets.
-  OS << '\n';
-  llvm::TargetRegistry::printRegisteredTargetsForVersion(OS);
 }
 
 /// PrintDiagnosticCategories - Implement the --print-diagnostic-categories
@@ -1166,6 +1162,10 @@
   if (C.getArgs().hasArg(options::OPT__version)) {
 // Follow gcc behavior and use stdout for --version and stderr for -v.
 PrintVersion(C, llvm::outs());
+
+// Print registered targets.
+llvm::outs() << '\n';
+llvm::TargetRegistry::printRegisteredTargetsForVersion(llvm::outs());
 return false;
   }
 


Index: cfe/trunk/lib/Driver/Driver.cpp
===
--- cfe/trunk/lib/Driver/Driver.cpp
+++ cfe/trunk/lib/Driver/Driver.cpp
@@ -1117,10 +1117,6 @@
 
   // Print out the install directory.
   OS << "InstalledDir: " << InstalledDir << '\n';
-
-  // Print registered targets.
-  OS << '\n';
-  llvm::TargetRegistry::printRegisteredTargetsForVersion(OS);
 }
 
 /// PrintDiagnosticCategories - Implement the --print-diagnostic-categories
@@ -1166,6 +1162,10 @@
   if (C.getArgs().hasArg(options::OPT__version)) {
 // Follow gcc behavior and use stdout for --version and stderr for -v.
 PrintVersion(C, llvm::outs());
+
+// Print registered targets.
+llvm::outs() << '\n';
+llvm::TargetRegistry::printRegisteredTargetsForVersion(llvm::outs());
 return false;
   }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D30691: [analyzer] Support for naive cross translational unit analysis

2017-06-07 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun marked 2 inline comments as done.
xazax.hun added a comment.

In https://reviews.llvm.org/D30691#731617, @zaks.anna wrote:

> I agree that scan-build or scan-build-py integration is an important issue to 
> resolve here. What I envision is that users will just call scan-build and 
> pass -whole-project as an option to it. Everything else will happen 
> automagically:)


We contacted Laszlo and we have a pull request into scan-build that is under 
review. He is very helpful and supports the idea of scan-build-py supporting 
CTU analysis.

> I do not quite understand why AST serialization is needed at all. Can we 
> instead recompile the translation units on demand into a separate ASTContext 
> and then ASTImport?

We did a prototype implementation of on-demand reparsing. On the C projects we 
tested, the runtime is increased by 10-30% compared to dumping the ASTs. Note 
that, it is relatively fast to parse C, I would expect a much bigger delta in 
case of C++ projects. Unfortunately, we weren't able to test that setting due 
to the ASTImporter limitations.




Comment at: include/clang/AST/Mangle.h:59
+  // the static analyzer.
+  bool ShouldForceMangleProto;
 

xazax.hun wrote:
> dcoughlin wrote:
> > I'm pretty worried about using C++ mangling for C functions. It doesn't 
> > ever seem appropriate to do so and it sounds like it is papering over 
> > problems with the design.
> > 
> > Some questions:
> > - How do you handle when two translation units have different C functions 
> > with the same type signatures? Is there a collision? This can arise because 
> > of two-level namespacing or when building multiple targets with the same 
> > CTU directory.
> > - How do you handle when a C function has the same signature as a C++ 
> > function. Is there a collision when you mangle the C function?
> I agree that using C++ mangling for C+ is not the nicest solution, and I had 
> to circumvent a problem in the name mangler for C prototypes.
> 
> In case a mangled name is found in multiple source files, it will not be 
> imported. This is the way how collisions handled regardless of being C or C++ 
> functions. 
> The target arch is appended to the mangled name to support the cross 
> compilation scenario. Currently we do not add the full triple, but this could 
> be done.
> 
> An alternative solution would be to use USRs instead of mangled names but we 
> did not explore this option in depth yet. 
Note that the newest version of this patch does not use name mangling, it uses 
USRs instead. This turned out to be a perfectly viable alternative and we did 
not see any behavioral changes on the project we tested after the transition.


https://reviews.llvm.org/D30691



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


[PATCH] D20693: [clang-tidy] New checker to replace dynamic exception specifications

2017-06-07 Thread don hinton via Phabricator via cfe-commits
hintonda updated this revision to Diff 101708.
hintonda added a comment.

- Rollback to previous version: rebased + r293218 and r293234.


https://reviews.llvm.org/D20693

Files:
  clang-tidy/modernize/CMakeLists.txt
  clang-tidy/modernize/ModernizeTidyModule.cpp
  clang-tidy/modernize/UseNoexceptCheck.cpp
  clang-tidy/modernize/UseNoexceptCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/modernize-use-noexcept.rst
  test/clang-tidy/modernize-use-noexcept-macro.cpp
  test/clang-tidy/modernize-use-noexcept-opt.cpp
  test/clang-tidy/modernize-use-noexcept.cpp

Index: test/clang-tidy/modernize-use-noexcept.cpp
===
--- /dev/null
+++ test/clang-tidy/modernize-use-noexcept.cpp
@@ -0,0 +1,104 @@
+// RUN: %check_clang_tidy %s modernize-use-noexcept %t -- \
+// RUN:   -- -std=c++11
+
+class A {};
+class B {};
+
+void foo() throw();
+// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: dynamic exception specification 'throw()' is deprecated; consider using 'noexcept' instead [modernize-use-noexcept]
+// CHECK-FIXES: void foo() noexcept;
+
+template 
+void foo() throw();
+void footest() { foo(); foo(); }
+// CHECK-MESSAGES: :[[@LINE-2]]:12: warning: dynamic exception specification 'throw()' is deprecated; consider using 'noexcept' instead [modernize-use-noexcept]
+// CHECK-FIXES: void foo() noexcept;
+
+void bar() throw(...);
+// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: dynamic exception specification 'throw(...)' is deprecated; consider using 'noexcept(false)' instead [modernize-use-noexcept]
+// CHECK-FIXES: void bar() noexcept(false);
+
+void k() throw(int(int));
+// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: dynamic exception specification 'throw(int(int))' is deprecated; consider using 'noexcept(false)' instead [modernize-use-noexcept]
+// CHECK-FIXES: void k() noexcept(false);
+
+void foobar() throw(A, B)
+{}
+// CHECK-MESSAGES: :[[@LINE-2]]:15: warning: dynamic exception specification 'throw(A, B)' is deprecated; consider using 'noexcept(false)' instead [modernize-use-noexcept]
+// CHECK-FIXES: void foobar() noexcept(false)
+
+void baz(int = (throw A(), 0)) throw(A, B) {}
+// CHECK-MESSAGES: :[[@LINE-1]]:32: warning: dynamic exception specification 'throw(A, B)' is deprecated; consider using 'noexcept(false)' instead [modernize-use-noexcept]
+// CHECK-FIXES: void baz(int = (throw A(), 0)) noexcept(false) {}
+
+void g(void (*fp)(void) throw());
+// CHECK-MESSAGES: :[[@LINE-1]]:25: warning: dynamic exception specification 'throw()' is deprecated; consider using 'noexcept' instead [modernize-use-noexcept]
+// CHECK-FIXES: void g(void (*fp)(void) noexcept);
+
+void f(void (*fp)(void) throw(int)) throw(char);
+// CHECK-MESSAGES: :[[@LINE-1]]:25: warning: dynamic exception specification 'throw(int)' is deprecated; consider using 'noexcept(false)' instead [modernize-use-noexcept]
+// CHECK-MESSAGES: :[[@LINE-2]]:37: warning: dynamic exception specification 'throw(char)' is deprecated; consider using 'noexcept(false)' instead [modernize-use-noexcept]
+// CHECK-FIXES: void f(void (*fp)(void) noexcept(false)) noexcept(false);
+
+#define THROW throw
+void h(void (*fp)(void) THROW(int)) THROW(char);
+// CHECK-MESSAGES: :[[@LINE-1]]:25: warning: dynamic exception specification 'THROW(int)' is deprecated; consider using 'noexcept(false)' instead [modernize-use-noexcept]
+// CHECK-MESSAGES: :[[@LINE-2]]:37: warning: dynamic exception specification 'THROW(char)' is deprecated; consider using 'noexcept(false)' instead [modernize-use-noexcept]
+// CHECK-FIXES: void h(void (*fp)(void) noexcept(false)) noexcept(false);
+
+void j() throw(int(int) throw(void(void) throw(int)));
+// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: dynamic exception specification 'throw(int(int) throw(void(void) throw(int)))' is deprecated; consider using 'noexcept(false)' instead [modernize-use-noexcept]
+// CHECK-FIXES: void j() noexcept(false);
+
+class Y {
+  Y() throw() = default;
+};
+// CHECK-MESSAGES: :[[@LINE-2]]:7: warning: dynamic exception specification 'throw()' is deprecated; consider using 'noexcept' instead [modernize-use-noexcept]
+// CHECK-FIXES: Y() noexcept = default;
+
+struct Z {
+  void operator delete(void *ptr) throw();
+  void operator delete[](void *ptr) throw(int);
+  ~Z() throw(int) {}
+};
+// CHECK-MESSAGES: :[[@LINE-4]]:35: warning: dynamic exception specification 'throw()' is deprecated; consider using 'noexcept' instead [modernize-use-noexcept]
+// CHECK-MESSAGES: :[[@LINE-4]]:37: warning: dynamic exception specification 'throw(int)' is deprecated; consider using 'noexcept(false)' instead [modernize-use-noexcept]
+// CHECK-MESSAGES: :[[@LINE-4]]:8: warning: dynamic exception specification 'throw(int)' is deprecated; consider using 'noexcept(false)' instead [modernize-use-noexcept]
+// CHECK-FIXES: void operator delete(void *ptr) noexcept;
+// CHECK-FIXES: void operator delete[](void *ptr) noexcept(false);
+// CHECK-FIXES: ~Z() no

[PATCH] D20693: [clang-tidy] New checker to replace dynamic exception specifications

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

Unfortunately, the logs are no longer available, and I don't have copies.

However, I think I know what's going on, so I'll try to submit a fix later 
today.


https://reviews.llvm.org/D20693



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


r304904 - clang-format: [JS] recognize exported type definitions.

2017-06-07 Thread Martin Probst via cfe-commits
Author: mprobst
Date: Wed Jun  7 07:53:22 2017
New Revision: 304904

URL: http://llvm.org/viewvc/llvm-project?rev=304904&view=rev
Log:
clang-format: [JS] recognize exported type definitions.

Summary: Support "export type T = {...};", in addition to just "type T = 
{...};".

Reviewers: klimek

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

Modified:
cfe/trunk/lib/Format/TokenAnnotator.cpp
cfe/trunk/unittests/Format/FormatTestJS.cpp

Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=304904&r1=304903&r2=304904&view=diff
==
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Wed Jun  7 07:53:22 2017
@@ -135,8 +135,11 @@ private:
 if (Left->is(TT_OverloadedOperatorLParen)) {
   Contexts.back().IsExpression = false;
 } else if (Style.Language == FormatStyle::LK_JavaScript &&
-   Line.startsWith(Keywords.kw_type, tok::identifier)) {
+   (Line.startsWith(Keywords.kw_type, tok::identifier) ||
+Line.startsWith(tok::kw_export, Keywords.kw_type,
+tok::identifier))) {
   // type X = (...);
+  // export type X = (...);
   Contexts.back().IsExpression = false;
 } else if (Left->Previous &&
 (Left->Previous->isOneOf(tok::kw_static_assert, tok::kw_decltype,
@@ -979,9 +982,12 @@ private:
   void modifyContext(const FormatToken &Current) {
 if (Current.getPrecedence() == prec::Assignment &&
 !Line.First->isOneOf(tok::kw_template, tok::kw_using, tok::kw_return) 
&&
-// Type aliases use `type X = ...;` in TypeScript.
+// Type aliases use `type X = ...;` in TypeScript and can be exported
+// using `export type ...`.
 !(Style.Language == FormatStyle::LK_JavaScript &&
-  Line.startsWith(Keywords.kw_type, tok::identifier)) &&
+  (Line.startsWith(Keywords.kw_type, tok::identifier) ||
+   Line.startsWith(tok::kw_export, Keywords.kw_type,
+   tok::identifier))) &&
 (!Current.Previous || Current.Previous->isNot(tok::kw_operator))) {
   Contexts.back().IsExpression = true;
   if (!Line.startsWith(TT_UnaryOperator)) {

Modified: cfe/trunk/unittests/Format/FormatTestJS.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestJS.cpp?rev=304904&r1=304903&r2=304904&view=diff
==
--- cfe/trunk/unittests/Format/FormatTestJS.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTestJS.cpp Wed Jun  7 07:53:22 2017
@@ -1226,6 +1226,12 @@ TEST_F(FormatTestJS, UnionIntersectionTy
   verifyFormat("let x: Bar|Baz;");
   verifyFormat("let x: Bar|Baz;");
   verifyFormat("let x: (Foo|Bar)[];");
+  verifyFormat("type X = {\n"
+   "  a: Foo|Bar;\n"
+   "};");
+  verifyFormat("export type X = {\n"
+   "  a: Foo|Bar;\n"
+   "};");
 }
 
 TEST_F(FormatTestJS, ClassDeclarations) {


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


[PATCH] D33982: [clang-format] Fix alignment of preprocessor trailing comments

2017-06-07 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh accepted this revision.
alexfh added a comment.
This revision is now accepted and ready to land.

LG




Comment at: lib/Format/WhitespaceManager.cpp:112
+assert(PreviousOriginalWhitespaceEndOffset <= 
OriginalWhitespaceStartOffset);
+StringRef Text(SourceMgr.getCharacterData(PreviousOriginalWhitespaceEnd),
+   SourceMgr.getCharacterData(OriginalWhitespaceStart) -

I'd pull `SourceMgr.getCharacterData(PreviousOriginalWhitespaceEnd)` out to a 
variable.


https://reviews.llvm.org/D33982



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


[PATCH] D33989: [OpenCL] Allow targets to select address space per type

2017-06-07 Thread Sven van Haastregt via Phabricator via cfe-commits
svenvh created this revision.

Generalize getOpenCLImageAddrSpace into getOpenCLTypeAddrSpace, such
that targets can select the address space per type.

No functional changes intended.  In particular, this is already
covered by test/CodeGenOpenCL/opencl_types.cl .

Patch by Simon Perretta.


https://reviews.llvm.org/D33989

Files:
  include/clang/Basic/TargetInfo.h
  lib/AST/ASTContext.cpp
  lib/Basic/Targets.cpp
  lib/CodeGen/CGOpenCLRuntime.cpp

Index: lib/CodeGen/CGOpenCLRuntime.cpp
===
--- lib/CodeGen/CGOpenCLRuntime.cpp
+++ lib/CodeGen/CGOpenCLRuntime.cpp
@@ -35,32 +35,39 @@
  "Not an OpenCL specific type!");
 
   llvm::LLVMContext& Ctx = CGM.getLLVMContext();
-  uint32_t ImgAddrSpc = CGM.getContext().getTargetAddressSpace(
-CGM.getTarget().getOpenCLImageAddrSpace());
   switch (cast(T)->getKind()) {
   default:
 llvm_unreachable("Unexpected opencl builtin type!");
 return nullptr;
 #define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
   case BuiltinType::Id: \
 return llvm::PointerType::get( \
 llvm::StructType::create(Ctx, "opencl." #ImgType "_" #Suffix "_t"), \
-ImgAddrSpc);
+CGM.getContext().getTargetAddressSpace( \
+CGM.getTarget().getOpenCLTypeAddrSpace(BuiltinType::Id)));
 #include "clang/Basic/OpenCLImageTypes.def"
   case BuiltinType::OCLSampler:
 return getSamplerType();
   case BuiltinType::OCLEvent:
-return llvm::PointerType::get(llvm::StructType::create(
-   Ctx, "opencl.event_t"), 0);
+return llvm::PointerType::get(
+llvm::StructType::create(Ctx, "opencl.event_t"),
+CGM.getContext().getTargetAddressSpace(
+CGM.getTarget().getOpenCLTypeAddrSpace(BuiltinType::OCLEvent)));
   case BuiltinType::OCLClkEvent:
 return llvm::PointerType::get(
-llvm::StructType::create(Ctx, "opencl.clk_event_t"), 0);
+llvm::StructType::create(Ctx, "opencl.clk_event_t"),
+CGM.getContext().getTargetAddressSpace(
+CGM.getTarget().getOpenCLTypeAddrSpace(BuiltinType::OCLClkEvent)));
   case BuiltinType::OCLQueue:
 return llvm::PointerType::get(
-llvm::StructType::create(Ctx, "opencl.queue_t"), 0);
+llvm::StructType::create(Ctx, "opencl.queue_t"),
+CGM.getContext().getTargetAddressSpace(
+CGM.getTarget().getOpenCLTypeAddrSpace(BuiltinType::OCLQueue)));
   case BuiltinType::OCLReserveID:
 return llvm::PointerType::get(
-llvm::StructType::create(Ctx, "opencl.reserve_id_t"), 0);
+llvm::StructType::create(Ctx, "opencl.reserve_id_t"),
+CGM.getContext().getTargetAddressSpace(
+CGM.getTarget().getOpenCLTypeAddrSpace(BuiltinType::OCLReserveID)));
   }
 }
 
Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -2364,8 +2364,17 @@
 }
   }
 
-  LangAS::ID getOpenCLImageAddrSpace() const override {
+  virtual LangAS::ID
+  getOpenCLTypeAddrSpace(BuiltinType::Kind K) const override {
+switch (K) {
+#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix)   \
+  case BuiltinType::Id:\
 return LangAS::opencl_constant;
+#include "clang/Basic/OpenCLImageTypes.def"
+
+default:
+  return LangAS::Default;
+}
   }
 
   /// \returns Target specific vtbl ptr address space.
Index: lib/AST/ASTContext.cpp
===
--- lib/AST/ASTContext.cpp
+++ lib/AST/ASTContext.cpp
@@ -1624,6 +1624,7 @@
   uint64_t Width = 0;
   unsigned Align = 8;
   bool AlignIsRequired = false;
+  unsigned AS = 0;
   switch (T->getTypeClass()) {
 #define TYPE(Class, Base)
 #define ABSTRACT_TYPE(Class, Base)
@@ -1771,7 +1772,7 @@
   Align = Target->getPointerAlign(0);
   break;
 case BuiltinType::OCLSampler: {
-  auto AS = getTargetAddressSpace(LangAS::opencl_constant);
+  AS = getTargetAddressSpace(LangAS::opencl_constant);
   Width = Target->getPointerWidth(AS);
   Align = Target->getPointerAlign(AS);
   break;
@@ -1785,10 +1786,10 @@
   Align = Target->getPointerAlign(0);
   break;
 #define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
-case BuiltinType::Id:
+case BuiltinType::Id: \
+  AS = getTargetAddressSpace(Target->getOpenCLTypeAddrSpace(BuiltinType::Id));
 #include "clang/Basic/OpenCLImageTypes.def"
   {
-auto AS = getTargetAddressSpace(Target->getOpenCLImageAddrSpace());
 Width = Target->getPointerWidth(AS);
 Align = Target->getPointerAlign(AS);
   }
@@ -1799,24 +1800,22 @@
 Align = Target->getPointerAlign(0);
 break;
   case Type::BlockPointer: {
-unsigned AS = getTargetAddressSpace(
-cast(T)->getPointeeType());
+AS = getTargetAddressSpace(cast(T)->getPointeeType());
 Width = Targ

[PATCH] D20693: [clang-tidy] New checker to replace dynamic exception specifications

2017-06-07 Thread don hinton via Phabricator via cfe-commits
hintonda updated this revision to Diff 101722.
hintonda added a comment.



- Only pass %2 parameter if %2 is included in format.


https://reviews.llvm.org/D20693

Files:
  clang-tidy/modernize/CMakeLists.txt
  clang-tidy/modernize/ModernizeTidyModule.cpp
  clang-tidy/modernize/UseNoexceptCheck.cpp
  clang-tidy/modernize/UseNoexceptCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/modernize-use-noexcept.rst
  test/clang-tidy/modernize-use-noexcept-macro.cpp
  test/clang-tidy/modernize-use-noexcept-opt.cpp
  test/clang-tidy/modernize-use-noexcept.cpp

Index: test/clang-tidy/modernize-use-noexcept.cpp
===
--- /dev/null
+++ test/clang-tidy/modernize-use-noexcept.cpp
@@ -0,0 +1,104 @@
+// RUN: %check_clang_tidy %s modernize-use-noexcept %t -- \
+// RUN:   -- -std=c++11
+
+class A {};
+class B {};
+
+void foo() throw();
+// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: dynamic exception specification 'throw()' is deprecated; consider using 'noexcept' instead [modernize-use-noexcept]
+// CHECK-FIXES: void foo() noexcept;
+
+template 
+void foo() throw();
+void footest() { foo(); foo(); }
+// CHECK-MESSAGES: :[[@LINE-2]]:12: warning: dynamic exception specification 'throw()' is deprecated; consider using 'noexcept' instead [modernize-use-noexcept]
+// CHECK-FIXES: void foo() noexcept;
+
+void bar() throw(...);
+// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: dynamic exception specification 'throw(...)' is deprecated; consider using 'noexcept(false)' instead [modernize-use-noexcept]
+// CHECK-FIXES: void bar() noexcept(false);
+
+void k() throw(int(int));
+// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: dynamic exception specification 'throw(int(int))' is deprecated; consider using 'noexcept(false)' instead [modernize-use-noexcept]
+// CHECK-FIXES: void k() noexcept(false);
+
+void foobar() throw(A, B)
+{}
+// CHECK-MESSAGES: :[[@LINE-2]]:15: warning: dynamic exception specification 'throw(A, B)' is deprecated; consider using 'noexcept(false)' instead [modernize-use-noexcept]
+// CHECK-FIXES: void foobar() noexcept(false)
+
+void baz(int = (throw A(), 0)) throw(A, B) {}
+// CHECK-MESSAGES: :[[@LINE-1]]:32: warning: dynamic exception specification 'throw(A, B)' is deprecated; consider using 'noexcept(false)' instead [modernize-use-noexcept]
+// CHECK-FIXES: void baz(int = (throw A(), 0)) noexcept(false) {}
+
+void g(void (*fp)(void) throw());
+// CHECK-MESSAGES: :[[@LINE-1]]:25: warning: dynamic exception specification 'throw()' is deprecated; consider using 'noexcept' instead [modernize-use-noexcept]
+// CHECK-FIXES: void g(void (*fp)(void) noexcept);
+
+void f(void (*fp)(void) throw(int)) throw(char);
+// CHECK-MESSAGES: :[[@LINE-1]]:25: warning: dynamic exception specification 'throw(int)' is deprecated; consider using 'noexcept(false)' instead [modernize-use-noexcept]
+// CHECK-MESSAGES: :[[@LINE-2]]:37: warning: dynamic exception specification 'throw(char)' is deprecated; consider using 'noexcept(false)' instead [modernize-use-noexcept]
+// CHECK-FIXES: void f(void (*fp)(void) noexcept(false)) noexcept(false);
+
+#define THROW throw
+void h(void (*fp)(void) THROW(int)) THROW(char);
+// CHECK-MESSAGES: :[[@LINE-1]]:25: warning: dynamic exception specification 'THROW(int)' is deprecated; consider using 'noexcept(false)' instead [modernize-use-noexcept]
+// CHECK-MESSAGES: :[[@LINE-2]]:37: warning: dynamic exception specification 'THROW(char)' is deprecated; consider using 'noexcept(false)' instead [modernize-use-noexcept]
+// CHECK-FIXES: void h(void (*fp)(void) noexcept(false)) noexcept(false);
+
+void j() throw(int(int) throw(void(void) throw(int)));
+// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: dynamic exception specification 'throw(int(int) throw(void(void) throw(int)))' is deprecated; consider using 'noexcept(false)' instead [modernize-use-noexcept]
+// CHECK-FIXES: void j() noexcept(false);
+
+class Y {
+  Y() throw() = default;
+};
+// CHECK-MESSAGES: :[[@LINE-2]]:7: warning: dynamic exception specification 'throw()' is deprecated; consider using 'noexcept' instead [modernize-use-noexcept]
+// CHECK-FIXES: Y() noexcept = default;
+
+struct Z {
+  void operator delete(void *ptr) throw();
+  void operator delete[](void *ptr) throw(int);
+  ~Z() throw(int) {}
+};
+// CHECK-MESSAGES: :[[@LINE-4]]:35: warning: dynamic exception specification 'throw()' is deprecated; consider using 'noexcept' instead [modernize-use-noexcept]
+// CHECK-MESSAGES: :[[@LINE-4]]:37: warning: dynamic exception specification 'throw(int)' is deprecated; consider using 'noexcept(false)' instead [modernize-use-noexcept]
+// CHECK-MESSAGES: :[[@LINE-4]]:8: warning: dynamic exception specification 'throw(int)' is deprecated; consider using 'noexcept(false)' instead [modernize-use-noexcept]
+// CHECK-FIXES: void operator delete(void *ptr) noexcept;
+// CHECK-FIXES: void operator delete[](void *ptr) noexcept(false);
+// CHECK-FIXES: ~Z() noexcept(

[PATCH] D31972: Do not force the frame pointer by default for ARM EABI

2017-06-07 Thread Joerg Sonnenberger via Phabricator via cfe-commits
joerg added a comment.

Actually, for NetBSD we want to use -fomit-frame-pointer by default whenever 
the implicit -funwind-tables is also present. In general, that should be the 
justification for the default behavior: "Can I reliably unwind a binary with 
the available information?" Performance of stack unwinding is IMO secondary and 
users of sanitizers can disable it where necessary.


https://reviews.llvm.org/D31972



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


[PATCH] D33305: [ubsan] Add a check for pointer overflow UB

2017-06-07 Thread Stephan Bergmann via Phabricator via cfe-commits
sberg added a comment.

Just a heads up that I ran into an arguably somewhat unexpected instance of 
this with (a copy of the Graphite project included in) LibreOffice, see the 
commit message of 
https://cgit.freedesktop.org/libreoffice/core/commit/?id=681b4a49d797996229513d3e842d2a431030730a
 "external/graphite: Avoid -fsanitize=pointer-overflow" for details.  (In 
short,  "ptrdiff_t d = ...; T * p += d / sizeof(T);" can trigger an overflow 
warning when d is negative.)


Repository:
  rL LLVM

https://reviews.llvm.org/D33305



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


[PATCH] D33726: [driver][netbsd] Build and pass `-L` arguments to the linker

2017-06-07 Thread Joerg Sonnenberger via Phabricator via cfe-commits
joerg added a comment.

In https://reviews.llvm.org/D33726#774105, @ruiu wrote:

> I'm totally against adding per-OS path knowledge to our linker. Compilers 
> already know include paths and I don't want to maintain another list of paths 
> in the linker. Also this can be more confusing than useful when you are doing 
> cross-linking.


The only reason for compilers to maintain that list is for finding crt*.o. They 
otherwise don't care about the library paths at all. There is no confusion for 
cross-linking as long as proper sysroot support is used. Which we have been 
doing on NetBSD for ages.

> For all OSes other than NetBSD, LLD works fine with the clang driver as the 
> driver passes include paths to the linker. I don't see any reason not to do 
> the same thing for NetBSD. That stands even if the linker has to have a list 
> of include paths.

Sorry, but this is again ignorant and wrong. The very same problem of build 
systems calling ld directly apply on most other systems. Even then, the list of 
linker paths is not the only OS-specific knowledge. Things like the DT_RPATH vs 
DT_RUNPATH mess, init vs init_array all belong into this category. The list 
goes on.


Repository:
  rL LLVM

https://reviews.llvm.org/D33726



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


[PATCH] D33982: [clang-format] Fix alignment of preprocessor trailing comments

2017-06-07 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir updated this revision to Diff 101734.
krasimir added a comment.

- Address review comments


https://reviews.llvm.org/D33982

Files:
  lib/Format/WhitespaceManager.cpp
  unittests/Format/FormatTestComments.cpp


Index: unittests/Format/FormatTestComments.cpp
===
--- unittests/Format/FormatTestComments.cpp
+++ unittests/Format/FormatTestComments.cpp
@@ -1052,6 +1052,30 @@
"}", getLLVMStyleWithColumns(80));
 }
 
+TEST_F(FormatTestComments, AlignsPPElseEndifComments) {
+  verifyFormat("#if A\n"
+   "#else  // A\n"
+   "int ;\n"
+   "#endif // B",
+   getLLVMStyleWithColumns(20));
+  verifyFormat("#if A\n"
+   "#else  // A\n"
+   "int ; // CC\n"
+   "#endif // B",
+   getLLVMStyleWithColumns(20));
+  EXPECT_EQ("#if A\n"
+"#else  // A1\n"
+"   // A2\n"
+"int ii;\n"
+"#endif // B",
+format("#if A\n"
+   "#else  // A1\n"
+   "   // A2\n"
+   "int ii;\n"
+   "#endif // B",
+   getLLVMStyleWithColumns(20)));
+}
+
 TEST_F(FormatTestComments, CommentsInStaticInitializers) {
   EXPECT_EQ(
   "static SomeType type = {, /* comment */\n"
Index: lib/Format/WhitespaceManager.cpp
===
--- lib/Format/WhitespaceManager.cpp
+++ lib/Format/WhitespaceManager.cpp
@@ -100,14 +100,52 @@
   Changes[0].PreviousEndOfTokenColumn = 0;
   Change *LastOutsideTokenChange = &Changes[0];
   for (unsigned i = 1, e = Changes.size(); i != e; ++i) {
-unsigned OriginalWhitespaceStart =
-SourceMgr.getFileOffset(Changes[i].OriginalWhitespaceRange.getBegin());
-unsigned PreviousOriginalWhitespaceEnd = SourceMgr.getFileOffset(
-Changes[i - 1].OriginalWhitespaceRange.getEnd());
-Changes[i - 1].TokenLength = OriginalWhitespaceStart -
- PreviousOriginalWhitespaceEnd +
- Changes[i].PreviousLinePostfix.size() +
- Changes[i - 1].CurrentLinePrefix.size();
+SourceLocation OriginalWhitespaceStart =
+Changes[i].OriginalWhitespaceRange.getBegin();
+SourceLocation PreviousOriginalWhitespaceEnd =
+Changes[i - 1].OriginalWhitespaceRange.getEnd();
+unsigned OriginalWhitespaceStartOffset =
+SourceMgr.getFileOffset(OriginalWhitespaceStart);
+unsigned PreviousOriginalWhitespaceEndOffset =
+SourceMgr.getFileOffset(PreviousOriginalWhitespaceEnd);
+assert(PreviousOriginalWhitespaceEndOffset <=
+   OriginalWhitespaceStartOffset);
+const char *const PreviousOriginalWhitespaceEndData =
+SourceMgr.getCharacterData(PreviousOriginalWhitespaceEnd);
+StringRef Text(PreviousOriginalWhitespaceEndData,
+   SourceMgr.getCharacterData(OriginalWhitespaceStart) -
+   PreviousOriginalWhitespaceEndData);
+// Usually consecutive changes would occur in consecutive tokens. This is
+// not the case however when analyzing some preprocessor runs of the
+// annotated lines. For example, in this code:
+//
+// #if A // line 1
+// int i = 1;
+// #else B // line 2
+// int i = 2;
+// #endif // line 3
+//
+// one of the runs will produce the sequence of lines marked with line 1, 2
+// and 3. So the two consecutive whitespace changes just before '// line 2'
+// and before '#endif // line 3' span multiple lines and tokens:
+//
+// #else B{change X}[// line 2
+// int i = 2;
+// ]{change Y}#endif // line 3
+//
+// For this reason, if the text between consecutive changes spans multiple
+// newlines, the token length must be adjusted to the end of the original
+// line of the token.
+auto NewlinePos = Text.find_first_of('\n');
+if (NewlinePos == StringRef::npos) {
+  Changes[i - 1].TokenLength = OriginalWhitespaceStartOffset -
+   PreviousOriginalWhitespaceEndOffset +
+   Changes[i].PreviousLinePostfix.size() +
+   Changes[i - 1].CurrentLinePrefix.size();
+} else {
+  Changes[i - 1].TokenLength =
+  NewlinePos + Changes[i - 1].CurrentLinePrefix.size();
+}
 
 // If there are multiple changes in this token, sum up all the changes 
until
 // the end of the line.


Index: unittests/Format/FormatTestComments.cpp
===
--- unittests/Format/FormatTestComments.cpp
+++ unittests/Format/FormatTestComments.cpp
@@ -1052,6 +1052,30 @@
"}", getLLVMStyleWithColumns(80));
 }
 
+TEST_F(FormatTestComments, AlignsPPElseEndifComments) {
+  verifyFormat("#if A\n"
+   "#el

r304912 - [clang-format] Fix alignment of preprocessor trailing comments

2017-06-07 Thread Krasimir Georgiev via cfe-commits
Author: krasimir
Date: Wed Jun  7 09:05:06 2017
New Revision: 304912

URL: http://llvm.org/viewvc/llvm-project?rev=304912&view=rev
Log:
[clang-format] Fix alignment of preprocessor trailing comments

Summary:
This patch is a follow-up of https://reviews.llvm.org/rL304687, which fixed an
overflow in the comment alignment code in clang-format. The token length of
trailing comments of preprocessor directives is calculated incorrectly by
including the text between consecutive directives. That causes them to not being
aligned.

For example, in this code with column limit 20
```
#if A
#else  // A
int ;
#endif // B
```
the length of the token `// A` was wrongly calculated as 14 = 5 (the size of 
`// A\n`) plus 9 (the size of `int ;`) and so `// A` wouldn't be aligned 
with `// B` and this was produced:
```
#if A
#else // A
int ;
#endif // B
```

This patch fixes this case.

Reviewers: alexfh

Reviewed By: alexfh

Subscribers: cfe-commits, klimek

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

Modified:
cfe/trunk/lib/Format/WhitespaceManager.cpp
cfe/trunk/unittests/Format/FormatTestComments.cpp

Modified: cfe/trunk/lib/Format/WhitespaceManager.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/WhitespaceManager.cpp?rev=304912&r1=304911&r2=304912&view=diff
==
--- cfe/trunk/lib/Format/WhitespaceManager.cpp (original)
+++ cfe/trunk/lib/Format/WhitespaceManager.cpp Wed Jun  7 09:05:06 2017
@@ -100,14 +100,52 @@ void WhitespaceManager::calculateLineBre
   Changes[0].PreviousEndOfTokenColumn = 0;
   Change *LastOutsideTokenChange = &Changes[0];
   for (unsigned i = 1, e = Changes.size(); i != e; ++i) {
-unsigned OriginalWhitespaceStart =
-SourceMgr.getFileOffset(Changes[i].OriginalWhitespaceRange.getBegin());
-unsigned PreviousOriginalWhitespaceEnd = SourceMgr.getFileOffset(
-Changes[i - 1].OriginalWhitespaceRange.getEnd());
-Changes[i - 1].TokenLength = OriginalWhitespaceStart -
- PreviousOriginalWhitespaceEnd +
- Changes[i].PreviousLinePostfix.size() +
- Changes[i - 1].CurrentLinePrefix.size();
+SourceLocation OriginalWhitespaceStart =
+Changes[i].OriginalWhitespaceRange.getBegin();
+SourceLocation PreviousOriginalWhitespaceEnd =
+Changes[i - 1].OriginalWhitespaceRange.getEnd();
+unsigned OriginalWhitespaceStartOffset =
+SourceMgr.getFileOffset(OriginalWhitespaceStart);
+unsigned PreviousOriginalWhitespaceEndOffset =
+SourceMgr.getFileOffset(PreviousOriginalWhitespaceEnd);
+assert(PreviousOriginalWhitespaceEndOffset <=
+   OriginalWhitespaceStartOffset);
+const char *const PreviousOriginalWhitespaceEndData =
+SourceMgr.getCharacterData(PreviousOriginalWhitespaceEnd);
+StringRef Text(PreviousOriginalWhitespaceEndData,
+   SourceMgr.getCharacterData(OriginalWhitespaceStart) -
+   PreviousOriginalWhitespaceEndData);
+// Usually consecutive changes would occur in consecutive tokens. This is
+// not the case however when analyzing some preprocessor runs of the
+// annotated lines. For example, in this code:
+//
+// #if A // line 1
+// int i = 1;
+// #else B // line 2
+// int i = 2;
+// #endif // line 3
+//
+// one of the runs will produce the sequence of lines marked with line 1, 2
+// and 3. So the two consecutive whitespace changes just before '// line 2'
+// and before '#endif // line 3' span multiple lines and tokens:
+//
+// #else B{change X}[// line 2
+// int i = 2;
+// ]{change Y}#endif // line 3
+//
+// For this reason, if the text between consecutive changes spans multiple
+// newlines, the token length must be adjusted to the end of the original
+// line of the token.
+auto NewlinePos = Text.find_first_of('\n');
+if (NewlinePos == StringRef::npos) {
+  Changes[i - 1].TokenLength = OriginalWhitespaceStartOffset -
+   PreviousOriginalWhitespaceEndOffset +
+   Changes[i].PreviousLinePostfix.size() +
+   Changes[i - 1].CurrentLinePrefix.size();
+} else {
+  Changes[i - 1].TokenLength =
+  NewlinePos + Changes[i - 1].CurrentLinePrefix.size();
+}
 
 // If there are multiple changes in this token, sum up all the changes 
until
 // the end of the line.

Modified: cfe/trunk/unittests/Format/FormatTestComments.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestComments.cpp?rev=304912&r1=304911&r2=304912&view=diff
==
--- cfe/trunk/unittests/Format/FormatTestComments.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTestComments.cpp Wed Jun  7 09:05:0

[PATCH] D33982: [clang-format] Fix alignment of preprocessor trailing comments

2017-06-07 Thread Krasimir Georgiev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL304912: [clang-format] Fix alignment of preprocessor 
trailing comments (authored by krasimir).

Changed prior to commit:
  https://reviews.llvm.org/D33982?vs=101734&id=101736#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D33982

Files:
  cfe/trunk/lib/Format/WhitespaceManager.cpp
  cfe/trunk/unittests/Format/FormatTestComments.cpp


Index: cfe/trunk/lib/Format/WhitespaceManager.cpp
===
--- cfe/trunk/lib/Format/WhitespaceManager.cpp
+++ cfe/trunk/lib/Format/WhitespaceManager.cpp
@@ -100,14 +100,52 @@
   Changes[0].PreviousEndOfTokenColumn = 0;
   Change *LastOutsideTokenChange = &Changes[0];
   for (unsigned i = 1, e = Changes.size(); i != e; ++i) {
-unsigned OriginalWhitespaceStart =
-SourceMgr.getFileOffset(Changes[i].OriginalWhitespaceRange.getBegin());
-unsigned PreviousOriginalWhitespaceEnd = SourceMgr.getFileOffset(
-Changes[i - 1].OriginalWhitespaceRange.getEnd());
-Changes[i - 1].TokenLength = OriginalWhitespaceStart -
- PreviousOriginalWhitespaceEnd +
- Changes[i].PreviousLinePostfix.size() +
- Changes[i - 1].CurrentLinePrefix.size();
+SourceLocation OriginalWhitespaceStart =
+Changes[i].OriginalWhitespaceRange.getBegin();
+SourceLocation PreviousOriginalWhitespaceEnd =
+Changes[i - 1].OriginalWhitespaceRange.getEnd();
+unsigned OriginalWhitespaceStartOffset =
+SourceMgr.getFileOffset(OriginalWhitespaceStart);
+unsigned PreviousOriginalWhitespaceEndOffset =
+SourceMgr.getFileOffset(PreviousOriginalWhitespaceEnd);
+assert(PreviousOriginalWhitespaceEndOffset <=
+   OriginalWhitespaceStartOffset);
+const char *const PreviousOriginalWhitespaceEndData =
+SourceMgr.getCharacterData(PreviousOriginalWhitespaceEnd);
+StringRef Text(PreviousOriginalWhitespaceEndData,
+   SourceMgr.getCharacterData(OriginalWhitespaceStart) -
+   PreviousOriginalWhitespaceEndData);
+// Usually consecutive changes would occur in consecutive tokens. This is
+// not the case however when analyzing some preprocessor runs of the
+// annotated lines. For example, in this code:
+//
+// #if A // line 1
+// int i = 1;
+// #else B // line 2
+// int i = 2;
+// #endif // line 3
+//
+// one of the runs will produce the sequence of lines marked with line 1, 2
+// and 3. So the two consecutive whitespace changes just before '// line 2'
+// and before '#endif // line 3' span multiple lines and tokens:
+//
+// #else B{change X}[// line 2
+// int i = 2;
+// ]{change Y}#endif // line 3
+//
+// For this reason, if the text between consecutive changes spans multiple
+// newlines, the token length must be adjusted to the end of the original
+// line of the token.
+auto NewlinePos = Text.find_first_of('\n');
+if (NewlinePos == StringRef::npos) {
+  Changes[i - 1].TokenLength = OriginalWhitespaceStartOffset -
+   PreviousOriginalWhitespaceEndOffset +
+   Changes[i].PreviousLinePostfix.size() +
+   Changes[i - 1].CurrentLinePrefix.size();
+} else {
+  Changes[i - 1].TokenLength =
+  NewlinePos + Changes[i - 1].CurrentLinePrefix.size();
+}
 
 // If there are multiple changes in this token, sum up all the changes 
until
 // the end of the line.
Index: cfe/trunk/unittests/Format/FormatTestComments.cpp
===
--- cfe/trunk/unittests/Format/FormatTestComments.cpp
+++ cfe/trunk/unittests/Format/FormatTestComments.cpp
@@ -1052,6 +1052,30 @@
"}", getLLVMStyleWithColumns(80));
 }
 
+TEST_F(FormatTestComments, AlignsPPElseEndifComments) {
+  verifyFormat("#if A\n"
+   "#else  // A\n"
+   "int ;\n"
+   "#endif // B",
+   getLLVMStyleWithColumns(20));
+  verifyFormat("#if A\n"
+   "#else  // A\n"
+   "int ; // CC\n"
+   "#endif // B",
+   getLLVMStyleWithColumns(20));
+  EXPECT_EQ("#if A\n"
+"#else  // A1\n"
+"   // A2\n"
+"int ii;\n"
+"#endif // B",
+format("#if A\n"
+   "#else  // A1\n"
+   "   // A2\n"
+   "int ii;\n"
+   "#endif // B",
+   getLLVMStyleWithColumns(20)));
+}
+
 TEST_F(FormatTestComments, CommentsInStaticInitializers) {
   EXPECT_EQ(
   "static SomeType type = {, /* comment */\n"


Index: cfe/trunk/lib/Format/WhitespaceManager.cpp

[PATCH] D33735: [DebugInfo] Add ThisOrSelf attribute for emission of FlagObjectPointer.

2017-06-07 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: include/clang/AST/Decl.h:901
+/// member functions.
+unsigned ImplicitParamKind : 3;
   };

It's a bit strange to me that the non-parameter declaration bits now have a 
field for implicit parameter information. Why here instead of `ParmVarDeclBits`?



Comment at: include/clang/AST/Decl.h:1383
 class ImplicitParamDecl : public VarDecl {
+public:
+  /// Defines the kind of the implicit parameter: is this an implicit parameter

Rather than use three access specifiers, can you reorder this?
```
class ... {
  void anchor() override;

public:
  ...
};
```



Comment at: lib/CodeGen/CGDebugInfo.cpp:3471
+  // then give it an object pointer flag.
+  if (auto *IPD = dyn_cast(VD)) {
+if (IPD->getParameterKind() == ImplicitParamDecl::CXXThis ||

`const auto *` please.



Comment at: lib/CodeGen/CGDebugInfo.cpp:3586
   // block. Mark it as the object pointer.
-  if (isa(VD) && VD->getName() == "self")
-Ty = CreateSelfType(VD->getType(), Ty);
+  if (auto *IPD = dyn_cast(VD))
+if (IPD->getParameterKind() == ImplicitParamDecl::ObjCSelf)

`const auto *`



Comment at: lib/CodeGen/CGOpenMPRuntime.cpp:3467
   ImplicitParamDecl TaskPrivatesArg(
-  C, /*DC=*/nullptr, Loc, /*Id=*/nullptr,
-  C.getPointerType(PrivatesQTy).withConst().withRestrict());
+  C, C.getPointerType(PrivatesQTy).withConst().withRestrict(),
+  ImplicitParamDecl::Other);

This no longer sets the SourceLocation -- is that intended?



Comment at: lib/CodeGen/CGOpenMPRuntime.cpp:3479-3480
+ImplicitParamDecl::Other);
+IPD->setLocation(Loc);
+Args.push_back(IPD);
 auto *VD = cast(cast(E)->getDecl());

This code would be cleaner if ImplicitParamDecl::Create() took a SourceLocation 
as it originally did. Perhaps the last param could be a default argument that 
defaults to `SourceLocation{}`?



Comment at: lib/CodeGen/CGStmtOpenMP.cpp:284
 }
-Args.push_back(ImplicitParamDecl::Create(getContext(), nullptr,
- FD->getLocation(), II, ArgType));
+auto *IPD = ImplicitParamDecl::Create(getContext(), /*DC=*/nullptr,
+  FD->getLocation(), II, ArgType,

Why use a local variable here?



Comment at: lib/CodeGen/ItaniumCXXABI.cpp:1411
 QualType T = Context.getPointerType(Context.VoidPtrTy);
-ImplicitParamDecl *VTTDecl
-  = ImplicitParamDecl::Create(Context, nullptr, MD->getLocation(),
-  &Context.Idents.get("vtt"), T);
+ImplicitParamDecl *VTTDecl = ImplicitParamDecl::Create(
+Context, nullptr, MD->getLocation(), &Context.Idents.get("vtt"), T,

Can use `auto *` here.



Comment at: lib/CodeGen/MicrosoftCXXABI.cpp:1416
   if (isa(MD) && MD->getParent()->getNumVBases()) {
-ImplicitParamDecl *IsMostDerived
-  = ImplicitParamDecl::Create(Context, nullptr,
-  CGF.CurGD.getDecl()->getLocation(),
-  &Context.Idents.get("is_most_derived"),
-  Context.IntTy);
+ImplicitParamDecl *IsMostDerived = ImplicitParamDecl::Create(
+Context, /*DC=*/nullptr, CGF.CurGD.getDecl()->getLocation(),

`auto *`



Comment at: lib/CodeGen/MicrosoftCXXABI.cpp:1429
   } else if (isDeletingDtor(CGF.CurGD)) {
-ImplicitParamDecl *ShouldDelete
-  = ImplicitParamDecl::Create(Context, nullptr,
-  CGF.CurGD.getDecl()->getLocation(),
-  &Context.Idents.get("should_call_delete"),
-  Context.IntTy);
+ImplicitParamDecl *ShouldDelete = ImplicitParamDecl::Create(
+Context, /*DC=*/nullptr, CGF.CurGD.getDecl()->getLocation(),

`auto *`



Comment at: lib/Sema/SemaStmt.cpp:3959
   QualType ParamType = Context.getPointerType(Context.getTagDeclType(RD));
-  ImplicitParamDecl *Param
-= ImplicitParamDecl::Create(Context, DC, Loc, ParamName, ParamType);
+  ImplicitParamDecl *Param =
+  ImplicitParamDecl::Create(Context, DC, Loc, ParamName, ParamType,

`auto *` (and elsewhere, I'll stop posting about them.)



Comment at: lib/Serialization/ASTWriterDecl.cpp:918
 Record.push_back(D->isPreviousDeclInSameBlockScope());
+if (auto *IPD = dyn_cast(D))
+  Record.push_back(static_cast(IPD->getParameterKind()));

`const auto *`


https://reviews.llvm.org/D33735



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


[PATCH] D33735: [DebugInfo] Add ThisOrSelf attribute for emission of FlagObjectPointer.

2017-06-07 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: include/clang/AST/Decl.h:901
+/// member functions.
+unsigned ImplicitParamKind : 3;
   };

aaron.ballman wrote:
> It's a bit strange to me that the non-parameter declaration bits now have a 
> field for implicit parameter information. Why here instead of 
> `ParmVarDeclBits`?
Actually, `ImplicitParamDecl` already uses some bits from the 
`NonParmVarDeclBitfields`, at least it may be marked as `ARCPseudoStrong` for 
ObjC. That's why I had to reuse `NonParmVarDeclBitfields` part.



Comment at: include/clang/AST/Decl.h:1383
 class ImplicitParamDecl : public VarDecl {
+public:
+  /// Defines the kind of the implicit parameter: is this an implicit parameter

aaron.ballman wrote:
> Rather than use three access specifiers, can you reorder this?
> ```
> class ... {
>   void anchor() override;
> 
> public:
>   ...
> };
> ```
Ok



Comment at: lib/CodeGen/CGOpenMPRuntime.cpp:3467
   ImplicitParamDecl TaskPrivatesArg(
-  C, /*DC=*/nullptr, Loc, /*Id=*/nullptr,
-  C.getPointerType(PrivatesQTy).withConst().withRestrict());
+  C, C.getPointerType(PrivatesQTy).withConst().withRestrict(),
+  ImplicitParamDecl::Other);

aaron.ballman wrote:
> This no longer sets the SourceLocation -- is that intended?
Just missed this after some reworks, will return it back


https://reviews.llvm.org/D33735



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


[PATCH] D33735: [DebugInfo] Add ThisOrSelf attribute for emission of FlagObjectPointer.

2017-06-07 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: include/clang/AST/Decl.h:901
+/// member functions.
+unsigned ImplicitParamKind : 3;
   };

ABataev wrote:
> aaron.ballman wrote:
> > It's a bit strange to me that the non-parameter declaration bits now have a 
> > field for implicit parameter information. Why here instead of 
> > `ParmVarDeclBits`?
> Actually, `ImplicitParamDecl` already uses some bits from the 
> `NonParmVarDeclBitfields`, at least it may be marked as `ARCPseudoStrong` for 
> ObjC. That's why I had to reuse `NonParmVarDeclBitfields` part.
Ew. That's nasty and we should probably fix that (not as part of this patch). 
Can you add a FIXME here?


https://reviews.llvm.org/D33735



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


[PATCH] D33735: [DebugInfo] Add ThisOrSelf attribute for emission of FlagObjectPointer.

2017-06-07 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: include/clang/AST/Decl.h:901
+/// member functions.
+unsigned ImplicitParamKind : 3;
   };

aaron.ballman wrote:
> ABataev wrote:
> > aaron.ballman wrote:
> > > It's a bit strange to me that the non-parameter declaration bits now have 
> > > a field for implicit parameter information. Why here instead of 
> > > `ParmVarDeclBits`?
> > Actually, `ImplicitParamDecl` already uses some bits from the 
> > `NonParmVarDeclBitfields`, at least it may be marked as `ARCPseudoStrong` 
> > for ObjC. That's why I had to reuse `NonParmVarDeclBitfields` part.
> Ew. That's nasty and we should probably fix that (not as part of this patch). 
> Can you add a FIXME here?
Ok, I will add FIXME for `ARCPseudoStrong` and for the `ImplicitParamKind` 
bitfields


https://reviews.llvm.org/D33735



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


[PATCH] D20693: [clang-tidy] New checker to replace dynamic exception specifications

2017-06-07 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added a comment.

In https://reviews.llvm.org/D20693#775014, @hintonda wrote:

> - Only pass %2 parameter if %2 is included in format.


I thought, DiagnosticsBuilder handles placeholders in conditional parts 
correctly. Did you find an evidence of the opposite? Can you add a test that 
consistently fails?




Comment at: clang-tidy/modernize/UseNoexceptCheck.h:42
+  const std::string NoexceptMacro;
+  bool UseNoexceptFalse;
+};

This can also be `const` for consistency with how options are handled in this 
and other checks.


https://reviews.llvm.org/D20693



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


[PATCH] D20693: [clang-tidy] New checker to replace dynamic exception specifications

2017-06-07 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added a comment.

In https://reviews.llvm.org/D20693#775153, @alexfh wrote:

> In https://reviews.llvm.org/D20693#775014, @hintonda wrote:
>
> > - Only pass %2 parameter if %2 is included in format.
>
>
> I thought, DiagnosticsBuilder handles placeholders in conditional parts 
> correctly. Did you find an evidence of the opposite? Can you add a test that 
> consistently fails?


(without your latest change that is)


https://reviews.llvm.org/D20693



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


[PATCH] D33305: [ubsan] Add a check for pointer overflow UB

2017-06-07 Thread John Regehr via Phabricator via cfe-commits
regehr added a comment.

I'm taking a look. For reference here's the test program I'm using.

  #include 
  
  typedef struct {
int x[2];
  } T;
  
  int main(void) {
T f;
T *p = &f;
ptrdiff_t d = -3293184;
p += d / sizeof(T);
return 0;
  }


Repository:
  rL LLVM

https://reviews.llvm.org/D33305



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


Re: [PATCH] D33750: CGCleanup: (NFC) add a test that used to trigger broken IR

2017-06-07 Thread Gor Nishanov via cfe-commits
Sure thing. I'll expand the test to verify that frontend emit expected IR
for this case.
Thank you for the feedback

On Mon, Jun 5, 2017 at 9:58 AM, David Blaikie  wrote:

>
>
> On Wed, May 31, 2017 at 5:45 PM Gor Nishanov via Phabricator via
> cfe-commits  wrote:
>
>> GorNishanov created this revision.
>>
>> Coroutine related test that used to trigger broken IR prior to r304335.
>>
>>
>> https://reviews.llvm.org/D33750
>>
>> Files:
>>   test/CodeGenCoroutines/coro-await-domination.cpp
>>
>>
>> Index: test/CodeGenCoroutines/coro-await-domination.cpp
>> ===
>> --- /dev/null
>> +++ test/CodeGenCoroutines/coro-await-domination.cpp
>> @@ -0,0 +1,38 @@
>> +// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fcoroutines-ts
>> -std=c++14 -emit-llvm %s -o - | FileCheck %s
>
> +#include "Inputs/coroutine.h"
>> +
>> +using namespace std::experimental;
>> +
>> +struct coro {
>> +  struct promise_type {
>> +coro get_return_object();
>> +suspend_never initial_suspend();
>> +suspend_never final_suspend();
>> +void return_void();
>> +static void unhandled_exception();
>> +  };
>> +};
>> +
>> +struct A {
>> +  ~A();
>> +  bool await_ready();
>> +  int await_resume() { return 8; }
>> +  template  void await_suspend(F);
>> +};
>> +
>> +extern "C" void consume(int);
>> +
>> +// Verifies that domination is properly built during cleanup.
>> +// Without CGCleanup.cpp fix verifier was reporting:
>> +// Instruction does not dominate all uses!
>> +//  %tmp.exprcleanup = alloca i32*, align 8
>> +//  store i32* %x, i32** %tmp.exprcleanup, align 8
>> +
>> +
>> +// CHECK-LABEL: f(
>>
>
> This doesn't seem to check much. Should this test check that the IR
> instructions have the 'good' layout, more than that the verifier doesn't
> fail?
>
> Or is that already tested by the test case added in r304335? In that case
> I wouldn't add this test. If the change can/is tested in isolation in
> Clang, that should be sufficient/tends to be how testing is done in the
> regression test suites in the LLVM project. (the test-suite is the place
> for broader/end-to-end testing)
>
>
>> +extern "C" coro f(int) {
>> +  int x = 42;
>> +  x = co_await A{};
>> +  consume(x);
>> +}
>> +
>>
>>
>> ___
>> cfe-commits mailing list
>> cfe-commits@lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D33305: [ubsan] Add a check for pointer overflow UB

2017-06-07 Thread John Regehr via Phabricator via cfe-commits
regehr added a comment.

Sorry, let's go with this example instead, which makes it clear that the 
program is attempting to do something completely sensible:

  #include 
  
  typedef struct {
int x[2];
  } T;
  
  int main(void) {
T f[1000];
T *p = &f[500];
ptrdiff_t d = -10;
p += d / sizeof(T);
return 0;
  }


Repository:
  rL LLVM

https://reviews.llvm.org/D33305



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


[PATCH] D20693: [clang-tidy] New checker to replace dynamic exception specifications

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

I have not, as yet, been able to reproduce the buildbot failures.  They were 
essentially intermittent seg-faults, and corrupt diag output.

I will work on creating a test that can reproduce the problem.


https://reviews.llvm.org/D20693



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


[PATCH] D33735: [DebugInfo] Add ThisOrSelf attribute for emission of FlagObjectPointer.

2017-06-07 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev updated this revision to Diff 101751.
ABataev added a comment.

Update after review


https://reviews.llvm.org/D33735

Files:
  include/clang/AST/Decl.h
  lib/AST/ASTImporter.cpp
  lib/AST/Decl.cpp
  lib/AST/DeclObjC.cpp
  lib/CodeGen/CGBlocks.cpp
  lib/CodeGen/CGCXXABI.cpp
  lib/CodeGen/CGDebugInfo.cpp
  lib/CodeGen/CGDeclCXX.cpp
  lib/CodeGen/CGException.cpp
  lib/CodeGen/CGExpr.cpp
  lib/CodeGen/CGObjC.cpp
  lib/CodeGen/CGOpenMPRuntime.cpp
  lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
  lib/CodeGen/CGStmtOpenMP.cpp
  lib/CodeGen/CodeGenFunction.cpp
  lib/CodeGen/ItaniumCXXABI.cpp
  lib/CodeGen/MicrosoftCXXABI.cpp
  lib/Sema/SemaStmt.cpp
  lib/Serialization/ASTReaderDecl.cpp
  lib/Serialization/ASTWriterDecl.cpp
  test/CodeGen/captured-statements.c
  test/CodeGenCXX/captured-statements.cpp

Index: test/CodeGenCXX/captured-statements.cpp
===
--- test/CodeGenCXX/captured-statements.cpp
+++ test/CodeGenCXX/captured-statements.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -std=c++11 -triple %itanium_abi_triple -emit-llvm %s -o %t
+// RUN: %clang_cc1 -std=c++11 -triple %itanium_abi_triple -emit-llvm %s -o %t -debug-info-kind=limited
 // RUN: FileCheck %s -input-file=%t -check-prefix=CHECK-1
 // RUN: FileCheck %s -input-file=%t -check-prefix=CHECK-2
 // RUN: FileCheck %s -input-file=%t -check-prefix=CHECK-3
@@ -194,3 +194,18 @@
 void call_test_captured_linkage() {
   test_captured_linkage();
 }
+
+// CHECK-1-DAG: !DILocalVariable(name: "this", {{.*}}, flags: DIFlagArtificial | DIFlagObjectPointer)
+// CHECK-1-DAG: !DILocalVariable(name: "__context", {{.*}}, flags: DIFlagArtificial)
+// CHECK-2-DAG: !DILocalVariable(name: "this", {{.*}}, flags: DIFlagArtificial | DIFlagObjectPointer)
+// CHECK-2-DAG: !DILocalVariable(name: "__context", {{.*}}, flags: DIFlagArtificial)
+// CHECK-3-DAG: !DILocalVariable(name: "this", {{.*}}, flags: DIFlagArtificial | DIFlagObjectPointer)
+// CHECK-3-DAG: !DILocalVariable(name: "__context", {{.*}}, flags: DIFlagArtificial)
+// CHECK-4-DAG: !DILocalVariable(name: "this", {{.*}}, flags: DIFlagArtificial | DIFlagObjectPointer)
+// CHECK-4-DAG: !DILocalVariable(name: "__context", {{.*}}, flags: DIFlagArtificial)
+// CHECK-5-DAG: !DILocalVariable(name: "this", {{.*}}, flags: DIFlagArtificial | DIFlagObjectPointer)
+// CHECK-5-DAG: !DILocalVariable(name: "__context", {{.*}}, flags: DIFlagArtificial)
+// CHECK-6-DAG: !DILocalVariable(name: "this", {{.*}}, flags: DIFlagArtificial | DIFlagObjectPointer)
+// CHECK-6-DAG: !DILocalVariable(name: "__context", {{.*}}, flags: DIFlagArtificial)
+// CHECK-7-DAG: !DILocalVariable(name: "this", {{.*}}, flags: DIFlagArtificial | DIFlagObjectPointer)
+// CHECK-7-DAG: !DILocalVariable(name: "__context", {{.*}}, flags: DIFlagArtificial)
Index: test/CodeGen/captured-statements.c
===
--- test/CodeGen/captured-statements.c
+++ test/CodeGen/captured-statements.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple %itanium_abi_triple -emit-llvm %s -o %t
+// RUN: %clang_cc1 -triple %itanium_abi_triple -emit-llvm %s -o %t -debug-info-kind=limited
 // RUN: FileCheck %s -input-file=%t -check-prefix=CHECK-GLOBALS
 // RUN: FileCheck %s -input-file=%t -check-prefix=CHECK-1
 // RUN: FileCheck %s -input-file=%t -check-prefix=CHECK-2
@@ -98,3 +98,8 @@
 // CHECK-GLOBALS:   load i32, i32* @global
 // CHECK-GLOBALS:   load i32, i32* @
 // CHECK-GLOBALS:   load i32, i32* @e
+
+// CHECK-GLOBALS-NOT: DIFlagObjectPointer
+// CHECK-1-NOT: DIFlagObjectPointer
+// CHECK-2-NOT: DIFlagObjectPointer
+// CHECK-3-NOT: DIFlagObjectPointer
Index: lib/Serialization/ASTWriterDecl.cpp
===
--- lib/Serialization/ASTWriterDecl.cpp
+++ lib/Serialization/ASTWriterDecl.cpp
@@ -915,6 +915,10 @@
 Record.push_back(D->isConstexpr());
 Record.push_back(D->isInitCapture());
 Record.push_back(D->isPreviousDeclInSameBlockScope());
+if (auto *IPD = dyn_cast(D))
+  Record.push_back(static_cast(IPD->getParameterKind()));
+else
+  Record.push_back(0);
   }
   Record.push_back(D->getLinkageInternal());
 
@@ -1989,6 +1993,7 @@
   Abv->Add(BitCodeAbbrevOp(0)); // isConstexpr
   Abv->Add(BitCodeAbbrevOp(0)); // isInitCapture
   Abv->Add(BitCodeAbbrevOp(0)); // isPrevDeclInSameScope
+  Abv->Add(BitCodeAbbrevOp(0)); // ImplicitParamKind
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); // Linkage
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 2)); // IsInitICE (local)
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 2)); // VarKind (local enum)
Index: lib/Serialization/ASTReaderDecl.cpp
===
--- lib/Serialization/ASTReaderDecl.cpp
+++ lib/Serialization/ASTReaderDecl.cpp
@@ -1229,6 +1229,7 @@
 VD->NonParmVarDeclBits.IsConstexpr = Reco

[PATCH] D33493: Speed up preamble loading

2017-06-07 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added inline comments.



Comment at: include/clang/Frontend/ASTUnit.h:192
+  /// of that loading
+  std::map SrcLocCache;
+

You can use an `llvm::StringMap` instead.



Comment at: lib/Frontend/ASTUnit.cpp:1152
+  else
+SrcLocCache.clear();
 

Why is `clear` in an `else` here? We always create a new `SourceManager` in 
this function, so the previously cached locations will be invalid, so shouldn't 
we always clear the cache before `TranslateStoredDiagnostics`?


https://reviews.llvm.org/D33493



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


[PATCH] D33997: Implement the non-execution policy versions of `reduce` and `transform_reduce` for C++17

2017-06-07 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists created this revision.

There are versions of `reduce` and `transform_reduce` that take an execution 
policy, and those that do not.
This implements the ones that do not.


https://reviews.llvm.org/D33997

Files:
  include/numeric
  test/std/numerics/numeric.ops/reduce/reduce_iter_iter.pass.cpp
  test/std/numerics/numeric.ops/reduce/reduce_iter_iter_T.pass.cpp
  test/std/numerics/numeric.ops/reduce/reduce_iter_iter_T_op.pass.cpp
  
test/std/numerics/numeric.ops/transform.reduce/transform_reduce_iter_iter_init_bop_uop.pass.cpp
  
test/std/numerics/numeric.ops/transform.reduce/transform_reduce_iter_iter_iter_init.pass.cpp
  
test/std/numerics/numeric.ops/transform.reduce/transform_reduce_iter_iter_iter_init_op_op.pass.cpp

Index: test/std/numerics/numeric.ops/transform.reduce/transform_reduce_iter_iter_iter_init_op_op.pass.cpp
===
--- test/std/numerics/numeric.ops/transform.reduce/transform_reduce_iter_iter_iter_init_op_op.pass.cpp
+++ test/std/numerics/numeric.ops/transform.reduce/transform_reduce_iter_iter_iter_init_op_op.pass.cpp
@@ -0,0 +1,97 @@
+//===--===//
+//
+// 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
+
+// template 
+//T transform_reduce(InputIterator1 first1, InputIterator1 last1,
+//   InputIterator2 first2, T init,
+//   BinaryOperation1 binary_op1, BinaryOperation2 binary_op2);
+//  
+  
+#include 
+#include 
+
+#include "test_iterators.h"
+
+template 
+void
+test(Iter1 first1, Iter1 last1, Iter2 first2, T init, Op1 op1, Op2 op2, T x)
+{
+static_assert( std::is_same::value, "" );
+assert(std::transform_reduce(first1, last1, first2, init, op1, op2) == x);
+}
+
+template 
+void
+test()
+{
+int ia[]  = {1, 2, 3, 4, 5, 6};
+unsigned int ua[] = {2, 4, 6, 8, 10,12};
+unsigned sa = sizeof(ia) / sizeof(ia[0]);
+assert(sa == sizeof(ua) / sizeof(ua[0]));   // just to be sure
+
+test(SIter(ia), SIter(ia),UIter(ua), 0, std::plus<>(), std::multiplies<>(),   0);
+test(UIter(ua), UIter(ua),SIter(ia), 1, std::multiplies<>(), std::plus<>(),   1);
+test(SIter(ia), SIter(ia+1),  UIter(ua), 0, std::multiplies<>(), std::plus<>(),   0);
+test(UIter(ua), UIter(ua+1),  SIter(ia), 2, std::plus<>(), std::multiplies<>(),   4);
+test(SIter(ia), SIter(ia+2),  UIter(ua), 0, std::plus<>(), std::multiplies<>(),  10);
+test(UIter(ua), UIter(ua+2),  SIter(ia), 3, std::multiplies<>(), std::plus<>(),  54);
+test(SIter(ia), SIter(ia+sa), UIter(ua), 4, std::multiplies<>(), std::plus<>(), 2099520);
+test(UIter(ua), UIter(ua+sa), SIter(ia), 4, std::plus<>(), std::multiplies<>(), 186);
+}
+
+template 
+void test_return_type()
+{
+T *p = nullptr;
+static_assert( std::is_same(), std::multiplies<>()))>::value, "" );
+}
+
+int main()
+{
+test_return_type();
+test_return_type();
+test_return_type();
+test_return_type();
+test_return_type();
+test_return_type();
+test_return_type();
+
+//  All the iterator categories
+test, input_iterator >();
+test, forward_iterator   >();
+test, bidirectional_iterator >();
+test, random_access_iterator >();
+
+test, input_iterator >();
+test, forward_iterator   >();
+test, bidirectional_iterator >();
+test, random_access_iterator >();
+
+test, input_iterator >();
+test, forward_iterator   >();
+test, bidirectional_iterator >();
+test, random_access_iterator >();
+
+test, input_iterator >();
+test, forward_iterator   >();
+test, bidirectional_iterator >();
+test, random_access_iterator >();
+
+//  just plain pointers (const vs. non-const, too)
+test();
+test();
+test<  int*, const unsigned int *>();
+test<  int*,   unsigned int *>();
+}
Index: test/std/numerics/numeric.ops/transform.reduce/transform_reduce_iter_iter_iter_init.pass.cpp
===
--- test/std/numerics/numeric.ops/transform.reduce/transform_reduce_iter_iter_iter_init.pass.cpp
+++ test/std/numerics/numeric.ops/transform.reduce/transform_reduce_iter_iter_iter_init.pass.cpp
@@ -0,0 +1,95 @@
+//===--===//
+//
+// 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.
+//
+//===--

[PATCH] D33997: Implement the non-execution policy versions of `reduce` and `transform_reduce` for C++17

2017-06-07 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists added inline comments.



Comment at: include/numeric:98
 #include  // for numeric_limits
+#include 
 

I don't like adding this dependency; but the standard requires the use of 
`std::plus` and `std::multiplies`


https://reviews.llvm.org/D33997



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


[PATCH] D33305: [ubsan] Add a check for pointer overflow UB

2017-06-07 Thread John Regehr via Phabricator via cfe-commits
regehr added a comment.

Well, my second program should subtract a multiple of sizeof(T). But anyway, my 
view is that this is a real overflow and a nasty consequence of the unsigned 
size_t and the usual arithmetic conversions and I don't think we want to try to 
poke a hole in UBSan to allow this idiom unless it turns out to be extremely 
common.

I think it would be better style to cast the sizeof() to a ptrdiff_t rather 
than to an int, but as long as d is a ptrdiff_t this won't matter.


Repository:
  rL LLVM

https://reviews.llvm.org/D33305



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


[PATCH] D31956: Implement (part of) LWG2857: `{variant, optional, any}::emplace` should return the constructed value

2017-06-07 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists closed this revision.
mclow.lists added a comment.

Landed as r300123


https://reviews.llvm.org/D31956



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


[PATCH] D33304: [clang-tidy][Part1] Add a new module Android and three new checks.

2017-06-07 Thread Haojian Wu via Phabricator via cfe-commits
hokein added a comment.

In https://reviews.llvm.org/D33304#771493, @alexfh wrote:

> IIUC, these checks enforce a certain - Android-specific - way of using POSIX 
> APIs. I'm not sure if the recommendations are universally useful. Or am I 
> mistaken?


OK, that makes sense. I may miss some background context.




Comment at: docs/clang-tidy/index.rst:58
 == 
=
+``android``
 ``boost-`` Checks related to Boost library.

Add some words explaining this module?


https://reviews.llvm.org/D33304



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


[PATCH] D26065: Improve diagnostics if friend function redefines file-level function.

2017-06-07 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman accepted this revision.
arphaman added a comment.
This revision is now accepted and ready to land.

LGTM.


https://reviews.llvm.org/D26065



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


r304929 - [mips] Add runtime options to enable/disable madd.fmt and msub.fmt

2017-06-07 Thread Petar Jovanovic via cfe-commits
Author: petarj
Date: Wed Jun  7 12:17:57 2017
New Revision: 304929

URL: http://llvm.org/viewvc/llvm-project?rev=304929&view=rev
Log:
[mips] Add runtime options to enable/disable madd.fmt and msub.fmt

Add options to clang: -mmadd4 and -mno-madd4, use it to enable or disable
generation of madd.fmt and similar instructions respectively, as per GCC.

Patch by Stefan Maksimovic.

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

Added:
cfe/trunk/test/CodeGen/mips-madd4.c
Modified:
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/lib/Basic/Targets.cpp
cfe/trunk/lib/Driver/ToolChains/Arch/Mips.cpp
cfe/trunk/test/Preprocessor/init.c

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=304929&r1=304928&r2=304929&view=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Wed Jun  7 12:17:57 2017
@@ -2001,6 +2001,10 @@ def mdspr2 : Flag<["-"], "mdspr2">, Grou
 def mno_dspr2 : Flag<["-"], "mno-dspr2">, Group;
 def msingle_float : Flag<["-"], "msingle-float">, Group;
 def mdouble_float : Flag<["-"], "mdouble-float">, Group;
+def mmadd4 : Flag<["-"], "mmadd4">, Group,
+  HelpText<"Enable the generation of 4-operand madd.s, madd.d and related 
instructions.">;
+def mno_madd4 : Flag<["-"], "mno-madd4">, Group,
+  HelpText<"Disable the generation of 4-operand madd.s, madd.d and related 
instructions.">;
 def mmsa : Flag<["-"], "mmsa">, Group,
   HelpText<"Enable MSA ASE (MIPS only)">;
 def mno_msa : Flag<["-"], "mno-msa">, Group,

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=304929&r1=304928&r2=304929&view=diff
==
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Wed Jun  7 12:17:57 2017
@@ -7737,6 +7737,7 @@ class MipsTargetInfo : public TargetInfo
 NoDSP, DSP1, DSP2
   } DspRev;
   bool HasMSA;
+  bool DisableMadd4;
 
 protected:
   bool HasFP64;
@@ -7747,7 +7748,7 @@ public:
   : TargetInfo(Triple), IsMips16(false), IsMicromips(false),
 IsNan2008(false), IsSingleFloat(false), IsNoABICalls(false),
 CanUseBSDABICalls(false), FloatABI(HardFloat), DspRev(NoDSP),
-HasMSA(false), HasFP64(false) {
+HasMSA(false), DisableMadd4(false), HasFP64(false) {
 TheCXXABI.set(TargetCXXABI::GenericMIPS);
 
 setABI((getTriple().getArch() == llvm::Triple::mips ||
@@ -7993,6 +7994,9 @@ public:
 if (HasMSA)
   Builder.defineMacro("__mips_msa", Twine(1));
 
+if (DisableMadd4)
+  Builder.defineMacro("__mips_no_madd4", Twine(1));
+
 Builder.defineMacro("_MIPS_SZPTR", Twine(getPointerWidth(0)));
 Builder.defineMacro("_MIPS_SZINT", Twine(getIntWidth()));
 Builder.defineMacro("_MIPS_SZLONG", Twine(getLongWidth()));
@@ -8155,6 +8159,8 @@ public:
 DspRev = std::max(DspRev, DSP2);
   else if (Feature == "+msa")
 HasMSA = true;
+  else if (Feature == "+nomadd4")
+DisableMadd4 = true;
   else if (Feature == "+fp64")
 HasFP64 = true;
   else if (Feature == "-fp64")

Modified: cfe/trunk/lib/Driver/ToolChains/Arch/Mips.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Arch/Mips.cpp?rev=304929&r1=304928&r2=304929&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Arch/Mips.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Arch/Mips.cpp Wed Jun  7 12:17:57 2017
@@ -298,6 +298,13 @@ void mips::getMIPSTargetFeatures(const D
 
   AddTargetFeature(Args, Features, options::OPT_mno_odd_spreg,
options::OPT_modd_spreg, "nooddspreg");
+
+  if (Arg *A = Args.getLastArg(options::OPT_mmadd4, options::OPT_mno_madd4)) {
+if (A->getOption().matches(options::OPT_mmadd4))
+  Features.push_back("-nomadd4");
+else
+  Features.push_back("+nomadd4");
+  }
 }
 
 mips::NanEncoding mips::getSupportedNanEncoding(StringRef &CPU) {

Added: cfe/trunk/test/CodeGen/mips-madd4.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/mips-madd4.c?rev=304929&view=auto
==
--- cfe/trunk/test/CodeGen/mips-madd4.c (added)
+++ cfe/trunk/test/CodeGen/mips-madd4.c Wed Jun  7 12:17:57 2017
@@ -0,0 +1,86 @@
+// RUN: %clang --target=mips64-unknown-linux -S -mmadd4%s -o -| FileCheck 
%s -check-prefix=MADD4
+// RUN: %clang --target=mips64-unknown-linux -S -mno-madd4 %s -o -| FileCheck 
%s -check-prefix=NOMADD4
+// RUN: %clang --target=mips64-unknown-linux -S -mmadd4-fno-honor-nans %s 
-o -| FileCheck %s -check-prefix=MADD4-NONAN
+// RUN: %clang --target=mips64-unknown-linux -S -mno-madd4 -fno-honor-nans %s 
-o -| FileCheck %

[PATCH] D33401: [mips] Add runtime options to enable/disable generation of madd.fmt, msub.fmt

2017-06-07 Thread Petar Jovanovic via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL304929: [mips] Add runtime options to enable/disable 
madd.fmt and msub.fmt (authored by petarj).

Changed prior to commit:
  https://reviews.llvm.org/D33401?vs=101562&id=101767#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D33401

Files:
  cfe/trunk/include/clang/Driver/Options.td
  cfe/trunk/lib/Basic/Targets.cpp
  cfe/trunk/lib/Driver/ToolChains/Arch/Mips.cpp
  cfe/trunk/test/CodeGen/mips-madd4.c
  cfe/trunk/test/Preprocessor/init.c

Index: cfe/trunk/include/clang/Driver/Options.td
===
--- cfe/trunk/include/clang/Driver/Options.td
+++ cfe/trunk/include/clang/Driver/Options.td
@@ -2001,6 +2001,10 @@
 def mno_dspr2 : Flag<["-"], "mno-dspr2">, Group;
 def msingle_float : Flag<["-"], "msingle-float">, Group;
 def mdouble_float : Flag<["-"], "mdouble-float">, Group;
+def mmadd4 : Flag<["-"], "mmadd4">, Group,
+  HelpText<"Enable the generation of 4-operand madd.s, madd.d and related instructions.">;
+def mno_madd4 : Flag<["-"], "mno-madd4">, Group,
+  HelpText<"Disable the generation of 4-operand madd.s, madd.d and related instructions.">;
 def mmsa : Flag<["-"], "mmsa">, Group,
   HelpText<"Enable MSA ASE (MIPS only)">;
 def mno_msa : Flag<["-"], "mno-msa">, Group,
Index: cfe/trunk/test/Preprocessor/init.c
===
--- cfe/trunk/test/Preprocessor/init.c
+++ cfe/trunk/test/Preprocessor/init.c
@@ -4664,6 +4664,16 @@
 // RUN:   | FileCheck -match-full-lines -check-prefix MIPS-MSA %s
 // MIPS-MSA:#define __mips_msa 1
 //
+// RUN: %clang_cc1 -target-feature +nomadd4 \
+// RUN:   -E -dM -triple=mips-none-none < /dev/null \
+// RUN:   | FileCheck -match-full-lines -check-prefix MIPS-NOMADD4 %s
+// MIPS-NOMADD4:#define __mips_no_madd4 1
+//
+// RUN: %clang_cc1 \
+// RUN:   -E -dM -triple=mips-none-none < /dev/null \
+// RUN:   | FileCheck -match-full-lines -check-prefix MIPS-MADD4 %s
+// MIPS-MADD4-NOT:#define __mips_no_madd4 1
+//
 // RUN: %clang_cc1 -target-cpu mips32r3 -target-feature +nan2008 \
 // RUN:   -E -dM -triple=mips-none-none < /dev/null \
 // RUN:   | FileCheck -match-full-lines -check-prefix MIPS-NAN2008 %s
Index: cfe/trunk/test/CodeGen/mips-madd4.c
===
--- cfe/trunk/test/CodeGen/mips-madd4.c
+++ cfe/trunk/test/CodeGen/mips-madd4.c
@@ -0,0 +1,86 @@
+// RUN: %clang --target=mips64-unknown-linux -S -mmadd4%s -o -| FileCheck %s -check-prefix=MADD4
+// RUN: %clang --target=mips64-unknown-linux -S -mno-madd4 %s -o -| FileCheck %s -check-prefix=NOMADD4
+// RUN: %clang --target=mips64-unknown-linux -S -mmadd4-fno-honor-nans %s -o -| FileCheck %s -check-prefix=MADD4-NONAN
+// RUN: %clang --target=mips64-unknown-linux -S -mno-madd4 -fno-honor-nans %s -o -| FileCheck %s -check-prefix=NOMADD4-NONAN
+ 
+float madd_s (float f, float g, float h)
+{
+  return (f * g) + h;
+}
+// MADD4:   madd.s
+// NOMADD4: mul.s
+// NOMADD4: add.s
+
+float msub_s (float f, float g, float h)
+{
+  return (f * g) - h;
+}
+// MADD4:   msub.s
+// NOMADD4: mul.s
+// NOMADD4: sub.s
+
+double madd_d (double f, double g, double h)
+{
+  return (f * g) + h;
+}
+// MADD4:   madd.d
+// NOMADD4: mul.d
+// NOMADD4: add.d
+
+double msub_d (double f, double g, double h)
+{
+  return (f * g) - h;
+}
+// MADD4:   msub.d
+// NOMADD4: mul.d
+// NOMADD4: sub.d
+
+
+float nmadd_s (float f, float g, float h)
+{
+  // FIXME: Zero has been explicitly placed to force generation of a positive
+  // zero in IR until pattern used to match this instruction is changed to
+  // comply with negative zero as well.
+  return 0-((f * g) + h);
+}
+// MADD4-NONAN:   nmadd.s
+// NOMADD4-NONAN: mul.s
+// NOMADD4-NONAN: add.s
+// NOMADD4-NONAN: sub.s
+
+float nmsub_s (float f, float g, float h)
+{
+  // FIXME: Zero has been explicitly placed to force generation of a positive
+  // zero in IR until pattern used to match this instruction is changed to
+  // comply with negative zero as well.
+  return 0-((f * g) - h);
+}
+// MADD4-NONAN:   nmsub.s
+// NOMADD4-NONAN: mul.s
+// NOMADD4-NONAN: sub.s
+// NOMADD4-NONAN: sub.s
+
+double nmadd_d (double f, double g, double h)
+{
+  // FIXME: Zero has been explicitly placed to force generation of a positive
+  // zero in IR until pattern used to match this instruction is changed to
+  // comply with negative zero as well.
+  return 0-((f * g) + h);
+}
+// MADD4-NONAN:   nmadd.d
+// NOMADD4-NONAN: mul.d
+// NOMADD4-NONAN: add.d
+// NOMADD4-NONAN: sub.d
+
+double nmsub_d (double f, double g, double h)
+{
+  // FIXME: Zero has been explicitly placed to force generation of a positive
+  // zero in IR until pattern used to match this instruction is changed to
+  // comply with negative zero as well.
+  return 0-((f * g) - h);
+}
+// MADD4-NONAN:   nmsub.d
+// NOMADD4-NONAN: mul.d
+// NOMADD4-NONAN: sub.d
+// NOMADD4-NONAN: sub.d
+
Index: cfe/tru

[clang-tools-extra] r304931 - [clang-tidy] When" -fno-exceptions is used", this warning is better to be suppressed.

2017-06-07 Thread Yan Wang via cfe-commits
Author: yawanng
Date: Wed Jun  7 12:41:59 2017
New Revision: 304931

URL: http://llvm.org/viewvc/llvm-project?rev=304931&view=rev
Log:
[clang-tidy]  When" -fno-exceptions is used", this warning is better to be 
suppressed.

Summary: clang-tidy is better not to issues this warning, which checks where 
the initializer for the object may throw an exception, when "-fno-exceptions" 
is used.

Reviewers: chh, aaron.ballman

Reviewed By: aaron.ballman

Subscribers: xazax.hun

Tags: #clang-tools-extra

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

Modified:
clang-tools-extra/trunk/clang-tidy/cert/StaticObjectExceptionCheck.cpp
clang-tools-extra/trunk/test/clang-tidy/cert-static-object-exception.cpp

Modified: clang-tools-extra/trunk/clang-tidy/cert/StaticObjectExceptionCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/cert/StaticObjectExceptionCheck.cpp?rev=304931&r1=304930&r2=304931&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/cert/StaticObjectExceptionCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/cert/StaticObjectExceptionCheck.cpp Wed 
Jun  7 12:41:59 2017
@@ -19,7 +19,7 @@ namespace tidy {
 namespace cert {
 
 void StaticObjectExceptionCheck::registerMatchers(MatchFinder *Finder) {
-  if (!getLangOpts().CPlusPlus)
+  if ((!getLangOpts().CPlusPlus) || (!getLangOpts().CXXExceptions))
 return;
 
   // Match any static or thread_local variable declaration that has an

Modified: 
clang-tools-extra/trunk/test/clang-tidy/cert-static-object-exception.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/cert-static-object-exception.cpp?rev=304931&r1=304930&r2=304931&view=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/cert-static-object-exception.cpp 
(original)
+++ clang-tools-extra/trunk/test/clang-tidy/cert-static-object-exception.cpp 
Wed Jun  7 12:41:59 2017
@@ -1,4 +1,9 @@
-// RUN: %check_clang_tidy %s cert-err58-cpp %t -- -- -std=c++11 -target 
x86_64-pc-linux-gnu
+// RUN: clang-tidy %s -checks="-*,cert-err58-cpp" -- -std=c++11 -target 
x86_64-pc-linux-gnu \
+// RUN:   | FileCheck %s -check-prefix=CHECK-EXCEPTIONS \
+// RUN:   -implicit-check-not="{{warning|error}}:"
+// RUN: clang-tidy %s -checks="-*,cert-err58-cpp" -- -fno-exceptions 
-std=c++11 -target x86_64-pc-linux-gnu \
+// RUN:   | FileCheck %s -allow-empty -check-prefix=CHECK-NONEXCEPTIONS \
+// RUN:   -implicit-check-not="{{warning|error}}:"
 
 struct S {
   S() noexcept(false);
@@ -52,39 +57,49 @@ UserConv_Bad some_bad_func() noexcept;
 UserConv_Good some_good_func() noexcept;
 
 S s;
-// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: initialization of 's' with static 
storage duration may throw an exception that cannot be caught [cert-err58-cpp]
-// CHECK-MESSAGES: 4:3: note: possibly throwing constructor declared here
+// CHECK-EXCEPTIONS: :[[@LINE-1]]:3: warning: initialization of 's' with 
static storage duration may throw an exception that cannot be caught 
[cert-err58-cpp]
+// CHECK-EXCEPTIONS: 9:3: note: possibly throwing constructor declared here
+// CHECK-NONEXCEPTIONS-NOT: warning:
 T t; // ok
 U u;
-// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: initialization of 'u' with static 
storage duration may throw an exception that cannot be caught
-// CHECK-MESSAGES: 12:3: note: possibly throwing constructor declared here
+// CHECK-EXCEPTIONS: :[[@LINE-1]]:3: warning: initialization of 'u' with 
static storage duration may throw an exception that cannot be caught
+// CHECK-EXCEPTIONS: 17:3: note: possibly throwing constructor declared here
+// CHECK-NONEXCEPTIONS-NOT: warning:
 V v("v");
-// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: initialization of 'v' with static 
storage duration may throw an exception that cannot be caught
-// CHECK-MESSAGES: 16:12: note: possibly throwing constructor declared here
+// CHECK-EXCEPTIONS: :[[@LINE-1]]:3: warning: initialization of 'v' with 
static storage duration may throw an exception that cannot be caught
+// CHECK-EXCEPTIONS: 21:12: note: possibly throwing constructor declared here
+// CHECK-NONEXCEPTIONS-NOT: warning:
 W w;
-// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: initialization of 'w' with static 
storage duration may throw an exception that cannot be caught
-// CHECK-MESSAGES: 24:3: note: possibly throwing constructor declared here
+// CHECK-EXCEPTIONS: :[[@LINE-1]]:3: warning: initialization of 'w' with 
static storage duration may throw an exception that cannot be caught
+// CHECK-EXCEPTIONS: 29:3: note: possibly throwing constructor declared here
+// CHECK-NONEXCEPTIONS-NOT: warning:
 X x1(S{});
-// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: initialization of 'x1' with static 
storage duration may throw an exception that cannot be caught
-// CHECK-MESSAGES: 4:3: note: possibly throwing constructor declared here
+// CHECK-EXCEPTIONS: :[[@LINE-1]

[PATCH] D33493: Speed up preamble loading

2017-06-07 Thread Ivan Donchevskii via Phabricator via cfe-commits
yvvan added inline comments.



Comment at: include/clang/Frontend/ASTUnit.h:192
+  /// of that loading
+  std::map SrcLocCache;
+

arphaman wrote:
> You can use an `llvm::StringMap` instead.
I will change that



Comment at: lib/Frontend/ASTUnit.cpp:1152
+  else
+SrcLocCache.clear();
 

arphaman wrote:
> Why is `clear` in an `else` here? We always create a new `SourceManager` in 
> this function, so the previously cached locations will be invalid, so 
> shouldn't we always clear the cache before `TranslateStoredDiagnostics`?
When we load diagnostics that means that preamble has not changed. Doesn't that 
mean that source locations can be reused? What can cause them to become invalid?
When preamble is invalidated - cache is cleared.

I can keep cache only during TranslateStoredDiagnostics calls but in that case 
performance improvement is way less.

But if you say that current solution is invalid I will do that


https://reviews.llvm.org/D33493



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


[PATCH] D34002: [clang-tidy] When" -fno-exceptions is used", this warning is better to be suppressed.

2017-06-07 Thread Chih-Hung Hsieh via Phabricator via cfe-commits
chh added a comment.

LGTM, leave this to alexfh's approval.


Repository:
  rL LLVM

https://reviews.llvm.org/D34002



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


[PATCH] D34002: [clang-tidy] When" -fno-exceptions is used", this warning is better to be suppressed.

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

Aside from one minor nit, LGTM




Comment at: clang-tidy/misc/NoexceptMoveConstructorCheck.cpp:23
   // provide any benefit to other languages, despite being benign.
-  if (!getLangOpts().CPlusPlus11)
+  if ((!getLangOpts().CPlusPlus11) || (!getLangOpts().CXXExceptions))
 return;

You can remove the spurious parens.


Repository:
  rL LLVM

https://reviews.llvm.org/D34002



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


r304935 - Revert r304929 [mips] Add runtime options to enable/disable madd/sub.fmt

2017-06-07 Thread Petar Jovanovic via cfe-commits
Author: petarj
Date: Wed Jun  7 13:57:56 2017
New Revision: 304935

URL: http://llvm.org/viewvc/llvm-project?rev=304935&view=rev
Log:
Revert r304929 [mips] Add runtime options to enable/disable madd/sub.fmt

Revert r304929 since the test broke buildbots.

Original commit:

  [mips] Add runtime options to enable/disable madd.fmt and msub.fmt

  Add options to clang: -mmadd4 and -mno-madd4, use it to enable or disable
  generation of madd.fmt and similar instructions respectively, as per GCC.

  Patch by Stefan Maksimovic.

Modified:
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/lib/Basic/Targets.cpp
cfe/trunk/lib/Driver/ToolChains/Arch/Mips.cpp
cfe/trunk/test/CodeGen/mips-madd4.c
cfe/trunk/test/Preprocessor/init.c

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=304935&r1=304934&r2=304935&view=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Wed Jun  7 13:57:56 2017
@@ -2001,10 +2001,6 @@ def mdspr2 : Flag<["-"], "mdspr2">, Grou
 def mno_dspr2 : Flag<["-"], "mno-dspr2">, Group;
 def msingle_float : Flag<["-"], "msingle-float">, Group;
 def mdouble_float : Flag<["-"], "mdouble-float">, Group;
-def mmadd4 : Flag<["-"], "mmadd4">, Group,
-  HelpText<"Enable the generation of 4-operand madd.s, madd.d and related 
instructions.">;
-def mno_madd4 : Flag<["-"], "mno-madd4">, Group,
-  HelpText<"Disable the generation of 4-operand madd.s, madd.d and related 
instructions.">;
 def mmsa : Flag<["-"], "mmsa">, Group,
   HelpText<"Enable MSA ASE (MIPS only)">;
 def mno_msa : Flag<["-"], "mno-msa">, Group,

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=304935&r1=304934&r2=304935&view=diff
==
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Wed Jun  7 13:57:56 2017
@@ -7737,7 +7737,6 @@ class MipsTargetInfo : public TargetInfo
 NoDSP, DSP1, DSP2
   } DspRev;
   bool HasMSA;
-  bool DisableMadd4;
 
 protected:
   bool HasFP64;
@@ -7748,7 +7747,7 @@ public:
   : TargetInfo(Triple), IsMips16(false), IsMicromips(false),
 IsNan2008(false), IsSingleFloat(false), IsNoABICalls(false),
 CanUseBSDABICalls(false), FloatABI(HardFloat), DspRev(NoDSP),
-HasMSA(false), DisableMadd4(false), HasFP64(false) {
+HasMSA(false), HasFP64(false) {
 TheCXXABI.set(TargetCXXABI::GenericMIPS);
 
 setABI((getTriple().getArch() == llvm::Triple::mips ||
@@ -7994,9 +7993,6 @@ public:
 if (HasMSA)
   Builder.defineMacro("__mips_msa", Twine(1));
 
-if (DisableMadd4)
-  Builder.defineMacro("__mips_no_madd4", Twine(1));
-
 Builder.defineMacro("_MIPS_SZPTR", Twine(getPointerWidth(0)));
 Builder.defineMacro("_MIPS_SZINT", Twine(getIntWidth()));
 Builder.defineMacro("_MIPS_SZLONG", Twine(getLongWidth()));
@@ -8159,8 +8155,6 @@ public:
 DspRev = std::max(DspRev, DSP2);
   else if (Feature == "+msa")
 HasMSA = true;
-  else if (Feature == "+nomadd4")
-DisableMadd4 = true;
   else if (Feature == "+fp64")
 HasFP64 = true;
   else if (Feature == "-fp64")

Modified: cfe/trunk/lib/Driver/ToolChains/Arch/Mips.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Arch/Mips.cpp?rev=304935&r1=304934&r2=304935&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Arch/Mips.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Arch/Mips.cpp Wed Jun  7 13:57:56 2017
@@ -298,13 +298,6 @@ void mips::getMIPSTargetFeatures(const D
 
   AddTargetFeature(Args, Features, options::OPT_mno_odd_spreg,
options::OPT_modd_spreg, "nooddspreg");
-
-  if (Arg *A = Args.getLastArg(options::OPT_mmadd4, options::OPT_mno_madd4)) {
-if (A->getOption().matches(options::OPT_mmadd4))
-  Features.push_back("-nomadd4");
-else
-  Features.push_back("+nomadd4");
-  }
 }
 
 mips::NanEncoding mips::getSupportedNanEncoding(StringRef &CPU) {

Modified: cfe/trunk/test/CodeGen/mips-madd4.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/mips-madd4.c?rev=304935&r1=304934&r2=304935&view=diff
==
--- cfe/trunk/test/CodeGen/mips-madd4.c (original)
+++ cfe/trunk/test/CodeGen/mips-madd4.c Wed Jun  7 13:57:56 2017
@@ -1,86 +0,0 @@
-// RUN: %clang --target=mips64-unknown-linux -S -mmadd4%s -o -| FileCheck 
%s -check-prefix=MADD4
-// RUN: %clang --target=mips64-unknown-linux -S -mno-madd4 %s -o -| FileCheck 
%s -check-prefix=NOMADD4
-// RUN: %clang --target=mips64-unknown-linux -S -mmadd4-fno-honor-nans %s 
-o -| FileCheck %s -check-prefi

[PATCH] D33478: [libclang] When getting platform availabilities, merge multiple declarations if possible

2017-06-07 Thread Ronald Wampler via Phabricator via cfe-commits
rdwampler updated this revision to Diff 101787.
rdwampler marked 6 inline comments as done.
rdwampler added a comment.

This should resolve the bug (a conditional was inverted) in the last revision 
along with the other changes requested.


https://reviews.llvm.org/D33478

Files:
  test/Index/availability.c
  tools/libclang/CIndex.cpp

Index: tools/libclang/CIndex.cpp
===
--- tools/libclang/CIndex.cpp
+++ tools/libclang/CIndex.cpp
@@ -7200,15 +7200,11 @@
   return Out;
 }
 
-static int getCursorPlatformAvailabilityForDecl(const Decl *D,
-int *always_deprecated,
-CXString *deprecated_message,
-int *always_unavailable,
-CXString *unavailable_message,
-   CXPlatformAvailability *availability,
-int availability_size) {
+static void getCursorPlatformAvailabilityForDecl(
+const Decl *D, int *always_deprecated, CXString *deprecated_message,
+int *always_unavailable, CXString *unavailable_message,
+SmallVectorImpl &AvailabilityAttrs) {
   bool HadAvailAttr = false;
-  int N = 0;
   for (auto A : D->attrs()) {
 if (DeprecatedAttr *Deprecated = dyn_cast(A)) {
   HadAvailAttr = true;
@@ -7220,7 +7216,7 @@
   }
   continue;
 }
-
+
 if (UnavailableAttr *Unavailable = dyn_cast(A)) {
   HadAvailAttr = true;
   if (always_unavailable)
@@ -7231,38 +7227,72 @@
   }
   continue;
 }
-
+
 if (AvailabilityAttr *Avail = dyn_cast(A)) {
+  AvailabilityAttrs.push_back(Avail);
   HadAvailAttr = true;
-  if (N < availability_size) {
-availability[N].Platform
-  = cxstring::createDup(Avail->getPlatform()->getName());
-availability[N].Introduced = convertVersion(Avail->getIntroduced());
-availability[N].Deprecated = convertVersion(Avail->getDeprecated());
-availability[N].Obsoleted = convertVersion(Avail->getObsoleted());
-availability[N].Unavailable = Avail->getUnavailable();
-availability[N].Message = cxstring::createDup(Avail->getMessage());
-  }
-  ++N;
 }
   }
 
   if (!HadAvailAttr)
 if (const EnumConstantDecl *EnumConst = dyn_cast(D))
   return getCursorPlatformAvailabilityForDecl(
-cast(EnumConst->getDeclContext()),
-  always_deprecated,
-  deprecated_message,
-  always_unavailable,
-  unavailable_message,
-  availability,
-  availability_size);
-  
-  return N;
+  cast(EnumConst->getDeclContext()), always_deprecated,
+  deprecated_message, always_unavailable, unavailable_message,
+  AvailabilityAttrs);
+
+  if (AvailabilityAttrs.empty())
+return;
+
+  std::sort(AvailabilityAttrs.begin(), AvailabilityAttrs.end(),
+[](AvailabilityAttr *LHS, AvailabilityAttr *RHS) {
+  return LHS->getPlatform() > RHS->getPlatform();
+});
+  ASTContext &Ctx = D->getASTContext();
+  auto It = std::unique(
+  AvailabilityAttrs.begin(), AvailabilityAttrs.end(),
+  [&Ctx](AvailabilityAttr *LHS, AvailabilityAttr *RHS) {
+if (LHS->getPlatform() != RHS->getPlatform())
+  return false;
+
+if (LHS->getIntroduced() == RHS->getIntroduced() &&
+LHS->getDeprecated() == RHS->getDeprecated() &&
+LHS->getObsoleted() == RHS->getObsoleted() &&
+LHS->getMessage() == RHS->getMessage() &&
+LHS->getReplacement() == RHS->getReplacement())
+  return true;
+
+if ((!LHS->getIntroduced().empty() && !RHS->getIntroduced().empty()) ||
+(!LHS->getDeprecated().empty() && !RHS->getDeprecated().empty()) ||
+(!LHS->getObsoleted().empty() && !RHS->getObsoleted().empty()) ||
+(!LHS->getMessage().empty() && !RHS->getMessage().empty()))
+  return false;
+
+if (LHS->getIntroduced().empty() && !RHS->getIntroduced().empty())
+  LHS->setIntroduced(Ctx, RHS->getIntroduced());
+
+if (LHS->getDeprecated().empty() && !RHS->getDeprecated().empty()) {
+  LHS->setDeprecated(Ctx, RHS->getDeprecated());
+  if (LHS->getMessage().empty())
+LHS->setMessage(Ctx, RHS->getMessage());
+  if (LHS->getReplacement().empty())
+LHS->setReplacement(Ctx, RHS->getReplacement());
+}
+
+if (LHS->getObsoleted().empty() && !RHS->getObsoleted().empty()) {
+  LHS->setObsoleted(Ctx, RHS->getObsoleted());
+

[PATCH] D34007: Implement inclusive_scan and transform_inclusive_scan

2017-06-07 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists created this revision.

Like https://reviews.llvm.org/D33997, this implements the non-parallel versions 
of these algorithms

https://reviews.llvm.org/D33997 implemented `reduce` and `transform_reduce`, 
this adds `inclusive_scan` and `transform_inclusive_scan`.

There will be another patch that adds `exclusive_scan` and 
`transform_exclusive_scan`


https://reviews.llvm.org/D34007

Files:
  include/numeric
  
test/std/numerics/numeric.ops/inclusive.scan/inclusive_scan_iter_iter_iter.pass.cpp
  
test/std/numerics/numeric.ops/inclusive.scan/inclusive_scan_iter_iter_iter_op.pass.cpp
  
test/std/numerics/numeric.ops/inclusive.scan/inclusive_scan_iter_iter_iter_op_init.pass.cpp
  
test/std/numerics/numeric.ops/transform.inclusive.scan/transform_inclusive_scan_iter_iter_iter_bop_uop.pass.cpp
  
test/std/numerics/numeric.ops/transform.inclusive.scan/transform_inclusive_scan_iter_iter_iter_bop_uop_init.pass.cpp

Index: test/std/numerics/numeric.ops/transform.inclusive.scan/transform_inclusive_scan_iter_iter_iter_bop_uop_init.pass.cpp
===
--- test/std/numerics/numeric.ops/transform.inclusive.scan/transform_inclusive_scan_iter_iter_iter_bop_uop_init.pass.cpp
+++ test/std/numerics/numeric.ops/transform.inclusive.scan/transform_inclusive_scan_iter_iter_iter_bop_uop_init.pass.cpp
@@ -0,0 +1,101 @@
+//===--===//
+//
+// 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
+
+// template
+//   OutputIterator transform_inclusive_scan(InputIterator first, InputIterator last,
+//   OutputIterator result,
+//   BinaryOperation binary_op,
+//   UnaryOperation unary_op, T init);
+
+
+#include 
+#include 
+#include 
+// #include 
+
+#include "test_iterators.h"
+
+template 
+struct identity : std::unary_function<_Tp, _Tp>
+{
+constexpr const _Tp& operator()(const _Tp& __x) const { return __x;}
+};
+
+template <>
+struct identity
+{
+template 
+constexpr auto operator()(_Tp&& __x) const
+_NOEXCEPT_(noexcept(_VSTD::forward<_Tp>(__x)))
+-> decltype(_VSTD::forward<_Tp>(__x))
+{ return_VSTD::forward<_Tp>(__x); }
+};
+
+template 
+void
+test(Iter1 first, Iter1 last, BOp bop, UOp uop, T init, Iter2 rFirst, Iter2 rLast)
+{
+	std::vector::value_type> v;
+	std::transform_inclusive_scan(first, last, std::back_inserter(v), bop, uop, init);
+// 	std::cout << v.size() << " vs " << std::distance(rFirst, rLast) << std::endl;
+// 	std::copy(v.begin(), v.end(), std::ostream_iterator(std::cout, " "));
+// 	std::cout << std::endl;
+	assert(std::equal(v.begin(), v.end(), rFirst, rLast));
+}
+
+
+template 
+void
+test()
+{
+  int ia[] = { 1,  3,   5,   7, 9};
+const int pResI0[] = { 0,  1,  4,   9,  16,25};		// with identity
+const int mResI0[] = { 0,  0,  0,   0,   0, 0};		
+const int pResN0[] = { 0, -1, -4,  -9, -16,   -25};		// with negate
+const int mResN0[] = { 0,  0,  0,   0,   0, 0};
+const int pResI2[] = { 2,  3,  6,  11,  18,27};		// with identity
+const int mResI2[] = { 2,  2,  6,  30, 210,  1890};		
+const int pResN2[] = { 2,  1, -2,  -7, -14,   -23};		// with negate
+const int mResN2[] = { 2, -2,  6, -30, 210, -1890};
+unsigned sa = sizeof(ia) / sizeof(ia[0]);
+assert(sa + 1 == sizeof(pResI0) / sizeof(pResI0[0]));   // just to be sure
+assert(sa + 1 == sizeof(mResI0) / sizeof(mResI0[0]));   // just to be sure
+assert(sa + 1 == sizeof(pResN0) / sizeof(pResN0[0]));   // just to be sure
+assert(sa + 1 == sizeof(mResN0) / sizeof(mResN0[0]));   // just to be sure
+assert(sa + 1 == sizeof(pResI2) / sizeof(pResI2[0]));   // just to be sure
+assert(sa + 1 == sizeof(mResI2) / sizeof(mResI2[0]));   // just to be sure
+assert(sa + 1 == sizeof(pResN2) / sizeof(pResN2[0]));   // just to be sure
+assert(sa + 1 == sizeof(mResN2) / sizeof(mResN2[0]));   // just to be sure
+
+	for (unsigned int i = 0; i < sa; ++i ) {
+	test(Iter(ia), Iter(ia + i), std::plus<>(),   identity<>(),0, pResI0, pResI0 + i + 1);
+	test(Iter(ia), Iter(ia + i), std::multiplies<>(), identity<>(),0, mResI0, mResI0 + i + 1);
+	test(Iter(ia), Iter(ia + i), std::plus<>(),   std::negate<>(), 0, pResN0, pResN0 + i + 1);
+	test(Iter(ia), Iter(ia + i), std::multiplies<>(), std::negate<>(), 0, mResN0, mResN0 + i + 1);
+	test(Iter(ia), Iter(ia + i), std::plus<>(),   identity<>(),2, pResI2, pResI2 + i + 1);
+	test(Iter(ia), Iter(ia + i), std::

[PATCH] D20693: [clang-tidy] New checker to replace dynamic exception specifications

2017-06-07 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added a comment.

In https://reviews.llvm.org/D20693#775197, @hintonda wrote:

> I have not, as yet, been able to reproduce the buildbot failures.  They were 
> essentially intermittent seg-faults, and corrupt diag output.
>
> I will work on creating a test that can reproduce the problem.


As I said, we could re-submit the patch (without speculative fixes) and see 
whether the buildbots break again. One more suggestion is to run the tests with 
asan. Have you tried this?


https://reviews.llvm.org/D20693



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


[PATCH] D33841: [clang-tidy] redundant keyword check

2017-06-07 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh requested changes to this revision.
alexfh added inline comments.
This revision now requires changes to proceed.



Comment at: docs/clang-tidy/checks/readability-redundant-keyword.rst:8
+
+`extern` is redundant in function declarations
+

Could you explain, why you think `extern` is redundant in function declarations?


Repository:
  rL LLVM

https://reviews.llvm.org/D33841



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


Re: r304935 - Revert r304929 [mips] Add runtime options to enable/disable madd/sub.fmt

2017-06-07 Thread Evgenii Stepanov via cfe-commits
You've left an empty file in test/CodeGen/mips-madd4.c

On Wed, Jun 7, 2017 at 11:57 AM, Petar Jovanovic via cfe-commits
 wrote:
> Author: petarj
> Date: Wed Jun  7 13:57:56 2017
> New Revision: 304935
>
> URL: http://llvm.org/viewvc/llvm-project?rev=304935&view=rev
> Log:
> Revert r304929 [mips] Add runtime options to enable/disable madd/sub.fmt
>
> Revert r304929 since the test broke buildbots.
>
> Original commit:
>
>   [mips] Add runtime options to enable/disable madd.fmt and msub.fmt
>
>   Add options to clang: -mmadd4 and -mno-madd4, use it to enable or disable
>   generation of madd.fmt and similar instructions respectively, as per GCC.
>
>   Patch by Stefan Maksimovic.
>
> Modified:
> cfe/trunk/include/clang/Driver/Options.td
> cfe/trunk/lib/Basic/Targets.cpp
> cfe/trunk/lib/Driver/ToolChains/Arch/Mips.cpp
> cfe/trunk/test/CodeGen/mips-madd4.c
> cfe/trunk/test/Preprocessor/init.c
>
> Modified: cfe/trunk/include/clang/Driver/Options.td
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=304935&r1=304934&r2=304935&view=diff
> ==
> --- cfe/trunk/include/clang/Driver/Options.td (original)
> +++ cfe/trunk/include/clang/Driver/Options.td Wed Jun  7 13:57:56 2017
> @@ -2001,10 +2001,6 @@ def mdspr2 : Flag<["-"], "mdspr2">, Grou
>  def mno_dspr2 : Flag<["-"], "mno-dspr2">, Group;
>  def msingle_float : Flag<["-"], "msingle-float">, Group;
>  def mdouble_float : Flag<["-"], "mdouble-float">, Group;
> -def mmadd4 : Flag<["-"], "mmadd4">, Group,
> -  HelpText<"Enable the generation of 4-operand madd.s, madd.d and related 
> instructions.">;
> -def mno_madd4 : Flag<["-"], "mno-madd4">, Group,
> -  HelpText<"Disable the generation of 4-operand madd.s, madd.d and related 
> instructions.">;
>  def mmsa : Flag<["-"], "mmsa">, Group,
>HelpText<"Enable MSA ASE (MIPS only)">;
>  def mno_msa : Flag<["-"], "mno-msa">, Group,
>
> Modified: cfe/trunk/lib/Basic/Targets.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=304935&r1=304934&r2=304935&view=diff
> ==
> --- cfe/trunk/lib/Basic/Targets.cpp (original)
> +++ cfe/trunk/lib/Basic/Targets.cpp Wed Jun  7 13:57:56 2017
> @@ -7737,7 +7737,6 @@ class MipsTargetInfo : public TargetInfo
>  NoDSP, DSP1, DSP2
>} DspRev;
>bool HasMSA;
> -  bool DisableMadd4;
>
>  protected:
>bool HasFP64;
> @@ -7748,7 +7747,7 @@ public:
>: TargetInfo(Triple), IsMips16(false), IsMicromips(false),
>  IsNan2008(false), IsSingleFloat(false), IsNoABICalls(false),
>  CanUseBSDABICalls(false), FloatABI(HardFloat), DspRev(NoDSP),
> -HasMSA(false), DisableMadd4(false), HasFP64(false) {
> +HasMSA(false), HasFP64(false) {
>  TheCXXABI.set(TargetCXXABI::GenericMIPS);
>
>  setABI((getTriple().getArch() == llvm::Triple::mips ||
> @@ -7994,9 +7993,6 @@ public:
>  if (HasMSA)
>Builder.defineMacro("__mips_msa", Twine(1));
>
> -if (DisableMadd4)
> -  Builder.defineMacro("__mips_no_madd4", Twine(1));
> -
>  Builder.defineMacro("_MIPS_SZPTR", Twine(getPointerWidth(0)));
>  Builder.defineMacro("_MIPS_SZINT", Twine(getIntWidth()));
>  Builder.defineMacro("_MIPS_SZLONG", Twine(getLongWidth()));
> @@ -8159,8 +8155,6 @@ public:
>  DspRev = std::max(DspRev, DSP2);
>else if (Feature == "+msa")
>  HasMSA = true;
> -  else if (Feature == "+nomadd4")
> -DisableMadd4 = true;
>else if (Feature == "+fp64")
>  HasFP64 = true;
>else if (Feature == "-fp64")
>
> Modified: cfe/trunk/lib/Driver/ToolChains/Arch/Mips.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Arch/Mips.cpp?rev=304935&r1=304934&r2=304935&view=diff
> ==
> --- cfe/trunk/lib/Driver/ToolChains/Arch/Mips.cpp (original)
> +++ cfe/trunk/lib/Driver/ToolChains/Arch/Mips.cpp Wed Jun  7 13:57:56 2017
> @@ -298,13 +298,6 @@ void mips::getMIPSTargetFeatures(const D
>
>AddTargetFeature(Args, Features, options::OPT_mno_odd_spreg,
> options::OPT_modd_spreg, "nooddspreg");
> -
> -  if (Arg *A = Args.getLastArg(options::OPT_mmadd4, options::OPT_mno_madd4)) 
> {
> -if (A->getOption().matches(options::OPT_mmadd4))
> -  Features.push_back("-nomadd4");
> -else
> -  Features.push_back("+nomadd4");
> -  }
>  }
>
>  mips::NanEncoding mips::getSupportedNanEncoding(StringRef &CPU) {
>
> Modified: cfe/trunk/test/CodeGen/mips-madd4.c
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/mips-madd4.c?rev=304935&r1=304934&r2=304935&view=diff
> ==
> --- cfe/trunk/test/CodeGen/mips-madd4.c (original)
> +++ cfe/trunk/test/CodeGen/mips-madd4.c Wed Jun  7 13:57:5

[PATCH] D34010: clang-format: Add --cached option to format index

2017-06-07 Thread Kevin Locke via Phabricator via cfe-commits
kevinoid created this revision.

Add --cached option to git-clang-format which behaves analogously to the
use of --cached for other git subcommands, by causing the operation to
work against the index state rather than the working directory state.

This can be particularly useful for hook scripts which need to check or
change the formatting of the index state before commit.

Patch by Kevin Locke.


https://reviews.llvm.org/D34010

Files:
  tools/clang-format/git-clang-format

Index: tools/clang-format/git-clang-format
===
--- tools/clang-format/git-clang-format
+++ tools/clang-format/git-clang-format
@@ -92,6 +92,8 @@
   p.add_argument('--binary',
  default=config.get('clangformat.binary', 'clang-format'),
  help='path to clang-format'),
+  p.add_argument('--cached', action='store_true',
+ help='format index instead of working directory'),
   p.add_argument('--commit',
  default=config.get('clangformat.commit', 'HEAD'),
  help='default commit to use if none is specified'),
@@ -129,10 +131,12 @@
   if len(commits) > 1:
 if not opts.diff:
   die('--diff is required when two commits are given')
+if opts.cached:
+  die('--cached is not applicable when two commits are given')
   else:
 if len(commits) > 2:
   die('at most two commits allowed; %d given' % len(commits))
-  changed_lines = compute_diff_and_extract_lines(commits, files)
+  changed_lines = compute_diff_and_extract_lines(commits, files, opts.cached)
   if opts.verbose >= 1:
 ignored_files = set(changed_lines)
   filter_by_extension(changed_lines, opts.extensions.lower().split(','))
@@ -154,15 +158,17 @@
   cd_to_toplevel()
   if len(commits) > 1:
 old_tree = commits[1]
-new_tree = run_clang_format_and_save_to_tree(changed_lines,
- revision=commits[1],
- binary=opts.binary,
- style=opts.style)
+fmt_tree = commits[1]
+  elif opts.cached:
+old_tree = run('git', 'write-tree')
+fmt_tree = old_tree
   else:
 old_tree = create_tree_from_workdir(changed_lines)
-new_tree = run_clang_format_and_save_to_tree(changed_lines,
- binary=opts.binary,
- style=opts.style)
+fmt_tree = None
+  new_tree = run_clang_format_and_save_to_tree(changed_lines,
+   revision=fmt_tree,
+   binary=opts.binary,
+   style=opts.style)
   if opts.verbose >= 1:
 print('old tree: %s' % old_tree)
 print('new tree: %s' % new_tree)
@@ -173,7 +179,7 @@
 print_diff(old_tree, new_tree)
   else:
 changed_files = apply_changes(old_tree, new_tree, force=opts.force,
-  patch_mode=opts.patch)
+  patch_mode=opts.patch, cached=opts.cached)
 if (opts.verbose >= 0 and not opts.patch) or opts.verbose >= 1:
   print('changed files:')
   for filename in changed_files:
@@ -261,9 +267,9 @@
   return convert_string(stdout.strip())
 
 
-def compute_diff_and_extract_lines(commits, files):
+def compute_diff_and_extract_lines(commits, files, cached=False):
   """Calls compute_diff() followed by extract_lines()."""
-  diff_process = compute_diff(commits, files)
+  diff_process = compute_diff(commits, files, cached)
   changed_lines = extract_lines(diff_process.stdout)
   diff_process.stdout.close()
   diff_process.wait()
@@ -273,7 +279,7 @@
   return changed_lines
 
 
-def compute_diff(commits, files):
+def compute_diff(commits, files, cached=False):
   """Return a subprocess object producing the diff from `commits`.
 
   The return value's `stdin` file object will produce a patch with the
@@ -283,7 +289,11 @@
   git_tool = 'diff-index'
   if len(commits) > 1:
 git_tool = 'diff-tree'
-  cmd = ['git', git_tool, '-p', '-U0'] + commits + ['--']
+  cmd = ['git', git_tool, '-p', '-U0']
+  if cached:
+cmd.append('--cached')
+  cmd.extend(commits)
+  cmd.append('--')
   cmd.extend(files)
   p = subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE)
   p.stdin.close()
@@ -487,23 +497,43 @@
  '--'])
 
 
-def apply_changes(old_tree, new_tree, force=False, patch_mode=False):
-  """Apply the changes in `new_tree` to the working directory.
+def apply_changes(old_tree, new_tree, force=False, patch_mode=False,
+  cached=False):
+  """Apply the changes in `new_tree` to the working directory or index.
 
   Bails if there are local changes in those files and not `force`.  If
-  `patch_mode`, runs `git checkout --patch` to select hunks interactively."""
+  `patch_mode`, adds `--patch` option to select hunks interactiv

[PATCH] D34010: clang-format: Add --cached option to format index

2017-06-07 Thread Kevin Locke via Phabricator via cfe-commits
kevinoid abandoned this revision.
kevinoid added a comment.

Meant to update diff for https://reviews.llvm.org/D33944.  My mistake.  Closing.


https://reviews.llvm.org/D34010



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


[PATCH] D33944: git-clang-format: Add --cached option to format index

2017-06-07 Thread Kevin Locke via Phabricator via cfe-commits
kevinoid updated this revision to Diff 101799.
kevinoid added a comment.

Fixed handling of case when no formatting changes are made but `old_tree != 
new_tree` in `apply_changes`.


https://reviews.llvm.org/D33944

Files:
  tools/clang-format/git-clang-format

Index: tools/clang-format/git-clang-format
===
--- tools/clang-format/git-clang-format
+++ tools/clang-format/git-clang-format
@@ -92,6 +92,8 @@
   p.add_argument('--binary',
  default=config.get('clangformat.binary', 'clang-format'),
  help='path to clang-format'),
+  p.add_argument('--cached', action='store_true',
+ help='format index instead of working directory'),
   p.add_argument('--commit',
  default=config.get('clangformat.commit', 'HEAD'),
  help='default commit to use if none is specified'),
@@ -129,10 +131,12 @@
   if len(commits) > 1:
 if not opts.diff:
   die('--diff is required when two commits are given')
+if opts.cached:
+  die('--cached is not applicable when two commits are given')
   else:
 if len(commits) > 2:
   die('at most two commits allowed; %d given' % len(commits))
-  changed_lines = compute_diff_and_extract_lines(commits, files)
+  changed_lines = compute_diff_and_extract_lines(commits, files, opts.cached)
   if opts.verbose >= 1:
 ignored_files = set(changed_lines)
   filter_by_extension(changed_lines, opts.extensions.lower().split(','))
@@ -154,15 +158,17 @@
   cd_to_toplevel()
   if len(commits) > 1:
 old_tree = commits[1]
-new_tree = run_clang_format_and_save_to_tree(changed_lines,
- revision=commits[1],
- binary=opts.binary,
- style=opts.style)
+fmt_tree = commits[1]
+  elif opts.cached:
+old_tree = run('git', 'write-tree')
+fmt_tree = old_tree
   else:
 old_tree = create_tree_from_workdir(changed_lines)
-new_tree = run_clang_format_and_save_to_tree(changed_lines,
- binary=opts.binary,
- style=opts.style)
+fmt_tree = None
+  new_tree = run_clang_format_and_save_to_tree(changed_lines,
+   revision=fmt_tree,
+   binary=opts.binary,
+   style=opts.style)
   if opts.verbose >= 1:
 print('old tree: %s' % old_tree)
 print('new tree: %s' % new_tree)
@@ -173,7 +179,7 @@
 print_diff(old_tree, new_tree)
   else:
 changed_files = apply_changes(old_tree, new_tree, force=opts.force,
-  patch_mode=opts.patch)
+  patch_mode=opts.patch, cached=opts.cached)
 if (opts.verbose >= 0 and not opts.patch) or opts.verbose >= 1:
   print('changed files:')
   for filename in changed_files:
@@ -261,9 +267,9 @@
   return convert_string(stdout.strip())
 
 
-def compute_diff_and_extract_lines(commits, files):
+def compute_diff_and_extract_lines(commits, files, cached=False):
   """Calls compute_diff() followed by extract_lines()."""
-  diff_process = compute_diff(commits, files)
+  diff_process = compute_diff(commits, files, cached)
   changed_lines = extract_lines(diff_process.stdout)
   diff_process.stdout.close()
   diff_process.wait()
@@ -273,7 +279,7 @@
   return changed_lines
 
 
-def compute_diff(commits, files):
+def compute_diff(commits, files, cached=False):
   """Return a subprocess object producing the diff from `commits`.
 
   The return value's `stdin` file object will produce a patch with the
@@ -283,7 +289,11 @@
   git_tool = 'diff-index'
   if len(commits) > 1:
 git_tool = 'diff-tree'
-  cmd = ['git', git_tool, '-p', '-U0'] + commits + ['--']
+  cmd = ['git', git_tool, '-p', '-U0']
+  if cached:
+cmd.append('--cached')
+  cmd.extend(commits)
+  cmd.append('--')
   cmd.extend(files)
   p = subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE)
   p.stdin.close()
@@ -487,23 +497,43 @@
  '--'])
 
 
-def apply_changes(old_tree, new_tree, force=False, patch_mode=False):
-  """Apply the changes in `new_tree` to the working directory.
+def apply_changes(old_tree, new_tree, force=False, patch_mode=False,
+  cached=False):
+  """Apply the changes in `new_tree` to the working directory or index.
 
   Bails if there are local changes in those files and not `force`.  If
-  `patch_mode`, runs `git checkout --patch` to select hunks interactively."""
+  `patch_mode`, adds `--patch` option to select hunks interactively."""
   changed_files = run('git', 'diff-tree', '--diff-filter=M', '-r', '-z',
   '--name-only', old_tree,
   new_tree).rstrip('\0').split('\0')
+  if changed_files == ['']:
+

r304936 - Finish revert of "r304929, [mips] Add runtime options to enable/disable madd/sub.fmt"

2017-06-07 Thread Simon Dardis via cfe-commits
Author: sdardis
Date: Wed Jun  7 15:02:24 2017
New Revision: 304936

URL: http://llvm.org/viewvc/llvm-project?rev=304936&view=rev
Log:
Finish revert of "r304929, [mips] Add runtime options to enable/disable 
madd/sub.fmt"

The r304935 missed deleting the test case.


Removed:
cfe/trunk/test/CodeGen/mips-madd4.c

Removed: cfe/trunk/test/CodeGen/mips-madd4.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/mips-madd4.c?rev=304935&view=auto
==
(empty)


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


[PATCH] D34007: Implement inclusive_scan and transform_inclusive_scan

2017-06-07 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists added a comment.

Re-reading this, I may have implemented `exclusive_scan` instead of 
`inclusive_scan` here.


https://reviews.llvm.org/D34007



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


[PATCH] D33493: Speed up preamble loading

2017-06-07 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added inline comments.



Comment at: lib/Frontend/ASTUnit.cpp:1152
+  else
+SrcLocCache.clear();
 

yvvan wrote:
> arphaman wrote:
> > Why is `clear` in an `else` here? We always create a new `SourceManager` in 
> > this function, so the previously cached locations will be invalid, so 
> > shouldn't we always clear the cache before `TranslateStoredDiagnostics`?
> When we load diagnostics that means that preamble has not changed. Doesn't 
> that mean that source locations can be reused? What can cause them to become 
> invalid?
> When preamble is invalidated - cache is cleared.
> 
> I can keep cache only during TranslateStoredDiagnostics calls but in that 
> case performance improvement is way less.
> 
> But if you say that current solution is invalid I will do that
You're right actually, we can reuse them. We already do make that assumption 
that the preamble's source locations can be reused in `checkAndSanitizeDiags`. 
This code is fine then, sorry about the confusion.

You should mention in the comment for the `SrcLocCache` that we cache only the 
source locations from the preamble as we can guarantee that they will stay 
valid when the source manager is re-created.



https://reviews.llvm.org/D33493



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


RE: r304935 - Revert r304929 [mips] Add runtime options to enable/disable madd/sub.fmt

2017-06-07 Thread Simon Dardis via cfe-commits
Appears to be fixed, r304936. I'll keep an eye on the buildbots.

Thanks,
Simon

From: cfe-commits [cfe-commits-boun...@lists.llvm.org] on behalf of Evgenii 
Stepanov via cfe-commits [cfe-commits@lists.llvm.org]
Sent: 07 June 2017 20:53
To: Petar Jovanovic
Cc: cfe-commits
Subject: Re: r304935 - Revert r304929 [mips] Add runtime options to 
enable/disable madd/sub.fmt

You've left an empty file in test/CodeGen/mips-madd4.c

On Wed, Jun 7, 2017 at 11:57 AM, Petar Jovanovic via cfe-commits
 wrote:
> Author: petarj
> Date: Wed Jun  7 13:57:56 2017
> New Revision: 304935
>
> URL: http://llvm.org/viewvc/llvm-project?rev=304935&view=rev
> Log:
> Revert r304929 [mips] Add runtime options to enable/disable madd/sub.fmt
>
> Revert r304929 since the test broke buildbots.
>
> Original commit:
>
>   [mips] Add runtime options to enable/disable madd.fmt and msub.fmt
>
>   Add options to clang: -mmadd4 and -mno-madd4, use it to enable or disable
>   generation of madd.fmt and similar instructions respectively, as per GCC.
>
>   Patch by Stefan Maksimovic.
>
> Modified:
> cfe/trunk/include/clang/Driver/Options.td
> cfe/trunk/lib/Basic/Targets.cpp
> cfe/trunk/lib/Driver/ToolChains/Arch/Mips.cpp
> cfe/trunk/test/CodeGen/mips-madd4.c
> cfe/trunk/test/Preprocessor/init.c
>
> Modified: cfe/trunk/include/clang/Driver/Options.td
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=304935&r1=304934&r2=304935&view=diff
> ==
> --- cfe/trunk/include/clang/Driver/Options.td (original)
> +++ cfe/trunk/include/clang/Driver/Options.td Wed Jun  7 13:57:56 2017
> @@ -2001,10 +2001,6 @@ def mdspr2 : Flag<["-"], "mdspr2">, Grou
>  def mno_dspr2 : Flag<["-"], "mno-dspr2">, Group;
>  def msingle_float : Flag<["-"], "msingle-float">, Group;
>  def mdouble_float : Flag<["-"], "mdouble-float">, Group;
> -def mmadd4 : Flag<["-"], "mmadd4">, Group,
> -  HelpText<"Enable the generation of 4-operand madd.s, madd.d and related 
> instructions.">;
> -def mno_madd4 : Flag<["-"], "mno-madd4">, Group,
> -  HelpText<"Disable the generation of 4-operand madd.s, madd.d and related 
> instructions.">;
>  def mmsa : Flag<["-"], "mmsa">, Group,
>HelpText<"Enable MSA ASE (MIPS only)">;
>  def mno_msa : Flag<["-"], "mno-msa">, Group,
>
> Modified: cfe/trunk/lib/Basic/Targets.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=304935&r1=304934&r2=304935&view=diff
> ==
> --- cfe/trunk/lib/Basic/Targets.cpp (original)
> +++ cfe/trunk/lib/Basic/Targets.cpp Wed Jun  7 13:57:56 2017
> @@ -7737,7 +7737,6 @@ class MipsTargetInfo : public TargetInfo
>  NoDSP, DSP1, DSP2
>} DspRev;
>bool HasMSA;
> -  bool DisableMadd4;
>
>  protected:
>bool HasFP64;
> @@ -7748,7 +7747,7 @@ public:
>: TargetInfo(Triple), IsMips16(false), IsMicromips(false),
>  IsNan2008(false), IsSingleFloat(false), IsNoABICalls(false),
>  CanUseBSDABICalls(false), FloatABI(HardFloat), DspRev(NoDSP),
> -HasMSA(false), DisableMadd4(false), HasFP64(false) {
> +HasMSA(false), HasFP64(false) {
>  TheCXXABI.set(TargetCXXABI::GenericMIPS);
>
>  setABI((getTriple().getArch() == llvm::Triple::mips ||
> @@ -7994,9 +7993,6 @@ public:
>  if (HasMSA)
>Builder.defineMacro("__mips_msa", Twine(1));
>
> -if (DisableMadd4)
> -  Builder.defineMacro("__mips_no_madd4", Twine(1));
> -
>  Builder.defineMacro("_MIPS_SZPTR", Twine(getPointerWidth(0)));
>  Builder.defineMacro("_MIPS_SZINT", Twine(getIntWidth()));
>  Builder.defineMacro("_MIPS_SZLONG", Twine(getLongWidth()));
> @@ -8159,8 +8155,6 @@ public:
>  DspRev = std::max(DspRev, DSP2);
>else if (Feature == "+msa")
>  HasMSA = true;
> -  else if (Feature == "+nomadd4")
> -DisableMadd4 = true;
>else if (Feature == "+fp64")
>  HasFP64 = true;
>else if (Feature == "-fp64")
>
> Modified: cfe/trunk/lib/Driver/ToolChains/Arch/Mips.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Arch/Mips.cpp?rev=304935&r1=304934&r2=304935&view=diff
> ==
> --- cfe/trunk/lib/Driver/ToolChains/Arch/Mips.cpp (original)
> +++ cfe/trunk/lib/Driver/ToolChains/Arch/Mips.cpp Wed Jun  7 13:57:56 2017
> @@ -298,13 +298,6 @@ void mips::getMIPSTargetFeatures(const D
>
>AddTargetFeature(Args, Features, options::OPT_mno_odd_spreg,
> options::OPT_modd_spreg, "nooddspreg");
> -
> -  if (Arg *A = Args.getLastArg(options::OPT_mmadd4, options::OPT_mno_madd4)) 
> {
> -if (A->getOption().matches(options::OPT_mmadd4))
> -  Features.push_back("-nomadd4");
> -else
> -  Features.push_back("+nomadd4");
> -  }
>  }
>
>  mips::NanEncoding mips

[PATCH] D33598: [libclang] [OpenCL] Expose CIndex functions for typedef and address space

2017-06-07 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added a comment.

Sam, do you think you have some time to look at this change? Thanks!


https://reviews.llvm.org/D33598



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


[PATCH] D33681: Allow function declaration with empty argument list.

2017-06-07 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia accepted this revision.
Anastasia added a comment.
This revision is now accepted and ready to land.

LGTM! Thanks!


https://reviews.llvm.org/D33681



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


[libcxx] r304942 - Fix compile error with Bionic's PTHREAD_MUTEX_INITIALIZER

2017-06-07 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Wed Jun  7 15:47:42 2017
New Revision: 304942

URL: http://llvm.org/viewvc/llvm-project?rev=304942&view=rev
Log:
Fix compile error with Bionic's PTHREAD_MUTEX_INITIALIZER

On Bionic PTHREAD_MUTEX_INITIALIZER contains the expression " & 
",
which causes ADL to perform name lookup for operator&. During this lookup Clang 
decides
that it requires the default member initializer for std::mutex while defining 
the DMI
for std::mutex::__m_.

If I'm not mistaken this is caused by the explicit noexcept declaration on the 
defaulted
constructor.

This patch removes the explicit noexcept and instead allows the compiler to 
declare
the default constructor implicitly noexcept. It also adds a static_assert to 
ensure
that happens.

Unfortunatly because it's not easy to change the value of 
_LIBCPP_MUTEX_INITIALIZER
for a single test there is no good way to test this patch.

The Clang behavior causing the trouble here was introduced in r287713, which 
first
appears in the 4.0 release.

Modified:
libcxx/trunk/include/__mutex_base

libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.class/default.pass.cpp

Modified: libcxx/trunk/include/__mutex_base
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__mutex_base?rev=304942&r1=304941&r2=304942&view=diff
==
--- libcxx/trunk/include/__mutex_base (original)
+++ libcxx/trunk/include/__mutex_base Wed Jun  7 15:47:42 2017
@@ -48,7 +48,7 @@ class _LIBCPP_TYPE_VIS _LIBCPP_THREAD_SA
 public:
 _LIBCPP_INLINE_VISIBILITY
 #ifndef _LIBCPP_CXX03_LANG
-constexpr mutex() _NOEXCEPT = default;
+constexpr mutex() = default;
 #else
 mutex() _NOEXCEPT {__m_ = (__libcpp_mutex_t)_LIBCPP_MUTEX_INITIALIZER;}
 #endif
@@ -67,6 +67,9 @@ public:
 _LIBCPP_INLINE_VISIBILITY native_handle_type native_handle() {return 
&__m_;}
 };
 
+static_assert(is_nothrow_default_constructible::value,
+  "the default constructor for std::mutex must be nothrow");
+
 struct _LIBCPP_TYPE_VIS defer_lock_t {};
 struct _LIBCPP_TYPE_VIS try_to_lock_t {};
 struct _LIBCPP_TYPE_VIS adopt_lock_t {};

Modified: 
libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.class/default.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.class/default.pass.cpp?rev=304942&r1=304941&r2=304942&view=diff
==
--- 
libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.class/default.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.class/default.pass.cpp
 Wed Jun  7 15:47:42 2017
@@ -16,8 +16,10 @@
 // mutex();
 
 #include 
+#include 
 
 int main()
 {
+static_assert(std::is_nothrow_default_constructible::value, 
"");
 std::mutex m;
 }


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


[PATCH] D33478: [libclang] When getting platform availabilities, merge multiple declarations if possible

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

This looks better, it's almost ready. A couple of small requests:




Comment at: tools/libclang/CIndex.cpp:7262
+LHS->getMessage() == RHS->getMessage() &&
+LHS->getReplacement() == RHS->getReplacement())
+  return true;

We should also have a test that verifies that we merge identical availabilities.



Comment at: tools/libclang/CIndex.cpp:7268
+(!LHS->getObsoleted().empty() && !RHS->getObsoleted().empty()) ||
+(!LHS->getMessage().empty() && !RHS->getMessage().empty()))
+  return false;

I think that we don't really need the `(!LHS->getMessage().empty() && 
!RHS->getMessage().empty())` check here since message has to be either in a 
deprecated or obsoleted clause, so we should already handle that with previous 
checks.


https://reviews.llvm.org/D33478



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


[PATCH] D33135: [ASTMatchers] Add support for floatLiterals

2017-06-07 Thread Peter Wu via Phabricator via cfe-commits
Lekensteyn updated this revision to Diff 101816.
Lekensteyn marked 8 inline comments as done.
Lekensteyn added a comment.

diff from previous version:

  diff --git a/include/clang/ASTMatchers/Dynamic/Parser.h 
b/include/clang/ASTMatchers/Dynamic/Parser.h
  index 0d0c2ba540..5ec4a9abf4 100644
  --- a/include/clang/ASTMatchers/Dynamic/Parser.h
  +++ b/include/clang/ASTMatchers/Dynamic/Parser.h
  @@ -22,7 +22,7 @@
   ///:=  |  |  | 

   ///  := "quoted string"
   ///:= true | false
  -/// := 1.0 | 2e-3 | 3.45e67
  +/// := [0-9]+.[0-9]* | [0-9]+.[0-9]*[eE][-+]?[0-9]+
   ///   := [0-9]+
   /// := 
   ///  := () |
  diff --git a/lib/ASTMatchers/Dynamic/Parser.cpp 
b/lib/ASTMatchers/Dynamic/Parser.cpp
  index 669e5ca44f..ff5c5fb657 100644
  --- a/lib/ASTMatchers/Dynamic/Parser.cpp
  +++ b/lib/ASTMatchers/Dynamic/Parser.cpp
  @@ -130,8 +130,8 @@ private:
   
   case '0': case '1': case '2': case '3': case '4':
   case '5': case '6': case '7': case '8': case '9':
  -  // Parse an unsigned literal.
  -  consumeUnsignedLiteral(&Result);
  +  // Parse an unsigned and float literal.
  +  consumeNumberLiteral(&Result);
 break;
   
   default:
  @@ -176,8 +176,8 @@ private:
   return Result;
 }
   
  -  /// \brief Consume an unsigned literal.
  -  void consumeUnsignedLiteral(TokenInfo *Result) {
  +  /// \brief Consume an unsigned and float literal.
  +  void consumeNumberLiteral(TokenInfo *Result) {
   bool isFloatingLiteral = false;
   unsigned Length = 1;
   if (Code.size() > 1) {
  @@ -205,8 +205,9 @@ private:
   
   if (isFloatingLiteral) {
 char *end;
  +  errno = 0;
 double doubleValue = strtod(Result->Text.str().c_str(), &end);
  -  if (*end == 0) {
  +  if (*end == 0 && errno == 0) {
   Result->Kind = TokenInfo::TK_Literal;
   Result->Value = doubleValue;
   return;


https://reviews.llvm.org/D33135

Files:
  include/clang/ASTMatchers/Dynamic/Diagnostics.h
  include/clang/ASTMatchers/Dynamic/Parser.h
  include/clang/ASTMatchers/Dynamic/VariantValue.h
  lib/ASTMatchers/Dynamic/Diagnostics.cpp
  lib/ASTMatchers/Dynamic/Marshallers.h
  lib/ASTMatchers/Dynamic/Parser.cpp
  lib/ASTMatchers/Dynamic/VariantValue.cpp
  unittests/ASTMatchers/Dynamic/ParserTest.cpp
  unittests/ASTMatchers/Dynamic/VariantValueTest.cpp

Index: unittests/ASTMatchers/Dynamic/VariantValueTest.cpp
===
--- unittests/ASTMatchers/Dynamic/VariantValueTest.cpp
+++ unittests/ASTMatchers/Dynamic/VariantValueTest.cpp
@@ -76,13 +76,15 @@
   EXPECT_EQ("A", Value.getString());
   EXPECT_TRUE(Value.hasValue());
   EXPECT_FALSE(Value.isBoolean());
+  EXPECT_FALSE(Value.isDouble());
   EXPECT_FALSE(Value.isUnsigned());
   EXPECT_FALSE(Value.isMatcher());
   EXPECT_EQ("String", Value.getTypeAsString());
 
   Value = VariantMatcher::SingleMatcher(recordDecl());
   EXPECT_TRUE(Value.hasValue());
   EXPECT_FALSE(Value.isBoolean());
+  EXPECT_FALSE(Value.isDouble());
   EXPECT_FALSE(Value.isUnsigned());
   EXPECT_FALSE(Value.isString());
   EXPECT_TRUE(Value.isMatcher());
@@ -98,17 +100,28 @@
   EXPECT_FALSE(Value.isMatcher());
   EXPECT_FALSE(Value.isString());
 
+  Value = 3.14;
+  EXPECT_TRUE(Value.isDouble());
+  EXPECT_EQ(3.14, Value.getDouble());
+  EXPECT_TRUE(Value.hasValue());
+  EXPECT_FALSE(Value.isBoolean());
+  EXPECT_FALSE(Value.isUnsigned());
+  EXPECT_FALSE(Value.isMatcher());
+  EXPECT_FALSE(Value.isString());
+
   Value = 17;
   EXPECT_TRUE(Value.isUnsigned());
   EXPECT_EQ(17U, Value.getUnsigned());
   EXPECT_FALSE(Value.isBoolean());
+  EXPECT_FALSE(Value.isDouble());
   EXPECT_TRUE(Value.hasValue());
   EXPECT_FALSE(Value.isMatcher());
   EXPECT_FALSE(Value.isString());
 
   Value = VariantValue();
   EXPECT_FALSE(Value.hasValue());
   EXPECT_FALSE(Value.isBoolean());
+  EXPECT_FALSE(Value.isDouble());
   EXPECT_FALSE(Value.isUnsigned());
   EXPECT_FALSE(Value.isString());
   EXPECT_FALSE(Value.isMatcher());
Index: unittests/ASTMatchers/Dynamic/ParserTest.cpp
===
--- unittests/ASTMatchers/Dynamic/ParserTest.cpp
+++ unittests/ASTMatchers/Dynamic/ParserTest.cpp
@@ -84,6 +84,21 @@
   EXPECT_EQ(false, Sema.Values[1].getBoolean());
 }
 
+TEST(ParserTest, ParseDouble) {
+  MockSema Sema;
+  Sema.parse("1.0");
+  Sema.parse("2.0f");
+  Sema.parse("34.56e-78");
+  Sema.parse("4.E+6");
+  Sema.parse("1");
+  EXPECT_EQ(5U, Sema.Values.size());
+  EXPECT_EQ(1.0, Sema.Values[0].getDouble());
+  EXPECT_EQ("1:1: Error parsing numeric literal: <2.0f>", Sema.Errors[1]);
+  EXPECT_EQ(34.56e-78, Sema.Values[2].getDouble());
+  EXPECT_EQ(4e+6, Sema.Values[3].getDouble());
+  EXPECT_FALSE(Sema.Values[4].isDouble());
+}
+
 TEST(ParserTest, ParseUnsigned) {
   MockSema Sema;
   Sema.parse("0");
@@ -95,8 +110,8 @@
   EXPECT_EQ(0U, Sema.Values[0].getUnsigned());

[PATCH] D33135: [ASTMatchers] Add support for floatLiterals

2017-06-07 Thread Peter Wu via Phabricator via cfe-commits
Lekensteyn added a comment.

Rebased patches on latest clang master (trunk), there were no changes in 
ASTMatchers.
boolean literal patch was unchanged, this floating literal patch was updated to 
address comments.




Comment at: include/clang/ASTMatchers/Dynamic/VariantValue.h:335
 unsigned Unsigned;
+double Double;
 bool Boolean;

aaron.ballman wrote:
> Lekensteyn wrote:
> > aaron.ballman wrote:
> > > Lekensteyn wrote:
> > > > aaron.ballman wrote:
> > > > > This may or may not be a good idea, but do we want to put the values 
> > > > > into an APFloat rather than a double? My concern with double is that 
> > > > > (0) it may be subtly different if the user wants a 16- or 32-bit 
> > > > > float explicitly, (1) it won't be able to represent long double 
> > > > > values, or quad double.
> > > > > 
> > > > > I'm thinking this value could be passed directly from the C++ API as 
> > > > > an APFloat, float, or double, or provided using a StringRef for the 
> > > > > dynamic API.
> > > > (32-bit) double values are a superset of (16-bit) float values, that 
> > > > should be OK.
> > > > Long doubles are possible in the AST (e.g. for `0.1L`), but neither C11 
> > > > nor C++14 seem to define a quad double literal type (so that should be 
> > > > of a lesser concern).
> > > > 
> > > > Reasons why I chose for double instead of APFloat:
> > > > - `strtod` is readily available and does not abort the program. By 
> > > > contrast, `APFloat(StringRef)` trips on assertions if the input is 
> > > > invalid.
> > > > - I was not sure if the APFloat class can be used in an union.
> > > The downside to using `strtod()` is that invalid input is silently 
> > > accepted. However, assertions on invalid input is certainly not good 
> > > either. It might be worth modifying `APFloat::convertFromString()` to 
> > > accept invalid input and return an error.
> > > 
> > > I think instead of an `APFloat`, maybe using an `APValue` for both the 
> > > `Unsigned` and `Double` fields might work. At the very least, it should 
> > > give you implementation ideas.
> > > 
> > > There is a quad double literal suffix: `q`. It's only supported on some 
> > > architectures, however. There are also imaginary numbers (`i`) and half 
> > > (`h`).
> > The strtod conversion was based on parseDouble in 
> > lib/Support/CommandLine.cpp, so any conversion issues also exist there.
> > 
> > Same question, can APFloat/APValue be used in a union?
> > 
> > float (or quad-double suffixes) are explicitly not supported now in this 
> > matcher, maybe they can be added later but for now I decided to keep the 
> > grammar simple (that is, do not express double/float data types via the 
> > literal).
> > The strtod conversion was based on parseDouble in 
> > lib/Support/CommandLine.cpp, so any conversion issues also exist there.
> 
> Good to know.
> 
> > Same question, can APFloat/APValue be used in a union?
> 
> I believe so, but I've not tried it myself. Also, as I mentioned, `APValue` 
> demonstrates another implementation strategy in case you cannot use a union 
> directly.
> 
> > float (or quad-double suffixes) are explicitly not supported now in this 
> > matcher, maybe they can be added later but for now I decided to keep the 
> > grammar simple (that is, do not express double/float data types via the 
> > literal).
> 
> That's reasonable for an initial implementation.
I think I'll keep it like this for now and defer eventual conversion to APValue 
for a future patch that also makes uint64_t possible. Is that OK?


https://reviews.llvm.org/D33135



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


[PATCH] D33094: [ASTMatchers] Add clang-query support for equals matcher

2017-06-07 Thread Peter Wu via Phabricator via cfe-commits
Lekensteyn updated this revision to Diff 101817.
Lekensteyn marked 7 inline comments as done.
Lekensteyn added a comment.

diff from previous patch:

  diff --git a/unittests/ASTMatchers/Dynamic/RegistryTest.cpp 
b/unittests/ASTMatchers/Dynamic/RegistryTest.cpp
  index 29fcdec6c1..84e31f721a 100644
  --- a/unittests/ASTMatchers/Dynamic/RegistryTest.cpp
  +++ b/unittests/ASTMatchers/Dynamic/RegistryTest.cpp
  @@ -530,6 +530,8 @@ TEST_F(RegistryTest, EqualsMatcher) {
 "floatLiteral", constructMatcher("equals", VariantValue(1.2)))
 .getTypedMatcher();
 EXPECT_TRUE(matches("double x = 1.2;", DoubleStmt));
  +  EXPECT_TRUE(matches("double x = 1.2f;", DoubleStmt));
  +  EXPECT_TRUE(matches("double x = 1.2l;", DoubleStmt));
 EXPECT_TRUE(matches("double x = 12e-1;", DoubleStmt));
 EXPECT_FALSE(matches("double x = 1.23;", DoubleStmt));
   
  @@ -543,6 +545,9 @@ TEST_F(RegistryTest, EqualsMatcher) {
 "characterLiteral", constructMatcher("equals", VariantValue('x')))
 .getTypedMatcher();
 EXPECT_TRUE(matches("int x = 'x';", CharStmt));
  +  EXPECT_TRUE(matches("int x = L'x';", CharStmt));
  +  EXPECT_TRUE(matches("int x = u'x';", CharStmt));
  +  EXPECT_TRUE(matches("int x = U'x';", CharStmt));
 EXPECT_FALSE(matches("int x = 120;", CharStmt));
   }


https://reviews.llvm.org/D33094

Files:
  docs/LibASTMatchersReference.html
  include/clang/ASTMatchers/ASTMatchers.h
  lib/ASTMatchers/Dynamic/Registry.cpp
  unittests/ASTMatchers/Dynamic/RegistryTest.cpp

Index: unittests/ASTMatchers/Dynamic/RegistryTest.cpp
===
--- unittests/ASTMatchers/Dynamic/RegistryTest.cpp
+++ unittests/ASTMatchers/Dynamic/RegistryTest.cpp
@@ -511,6 +511,46 @@
   EXPECT_FALSE(matches("int i = 1;", Value));
 }
 
+TEST_F(RegistryTest, EqualsMatcher) {
+  Matcher BooleanStmt = constructMatcher(
+  "cxxBoolLiteral", constructMatcher("equals", VariantValue(true)))
+  .getTypedMatcher();
+  EXPECT_TRUE(matches("bool x = true;", BooleanStmt));
+  EXPECT_FALSE(matches("bool x = false;", BooleanStmt));
+  EXPECT_FALSE(matches("bool x = 0;", BooleanStmt));
+
+  BooleanStmt = constructMatcher(
+  "cxxBoolLiteral", constructMatcher("equals", VariantValue(0)))
+  .getTypedMatcher();
+  EXPECT_TRUE(matches("bool x = false;", BooleanStmt));
+  EXPECT_FALSE(matches("bool x = true;", BooleanStmt));
+  EXPECT_FALSE(matches("bool x = 0;", BooleanStmt));
+
+  Matcher DoubleStmt = constructMatcher(
+  "floatLiteral", constructMatcher("equals", VariantValue(1.2)))
+  .getTypedMatcher();
+  EXPECT_TRUE(matches("double x = 1.2;", DoubleStmt));
+  EXPECT_TRUE(matches("double x = 1.2f;", DoubleStmt));
+  EXPECT_TRUE(matches("double x = 1.2l;", DoubleStmt));
+  EXPECT_TRUE(matches("double x = 12e-1;", DoubleStmt));
+  EXPECT_FALSE(matches("double x = 1.23;", DoubleStmt));
+
+  Matcher IntegerStmt = constructMatcher(
+  "integerLiteral", constructMatcher("equals", VariantValue(42)))
+  .getTypedMatcher();
+  EXPECT_TRUE(matches("int x = 42;", IntegerStmt));
+  EXPECT_FALSE(matches("int x = 1;", IntegerStmt));
+
+  Matcher CharStmt = constructMatcher(
+  "characterLiteral", constructMatcher("equals", VariantValue('x')))
+  .getTypedMatcher();
+  EXPECT_TRUE(matches("int x = 'x';", CharStmt));
+  EXPECT_TRUE(matches("int x = L'x';", CharStmt));
+  EXPECT_TRUE(matches("int x = u'x';", CharStmt));
+  EXPECT_TRUE(matches("int x = U'x';", CharStmt));
+  EXPECT_FALSE(matches("int x = 120;", CharStmt));
+}
+
 } // end anonymous namespace
 } // end namespace dynamic
 } // end namespace ast_matchers
Index: lib/ASTMatchers/Dynamic/Registry.cpp
===
--- lib/ASTMatchers/Dynamic/Registry.cpp
+++ lib/ASTMatchers/Dynamic/Registry.cpp
@@ -56,20 +56,24 @@
   registerMatcher(#name, internal::makeMatcherAutoMarshall(\
  ::clang::ast_matchers::name, #name));
 
+#define REGISTER_MATCHER_OVERLOAD(name)\
+  registerMatcher(#name,   \
+  llvm::make_unique(name##Callbacks))
+
 #define SPECIFIC_MATCHER_OVERLOAD(name, Id)\
   static_cast<::clang::ast_matchers::name##_Type##Id>( \
   ::clang::ast_matchers::name)
 
+#define MATCHER_OVERLOAD_ENTRY(name, Id)   \
+internal::makeMatcherAutoMarshall(SPECIFIC_MATCHER_OVERLOAD(name, Id), \
+  #name)
+
 #define REGISTER_OVERLOADED_2(name)\
   do { \
-std::unique_ptr Callbacks[] = { \
-internal::makeMatcherAutoMarshall(SPECIFIC_MATCHER_OVERLOAD(name, 0),  \
-  #name), 

[PATCH] D33094: [ASTMatchers] Add clang-query support for equals matcher

2017-06-07 Thread Peter Wu via Phabricator via cfe-commits
Lekensteyn added inline comments.



Comment at: unittests/ASTMatchers/Dynamic/RegistryTest.cpp:545
+  .getTypedMatcher();
+  EXPECT_TRUE(matches("int x = 'x';", CharStmt));
+  EXPECT_FALSE(matches("int x = 120;", CharStmt));

Lekensteyn wrote:
> aaron.ballman wrote:
> > Can you add some tests involving the other character literal types (L, u, 
> > U, u8)?
> will do
Done (except for u8 which is only defined for string literals).


https://reviews.llvm.org/D33094



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


r304946 - [c++1z] Support deducing B in noexcept(B).

2017-06-07 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Wed Jun  7 16:46:22 2017
New Revision: 304946

URL: http://llvm.org/viewvc/llvm-project?rev=304946&view=rev
Log:
[c++1z] Support deducing B in noexcept(B).

This is not required by the standard (yet), but there seems to be reasonable
support for this being a defect according to CWG discussion, and libstdc++ 7.1
relies on it working.

Modified:
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp
cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp
cfe/trunk/test/CXX/drs/dr13xx.cpp
cfe/trunk/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.call/p4.cpp
cfe/trunk/test/SemaCXX/cxx1z-noexcept-function-type.cpp
cfe/trunk/test/SemaTemplate/temp_arg_type.cpp

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=304946&r1=304945&r2=304946&view=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Wed Jun  7 16:46:22 2017
@@ -7555,6 +7555,10 @@ public:
 unsigned ThisTypeQuals);
   void SubstExceptionSpec(FunctionDecl *New, const FunctionProtoType *Proto,
   const MultiLevelTemplateArgumentList &Args);
+  bool SubstExceptionSpec(SourceLocation Loc,
+  FunctionProtoType::ExceptionSpecInfo &ESI,
+  SmallVectorImpl &ExceptionStorage,
+  const MultiLevelTemplateArgumentList &Args);
   ParmVarDecl *SubstParmVarDecl(ParmVarDecl *D,
 const MultiLevelTemplateArgumentList &TemplateArgs,
 int indexAdjustment,

Modified: cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp?rev=304946&r1=304945&r2=304946&view=diff
==
--- cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp Wed Jun  7 16:46:22 2017
@@ -56,8 +56,12 @@ namespace clang {
 TDF_TopLevelParameterTypeList = 0x10,
 /// \brief Within template argument deduction from overload resolution per
 /// C++ [over.over] allow matching function types that are compatible in
-/// terms of noreturn and default calling convention adjustments.
-TDF_InOverloadResolution = 0x20
+/// terms of noreturn and default calling convention adjustments, or
+/// similarly matching a declared template specialization against a
+/// possible template, per C++ [temp.deduct.decl]. In either case, permit
+/// deduction where the parameter is a function type that can be converted
+/// to the argument type.
+TDF_AllowCompatibleFunctionType = 0x20,
   };
 }
 
@@ -1306,9 +1310,10 @@ DeduceTemplateArgumentsByTypeMatch(Sema
 // If the parameter type is not dependent, there is nothing to deduce.
 if (!Param->isDependentType()) {
   if (!(TDF & TDF_SkipNonDependent)) {
-bool NonDeduced = (TDF & TDF_InOverloadResolution)?
-  !S.isSameOrCompatibleFunctionType(CanParam, CanArg) :
-  Param != Arg;
+bool NonDeduced =
+(TDF & TDF_AllowCompatibleFunctionType)
+? !S.isSameOrCompatibleFunctionType(CanParam, CanArg)
+: Param != Arg;
 if (NonDeduced) {
   return Sema::TDK_NonDeducedMismatch;
 }
@@ -1318,10 +1323,10 @@ DeduceTemplateArgumentsByTypeMatch(Sema
   } else if (!Param->isDependentType()) {
 CanQualType ParamUnqualType = CanParam.getUnqualifiedType(),
 ArgUnqualType = CanArg.getUnqualifiedType();
-bool Success = (TDF & TDF_InOverloadResolution)?
-   S.isSameOrCompatibleFunctionType(ParamUnqualType,
-ArgUnqualType) :
-   ParamUnqualType == ArgUnqualType;
+bool Success =
+(TDF & TDF_AllowCompatibleFunctionType)
+? S.isSameOrCompatibleFunctionType(ParamUnqualType, ArgUnqualType)
+: ParamUnqualType == ArgUnqualType;
 if (Success)
   return Sema::TDK_Success;
   }
@@ -1524,17 +1529,56 @@ DeduceTemplateArgumentsByTypeMatch(Sema
 return Sema::TDK_NonDeducedMismatch;
 
   // Check return types.
-  if (Sema::TemplateDeductionResult Result =
-  DeduceTemplateArgumentsByTypeMatch(
-  S, TemplateParams, FunctionProtoParam->getReturnType(),
-  FunctionProtoArg->getReturnType(), Info, Deduced, 0))
+  if (auto Result = DeduceTemplateArgumentsByTypeMatch(
+  S, TemplateParams, FunctionProtoParam->getReturnType(),
+  FunctionProtoArg->getReturnType(), Info, Deduced, 0))
 return Result;
 
-  return DeduceTemplateArguments(
-  S, Templ

[PATCH] D20693: [clang-tidy] New checker to replace dynamic exception specifications

2017-06-07 Thread don hinton via Phabricator via cfe-commits
hintonda updated this revision to Diff 101819.
hintonda added a comment.

- Rollback last change.


https://reviews.llvm.org/D20693

Files:
  clang-tidy/modernize/CMakeLists.txt
  clang-tidy/modernize/ModernizeTidyModule.cpp
  clang-tidy/modernize/UseNoexceptCheck.cpp
  clang-tidy/modernize/UseNoexceptCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/modernize-use-noexcept.rst
  test/clang-tidy/modernize-use-noexcept-macro.cpp
  test/clang-tidy/modernize-use-noexcept-opt.cpp
  test/clang-tidy/modernize-use-noexcept.cpp

Index: test/clang-tidy/modernize-use-noexcept.cpp
===
--- /dev/null
+++ test/clang-tidy/modernize-use-noexcept.cpp
@@ -0,0 +1,104 @@
+// RUN: %check_clang_tidy %s modernize-use-noexcept %t -- \
+// RUN:   -- -std=c++11
+
+class A {};
+class B {};
+
+void foo() throw();
+// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: dynamic exception specification 'throw()' is deprecated; consider using 'noexcept' instead [modernize-use-noexcept]
+// CHECK-FIXES: void foo() noexcept;
+
+template 
+void foo() throw();
+void footest() { foo(); foo(); }
+// CHECK-MESSAGES: :[[@LINE-2]]:12: warning: dynamic exception specification 'throw()' is deprecated; consider using 'noexcept' instead [modernize-use-noexcept]
+// CHECK-FIXES: void foo() noexcept;
+
+void bar() throw(...);
+// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: dynamic exception specification 'throw(...)' is deprecated; consider using 'noexcept(false)' instead [modernize-use-noexcept]
+// CHECK-FIXES: void bar() noexcept(false);
+
+void k() throw(int(int));
+// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: dynamic exception specification 'throw(int(int))' is deprecated; consider using 'noexcept(false)' instead [modernize-use-noexcept]
+// CHECK-FIXES: void k() noexcept(false);
+
+void foobar() throw(A, B)
+{}
+// CHECK-MESSAGES: :[[@LINE-2]]:15: warning: dynamic exception specification 'throw(A, B)' is deprecated; consider using 'noexcept(false)' instead [modernize-use-noexcept]
+// CHECK-FIXES: void foobar() noexcept(false)
+
+void baz(int = (throw A(), 0)) throw(A, B) {}
+// CHECK-MESSAGES: :[[@LINE-1]]:32: warning: dynamic exception specification 'throw(A, B)' is deprecated; consider using 'noexcept(false)' instead [modernize-use-noexcept]
+// CHECK-FIXES: void baz(int = (throw A(), 0)) noexcept(false) {}
+
+void g(void (*fp)(void) throw());
+// CHECK-MESSAGES: :[[@LINE-1]]:25: warning: dynamic exception specification 'throw()' is deprecated; consider using 'noexcept' instead [modernize-use-noexcept]
+// CHECK-FIXES: void g(void (*fp)(void) noexcept);
+
+void f(void (*fp)(void) throw(int)) throw(char);
+// CHECK-MESSAGES: :[[@LINE-1]]:25: warning: dynamic exception specification 'throw(int)' is deprecated; consider using 'noexcept(false)' instead [modernize-use-noexcept]
+// CHECK-MESSAGES: :[[@LINE-2]]:37: warning: dynamic exception specification 'throw(char)' is deprecated; consider using 'noexcept(false)' instead [modernize-use-noexcept]
+// CHECK-FIXES: void f(void (*fp)(void) noexcept(false)) noexcept(false);
+
+#define THROW throw
+void h(void (*fp)(void) THROW(int)) THROW(char);
+// CHECK-MESSAGES: :[[@LINE-1]]:25: warning: dynamic exception specification 'THROW(int)' is deprecated; consider using 'noexcept(false)' instead [modernize-use-noexcept]
+// CHECK-MESSAGES: :[[@LINE-2]]:37: warning: dynamic exception specification 'THROW(char)' is deprecated; consider using 'noexcept(false)' instead [modernize-use-noexcept]
+// CHECK-FIXES: void h(void (*fp)(void) noexcept(false)) noexcept(false);
+
+void j() throw(int(int) throw(void(void) throw(int)));
+// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: dynamic exception specification 'throw(int(int) throw(void(void) throw(int)))' is deprecated; consider using 'noexcept(false)' instead [modernize-use-noexcept]
+// CHECK-FIXES: void j() noexcept(false);
+
+class Y {
+  Y() throw() = default;
+};
+// CHECK-MESSAGES: :[[@LINE-2]]:7: warning: dynamic exception specification 'throw()' is deprecated; consider using 'noexcept' instead [modernize-use-noexcept]
+// CHECK-FIXES: Y() noexcept = default;
+
+struct Z {
+  void operator delete(void *ptr) throw();
+  void operator delete[](void *ptr) throw(int);
+  ~Z() throw(int) {}
+};
+// CHECK-MESSAGES: :[[@LINE-4]]:35: warning: dynamic exception specification 'throw()' is deprecated; consider using 'noexcept' instead [modernize-use-noexcept]
+// CHECK-MESSAGES: :[[@LINE-4]]:37: warning: dynamic exception specification 'throw(int)' is deprecated; consider using 'noexcept(false)' instead [modernize-use-noexcept]
+// CHECK-MESSAGES: :[[@LINE-4]]:8: warning: dynamic exception specification 'throw(int)' is deprecated; consider using 'noexcept(false)' instead [modernize-use-noexcept]
+// CHECK-FIXES: void operator delete(void *ptr) noexcept;
+// CHECK-FIXES: void operator delete[](void *ptr) noexcept(false);
+// CHECK-FIXES: ~Z() noexcept(false) {}
+
+struct S {
+  void 

Re: r284060 - Implement MS _BitScan intrinsics

2017-06-07 Thread Duncan P. N. Exon Smith via cfe-commits
[... excuse the necromancy...]

Hi Albert (and Reid and David),

This commit is breaking some uses of -fms-extensions on Apple platforms.  In 
particular, Brian and Erik (CC'ed) build against a version of the Windows SDK 
on Apple platforms.  _BitScanReverse is expected to be 32-bit, matching 
Windows/LLP64, even though long is 64-bit on Darwin/LP64.

One idea we've had for fixing this is to use "int" instead of "long" for these 
intrinsics, either:
- all the time, or
- when in LP64 mode (e.g., Darwin + -fms-extensions).

Any other ideas?

Thanks,
Duncan

> On Oct 12, 2016, at 15:01, Albert Gutowski via cfe-commits 
>  wrote:
> 
> Author: agutowski
> Date: Wed Oct 12 17:01:05 2016
> New Revision: 284060
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=284060&view=rev
> Log:
> Implement MS _BitScan intrinsics
> 
> Summary: _BitScan intrinsics (and some others, for example _Interlocked and 
> _bittest) are supposed to work on both ARM and x86. This is an attempt to 
> isolate them, avoiding repeating their code or writing separate function for 
> each builtin.
> 
> Reviewers: hans, thakis, rnk, majnemer
> 
> Subscribers: RKSimon, cfe-commits, aemerson
> 
> Differential Revision: https://reviews.llvm.org/D25264
> 
> Modified:
>cfe/trunk/include/clang/Basic/BuiltinsARM.def
>cfe/trunk/include/clang/Basic/BuiltinsX86.def
>cfe/trunk/include/clang/Basic/BuiltinsX86_64.def
>cfe/trunk/lib/Basic/Targets.cpp
>cfe/trunk/lib/CodeGen/CGBuiltin.cpp
>cfe/trunk/lib/CodeGen/CodeGenFunction.h
>cfe/trunk/lib/Headers/intrin.h
>cfe/trunk/test/CodeGen/ms-intrinsics.c
> 
> Modified: cfe/trunk/include/clang/Basic/BuiltinsARM.def
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsARM.def?rev=284060&r1=284059&r2=284060&view=diff
> ==
> --- cfe/trunk/include/clang/Basic/BuiltinsARM.def (original)
> +++ cfe/trunk/include/clang/Basic/BuiltinsARM.def Wed Oct 12 17:01:05 2016
> @@ -18,6 +18,10 @@
> #   define LANGBUILTIN(ID, TYPE, ATTRS, BUILTIN_LANG) BUILTIN(ID, TYPE, ATTRS)
> #endif
> 
> +#if defined(BUILTIN) && !defined(TARGET_HEADER_BUILTIN)
> +#  define TARGET_HEADER_BUILTIN(ID, TYPE, ATTRS, HEADER, LANG, FEATURE) 
> BUILTIN(ID, TYPE, ATTRS)
> +#endif
> +
> // In libgcc
> BUILTIN(__clear_cache, "vv*v*", "i")
> 
> @@ -129,5 +133,11 @@ LANGBUILTIN(_MoveFromCoprocessor2, "UiIU
> LANGBUILTIN(_MoveToCoprocessor, "vUiIUiIUiIUiIUiIUi", "", ALL_MS_LANGUAGES)
> LANGBUILTIN(_MoveToCoprocessor2, "vUiIUiIUiIUiIUiIUi", "", ALL_MS_LANGUAGES)
> 
> +TARGET_HEADER_BUILTIN(_BitScanForward, "UcULi*ULi", "n", "intrin.h", 
> ALL_MS_LANGUAGES, "")
> +TARGET_HEADER_BUILTIN(_BitScanReverse, "UcULi*ULi", "n", "intrin.h", 
> ALL_MS_LANGUAGES, "")
> +TARGET_HEADER_BUILTIN(_BitScanForward64, "UcULi*ULLi", "n", "intrin.h", 
> ALL_MS_LANGUAGES, "")
> +TARGET_HEADER_BUILTIN(_BitScanReverse64, "UcULi*ULLi", "n", "intrin.h", 
> ALL_MS_LANGUAGES, "")
> +
> #undef BUILTIN
> #undef LANGBUILTIN
> +#undef TARGET_HEADER_BUILTIN
> 
> Modified: cfe/trunk/include/clang/Basic/BuiltinsX86.def
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsX86.def?rev=284060&r1=284059&r2=284060&view=diff
> ==
> --- cfe/trunk/include/clang/Basic/BuiltinsX86.def (original)
> +++ cfe/trunk/include/clang/Basic/BuiltinsX86.def Wed Oct 12 17:01:05 2016
> @@ -2028,6 +2028,10 @@ TARGET_BUILTIN(__builtin_ia32_selectpd_5
> TARGET_BUILTIN(__builtin_ia32_monitorx, "vv*UiUi", "", "mwaitx")
> TARGET_BUILTIN(__builtin_ia32_mwaitx, "vUiUiUi", "", "mwaitx")
> 
> +// MSVC
> +TARGET_HEADER_BUILTIN(_BitScanForward, "UcULi*ULi", "n", "intrin.h", 
> ALL_MS_LANGUAGES, "")
> +TARGET_HEADER_BUILTIN(_BitScanReverse, "UcULi*ULi", "n", "intrin.h", 
> ALL_MS_LANGUAGES, "")
> +
> TARGET_HEADER_BUILTIN(_ReadWriteBarrier, "v", "nh", "intrin.h", 
> ALL_MS_LANGUAGES, "")
> TARGET_HEADER_BUILTIN(_ReadBarrier,  "v", "nh", "intrin.h", 
> ALL_MS_LANGUAGES, "")
> TARGET_HEADER_BUILTIN(_WriteBarrier, "v", "nh", "intrin.h", 
> ALL_MS_LANGUAGES, "")
> 
> Modified: cfe/trunk/include/clang/Basic/BuiltinsX86_64.def
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsX86_64.def?rev=284060&r1=284059&r2=284060&view=diff
> ==
> --- cfe/trunk/include/clang/Basic/BuiltinsX86_64.def (original)
> +++ cfe/trunk/include/clang/Basic/BuiltinsX86_64.def Wed Oct 12 17:01:05 2016
> @@ -22,6 +22,9 @@
> #  define TARGET_HEADER_BUILTIN(ID, TYPE, ATTRS, HEADER, LANG, FEATURE) 
> BUILTIN(ID, TYPE, ATTRS)
> #endif
> 
> +TARGET_HEADER_BUILTIN(_BitScanForward64, "UcULi*ULLi", "n", "intrin.h", 
> ALL_MS_LANGUAGES, "")
> +TARGET_HEADER_BUILTIN(_BitScanReverse64, "UcULi*ULLi", "n", "intrin.h", 
> ALL_MS_LANGUAGES, "")
> +
> TARGET_HEADER_BUILTIN(__mulh,  "LLiLLiLLi","nch", "intrin.h", 
> ALL_MS_L

[PATCH] D33304: [clang-tidy][Part1] Add a new module Android and three new checks.

2017-06-07 Thread Yan Wang via Phabricator via cfe-commits
yawanng updated this revision to Diff 101831.
yawanng marked an inline comment as done.

https://reviews.llvm.org/D33304

Files:
  clang-tidy/CMakeLists.txt
  clang-tidy/android/AndroidTidyModule.cpp
  clang-tidy/android/CMakeLists.txt
  clang-tidy/android/FileOpenFlagCheck.cpp
  clang-tidy/android/FileOpenFlagCheck.h
  clang-tidy/plugin/CMakeLists.txt
  clang-tidy/tool/CMakeLists.txt
  clang-tidy/tool/ClangTidyMain.cpp
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/android-file-open-flag.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/index.rst
  test/clang-tidy/android-file-open-flag.cpp
  unittests/clang-tidy/CMakeLists.txt

Index: unittests/clang-tidy/CMakeLists.txt
===
--- unittests/clang-tidy/CMakeLists.txt
+++ unittests/clang-tidy/CMakeLists.txt
@@ -25,6 +25,7 @@
   clangFrontend
   clangLex
   clangTidy
+  clangTidyAndroidModule
   clangTidyGoogleModule
   clangTidyLLVMModule
   clangTidyMiscModule
Index: test/clang-tidy/android-file-open-flag.cpp
===
--- /dev/null
+++ test/clang-tidy/android-file-open-flag.cpp
@@ -0,0 +1,104 @@
+// RUN: %check_clang_tidy %s android-file-open-flag %t
+
+#define O_RDWR 1
+#define O_EXCL 2
+#define __O_CLOEXEC 3
+#define O_CLOEXEC __O_CLOEXEC
+
+extern "C" int open(const char *fn, int flags, ...);
+extern "C" int open64(const char *fn, int flags, ...);
+extern "C" int openat(int dirfd, const char *pathname, int flags, ...);
+
+void a() {
+  open("filename", O_RDWR);
+  // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: open should use O_CLOEXEC where possible [android-file-open-flag]
+  // CHECK-FIXES: O_RDWR | O_CLOEXEC
+  open("filename", O_RDWR | O_EXCL);
+  // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: open should use O_CLOEXEC where
+  // CHECK-FIXES: O_RDWR | O_EXCL | O_CLOEXEC
+}
+
+void b() {
+  open64("filename", O_RDWR);
+  // CHECK-MESSAGES: :[[@LINE-1]]:22: warning: open64 should use O_CLOEXEC where possible [android-file-open-flag]
+  // CHECK-FIXES: O_RDWR | O_CLOEXEC
+  open64("filename", O_RDWR | O_EXCL);
+  // CHECK-MESSAGES: :[[@LINE-1]]:22: warning: open64 should use O_CLOEXEC where
+  // CHECK-FIXES: O_RDWR | O_EXCL | O_CLOEXEC
+}
+
+void c() {
+  openat(0, "filename", O_RDWR);
+  // CHECK-MESSAGES: :[[@LINE-1]]:25: warning: openat should use O_CLOEXEC where possible [android-file-open-flag]
+  // CHECK-FIXES: O_RDWR | O_CLOEXEC
+  openat(0, "filename", O_RDWR | O_EXCL);
+  // CHECK-MESSAGES: :[[@LINE-1]]:25: warning: openat should use O_CLOEXEC where
+  // CHECK-FIXES: O_RDWR | O_EXCL | O_CLOEXEC
+}
+
+void f() {
+  open("filename", 3);
+  // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: open should use O_CLOEXEC where possible [android-file-open-flag]
+  // CHECK-FIXES: 3 | O_CLOEXEC
+  open64("filename", 3);
+  // CHECK-MESSAGES: :[[@LINE-1]]:22: warning: open64 should use O_CLOEXEC where possible [android-file-open-flag]
+  // CHECK-FIXES: 3 | O_CLOEXEC
+  openat(0, "filename", 3);
+  // CHECK-MESSAGES: :[[@LINE-1]]:25: warning: openat should use O_CLOEXEC where possible [android-file-open-flag]
+  // CHECK-FIXES: 3 | O_CLOEXEC
+
+  int flag = 3;
+  open("filename", flag);
+  // CHECK-MESSAGES-NOT: warning:
+  open64("filename", flag);
+  // CHECK-MESSAGES-NOT: warning:
+  openat(0, "filename", flag);
+  // CHECK-MESSAGES-NOT: warning:
+}
+
+namespace i {
+int open(const char *pathname, int flags, ...);
+int open64(const char *pathname, int flags, ...);
+int openat(int dirfd, const char *pathname, int flags, ...);
+
+void d() {
+  open("filename", O_RDWR);
+  // CHECK-MESSAGES-NOT: warning:
+  open64("filename", O_RDWR);
+  // CHECK-MESSAGES-NOT: warning:
+  openat(0, "filename", O_RDWR);
+  // CHECK-MESSAGES-NOT: warning:
+}
+
+} // namespace i
+
+void e() {
+  open("filename", O_CLOEXEC);
+  // CHECK-MESSAGES-NOT: warning:
+  open("filename", O_RDWR | O_CLOEXEC);
+  // CHECK-MESSAGES-NOT: warning:
+  open64("filename", O_CLOEXEC);
+  // CHECK-MESSAGES-NOT: warning:
+  open64("filename", O_RDWR | O_CLOEXEC);
+  // CHECK-MESSAGES-NOT: warning:
+  openat(0, "filename", O_CLOEXEC);
+  // CHECK-MESSAGES-NOT: warning:
+  openat(0, "filename", O_RDWR | O_CLOEXEC);
+  // CHECK-MESSAGES-NOT: warning:
+}
+
+class G {
+public:
+  int open(const char *pathname, int flags, ...);
+  int open64(const char *pathname, int flags, ...);
+  int openat(int dirfd, const char *pathname, int flags, ...);
+
+  void h() {
+open("filename", O_RDWR);
+// CHECK-MESSAGES-NOT: warning:
+open64("filename", O_RDWR);
+// CHECK-MESSAGES-NOT: warning:
+openat(0, "filename", O_RDWR);
+// CHECK-MESSAGES-NOT: warning:
+  }
+};
Index: docs/clang-tidy/index.rst
===
--- docs/clang-tidy/index.rst
+++ docs/clang-tidy/index.rst
@@ -55,6 +55,7 @@
 == =
 Name prefixDescription
 

[PATCH] D33735: [DebugInfo] Add ThisOrSelf attribute for emission of FlagObjectPointer.

2017-06-07 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: include/clang/AST/Decl.h:1387
+IPK_CapturedContext, /// Parameter for captured context
+IPK_GeneralParam,/// General implicit parameter
+  };

ABataev wrote:
> rjmccall wrote:
> > I would just call this "Other" and document it as being for kinds of 
> > implicit parameters that we haven't seen a purpose in categorizing yet.  
> > (Or you could just classify them all, I suppose.)
> > 
> > We can use C++11 features in Clang now, so I would recommend hoisting this 
> > type out of ImplicitParamDecl and making it an enum class.  You can then 
> > drop the "IPK_" prefixes.
> It's hard to classify them, in most cases they just represent some general 
> parameters used for correct codegen of function types and that's it.
That's fair.



Comment at: include/clang/AST/Decl.h:901
+/// member functions.
+unsigned ImplicitParamKind : 3;
   };

ABataev wrote:
> aaron.ballman wrote:
> > ABataev wrote:
> > > aaron.ballman wrote:
> > > > It's a bit strange to me that the non-parameter declaration bits now 
> > > > have a field for implicit parameter information. Why here instead of 
> > > > `ParmVarDeclBits`?
> > > Actually, `ImplicitParamDecl` already uses some bits from the 
> > > `NonParmVarDeclBitfields`, at least it may be marked as `ARCPseudoStrong` 
> > > for ObjC. That's why I had to reuse `NonParmVarDeclBitfields` part.
> > Ew. That's nasty and we should probably fix that (not as part of this 
> > patch). Can you add a FIXME here?
> Ok, I will add FIXME for `ARCPseudoStrong` and for the `ImplicitParamKind` 
> bitfields
The FIXME doesn't make sense because ImplicitParamDecl is not a subclass of 
ParamVarDecl.

The comment here needs to be updated.


https://reviews.llvm.org/D33735



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


[PATCH] D34002: [clang-tidy] When" -fno-exceptions is used", this warning is better to be suppressed.

2017-06-07 Thread Yan Wang via Phabricator via cfe-commits
yawanng updated this revision to Diff 101834.
yawanng marked an inline comment as done.

https://reviews.llvm.org/D34002

Files:
  clang-tidy/misc/NoexceptMoveConstructorCheck.cpp
  test/clang-tidy/misc-noexcept-move-constructor.cpp


Index: test/clang-tidy/misc-noexcept-move-constructor.cpp
===
--- test/clang-tidy/misc-noexcept-move-constructor.cpp
+++ test/clang-tidy/misc-noexcept-move-constructor.cpp
@@ -1,16 +1,25 @@
-// RUN: %check_clang_tidy %s misc-noexcept-move-constructor %t
+// RUN: clang-tidy %s -checks="-*,misc-noexcept-move-constructor" -- 
-std=c++11 \
+// RUN:   | FileCheck %s -check-prefix=CHECK-EXCEPTIONS \
+// RUN:   -implicit-check-not="{{warning|error}}:"
+// RUN: clang-tidy %s -checks="-*,misc-noexcept-move-constructor" -- 
-fno-exceptions -std=c++11 \
+// RUN:   | FileCheck %s -allow-empty -check-prefix=CHECK-NONEXCEPTIONS \
+// RUN:   -implicit-check-not="{{warning|error}}:"
+
 
 class A {
   A(A &&);
-  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: move constructors should be 
marked noexcept [misc-noexcept-move-constructor]
+  // CHECK-EXCEPTIONS: :[[@LINE-1]]:3: warning: move constructors should be 
marked noexcept [misc-noexcept-move-constructor]
+  // CHECK-NONEXCEPTIONS-NOT: warning:
   A &operator=(A &&);
-  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: move assignment operators should
+  // CHECK-EXCEPTIONS: :[[@LINE-1]]:6: warning: move assignment operators 
should
+  // CHECK-NONEXCEPTIONS-NOT: warning:
 };
 
 struct B {
   static constexpr bool kFalse = false;
   B(B &&) noexcept(kFalse);
-  // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: noexcept specifier on the move 
constructor evaluates to 'false' [misc-noexcept-move-constructor]
+  // CHECK-EXCEPTIONS: :[[@LINE-1]]:20: warning: noexcept specifier on the 
move constructor evaluates to 'false' [misc-noexcept-move-constructor]
+  // CHECK-NONEXCEPTIONS-NOT: warning:
 };
 
 class OK {};
Index: clang-tidy/misc/NoexceptMoveConstructorCheck.cpp
===
--- clang-tidy/misc/NoexceptMoveConstructorCheck.cpp
+++ clang-tidy/misc/NoexceptMoveConstructorCheck.cpp
@@ -20,7 +20,7 @@
 void NoexceptMoveConstructorCheck::registerMatchers(MatchFinder *Finder) {
   // Only register the matchers for C++11; the functionality currently does not
   // provide any benefit to other languages, despite being benign.
-  if (!getLangOpts().CPlusPlus11)
+  if (!getLangOpts().CPlusPlus11 || !getLangOpts().CXXExceptions)
 return;
 
   Finder->addMatcher(


Index: test/clang-tidy/misc-noexcept-move-constructor.cpp
===
--- test/clang-tidy/misc-noexcept-move-constructor.cpp
+++ test/clang-tidy/misc-noexcept-move-constructor.cpp
@@ -1,16 +1,25 @@
-// RUN: %check_clang_tidy %s misc-noexcept-move-constructor %t
+// RUN: clang-tidy %s -checks="-*,misc-noexcept-move-constructor" -- -std=c++11 \
+// RUN:   | FileCheck %s -check-prefix=CHECK-EXCEPTIONS \
+// RUN:   -implicit-check-not="{{warning|error}}:"
+// RUN: clang-tidy %s -checks="-*,misc-noexcept-move-constructor" -- -fno-exceptions -std=c++11 \
+// RUN:   | FileCheck %s -allow-empty -check-prefix=CHECK-NONEXCEPTIONS \
+// RUN:   -implicit-check-not="{{warning|error}}:"
+
 
 class A {
   A(A &&);
-  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: move constructors should be marked noexcept [misc-noexcept-move-constructor]
+  // CHECK-EXCEPTIONS: :[[@LINE-1]]:3: warning: move constructors should be marked noexcept [misc-noexcept-move-constructor]
+  // CHECK-NONEXCEPTIONS-NOT: warning:
   A &operator=(A &&);
-  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: move assignment operators should
+  // CHECK-EXCEPTIONS: :[[@LINE-1]]:6: warning: move assignment operators should
+  // CHECK-NONEXCEPTIONS-NOT: warning:
 };
 
 struct B {
   static constexpr bool kFalse = false;
   B(B &&) noexcept(kFalse);
-  // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: noexcept specifier on the move constructor evaluates to 'false' [misc-noexcept-move-constructor]
+  // CHECK-EXCEPTIONS: :[[@LINE-1]]:20: warning: noexcept specifier on the move constructor evaluates to 'false' [misc-noexcept-move-constructor]
+  // CHECK-NONEXCEPTIONS-NOT: warning:
 };
 
 class OK {};
Index: clang-tidy/misc/NoexceptMoveConstructorCheck.cpp
===
--- clang-tidy/misc/NoexceptMoveConstructorCheck.cpp
+++ clang-tidy/misc/NoexceptMoveConstructorCheck.cpp
@@ -20,7 +20,7 @@
 void NoexceptMoveConstructorCheck::registerMatchers(MatchFinder *Finder) {
   // Only register the matchers for C++11; the functionality currently does not
   // provide any benefit to other languages, despite being benign.
-  if (!getLangOpts().CPlusPlus11)
+  if (!getLangOpts().CPlusPlus11 || !getLangOpts().CXXExceptions)
 return;
 
   Finder->addMatcher(
___
cfe-commits mailing list
cfe-commits@list

[PATCH] D34007: Implement inclusive_scan and transform_inclusive_scan

2017-06-07 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists abandoned this revision.
mclow.lists added a comment.

I don't think that this is a correct implementation. Also, I need tests for 
when the result overwrites the source.
As they say .. I'll be back :-)


https://reviews.llvm.org/D34007



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


r304951 - When determining the target function of an explicit instantiation, make

2017-06-07 Thread John McCall via cfe-commits
Author: rjmccall
Date: Wed Jun  7 18:00:05 2017
New Revision: 304951

URL: http://llvm.org/viewvc/llvm-project?rev=304951&view=rev
Log:
When determining the target function of an explicit instantiation, make
sure that non-template functions don't end up in the candidate set.

Fixes PR14211.

Patch by Don Hinton!

Modified:
cfe/trunk/lib/Sema/SemaTemplate.cpp
cfe/trunk/test/CXX/temp/temp.decls/temp.mem/p5.cpp

Modified: cfe/trunk/lib/Sema/SemaTemplate.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplate.cpp?rev=304951&r1=304950&r2=304951&view=diff
==
--- cfe/trunk/lib/Sema/SemaTemplate.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplate.cpp Wed Jun  7 18:00:05 2017
@@ -8957,7 +8957,8 @@ DeclResult Sema::ActOnExplicitInstantiat
   //   A member function [...] of a class template can be explicitly
   //  instantiated from the member definition associated with its class
   //  template.
-  UnresolvedSet<8> Matches;
+  UnresolvedSet<8> TemplateMatches;
+  FunctionDecl *NonTemplateMatch = nullptr;
   AttributeList *Attr = D.getDeclSpec().getAttributes().getList();
   TemplateSpecCandidateSet FailedCandidates(D.getIdentifierLoc());
   for (LookupResult::iterator P = Previous.begin(), PEnd = Previous.end();
@@ -8968,11 +8969,13 @@ DeclResult Sema::ActOnExplicitInstantiat
 QualType Adjusted = adjustCCAndNoReturn(R, Method->getType(),
 /*AdjustExceptionSpec*/true);
 if (Context.hasSameUnqualifiedType(Method->getType(), Adjusted)) {
-  Matches.clear();
-
-  Matches.addDecl(Method, P.getAccess());
-  if (Method->getTemplateSpecializationKind() == TSK_Undeclared)
-break;
+  if (Method->getPrimaryTemplate()) {
+TemplateMatches.addDecl(Method, P.getAccess());
+  } else {
+// FIXME: Can this assert ever happen?  Needs a test.
+assert(!NonTemplateMatch && "Multiple NonTemplateMatches");
+NonTemplateMatch = Method;
+  }
 }
   }
 }
@@ -9011,22 +9014,25 @@ DeclResult Sema::ActOnExplicitInstantiat
   continue;
 }
 
-Matches.addDecl(Specialization, P.getAccess());
+TemplateMatches.addDecl(Specialization, P.getAccess());
   }
 
-  // Find the most specialized function template specialization.
-  UnresolvedSetIterator Result = getMostSpecialized(
-  Matches.begin(), Matches.end(), FailedCandidates,
-  D.getIdentifierLoc(),
-  PDiag(diag::err_explicit_instantiation_not_known) << Name,
-  PDiag(diag::err_explicit_instantiation_ambiguous) << Name,
-  PDiag(diag::note_explicit_instantiation_candidate));
+  FunctionDecl *Specialization = NonTemplateMatch;
+  if (!Specialization) {
+// Find the most specialized function template specialization.
+UnresolvedSetIterator Result = getMostSpecialized(
+TemplateMatches.begin(), TemplateMatches.end(), FailedCandidates,
+D.getIdentifierLoc(),
+PDiag(diag::err_explicit_instantiation_not_known) << Name,
+PDiag(diag::err_explicit_instantiation_ambiguous) << Name,
+PDiag(diag::note_explicit_instantiation_candidate));
 
-  if (Result == Matches.end())
-return true;
+if (Result == TemplateMatches.end())
+  return true;
 
-  // Ignore access control bits, we don't need them for redeclaration checking.
-  FunctionDecl *Specialization = cast(*Result);
+// Ignore access control bits, we don't need them for redeclaration 
checking.
+Specialization = cast(*Result);
+  }
 
   // C++11 [except.spec]p4
   // In an explicit instantiation an exception-specification may be specified,

Modified: cfe/trunk/test/CXX/temp/temp.decls/temp.mem/p5.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/temp/temp.decls/temp.mem/p5.cpp?rev=304951&r1=304950&r2=304951&view=diff
==
--- cfe/trunk/test/CXX/temp/temp.decls/temp.mem/p5.cpp (original)
+++ cfe/trunk/test/CXX/temp/temp.decls/temp.mem/p5.cpp Wed Jun  7 18:00:05 2017
@@ -77,3 +77,16 @@ void test_X0(X0 x0, const X0 &x0c) {
   x0.operator float *();
   x0c.operator const char*();
 }
+
+namespace PR14211 {
+template  struct X {
+  void foo(U){}
+  template  void foo(T){}
+
+  template  void bar(T){}
+  void bar(U){}
+};
+
+template void X::foo(int);
+template void X::bar(int);
+}


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


[PATCH] D17215: [Sema] Fix PR14211 Crash for explicit instantiation of overloaded template function within class template

2017-06-07 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

Sure thing, r304951.


https://reviews.llvm.org/D17215



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


[PATCH] D20693: [clang-tidy] New checker to replace dynamic exception specifications

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

Just ran asan on linux and we have a heap-use-after-free in the std::string 
ctor.

Here's a partial stack dump:

4980==ERROR: AddressSanitizer: heap-use-after-free on address 0x60424328 at 
pc 0x0057ad32 bp 0x7ffd240a7f50 sp 0x7ffd240a7700
-

READ of size 8 at 0x60424328 thread T0

  #0 0x57ad31 in __interceptor_memcpy.part.36 
/home/d80049854/projects/clang/4.0.0/llvm/projects/compiler-rt/lib/asan/../sanitizer_common/sanitizer_common_interceptors.inc:655
  #1 0x6c5960 in char* std::string::_S_construct(char const*, char 
const*, std::allocator const&, std::forward_iterator_tag) 
/usr/lib/gcc/x86_64-linux-gnu/6.2.0/../../../../include/c+

+/6.2.0/bits/basic_string.tcc:580:6

  #2 0x7fe7bd7bc98a in std::basic_string, 
std::allocator >::basic_string(char const*, unsigned long, 
std::allocator const&) (/usr/lib/x86_64-linux-gnu/libstdc++.

so.6+0xc598a)

  #3 0x67b89f in llvm::StringRef::str() const 
/home/d80049854/projects/clang/llvm/include/llvm/ADT/StringRef.h:230:14
  #4 0x67b3dd in llvm::StringRef::operator std::string() const 
/home/d80049854/projects/clang/llvm/include/llvm/ADT/StringRef.h:257:14
  #5 0xd679d2 in clang::FixItHint::CreateReplacement(clang::CharSourceRange, 
llvm::StringRef) 
/home/d80049854/projects/clang/llvm/tools/clang/include/clang/Basic/Diagnostic.h:131:25
  #6 0x1213006 in 
clang::tidy::modernize::UseNoexceptCheck::check(clang::ast_matchers::MatchFinder::MatchResult
 const&) 
/home/d80049854/projects/clang/llvm/tools/clang/tools/extra/clang-tidy/modernize/U

$ ../../4.0.0/build/Release/bin/clang -v
clang version 4.0.0 (tags/RELEASE_400/final)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: 
/home/d80049854/projects/clang/build/Debug/../../4.0.0/build/Release/bin
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.6
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.6.4
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.8
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.8.4
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.9
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.9.3
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5.4.1
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/6
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/6.2.0
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/6.2.0
Candidate multilib: .;@m64
Selected multilib: .;@m64

stdlibc++ from gcc 6.2:

$ g++-6 -v
Using built-in specs.
COLLECT_GCC=g++-6
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/6/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 
6.2.0-3ubuntu11~14.04' --with-bugurl=file:///usr/share/doc/gcc-6/README.Bugs 
--enable-languages=c,ada,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr 
--program-suffix=-6 --enable-shared --enable-linker-build-id 
--libexecdir=/usr/lib --without-included-gettext --enable-threads=posix 
--libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu 
--enable-libstdcxx-debug --enable-libstdcxx-time=yes 
--with-default-libstdcxx-abi=gcc4-compatible --disable-libstdcxx-dual-abi 
--enable-gnu-unique-object --disable-vtable-verify --enable-libmpx 
--enable-plugin --with-system-zlib --disable-browser-plugin 
--enable-java-awt=gtk --enable-gtk-cairo 
--with-java-home=/usr/lib/jvm/java-1.5.0-gcj-6-amd64/jre --enable-java-home 
--with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-6-amd64 
--with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-6-amd64 
--with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar 
--enable-objc-gc --enable-multiarch --disable-werror --with-arch-32=i686 
--with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib 
--with-tune=generic --enable-checking=release --build=x86_64-linux-gnu 
--host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 6.2.0 20160901 (Ubuntu 6.2.0-3ubuntu11~14.04)

$ ldd bin/clang-tidy

  linux-vdso.so.1 =>  (0x7ffde1996000)
  libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x7f6104f2a000)
  librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x7f6104d22000)
  libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x7f6104b1e000)
  libtinfo.so.5 => /lib/x86_64-linux-gnu/libtinfo.so.5 (0x7f61048f5000)
  libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x7f61045ef000)
  libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 
(0x7f61042dd000)
  libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x7f61040c6000)
  libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x7f6103d01000)
  /lib64/ld-linux-x86-64.so.2 (0x7f6105148000)


https://reviews.llvm.org/D20693



___

[PATCH] D20693: [clang-tidy] New checker to replace dynamic exception specifications

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

btw, here's how I built it, in case that matters...

CC=../../4.0.0/build/Release/bin/clang 
CXX=../../4.0.0/build/Release/bin/clang++  \
 cmake ../../llvm/ \
 -GNinja \
 -DLLVM_USE_SANITIZER=Address \
 -DCMAKE_BUILD_TYPE=Debug \
 -DLLVM_TARGETS_TO_BUILD="X86" \
 -DLLVM_PARALLEL_LINK_JOBS=4


https://reviews.llvm.org/D20693



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


r304953 - Reapply r304929 [mips] Add runtime options to enable/disable madd/sub.fmt

2017-06-07 Thread Petar Jovanovic via cfe-commits
Author: petarj
Date: Wed Jun  7 18:51:52 2017
New Revision: 304953

URL: http://llvm.org/viewvc/llvm-project?rev=304953&view=rev
Log:
Reapply r304929 [mips] Add runtime options to enable/disable madd/sub.fmt

The test in r304929 broke multiple buildbots as it expected mips target to
be registered and available (which is not necessarily true). Updating the
test with this condition.

Original commit:

  [mips] Add runtime options to enable/disable madd.fmt and msub.fmt

  Add options to clang: -mmadd4 and -mno-madd4, use it to enable or disable
  generation of madd.fmt and similar instructions respectively, as per GCC.

  Patch by Stefan Maksimovic.

Added:
cfe/trunk/test/CodeGen/mips-madd4.c
Modified:
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/lib/Basic/Targets.cpp
cfe/trunk/lib/Driver/ToolChains/Arch/Mips.cpp
cfe/trunk/test/Preprocessor/init.c

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=304953&r1=304952&r2=304953&view=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Wed Jun  7 18:51:52 2017
@@ -2001,6 +2001,10 @@ def mdspr2 : Flag<["-"], "mdspr2">, Grou
 def mno_dspr2 : Flag<["-"], "mno-dspr2">, Group;
 def msingle_float : Flag<["-"], "msingle-float">, Group;
 def mdouble_float : Flag<["-"], "mdouble-float">, Group;
+def mmadd4 : Flag<["-"], "mmadd4">, Group,
+  HelpText<"Enable the generation of 4-operand madd.s, madd.d and related 
instructions.">;
+def mno_madd4 : Flag<["-"], "mno-madd4">, Group,
+  HelpText<"Disable the generation of 4-operand madd.s, madd.d and related 
instructions.">;
 def mmsa : Flag<["-"], "mmsa">, Group,
   HelpText<"Enable MSA ASE (MIPS only)">;
 def mno_msa : Flag<["-"], "mno-msa">, Group,

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=304953&r1=304952&r2=304953&view=diff
==
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Wed Jun  7 18:51:52 2017
@@ -7737,6 +7737,7 @@ class MipsTargetInfo : public TargetInfo
 NoDSP, DSP1, DSP2
   } DspRev;
   bool HasMSA;
+  bool DisableMadd4;
 
 protected:
   bool HasFP64;
@@ -7747,7 +7748,7 @@ public:
   : TargetInfo(Triple), IsMips16(false), IsMicromips(false),
 IsNan2008(false), IsSingleFloat(false), IsNoABICalls(false),
 CanUseBSDABICalls(false), FloatABI(HardFloat), DspRev(NoDSP),
-HasMSA(false), HasFP64(false) {
+HasMSA(false), DisableMadd4(false), HasFP64(false) {
 TheCXXABI.set(TargetCXXABI::GenericMIPS);
 
 setABI((getTriple().getArch() == llvm::Triple::mips ||
@@ -7993,6 +7994,9 @@ public:
 if (HasMSA)
   Builder.defineMacro("__mips_msa", Twine(1));
 
+if (DisableMadd4)
+  Builder.defineMacro("__mips_no_madd4", Twine(1));
+
 Builder.defineMacro("_MIPS_SZPTR", Twine(getPointerWidth(0)));
 Builder.defineMacro("_MIPS_SZINT", Twine(getIntWidth()));
 Builder.defineMacro("_MIPS_SZLONG", Twine(getLongWidth()));
@@ -8155,6 +8159,8 @@ public:
 DspRev = std::max(DspRev, DSP2);
   else if (Feature == "+msa")
 HasMSA = true;
+  else if (Feature == "+nomadd4")
+DisableMadd4 = true;
   else if (Feature == "+fp64")
 HasFP64 = true;
   else if (Feature == "-fp64")

Modified: cfe/trunk/lib/Driver/ToolChains/Arch/Mips.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Arch/Mips.cpp?rev=304953&r1=304952&r2=304953&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Arch/Mips.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Arch/Mips.cpp Wed Jun  7 18:51:52 2017
@@ -298,6 +298,13 @@ void mips::getMIPSTargetFeatures(const D
 
   AddTargetFeature(Args, Features, options::OPT_mno_odd_spreg,
options::OPT_modd_spreg, "nooddspreg");
+
+  if (Arg *A = Args.getLastArg(options::OPT_mmadd4, options::OPT_mno_madd4)) {
+if (A->getOption().matches(options::OPT_mmadd4))
+  Features.push_back("-nomadd4");
+else
+  Features.push_back("+nomadd4");
+  }
 }
 
 mips::NanEncoding mips::getSupportedNanEncoding(StringRef &CPU) {

Added: cfe/trunk/test/CodeGen/mips-madd4.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/mips-madd4.c?rev=304953&view=auto
==
--- cfe/trunk/test/CodeGen/mips-madd4.c (added)
+++ cfe/trunk/test/CodeGen/mips-madd4.c Wed Jun  7 18:51:52 2017
@@ -0,0 +1,87 @@
+// REQUIRES: mips-registered-target
+// RUN: %clang --target=mips64-unknown-linux -S -mmadd4%s -o -| FileCheck 
%s -check-prefix=MADD4
+// RUN: %clang --target=mips64-unknown-linux -S -mno-madd4 %s -o -| 

[PATCH] D34018: Support __float128 on NetBSD libstdc++ x86/x86_64

2017-06-07 Thread Kamil Rytarowski via Phabricator via cfe-commits
krytarowski created this revision.

This adds support for __float128 from GNU libstdc++ with Clang on NetBSD 
x86/x86_64 targets.

This corrects compilation at least of CMake and probably others like Firefox.

In file included from 
/tmp/pkgsrc-tmp/devel/cmake/work/cmake-3.8.2/Source/kwsys/Directory.cxx:4:
In file included from 
/tmp/pkgsrc-tmp/devel/cmake/work/cmake-3.8.2/Source/cmsys/Directory.hxx:8:
In file included from /usr/include/g++/string:40:
In file included from /usr/include/g++/bits/char_traits.h:39:
In file included from /usr/include/g++/bits/stl_algobase.h:64:
In file included from /usr/include/g++/bits/stl_pair.h:59:
In file included from /usr/include/g++/bits/move.h:57:
/usr/include/g++/type_traits:311:39: error: __float128 is not supported on this 
target

  struct __is_floating_point_helper<__float128>
^

Sponsored by 


Repository:
  rL LLVM

https://reviews.llvm.org/D34018

Files:
  lib/Basic/Targets.cpp


Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -514,6 +514,8 @@
 Builder.defineMacro("__ELF__");
 if (Opts.POSIXThreads)
   Builder.defineMacro("_REENTRANT");
+if (this->HasFloat128)
+  Builder.defineMacro("__FLOAT128__");
 
 switch (Triple.getArch()) {
 default:
@@ -530,6 +532,15 @@
   NetBSDTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
   : OSTargetInfo(Triple, Opts) {
 this->MCountName = "_mcount";
+
+switch (Triple.getArch()) {
+default:
+  break;
+case llvm::Triple::x86:
+case llvm::Triple::x86_64:
+  this->HasFloat128 = true;
+  break;
+}
   }
 };
 


Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -514,6 +514,8 @@
 Builder.defineMacro("__ELF__");
 if (Opts.POSIXThreads)
   Builder.defineMacro("_REENTRANT");
+if (this->HasFloat128)
+  Builder.defineMacro("__FLOAT128__");
 
 switch (Triple.getArch()) {
 default:
@@ -530,6 +532,15 @@
   NetBSDTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
   : OSTargetInfo(Triple, Opts) {
 this->MCountName = "_mcount";
+
+switch (Triple.getArch()) {
+default:
+  break;
+case llvm::Triple::x86:
+case llvm::Triple::x86_64:
+  this->HasFloat128 = true;
+  break;
+}
   }
 };
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


RE: r304935 - Revert r304929 [mips] Add runtime options to enable/disable madd/sub.fmt

2017-06-07 Thread Petar Jovanovic via cfe-commits
I reverted the patch too quickly and have not noticed the file was not
actually deleted. I am reapplying the patch with minor modifications now,
hopefully no issues this time.

Thanks.

Regards,
Petar

From: Simon Dardis
Sent: Wednesday, June 07, 2017 10:36 PM
To: Evgenii Stepanov; Petar Jovanovic
Cc: cfe-commits
Subject: RE: r304935 - Revert r304929 [mips] Add runtime options to 
enable/disable madd/sub.fmt

Appears to be fixed, r304936. I'll keep an eye on the buildbots.

Thanks,
Simon

From: cfe-commits [cfe-commits-boun...@lists.llvm.org] on behalf of Evgenii 
Stepanov via cfe-commits [cfe-commits@lists.llvm.org]
Sent: 07 June 2017 20:53
To: Petar Jovanovic
Cc: cfe-commits
Subject: Re: r304935 - Revert r304929 [mips] Add runtime options to 
enable/disable madd/sub.fmt

You've left an empty file in test/CodeGen/mips-madd4.c

On Wed, Jun 7, 2017 at 11:57 AM, Petar Jovanovic via cfe-commits
 wrote:
> Author: petarj
> Date: Wed Jun  7 13:57:56 2017
> New Revision: 304935
>
> URL: http://llvm.org/viewvc/llvm-project?rev=304935&view=rev
> Log:
> Revert r304929 [mips] Add runtime options to enable/disable madd/sub.fmt
>
> Revert r304929 since the test broke buildbots.
>
> Original commit:
>
>   [mips] Add runtime options to enable/disable madd.fmt and msub.fmt
>
>   Add options to clang: -mmadd4 and -mno-madd4, use it to enable or disable
>   generation of madd.fmt and similar instructions respectively, as per GCC.
>
>   Patch by Stefan Maksimovic.
>
> Modified:
> cfe/trunk/include/clang/Driver/Options.td
> cfe/trunk/lib/Basic/Targets.cpp
> cfe/trunk/lib/Driver/ToolChains/Arch/Mips.cpp
> cfe/trunk/test/CodeGen/mips-madd4.c
> cfe/trunk/test/Preprocessor/init.c
>
> Modified: cfe/trunk/include/clang/Driver/Options.td
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=304935&r1=304934&r2=304935&view=diff
> ==
> --- cfe/trunk/include/clang/Driver/Options.td (original)
> +++ cfe/trunk/include/clang/Driver/Options.td Wed Jun  7 13:57:56 2017
> @@ -2001,10 +2001,6 @@ def mdspr2 : Flag<["-"], "mdspr2">, Grou
>  def mno_dspr2 : Flag<["-"], "mno-dspr2">, Group;
>  def msingle_float : Flag<["-"], "msingle-float">, Group;
>  def mdouble_float : Flag<["-"], "mdouble-float">, Group;
> -def mmadd4 : Flag<["-"], "mmadd4">, Group,
> -  HelpText<"Enable the generation of 4-operand madd.s, madd.d and related 
> instructions.">;
> -def mno_madd4 : Flag<["-"], "mno-madd4">, Group,
> -  HelpText<"Disable the generation of 4-operand madd.s, madd.d and related 
> instructions.">;
>  def mmsa : Flag<["-"], "mmsa">, Group,
>HelpText<"Enable MSA ASE (MIPS only)">;
>  def mno_msa : Flag<["-"], "mno-msa">, Group,
>
> Modified: cfe/trunk/lib/Basic/Targets.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=304935&r1=304934&r2=304935&view=diff
> ==
> --- cfe/trunk/lib/Basic/Targets.cpp (original)
> +++ cfe/trunk/lib/Basic/Targets.cpp Wed Jun  7 13:57:56 2017
> @@ -7737,7 +7737,6 @@ class MipsTargetInfo : public TargetInfo
>  NoDSP, DSP1, DSP2
>} DspRev;
>bool HasMSA;
> -  bool DisableMadd4;
>
>  protected:
>bool HasFP64;
> @@ -7748,7 +7747,7 @@ public:
>: TargetInfo(Triple), IsMips16(false), IsMicromips(false),
>  IsNan2008(false), IsSingleFloat(false), IsNoABICalls(false),
>  CanUseBSDABICalls(false), FloatABI(HardFloat), DspRev(NoDSP),
> -HasMSA(false), DisableMadd4(false), HasFP64(false) {
> +HasMSA(false), HasFP64(false) {
>  TheCXXABI.set(TargetCXXABI::GenericMIPS);
>
>  setABI((getTriple().getArch() == llvm::Triple::mips ||
> @@ -7994,9 +7993,6 @@ public:
>  if (HasMSA)
>Builder.defineMacro("__mips_msa", Twine(1));
>
> -if (DisableMadd4)
> -  Builder.defineMacro("__mips_no_madd4", Twine(1));
> -
>  Builder.defineMacro("_MIPS_SZPTR", Twine(getPointerWidth(0)));
>  Builder.defineMacro("_MIPS_SZINT", Twine(getIntWidth()));
>  Builder.defineMacro("_MIPS_SZLONG", Twine(getLongWidth()));
> @@ -8159,8 +8155,6 @@ public:
>  DspRev = std::max(DspRev, DSP2);
>else if (Feature == "+msa")
>  HasMSA = true;
> -  else if (Feature == "+nomadd4")
> -DisableMadd4 = true;
>else if (Feature == "+fp64")
>  HasFP64 = true;
>else if (Feature == "-fp64")
>
> Modified: cfe/trunk/lib/Driver/ToolChains/Arch/Mips.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Arch/Mips.cpp?rev=304935&r1=304934&r2=304935&view=diff
> ==
> --- cfe/trunk/lib/Driver/ToolChains/Arch/Mips.cpp (original)
> +++ cfe/trunk/lib/Driver/ToolChains/Arch/Mips.cpp Wed Jun  7 13:57:56 2017
> @@ -298,13 +298,6

[PATCH] D33478: [libclang] When getting platform availabilities, merge multiple declarations if possible

2017-06-07 Thread Ronald Wampler via Phabricator via cfe-commits
rdwampler marked an inline comment as done.
rdwampler added inline comments.



Comment at: test/Index/availability.c:20
 // CHECK-2: (macos, introduced=10.4, deprecated=10.5, obsoleted=10.7)
 
 // CHECK-2: EnumConstantDecl=old_enum:6:3 (Definition) (deprecated)

Can we run `FileCheck` once now? I believe the `CHECK-1` and `CHECK-2` were 
added since there were no particular order for the availabilities. With this 
patch the order is guarantee to be stable.



Comment at: tools/libclang/CIndex.cpp:7268
+(!LHS->getObsoleted().empty() && !RHS->getObsoleted().empty()) ||
+(!LHS->getMessage().empty() && !RHS->getMessage().empty()))
+  return false;

arphaman wrote:
> I think that we don't really need the `(!LHS->getMessage().empty() && 
> !RHS->getMessage().empty())` check here since message has to be either in a 
> deprecated or obsoleted clause, so we should already handle that with 
> previous checks.
Agreed.


https://reviews.llvm.org/D33478



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


[libcxx] r304955 - Fix class template deduction for scoped_lock.

2017-06-07 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Wed Jun  7 19:38:56 2017
New Revision: 304955

URL: http://llvm.org/viewvc/llvm-project?rev=304955&view=rev
Log:
Fix class template deduction for scoped_lock.

r304862 changed how CTD handles deducing a non-primary class template
using a non-dependent constructor of the primary template. This change
requires libc++ to provide explicit deduction guides to make scoped_lock
work again.

Modified:
libcxx/trunk/include/mutex

Modified: libcxx/trunk/include/mutex
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/mutex?rev=304955&r1=304954&r2=304955&view=diff
==
--- libcxx/trunk/include/mutex (original)
+++ libcxx/trunk/include/mutex Wed Jun  7 19:38:56 2017
@@ -502,7 +502,6 @@ public:
 _LIBCPP_INLINE_VISIBILITY
 explicit scoped_lock(mutex_type& __m, adopt_lock_t) 
_LIBCPP_THREAD_SAFETY_ANNOTATION(requires_capability(__m))
 : __m_(__m) {}
-
 
 scoped_lock(scoped_lock const&) = delete;
 scoped_lock& operator=(scoped_lock const&) = delete;
@@ -547,6 +546,11 @@ private:
 _MutexTuple __t_;
 };
 
+#ifdef __cpp_deduction_guides
+template  explicit scoped_lock(_Mutex&) -> scoped_lock<_Mutex>;
+explicit scoped_lock() -> scoped_lock<>;
+#endif
+
 #endif // _LIBCPP_STD_VER > 14
 #endif // !_LIBCPP_HAS_NO_THREADS
 


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


r304956 - [ODRHash] Change the fall-back diagnostic error.

2017-06-07 Thread Richard Trieu via cfe-commits
Author: rtrieu
Date: Wed Jun  7 19:56:21 2017
New Revision: 304956

URL: http://llvm.org/viewvc/llvm-project?rev=304956&view=rev
Log:
[ODRHash] Change the fall-back diagnostic error.

Provide a little more information when a ODR violation is detected, but the
specific error could not be diagnosed.

Modified:
cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td
cfe/trunk/lib/Serialization/ASTReader.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td?rev=304956&r1=304955&r2=304956&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td Wed Jun  7 
19:56:21 2017
@@ -174,6 +174,13 @@ def note_module_odr_violation_mismatch_d
   "method %2 with %ordinal3 parameter of type %4%select{| decayed from %6}5|"
   "method %2 with %ordinal3 parameter named %4}1">;
 
+def err_module_odr_violation_mismatch_decl_unknown : Error<
+  "%q0 has different definitions in different modules; first difference is "
+  "%select{definition in module '%2'|defined here}1 found different "
+  "%select{static assert|field|method|other}3">;
+def note_module_odr_violation_mismatch_decl_unknown : Note<
+  "but in '%0' found different %select{static 
assert|field|method|other}1">;
+
 def warn_duplicate_module_file_extension : Warning<
   "duplicate module file extension block name '%0'">,
   InGroup;

Modified: cfe/trunk/lib/Serialization/ASTReader.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=304956&r1=304955&r2=304956&view=diff
==
--- cfe/trunk/lib/Serialization/ASTReader.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReader.cpp Wed Jun  7 19:56:21 2017
@@ -9753,13 +9753,13 @@ void ASTReader::diagnoseOdrViolations()
   if (Diagnosed == true)
 continue;
 
-  Diag(FirstRecord->getLocation(),
-   diag::err_module_odr_violation_different_definitions)
-  << FirstRecord << FirstModule.empty() << FirstModule;
-
-  Diag(SecondRecord->getLocation(),
-   diag::note_module_odr_violation_different_definitions)
-  << SecondModule;
+  Diag(FirstDecl->getLocation(),
+   diag::err_module_odr_violation_mismatch_decl_unknown)
+  << FirstRecord << FirstModule.empty() << FirstModule << FirstDiffType
+  << FirstDecl->getSourceRange();
+  Diag(SecondDecl->getLocation(),
+   diag::note_module_odr_violation_mismatch_decl_unknown)
+  << SecondModule << FirstDiffType << SecondDecl->getSourceRange();
   Diagnosed = true;
 }
 


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


  1   2   >