[PATCH] D21547: Added calculateRangesAfterReplaments() to calculate affacted ranges in the new code.

2016-06-20 Thread Eric Liu via cfe-commits
ioeric created this revision.
ioeric added reviewers: djasper, klimek.
ioeric added a subscriber: cfe-commits.
Herald added a subscriber: klimek.

Added calculateRangesAfterReplaments() to calculate original ranges as well as
newly affacted ranges in the new code.

http://reviews.llvm.org/D21547

Files:
  include/clang/Tooling/Core/Replacement.h
  lib/Tooling/Core/Replacement.cpp
  unittests/Tooling/RefactoringTest.cpp

Index: unittests/Tooling/RefactoringTest.cpp
===
--- unittests/Tooling/RefactoringTest.cpp
+++ unittests/Tooling/RefactoringTest.cpp
@@ -471,6 +471,91 @@
   EXPECT_TRUE(Ranges[2].getLength() == 16);
 }
 
+TEST(Range, RangesAfterReplacements) {
+  std::vector Ranges = {Range(5, 2), Range(10, 5)};
+  Replacements Replaces = {Replacement("foo", 0, 2, "1234")};
+  std::vector Expected = {Range(0, 4), Range(7, 2), Range(12, 5)};
+  EXPECT_EQ(Expected, calculateRangesAfterReplacements(Replaces, Ranges));
+}
+
+TEST(Range, RangesBeforeReplacements) {
+  std::vector Ranges = {Range(5, 2), Range(10, 5)};
+  Replacements Replaces = {Replacement("foo", 20, 2, "1234")};
+  std::vector Expected = {Range(5, 2), Range(10, 5), Range(20, 4)};
+  EXPECT_EQ(Expected, calculateRangesAfterReplacements(Replaces, Ranges));
+}
+
+TEST(Range, NotAffectedByReplacements) {
+  std::vector Ranges = {Range(0, 2), Range(5, 2), Range(10, 5)};
+  Replacements Replaces = {Replacement("foo", 3, 2, "12"),
+   Replacement("foo", 12, 2, "12"),
+   Replacement("foo", 20, 5, "")};
+  std::vector Expected = {Range(0, 2), Range(3, 4), Range(10, 5),
+ Range(20, 0)};
+  EXPECT_EQ(Expected, calculateRangesAfterReplacements(Replaces, Ranges));
+}
+
+TEST(Range, RangesWithNonOverlappingReplacements) {
+  std::vector Ranges = {Range(0, 2), Range(5, 2), Range(10, 5)};
+  Replacements Replaces = {Replacement("foo", 3, 1, ""),
+   Replacement("foo", 6, 1, "123"),
+   Replacement("foo", 20, 2, "12345")};
+  std::vector Expected = {Range(0, 2), Range(3, 0), Range(4, 4),
+ Range(11, 5), Range(21, 5)};
+  EXPECT_EQ(Expected, calculateRangesAfterReplacements(Replaces, Ranges));
+}
+
+TEST(Range, RangesWithOverlappingReplacements) {
+  std::vector Ranges = {Range(0, 2), Range(5, 2), Range(15, 5),
+   Range(30, 5)};
+  Replacements Replaces = {
+  Replacement("foo", 1, 3, ""), Replacement("foo", 6, 1, "123"),
+  Replacement("foo", 13, 3, "1"), Replacement("foo", 25, 15, "")};
+  std::vector Expected = {Range(0, 1), Range(2, 4), Range(12, 5),
+ Range(22, 0)};
+  EXPECT_EQ(Expected, calculateRangesAfterReplacements(Replaces, Ranges));
+}
+
+TEST(Range, MergeIntoOneRange) {
+  std::vector Ranges = {Range(0, 2), Range(5, 2), Range(15, 5)};
+  Replacements Replaces = {Replacement("foo", 1, 15, "1234567890")};
+  std::vector Expected = {Range(0, 15)};
+  EXPECT_EQ(Expected, calculateRangesAfterReplacements(Replaces, Ranges));
+}
+
+TEST(Range, ReplacementsStartingAtRangeOffsets) {
+  std::vector Ranges = {Range(0, 2), Range(5, 5), Range(15, 5)};
+  Replacements Replaces = {
+  Replacement("foo", 0, 2, "12"), Replacement("foo", 5, 1, "123"),
+  Replacement("foo", 7, 4, "12345"), Replacement("foo", 15, 10, "12")};
+  std::vector Expected = {Range(0, 2), Range(5, 9), Range(18, 2)};
+  EXPECT_EQ(Expected, calculateRangesAfterReplacements(Replaces, Ranges));
+}
+
+TEST(Range, ReplacementsEndingAtRangeEnds) {
+  std::vector Ranges = {Range(0, 2), Range(5, 2), Range(15, 5)};
+  Replacements Replaces = {Replacement("foo", 6, 1, "123"),
+   Replacement("foo", 17, 3, "12")};
+  std::vector Expected = {Range(0, 2), Range(5, 4), Range(17, 4)};
+  EXPECT_EQ(Expected, calculateRangesAfterReplacements(Replaces, Ranges));
+}
+
+TEST(Range, AjacentReplacements) {
+  std::vector Ranges = {Range(0, 0), Range(15, 5)};
+  Replacements Replaces = {Replacement("foo", 1, 2, "123"),
+   Replacement("foo", 12, 3, "1234")};
+  std::vector Expected = {Range(0, 0), Range(1, 3), Range(13, 9)};
+  EXPECT_EQ(Expected, calculateRangesAfterReplacements(Replaces, Ranges));
+}
+
+TEST(Range, MergeRangesAfterReplacements) {
+  std::vector Ranges = {Range(8, 0), Range(5, 2), Range(9, 0), Range(0, 1)};
+  Replacements Replaces = {Replacement("foo", 1, 3, ""),
+   Replacement("foo", 7, 0, "12"), Replacement("foo", 9, 2, "")};
+  std::vector Expected = {Range(0, 1), Range(2, 4), Range(7, 0), Range(8, 0)};
+  EXPECT_EQ(Expected, calculateRangesAfterReplacements(Replaces, Ranges));
+}
+
 TEST(DeduplicateTest, removesDuplicates) {
   std::vector Input;
   Input.push_back(Replacement("fileA", 50, 0, " foo "));
Index: lib/Tooling/Core/Replacement.cpp
===
--- 

Re: [libcxx] r273034 - Add Filesystem TS -- Complete

2016-06-20 Thread Eric Fiselier via cfe-commits
Hi Artem,

Sorry for the delay, I've been busy with school all day.
I'll check in a fix tomorrow morning.

Sorry again,

/Eric

On Mon, Jun 20, 2016 at 2:31 PM, Eric Fiselier  wrote:

> Oh shoot, I definitely didn't take that into account. I'll put together a
> fix.
>
> /Eric
>
>
>
> On Mon, Jun 20, 2016 at 2:27 PM, Artem Belevich  wrote:
>
>> Eric,
>>
>> Some tests appear to fail if the path to the tests' current directory has
>> some symlinks in it.
>> In my case source and build tree are in directory 'work' that's symlinked
>> to from my home directory:
>> /usr/local/home/tra/work -> /work/tra
>>
>> This causes multiple failures in libcxx tests. One example:
>>
>>
>> projects/libcxx/test/std/experimental/filesystem/fs.op.funcs/fs.op.rename/rename.pass.cpp:121
>> 121TEST_CHECK(read_symlink(bad_sym_dest) == dne);
>>
>> dne:
>>
>> /usr/local/home/tra/work/llvm/build/gpu/debug/projects/libcxx/test/filesystem/Output/dynamic_env/test.529143/dne
>> bad_sym_dest:
>>
>> /usr/local/home/tra/work/llvm/build/gpu/debug/projects/libcxx/test/filesystem/Output/dynamic_env/test.529143/bad_sym2
>>
>> These are the paths that traverse the 'work' symlink in my home
>> directory. However, the symlink that we're reading contains physical path
>> to the directory. While it does link to the right place, it's not the path
>> the test expects.
>>
>> #readlink
>> /usr/local/home/tra/work/llvm/build/gpu/debug/projects/libcxx/test/filesystem/Output/dynamic_env/test.529143/bad_sym2
>>
>> /work/tra/llvm/build/gpu/debug/projects/libcxx/test/filesystem/Output/dynamic_env/test.529143/dne
>>
>> I think we need to normalize paths before we compare them.
>>
>> --Artem
>>
>>
>> On Sat, Jun 18, 2016 at 12:03 PM, Eric Fiselier via cfe-commits <
>> cfe-commits@lists.llvm.org> wrote:
>>
>>> > I assume the correct way to fix this is to disable
>>> -Wcovered-switch-default while compiling libcxx/src/experimental/
>>> filesystem/operations.cpp
>>>
>>> Agreed. Disabled in r273092.
>>>
>>> Thanks for your patience with this latest change,
>>>
>>> /Eric
>>>
>>> On Sat, Jun 18, 2016 at 12:54 PM, Adrian Prantl 
>>> wrote:
>>>
 Hello Eric,

 this commit causes new warnings on our bots:

 clang/src/projects/libcxx/include/fstream:816:5: warning: default label
 in switch which covers all enumeration values [-Wcovered-switch-default]
 default:

 The problem is with this defensive default statement in fstream:


  template 
 0792 typename basic_filebuf<_CharT, _Traits>::pos_type
 0793 basic_filebuf<_CharT, _Traits>::seekoff(off_type __off,
 ios_base::seekdir __way,
 0794 ios_base::openmode)
 0795 {
 0796 #ifndef _LIBCPP_NO_EXCEPTIONS
 0797 if (!__cv_)
 0798 throw bad_cast();
 0799 #endif
 0800 int __width = __cv_->encoding();
 0801 if (__file_ == 0 || (__width <= 0 && __off != 0) || sync())
 0802 return pos_type(off_type(-1));
 0803 // __width > 0 || __off == 0
 0804 int __whence;
 0805 switch (__way)
 0806 {
 0807 case ios_base::beg:
 0808 __whence = SEEK_SET;
 0809 break;
 0810 case ios_base::cur:
 0811 __whence = SEEK_CUR;
 0812 break;
 0813 case ios_base::end:
 0814 __whence = SEEK_END;
 0815 break;
 0816 default:
 0817 return pos_type(off_type(-1));
 0818 }


 I assume the correct way to fix this is to disable
 -Wcovered-switch-default while compiling
 libcxx/src/experimental/filesystem/operations.cpp

 Could you please investigate?

 thanks,
 Adrian
>>>
>>>
>>>
>>> ___
>>> cfe-commits mailing list
>>> cfe-commits@lists.llvm.org
>>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>>>
>>>
>>
>>
>> --
>> --Artem Belevich
>>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r273239 - r273237 fixed PR28220, not PR28216

2016-06-20 Thread David Majnemer via cfe-commits
Author: majnemer
Date: Mon Jun 20 22:43:11 2016
New Revision: 273239

URL: http://llvm.org/viewvc/llvm-project?rev=273239=rev
Log:
r273237 fixed PR28220, not PR28216

Added:
cfe/trunk/test/CodeGenCXX/PR28220.cpp
  - copied, changed from r273237, cfe/trunk/test/CodeGenCXX/PR28216.cpp
Removed:
cfe/trunk/test/CodeGenCXX/PR28216.cpp

Removed: cfe/trunk/test/CodeGenCXX/PR28216.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/PR28216.cpp?rev=273238=auto
==
--- cfe/trunk/test/CodeGenCXX/PR28216.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/PR28216.cpp (removed)
@@ -1,19 +0,0 @@
-// RUN: %clang_cc1 %s -triple i686-pc-win32 -fms-extensions -emit-llvm -o - | 
FileCheck %s
-
-template 
-struct __declspec(dllimport) S {
-  S();
-};
-
-template 
-struct __declspec(dllimport) U {
-  static S u;
-};
-
-template 
-S U::u;
-
-template S U::u;
-// CHECK-NOT: define internal void @"\01??__Eu@?$U@H@@2U?$S@H@@A@YAXXZ"(
-
-S  = U::u;

Copied: cfe/trunk/test/CodeGenCXX/PR28220.cpp (from r273237, 
cfe/trunk/test/CodeGenCXX/PR28216.cpp)
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/PR28220.cpp?p2=cfe/trunk/test/CodeGenCXX/PR28220.cpp=cfe/trunk/test/CodeGenCXX/PR28216.cpp=273237=273239=273239=diff
==
(empty)


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


r273237 - [CodeGen] Do not run initializers for imported variables

2016-06-20 Thread David Majnemer via cfe-commits
Author: majnemer
Date: Mon Jun 20 22:40:16 2016
New Revision: 273237

URL: http://llvm.org/viewvc/llvm-project?rev=273237=rev
Log:
[CodeGen] Do not run initializers for imported variables

The export side is responsible for running any initializers, they are
run when the module is first loaded.  Attempting to run an initializer
for the import side is not possible.

This fixes PR28216.

Added:
cfe/trunk/test/CodeGenCXX/PR28216.cpp
Modified:
cfe/trunk/lib/CodeGen/CGDeclCXX.cpp

Modified: cfe/trunk/lib/CodeGen/CGDeclCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDeclCXX.cpp?rev=273237=273236=273237=diff
==
--- cfe/trunk/lib/CodeGen/CGDeclCXX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDeclCXX.cpp Mon Jun 20 22:40:16 2016
@@ -323,6 +323,10 @@ CodeGenModule::EmitCXXGlobalVarDeclInitF
D->hasAttr()))
 return;
 
+  // DLL imported variables will be initialized by the export side.
+  if (D->hasAttr())
+return;
+
   // Check if we've already initialized this decl.
   auto I = DelayedCXXInitPosition.find(D);
   if (I != DelayedCXXInitPosition.end() && I->second == ~0U)

Added: cfe/trunk/test/CodeGenCXX/PR28216.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/PR28216.cpp?rev=273237=auto
==
--- cfe/trunk/test/CodeGenCXX/PR28216.cpp (added)
+++ cfe/trunk/test/CodeGenCXX/PR28216.cpp Mon Jun 20 22:40:16 2016
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 %s -triple i686-pc-win32 -fms-extensions -emit-llvm -o - | 
FileCheck %s
+
+template 
+struct __declspec(dllimport) S {
+  S();
+};
+
+template 
+struct __declspec(dllimport) U {
+  static S u;
+};
+
+template 
+S U::u;
+
+template S U::u;
+// CHECK-NOT: define internal void @"\01??__Eu@?$U@H@@2U?$S@H@@A@YAXXZ"(
+
+S  = U::u;


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


Re: [PATCH] D21542: CodeGen: Replace test/CodeGen/thinlto_backend.c with a functional test.

2016-06-20 Thread Teresa Johnson via cfe-commits
tejohnson accepted this revision.
tejohnson added a comment.
This revision is now accepted and ready to land.

LGTM but with one question: Any issue with IR tests in clang tests? I noticed 
that there are very few (although there is already one existing .ll in 
test/CodeGen).


http://reviews.llvm.org/D21542



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


Re: [PATCH] D21544: [MS] Don't expect vftables to be provided for extern template instantiations

2016-06-20 Thread David Majnemer via cfe-commits
majnemer accepted this revision.
majnemer added a comment.
This revision is now accepted and ready to land.

LGTM


http://reviews.llvm.org/D21544



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


r273232 - [Docs] More warning fixes to unbreak the docs buildbot.

2016-06-20 Thread George Burgess IV via cfe-commits
Author: gbiv
Date: Mon Jun 20 21:19:43 2016
New Revision: 273232

URL: http://llvm.org/viewvc/llvm-project?rev=273232=rev
Log:
[Docs] More warning fixes to unbreak the docs buildbot.

A number of warnings still remain, but these were the last of the
"unlexable code"-related ones (AFAICT).

I changed a few examples in docs/UsersManual.rst to showcase
-Wextra-tokens because it's already documented (-Wmultichar isn't), and
the sphinx C lexer apparently can't handle char literals like 'ab'. It
seemed like a better overall approach than just marking the code blocks
as none or console.

Modified:
cfe/trunk/docs/SourceBasedCodeCoverage.rst
cfe/trunk/docs/ThreadSanitizer.rst
cfe/trunk/docs/UsersManual.rst

Modified: cfe/trunk/docs/SourceBasedCodeCoverage.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/SourceBasedCodeCoverage.rst?rev=273232=273231=273232=diff
==
--- cfe/trunk/docs/SourceBasedCodeCoverage.rst (original)
+++ cfe/trunk/docs/SourceBasedCodeCoverage.rst Mon Jun 20 21:19:43 2016
@@ -123,7 +123,7 @@ distinct views for ``foo(...)`` and
 ``-show-line-counts-or-regions`` is enabled, ``llvm-cov`` displays sub-line
 region counts (even in macro expansions):
 
-.. code-block:: cpp
+.. code-block:: none
 
20|1|#define BAR(x) ((x) || (x))
^20 ^2

Modified: cfe/trunk/docs/ThreadSanitizer.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ThreadSanitizer.rst?rev=273232=273231=273232=diff
==
--- cfe/trunk/docs/ThreadSanitizer.rst (original)
+++ cfe/trunk/docs/ThreadSanitizer.rst Mon Jun 20 21:19:43 2016
@@ -30,7 +30,7 @@ and line numbers in the warning messages
 
 Example:
 
-.. code-block:: c++
+.. code-block:: console
 
   % cat projects/compiler-rt/lib/tsan/lit_tests/tiny_race.c
   #include 

Modified: cfe/trunk/docs/UsersManual.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/UsersManual.rst?rev=273232=273231=273232=diff
==
--- cfe/trunk/docs/UsersManual.rst (original)
+++ cfe/trunk/docs/UsersManual.rst Mon Jun 20 21:19:43 2016
@@ -711,16 +711,19 @@ also allows you to push and pop the curr
 particularly useful when writing a header file that will be compiled by
 other people, because you don't know what warning flags they build with.
 
-In the below example :option:`-Wmultichar` is ignored for only a single line of
-code, after which the diagnostics return to whatever state had previously
+In the below example :option:`-Wextra-tokens` is ignored for only a single line
+of code, after which the diagnostics return to whatever state had previously
 existed.
 
 .. code-block:: c
 
-  #pragma clang diagnostic push
-  #pragma clang diagnostic ignored "-Wmultichar"
+  #if foo
+  #endif foo // warning: extra tokens at end of #endif directive
 
-  char b = 'df'; // no warning.
+  #pragma clang diagnostic ignored "-Wextra-tokens"
+
+  #if foo
+  #endif foo // no warning
 
   #pragma clang diagnostic pop
 
@@ -772,11 +775,13 @@ the pragma onwards within the same file.
 
 .. code-block:: c
 
-  char a = 'xy'; // warning
+  #if foo
+  #endif foo // warning: extra tokens at end of #endif directive
 
   #pragma clang system_header
 
-  char b = 'ab'; // no warning
+  #if foo
+  #endif foo // no warning
 
 The :option:`--system-header-prefix=` and :option:`--no-system-header-prefix=`
 command-line arguments can be used to override whether subsets of an include


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


r273230 - clang/test/Headers/opencl-c-header.cl: Add explicit -triple x86_64-unknown to appease *-win32 targets.

2016-06-20 Thread NAKAMURA Takumi via cfe-commits
Author: chapuni
Date: Mon Jun 20 20:54:54 2016
New Revision: 273230

URL: http://llvm.org/viewvc/llvm-project?rev=273230=rev
Log:
clang/test/Headers/opencl-c-header.cl: Add explicit -triple x86_64-unknown to 
appease *-win32 targets.

  :9:25: note: possible intended match here
   %call = tail call i8 @"\01?convert_char_rte@@$$J0YADD@Z"(i8 %x) #2
  ^

Modified:
cfe/trunk/test/Headers/opencl-c-header.cl

Modified: cfe/trunk/test/Headers/opencl-c-header.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Headers/opencl-c-header.cl?rev=273230=273229=273230=diff
==
--- cfe/trunk/test/Headers/opencl-c-header.cl (original)
+++ cfe/trunk/test/Headers/opencl-c-header.cl Mon Jun 20 20:54:54 2016
@@ -27,7 +27,7 @@
 // RUN: %clang_cc1 -triple nvptx64-unknown-unknown -internal-isystem 
../../lib/Headers -include opencl-c.h -emit-llvm -o - %s -cl-std=CL1.2| 
FileCheck %s
 // RUN: %clang_cc1 -triple nvptx64-unknown-unknown -internal-isystem 
../../lib/Headers -include opencl-c.h -fblocks -emit-llvm -o - %s 
-cl-std=CL2.0| FileCheck --check-prefix=CHECK20 %s
 
-// RUN: %clang_cc1 -finclude-default-header -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -finclude-default-header 
-emit-llvm -o - %s | FileCheck %s
 // CHECK: _Z16convert_char_rtec
 // CHECK-NOT: _Z3ctzc
 // CHECK20: _Z3ctzc


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


[PATCH] D21545: CodeGen: Replace ThinLTO backend implementation with a client of LTO/Resolution.

2016-06-20 Thread Peter Collingbourne via cfe-commits
pcc created this revision.
pcc added reviewers: tejohnson, mehdi_amini.
pcc added a subscriber: cfe-commits.
pcc added dependencies: D21542: CodeGen: Replace test/CodeGen/thinlto_backend.c 
with a functional test., D20268: [wip] Resolution-based LTO API., D21537: 
Frontend: Simplify ownership model for clang's output streams..
Herald added a subscriber: mehdi_amini.

This changes clang to use the llvm::lto::thinBackend function instead of
its own less comprehensive ThinLTO backend implementation.

Depends on D20268

Depends on D21537

Depends on D21542

http://reviews.llvm.org/D21545

Files:
  lib/CodeGen/BackendUtil.cpp
  lib/CodeGen/CMakeLists.txt
  lib/Driver/Tools.cpp
  test/Driver/thinlto_backend.c

Index: test/Driver/thinlto_backend.c
===
--- test/Driver/thinlto_backend.c
+++ test/Driver/thinlto_backend.c
@@ -6,5 +6,9 @@
 // CHECK-THINLTOBE-ACTION: -fthinlto-index=
 
 // Ensure clang driver gives the expected error for incorrect input type
-// RUN: not %clang -O2 -o %t1.o %s -c -fthinlto-index=%t.thinlto.bc 2>&1 | FileCheck %s -check-prefix=CHECK-WARNING
-// CHECK-WARNING: error: invalid argument '-fthinlto-index={{.*}}' only allowed with '-x ir'
+// RUN: not %clang -O2 -o %t1.o %s -c -fthinlto-index=%t.thinlto.bc 2>&1 | FileCheck %s -check-prefix=CHECK-ERR1
+// CHECK-ERR1: error: invalid argument '-fthinlto-index={{.*}}' only allowed with '-x ir'
+
+// And for incorrect output type
+// RUN: not %clang -O2 -o %t1.o -x ir %s -S -fthinlto-index=%t.thinlto.bc 2>&1 | FileCheck %s -check-prefix=CHECK-ERR2
+// CHECK-ERR2: error: invalid argument '-fthinlto-index={{.*}}' only allowed with '-c'
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -3891,6 +3891,9 @@
 if (!types::isLLVMIR(Input.getType()))
   D.Diag(diag::err_drv_argument_only_allowed_with) << A->getAsString(Args)
<< "-x ir";
+if (!isa(JA))
+  D.Diag(diag::err_drv_argument_only_allowed_with) << A->getAsString(Args)
+   << "-c";
 Args.AddLastArg(CmdArgs, options::OPT_fthinlto_index_EQ);
   }
 
Index: lib/CodeGen/CMakeLists.txt
===
--- lib/CodeGen/CMakeLists.txt
+++ lib/CodeGen/CMakeLists.txt
@@ -8,6 +8,7 @@
   IRReader
   InstCombine
   Instrumentation
+  LTOResolution
   Linker
   MC
   ObjCARCOpts
Index: lib/CodeGen/BackendUtil.cpp
===
--- lib/CodeGen/BackendUtil.cpp
+++ lib/CodeGen/BackendUtil.cpp
@@ -29,9 +29,11 @@
 #include "llvm/IR/LegacyPassManager.h"
 #include "llvm/IR/Module.h"
 #include "llvm/IR/Verifier.h"
+#include "llvm/LTO/Resolution/LTOBackend.h"
 #include "llvm/MC/SubtargetFeature.h"
 #include "llvm/Object/ModuleSummaryIndexObjectFile.h"
 #include "llvm/Support/CommandLine.h"
+#include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/PrettyStackTrace.h"
 #include "llvm/Support/TargetRegistry.h"
 #include "llvm/Support/Timer.h"
@@ -74,8 +76,7 @@
   /// Set LLVM command line options passed through -backend-option.
   void setCommandLineOpts();
 
-  void CreatePasses(legacy::PassManager , legacy::FunctionPassManager ,
-ModuleSummaryIndex *ModuleSummary);
+  void CreatePasses(legacy::PassManager , legacy::FunctionPassManager );
 
   /// Generates the TargetMachine.
   /// Leaves TM unchanged if it is unable to create the target machine.
@@ -275,8 +276,7 @@
 }
 
 void EmitAssemblyHelper::CreatePasses(legacy::PassManager ,
-  legacy::FunctionPassManager ,
-  ModuleSummaryIndex *ModuleSummary) {
+  legacy::FunctionPassManager ) {
   if (CodeGenOpts.DisableLLVMPasses)
 return;
 
@@ -327,14 +327,6 @@
   PMBuilder.PrepareForLTO = CodeGenOpts.PrepareForLTO;
   PMBuilder.RerollLoops = CodeGenOpts.RerollLoops;
 
-  // If we are performing a ThinLTO importing compile, invoke the LTO
-  // pipeline and pass down the in-memory module summary index.
-  if (ModuleSummary) {
-PMBuilder.ModuleSummary = ModuleSummary;
-PMBuilder.populateThinLTOPassManager(MPM);
-return;
-  }
-
   // Add target-specific passes that need to run as early as possible.
   if (TM)
 PMBuilder.addExtension(
@@ -652,35 +644,15 @@
   if (TM)
 TheModule->setDataLayout(TM->createDataLayout());
 
-  // If we are performing a ThinLTO importing compile, load the function
-  // index into memory and pass it into CreatePasses, which will add it
-  // to the PassManagerBuilder and invoke LTO passes.
-  std::unique_ptr ModuleSummary;
-  if (!CodeGenOpts.ThinLTOIndexFile.empty()) {
-ErrorOr IndexOrErr =
-llvm::getModuleSummaryIndexForFile(
-CodeGenOpts.ThinLTOIndexFile, [&](const 

[PATCH] D21544: [MS] Don't expect vftables to be provided for extern template instantiations

2016-06-20 Thread Reid Kleckner via cfe-commits
rnk created this revision.
rnk added a reviewer: majnemer.
rnk added a subscriber: cfe-commits.

MSVC doesn't provide them. PR28223

I left behind the machinery in case we want to resurrect available_externally
vftable emission to support devirtualization.

http://reviews.llvm.org/D21544

Files:
  lib/AST/VTableBuilder.cpp
  lib/CodeGen/CGVTables.cpp
  test/CodeGenCXX/microsoft-abi-vbtables.cpp
  test/CodeGenCXX/microsoft-abi-vftables.cpp

Index: test/CodeGenCXX/microsoft-abi-vftables.cpp
===
--- test/CodeGenCXX/microsoft-abi-vftables.cpp
+++ test/CodeGenCXX/microsoft-abi-vftables.cpp
@@ -33,7 +33,7 @@
 
 namespace {
 struct W {
-  virtual ~W();
+  virtual ~W() {}
 } w;
 }
 // RTTI-DAG: [[VTABLE_W:@.*]] = private unnamed_addr constant [2 x i8*] [i8* 
bitcast ({{.*}} @"\01??_R4W@?A@@6B@" to i8*), i8* bitcast ({{.*}} 
@"\01??_GW@?A@@UAEPAXI@Z" to i8*)]
@@ -49,5 +49,7 @@
 
 extern template class Y;
 template Y::Y();
-// RTTI-DAG: @"\01??_7?$Y@H@@6B@" = external unnamed_addr constant [1 x i8*]
-// NO-RTTI-DAG: @"\01??_7?$Y@H@@6B@" = external unnamed_addr constant [1 x i8*]
+// RTTI-DAG: [[VTABLE_Y:@.*]] = private unnamed_addr constant [2 x i8*] [i8* 
bitcast (%rtti.CompleteObjectLocator* @"\01??_R4?$Y@H@@6B@" to i8*), i8* 
bitcast (i8* (%struct.Y*, i32)* @"\01??_G?$Y@H@@UAEPAXI@Z" to i8*)], 
comdat($"\01??_7?$Y@H@@6B@")
+// RTTI-DAG: @"\01??_7?$Y@H@@6B@" = unnamed_addr alias i8*, getelementptr 
inbounds ([2 x i8*], [2 x i8*]* [[VTABLE_Y]], i32 0, i32 1)
+
+// NO-RTTI-DAG: @"\01??_7?$Y@H@@6B@" = linkonce_odr unnamed_addr constant [1 x 
i8*] [i8* bitcast (i8* (%struct.Y*, i32)* @"\01??_G?$Y@H@@UAEPAXI@Z" to i8*)], 
comdat
Index: test/CodeGenCXX/microsoft-abi-vbtables.cpp
===
--- test/CodeGenCXX/microsoft-abi-vbtables.cpp
+++ test/CodeGenCXX/microsoft-abi-vbtables.cpp
@@ -537,5 +537,5 @@
 
 extern template class B;
 template B::B();
-// CHECK-DAG: @"\01??_8?$B@H@Test30@@7B@" = external unnamed_addr constant [2 
x i32]{{$}}
+// CHECK-DAG: @"\01??_8?$B@H@Test30@@7B@" = linkonce_odr unnamed_addr constant 
[2 x i32] [i32 0, i32 4], comdat
 }
Index: lib/CodeGen/CGVTables.cpp
===
--- lib/CodeGen/CGVTables.cpp
+++ lib/CodeGen/CGVTables.cpp
@@ -794,6 +794,10 @@
   return DiscardableODRLinkage;
 
 case TSK_ExplicitInstantiationDeclaration:
+  // Explicit instantiations in MSVC do not provide vtables, so we must 
emit
+  // our own.
+  if (getTarget().getCXXABI().isMicrosoft())
+return DiscardableODRLinkage;
   return shouldEmitAvailableExternallyVTable(*this, RD)
  ? llvm::GlobalVariable::AvailableExternallyLinkage
  : llvm::GlobalVariable::ExternalLinkage;
@@ -839,9 +843,9 @@
 bool CodeGenVTables::isVTableExternal(const CXXRecordDecl *RD) {
   assert(RD->isDynamicClass() && "Non-dynamic classes have no VTable.");
 
-  // We always synthesize vtables on the import side regardless of whether or
-  // not it is an explicit instantiation declaration.
-  if (CGM.getTarget().getCXXABI().isMicrosoft() && 
RD->hasAttr())
+  // We always synthesize vtables if they are needed in the MS ABI. MSVC 
doesn't
+  // emit them even if there is an explicit template instantiation.
+  if (CGM.getTarget().getCXXABI().isMicrosoft())
 return false;
 
   // If we have an explicit instantiation declaration (and not a
Index: lib/AST/VTableBuilder.cpp
===
--- lib/AST/VTableBuilder.cpp
+++ lib/AST/VTableBuilder.cpp
@@ -2545,14 +2545,13 @@
 MostDerivedClassLayout(Context.getASTRecordLayout(MostDerivedClass)),
 WhichVFPtr(*Which),
 Overriders(MostDerivedClass, CharUnits(), MostDerivedClass) {
-// Only include the RTTI component if we know that we will provide a
-// definition of the vftable.  We always provide the definition of
-// dllimported classes.
+// Provide the RTTI component if RTTIData is enabled. If the vftable would
+// be available externally, we should not provide the RTTI componenent. It
+// is currently impossible to get available externally vftables with either
+// dllimport or extern template instantiations, but eventually we may add a
+// flag to support additional devirtualization that needs this.
 if (Context.getLangOpts().RTTIData)
-  if (MostDerivedClass->hasAttr() ||
-  MostDerivedClass->getTemplateSpecializationKind() !=
-  TSK_ExplicitInstantiationDeclaration)
-HasRTTIComponent = true;
+  HasRTTIComponent = true;
 
 LayoutVFTable();
 


Index: test/CodeGenCXX/microsoft-abi-vftables.cpp
===
--- test/CodeGenCXX/microsoft-abi-vftables.cpp
+++ test/CodeGenCXX/microsoft-abi-vftables.cpp
@@ -33,7 +33,7 @@
 
 namespace {
 struct W {
-  virtual ~W();
+  

[PATCH] D21542: CodeGen: Replace test/CodeGen/thinlto_backend.c with a functional test.

2016-06-20 Thread Peter Collingbourne via cfe-commits
pcc created this revision.
pcc added a reviewer: tejohnson.
pcc added a subscriber: cfe-commits.
Herald added a subscriber: mehdi_amini.

This new test tests that functions are capable of being imported, rather than
that the import pass is run. This new test is compatible with the approach
being developed in D20268 which runs the importer on its own rather than in
a pass.

http://reviews.llvm.org/D21542

Files:
  test/CodeGen/Inputs/thinlto_backend.ll
  test/CodeGen/thinlto_backend.c
  test/CodeGen/thinlto_backend.ll

Index: test/CodeGen/thinlto_backend.ll
===
--- /dev/null
+++ test/CodeGen/thinlto_backend.ll
@@ -0,0 +1,27 @@
+; RUN: opt -module-summary -o %t1.o %s
+; RUN: opt -module-summary -o %t2.o %S/Inputs/thinlto_backend.ll
+; RUN: llvm-lto -thinlto -o %t %t1.o %t2.o
+
+; Ensure clang -cc1 give expected error for incorrect input type
+; RUN: not %clang_cc1 -O2 -o %t1.o -x c %s -c -fthinlto-index=%t.thinlto.bc 
2>&1 | FileCheck %s -check-prefix=CHECK-WARNING
+; CHECK-WARNING: error: invalid argument '-fthinlto-index={{.*}}' only allowed 
with '-x ir'
+
+; Ensure we get expected error for missing index file
+; RUN: %clang -O2 -o %t3.o -x ir %t1.o -c -fthinlto-index=bad.thinlto.bc 2>&1 
| FileCheck %s -check-prefix=CHECK-ERROR
+; CHECK-ERROR: Error loading index file 'bad.thinlto.bc'
+
+; Ensure f2 was imported
+; RUN: %clang -O2 -o %t3.o -x ir %t1.o -c -fthinlto-index=%t.thinlto.bc
+; RUN: llvm-nm %t3.o | FileCheck --check-prefix=CHECK-OBJ %s
+; CHECK-OBJ: T f1
+; CHECK-OBJ-NOT: U f2
+
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+declare void @f2()
+
+define void @f1() {
+  call void @f2()
+  ret void
+}
Index: test/CodeGen/thinlto_backend.c
===
--- test/CodeGen/thinlto_backend.c
+++ /dev/null
@@ -1,14 +0,0 @@
-// RUN: %clang -O2 %s -flto=thin -c -o %t.o
-// RUN: llvm-lto -thinlto -o %t %t.o
-
-// Ensure clang -cc1 give expected error for incorrect input type
-// RUN: not %clang_cc1 -O2 -o %t1.o %s -c -fthinlto-index=%t.thinlto.bc 2>&1 | 
FileCheck %s -check-prefix=CHECK-WARNING
-// CHECK-WARNING: error: invalid argument '-fthinlto-index={{.*}}' only 
allowed with '-x ir'
-
-// Ensure we get expected error for missing index file
-// RUN: %clang -O2 -o %t1.o -x ir %t.o -c -fthinlto-index=bad.thinlto.bc 2>&1 
| FileCheck %s -check-prefix=CHECK-ERROR
-// CHECK-ERROR: Error loading index file 'bad.thinlto.bc'
-
-// Ensure Function Importing pass added
-// RUN: %clang -O2 -o %t1.o -x ir %t.o -c -fthinlto-index=%t.thinlto.bc -mllvm 
-debug-pass=Structure 2>&1 | FileCheck %s -check-prefix=CHECK-PASS
-// CHECK-PASS: Function Importing
Index: test/CodeGen/Inputs/thinlto_backend.ll
===
--- /dev/null
+++ test/CodeGen/Inputs/thinlto_backend.ll
@@ -0,0 +1,6 @@
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+define void @f2() {
+  ret void
+}


Index: test/CodeGen/thinlto_backend.ll
===
--- /dev/null
+++ test/CodeGen/thinlto_backend.ll
@@ -0,0 +1,27 @@
+; RUN: opt -module-summary -o %t1.o %s
+; RUN: opt -module-summary -o %t2.o %S/Inputs/thinlto_backend.ll
+; RUN: llvm-lto -thinlto -o %t %t1.o %t2.o
+
+; Ensure clang -cc1 give expected error for incorrect input type
+; RUN: not %clang_cc1 -O2 -o %t1.o -x c %s -c -fthinlto-index=%t.thinlto.bc 2>&1 | FileCheck %s -check-prefix=CHECK-WARNING
+; CHECK-WARNING: error: invalid argument '-fthinlto-index={{.*}}' only allowed with '-x ir'
+
+; Ensure we get expected error for missing index file
+; RUN: %clang -O2 -o %t3.o -x ir %t1.o -c -fthinlto-index=bad.thinlto.bc 2>&1 | FileCheck %s -check-prefix=CHECK-ERROR
+; CHECK-ERROR: Error loading index file 'bad.thinlto.bc'
+
+; Ensure f2 was imported
+; RUN: %clang -O2 -o %t3.o -x ir %t1.o -c -fthinlto-index=%t.thinlto.bc
+; RUN: llvm-nm %t3.o | FileCheck --check-prefix=CHECK-OBJ %s
+; CHECK-OBJ: T f1
+; CHECK-OBJ-NOT: U f2
+
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+declare void @f2()
+
+define void @f1() {
+  call void @f2()
+  ret void
+}
Index: test/CodeGen/thinlto_backend.c
===
--- test/CodeGen/thinlto_backend.c
+++ /dev/null
@@ -1,14 +0,0 @@
-// RUN: %clang -O2 %s -flto=thin -c -o %t.o
-// RUN: llvm-lto -thinlto -o %t %t.o
-
-// Ensure clang -cc1 give expected error for incorrect input type
-// RUN: not %clang_cc1 -O2 -o %t1.o %s -c -fthinlto-index=%t.thinlto.bc 2>&1 | FileCheck %s -check-prefix=CHECK-WARNING
-// CHECK-WARNING: error: invalid argument '-fthinlto-index={{.*}}' only allowed with '-x ir'
-
-// Ensure we get expected error for missing index file
-// RUN: %clang -O2 -o %t1.o -x ir %t.o -c 

r273227 - [Docs] Try to fix the docs buildbot.

2016-06-20 Thread George Burgess IV via cfe-commits
Author: gbiv
Date: Mon Jun 20 19:16:23 2016
New Revision: 273227

URL: http://llvm.org/viewvc/llvm-project?rev=273227=rev
Log:
[Docs] Try to fix the docs buildbot.

It's complaining that it couldn't lex a compiler warning as C++. I don't
blame it.

Modified:
cfe/trunk/docs/LanguageExtensions.rst

Modified: cfe/trunk/docs/LanguageExtensions.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/LanguageExtensions.rst?rev=273227=273226=273227=diff
==
--- cfe/trunk/docs/LanguageExtensions.rst (original)
+++ cfe/trunk/docs/LanguageExtensions.rst Mon Jun 20 19:16:23 2016
@@ -449,7 +449,7 @@ An optional string message can be added
 If the deprecated or unavailable declaration is used, the message will be
 incorporated into the appropriate diagnostic:
 
-.. code-block:: c++
+.. code-block:: none
 
   harmless.c:4:3: warning: 'explode' is deprecated: extremely unsafe, use 
'combust' instead!!!
 [-Wdeprecated-declarations]


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


Re: [PATCH] D21506: [analyzer] Block in critical section

2016-06-20 Thread Anna Zaks via cfe-commits
zaks.anna added a comment.

Thanks for the patch!

Have you run this on a large codebase?



Comment at: include/clang/StaticAnalyzer/Checkers/Checkers.td:406
@@ +405,3 @@
+def BlockInCriticalSectionChecker : Checker<"BlockInCriticalSection">,
+  HelpText<"Check for blocks in critical section">,
+  DescFile<"BlockInCriticalSectionChecker.cpp">;

"blocks" sounds a lot like blocks ObjC feature. I'd just be more explicit and 
say "Check for calls to blocking functions inside a critical section".

Please, change the name of the class as well.


Comment at: lib/StaticAnalyzer/Checkers/BlockInCriticalSectionChecker.cpp:54
@@ +53,3 @@
+
+REGISTER_TRAIT_WITH_PROGRAMSTATE(Counter, unsigned)
+

Counter -> MutexCounter or MutexState


Comment at: lib/StaticAnalyzer/Checkers/BlockInCriticalSectionChecker.cpp:61
@@ +60,3 @@
+  BlockInCritSectionBugType.reset(
+  new BugType(this, "Block in critical section", "Unix Stream API Error"));
+}

Same here: "Block" sounds like an ObjC language feature. Also, the category 
name ("Unix Stream API Error") should be different.


Comment at: lib/StaticAnalyzer/Checkers/BlockInCriticalSectionChecker.cpp:85
@@ +84,3 @@
+
+void BlockInCriticalSectionChecker::checkPreCall(const CallEvent ,
+ CheckerContext ) const {

Why is handling of unlock in preCall?


Comment at: lib/StaticAnalyzer/Checkers/BlockInCriticalSectionChecker.cpp:96
@@ +95,3 @@
+
+void BlockInCriticalSectionChecker::reportBlockInCritSection(
+SymbolRef BlockDescSym, const CallEvent , CheckerContext ) const {

It would be great if you could implement a BugReporterVisitor that walks the 
path and explains where the lock has occurred. (This is not blocking for this 
commit.)


Comment at: lib/StaticAnalyzer/Checkers/BlockInCriticalSectionChecker.cpp:103
@@ +102,3 @@
+  auto R = llvm::make_unique(*BlockInCritSectionBugType,
+  "Block in a critical section", ErrNode);
+  R->addRange(Call.getSourceRange());

 "Block in a critical section" -> "A blocking function %s is called inside a 
critical section."


Comment at: test/Analysis/block-in-critical-section.cpp:12
@@ +11,3 @@
+
+void testBlockInCriticalSection() {
+  std::mutex m;

Please, add inter-procedural examples like in the description of the checker.


Repository:
  rL LLVM

http://reviews.llvm.org/D21506



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


r273224 - Add a ENABLE_X86_RELAX_RELOCATIONS cmake option.

2016-06-20 Thread Rafael Espindola via cfe-commits
Author: rafael
Date: Mon Jun 20 18:54:44 2016
New Revision: 273224

URL: http://llvm.org/viewvc/llvm-project?rev=273224=rev
Log:
Add a ENABLE_X86_RELAX_RELOCATIONS  cmake option.

This corresponds to binutils' --enable-x86-relax-relocations.

Modified:
cfe/trunk/CMakeLists.txt
cfe/trunk/include/clang/Config/config.h.cmake
cfe/trunk/lib/Driver/Tools.cpp

Modified: cfe/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/CMakeLists.txt?rev=273224=273223=273224=diff
==
--- cfe/trunk/CMakeLists.txt (original)
+++ cfe/trunk/CMakeLists.txt Mon Jun 20 18:54:44 2016
@@ -185,6 +185,9 @@ set(DEFAULT_SYSROOT "" CACHE PATH
 
 set(ENABLE_LINKER_BUILD_ID OFF CACHE BOOL "pass --build-id to ld")
 
+set(ENABLE_X86_RELAX_RELOCATIONS OFF CACHE BOOL
+"enable x86 relax relocations by default")
+
 set(CLANG_DEFAULT_CXX_STDLIB "" CACHE STRING
   "Default C++ stdlib to use (empty for architecture default, \"libstdc++\" or 
\"libc++\"")
 if (NOT(CLANG_DEFAULT_CXX_STDLIB STREQUAL "" OR

Modified: cfe/trunk/include/clang/Config/config.h.cmake
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Config/config.h.cmake?rev=273224=273223=273224=diff
==
--- cfe/trunk/include/clang/Config/config.h.cmake (original)
+++ cfe/trunk/include/clang/Config/config.h.cmake Mon Jun 20 18:54:44 2016
@@ -41,4 +41,7 @@
 /* pass --build-id to ld */
 #cmakedefine ENABLE_LINKER_BUILD_ID
 
+/* enable x86 relax relocations by default */
+#cmakedefine01 ENABLE_X86_RELAX_RELOCATIONS
+
 #endif

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=273224=273223=273224=diff
==
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Mon Jun 20 18:54:44 2016
@@ -2839,7 +2839,7 @@ static void CollectArgsForIntegratedAsse
   // options.
   bool CompressDebugSections = false;
 
-  bool UseRelaxRelocations = false;
+  bool UseRelaxRelocations = ENABLE_X86_RELAX_RELOCATIONS;
   const char *MipsTargetFeature = nullptr;
   for (const Arg *A :
Args.filtered(options::OPT_Wa_COMMA, options::OPT_Xassembler)) {


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


Re: [PATCH] D20647: Add flag to add InlineHint attribute on implicitly inline functions

2016-06-20 Thread Rudy Pons via cfe-commits
Ilod updated this revision to Diff 61318.
Ilod added a comment.

New patch, which instead add NoInline to function not marked (implicitly or 
explicitly) inline, when we use the -finline-hint-functions flag (effectily 
inlining only implicitly and explicitly inline functions). Also adds support 
for /Ob1, since it's now an alias for it.
There is no longer a flag to treat implicit and explicit inline functions 
exactly the same way, I don't kow if it's really useful (it can be if we want 
to use the threshold difference between InlineHint and standard functions). If 
it's wanted for other uses, I can re-add it.
There is no flag to inline only explicitly marked inline functions, but it can 
be done by passing -finline-functions -mllvm -inline-threshold=-1000 (which 
will add InlineHint only to explicitly inline functions, and put a negative 
enough threshold for non-hinted functions to inline only the hinted ones).


http://reviews.llvm.org/D20647

Files:
  include/clang/Driver/CLCompatOptions.td
  include/clang/Driver/Options.td
  include/clang/Frontend/CodeGenOptions.h
  lib/CodeGen/BackendUtil.cpp
  lib/CodeGen/CodeGenFunction.cpp
  lib/Driver/MSVCToolChain.cpp
  lib/Frontend/CompilerInvocation.cpp
  test/CodeGen/inline-optim.c
  test/CodeGenCXX/inline-hint.cpp
  test/Driver/cl-options.c

Index: test/Driver/cl-options.c
===
--- test/Driver/cl-options.c
+++ test/Driver/cl-options.c
@@ -280,7 +280,6 @@
 // RUN:/GS- \
 // RUN:/kernel- \
 // RUN:/nologo \
-// RUN:/Ob1 \
 // RUN:/openmp- \
 // RUN:/RTC1 \
 // RUN:/sdl \
Index: test/CodeGenCXX/inline-hint.cpp
===
--- test/CodeGenCXX/inline-hint.cpp
+++ test/CodeGenCXX/inline-hint.cpp
@@ -0,0 +1,96 @@
+// RUN: %clang_cc1 %s -std=c++11 -triple=x86_64-linux -finline-functions -emit-llvm -disable-llvm-optzns -o - | FileCheck %s --check-prefix=CHECK --check-prefix=SUITABLE
+// RUN: %clang_cc1 %s -std=c++11 -triple=x86_64-linux -finline-hint-functions -emit-llvm -disable-llvm-optzns -o - | FileCheck %s --check-prefix=CHECK --check-prefix=HINTED
+// RUN: %clang_cc1 %s -std=c++11 -triple=x86_64-linux -fno-inline -emit-llvm -disable-llvm-optzns -o - | FileCheck %s --check-prefix=CHECK --check-prefix=NOINLINE
+
+// Force non-trivial implicit constructors/destructors/operators for B by having explicit ones for A
+struct A {
+  A() {}
+  A(const A&) {}
+  A& operator=(const A&) { return *this; }
+  ~A() {}
+};
+
+struct B {
+  A member;
+  int implicitFunction(int a) { return a + a; }
+  inline int explicitFunction(int a);
+  int noHintFunction(int a);
+  __attribute__((optnone)) int optNoneFunction(int a) { return a + a; }
+  template int implicitTplFunction(int a) { return N + a; }
+  template inline int explicitTplFunction(int a) { return N + a; }
+  template int noHintTplFunction(int a);
+  template int explicitRedeclTplFunction(int a);
+};
+
+int B::explicitFunction(int a) { return a + a; }
+// CHECK: @_ZN1B14noHintFunctionEi({{.*}}) [[NOHINT_ATTR:#[0-9]+]]
+int B::noHintFunction(int a) { return a + a; }
+
+// CHECK: @_ZN1B19implicitTplFunctionILi0EEEii({{.*}}) [[NOHINT_ATTR]]
+template<> int B::implicitTplFunction<0>(int a) { return a + a; }
+// CHECK: @_ZN1B19explicitTplFunctionILi0EEEii({{.*}}) [[NOHINT_ATTR]]
+template<> int B::explicitTplFunction<0>(int a) { return a + a; }
+// CHECK: @_ZN1B17noHintTplFunctionILi0EEEii({{.*}}) [[NOHINT_ATTR]]
+template<> int B::noHintTplFunction<0>(int a) { return a + a; }
+template<> inline int B::implicitTplFunction<1>(int a) { return a; }
+template<> inline int B::explicitTplFunction<1>(int a) { return a; }
+template<> inline int B::noHintTplFunction<1>(int a) { return a; }
+template int B::noHintTplFunction(int a) { return N + a; }
+template inline int B::explicitRedeclTplFunction(int a) { return N + a; }
+
+constexpr int constexprFunction(int a) { return a + a; }
+
+void foo()
+{
+// CHECK: @_ZN1BC1Ev({{.*}}) unnamed_addr [[IMPLICIT_CONSTR_ATTR:#[0-9]+]]
+  B b1;
+// CHECK: @_ZN1BC1ERKS_({{.*}}) unnamed_addr [[IMPLICIT_CONSTR_ATTR]]
+  B b2(b1);
+// CHECK: @_ZN1BaSERKS_({{.*}}) [[IMPLICIT_CONSTR_ATTR]]
+  b2 = b1;
+// CHECK: @_ZN1B16implicitFunctionEi({{.*}}) [[IMPLICIT_ATTR:#[0-9]+]]
+  b1.implicitFunction(1);
+// CHECK: @_ZN1B16explicitFunctionEi({{.*}}) [[EXPLICIT_ATTR:#[0-9]+]]
+  b1.explicitFunction(2);
+  b1.noHintFunction(3);
+// CHECK: @_ZN1B15optNoneFunctionEi({{.*}}) [[OPTNONE_ATTR:#[0-9]+]]
+  b1.optNoneFunction(4);
+// CHECK: @_Z17constexprFunctioni({{.*}}) [[IMPLICIT_ATTR]]
+  constexprFunction(5);
+  b1.implicitTplFunction<0>(6);
+// CHECK: @_ZN1B19implicitTplFunctionILi1EEEii({{.*}}) [[EXPLICIT_ATTR]]
+  b1.implicitTplFunction<1>(7);
+// CHECK: @_ZN1B19implicitTplFunctionILi2EEEii({{.*}}) [[IMPLICIT_ATTR]]
+  b1.implicitTplFunction<2>(8);
+  b1.explicitTplFunction<0>(9);
+// CHECK: @_ZN1B19explicitTplFunctionILi1EEEii({{.*}}) [[EXPLICIT_ATTR]]
+  

Re: [PATCH] D21537: Frontend: Simplify ownership model for clang's output streams.

2016-06-20 Thread Peter Collingbourne via cfe-commits
pcc updated this revision to Diff 61317.
pcc added a comment.

- Move EmitAssemblyHelper's pass managers into CreatePasses


http://reviews.llvm.org/D21537

Files:
  include/clang/CodeGen/BackendUtil.h
  include/clang/CodeGen/ObjectFilePCHContainerOperations.h
  include/clang/Frontend/ASTConsumers.h
  include/clang/Frontend/CompilerInstance.h
  include/clang/Frontend/FrontendActions.h
  include/clang/Frontend/PCHContainerOperations.h
  include/clang/Rewrite/Frontend/ASTConsumers.h
  lib/CodeGen/BackendUtil.cpp
  lib/CodeGen/CodeGenAction.cpp
  lib/CodeGen/ObjectFilePCHContainerOperations.cpp
  lib/Frontend/ASTConsumers.cpp
  lib/Frontend/ASTUnit.cpp
  lib/Frontend/CompilerInstance.cpp
  lib/Frontend/FrontendActions.cpp
  lib/Frontend/PCHContainerOperations.cpp
  lib/Frontend/Rewrite/FrontendActions.cpp
  lib/Frontend/Rewrite/HTMLPrint.cpp
  lib/Frontend/Rewrite/RewriteModernObjC.cpp
  lib/Frontend/Rewrite/RewriteObjC.cpp
  tools/clang-check/ClangCheck.cpp

Index: tools/clang-check/ClangCheck.cpp
===
--- tools/clang-check/ClangCheck.cpp
+++ tools/clang-check/ClangCheck.cpp
@@ -142,7 +142,7 @@
   return clang::CreateASTDumper(ASTDumpFilter, /*DumpDecls=*/true,
 /*DumpLookups=*/false);
 if (ASTPrint)
-  return clang::CreateASTPrinter(::outs(), ASTDumpFilter);
+  return clang::CreateASTPrinter(nullptr, ASTDumpFilter);
 return llvm::make_unique();
   }
 };
Index: lib/Frontend/Rewrite/RewriteObjC.cpp
===
--- lib/Frontend/Rewrite/RewriteObjC.cpp
+++ lib/Frontend/Rewrite/RewriteObjC.cpp
@@ -71,7 +71,7 @@
 Stmt *CurrentBody;
 ParentMap *PropParentMap; // created lazily.
 std::string InFileName;
-raw_ostream* OutFile;
+std::unique_ptr OutFile;
 std::string Preamble;
 
 TypeDecl *ProtocolTypeDecl;
@@ -190,7 +190,7 @@
 
 void HandleTopLevelSingleDecl(Decl *D);
 void HandleDeclInMainFile(Decl *D);
-RewriteObjC(std::string inFile, raw_ostream *OS,
+RewriteObjC(std::string inFile, std::unique_ptr OS,
 DiagnosticsEngine , const LangOptions ,
 bool silenceMacroWarn);
 
@@ -506,11 +506,10 @@
   
   class RewriteObjCFragileABI : public RewriteObjC {
   public:
-RewriteObjCFragileABI(std::string inFile, raw_ostream *OS,
-DiagnosticsEngine , const LangOptions ,
-bool silenceMacroWarn) : RewriteObjC(inFile, OS,
- D, LOpts,
- silenceMacroWarn) {}
+RewriteObjCFragileABI(std::string inFile, std::unique_ptr OS,
+  DiagnosticsEngine , const LangOptions ,
+  bool silenceMacroWarn)
+: RewriteObjC(inFile, std::move(OS), D, LOpts, silenceMacroWarn) {}
 
 ~RewriteObjCFragileABI() override {}
 void Initialize(ASTContext ) override;
@@ -575,11 +574,11 @@
   return Ext == "h" || Ext == "hh" || Ext == "H";
 }
 
-RewriteObjC::RewriteObjC(std::string inFile, raw_ostream* OS,
+RewriteObjC::RewriteObjC(std::string inFile, std::unique_ptr OS,
  DiagnosticsEngine , const LangOptions ,
  bool silenceMacroWarn)
-  : Diags(D), LangOpts(LOpts), InFileName(inFile), OutFile(OS),
-SilenceRewriteMacroWarning(silenceMacroWarn) {
+: Diags(D), LangOpts(LOpts), InFileName(inFile), OutFile(std::move(OS)),
+  SilenceRewriteMacroWarning(silenceMacroWarn) {
   IsHeader = IsHeaderFile(inFile);
   RewriteFailedDiag = Diags.getCustomDiagID(DiagnosticsEngine::Warning,
"rewriting sub-expression within a macro (may not be correct)");
@@ -590,11 +589,12 @@
 }
 
 std::unique_ptr
-clang::CreateObjCRewriter(const std::string , raw_ostream *OS,
+clang::CreateObjCRewriter(const std::string ,
+  std::unique_ptr OS,
   DiagnosticsEngine , const LangOptions ,
   bool SilenceRewriteMacroWarning) {
-  return llvm::make_unique(InFile, OS, Diags, LOpts,
-  SilenceRewriteMacroWarning);
+  return llvm::make_unique(
+  InFile, std::move(OS), Diags, LOpts, SilenceRewriteMacroWarning);
 }
 
 void RewriteObjC::InitializeCommon(ASTContext ) {
Index: lib/Frontend/Rewrite/RewriteModernObjC.cpp
===
--- lib/Frontend/Rewrite/RewriteModernObjC.cpp
+++ lib/Frontend/Rewrite/RewriteModernObjC.cpp
@@ -72,7 +72,7 @@
 Stmt *CurrentBody;
 ParentMap *PropParentMap; // created lazily.
 std::string InFileName;
-raw_ostream* OutFile;
+std::unique_ptr OutFile;
 std::string Preamble;
 
 TypeDecl *ProtocolTypeDecl;
@@ -239,9 +239,9 @@
 
 void HandleTopLevelSingleDecl(Decl *D);
 void HandleDeclInMainFile(Decl *D);
-

[PATCH] D21537: Frontend: Simplify ownership model for clang's output streams.

2016-06-20 Thread Peter Collingbourne via cfe-commits
pcc created this revision.
pcc added a reviewer: rsmith.
pcc added a subscriber: cfe-commits.

This changes the CompilerInstance::createOutputFile function to return
a std::unique_ptr, rather than an llvm::raw_ostream
implicitly owned by the CompilerInstance. This in most cases required that
I move ownership of the output stream to the relevant ASTConsumer.

The motivation for this change is to allow BackendConsumer to be a client
of interfaces such as D20268 which take ownership of the output stream.

http://reviews.llvm.org/D21537

Files:
  include/clang/CodeGen/BackendUtil.h
  include/clang/CodeGen/ObjectFilePCHContainerOperations.h
  include/clang/Frontend/ASTConsumers.h
  include/clang/Frontend/CompilerInstance.h
  include/clang/Frontend/FrontendActions.h
  include/clang/Frontend/PCHContainerOperations.h
  include/clang/Rewrite/Frontend/ASTConsumers.h
  lib/CodeGen/BackendUtil.cpp
  lib/CodeGen/CodeGenAction.cpp
  lib/CodeGen/ObjectFilePCHContainerOperations.cpp
  lib/Frontend/ASTConsumers.cpp
  lib/Frontend/ASTUnit.cpp
  lib/Frontend/CompilerInstance.cpp
  lib/Frontend/FrontendActions.cpp
  lib/Frontend/PCHContainerOperations.cpp
  lib/Frontend/Rewrite/FrontendActions.cpp
  lib/Frontend/Rewrite/HTMLPrint.cpp
  lib/Frontend/Rewrite/RewriteModernObjC.cpp
  lib/Frontend/Rewrite/RewriteObjC.cpp
  tools/clang-check/ClangCheck.cpp

Index: tools/clang-check/ClangCheck.cpp
===
--- tools/clang-check/ClangCheck.cpp
+++ tools/clang-check/ClangCheck.cpp
@@ -142,7 +142,7 @@
   return clang::CreateASTDumper(ASTDumpFilter, /*DumpDecls=*/true,
 /*DumpLookups=*/false);
 if (ASTPrint)
-  return clang::CreateASTPrinter(::outs(), ASTDumpFilter);
+  return clang::CreateASTPrinter(nullptr, ASTDumpFilter);
 return llvm::make_unique();
   }
 };
Index: lib/Frontend/Rewrite/RewriteObjC.cpp
===
--- lib/Frontend/Rewrite/RewriteObjC.cpp
+++ lib/Frontend/Rewrite/RewriteObjC.cpp
@@ -71,7 +71,7 @@
 Stmt *CurrentBody;
 ParentMap *PropParentMap; // created lazily.
 std::string InFileName;
-raw_ostream* OutFile;
+std::unique_ptr OutFile;
 std::string Preamble;
 
 TypeDecl *ProtocolTypeDecl;
@@ -190,7 +190,7 @@
 
 void HandleTopLevelSingleDecl(Decl *D);
 void HandleDeclInMainFile(Decl *D);
-RewriteObjC(std::string inFile, raw_ostream *OS,
+RewriteObjC(std::string inFile, std::unique_ptr OS,
 DiagnosticsEngine , const LangOptions ,
 bool silenceMacroWarn);
 
@@ -506,11 +506,10 @@
   
   class RewriteObjCFragileABI : public RewriteObjC {
   public:
-RewriteObjCFragileABI(std::string inFile, raw_ostream *OS,
-DiagnosticsEngine , const LangOptions ,
-bool silenceMacroWarn) : RewriteObjC(inFile, OS,
- D, LOpts,
- silenceMacroWarn) {}
+RewriteObjCFragileABI(std::string inFile, std::unique_ptr OS,
+  DiagnosticsEngine , const LangOptions ,
+  bool silenceMacroWarn)
+: RewriteObjC(inFile, std::move(OS), D, LOpts, silenceMacroWarn) {}
 
 ~RewriteObjCFragileABI() override {}
 void Initialize(ASTContext ) override;
@@ -575,11 +574,11 @@
   return Ext == "h" || Ext == "hh" || Ext == "H";
 }
 
-RewriteObjC::RewriteObjC(std::string inFile, raw_ostream* OS,
+RewriteObjC::RewriteObjC(std::string inFile, std::unique_ptr OS,
  DiagnosticsEngine , const LangOptions ,
  bool silenceMacroWarn)
-  : Diags(D), LangOpts(LOpts), InFileName(inFile), OutFile(OS),
-SilenceRewriteMacroWarning(silenceMacroWarn) {
+: Diags(D), LangOpts(LOpts), InFileName(inFile), OutFile(std::move(OS)),
+  SilenceRewriteMacroWarning(silenceMacroWarn) {
   IsHeader = IsHeaderFile(inFile);
   RewriteFailedDiag = Diags.getCustomDiagID(DiagnosticsEngine::Warning,
"rewriting sub-expression within a macro (may not be correct)");
@@ -590,11 +589,12 @@
 }
 
 std::unique_ptr
-clang::CreateObjCRewriter(const std::string , raw_ostream *OS,
+clang::CreateObjCRewriter(const std::string ,
+  std::unique_ptr OS,
   DiagnosticsEngine , const LangOptions ,
   bool SilenceRewriteMacroWarning) {
-  return llvm::make_unique(InFile, OS, Diags, LOpts,
-  SilenceRewriteMacroWarning);
+  return llvm::make_unique(
+  InFile, std::move(OS), Diags, LOpts, SilenceRewriteMacroWarning);
 }
 
 void RewriteObjC::InitializeCommon(ASTContext ) {
Index: lib/Frontend/Rewrite/RewriteModernObjC.cpp
===
--- lib/Frontend/Rewrite/RewriteModernObjC.cpp
+++ 

Re: [Patch] Add a ENABLE_X86_RELAX_RELOCATIONS cmake option

2016-06-20 Thread Chris Bieneman via cfe-commits
Patch LGTM.

-Chris

> On Jun 17, 2016, at 12:36 PM, Rafael EspĂ­ndola  
> wrote:
> 
> This corresponds to binutils' --enable-x86-relax-relocations.
> 
> Cheers,
> Rafael
> <0001-Add-a-ENABLE_X86_RELAX_RELOCATIONS-cmake-option.patch>

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


r273198 - Remove MaxFunctionCount module flag annotation.

2016-06-20 Thread Easwaran Raman via cfe-commits
Author: eraman
Date: Mon Jun 20 15:48:32 2016
New Revision: 273198

URL: http://llvm.org/viewvc/llvm-project?rev=273198=rev
Log:
Remove MaxFunctionCount module flag annotation.

Differential revision: http://reviews.llvm.org/D19184


Removed:
cfe/trunk/test/Profile/max-function-count.c
Modified:
cfe/trunk/lib/CodeGen/CodeGenModule.cpp

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=273198=273197=273198=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Mon Jun 20 15:48:32 2016
@@ -393,7 +393,6 @@ void CodeGenModule::Release() {
 OpenMPRuntime->emitRegistrationFunction())
   AddGlobalCtor(OpenMPRegistrationFunction, 0);
   if (PGOReader) {
-getModule().setMaximumFunctionCount(PGOReader->getMaximumFunctionCount());
 getModule().setProfileSummary(PGOReader->getSummary().getMD(VMContext));
 if (PGOStats.hasDiagnostics())
   PGOStats.reportDiagnostics(getDiags(), getCodeGenOpts().MainFileName);

Removed: cfe/trunk/test/Profile/max-function-count.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Profile/max-function-count.c?rev=273197=auto
==
--- cfe/trunk/test/Profile/max-function-count.c (original)
+++ cfe/trunk/test/Profile/max-function-count.c (removed)
@@ -1,24 +0,0 @@
-// Test that maximum function counts are set correctly.
-
-// RUN: llvm-profdata merge %S/Inputs/max-function-count.proftext -o 
%t.profdata
-// RUN: %clang_cc1 %s -o - -disable-llvm-optzns -emit-llvm 
-fprofile-instrument-use-path=%t.profdata | FileCheck %s
-//
-int begin(int i) {
-  if (i)
-return 0;
-  return 1;
-}
-
-int end(int i) {
-  if (i)
-return 0;
-  return 1;
-}
-
-int main(int argc, const char *argv[]) {
-  begin(0);
-  end(1);
-  end(1);
-  return 0;
-}
-// CHECK: !{{[0-9]+}} = !{i32 1, !"MaxFunctionCount", i32 2}


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


Re: [PATCH] D19184: Remove MaxFunctionCount module flag annotation

2016-06-20 Thread Easwaran Raman via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL273198: Remove MaxFunctionCount module flag annotation. 
(authored by eraman).

Changed prior to commit:
  http://reviews.llvm.org/D19184?vs=53969=61302#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D19184

Files:
  cfe/trunk/lib/CodeGen/CodeGenModule.cpp
  cfe/trunk/test/Profile/max-function-count.c

Index: cfe/trunk/test/Profile/max-function-count.c
===
--- cfe/trunk/test/Profile/max-function-count.c
+++ cfe/trunk/test/Profile/max-function-count.c
@@ -1,24 +0,0 @@
-// Test that maximum function counts are set correctly.
-
-// RUN: llvm-profdata merge %S/Inputs/max-function-count.proftext -o 
%t.profdata
-// RUN: %clang_cc1 %s -o - -disable-llvm-optzns -emit-llvm 
-fprofile-instrument-use-path=%t.profdata | FileCheck %s
-//
-int begin(int i) {
-  if (i)
-return 0;
-  return 1;
-}
-
-int end(int i) {
-  if (i)
-return 0;
-  return 1;
-}
-
-int main(int argc, const char *argv[]) {
-  begin(0);
-  end(1);
-  end(1);
-  return 0;
-}
-// CHECK: !{{[0-9]+}} = !{i32 1, !"MaxFunctionCount", i32 2}
Index: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
===
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp
@@ -393,7 +393,6 @@
 OpenMPRuntime->emitRegistrationFunction())
   AddGlobalCtor(OpenMPRegistrationFunction, 0);
   if (PGOReader) {
-getModule().setMaximumFunctionCount(PGOReader->getMaximumFunctionCount());
 getModule().setProfileSummary(PGOReader->getSummary().getMD(VMContext));
 if (PGOStats.hasDiagnostics())
   PGOStats.reportDiagnostics(getDiags(), getCodeGenOpts().MainFileName);


Index: cfe/trunk/test/Profile/max-function-count.c
===
--- cfe/trunk/test/Profile/max-function-count.c
+++ cfe/trunk/test/Profile/max-function-count.c
@@ -1,24 +0,0 @@
-// Test that maximum function counts are set correctly.
-
-// RUN: llvm-profdata merge %S/Inputs/max-function-count.proftext -o %t.profdata
-// RUN: %clang_cc1 %s -o - -disable-llvm-optzns -emit-llvm -fprofile-instrument-use-path=%t.profdata | FileCheck %s
-//
-int begin(int i) {
-  if (i)
-return 0;
-  return 1;
-}
-
-int end(int i) {
-  if (i)
-return 0;
-  return 1;
-}
-
-int main(int argc, const char *argv[]) {
-  begin(0);
-  end(1);
-  end(1);
-  return 0;
-}
-// CHECK: !{{[0-9]+}} = !{i32 1, !"MaxFunctionCount", i32 2}
Index: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
===
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp
@@ -393,7 +393,6 @@
 OpenMPRuntime->emitRegistrationFunction())
   AddGlobalCtor(OpenMPRegistrationFunction, 0);
   if (PGOReader) {
-getModule().setMaximumFunctionCount(PGOReader->getMaximumFunctionCount());
 getModule().setProfileSummary(PGOReader->getSummary().getMD(VMContext));
 if (PGOStats.hasDiagnostics())
   PGOStats.reportDiagnostics(getDiags(), getCodeGenOpts().MainFileName);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D21507: Changes after running check modernize-use-emplace (D20964)

2016-06-20 Thread Piotr Padlewski via cfe-commits
Prazek added a comment.

In http://reviews.llvm.org/D21507#462210, @jlebar wrote:

> There seem to be many nontrivial whitespace errors introduced by this patch.  
> For example,
>
>   -Attrs.push_back(HTMLStartTagComment::Attribute(Ident.getLocation(),
>   -   
> Ident.getHTMLIdent()));
>   +Attrs.emplace_back(Ident.getLocation(),
>   +   
> Ident.getHTMLIdent());
>   
>
> and
>
>   -BitGroups.push_back(BitGroup(LastValue, LastRLAmt, 
> LastGroupStartIdx,
>   - i-1));
>   +BitGroups.emplace_back(LastValue, LastRLAmt, LastGroupStartIdx,
>   + i-1);
>


That's right. I will git-clang-format it before pushing upstream. This is just 
raw diff of what check does.


Repository:
  rL LLVM

http://reviews.llvm.org/D21507



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


r273196 - clang-format: [Proto] Fix "import public" after r273179.

2016-06-20 Thread Daniel Jasper via cfe-commits
Author: djasper
Date: Mon Jun 20 15:39:53 2016
New Revision: 273196

URL: http://llvm.org/viewvc/llvm-project?rev=273196=rev
Log:
clang-format: [Proto] Fix "import public" after r273179.

Modified:
cfe/trunk/lib/Format/UnwrappedLineParser.cpp
cfe/trunk/unittests/Format/FormatTestProto.cpp

Modified: cfe/trunk/lib/Format/UnwrappedLineParser.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/UnwrappedLineParser.cpp?rev=273196=273195=273196=diff
==
--- cfe/trunk/lib/Format/UnwrappedLineParser.cpp (original)
+++ cfe/trunk/lib/Format/UnwrappedLineParser.cpp Mon Jun 20 15:39:53 2016
@@ -889,6 +889,8 @@ void UnwrappedLineParser::parseStructura
   }
   if (Style.Language == FormatStyle::LK_Proto) {
 nextToken();
+if (FormatTok->is(tok::kw_public))
+  nextToken();
 if (!FormatTok->is(tok::string_literal))
   return;
 nextToken();

Modified: cfe/trunk/unittests/Format/FormatTestProto.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestProto.cpp?rev=273196=273195=273196=diff
==
--- cfe/trunk/unittests/Format/FormatTestProto.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTestProto.cpp Mon Jun 20 15:39:53 2016
@@ -196,6 +196,12 @@ TEST_F(FormatTestProto, FormatsImports)
"message A {\n"
"}");
 
+  verifyFormat("import public \"a.proto\";\n"
+   "import \"b.proto\";\n"
+   "// comment\n"
+   "message A {\n"
+   "}");
+
   // Missing semicolons should not confuse clang-format.
   verifyFormat("import \"a.proto\"\n"
"import \"b.proto\"\n"


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


Re: [libcxx] r273034 - Add Filesystem TS -- Complete

2016-06-20 Thread Eric Fiselier via cfe-commits
Oh shoot, I definitely didn't take that into account. I'll put together a
fix.

/Eric



On Mon, Jun 20, 2016 at 2:27 PM, Artem Belevich  wrote:

> Eric,
>
> Some tests appear to fail if the path to the tests' current directory has
> some symlinks in it.
> In my case source and build tree are in directory 'work' that's symlinked
> to from my home directory:
> /usr/local/home/tra/work -> /work/tra
>
> This causes multiple failures in libcxx tests. One example:
>
>
> projects/libcxx/test/std/experimental/filesystem/fs.op.funcs/fs.op.rename/rename.pass.cpp:121
> 121TEST_CHECK(read_symlink(bad_sym_dest) == dne);
>
> dne:
>
> /usr/local/home/tra/work/llvm/build/gpu/debug/projects/libcxx/test/filesystem/Output/dynamic_env/test.529143/dne
> bad_sym_dest:
>
> /usr/local/home/tra/work/llvm/build/gpu/debug/projects/libcxx/test/filesystem/Output/dynamic_env/test.529143/bad_sym2
>
> These are the paths that traverse the 'work' symlink in my home directory.
> However, the symlink that we're reading contains physical path to the
> directory. While it does link to the right place, it's not the path the
> test expects.
>
> #readlink
> /usr/local/home/tra/work/llvm/build/gpu/debug/projects/libcxx/test/filesystem/Output/dynamic_env/test.529143/bad_sym2
>
> /work/tra/llvm/build/gpu/debug/projects/libcxx/test/filesystem/Output/dynamic_env/test.529143/dne
>
> I think we need to normalize paths before we compare them.
>
> --Artem
>
>
> On Sat, Jun 18, 2016 at 12:03 PM, Eric Fiselier via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> > I assume the correct way to fix this is to disable
>> -Wcovered-switch-default while compiling libcxx/src/experimental/
>> filesystem/operations.cpp
>>
>> Agreed. Disabled in r273092.
>>
>> Thanks for your patience with this latest change,
>>
>> /Eric
>>
>> On Sat, Jun 18, 2016 at 12:54 PM, Adrian Prantl 
>> wrote:
>>
>>> Hello Eric,
>>>
>>> this commit causes new warnings on our bots:
>>>
>>> clang/src/projects/libcxx/include/fstream:816:5: warning: default label
>>> in switch which covers all enumeration values [-Wcovered-switch-default]
>>> default:
>>>
>>> The problem is with this defensive default statement in fstream:
>>>
>>>
>>>  template 
>>> 0792 typename basic_filebuf<_CharT, _Traits>::pos_type
>>> 0793 basic_filebuf<_CharT, _Traits>::seekoff(off_type __off,
>>> ios_base::seekdir __way,
>>> 0794 ios_base::openmode)
>>> 0795 {
>>> 0796 #ifndef _LIBCPP_NO_EXCEPTIONS
>>> 0797 if (!__cv_)
>>> 0798 throw bad_cast();
>>> 0799 #endif
>>> 0800 int __width = __cv_->encoding();
>>> 0801 if (__file_ == 0 || (__width <= 0 && __off != 0) || sync())
>>> 0802 return pos_type(off_type(-1));
>>> 0803 // __width > 0 || __off == 0
>>> 0804 int __whence;
>>> 0805 switch (__way)
>>> 0806 {
>>> 0807 case ios_base::beg:
>>> 0808 __whence = SEEK_SET;
>>> 0809 break;
>>> 0810 case ios_base::cur:
>>> 0811 __whence = SEEK_CUR;
>>> 0812 break;
>>> 0813 case ios_base::end:
>>> 0814 __whence = SEEK_END;
>>> 0815 break;
>>> 0816 default:
>>> 0817 return pos_type(off_type(-1));
>>> 0818 }
>>>
>>>
>>> I assume the correct way to fix this is to disable
>>> -Wcovered-switch-default while compiling
>>> libcxx/src/experimental/filesystem/operations.cpp
>>>
>>> Could you please investigate?
>>>
>>> thanks,
>>> Adrian
>>
>>
>>
>> ___
>> cfe-commits mailing list
>> cfe-commits@lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>>
>>
>
>
> --
> --Artem Belevich
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [libcxx] r273034 - Add Filesystem TS -- Complete

2016-06-20 Thread Artem Belevich via cfe-commits
Eric,

Some tests appear to fail if the path to the tests' current directory has
some symlinks in it.
In my case source and build tree are in directory 'work' that's symlinked
to from my home directory:
/usr/local/home/tra/work -> /work/tra

This causes multiple failures in libcxx tests. One example:

projects/libcxx/test/std/experimental/filesystem/fs.op.funcs/fs.op.rename/rename.pass.cpp:121
121TEST_CHECK(read_symlink(bad_sym_dest) == dne);

dne:

/usr/local/home/tra/work/llvm/build/gpu/debug/projects/libcxx/test/filesystem/Output/dynamic_env/test.529143/dne
bad_sym_dest:

/usr/local/home/tra/work/llvm/build/gpu/debug/projects/libcxx/test/filesystem/Output/dynamic_env/test.529143/bad_sym2

These are the paths that traverse the 'work' symlink in my home directory.
However, the symlink that we're reading contains physical path to the
directory. While it does link to the right place, it's not the path the
test expects.

#readlink
/usr/local/home/tra/work/llvm/build/gpu/debug/projects/libcxx/test/filesystem/Output/dynamic_env/test.529143/bad_sym2
/work/tra/llvm/build/gpu/debug/projects/libcxx/test/filesystem/Output/dynamic_env/test.529143/dne

I think we need to normalize paths before we compare them.

--Artem


On Sat, Jun 18, 2016 at 12:03 PM, Eric Fiselier via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> > I assume the correct way to fix this is to disable
> -Wcovered-switch-default while compiling libcxx/src/experimental/
> filesystem/operations.cpp
>
> Agreed. Disabled in r273092.
>
> Thanks for your patience with this latest change,
>
> /Eric
>
> On Sat, Jun 18, 2016 at 12:54 PM, Adrian Prantl  wrote:
>
>> Hello Eric,
>>
>> this commit causes new warnings on our bots:
>>
>> clang/src/projects/libcxx/include/fstream:816:5: warning: default label
>> in switch which covers all enumeration values [-Wcovered-switch-default]
>> default:
>>
>> The problem is with this defensive default statement in fstream:
>>
>>
>>  template 
>> 0792 typename basic_filebuf<_CharT, _Traits>::pos_type
>> 0793 basic_filebuf<_CharT, _Traits>::seekoff(off_type __off,
>> ios_base::seekdir __way,
>> 0794 ios_base::openmode)
>> 0795 {
>> 0796 #ifndef _LIBCPP_NO_EXCEPTIONS
>> 0797 if (!__cv_)
>> 0798 throw bad_cast();
>> 0799 #endif
>> 0800 int __width = __cv_->encoding();
>> 0801 if (__file_ == 0 || (__width <= 0 && __off != 0) || sync())
>> 0802 return pos_type(off_type(-1));
>> 0803 // __width > 0 || __off == 0
>> 0804 int __whence;
>> 0805 switch (__way)
>> 0806 {
>> 0807 case ios_base::beg:
>> 0808 __whence = SEEK_SET;
>> 0809 break;
>> 0810 case ios_base::cur:
>> 0811 __whence = SEEK_CUR;
>> 0812 break;
>> 0813 case ios_base::end:
>> 0814 __whence = SEEK_END;
>> 0815 break;
>> 0816 default:
>> 0817 return pos_type(off_type(-1));
>> 0818 }
>>
>>
>> I assume the correct way to fix this is to disable
>> -Wcovered-switch-default while compiling
>> libcxx/src/experimental/filesystem/operations.cpp
>>
>> Could you please investigate?
>>
>> thanks,
>> Adrian
>
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
>


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


Re: [PATCH] D21279: Fix some issues in clang-format's AlignConsecutive modes

2016-06-20 Thread Ben Harper via cfe-commits
bmharper added a comment.

I've taken some time to investigate those two issues, and these are my thoughts:

1. Constructor alignment: I think this is a good thing to do, but if 
`isFunctionDeclarationName`, and it's caller 
`TokenAnnotator::calculateFormattingInformation` are anything to go by, adding 
support for detection of constructors is going to be pretty hairy. I think I 
can see a way to do it, but it involves adding yet more complexity to 
`TokenAnnotator::calculateFormattingInformation`, and I'm not sure it's worth 
the effort. See TokenAnnotator.cpp 

 for reference.

2. friend functions: I don't really understand why the current behavior is what 
it is, but I think it's reasonable to argue that it actually improves 
readability by drawing attention to the fact these are friend functions, which 
ought to be quite rare in most code


Repository:
  rL LLVM

http://reviews.llvm.org/D21279



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


Re: [PATCH] D20923: [Sema] Fix a crash on invalid where invalid defaulted function is called

2016-06-20 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL273193: [Sema] Only define function as move assignment when 
needed (authored by epilk).

Changed prior to commit:
  http://reviews.llvm.org/D20923?vs=59409=61296#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D20923

Files:
  cfe/trunk/lib/Sema/SemaExpr.cpp
  cfe/trunk/test/SemaCXX/cxx0x-defaulted-functions.cpp

Index: cfe/trunk/lib/Sema/SemaExpr.cpp
===
--- cfe/trunk/lib/Sema/SemaExpr.cpp
+++ cfe/trunk/lib/Sema/SemaExpr.cpp
@@ -13012,7 +13012,7 @@
   if (MethodDecl->isDefaulted() && !MethodDecl->isDeleted()) {
 if (MethodDecl->isCopyAssignmentOperator())
   DefineImplicitCopyAssignment(Loc, MethodDecl);
-else
+else if (MethodDecl->isMoveAssignmentOperator())
   DefineImplicitMoveAssignment(Loc, MethodDecl);
   }
 } else if (isa(MethodDecl) &&
Index: cfe/trunk/test/SemaCXX/cxx0x-defaulted-functions.cpp
===
--- cfe/trunk/test/SemaCXX/cxx0x-defaulted-functions.cpp
+++ cfe/trunk/test/SemaCXX/cxx0x-defaulted-functions.cpp
@@ -196,3 +196,15 @@
   A a;
   B b; // expected-note {{here}}
 }
+
+namespace PR27941 {
+struct ExplicitBool {
+  ExplicitBool =(bool) = default; // expected-error{{only special 
member functions may be defaulted}}
+  int member;
+};
+
+int fn() {
+  ExplicitBool t;
+  t = true;
+}
+}


Index: cfe/trunk/lib/Sema/SemaExpr.cpp
===
--- cfe/trunk/lib/Sema/SemaExpr.cpp
+++ cfe/trunk/lib/Sema/SemaExpr.cpp
@@ -13012,7 +13012,7 @@
   if (MethodDecl->isDefaulted() && !MethodDecl->isDeleted()) {
 if (MethodDecl->isCopyAssignmentOperator())
   DefineImplicitCopyAssignment(Loc, MethodDecl);
-else
+else if (MethodDecl->isMoveAssignmentOperator())
   DefineImplicitMoveAssignment(Loc, MethodDecl);
   }
 } else if (isa(MethodDecl) &&
Index: cfe/trunk/test/SemaCXX/cxx0x-defaulted-functions.cpp
===
--- cfe/trunk/test/SemaCXX/cxx0x-defaulted-functions.cpp
+++ cfe/trunk/test/SemaCXX/cxx0x-defaulted-functions.cpp
@@ -196,3 +196,15 @@
   A a;
   B b; // expected-note {{here}}
 }
+
+namespace PR27941 {
+struct ExplicitBool {
+  ExplicitBool =(bool) = default; // expected-error{{only special member functions may be defaulted}}
+  int member;
+};
+
+int fn() {
+  ExplicitBool t;
+  t = true;
+}
+}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r273193 - [Sema] Only define function as move assignment when needed

2016-06-20 Thread Erik Pilkington via cfe-commits
Author: epilk
Date: Mon Jun 20 15:04:15 2016
New Revision: 273193

URL: http://llvm.org/viewvc/llvm-project?rev=273193=rev
Log:
[Sema] Only define function as move assignment when needed

Fixes PR27941, a crash on invalid.

Differential revision: http://reviews.llvm.org/D20923

Modified:
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/test/SemaCXX/cxx0x-defaulted-functions.cpp

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=273193=273192=273193=diff
==
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Mon Jun 20 15:04:15 2016
@@ -13012,7 +13012,7 @@ void Sema::MarkFunctionReferenced(Source
   if (MethodDecl->isDefaulted() && !MethodDecl->isDeleted()) {
 if (MethodDecl->isCopyAssignmentOperator())
   DefineImplicitCopyAssignment(Loc, MethodDecl);
-else
+else if (MethodDecl->isMoveAssignmentOperator())
   DefineImplicitMoveAssignment(Loc, MethodDecl);
   }
 } else if (isa(MethodDecl) &&

Modified: cfe/trunk/test/SemaCXX/cxx0x-defaulted-functions.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/cxx0x-defaulted-functions.cpp?rev=273193=273192=273193=diff
==
--- cfe/trunk/test/SemaCXX/cxx0x-defaulted-functions.cpp (original)
+++ cfe/trunk/test/SemaCXX/cxx0x-defaulted-functions.cpp Mon Jun 20 15:04:15 
2016
@@ -196,3 +196,15 @@ namespace PR15597 {
   A a;
   B b; // expected-note {{here}}
 }
+
+namespace PR27941 {
+struct ExplicitBool {
+  ExplicitBool =(bool) = default; // expected-error{{only special 
member functions may be defaulted}}
+  int member;
+};
+
+int fn() {
+  ExplicitBool t;
+  t = true;
+}
+}


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


Re: [PATCH] D20444: [OpenCL] Include opencl-c.h by default as a clang module

2016-06-20 Thread Yaxun Liu via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL273191: [OpenCL] Include opencl-c.h by default as a clang 
module (authored by yaxunl).

Changed prior to commit:
  http://reviews.llvm.org/D20444?vs=60568=61290#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D20444

Files:
  cfe/trunk/include/clang/Basic/LangOptions.def
  cfe/trunk/include/clang/Driver/CC1Options.td
  cfe/trunk/include/clang/Frontend/CompilerInvocation.h
  cfe/trunk/lib/Frontend/CompilerInvocation.cpp
  cfe/trunk/lib/Headers/module.modulemap
  cfe/trunk/test/Headers/opencl-c-header.cl

Index: cfe/trunk/include/clang/Driver/CC1Options.td
===
--- cfe/trunk/include/clang/Driver/CC1Options.td
+++ cfe/trunk/include/clang/Driver/CC1Options.td
@@ -612,6 +612,8 @@
   HelpText<"Allow function arguments and returns of type half">;
 def fdefault_calling_conv_EQ : Joined<["-"], "fdefault-calling-conv=">,
   HelpText<"Set default MS calling convention">;
+def finclude_default_header : Flag<["-"], "finclude-default-header">,
+  HelpText<"Include the default header file for OpenCL">;
 
 // C++ TSes.
 def fcoroutines : Flag<["-"], "fcoroutines">,
Index: cfe/trunk/include/clang/Basic/LangOptions.def
===
--- cfe/trunk/include/clang/Basic/LangOptions.def
+++ cfe/trunk/include/clang/Basic/LangOptions.def
@@ -218,7 +218,7 @@
 LANGOPT(ObjCSubscriptingLegacyRuntime , 1, 0, "Subscripting support in legacy ObjectiveC runtime")
 LANGOPT(FakeAddressSpaceMap , 1, 0, "OpenCL fake address space map")
 ENUM_LANGOPT(AddressSpaceMapMangling , AddrSpaceMapMangling, 2, ASMM_Target, "OpenCL address space map mangling mode")
-
+LANGOPT(IncludeDefaultHeader, 1, 0, "Include default header file for OpenCL")
 BENIGN_LANGOPT(DelayedTemplateParsing , 1, 0, "delayed template parsing")
 LANGOPT(BlocksRuntimeOptional , 1, 0, "optional blocks runtime")
 
Index: cfe/trunk/include/clang/Frontend/CompilerInvocation.h
===
--- cfe/trunk/include/clang/Frontend/CompilerInvocation.h
+++ cfe/trunk/include/clang/Frontend/CompilerInvocation.h
@@ -155,9 +155,10 @@
   /// \param Opts - The LangOptions object to set up.
   /// \param IK - The input language.
   /// \param T - The target triple.
+  /// \param PPOpts - The PreprocessorOptions affected.
   /// \param LangStd - The input language standard.
   static void setLangDefaults(LangOptions , InputKind IK,
-   const llvm::Triple ,
+   const llvm::Triple , PreprocessorOptions ,
LangStandard::Kind LangStd = LangStandard::lang_unspecified);
   
   /// \brief Retrieve a module hash string that is suitable for uniquely 
Index: cfe/trunk/test/Headers/opencl-c-header.cl
===
--- cfe/trunk/test/Headers/opencl-c-header.cl
+++ cfe/trunk/test/Headers/opencl-c-header.cl
@@ -1,33 +1,90 @@
 // RUN: %clang_cc1 -triple spir-unknown-unknown -internal-isystem ../../lib/Headers -include opencl-c.h -emit-llvm -o - %s | FileCheck %s
 // RUN: %clang_cc1 -triple spir-unknown-unknown -internal-isystem ../../lib/Headers -include opencl-c.h -emit-llvm -o - %s -cl-std=CL1.1| FileCheck %s
 // RUN: %clang_cc1 -triple spir-unknown-unknown -internal-isystem ../../lib/Headers -include opencl-c.h -emit-llvm -o - %s -cl-std=CL1.2| FileCheck %s
-// RUN: %clang_cc1 -triple spir-unknown-unknown -internal-isystem ../../lib/Headers -include opencl-c.h -fblocks -emit-llvm -o - %s -cl-std=CL2.0| FileCheck %s
+// RUN: %clang_cc1 -triple spir-unknown-unknown -internal-isystem ../../lib/Headers -include opencl-c.h -fblocks -emit-llvm -o - %s -cl-std=CL2.0| FileCheck --check-prefix=CHECK20 %s
 // RUN: %clang_cc1 -triple spir64-unknown-unknown -internal-isystem ../../lib/Headers -include opencl-c.h -emit-llvm -o - %s | FileCheck %s
 // RUN: %clang_cc1 -triple spir64-unknown-unknown -internal-isystem ../../lib/Headers -include opencl-c.h -emit-llvm -o - %s -cl-std=CL1.1| FileCheck %s
 // RUN: %clang_cc1 -triple spir64-unknown-unknown -internal-isystem ../../lib/Headers -include opencl-c.h -emit-llvm -o - %s -cl-std=CL1.2| FileCheck %s
-// RUN: %clang_cc1 -triple spir64-unknown-unknown -internal-isystem ../../lib/Headers -include opencl-c.h -fblocks -emit-llvm -o - %s -cl-std=CL2.0| FileCheck %s
+// RUN: %clang_cc1 -triple spir64-unknown-unknown -internal-isystem ../../lib/Headers -include opencl-c.h -fblocks -emit-llvm -o - %s -cl-std=CL2.0| FileCheck --check-prefix=CHECK20 %s
 // RUN: %clang_cc1 -triple amdgcn-unknown-amdhsa -internal-isystem ../../lib/Headers -include opencl-c.h -emit-llvm -o - %s | FileCheck %s
 // RUN: %clang_cc1 -triple amdgcn-unknown-amdhsa -internal-isystem ../../lib/Headers -include opencl-c.h -emit-llvm -o - %s -cl-std=CL1.1| FileCheck %s
 // RUN: %clang_cc1 -triple amdgcn-unknown-amdhsa -internal-isystem 

r273191 - [OpenCL] Include opencl-c.h by default as a clang module

2016-06-20 Thread Yaxun Liu via cfe-commits
Author: yaxunl
Date: Mon Jun 20 14:26:00 2016
New Revision: 273191

URL: http://llvm.org/viewvc/llvm-project?rev=273191=rev
Log:
[OpenCL] Include opencl-c.h by default as a clang module

Include opencl-c.h by default as a module to utilize the automatic AST caching 
mechanism of clang modules.

Add an option -finclude-default-header to enable default header for OpenCL, 
which is off by default.

Differential Revision: http://reviews.llvm.org/D20444

Modified:
cfe/trunk/include/clang/Basic/LangOptions.def
cfe/trunk/include/clang/Driver/CC1Options.td
cfe/trunk/include/clang/Frontend/CompilerInvocation.h
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/lib/Headers/module.modulemap
cfe/trunk/test/Headers/opencl-c-header.cl

Modified: cfe/trunk/include/clang/Basic/LangOptions.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/LangOptions.def?rev=273191=273190=273191=diff
==
--- cfe/trunk/include/clang/Basic/LangOptions.def (original)
+++ cfe/trunk/include/clang/Basic/LangOptions.def Mon Jun 20 14:26:00 2016
@@ -218,7 +218,7 @@ LANGOPT(ObjCWeak, 1, 0, "Obj
 LANGOPT(ObjCSubscriptingLegacyRuntime , 1, 0, "Subscripting support in 
legacy ObjectiveC runtime")
 LANGOPT(FakeAddressSpaceMap , 1, 0, "OpenCL fake address space map")
 ENUM_LANGOPT(AddressSpaceMapMangling , AddrSpaceMapMangling, 2, ASMM_Target, 
"OpenCL address space map mangling mode")
-
+LANGOPT(IncludeDefaultHeader, 1, 0, "Include default header file for OpenCL")
 BENIGN_LANGOPT(DelayedTemplateParsing , 1, 0, "delayed template parsing")
 LANGOPT(BlocksRuntimeOptional , 1, 0, "optional blocks runtime")
 

Modified: cfe/trunk/include/clang/Driver/CC1Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/CC1Options.td?rev=273191=273190=273191=diff
==
--- cfe/trunk/include/clang/Driver/CC1Options.td (original)
+++ cfe/trunk/include/clang/Driver/CC1Options.td Mon Jun 20 14:26:00 2016
@@ -612,6 +612,8 @@ def fallow_half_arguments_and_returns :
   HelpText<"Allow function arguments and returns of type half">;
 def fdefault_calling_conv_EQ : Joined<["-"], "fdefault-calling-conv=">,
   HelpText<"Set default MS calling convention">;
+def finclude_default_header : Flag<["-"], "finclude-default-header">,
+  HelpText<"Include the default header file for OpenCL">;
 
 // C++ TSes.
 def fcoroutines : Flag<["-"], "fcoroutines">,

Modified: cfe/trunk/include/clang/Frontend/CompilerInvocation.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/CompilerInvocation.h?rev=273191=273190=273191=diff
==
--- cfe/trunk/include/clang/Frontend/CompilerInvocation.h (original)
+++ cfe/trunk/include/clang/Frontend/CompilerInvocation.h Mon Jun 20 14:26:00 
2016
@@ -155,9 +155,10 @@ public:
   /// \param Opts - The LangOptions object to set up.
   /// \param IK - The input language.
   /// \param T - The target triple.
+  /// \param PPOpts - The PreprocessorOptions affected.
   /// \param LangStd - The input language standard.
   static void setLangDefaults(LangOptions , InputKind IK,
-   const llvm::Triple ,
+   const llvm::Triple , PreprocessorOptions ,
LangStandard::Kind LangStd = 
LangStandard::lang_unspecified);
   
   /// \brief Retrieve a module hash string that is suitable for uniquely 

Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=273191=273190=273191=diff
==
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Mon Jun 20 14:26:00 2016
@@ -1459,6 +1459,7 @@ bool isOpenCL(LangStandard::Kind LangStd
 
 void CompilerInvocation::setLangDefaults(LangOptions , InputKind IK,
  const llvm::Triple ,
+ PreprocessorOptions ,
  LangStandard::Kind LangStd) {
   // Set some properties which depend solely on the input kind; it would be 
nice
   // to move these to the language standard, and have the driver resolve the
@@ -1543,6 +1544,10 @@ void CompilerInvocation::setLangDefaults
 Opts.DefaultFPContract = 1;
 Opts.NativeHalfType = 1;
 Opts.NativeHalfArgsAndReturns = 1;
+// Include default header file for OpenCL.
+if (Opts.IncludeDefaultHeader) {
+  PPOpts.Includes.push_back("opencl-c.h");
+}
   }
 
   Opts.CUDA = IK == IK_CUDA || IK == IK_PreprocessedCuda ||
@@ -1589,6 +1594,7 @@ static Visibility parseVisibility(Arg *a
 
 static void ParseLangArgs(LangOptions , ArgList , InputKind IK,
   

r273190 - [OpenMP] Add the nowait clause to target update construct.

2016-06-20 Thread Kelvin Li via cfe-commits
Author: kli
Date: Mon Jun 20 14:16:34 2016
New Revision: 273190

URL: http://llvm.org/viewvc/llvm-project?rev=273190=rev
Log:
[OpenMP] Add the nowait clause to target update construct.

Differential Revision: http://reviews.llvm.org/D21477

Added:
cfe/trunk/test/OpenMP/target_update_nowait_messages.cpp
Modified:
cfe/trunk/include/clang/Basic/OpenMPKinds.def
cfe/trunk/test/OpenMP/target_update_ast_print.cpp

Modified: cfe/trunk/include/clang/Basic/OpenMPKinds.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/OpenMPKinds.def?rev=273190=273189=273190=diff
==
--- cfe/trunk/include/clang/Basic/OpenMPKinds.def (original)
+++ cfe/trunk/include/clang/Basic/OpenMPKinds.def Mon Jun 20 14:16:34 2016
@@ -454,6 +454,7 @@ OPENMP_TARGET_UPDATE_CLAUSE(if)
 OPENMP_TARGET_UPDATE_CLAUSE(device)
 OPENMP_TARGET_UPDATE_CLAUSE(to)
 OPENMP_TARGET_UPDATE_CLAUSE(from)
+OPENMP_TARGET_UPDATE_CLAUSE(nowait)
 
 // Clauses allowed for OpenMP directive 'teams'.
 // TODO More clauses for 'teams' directive.

Modified: cfe/trunk/test/OpenMP/target_update_ast_print.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/target_update_ast_print.cpp?rev=273190=273189=273190=diff
==
--- cfe/trunk/test/OpenMP/target_update_ast_print.cpp (original)
+++ cfe/trunk/test/OpenMP/target_update_ast_print.cpp Mon Jun 20 14:16:34 2016
@@ -13,26 +13,26 @@ T foo(T targ, U uarg) {
   static T a;
   U b;
   int l;
-#pragma omp target update to(a) if(l>5) device(l)
+#pragma omp target update to(a) if(l>5) device(l) nowait
 
-#pragma omp target update from(b) if(l<5) device(l-1)
+#pragma omp target update from(b) if(l<5) device(l-1) nowait
   return a + targ + (T)b;
 }
 // CHECK:  static int a;
 // CHECK-NEXT: float b;
 // CHECK-NEXT: int l;
 // CHECK-NEXT: #pragma omp target update to(a) if(l > 5) device(l)
-// CHECK-NEXT: #pragma omp target update from(b) if(l < 5) device(l - 1)
+// CHECK-NEXT: #pragma omp target update from(b) if(l < 5) device(l - 1) nowait
 // CHECK:  static char a;
 // CHECK-NEXT: float b;
 // CHECK-NEXT: int l;
-// CHECK-NEXT: #pragma omp target update to(a) if(l > 5) device(l)
-// CHECK-NEXT: #pragma omp target update from(b) if(l < 5) device(l - 1)
+// CHECK-NEXT: #pragma omp target update to(a) if(l > 5) device(l) nowait
+// CHECK-NEXT: #pragma omp target update from(b) if(l < 5) device(l - 1) nowait
 // CHECK:  static T a;
 // CHECK-NEXT: U b;
 // CHECK-NEXT: int l;
-// CHECK-NEXT: #pragma omp target update to(a) if(l > 5) device(l)
-// CHECK-NEXT: #pragma omp target update from(b) if(l < 5) device(l - 1)
+// CHECK-NEXT: #pragma omp target update to(a) if(l > 5) device(l) nowait
+// CHECK-NEXT: #pragma omp target update from(b) if(l < 5) device(l - 1) nowait
 
 int main(int argc, char **argv) {
   static int a;
@@ -42,10 +42,10 @@ int main(int argc, char **argv) {
 // CHECK:  static int a;
 // CHECK-NEXT: int n;
 // CHECK-NEXT: float f;
-#pragma omp target update to(a) if(f>0.0) device(n)
-  // CHECK-NEXT: #pragma omp target update to(a) if(f > 0.) device(n)
-#pragma omp target update from(f) if(f<0.0) device(n+1)
-  // CHECK-NEXT: #pragma omp target update from(f) if(f < 0.) device(n + 1)
+#pragma omp target update to(a) if(f>0.0) device(n) nowait
+// CHECK-NEXT: #pragma omp target update to(a) if(f > 0.) device(n) nowait
+#pragma omp target update from(f) if(f<0.0) device(n+1) nowait
+// CHECK-NEXT: #pragma omp target update from(f) if(f < 0.) device(n + 1) 
nowait
   return foo(argc, f) + foo(argv[0][0], f) + a;
 }
 

Added: cfe/trunk/test/OpenMP/target_update_nowait_messages.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/target_update_nowait_messages.cpp?rev=273190=auto
==
--- cfe/trunk/test/OpenMP/target_update_nowait_messages.cpp (added)
+++ cfe/trunk/test/OpenMP/target_update_nowait_messages.cpp Mon Jun 20 14:16:34 
2016
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 %s
+
+int main(int argc, char **argv) {
+  int i;
+
+  #pragma omp nowait target update to(i) // expected-error {{expected an 
OpenMP directive}}
+  #pragma omp target nowait update to(i) // expected-error {{unexpected OpenMP 
clause 'update' in directive '#pragma omp target'}} expected-error {{unexpected 
OpenMP clause 'to' in directive '#pragma omp target'}}
+  {}
+  #pragma omp target update nowait() to(i) // expected-warning {{extra tokens 
at the end of '#pragma omp target update' are ignored}} expected-error 
{{expected at least one 'to' clause or 'from' clause specified to '#pragma omp 
target update'}}
+  #pragma omp target update to(i) nowait( // expected-warning {{extra tokens 
at the end of '#pragma omp target update' are ignored}}
+  #pragma omp target update to(i) nowait (argc)) // expected-warning {{extra 
tokens at 

Re: [PATCH] D21031: [OpenCL] Allow -cl-std and other standard -cl- options in driver

2016-06-20 Thread Aaron En Ye Shi via cfe-commits
ashi1 updated this revision to Diff 61275.
ashi1 marked 2 inline comments as done.
ashi1 added a comment.

Revised with Anastasia's comments. Please take a look at the diagnostic to see 
if it is what we want.


http://reviews.llvm.org/D21031

Files:
  include/clang/Basic/DiagnosticFrontendKinds.td
  include/clang/Driver/CC1Options.td
  include/clang/Driver/Options.td
  lib/Driver/Tools.cpp
  lib/Frontend/CompilerInvocation.cpp
  test/Driver/opencl.cl

Index: test/Driver/opencl.cl
===
--- test/Driver/opencl.cl
+++ test/Driver/opencl.cl
@@ -1,15 +1,33 @@
-// RUN: %clang -fsyntax-only %s
-// RUN: %clang -fsyntax-only -std=cl %s
-// RUN: %clang -fsyntax-only -std=cl1.1 %s
-// RUN: %clang -fsyntax-only -std=cl1.2 %s
-// RUN: %clang -fsyntax-only -std=cl2.0 %s
-// RUN: %clang -fsyntax-only -std=CL %s
-// RUN: %clang -fsyntax-only -std=CL1.1 %s
-// RUN: %clang -fsyntax-only -std=CL1.2 %s
-// RUN: %clang -fsyntax-only -std=CL2.0 %s
-// RUN: not %clang_cc1 -std=c99 -DOPENCL %s 2>&1 | FileCheck --check-prefix=CHECK-C99 %s
-// RUN: not %clang_cc1 -std=invalid -DOPENCL %s 2>&1 | FileCheck --check-prefix=CHECK-INVALID %s
-// CHECK-C99: error: invalid argument '-std=c99' not allowed with 'OpenCL'
-// CHECK-INVALID: error: invalid value 'invalid' in '-std=invalid'
+// RUN: %clang -S -### %s
+// RUN: %clang -S -### -cl-std=CL %s | FileCheck --check-prefix=CHECK-CL %s
+// RUN: %clang -S -### -cl-std=CL1.1 %s | FileCheck --check-prefix=CHECK-CL11 %s
+// RUN: %clang -S -### -cl-std=CL1.2 %s | FileCheck --check-prefix=CHECK-CL12 %s
+// RUN: %clang -S -### -cl-std=CL2.0 %s | FileCheck --check-prefix=CHECK-CL20 %s
+// RUN: %clang -S -### -cl-opt-disable %s | FileCheck --check-prefix=CHECK-OPT-DISABLE %s
+// RUN: %clang -S -### -cl-strict-aliasing %s | FileCheck --check-prefix=CHECK-STRICT-ALIASING %s
+// RUN: %clang -S -### -cl-single-precision-constant %s | FileCheck --check-prefix=CHECK-SINGLE-PRECISION-CONST %s
+// RUN: %clang -S -### -cl-finite-math-only %s | FileCheck --check-prefix=CHECK-FINITE-MATH-ONLY %s
+// RUN: %clang -S -### -cl-kernel-arg-info %s | FileCheck --check-prefix=CHECK-KERNEL-ARG-INFO %s
+// RUN: %clang -S -### -cl-unsafe-math-optimizations %s | FileCheck --check-prefix=CHECK-UNSAFE-MATH-OPT %s
+// RUN: %clang -S -### -cl-fast-relaxed-math %s | FileCheck --check-prefix=CHECK-FAST-RELAXED-MATH %s
+// RUN: %clang -S -### -cl-mad-enable %s | FileCheck --check-prefix=CHECK-MAD-ENABLE %s
+// RUN: %clang -S -### -cl-denorms-are-zero %s | FileCheck --check-prefix=CHECK-DENORMS-ARE-ZERO %s
+// RUN: not %clang_cc1 -cl-std=c99 -DOPENCL %s 2>&1 | FileCheck --check-prefix=CHECK-C99 %s
+// RUN: not %clang_cc1 -cl-std=invalid -DOPENCL %s 2>&1 | FileCheck --check-prefix=CHECK-INVALID %s
+// CHECK-C99: error: invalid argument '-cl-std=c99' not allowed with 'OpenCL'
+// CHECK-INVALID: error: invalid value 'invalid' in '-cl-std=invalid'
+// CHECK-CL: .*clang.* "-cc1" .* "-cl-std=CL"
+// CHECK-CL11: .*clang.* "-cc1" .* "-cl-std=CL1.1"
+// CHECK-CL12: .*clang.* "-cc1" .* "-cl-std=CL1.2"
+// CHECK-CL20: .*clang.* "-cc1" .* "-cl-std=CL2.0"
+// CHECK-OPT-DISABLE: .*clang.* "-cc1" .* "-cl-opt-disable"
+// CHECK-STRICT-ALIASING: .*clang.* "-cc1" .* "-cl-strict-aliasing"
+// CHECK-SINGLE-PRECISION-CONST: .*clang.* "-cc1" .* "-cl-single-precision-constant"
+// CHECK-FINITE-MATH-ONLY: .*clang.* "-cc1" .* "-cl-finite-math-only"
+// CHECK-KERNEL-ARG-INFO: .*clang.* "-cc1" .* "-cl-kernel-arg-info"
+// CHECK-UNSAFE-MATH-OPT: .*clang.* "-cc1" .* "-cl-unsafe-math-optimizations"
+// CHECK-FAST-RELAXED-MATH: .*clang.* "-cc1" .* "-cl-fast-relaxed-math"
+// CHECK-MAD-ENABLE: .*clang.* "-cc1" .* "-cl-mad-enable"
+// CHECK-DENORMS-ARE-ZERO: .*clang.* "-cc1" .* "-cl-denorms-are-zero"
 
 kernel void func(void);
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -1660,6 +1660,15 @@
   LangStd = OpenCLLangStd;
   }
 
+  // -cl-strict-aliasing needs to emit diagnostic in the case where CL > 1.0.
+  // This option should be deprecated for CL > 1.0 because
+  // this option was added for compatibility with OpenCL 1.0.
+  if (const Arg *A = Args.getLastArg(OPT_cl_strict_aliasing)) {
+if(Opts.OpenCLVersion > 100)
+  Diags.Report(diag::warn_option_depre_ocl_version) 
+  << A->getArgString(Args);
+  }
+
   llvm::Triple T(TargetOpts.Triple);
   CompilerInvocation::setLangDefaults(Opts, IK, T, LangStd);
 
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -5109,6 +5109,40 @@
 CmdArgs.push_back("-arm-restrict-it");
   }
 
+  // Forward -cl options to -cc1
+  if (Arg *A = Args.getLastArg(options::OPT_cl_opt_disable)) {
+CmdArgs.push_back("-cl-opt-disable");
+  }
+  if (Arg *A = Args.getLastArg(options::OPT_cl_strict_aliasing)) {
+

Re: [PATCH] D21031: [OpenCL] Allow -cl-std and other standard -cl- options in driver

2016-06-20 Thread Aaron En Ye Shi via cfe-commits
ashi1 marked 6 inline comments as done.
ashi1 added a comment.

F2085685: D21031.patch 



Comment at: include/clang/Driver/CC1Options.td:670
@@ -669,21 +669,3 @@
 
-def cl_opt_disable : Flag<["-"], "cl-opt-disable">,
-  HelpText<"OpenCL only. This option disables all optimizations. The default 
is optimizations are enabled.">;
-def cl_strict_aliasing : Flag<["-"], "cl-strict-aliasing">,
-  HelpText<"OpenCL only. This option does nothing and is for compatibility 
with OpenCL 1.0">;
-def cl_single_precision_constant : Flag<["-"], "cl-single-precision-constant">,
-  HelpText<"OpenCL only. Treat double precision floating-point constant as 
single precision constant.">;
-def cl_finite_math_only : Flag<["-"], "cl-finite-math-only">,
-  HelpText<"OpenCL only. Allow floating-point optimizations that assume 
arguments and results are not NaNs or +-Inf.">;
-def cl_kernel_arg_info : Flag<["-"], "cl-kernel-arg-info">,
-  HelpText<"OpenCL only. Generate kernel argument metadata.">;
-def cl_unsafe_math_optimizations : Flag<["-"], "cl-unsafe-math-optimizations">,
-  HelpText<"OpenCL only. Allow unsafe floating-point optimizations.  Also 
implies -cl-no-signed-zeros and -cl-mad-enable">;
-def cl_fast_relaxed_math : Flag<["-"], "cl-fast-relaxed-math">,
-  HelpText<"OpenCL only. Sets -cl-finite-math-only and 
-cl-unsafe-math-optimizations, and defines __FAST_RELAXED_MATH__">;
-def cl_mad_enable : Flag<["-"], "cl-mad-enable">,
-  HelpText<"OpenCL only. Enable less precise MAD instructions to be 
generated.">;
-def cl_std_EQ : Joined<["-"], "cl-std=">,
-  HelpText<"OpenCL language standard to compile for">;
-def cl_denorms_are_zero : Flag<["-"], "cl-denorms-are-zero">,
-  HelpText<"OpenCL only. Allow denormals to be flushed to zero">;
+//def cl_opt_disable : Flag<["-"], "cl-opt-disable">,
+//  HelpText<"OpenCL only. This option disables all optimizations. The default 
is optimizations are enabled.">;

Anastasia wrote:
> Is this code below to be removed?
Yes, I removed the code from CC1Options.td and added replacement in Options.td


Comment at: include/clang/Driver/CC1Options.td:673
@@ +672,3 @@
+//def cl_strict_aliasing : Flag<["-"], "cl-strict-aliasing">,
+//  HelpText<"OpenCL only. This option does nothing and is for compatibility 
with OpenCL 1.0">;
+//def cl_single_precision_constant : Flag<["-"], 
"cl-single-precision-constant">,

Anastasia wrote:
> This option does nothing and is for compatibility with OpenCL 1.0 -> This 
> option is added for compatibility with OpenCL 1.0.
>  finish with .
> 
> Btw, ideally this option should be deprivcated for CL > 1.0. Could we give 
> diagnostic in this case?
I've added a diagnostic. Can you take a look?


http://reviews.llvm.org/D21031



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


r273179 - clang-format: [Proto] Don't do bad things if imports are missing ; .

2016-06-20 Thread Daniel Jasper via cfe-commits
Author: djasper
Date: Mon Jun 20 13:20:38 2016
New Revision: 273179

URL: http://llvm.org/viewvc/llvm-project?rev=273179=rev
Log:
clang-format: [Proto] Don't do bad things if imports are missing ;.

Modified:
cfe/trunk/lib/Format/UnwrappedLineParser.cpp
cfe/trunk/unittests/Format/FormatTestProto.cpp

Modified: cfe/trunk/lib/Format/UnwrappedLineParser.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/UnwrappedLineParser.cpp?rev=273179=273178=273179=diff
==
--- cfe/trunk/lib/Format/UnwrappedLineParser.cpp (original)
+++ cfe/trunk/lib/Format/UnwrappedLineParser.cpp Mon Jun 20 13:20:38 2016
@@ -882,10 +882,21 @@ void UnwrappedLineParser::parseStructura
  /*MunchSemi=*/false);
   return;
 }
-if (Style.Language == FormatStyle::LK_JavaScript &&
-FormatTok->is(Keywords.kw_import)) {
-  parseJavaScriptEs6ImportExport();
-  return;
+if (FormatTok->is(Keywords.kw_import)) {
+  if (Style.Language == FormatStyle::LK_JavaScript) {
+parseJavaScriptEs6ImportExport();
+return;
+  }
+  if (Style.Language == FormatStyle::LK_Proto) {
+nextToken();
+if (!FormatTok->is(tok::string_literal))
+  return;
+nextToken();
+if (FormatTok->is(tok::semi))
+  nextToken();
+addUnwrappedLine();
+return;
+  }
 }
 if (FormatTok->isOneOf(Keywords.kw_signals, Keywords.kw_qsignals,
Keywords.kw_slots, Keywords.kw_qslots)) {

Modified: cfe/trunk/unittests/Format/FormatTestProto.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestProto.cpp?rev=273179=273178=273179=diff
==
--- cfe/trunk/unittests/Format/FormatTestProto.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTestProto.cpp Mon Jun 20 13:20:38 2016
@@ -189,5 +189,20 @@ TEST_F(FormatTestProto, ExtendingMessage
"}");
 }
 
+TEST_F(FormatTestProto, FormatsImports) {
+  verifyFormat("import \"a.proto\";\n"
+   "import \"b.proto\";\n"
+   "// comment\n"
+   "message A {\n"
+   "}");
+
+  // Missing semicolons should not confuse clang-format.
+  verifyFormat("import \"a.proto\"\n"
+   "import \"b.proto\"\n"
+   "// comment\n"
+   "message A {\n"
+   "}");
+}
+
 } // end namespace tooling
 } // end namespace clang


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


Re: [PATCH] D20939: Update for DiagnosticInfoStackSize changes

2016-06-20 Thread Matt Arsenault via cfe-commits
arsenm accepted this revision.
arsenm added a reviewer: arsenm.
arsenm added a comment.
This revision is now accepted and ready to land.

r273178


http://reviews.llvm.org/D20939



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


Re: [PATCH] D20923: [Sema] Fix a crash on invalid where invalid defaulted function is called

2016-06-20 Thread Manman Ren via cfe-commits
manmanren accepted this revision.
manmanren added a comment.
This revision is now accepted and ready to land.

LGTM.

Manman


http://reviews.llvm.org/D20923



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


Re: r273147 - [X86] Add -mno-iamcu option.

2016-06-20 Thread Bruno Cardoso Lopes via cfe-commits
Hi Andrey,

On Mon, Jun 20, 2016 at 3:31 AM, Andrey Turetskiy via cfe-commits
 wrote:
> Author: aturetsk
> Date: Mon Jun 20 05:31:39 2016
> New Revision: 273147
>
> URL: http://llvm.org/viewvc/llvm-project?rev=273147=rev
> Log:
> [X86] Add -mno-iamcu option.
>
> Add -mno-iamcu option to:
>   1) Countervail -miamcu option easily
>   2) Be compatible with GCC which supports this option
>
> Differential Revision: http://reviews.llvm.org/D21469
>
> Modified:
> cfe/trunk/include/clang/Driver/Options.td
> cfe/trunk/lib/Driver/Driver.cpp
> cfe/trunk/lib/Driver/Tools.cpp
> cfe/trunk/test/Driver/miamcu-opt.c
>
> Modified: cfe/trunk/include/clang/Driver/Options.td
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=273147=273146=273147=diff
> ==
> --- cfe/trunk/include/clang/Driver/Options.td (original)
> +++ cfe/trunk/include/clang/Driver/Options.td Mon Jun 20 05:31:39 2016
> @@ -1311,6 +1311,7 @@ def mx32 : Flag<["-"], "mx32">, Group  def mabi_EQ : Joined<["-"], "mabi=">, Group;
>  def miamcu : Flag<["-"], "miamcu">, Group, Flags<[DriverOption, 
> CoreOption]>,
>HelpText<"Use Intel MCU ABI">;
> +def mno_iamcu : Flag<["-"], "mno-iamcu">, Group, 
> Flags<[DriverOption, CoreOption]>;
>  def malign_functions_EQ : Joined<["-"], "malign-functions=">, 
> Group;
>  def malign_loops_EQ : Joined<["-"], "malign-loops=">, 
> Group;
>  def malign_jumps_EQ : Joined<["-"], "malign-jumps=">, 
> Group;
>
> Modified: cfe/trunk/lib/Driver/Driver.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=273147=273146=273147=diff
> ==
> --- cfe/trunk/lib/Driver/Driver.cpp (original)
> +++ cfe/trunk/lib/Driver/Driver.cpp Mon Jun 20 05:31:39 2016
> @@ -280,8 +280,9 @@ DerivedArgList *Driver::TranslateInputAr
>}
>
>// Enforce -static if -miamcu is present.
> -  if (Args.hasArg(options::OPT_miamcu))
> -DAL->AddFlagArg(0, Opts->getOption(options::OPT_static));
> +  if (Arg *Ar = Args.getLastArg(options::OPT_miamcu, options::OPT_mno_iamcu))
> +if (Ar->getOption().matches(options::OPT_miamcu))

Looks like you could use `hasFlag(OptSpecifier Pos, OptSpecifier Neg,
bool Default=...)` here instead?

> +  DAL->AddFlagArg(0, Opts->getOption(options::OPT_static));
>
>  // Add a default value of -mlinker-version=, if one was given and the user
>  // didn't specify one.
> @@ -375,22 +376,24 @@ static llvm::Triple computeTargetTriple(
>}
>
>// Handle -miamcu flag.
> -  if (Args.hasArg(options::OPT_miamcu)) {
> -if (Target.get32BitArchVariant().getArch() != llvm::Triple::x86)
> -  D.Diag(diag::err_drv_unsupported_opt_for_target) << "-miamcu"
> -   << Target.str();
> -
> -if (A && !A->getOption().matches(options::OPT_m32))
> -  D.Diag(diag::err_drv_argument_not_allowed_with)
> -  << "-miamcu" << A->getBaseArg().getAsString(Args);
> -
> -Target.setArch(llvm::Triple::x86);
> -Target.setArchName("i586");
> -Target.setEnvironment(llvm::Triple::UnknownEnvironment);
> -Target.setEnvironmentName("");
> -Target.setOS(llvm::Triple::ELFIAMCU);
> -Target.setVendor(llvm::Triple::UnknownVendor);
> -Target.setVendorName("intel");
> +  if (Arg *Ar = Args.getLastArg(options::OPT_miamcu, 
> options::OPT_mno_iamcu)) {
> +if (Ar->getOption().matches(options::OPT_miamcu)) {

and here

> +  if (Target.get32BitArchVariant().getArch() != llvm::Triple::x86)
> +D.Diag(diag::err_drv_unsupported_opt_for_target) << "-miamcu"
> + << Target.str();
> +
> +  if (A && !A->getOption().matches(options::OPT_m32))
> +D.Diag(diag::err_drv_argument_not_allowed_with)
> +<< "-miamcu" << A->getBaseArg().getAsString(Args);
> +
> +  Target.setArch(llvm::Triple::x86);
> +  Target.setArchName("i586");
> +  Target.setEnvironment(llvm::Triple::UnknownEnvironment);
> +  Target.setEnvironmentName("");
> +  Target.setOS(llvm::Triple::ELFIAMCU);
> +  Target.setVendor(llvm::Triple::UnknownVendor);
> +  Target.setVendorName("intel");
> +}
>}
>
>return Target;
>
> Modified: cfe/trunk/lib/Driver/Tools.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=273147=273146=273147=diff
> ==
> --- cfe/trunk/lib/Driver/Tools.cpp (original)
> +++ cfe/trunk/lib/Driver/Tools.cpp Mon Jun 20 05:31:39 2016
> @@ -2243,10 +2243,12 @@ void Clang::AddX86TargetArgs(const ArgLi
>}
>
>// Set flags to support MCU ABI.
> -  if (Args.hasArg(options::OPT_miamcu)) {
> -CmdArgs.push_back("-mfloat-abi");
> -CmdArgs.push_back("soft");
> -CmdArgs.push_back("-mstack-alignment=4");
> +  

Re: [PATCH] D19184: Remove MaxFunctionCount module flag annotation

2016-06-20 Thread Easwaran Raman via cfe-commits
eraman added a comment.

This patch and the one in  http://reviews.llvm.org/D19185 are now ready to land 
as the inliner now uses ProfileSummaryInfo. I will check them in.


http://reviews.llvm.org/D19184



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


Re: [PATCH] D21507: Changes after running check modernize-use-emplace (D20964)

2016-06-20 Thread Justin Lebar via cfe-commits
jlebar added a subscriber: jlebar.
jlebar added a comment.

There seem to be many nontrivial whitespace errors introduced by this patch.  
For example,

  -Attrs.push_back(HTMLStartTagComment::Attribute(Ident.getLocation(),
  -   
Ident.getHTMLIdent()));
  +Attrs.emplace_back(Ident.getLocation(),
  +   Ident.getHTMLIdent());

and

  -BitGroups.push_back(BitGroup(LastValue, LastRLAmt, LastGroupStartIdx,
  - i-1));
  +BitGroups.emplace_back(LastValue, LastRLAmt, LastGroupStartIdx,
  + i-1);


Repository:
  rL LLVM

http://reviews.llvm.org/D21507



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


Re: [PATCH] D21517: clang-rename: add a -old-name option

2016-06-20 Thread Miklos Vajna via cfe-commits
vmiklos updated this revision to Diff 61255.
vmiklos added a comment.

Added a getNamedDeclFor() for the fully qualified name-based search.


http://reviews.llvm.org/D21517

Files:
  clang-rename/USRFinder.cpp
  clang-rename/USRFinder.h
  clang-rename/USRFindingAction.cpp
  clang-rename/USRFindingAction.h
  clang-rename/tool/ClangRename.cpp
  test/clang-rename/ClassTestByName.cpp

Index: test/clang-rename/ClassTestByName.cpp
===
--- /dev/null
+++ test/clang-rename/ClassTestByName.cpp
@@ -0,0 +1,10 @@
+// RUN: cat %s > %t.cpp
+// RUN: clang-rename -old-name=Cla -new-name=Hector %t.cpp -i --
+// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
+class Cla { // CHECK: class Hector
+};
+
+int main() {
+  Cla *Pointer = 0; // CHECK: Hector *Pointer = 0;
+  return 0;
+}
Index: clang-rename/tool/ClangRename.cpp
===
--- clang-rename/tool/ClangRename.cpp
+++ clang-rename/tool/ClangRename.cpp
@@ -52,6 +52,11 @@
 "offset",
 cl::desc("Locates the symbol by offset as opposed to :."),
 cl::cat(ClangRenameCategory));
+static cl::opt
+OldName(
+"old-name",
+cl::desc("The fully qualified name of the symbol, if -offset is not used."),
+cl::cat(ClangRenameCategory));
 static cl::opt
 Inplace(
 "i",
@@ -96,7 +101,7 @@
   // Get the USRs.
   auto Files = OP.getSourcePathList();
   tooling::RefactoringTool Tool(OP.getCompilations(), Files);
-  rename::USRFindingAction USRAction(SymbolOffset);
+  rename::USRFindingAction USRAction(SymbolOffset, OldName);
 
   // Find the USRs.
   Tool.run(tooling::newFrontendActionFactory().get());
Index: clang-rename/USRFindingAction.h
===
--- clang-rename/USRFindingAction.h
+++ clang-rename/USRFindingAction.h
@@ -25,7 +25,7 @@
 namespace rename {
 
 struct USRFindingAction {
-  USRFindingAction(unsigned Offset) : SymbolOffset(Offset) {
+  USRFindingAction(unsigned Offset, const std::string ) : SymbolOffset(Offset), OldName(Name) {
   }
   std::unique_ptr newASTConsumer();
 
@@ -40,6 +40,7 @@
 
 private:
   unsigned SymbolOffset;
+  std::string OldName;
   std::string SpellingName;
   std::vector USRs;
 };
Index: clang-rename/USRFindingAction.cpp
===
--- clang-rename/USRFindingAction.cpp
+++ clang-rename/USRFindingAction.cpp
@@ -68,7 +68,12 @@
 SourceMgr.getMainFileID()).getLocWithOffset(SymbolOffset);
 if (!Point.isValid())
   return;
-const NamedDecl *FoundDecl = getNamedDeclAt(Context, Point);
+const NamedDecl *FoundDecl = nullptr;
+if (OldName.empty()) {
+  FoundDecl = getNamedDeclAt(Context, Point);
+} else {
+  FoundDecl = getNamedDeclFor(Context, OldName);
+}
 if (FoundDecl == nullptr) {
   FullSourceLoc FullLoc(Point, SourceMgr);
   errs() << "clang-rename: could not find symbol at "
@@ -96,6 +101,7 @@
   }
 
   unsigned SymbolOffset;
+  std::string OldName;
   std::string *SpellingName;
   std::vector *USRs;
 };
@@ -106,6 +112,7 @@
   new NamedDeclFindingConsumer);
   SpellingName = "";
   Consumer->SymbolOffset = SymbolOffset;
+  Consumer->OldName = OldName;
   Consumer->USRs = 
   Consumer->SpellingName = 
   return std::move(Consumer);
Index: clang-rename/USRFinder.h
===
--- clang-rename/USRFinder.h
+++ clang-rename/USRFinder.h
@@ -30,6 +30,12 @@
 const NamedDecl *getNamedDeclAt(const ASTContext ,
 const SourceLocation Point);
 
+// Given an AST context and a fully qualified name, returns a NamedDecl
+// identifying the symbol with a matching name. Returns null if nothing is
+// found for the name.
+const NamedDecl *getNamedDeclFor(const ASTContext ,
+ const std::string );
+
 // Converts a Decl into a USR.
 std::string getUSRForDecl(const Decl *Decl);
 
Index: clang-rename/USRFinder.cpp
===
--- clang-rename/USRFinder.cpp
+++ clang-rename/USRFinder.cpp
@@ -40,6 +40,14 @@
 Point(Point) {
   }
 
+  // \brief Finds the NamedDecl for a name in the source.
+  // \param Name the fully qualified name.
+  explicit NamedDeclFindingASTVisitor(const SourceManager ,
+  const std::string )
+  : Result(nullptr), SourceMgr(SourceMgr),
+Name(Name) {
+  }
+
   // Declaration visitors:
 
   // \brief Checks if the point falls within the NameDecl. This covers every
@@ -93,9 +101,17 @@
   // \returns false on success.
   bool setResult(const NamedDecl *Decl, SourceLocation Start,
  SourceLocation End) {
-if (!Start.isValid() || !Start.isFileID() || !End.isValid() ||
-!End.isFileID() || !isPointWithin(Start, End)) {
-  return true;
+if (Name.empty()) {
+  // Offset is used to find the 

r273159 - [modules] Allow emission of update records for predefined __va_list_tag.

2016-06-20 Thread Vassil Vassilev via cfe-commits
Author: vvassilev
Date: Mon Jun 20 10:10:40 2016
New Revision: 273159

URL: http://llvm.org/viewvc/llvm-project?rev=273159=rev
Log:
[modules] Allow emission of update records for predefined __va_list_tag.

Handles the cases where old __va_list_tag is coming from a module and the new
is not, needing an update record.

Fixes https://llvm.org/bugs/show_bug.cgi?id=27890

Patch by Cristina Cristescu, Richard Smith and me.

Added:
cfe/trunk/test/Modules/Inputs/PR27890/
cfe/trunk/test/Modules/Inputs/PR27890/a.h
cfe/trunk/test/Modules/Inputs/PR27890/module.modulemap
cfe/trunk/test/Modules/pr27890.cpp
Modified:
cfe/trunk/lib/Serialization/ASTWriter.cpp

Modified: cfe/trunk/lib/Serialization/ASTWriter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTWriter.cpp?rev=273159=273158=273159=diff
==
--- cfe/trunk/lib/Serialization/ASTWriter.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTWriter.cpp Mon Jun 20 10:10:40 2016
@@ -5654,10 +5654,6 @@ static bool isImportedDeclContext(ASTRea
   if (D->isFromASTFile())
 return true;
 
-  // If we've not loaded any modules, this can't be imported.
-  if (!Chain || !Chain->getModuleManager().size())
-return false;
-
   // The predefined __va_list_tag struct is imported if we imported any decls.
   // FIXME: This is a gross hack.
   return D == D->getASTContext().getVaListTagDecl();

Added: cfe/trunk/test/Modules/Inputs/PR27890/a.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/PR27890/a.h?rev=273159=auto
==
--- cfe/trunk/test/Modules/Inputs/PR27890/a.h (added)
+++ cfe/trunk/test/Modules/Inputs/PR27890/a.h Mon Jun 20 10:10:40 2016
@@ -0,0 +1,9 @@
+template  DataType values(DataType) { __builtin_va_list 
ValueArgs; return DataType(); }
+
+template 
+class opt {
+public:
+  template 
+  opt(Mods) {}
+};
+

Added: cfe/trunk/test/Modules/Inputs/PR27890/module.modulemap
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/PR27890/module.modulemap?rev=273159=auto
==
--- cfe/trunk/test/Modules/Inputs/PR27890/module.modulemap (added)
+++ cfe/trunk/test/Modules/Inputs/PR27890/module.modulemap Mon Jun 20 10:10:40 
2016
@@ -0,0 +1 @@
+module A { header "a.h" export * }

Added: cfe/trunk/test/Modules/pr27890.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/pr27890.cpp?rev=273159=auto
==
--- cfe/trunk/test/Modules/pr27890.cpp (added)
+++ cfe/trunk/test/Modules/pr27890.cpp Mon Jun 20 10:10:40 2016
@@ -0,0 +1,9 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -std=c++11 -I%S/Inputs/PR27890 -verify %s
+// RUN: %clang_cc1 -std=c++11 -fmodules 
-fmodule-map-file=%S/Inputs/PR27890/module.modulemap -fmodules-cache-path=%t 
-I%S/Inputs/PR27890 -verify %s
+
+#include "a.h"
+enum ActionType {};
+opt a(values(""));
+
+// expected-no-diagnostics
\ No newline at end of file


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


Re: [PATCH] D21517: clang-rename: add a -old-name option

2016-06-20 Thread Manuel Klimek via cfe-commits
klimek added inline comments.


Comment at: clang-rename/USRFinder.h:28-33
@@ -27,6 +27,8 @@
 
-// Given an AST context and a point, returns a NamedDecl identifying the symbol
-// at the point. Returns null if nothing is found at the point.
+// Given an AST context and a point (or fully qualified name), returns a
+// NamedDecl identifying the symbol at the point. Returns null if nothing is
+// found at the point.
 const NamedDecl *getNamedDeclAt(const ASTContext ,
-const SourceLocation Point);
+const SourceLocation Point,
+const std::string );
 

These seem to be fundamentally different use cases. Can we add a new top-level 
function instead?
It seems like the new case would have a much simpler implementation.


http://reviews.llvm.org/D21517



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


Re: [PATCH] D20979: [OpenCL] Use function metadata to represent kernel attributes

2016-06-20 Thread Yaxun Liu via cfe-commits
yaxunl added inline comments.


Comment at: test/CodeGenOpenCL/kernel-attributes.cl:9
@@ -8,3 +10,1 @@
 
-// CHECK: opencl.kernels = !{[[MDNODE0:![0-9]+]], [[MDNODE3:![0-9]+]]}
-

bader wrote:
> AFAIK, this named metadata node were also useful for kernel functions 
> traversal.
> What is the new BKM to differentiate kernel/non-kernel functions?
> Check for !kernel_arg_* function attribute?
I think it could be used for that purpose, since kernel functions and only 
kernel functions have this function attribute.


http://reviews.llvm.org/D20979



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


Re: [PATCH] D20979: [OpenCL] Use function metadata to represent kernel attributes

2016-06-20 Thread Alexey Bader via cfe-commits
bader accepted this revision.
bader added a comment.

LGTM.



Comment at: test/CodeGenOpenCL/kernel-attributes.cl:9
@@ -8,3 +10,1 @@
 
-// CHECK: opencl.kernels = !{[[MDNODE0:![0-9]+]], [[MDNODE3:![0-9]+]]}
-

AFAIK, this named metadata node were also useful for kernel functions traversal.
What is the new BKM to differentiate kernel/non-kernel functions?
Check for !kernel_arg_* function attribute?


http://reviews.llvm.org/D20979



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


r273158 - Make test less sensitive to the resource directory.

2016-06-20 Thread Paul Robinson via cfe-commits
Author: probinson
Date: Mon Jun 20 09:33:49 2016
New Revision: 273158

URL: http://llvm.org/viewvc/llvm-project?rev=273158=rev
Log:
Make test less sensitive to the resource directory.
Same tactic as linux-header-search.cpp and android-ndk-standalone.cpp.


Modified:
cfe/trunk/test/Driver/windows-cross.c

Modified: cfe/trunk/test/Driver/windows-cross.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/windows-cross.c?rev=273158=273157=273158=diff
==
--- cfe/trunk/test/Driver/windows-cross.c (original)
+++ cfe/trunk/test/Driver/windows-cross.c Mon Jun 20 09:33:49 2016
@@ -69,7 +69,8 @@
 
 // RUN: %clang -### -target armv7-windows-itanium -isystem-after "Windows 
Kits/10/Include/10.0.10586.0/ucrt" -isystem-after "Windows 
Kits/10/Include/10.0.10586.0/um" -isystem-after "Windows 
Kits/10/Include/10.0.10586.0/shared" -c %s -o /dev/null 2>&1 \
 // RUN: | FileCheck %s --check-prefix CHECK-ISYSTEM-AFTER
-// CHECK-ISYSTEM-AFTER: "-internal-isystem" 
"{{.*}}{{[/\\]}}clang{{[/\\]}}{{[\.0-9]+}}{{[/\\]}}include"
+// CHECK-ISYSTEM-AFTER: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
+// CHECK-ISYSTEM-AFTER: "-internal-isystem" 
"[[RESOURCE_DIR]]{{(/|)}}include"
 // CHECK-ISYSTEM-AFTER: "-internal-isystem" "Windows 
Kits{{[/\\]}}10{{[/\\]}}Include{{[/\\]}}10.0.10586.0{{[/\\]}}ucrt"
 // CHECK-ISYSTEM-AFTER: "-internal-isystem" "Windows 
Kits{{[/\\]}}10{{[/\\]}}Include{{[/\\]}}10.0.10586.0{{[/\\]}}um"
 // CHECK-ISYSTEM-AFTER: "-internal-isystem" "Windows 
Kits{{[/\\]}}10{{[/\\]}}Include{{[/\\]}}10.0.10586.0{{[/\\]}}shared"


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


Re: [PATCH] D21453: Add support for attribute "overallocated"

2016-06-20 Thread Aaron Ballman via cfe-commits
aaron.ballman added inline comments.


Comment at: include/clang/Basic/Attr.td:2279
@@ +2278,3 @@
+  let Spellings = [GNU<"overallocated">, CXX11<"clang", "overallocated">];
+  let Subjects = SubjectList<[Record], ErrorDiag, "ExpectedStructOrUnion">;
+  let Documentation = [OverAllocatedDocs];

Can drop the "Expected" string literal. A record type should automatically do 
the right thing.


Comment at: lib/Sema/SemaDeclAttr.cpp:4932
@@ -4931,1 +4931,3 @@
 
+static void handleOverAllocatedAttr(Sema , Decl *D, const AttributeList 
) {
+  D->addAttr(::new (S.Context)

This isn't required.


Comment at: lib/Sema/SemaDeclAttr.cpp:5404
@@ +5403,3 @@
+  case AttributeList::AT_OverAllocated:
+handleOverAllocatedAttr(S, D, Attr);
+break;

Can just call `handleSimpleAttribute()` instead.


http://reviews.llvm.org/D21453



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


Re: [PATCH] D20979: [OpenCL] Use function metadata to represent kernel attributes

2016-06-20 Thread Yaxun Liu via cfe-commits
yaxunl added a comment.

Ping!

Alexey/Xiuli, are you OK with this change? Thanks.


http://reviews.llvm.org/D20979



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


Re: [PATCH] D21505: [Clang][AVX512][Intrinsics]Adding intrinsics for mov{ss|sd} instruction set

2016-06-20 Thread michael zuckerman via cfe-commits
m_zuckerman updated this revision to Diff 61250.

http://reviews.llvm.org/D21505

Files:
  lib/Headers/avx512fintrin.h
  test/CodeGen/avx512f-builtins.c

Index: test/CodeGen/avx512f-builtins.c
===
--- test/CodeGen/avx512f-builtins.c
+++ test/CodeGen/avx512f-builtins.c
@@ -241,6 +241,23 @@
   _mm512_mask_store_pd(p, m, a);
 }
 
+__m128 test_mm_mask_store_ss (float * __W, __mmask8 __U, __m128 __A)
+{
+  // CHECK-LABEL: @test_mm_mask_store_ss
+  // CHECK:  store float {{.*}}, float* {{.*}}
+  // CHECK: load <4 x float>, <4 x float>* {{.*}}
+  return _mm_mask_store_ss (__W, __U, __A);
+}
+
+__m128d test_mm_mask_store_sd (double * __W, __mmask8 __U, __m128d __A)
+{
+  // CHECK-LABEL: @test_mm_mask_store_sd
+  // CHECK:  store double {{.*}}, double* {{.*}}
+  // CHECK: load <2 x double>, <2 x double>* {{.*}}
+  return _mm_mask_store_sd ( __W,  __U,  __A);
+}
+
+
 void test_mm512_mask_storeu_epi32(void *__P, __mmask16 __U, __m512i __A) {
   // CHECK-LABEL: @test_mm512_mask_storeu_epi32
   // CHECK: @llvm.masked.store.v16i32(<16 x i32> %{{.*}}, <16 x i32>* %{{.*}}, i32 1, <16 x i1> %{{.*}})
@@ -371,6 +388,38 @@
   return _mm512_maskz_load_pd(__U, __P);
 }
 
+__m128 test_mm_mask_load_ss (__m128 __W, __mmask8 __U, float const* __A)
+{
+  // CHECK-LABEL: @test_mm_mask_load_ss
+  // CHECK: select <4 x i1> {{.*}}, <4 x float> {{.*}}, <4 x float> {{.*}}
+  // CHECK: load <4 x float>, <4 x float>* {{.*}}
+  return _mm_mask_load_ss ( __W,  __U,  __A);
+}
+
+__m128 test_mm_maskz_load_ss (__mmask8 __U, float const* __A)
+{
+  // CHECK-LABEL: @test_mm_maskz_load_ss
+  // CHECK: select <4 x i1> {{.*}}, <4 x float> {{.*}}, <4 x float> {{.*}}
+  // CHECK: load <4 x float>, <4 x float>* {{.*}}
+  return _mm_maskz_load_ss (__U, __A);
+}
+
+__m128d test_mm_mask_load_sd (__m128 __W, __mmask8 __U, double const* __A)
+{
+  // CHECK-LABEL: @test_mm_mask_load_sd
+  // CHECK: select <2 x i1>{{.*}}, <2 x double>{{.*}}, <2 x double>{{.*}} 
+  // CHECK: load <2 x double>, <2 x double>* {{.*}}
+  return _mm_mask_load_sd ( __W,  __U,  __A);
+}
+
+__m128d test_mm_maskz_load_sd (__mmask8 __U, double const* __A)
+{
+  // CHECK-LABEL: @test_mm_maskz_load_sd
+  // CHECK: select <2 x i1> {{.*}}, <2 x double> {{.*}}, <2 x double> {{.*}}
+  // CHECK: load <2 x double>, <2 x double>* {{.*}}
+  return _mm_maskz_load_sd (__U, __A);
+}
+
 __m512d test_mm512_set1_pd(double d)
 {
   // CHECK-LABEL: @test_mm512_set1_pd
@@ -6125,6 +6174,38 @@
   return _mm512_maskz_mov_ps(__U, __A); 
 }
 
+__m128 test_mm_mask_move_ss (__m128 __W, __mmask8 __U, __m128 __A, __m128 __B)
+{
+  // CHECK-LABEL: @test_mm_mask_move_ss
+  // CHECK: select <4 x i1>{{.*}}, <4 x float> {{.*}}, <4 x float>{{.*}}
+  // CHECK: load <4 x float>, <4 x float>* {{.*}}
+ return _mm_mask_move_ss ( __W,  __U,  __A,  __B);
+}
+
+__m128 test_mm_maskz_move_ss (__mmask8 __U, __m128 __A, __m128 __B)
+{
+  // CHECK-LABEL: @test_mm_maskz_move_ss
+  // CHECK: select <4 x i1>{{.*}}, <4 x float> {{.*}}, <4 x float>{{.*}}
+  // CHECK: load <4 x float>, <4 x float>* {{.*}}
+  return _mm_maskz_move_ss (__U, __A, __B);
+}
+
+__m128d test_mm_mask_move_sd (__m128 __W, __mmask8 __U, __m128d __A, __m128d __B)
+{
+  // CHECK-LABEL: @test_mm_mask_move_sd
+  // CHECK: select <2 x i1>{{.*}}, <2 x double>{{.*}}, <2 x double>{{.*}}
+  // CHECK: load <2 x double>, <2 x double>* {{.*}}
+  return _mm_mask_move_sd ( __W,  __U,  __A,  __B);
+}
+
+__m128d test_mm_maskz_move_sd (__mmask8 __U, __m128d __A, __m128d __B)
+{
+  // CHECK-LABEL: @test_mm_maskz_move_sd
+  // CHECK: select <2 x i1> {{.*}}, <2 x double> {{.*}}, <2 x double> {{.*}}
+  // CHECK: load <2 x double>, <2 x double>* {{.*}}
+  return _mm_maskz_move_sd (__U, __A, __B);
+}
+
 void test_mm512_mask_compressstoreu_pd(void *__P, __mmask8 __U, __m512d __A) {
   // CHECK-LABEL: @test_mm512_mask_compressstoreu_pd
   // CHECK: @llvm.x86.avx512.mask.compress.store.pd.512
Index: lib/Headers/avx512fintrin.h
===
--- lib/Headers/avx512fintrin.h
+++ lib/Headers/avx512fintrin.h
@@ -4400,6 +4400,30 @@
   return *(__m512i *) __P;
 }
 
+static __inline__ __m128 __DEFAULT_FN_ATTRS
+_mm_mask_load_ss (__m128 __W, __mmask8 __U, const float* __A)
+{
+  return (__U & 1) ?  _mm_load_ss(__A) :  (__m128) { __W[0], 0, 0, 0}; 
+}
+
+static __inline__ __m128 __DEFAULT_FN_ATTRS
+_mm_maskz_load_ss (__mmask8 __U, const float* __A)
+{
+  return (__U & 1) ?  _mm_load_ss(__A) :  (__m128) { 0, 0, 0, 0}; 
+}
+
+static __inline__ __m128d __DEFAULT_FN_ATTRS
+_mm_mask_load_sd (__m128d __W, __mmask8 __U, const double* __A)
+{
+  return (__U & 1) ?  _mm_load_sd(__A) :(__m128d) { __W[0], 0};
+}
+
+static __inline__ __m128d __DEFAULT_FN_ATTRS
+_mm_maskz_load_sd (__mmask8 __U, const double* __A)
+{
+  return (__U & 1) ?  _mm_load_sd(__A) :(__m128d) { 0, 0};
+}
+
 /* SIMD store ops */
 
 static __inline void __DEFAULT_FN_ATTRS
@@ -4491,6 +4515,20 @@
   *(__m512i *) __P = __A;
 }
 

Re: [gentoo-musl] Re: Add support for musl-libc on Linux

2016-06-20 Thread Lei Zhang via cfe-commits
2016-06-20 19:44 GMT+08:00 Peter Smith :
> From what I can see, the EABI type is used to decide if certain
> __aeabi_ prefixed functions such as __aeabi_idiv are available. If
> Musl differs in function availability from the GNU library here I
> think you'll need a Musl EABI type. However if there is no difference
> you should be able to use the EABI::GNU type for Musl.

I think musl and glibc is compatible on this; I'm just a little
concerned that using EABI::GNU for both GNUEABI* and MuslEABI* might
cause some confusion.

> You might find http://reviews.llvm.org/D12413 helpful here
> (introduction of -meabi option).

It seems clang's -meabi option is incompatible with gcc's.


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


Re: [musl] Re: [gentoo-musl] Re: Add support for musl-libc on Linux

2016-06-20 Thread Szabolcs Nagy via cfe-commits
* Lei Zhang  [2016-06-20 18:59:20 +0800]:
> 2016-06-20 17:37 GMT+08:00 Peter Smith :
> > - isTargetEHABICompatible()
> > I'm making the assumption that musl supports the ARM exceptions EHABI,
> > if so you'll want to add MUSL and MUSLHF here.
> 
> I'm not 100% sure about this. Could some insider from musl confirm this?

musl is ehabi agnostic.

ehabi and libc should be independent.

throwing exceptions across libc boundary is undefined
behaviour, all ehabi support is in the compiler runtime.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [libcxx] r249738 - Split out of .

2016-06-20 Thread Vassil Vassilev via cfe-commits

On 17/10/15 01:27, Richard Smith via cfe-commits wrote:
On Thu, Oct 15, 2015 at 11:14 AM, Adrian Prantl > wrote:




On Oct 14, 2015, at 5:07 PM, Richard Smith > wrote:

Ack, there are non-modular headers in the Darwin module. =( I
seem to recall that they're not version-locked to your compiler,
so we've got to support them as-is?

If we can't turn on local submodule visibility, then we need a
module map for libc++ that covers all of its headers. I'll look
into pruning the include path when building a module from an
implicitly-loaded module map.


The attached patch implements this in the most hacky way; with it
I can successfully compile the first few hundred files of LLVM.


Slightly less hacky approach attached, does this also unstick you?

I got bitten by the same issue with ToT clang and xcode 7.3 update.

Did this set of patches land in trunk? Would it make sense the 
properties of NoUndeclaredIncludes to be added to [system] instead?



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



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


Re: [PATCH] D20964: [clang-tidy] Add modernize-use-emplace

2016-06-20 Thread Haojian Wu via cfe-commits
hokein accepted this revision.
hokein added a comment.
This revision is now accepted and ready to land.

Looks almost good now, a few comments. You'd better await for comments from 
@alexfh or @sbenza before committing.



Comment at: docs/clang-tidy/checks/modernize-use-emplace.rst:62
@@ +61,3 @@
+
+Check also fire if any argument of constructor call woule be:
+- bitfield (bitfields can't bind to rvalue/universal reference)

s/fire/fires
s/woule/would


Comment at: test/clang-tidy/modernize-use-emplace.cpp:3
@@ +2,3 @@
+
+namespace std {
+template 

Oops, you are right. That's another non-relevant issue (different 
`emplace_back` behaviors in `vector`, `vector`). I'm 
over-concerned here. 




Comment at: test/clang-tidy/modernize-use-emplace.cpp:317
@@ +316,3 @@
+
+void testAggregation() {
+  // This should not be noticed or fixed; after the correction, the code won't

Looks like the test is kind of duplicated with `testAggregate` in L248, you can 
merge that one into this one.


http://reviews.llvm.org/D20964



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


Re: [gentoo-musl] Re: Add support for musl-libc on Linux

2016-06-20 Thread Peter Smith via cfe-commits
From what I can see, the EABI type is used to decide if certain
__aeabi_ prefixed functions such as __aeabi_idiv are available. If
Musl differs in function availability from the GNU library here I
think you'll need a Musl EABI type. However if there is no difference
you should be able to use the EABI::GNU type for Musl.

You might find http://reviews.llvm.org/D12413 helpful here
(introduction of -meabi option).

Peter


On 20 June 2016 at 11:59, Lei Zhang  wrote:
> 2016-06-20 17:37 GMT+08:00 Peter Smith :
>> Hello Lei,
>
> Hi, thanks for your reply!
>
>> I agree with Rafael that this is currently missing a few critical
>> things right now, especially in the llvm patch.
>>
>> My (limited) understanding of musl is that it intends to support the
>> same interface as GNUEABI and GNUEABIHF, but it is obviously a
>> different implementation.
>>
>> This is what I could find with a basic grep for GNUAEABI and working
>> out from there.
>>
>> Clang patch
>> I'm assuming you are only intending to support Musl on linux, and not BSD.
>
> Yes.
>
>> ToolChains.cpp
>> - getDynamicLinker()
>> There is a Triple.getEnvironment() == llvm::triple::GNUEABIHF which
>> selects between ld-linux-armhf.so.3 or ld-linux.so.3. I think you'll
>> need ld-linux-armhf.so.3 for MUSLHF here as well.
>
> Actually musl's dynamic linker has a different naming scheme from
> glibc's, which is handled by an extra chunk of code in the patch. The
> code you mentioned won't be reached when musl is present, and thus
> need no change.
>
>> LLVM patch
>> ARMSubtarget.h
>> - isTargetGNUAEABI()
>> I think you'll need to check all the callsites of this function, and
>> check what you want isTargetMusl() to do. At present I think you'll
>> want them to do the same thing in all cases except finding the
>> implementation. There looks to be a trade off between adding MUSCL and
>> MUSCLHF to isTargetGNUAEABI(), adding something like
>> isTargetGNUAEABIInterface() and adding isTargetMusl() to all the
>> callsites.
>>
>> - isTargetEHABICompatible()
>> I'm making the assumption that musl supports the ARM exceptions EHABI,
>> if so you'll want to add MUSL and MUSLHF here.
>
> I'm not 100% sure about this. Could some insider from musl confirm this?
>
>> - isTargetHardFloat()
>> You'll want to add MUSLHF here.
>>
>> ARMTargetMachine.cpp
>> - computeTargetABI()
>> You'll want to add MUSL and MUSLHF alongside GNUEABI and GNUEABIHF in
>> the switch.
>>
>> Hope this helps
>
> In addition to what you mentioned, perhaps I should also add "Musl" as
> a new EABI type in TargetOptions.h (in LLVM), just side by side with
> "GNU", and change relevant bits in LLVM and clang accordingly.
>
>
> Thanks again,
> Lei
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r273150 - Add -fsyntax-only to Driver/opencl.cl test.

2016-06-20 Thread Cong Liu via cfe-commits
Author: congliu
Date: Mon Jun 20 06:25:26 2016
New Revision: 273150

URL: http://llvm.org/viewvc/llvm-project?rev=273150=rev
Log:
Add -fsyntax-only to Driver/opencl.cl test.

Modified:
cfe/trunk/test/Driver/opencl.cl

Modified: cfe/trunk/test/Driver/opencl.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/opencl.cl?rev=273150=273149=273150=diff
==
--- cfe/trunk/test/Driver/opencl.cl (original)
+++ cfe/trunk/test/Driver/opencl.cl Mon Jun 20 06:25:26 2016
@@ -1,12 +1,12 @@
-// RUN: %clang %s
-// RUN: %clang -std=cl %s
-// RUN: %clang -std=cl1.1 %s
-// RUN: %clang -std=cl1.2 %s
-// RUN: %clang -std=cl2.0 %s
-// RUN: %clang -std=CL %s
-// RUN: %clang -std=CL1.1 %s
-// RUN: %clang -std=CL1.2 %s
-// RUN: %clang -std=CL2.0 %s
+// RUN: %clang -fsyntax-only %s
+// RUN: %clang -fsyntax-only -std=cl %s
+// RUN: %clang -fsyntax-only -std=cl1.1 %s
+// RUN: %clang -fsyntax-only -std=cl1.2 %s
+// RUN: %clang -fsyntax-only -std=cl2.0 %s
+// RUN: %clang -fsyntax-only -std=CL %s
+// RUN: %clang -fsyntax-only -std=CL1.1 %s
+// RUN: %clang -fsyntax-only -std=CL1.2 %s
+// RUN: %clang -fsyntax-only -std=CL2.0 %s
 // RUN: not %clang_cc1 -std=c99 -DOPENCL %s 2>&1 | FileCheck 
--check-prefix=CHECK-C99 %s
 // RUN: not %clang_cc1 -std=invalid -DOPENCL %s 2>&1 | FileCheck 
--check-prefix=CHECK-INVALID %s
 // CHECK-C99: error: invalid argument '-std=c99' not allowed with 'OpenCL'


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


Re: [PATCH] D21224: [Driver] Add method to redirect output of Compilation.

2016-06-20 Thread Nikolay Haustov via cfe-commits
nhaustov added a comment.

Ping.


http://reviews.llvm.org/D21224



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


Re: [PATCH] D21367: AMDGPU: Set amdgpu_kernel calling convention for OpenCL kernels.

2016-06-20 Thread Nikolay Haustov via cfe-commits
nhaustov updated this revision to Diff 61247.
nhaustov added a comment.

Add test for calling OpenCL kernel from kernel.


http://reviews.llvm.org/D21367

Files:
  include/clang/AST/Type.h
  include/clang/Basic/Specifiers.h
  lib/AST/ItaniumMangle.cpp
  lib/AST/Type.cpp
  lib/AST/TypePrinter.cpp
  lib/Basic/Targets.cpp
  lib/CodeGen/CGCall.cpp
  lib/CodeGen/CGDebugInfo.cpp
  lib/Sema/SemaType.cpp
  test/CodeGenOpenCL/amdgpu-call-kernel.cl
  test/CodeGenOpenCL/amdgpu-calling-conv.cl
  test/CodeGenOpenCL/amdgpu-num-gpr-attr.cl
  tools/libclang/CXType.cpp

Index: tools/libclang/CXType.cpp
===
--- tools/libclang/CXType.cpp
+++ tools/libclang/CXType.cpp
@@ -542,6 +542,7 @@
   TCALLINGCONV(PreserveAll);
 case CC_SpirFunction: return CXCallingConv_Unexposed;
 case CC_SpirKernel: return CXCallingConv_Unexposed;
+case CC_AMDGPUKernel: return CXCallingConv_Unexposed;
   break;
 }
 #undef TCALLINGCONV
Index: test/CodeGenOpenCL/amdgpu-num-gpr-attr.cl
===
--- test/CodeGenOpenCL/amdgpu-num-gpr-attr.cl
+++ test/CodeGenOpenCL/amdgpu-num-gpr-attr.cl
@@ -5,23 +5,23 @@
 
 __attribute__((amdgpu_num_vgpr(64))) // expected-no-diagnostics
 kernel void test_num_vgpr64() {
-// CHECK: define void @test_num_vgpr64() [[ATTR_VGPR64:#[0-9]+]]
+// CHECK: define amdgpu_kernel void @test_num_vgpr64() [[ATTR_VGPR64:#[0-9]+]]
 }
 
 __attribute__((amdgpu_num_sgpr(32))) // expected-no-diagnostics
 kernel void test_num_sgpr32() {
-// CHECK: define void @test_num_sgpr32() [[ATTR_SGPR32:#[0-9]+]]
+// CHECK: define amdgpu_kernel void @test_num_sgpr32() [[ATTR_SGPR32:#[0-9]+]]
 }
 
 __attribute__((amdgpu_num_vgpr(64), amdgpu_num_sgpr(32))) // expected-no-diagnostics
 kernel void test_num_vgpr64_sgpr32() {
-// CHECK: define void @test_num_vgpr64_sgpr32() [[ATTR_VGPR64_SGPR32:#[0-9]+]]
+// CHECK: define amdgpu_kernel void @test_num_vgpr64_sgpr32() [[ATTR_VGPR64_SGPR32:#[0-9]+]]
 
 }
 
 __attribute__((amdgpu_num_sgpr(20), amdgpu_num_vgpr(40))) // expected-no-diagnostics
 kernel void test_num_sgpr20_vgpr40() {
-// CHECK: define void @test_num_sgpr20_vgpr40() [[ATTR_SGPR20_VGPR40:#[0-9]+]]
+// CHECK: define amdgpu_kernel void @test_num_sgpr20_vgpr40() [[ATTR_SGPR20_VGPR40:#[0-9]+]]
 }
 
 __attribute__((amdgpu_num_vgpr(0))) // expected-no-diagnostics
Index: test/CodeGenOpenCL/amdgpu-calling-conv.cl
===
--- /dev/null
+++ test/CodeGenOpenCL/amdgpu-calling-conv.cl
@@ -0,0 +1,12 @@
+// REQUIRES: amdgpu-registered-target
+// RUN: %clang_cc1 -triple amdgcn-unknown-unknown -S -emit-llvm -o - %s | FileCheck %s
+
+// CHECK: define amdgpu_kernel void @calling_conv_amdgpu_kernel()
+kernel void calling_conv_amdgpu_kernel()
+{
+}
+
+// CHECK: define void @calling_conv_none()
+void calling_conv_none()
+{
+}
Index: test/CodeGenOpenCL/amdgpu-call-kernel.cl
===
--- /dev/null
+++ test/CodeGenOpenCL/amdgpu-call-kernel.cl
@@ -0,0 +1,14 @@
+// REQUIRES: amdgpu-registered-target
+// RUN: %clang_cc1 -triple amdgcn-unknown-unknown -S -emit-llvm -o - %s | FileCheck %s
+// CHECK: define amdgpu_kernel void @test_call_kernel(i32 addrspace(1)* nocapture %out)
+// CHECK: store i32 4, i32 addrspace(1)* %out, align 4
+
+kernel void test_kernel(global int *out)
+{
+  out[0] = 4;
+}
+
+__kernel void test_call_kernel(__global int *out)
+{
+  test_kernel(out);
+}
Index: lib/Sema/SemaType.cpp
===
--- lib/Sema/SemaType.cpp
+++ lib/Sema/SemaType.cpp
@@ -3182,15 +3182,20 @@
   CallingConv CC = S.Context.getDefaultCallingConvention(FTI.isVariadic,
  IsCXXInstanceMethod);
 
-  // Attribute AT_OpenCLKernel affects the calling convention only on
-  // the SPIR target, hence it cannot be treated as a calling
+  // Attribute AT_OpenCLKernel affects the calling convention for SPIR
+  // and AMDGPU targets, hence it cannot be treated as a calling
   // convention attribute. This is the simplest place to infer
-  // "spir_kernel" for OpenCL kernels on SPIR.
-  if (CC == CC_SpirFunction) {
+  // calling convention for OpenCL kernels.
+  if (S.getLangOpts().OpenCL) {
 for (const AttributeList *Attr = D.getDeclSpec().getAttributes().getList();
  Attr; Attr = Attr->getNext()) {
   if (Attr->getKind() == AttributeList::AT_OpenCLKernel) {
-CC = CC_SpirKernel;
+llvm::Triple::ArchType arch = S.Context.getTargetInfo().getTriple().getArch();
+if (arch == llvm::Triple::spir || arch == llvm::Triple::spir64) {
+  CC = CC_SpirKernel;
+} else if (arch == llvm::Triple::amdgcn) {
+  CC = CC_AMDGPUKernel;
+}
 break;
   }
 }
Index: lib/CodeGen/CGDebugInfo.cpp
===
--- 

Re: [PATCH] D21367: AMDGPU: Set amdgpu_kernel calling convention for OpenCL kernels.

2016-06-20 Thread Nikolay Haustov via cfe-commits
nhaustov added a comment.

In http://reviews.llvm.org/D21367#461480, @tstellarAMD wrote:

> Does this new patch fix the OpenCL regression?


Yes, it fixes the problem with calling kernel from kernel. I'll add a test too.


http://reviews.llvm.org/D21367



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


Re: [PATCH] D21279: Fix some issues in clang-format's AlignConsecutive modes

2016-06-20 Thread Beren Minor via cfe-commits
berenm added a comment.

Thanks! The operators are now correctly handled.

Another thing I've found is that constructors aren't aligned either with other 
declarations or either together. Do you think it would be possible to treat 
them as functions as well?

Friend functions also aren't aligned with the other functions, but I'm not sure 
why or even if they should be. I believe most of the time friend functions are 
declared in a separate declaration "group" anyway.

  struct A {
explicit A(int);
A();
unsigned operator=(int a);
long bar(int a);
friend void foo();
friend unsigned baz();
  };


Repository:
  rL LLVM

http://reviews.llvm.org/D21279



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


Re: [gentoo-musl] Re: Add support for musl-libc on Linux

2016-06-20 Thread Lei Zhang via cfe-commits
2016-06-18 8:52 GMT+08:00 Rafael EspĂ­ndola :
> There are probably a few more places that need to be patched.
>
> In particular, take a look at lib/Target/ARM. There are things like
> computeTargetABI and isTargetHardFloat that probably need to be
> updated (and tested).

Any hints how to test the new changes? I guess merely checking clang's
output like the previous test cases won't suffice this time.


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


Re: [gentoo-musl] Re: Add support for musl-libc on Linux

2016-06-20 Thread Lei Zhang via cfe-commits
2016-06-20 17:37 GMT+08:00 Peter Smith :
> Hello Lei,

Hi, thanks for your reply!

> I agree with Rafael that this is currently missing a few critical
> things right now, especially in the llvm patch.
>
> My (limited) understanding of musl is that it intends to support the
> same interface as GNUEABI and GNUEABIHF, but it is obviously a
> different implementation.
>
> This is what I could find with a basic grep for GNUAEABI and working
> out from there.
>
> Clang patch
> I'm assuming you are only intending to support Musl on linux, and not BSD.

Yes.

> ToolChains.cpp
> - getDynamicLinker()
> There is a Triple.getEnvironment() == llvm::triple::GNUEABIHF which
> selects between ld-linux-armhf.so.3 or ld-linux.so.3. I think you'll
> need ld-linux-armhf.so.3 for MUSLHF here as well.

Actually musl's dynamic linker has a different naming scheme from
glibc's, which is handled by an extra chunk of code in the patch. The
code you mentioned won't be reached when musl is present, and thus
need no change.

> LLVM patch
> ARMSubtarget.h
> - isTargetGNUAEABI()
> I think you'll need to check all the callsites of this function, and
> check what you want isTargetMusl() to do. At present I think you'll
> want them to do the same thing in all cases except finding the
> implementation. There looks to be a trade off between adding MUSCL and
> MUSCLHF to isTargetGNUAEABI(), adding something like
> isTargetGNUAEABIInterface() and adding isTargetMusl() to all the
> callsites.
>
> - isTargetEHABICompatible()
> I'm making the assumption that musl supports the ARM exceptions EHABI,
> if so you'll want to add MUSL and MUSLHF here.

I'm not 100% sure about this. Could some insider from musl confirm this?

> - isTargetHardFloat()
> You'll want to add MUSLHF here.
>
> ARMTargetMachine.cpp
> - computeTargetABI()
> You'll want to add MUSL and MUSLHF alongside GNUEABI and GNUEABIHF in
> the switch.
>
> Hope this helps

In addition to what you mentioned, perhaps I should also add "Musl" as
a new EABI type in TargetOptions.h (in LLVM), just side by side with
"GNU", and change relevant bits in LLVM and clang accordingly.


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


Re: [PATCH] D21506: [analyzer] Block in critical section

2016-06-20 Thread Artem Dergachev via cfe-commits
NoQ added a comment.

Useful stuff!

When I see your approach with `mutexCount`, the following test case comes to 
mind:

  std::mutex m;
  void foo() {
// Suppose this function is always called
// with the mutex 'm' locked.
m.unlock();
// Here probably some useful work is done.
m.lock();
// What's the current mutex count?
sleep(1); // expected-warning{{}}
  }



Comment at: lib/StaticAnalyzer/Checkers/BlockInCriticalSectionChecker.cpp:11
@@ +10,3 @@
+// Defines a checker for blocks in critical sections. This checker should find 
+// the calls to blocking functions (for example: sleep, getc, fgets, read, 
+// recv etc.) inside a critical section. When sleep(x) is called while a mutex

A bit of trailing whitespace here.


Comment at: test/Analysis/block-in-critical-section.cpp:1
@@ +1,2 @@
+// RUN: %clang --analyze -std=c++11 -Xclang -analyzer-checker -Xclang 
alpha.unix.BlockInCriticalSection %s
+

The run line is lacking `-verify`, and therefore these tests always pass. In 
your case, it'd be `-Xclang -verify`. On the other hand, i'm not sure if it's a 
good idea to run the test under the driver, instead of the standard `-cc1` 
approach - after all, you aren't including any system headers in the test.


Repository:
  rL LLVM

http://reviews.llvm.org/D21506



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


Re: [PATCH] D21469: Add -mno-iamcu option

2016-06-20 Thread Andrey Turetskiy via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL273147: [X86] Add -mno-iamcu option. (authored by aturetsk).

Changed prior to commit:
  http://reviews.llvm.org/D21469?vs=61088=61245#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D21469

Files:
  cfe/trunk/include/clang/Driver/Options.td
  cfe/trunk/lib/Driver/Driver.cpp
  cfe/trunk/lib/Driver/Tools.cpp
  cfe/trunk/test/Driver/miamcu-opt.c

Index: cfe/trunk/include/clang/Driver/Options.td
===
--- cfe/trunk/include/clang/Driver/Options.td
+++ cfe/trunk/include/clang/Driver/Options.td
@@ -1311,6 +1311,7 @@
 def mabi_EQ : Joined<["-"], "mabi=">, Group;
 def miamcu : Flag<["-"], "miamcu">, Group, Flags<[DriverOption, CoreOption]>,
   HelpText<"Use Intel MCU ABI">;
+def mno_iamcu : Flag<["-"], "mno-iamcu">, Group, Flags<[DriverOption, CoreOption]>;
 def malign_functions_EQ : Joined<["-"], "malign-functions=">, Group;
 def malign_loops_EQ : Joined<["-"], "malign-loops=">, Group;
 def malign_jumps_EQ : Joined<["-"], "malign-jumps=">, Group;
Index: cfe/trunk/test/Driver/miamcu-opt.c
===
--- cfe/trunk/test/Driver/miamcu-opt.c
+++ cfe/trunk/test/Driver/miamcu-opt.c
@@ -4,16 +4,20 @@
 // RUN: %clang -miamcu -no-canonical-prefixes %s -### -o %t.o 2>&1 | FileCheck %s
 // RUN: %clang -miamcu -no-canonical-prefixes -m32 %s -### -o %t.o 2>&1 | FileCheck %s
 // RUN: %clang -miamcu -no-canonical-prefixes -target x86_64-unknown-linux-gnu %s -### -o %t.o 2>&1 | FileCheck %s
+// RUN: %clang -mno-iamcu -miamcu -no-canonical-prefixes %s -### -o %t.o 2>&1 | FileCheck %s
 // RUN: %clang -miamcu -no-canonical-prefixes -m64 %s -### -o %t.o 2>&1 | FileCheck %s -check-prefix=M64
 // RUN: %clang -miamcu -no-canonical-prefixes -dynamic %s -### -o %t.o 2>&1 | FileCheck %s -check-prefix=DYNAMIC
 // RUN: %clang -miamcu -no-canonical-prefixes  -target armv8-eabi %s -### -o %t.o 2>&1 | FileCheck %s -check-prefix=NOT-X86
+// RUN: %clang -miamcu -mno-iamcu -no-canonical-prefixes -target x86_64-unknown-linux-gnu %s -### -o %t.o 2>&1 | FileCheck %s -check-prefix=MNOIAMCU
 
 // M64: error: invalid argument '-miamcu' not allowed with '-m64'
 
 // DYNAMIC: error: invalid argument '-dynamic' not allowed with '-static'
 
 // NOT-X86: error: unsupported option '-miamcu' for target 'armv8---eabi'
 
+// MNOIAMCU-NOT: "-triple" "i586-intel-elfiamcu"
+
 // CHECK: "{{.*}}clang{{.*}}" "-cc1"
 // CHECK: "-triple" "i586-intel-elfiamcu"
 // CHECK: "-static-define"
Index: cfe/trunk/lib/Driver/Tools.cpp
===
--- cfe/trunk/lib/Driver/Tools.cpp
+++ cfe/trunk/lib/Driver/Tools.cpp
@@ -2243,10 +2243,12 @@
   }
 
   // Set flags to support MCU ABI.
-  if (Args.hasArg(options::OPT_miamcu)) {
-CmdArgs.push_back("-mfloat-abi");
-CmdArgs.push_back("soft");
-CmdArgs.push_back("-mstack-alignment=4");
+  if (Arg *A = Args.getLastArg(options::OPT_miamcu, options::OPT_mno_iamcu)) {
+if (A->getOption().matches(options::OPT_miamcu)) {
+  CmdArgs.push_back("-mfloat-abi");
+  CmdArgs.push_back("soft");
+  CmdArgs.push_back("-mstack-alignment=4");
+}
   }
 }
 
Index: cfe/trunk/lib/Driver/Driver.cpp
===
--- cfe/trunk/lib/Driver/Driver.cpp
+++ cfe/trunk/lib/Driver/Driver.cpp
@@ -280,8 +280,9 @@
   }
 
   // Enforce -static if -miamcu is present.
-  if (Args.hasArg(options::OPT_miamcu))
-DAL->AddFlagArg(0, Opts->getOption(options::OPT_static));
+  if (Arg *Ar = Args.getLastArg(options::OPT_miamcu, options::OPT_mno_iamcu))
+if (Ar->getOption().matches(options::OPT_miamcu))
+  DAL->AddFlagArg(0, Opts->getOption(options::OPT_static));
 
 // Add a default value of -mlinker-version=, if one was given and the user
 // didn't specify one.
@@ -375,22 +376,24 @@
   }
 
   // Handle -miamcu flag.
-  if (Args.hasArg(options::OPT_miamcu)) {
-if (Target.get32BitArchVariant().getArch() != llvm::Triple::x86)
-  D.Diag(diag::err_drv_unsupported_opt_for_target) << "-miamcu"
-   << Target.str();
-
-if (A && !A->getOption().matches(options::OPT_m32))
-  D.Diag(diag::err_drv_argument_not_allowed_with)
-  << "-miamcu" << A->getBaseArg().getAsString(Args);
-
-Target.setArch(llvm::Triple::x86);
-Target.setArchName("i586");
-Target.setEnvironment(llvm::Triple::UnknownEnvironment);
-Target.setEnvironmentName("");
-Target.setOS(llvm::Triple::ELFIAMCU);
-Target.setVendor(llvm::Triple::UnknownVendor);
-Target.setVendorName("intel");
+  if (Arg *Ar = Args.getLastArg(options::OPT_miamcu, options::OPT_mno_iamcu)) {
+if (Ar->getOption().matches(options::OPT_miamcu)) {
+  if (Target.get32BitArchVariant().getArch() != llvm::Triple::x86)
+D.Diag(diag::err_drv_unsupported_opt_for_target) << "-miamcu"
+

r273147 - [X86] Add -mno-iamcu option.

2016-06-20 Thread Andrey Turetskiy via cfe-commits
Author: aturetsk
Date: Mon Jun 20 05:31:39 2016
New Revision: 273147

URL: http://llvm.org/viewvc/llvm-project?rev=273147=rev
Log:
[X86] Add -mno-iamcu option.

Add -mno-iamcu option to:
  1) Countervail -miamcu option easily
  2) Be compatible with GCC which supports this option

Differential Revision: http://reviews.llvm.org/D21469

Modified:
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/lib/Driver/Driver.cpp
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/test/Driver/miamcu-opt.c

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=273147=273146=273147=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Mon Jun 20 05:31:39 2016
@@ -1311,6 +1311,7 @@ def mx32 : Flag<["-"], "mx32">, Group, Group, Flags<[DriverOption, 
CoreOption]>,
   HelpText<"Use Intel MCU ABI">;
+def mno_iamcu : Flag<["-"], "mno-iamcu">, Group, Flags<[DriverOption, 
CoreOption]>;
 def malign_functions_EQ : Joined<["-"], "malign-functions=">, 
Group;
 def malign_loops_EQ : Joined<["-"], "malign-loops=">, 
Group;
 def malign_jumps_EQ : Joined<["-"], "malign-jumps=">, 
Group;

Modified: cfe/trunk/lib/Driver/Driver.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=273147=273146=273147=diff
==
--- cfe/trunk/lib/Driver/Driver.cpp (original)
+++ cfe/trunk/lib/Driver/Driver.cpp Mon Jun 20 05:31:39 2016
@@ -280,8 +280,9 @@ DerivedArgList *Driver::TranslateInputAr
   }
 
   // Enforce -static if -miamcu is present.
-  if (Args.hasArg(options::OPT_miamcu))
-DAL->AddFlagArg(0, Opts->getOption(options::OPT_static));
+  if (Arg *Ar = Args.getLastArg(options::OPT_miamcu, options::OPT_mno_iamcu))
+if (Ar->getOption().matches(options::OPT_miamcu))
+  DAL->AddFlagArg(0, Opts->getOption(options::OPT_static));
 
 // Add a default value of -mlinker-version=, if one was given and the user
 // didn't specify one.
@@ -375,22 +376,24 @@ static llvm::Triple computeTargetTriple(
   }
 
   // Handle -miamcu flag.
-  if (Args.hasArg(options::OPT_miamcu)) {
-if (Target.get32BitArchVariant().getArch() != llvm::Triple::x86)
-  D.Diag(diag::err_drv_unsupported_opt_for_target) << "-miamcu"
-   << Target.str();
-
-if (A && !A->getOption().matches(options::OPT_m32))
-  D.Diag(diag::err_drv_argument_not_allowed_with)
-  << "-miamcu" << A->getBaseArg().getAsString(Args);
-
-Target.setArch(llvm::Triple::x86);
-Target.setArchName("i586");
-Target.setEnvironment(llvm::Triple::UnknownEnvironment);
-Target.setEnvironmentName("");
-Target.setOS(llvm::Triple::ELFIAMCU);
-Target.setVendor(llvm::Triple::UnknownVendor);
-Target.setVendorName("intel");
+  if (Arg *Ar = Args.getLastArg(options::OPT_miamcu, options::OPT_mno_iamcu)) {
+if (Ar->getOption().matches(options::OPT_miamcu)) {
+  if (Target.get32BitArchVariant().getArch() != llvm::Triple::x86)
+D.Diag(diag::err_drv_unsupported_opt_for_target) << "-miamcu"
+ << Target.str();
+
+  if (A && !A->getOption().matches(options::OPT_m32))
+D.Diag(diag::err_drv_argument_not_allowed_with)
+<< "-miamcu" << A->getBaseArg().getAsString(Args);
+
+  Target.setArch(llvm::Triple::x86);
+  Target.setArchName("i586");
+  Target.setEnvironment(llvm::Triple::UnknownEnvironment);
+  Target.setEnvironmentName("");
+  Target.setOS(llvm::Triple::ELFIAMCU);
+  Target.setVendor(llvm::Triple::UnknownVendor);
+  Target.setVendorName("intel");
+}
   }
 
   return Target;

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=273147=273146=273147=diff
==
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Mon Jun 20 05:31:39 2016
@@ -2243,10 +2243,12 @@ void Clang::AddX86TargetArgs(const ArgLi
   }
 
   // Set flags to support MCU ABI.
-  if (Args.hasArg(options::OPT_miamcu)) {
-CmdArgs.push_back("-mfloat-abi");
-CmdArgs.push_back("soft");
-CmdArgs.push_back("-mstack-alignment=4");
+  if (Arg *A = Args.getLastArg(options::OPT_miamcu, options::OPT_mno_iamcu)) {
+if (A->getOption().matches(options::OPT_miamcu)) {
+  CmdArgs.push_back("-mfloat-abi");
+  CmdArgs.push_back("soft");
+  CmdArgs.push_back("-mstack-alignment=4");
+}
   }
 }
 

Modified: cfe/trunk/test/Driver/miamcu-opt.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/miamcu-opt.c?rev=273147=273146=273147=diff
==
--- 

Re: [gentoo-musl] Re: Add support for musl-libc on Linux

2016-06-20 Thread Peter Smith via cfe-commits
Hello Lei,

I agree with Rafael that this is currently missing a few critical
things right now, especially in the llvm patch.

My (limited) understanding of musl is that it intends to support the
same interface as GNUEABI and GNUEABIHF, but it is obviously a
different implementation.

This is what I could find with a basic grep for GNUAEABI and working
out from there.

Clang patch
I'm assuming you are only intending to support Musl on linux, and not BSD.

ToolChains.cpp
- getDynamicLinker()
There is a Triple.getEnvironment() == llvm::triple::GNUEABIHF which
selects between ld-linux-armhf.so.3 or ld-linux.so.3. I think you'll
need ld-linux-armhf.so.3 for MUSLHF here as well.

LLVM patch
ARMSubtarget.h
- isTargetGNUAEABI()
I think you'll need to check all the callsites of this function, and
check what you want isTargetMusl() to do. At present I think you'll
want them to do the same thing in all cases except finding the
implementation. There looks to be a trade off between adding MUSCL and
MUSCLHF to isTargetGNUAEABI(), adding something like
isTargetGNUAEABIInterface() and adding isTargetMusl() to all the
callsites.

- isTargetEHABICompatible()
I'm making the assumption that musl supports the ARM exceptions EHABI,
if so you'll want to add MUSL and MUSLHF here.

- isTargetHardFloat()
You'll want to add MUSLHF here.

ARMTargetMachine.cpp
- computeTargetABI()
You'll want to add MUSL and MUSLHF alongside GNUEABI and GNUEABIHF in
the switch.

Hope this helps

Peter


On 18 June 2016 at 01:52, Rafael EspĂ­ndola  wrote:
> There are probably a few more places that need to be patched.
>
> In particular, take a look at lib/Target/ARM. There are things like
> computeTargetABI and isTargetHardFloat that probably need to be
> updated (and tested).
>
> CCing Peter for an arm opinion.
>
> Cheers,
> Rafael
>
>
> On 17 June 2016 at 05:50, Lei Zhang  wrote:
>> 2016-06-15 16:28 GMT+08:00 Lei Zhang :
>>> Here's another patch including test cases for various non-x86 archs,
>>> which should just work with my previous patches. ARM is left out
>>> purposely since it involves extra complexity. I'll work on it later.
>>
>> Hi,
>>
>> Here are another two patches which add support for ARM, with some test
>> cases included.
>>
>> They're a lot bigger than previous patches, and I'm not 100% sure if I
>> missed anything. Any comments are utterly welcome :)
>>
>>
>> Lei
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D21497: Fix test to specify C++03 (fails with C++11).

2016-06-20 Thread Paul Robinson via cfe-commits
probinson abandoned this revision.
probinson added a comment.

A proper fix is obviously better than patching the test!


http://reviews.llvm.org/D21497



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


Re: [PATCH] D21228: Deprecated (legacy) string literal conversion to 'char *' causes strange overloading resolution

2016-06-20 Thread Alexander Makarov via cfe-commits
a.makarov added a comment.

Ping.


http://reviews.llvm.org/D21228



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


[PATCH] D21517: clang-rename: add a -old-name option

2016-06-20 Thread Miklos Vajna via cfe-commits
vmiklos created this revision.
vmiklos added a reviewer: klimek.
vmiklos added a subscriber: cfe-commits.

This is similar to -offset with the following differences:

1) -offset can refer to local variables as well.

2) -old-name makes it easier to refer to e.g. ClassName::MemberName by
spelling out the fully qualified name, instead of having to use e.g.
grep to look up the exact offset.

In other words, -offset is great when clang-rename is invoked by e.g. an
IDE, but not really user-friendly when the tool is invoked by the user
from commandline.  That's the use case where -old-name is supposed to
improve the situation.

http://reviews.llvm.org/D21517

Files:
  clang-rename/USRFinder.cpp
  clang-rename/USRFinder.h
  clang-rename/USRFindingAction.cpp
  clang-rename/USRFindingAction.h
  clang-rename/tool/ClangRename.cpp
  test/clang-rename/ClassTestByName.cpp

Index: test/clang-rename/ClassTestByName.cpp
===
--- /dev/null
+++ test/clang-rename/ClassTestByName.cpp
@@ -0,0 +1,10 @@
+// RUN: cat %s > %t.cpp
+// RUN: clang-rename -old-name=Cla -new-name=Hector %t.cpp -i --
+// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
+class Cla { // CHECK: class Hector
+};
+
+int main() {
+  Cla *Pointer = 0; // CHECK: Hector *Pointer = 0;
+  return 0;
+}
Index: clang-rename/tool/ClangRename.cpp
===
--- clang-rename/tool/ClangRename.cpp
+++ clang-rename/tool/ClangRename.cpp
@@ -52,6 +52,11 @@
 "offset",
 cl::desc("Locates the symbol by offset as opposed to :."),
 cl::cat(ClangRenameCategory));
+static cl::opt
+OldName(
+"old-name",
+cl::desc("The fully qualified name of the symbol, if -offset is not used."),
+cl::cat(ClangRenameCategory));
 static cl::opt
 Inplace(
 "i",
@@ -96,7 +101,7 @@
   // Get the USRs.
   auto Files = OP.getSourcePathList();
   tooling::RefactoringTool Tool(OP.getCompilations(), Files);
-  rename::USRFindingAction USRAction(SymbolOffset);
+  rename::USRFindingAction USRAction(SymbolOffset, OldName);
 
   // Find the USRs.
   Tool.run(tooling::newFrontendActionFactory().get());
Index: clang-rename/USRFindingAction.h
===
--- clang-rename/USRFindingAction.h
+++ clang-rename/USRFindingAction.h
@@ -25,7 +25,7 @@
 namespace rename {
 
 struct USRFindingAction {
-  USRFindingAction(unsigned Offset) : SymbolOffset(Offset) {
+  USRFindingAction(unsigned Offset, const std::string ) : SymbolOffset(Offset), OldName(Name) {
   }
   std::unique_ptr newASTConsumer();
 
@@ -40,6 +40,7 @@
 
 private:
   unsigned SymbolOffset;
+  std::string OldName;
   std::string SpellingName;
   std::vector USRs;
 };
Index: clang-rename/USRFindingAction.cpp
===
--- clang-rename/USRFindingAction.cpp
+++ clang-rename/USRFindingAction.cpp
@@ -68,7 +68,7 @@
 SourceMgr.getMainFileID()).getLocWithOffset(SymbolOffset);
 if (!Point.isValid())
   return;
-const NamedDecl *FoundDecl = getNamedDeclAt(Context, Point);
+const NamedDecl *FoundDecl = getNamedDeclAt(Context, Point, OldName);
 if (FoundDecl == nullptr) {
   FullSourceLoc FullLoc(Point, SourceMgr);
   errs() << "clang-rename: could not find symbol at "
@@ -96,6 +96,7 @@
   }
 
   unsigned SymbolOffset;
+  std::string OldName;
   std::string *SpellingName;
   std::vector *USRs;
 };
@@ -106,6 +107,7 @@
   new NamedDeclFindingConsumer);
   SpellingName = "";
   Consumer->SymbolOffset = SymbolOffset;
+  Consumer->OldName = OldName;
   Consumer->USRs = 
   Consumer->SpellingName = 
   return std::move(Consumer);
Index: clang-rename/USRFinder.h
===
--- clang-rename/USRFinder.h
+++ clang-rename/USRFinder.h
@@ -25,10 +25,12 @@
 
 namespace rename {
 
-// Given an AST context and a point, returns a NamedDecl identifying the symbol
-// at the point. Returns null if nothing is found at the point.
+// Given an AST context and a point (or fully qualified name), returns a
+// NamedDecl identifying the symbol at the point. Returns null if nothing is
+// found at the point.
 const NamedDecl *getNamedDeclAt(const ASTContext ,
-const SourceLocation Point);
+const SourceLocation Point,
+const std::string );
 
 // Converts a Decl into a USR.
 std::string getUSRForDecl(const Decl *Decl);
Index: clang-rename/USRFinder.cpp
===
--- clang-rename/USRFinder.cpp
+++ clang-rename/USRFinder.cpp
@@ -35,9 +35,10 @@
   // \brief Finds the NamedDecl at a point in the source.
   // \param Point the location in the source to search for the NamedDecl.
   explicit NamedDeclFindingASTVisitor(const SourceManager ,
-  const SourceLocation